[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240814-google-config-fs-v1-6-8363181907a6@bootlin.com>
Date: Wed, 14 Aug 2024 17:15:53 +0200
From: Louis Chauvet <louis.chauvet@...tlin.com>
To: Rodrigo Siqueira <rodrigosiqueiramelo@...il.com>,
Melissa Wen <melissa.srw@...il.com>,
Maíra Canal <mairacanal@...eup.net>,
Haneen Mohammed <hamohammed.sa@...il.com>, Daniel Vetter <daniel@...ll.ch>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>
Cc: dri-devel@...ts.freedesktop.org, arthurgrillo@...eup.net,
linux-kernel@...r.kernel.org, jeremie.dautheribes@...tlin.com,
miquel.raynal@...tlin.com, thomas.petazzoni@...tlin.com,
seanpaul@...gle.com, nicolejadeyee@...gle.com,
Louis Chauvet <louis.chauvet@...tlin.com>
Subject: [PATCH RFC 6/7] drm/vkms: Add color range in ConfigFS
To allows the userspace to test many hardware configuration, introduce a
new interface to configure the available color ranges per planes. VKMS
supports multiple color ranges, so the userspace can choose any
combination.
The supported color ranges are configured by writing a color range bitmask
to the file `supported_color_ranges` and the default color range is
chosen by writing a color encoding bitmask to `default_color_range`.
The current interface is:
/config/vkms
DEVICE_1
┣━ enable
┣━ planes
┃ ┗━ PLANE_1
┃ ┣━ type
┃ ┣━ supported_rotations
┃ ┣━ supported_color_encoding
┃ ┣━ supported_color_ranges
┃ ┣━ default_rotation
┃ ┣━ default_color_encoding
┃ ┗━ default_color_range
DEVICE_2
┗━ ditto
Signed-off-by: Louis Chauvet <louis.chauvet@...tlin.com>
---
drivers/gpu/drm/vkms/vkms_configfs.c | 103 +++++++++++++++++++++++++++++++++++
1 file changed, 103 insertions(+)
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index a3dab5986882..aabc83283626 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -152,6 +152,105 @@ static ssize_t plane_default_rotation_store(struct config_item *item,
return count;
}
+static ssize_t plane_color_range_show(struct config_item *item, char *page)
+{
+ struct vkms_config_plane *plane;
+ unsigned int plane_type;
+ struct vkms_configfs_device *vkms_configfs = plane_item_to_vkms_configfs_device(item);
+
+ mutex_lock(&vkms_configfs->lock);
+ plane = plane_item_to_vkms_configfs_plane(item)->vkms_config_plane;
+ plane_type = plane->supported_color_range;
+ mutex_unlock(&vkms_configfs->lock);
+
+ return sprintf(page, "%u", plane_type);
+}
+
+static ssize_t plane_color_range_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_config_plane *plane;
+ struct vkms_configfs_device *vkms_configfs = plane_item_to_vkms_configfs_device(item);
+ int ret, val = 0;
+
+ ret = kstrtouint(page, 10, &val);
+ if (ret)
+ return ret;
+
+ /* Should be a supported value */
+ if (val & ~(BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE)))
+ return -EINVAL;
+ /* Should at least provide one color range */
+ if ((val & (BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE))) == 0)
+ return -EINVAL;
+
+ mutex_lock(&vkms_configfs->lock);
+
+ plane = plane_item_to_vkms_configfs_plane(item)->vkms_config_plane;
+
+ /* Ensures that the default rotation is included in supported rotation */
+ if (vkms_configfs->enabled || (val & plane->default_color_range) !=
+ plane->default_color_range) {
+ mutex_unlock(&vkms_configfs->lock);
+ return -EINVAL;
+ }
+ plane->supported_color_range = val;
+ mutex_unlock(&vkms_configfs->lock);
+
+ return count;
+}
+
+static ssize_t plane_default_color_range_show(struct config_item *item, char *page)
+{
+ struct vkms_config_plane *plane;
+ unsigned int plane_type;
+ struct vkms_configfs_device *vkms_configfs = plane_item_to_vkms_configfs_device(item);
+
+ mutex_lock(&vkms_configfs->lock);
+ plane = plane_item_to_vkms_configfs_plane(item)->vkms_config_plane;
+ plane_type = plane->default_color_range;
+ mutex_unlock(&vkms_configfs->lock);
+
+ return sprintf(page, "%u", plane_type);
+}
+
+static ssize_t plane_default_color_range_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_config_plane *plane;
+ struct vkms_configfs_device *vkms_configfs = plane_item_to_vkms_configfs_device(item);
+ int ret, val = 0;
+
+ ret = kstrtouint(page, 10, &val);
+ if (ret)
+ return ret;
+
+ /* Should be a supported value */
+ if (val & ~(BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE)))
+ return -EINVAL;
+ /* Should at least provide one color range */
+ if ((val & (BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) |
+ BIT(DRM_COLOR_YCBCR_FULL_RANGE))) == 0)
+ return -EINVAL;
+
+ mutex_lock(&vkms_configfs->lock);
+
+ plane = plane_item_to_vkms_configfs_plane(item)->vkms_config_plane;
+
+ /* Ensures that the default rotation is included in supported rotation */
+ if (vkms_configfs->enabled || (val & plane->supported_color_range) != val) {
+ mutex_unlock(&vkms_configfs->lock);
+ return -EINVAL;
+ }
+ plane->default_color_range = val;
+ mutex_unlock(&vkms_configfs->lock);
+
+ return count;
+}
+
static ssize_t plane_supported_color_encoding_show(struct config_item *item, char *page)
{
struct vkms_config_plane *plane;
@@ -258,6 +357,8 @@ static ssize_t plane_default_color_encoding_store(struct config_item *item,
CONFIGFS_ATTR(plane_, type);
CONFIGFS_ATTR(plane_, supported_rotations);
CONFIGFS_ATTR(plane_, default_rotation);
+CONFIGFS_ATTR(plane_, color_range);
+CONFIGFS_ATTR(plane_, default_color_range);
CONFIGFS_ATTR(plane_, supported_color_encoding);
CONFIGFS_ATTR(plane_, default_color_encoding);
@@ -265,6 +366,8 @@ static struct configfs_attribute *plane_attrs[] = {
&plane_attr_type,
&plane_attr_supported_rotations,
&plane_attr_default_rotation,
+ &plane_attr_color_range,
+ &plane_attr_default_color_range,
&plane_attr_supported_color_encoding,
&plane_attr_default_color_encoding,
NULL,
--
2.44.2
Powered by blists - more mailing lists