public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/vkms: set plane modifiers
@ 2021-12-15 16:42 José Expósito
  2021-12-15 17:23 ` Simon Ser
  0 siblings, 1 reply; 3+ messages in thread
From: José Expósito @ 2021-12-15 16:42 UTC (permalink / raw)
  To: rodrigosiqueiramelo
  Cc: melissa.srw, hamohammed.sa, daniel, airlied, dri-devel,
	linux-kernel, cphealy, José Expósito

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

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;
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/vkms: set plane modifiers
  2021-12-15 16:42 [PATCH] drm/vkms: set plane modifiers José Expósito
@ 2021-12-15 17:23 ` Simon Ser
  2021-12-16 17:05   ` José Expósito
  0 siblings, 1 reply; 3+ messages in thread
From: Simon Ser @ 2021-12-15 17:23 UTC (permalink / raw)
  To: José Expósito
  Cc: rodrigosiqueiramelo, hamohammed.sa, airlied, linux-kernel,
	dri-devel, melissa.srw, cphealy

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/vkms: set plane modifiers
  2021-12-15 17:23 ` Simon Ser
@ 2021-12-16 17:05   ` José Expósito
  0 siblings, 0 replies; 3+ messages in thread
From: José Expósito @ 2021-12-16 17:05 UTC (permalink / raw)
  To: Simon Ser
  Cc: rodrigosiqueiramelo, hamohammed.sa, airlied, linux-kernel,
	dri-devel, melissa.srw, cphealy

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-16 17:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-15 16:42 [PATCH] drm/vkms: set plane modifiers José Expósito
2021-12-15 17:23 ` Simon Ser
2021-12-16 17:05   ` José Expósito

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox