From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.85.4 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795692698; b=5Zf53LBj8eeD3XOKQ3PBVdknsVTxV//ip99pVmOEzKDDh8ks1oqFpAcWyzK8TANS7vkT hWKtP2RSWhPaORzT1/ywoCYGAzznRHsk9oiyAR1GVxvDN5Bs6vgWCUbXnKoL/qaC3BpD8 vDCD9AMfBxA2JzQ/STJA3pC+heYLEqlC4zvT+6T3S5PkziH19kBsv8nfSDlbNMxSJqxqW nvX7v0ot0Y7TdbNrlfrMhdBi5rcqTnRetd+wxTDO3fzHPzmjPgfq/VDj0uW+sBesLTofQ f6pOlx0Xpj3VRYfpiPSHOUR25XD+wGwruwJD7dd2U9GxGdrkELdvodLH3j3NJeqnXLA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795692698; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:Date: Subject:MIME-Version:Content-Type:Content-Transfer-Encoding: Message-Id:References:In-Reply-To:To:Cc:X-Mailer: X-Last-TLS-Session-Version; bh=asX8stq/YveSMit8T5a15n/5rCFS5HWeKy1w4ifMTS0=; b=0jLe9lSvZj7dh7P552Bx8Nbh6bkJ3cdfNNO06Hc+e5d65n+DYnvLc1sC3Iy00RPkZasm 66OYcrfugQ7AOp+HhaT2xtQDFwnTfTYZc/BxU8V1CSWIb8jthXqq9VeWrKZYyfKz0y4Ov J15AwBmFDsaW+Rsh5yD2P6wJstnPZ/TMM1a5Y8BeyAMp9WJzu5hHIQ6ScZl0IFyUcjytk Y7w1wRbfbtWTiUIXTwElcz6a390rrsuFp72RYOZz5jcEJGmTHdtvCN+qzLi0OFrr62dMj SMurcNvimlGiHEwRwGVL7QW+LNeTJOHjdqpg1zyiU2945xq7Lt66c5T6wQGvjUDMi5Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=yTgZ5A+9; arc=none smtp.remote-ip=185.246.85.4 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64CB8606A326 for ; Thu, 26 Nov 2026 11:31:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 64CB8606A326 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=yTgZ5A+9 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 234D44E41798; Thu, 26 Nov 2026 11:31:36 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E3ECE60237; Thu, 26 Nov 2026 11:31:35 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 35E8F11E6B302; Thu, 26 Nov 2026 12:31:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1795692689; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=asX8stq/YveSMit8T5a15n/5rCFS5HWeKy1w4ifMTS0=; b=yTgZ5A+9BZwxMBH1w0DEPxO5NN1+u7fQTGGTWxelM9j561Vk96gWQrxz3RvL2G1hAS6DUW OJGdr6DEjxmj70gbFhrBNW2+5z4BxnRZ0i46bOVaaeok+HolqVAny2wOBxIbakqDrfA1mz DF7jk8cksuWNC4W5wi78N2RqCKjlysSvKo30nHBLnD5PipbXsx5lEb3JcIB6hX81Ob/css T5WmktKRpff9jPKyd3pnOZCoWH4kVetK1DI6eFLj5kxSSaE7FzOue2b0HfesyvA92t2c4b oeZ4sxjSOJygeVB1rvIi80I9jsEs5Mohf08kTso7KOU8tjWVe7nFNvcqorq0/A== From: Louis Chauvet Date: Thu, 26 Nov 2026 12:29:05 +0100 Subject: [PATCH v7 22/43] drm/vkms: Introduce configfs for plane color encoding X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261126-vkms-all-config-v7-22-21194cda2468@bootlin.com> References: <20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com> In-Reply-To: <20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com> To: Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , jose.exposito89@gmail.com, Jonathan Corbet , Oarora Etimis , Harry Wentland , Lucas De Marchi , =?utf-8?q?Ville_Syrj=C3=A4l=C3=A4?= , Randy Dunlap , Nick Desaulniers , Louis Chauvet , Shuah Khan , Miguel Ojeda , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Luca Ceresoli , Kory Maincent , sebastian.wick@redhat.com, victoria@system76.com, thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, llvm@lists.linux.dev X-Mailer: b4 0.17-dev X-Last-TLS-Session-Version: TLSv1.3 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 --- Documentation/ABI/testing/configfs-vkms | 18 +++++++ Documentation/gpu/vkms.rst | 8 ++- drivers/gpu/drm/vkms/vkms_configfs.c | 91 +++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/testing/configfs-vkms index 07ebb797617d..592df5602065 100644 --- a/Documentation/ABI/testing/configfs-vkms +++ b/Documentation/ABI/testing/configfs-vkms @@ -127,6 +127,24 @@ Description: exactly one rotation bit; reflection bits may be set in addition. +What: /sys/kernel/config/vkms//planes//supported_color_encodings +Date: Nov 2025 +Contact: dri-devel@lists.freedesktop.org +Description: + Available color encodings for the plane, as a bitmask: + 0x01 - YCBCR_BT601, 0x02 - YCBCR_BT709, 0x04 - YCBCR_BT2020. + The value may be written in decimal or hexadecimal (with + a 0x prefix) and is read back as a decimal number. + +What: /sys/kernel/config/vkms//planes//default_color_encoding +Date: Nov 2025 +Contact: dri-devel@lists.freedesktop.org +Description: + Default color encoding presented to userspace, using the + same bit values as supported_color_encodings. The value + must be a single bit: 1 - YCBCR_BT601, 2 - YCBCR_BT709, + 4 - YCBCR_BT2020. + What: /sys/kernel/config/vkms//planes//possible_crtcs Date: Nov 2025 Contact: dri-devel@lists.freedesktop.org diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index 610305483716..7206cd2b231a 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -87,7 +87,7 @@ Start by creating one or more planes:: sudo mkdir /config/vkms/my-vkms/planes/plane0 -Planes have 3 configurable attributes: +Planes have 5 configurable attributes: - type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those exposed by the "type" property of a plane) @@ -96,6 +96,12 @@ Planes have 3 configurable attributes: (same values as those exposed by the "rotation" property of a plane) - default_rotation: Default rotation presented to the userspace, same values as supported_rotations. +- supported_color_encodings: Available encodings for a plane, as a bitmask: + 0x01 YCBCR_BT601, 0x02 YCBCR_BT709, 0x04 YCBCR_BT2020 (same values as those exposed + by the COLOR_ENCODING property of a plane). If set, supported_color_range + must be set too. +- default_color_encoding: Default color encoding presented to the userspace, same + values as supported_color_encodings Continue by creating one or more CRTCs:: diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c index 5c62797627c1..c6efc6db64c4 100644 --- a/drivers/gpu/drm/vkms/vkms_configfs.c +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -9,6 +9,14 @@ #include "vkms_configfs.h" #include "vkms_connector.h" +/** + * VKMS_SUPPORTED_COLOR_ENCODINGS - Bitmask of all supported color encodings in VKMS + */ +#define VKMS_SUPPORTED_COLOR_ENCODINGS ( \ + BIT(DRM_COLOR_YCBCR_BT601) | \ + BIT(DRM_COLOR_YCBCR_BT709) | \ + BIT(DRM_COLOR_YCBCR_BT2020)) + /* To avoid registering configfs more than once or unregistering on error */ static bool is_configfs_registered; @@ -402,14 +410,97 @@ static ssize_t plane_default_rotation_store(struct config_item *item, return count; } +static ssize_t plane_supported_color_encodings_show(struct config_item *item, char *page) +{ + struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item); + unsigned int supported_color_encodings; + + scoped_guard(mutex, &plane->dev->config->lock) + supported_color_encodings = vkms_config_plane_get_supported_color_encodings(plane->config); + + return sprintf(page, "%u\n", supported_color_encodings); +} + +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; + unsigned int val = 0; + + ret = kstrtouint(page, 0, &val); + if (ret) + return ret; + + /* Should be a supported value */ + if (val & ~(VKMS_SUPPORTED_COLOR_ENCODINGS)) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->config->lock) { + if (plane->dev->enabled) + return -EBUSY; + + vkms_config_plane_set_supported_color_encodings(plane->config, val); + } + + return count; +} + +static ssize_t plane_default_color_encoding_show(struct config_item *item, char *page) +{ + struct vkms_configfs_plane *plane = plane_item_to_vkms_configfs_plane(item); + unsigned int default_color_encoding; + + scoped_guard(mutex, &plane->dev->config->lock) + default_color_encoding = BIT(vkms_config_plane_get_default_color_encoding(plane->config)); + + return sprintf(page, "%u\n", default_color_encoding); +} + +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; + unsigned int val = 0; + + ret = kstrtouint(page, 0, &val); + if (ret) + return ret; + + /* Should be a supported value */ + if (val & ~VKMS_SUPPORTED_COLOR_ENCODINGS) + return -EINVAL; + + /* Ensure val is a single bit set */ + if (!is_power_of_2(val)) + return -EINVAL; + + /* Convert bit position to the proper enum value */ + val = __ffs(val) + DRM_COLOR_YCBCR_BT601; + + scoped_guard(mutex, &plane->dev->config->lock) { + if (plane->dev->enabled) + return -EBUSY; + + vkms_config_plane_set_default_color_encoding(plane->config, val); + } + + return count; +} + CONFIGFS_ATTR(plane_, type); CONFIGFS_ATTR(plane_, supported_rotations); CONFIGFS_ATTR(plane_, default_rotation); +CONFIGFS_ATTR(plane_, supported_color_encodings); +CONFIGFS_ATTR(plane_, default_color_encoding); static struct configfs_attribute *plane_item_attrs[] = { &plane_attr_type, &plane_attr_supported_rotations, &plane_attr_default_rotation, + &plane_attr_supported_color_encodings, + &plane_attr_default_color_encoding, NULL, }; -- 2.56.0