]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/vkms: Allow to configure the plane type via configfs
authorLouis Chauvet <louis.chauvet@bootlin.com>
Thu, 16 Oct 2025 17:56:06 +0000 (19:56 +0200)
committerLuca Ceresoli <luca.ceresoli@bootlin.com>
Wed, 22 Oct 2025 11:19:25 +0000 (13:19 +0200)
When a plane is created, add a `type` file to allow to set the type:

 - 0 overlay
 - 1 primary
 - 2 cursor

Tested-by: Mark Yacoub <markyacoub@google.com>
Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com>
Reviewed-by: Harry Wentland <harry.wentland@amd.com>
Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
Co-developed-by: José Expósito <jose.exposito89@gmail.com>
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Link: https://lore.kernel.org/r/20251016175618.10051-5-jose.exposito89@gmail.com
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Documentation/gpu/vkms.rst
drivers/gpu/drm/vkms/vkms_configfs.c

index c0c892e4e27c9ba33509ec4619cf17f4baf0e2a5..dd880ce6811c2fd98161908bf8357b975d909f57 100644 (file)
@@ -84,6 +84,11 @@ Start by creating one or more planes::
 
   sudo mkdir /config/vkms/my-vkms/planes/plane0
 
+Planes have 1 configurable attribute:
+
+- type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those
+  exposed by the "type" property of a plane)
+
 Once you are done configuring the VKMS instance, enable it::
 
   echo "1" | sudo tee /config/vkms/my-vkms/enabled
index a7c705e00e4c642641e3401a1069d594ca71a60f..398755127759dc9bb42635273a4030df883f377d 100644 (file)
@@ -55,6 +55,51 @@ struct vkms_configfs_plane {
 #define plane_item_to_vkms_configfs_plane(item) \
        container_of(to_config_group((item)), struct vkms_configfs_plane, group)
 
+static ssize_t plane_type_show(struct config_item *item, char *page)
+{
+       struct vkms_configfs_plane *plane;
+       enum drm_plane_type type;
+
+       plane = plane_item_to_vkms_configfs_plane(item);
+
+       scoped_guard(mutex, &plane->dev->lock)
+               type = vkms_config_plane_get_type(plane->config);
+
+       return sprintf(page, "%u", type);
+}
+
+static ssize_t plane_type_store(struct config_item *item, const char *page,
+                               size_t count)
+{
+       struct vkms_configfs_plane *plane;
+       enum drm_plane_type type;
+
+       plane = plane_item_to_vkms_configfs_plane(item);
+
+       if (kstrtouint(page, 10, &type))
+               return -EINVAL;
+
+       if (type != DRM_PLANE_TYPE_OVERLAY && type != DRM_PLANE_TYPE_PRIMARY &&
+           type != DRM_PLANE_TYPE_CURSOR)
+               return -EINVAL;
+
+       scoped_guard(mutex, &plane->dev->lock) {
+               if (plane->dev->enabled)
+                       return -EBUSY;
+
+               vkms_config_plane_set_type(plane->config, type);
+       }
+
+       return (ssize_t)count;
+}
+
+CONFIGFS_ATTR(plane_, type);
+
+static struct configfs_attribute *plane_item_attrs[] = {
+       &plane_attr_type,
+       NULL,
+};
+
 static void plane_release(struct config_item *item)
 {
        struct vkms_configfs_plane *plane;
@@ -74,6 +119,7 @@ static struct configfs_item_operations plane_item_operations = {
 };
 
 static const struct config_item_type plane_item_type = {
+       .ct_attrs       = plane_item_attrs,
        .ct_item_ops    = &plane_item_operations,
        .ct_owner       = THIS_MODULE,
 };