Where no modifiers are exposed, usually linear modifier is assumed. However, userspace code is starting to expect IN_FORMATS even when the only supported modifiers are linear [1].
To avoid possible issues, explicitly set the DRM_FORMAT_MOD_LINEAR modifier.
[1] https://gitlab.freedesktop.org/wayland/weston/-/merge_requests/599/diffs?com...
Suggested-by: Chris Healy cphealy@gmail.com Signed-off-by: José Expósito jose.exposito89@gmail.com --- drivers/gpu/drm/vkms/vkms_plane.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 32409e15244b..1666fa59189b 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -20,6 +20,11 @@ static const u32 vkms_plane_formats[] = { DRM_FORMAT_XRGB8888 };
+static const u64 vkms_plane_modifiers[] = { + DRM_FORMAT_MOD_LINEAR, + DRM_FORMAT_MOD_INVALID +}; + static struct drm_plane_state * vkms_plane_duplicate_state(struct drm_plane *plane) { @@ -189,7 +194,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 1 << index, &vkms_plane_funcs, formats, nformats, - NULL, type, NULL); + vkms_plane_modifiers, type, NULL); if (IS_ERR(plane)) return plane;
You'll need to set the format_mod_supported hook as well, otherwise the kernel will expose a bogus IN_FORMATS prop with one modifier and zero formats.
On Wed, Dec 15, 2021 at 05:23:10PM +0000, Simon Ser wrote:
You'll need to set the format_mod_supported hook as well, otherwise the kernel will expose a bogus IN_FORMATS prop with one modifier and zero formats.
Hi Simon,
Thank you very much for reviewing this patch, I just started learning about DRM and this kind of reviews are really helpful :)
I was a bit confused by the docs[1]: (*stars* added in the relevant parts)
format_mod_supported:
This *optional* hook is used for the DRM to determine if the given format/modifier combination is valid for the plane. This allows the DRM to generate the correct format bitmask (which formats apply to which modifier), and to valdiate modifiers at atomic_check time.
*If not present*, then any modifier in the plane’s modifier list is allowed with any of the plane’s formats.
How I read it: "format_mod_supported" can be ignored where no filtering is intended.
Looking at "create_in_format_blob" this does not look like a bug... But I am not sure. You probably know the answer. Whether the anwser is to chage the docs or "create_in_format_blob" I can send a patch.
For what is worth, after extrating the relevant bits from Weston's "drm_plane_populate_formats" function to my test program [2], formats are not listed if "format_mod_supported" is not implemented. The same applies to drm_info. So, for the moment I emailed v2 implementing "format_mod_supported" [3].
By the way, this could be related to [4], see commit b36a6bb8a151c056e1046e9d5b1192d90d9941c9. If we decided that the docs are wrong I can send a patch as well.
Thanks again for your input, Jose
[1] https://www.kernel.org/doc/html/latest/gpu/drm-kms.html?highlight=in_formats... [2] https://github.com/JoseExposito/drm-sandbox/blob/main/in_formats.c [3] https://lore.kernel.org/dri-devel/20211216170140.15803-1-jose.exposito89@gma... [4] https://lists.freedesktop.org/archives/wayland-devel/2021-December/042072.ht...
dri-devel@lists.freedesktop.org