Skip to contentSkip to conversation

drm/vkms: set plane modifiers

PATCH Superseded José Expósito 2 participants 3 messages Dec 15, 2021 – Dec 16, 2021

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/vkms: set plane modifiers

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?commit_id=5aea1bc522f0874e6cc07f5120fbcf1736706536

---
 drivers/gpu/drm/vkms/vkms_plane.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/gpu/drm/vkms/vkms_plane.c +6 -1
index 32409e15244b..1666fa59189b 100644
@@ -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;
 
Signature · 1 line
2.25.1
#1 lore raw

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.

#2 lore raw
Quoted 2 lines · Simon Ser

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)

Quoted 9 lines

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#c.drm_plane_funcs
[2] https://github.com/JoseExposito/drm-sandbox/blob/main/in_formats.c
[3] https://lore.kernel.org/dri-devel/[email protected]/T/
[4] https://lists.freedesktop.org/archives/wayland-devel/2021-December/042072.html