When a plane is created, add a `type` file to allow to set the type: - 0 overlay - 1 primary - 2 cursor Co-developed-by: Louis Chauvet <louis.chauvet@xxxxxxxxxxx> Signed-off-by: Louis Chauvet <louis.chauvet@xxxxxxxxxxx> Signed-off-by: José Expósito <jose.exposito89@xxxxxxxxx> --- Documentation/gpu/vkms.rst | 5 ++++ drivers/gpu/drm/vkms/vkms_configfs.c | 43 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index bf23d0da33fe..a87e0925bebb 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -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 diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c index 4f9d3341e6c0..c2e1eef75906 100644 --- a/drivers/gpu/drm/vkms/vkms_configfs.c +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -55,6 +55,48 @@ 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; + + plane = plane_item_to_vkms_configfs_plane(item); + + guard(mutex)(&plane->dev->lock); + return sprintf(page, "%u", vkms_config_plane_get_type(plane->config)); +} + +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; + + 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; @@ -73,6 +115,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, }; -- 2.48.1