Re: [PATCH v3 13/33] drm/vkms: Introduce configfs for plane color encoding

Luca Ceresoli
2025-12-23T12:56:17Z

On Mon Dec 22, 2025 at 11:11 AM CET, Louis Chauvet wrote:
> To allows the userspace to test many hardware configuration, introduce a
> new interface to configure the available color encoding per planes. VKMS
> supports multiple color encoding, so the userspace can choose any
> combination.
>
> The supported color encoding are configured by writing a color encoding
> bitmask to the file `supported_color_encoding` and the default color
> encoding is chosen by writing a color encoding bitmask to
> `default_color_encoding`.
>
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>

> --- a/Documentation/ABI/testing/configfs-vkms
> +++ b/Documentation/ABI/testing/configfs-vkms
> @@ -124,6 +124,20 @@ Description:
> Default rotation presented to userspace, same values as
> possible_rotations.
>
> +What: /sys/kernel/config/vkms/<device>/planes/<plane>/supported_color_encoding
^
supported_color_encodings (final 's').

> --- a/Documentation/gpu/vkms.rst
> +++ b/Documentation/gpu/vkms.rst

> +static ssize_t plane_supported_color_encodings_store(struct config_item *item,
> + const char *page, size_t count)
> +{
> + struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
> + int ret, val = 0;
> +
> + ret = kstrtouint(page, 10, &val);
> + if (ret)
> + return ret;
> +
> + /* Should be a supported value */
> + if (val & ~(VKMS_SUPPORTED_COLOR_ENCODINGS))
> + return -EINVAL;
> + /* Should at least provide one color range */
^ encoding

> +static ssize_t plane_default_color_encoding_show(struct config_item *item, char *page)
> +{
> + struct vkms_configfs_plane *plane;
> + unsigned int default_color_encoding;
> +
> + plane = plane_item_to_vkms_configfs_plane(item);

Set on declare, for consistency (and conciseness).

> +static ssize_t plane_default_color_encoding_store(struct config_item *item,
> + const char *page, size_t count)
> +{
> + struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item);
> + int ret, val = 0;
> +
> + ret = kstrtouint(page, 10, &val);
> + if (ret)
> + return ret;
> +
> + /* Should be a supported value */
> + if (val & ~VKMS_SUPPORTED_COLOR_ENCODINGS)
> + return -EINVAL;
> + /* Should at least provide one color range */
> + if ((val & VKMS_SUPPORTED_COLOR_ENCODINGS) == 0)
> + return -EINVAL;

This if() is redundant, the is_power_of_2() implies it because you already
ruled out any unsupported bit. Also, the comment is wrong. You can drop
these 3 lines entirely.

Luca

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering