From nobody Mon Feb 9 07:23:29 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 723D93161A3 for ; Mon, 22 Dec 2025 10:11:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766398316; cv=none; b=pJPDSEqvmmE7f/TocPmgH4oK9speVPAByeqjiZVf8tblzT/c5BoztoUFQxFWppFMZgar/Sj+y2SmLG2aGox5HQ+A93m7VNXkBgTJ2OJCD+wAqXWrUWTE9mTPv5J2aXxdnMpzmGSETcLSV+B9Qn6woX6QZ1i+tib2SH3wPWCWL2w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766398316; c=relaxed/simple; bh=KrbZiegF6pw+Vnpcarfhl+XKg7MwzTvyPUzkLZmmKLU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MXdNIzSp8qRSRtRXipw3VVJy5q13iZIHY0DAu94jKWD8subQ3FDfhmQZZCqeDZxAwQ3E4duALDTX3CH4ldd6r9H1eRRM9+wOhnye5iiXYtNHmX5yesdZvrH6R/4HSoFrlLD2Kw5YJa9b5zgT69YtXbIuNgB9ilROzgrcAJwirsc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Dci9uPPq; arc=none smtp.client-ip=185.171.202.116 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.b="Dci9uPPq" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 1F73CC1AE05; Mon, 22 Dec 2025 10:11:28 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 17AFD606C1; Mon, 22 Dec 2025 10:11:53 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 87D2610AB01AB; Mon, 22 Dec 2025 11:11:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1766398312; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=naVKzE5jKov3A6hauaUpolq/4+6MGPF41QUoRj+IiPw=; b=Dci9uPPqNuTXrGcYhGTxiH2MAYqM4wrRhaDeXRDDCvMZkGlWzrm/sagZfJgjR48GtWHj7r d6FsoyCV8sdQazEsnpCFAHfzwTHwrSzWN4f1+rRVgRYZ32k//ozu+UzV9abqJgEHqZ0y+h gfC83FgiTG2mVRJow0q62RaTs88/PuyJBoQwTXl2UC5hC+y4XQWIQrztU9TNG1RC1EUvKX wX3q4LnBHmPqIj87FA3o2zvCeaqGYy2Ps9Q8IPDzOKQqvzWfgcMMwQvqJQeAqmdFhx7bsS lnopMmDJODQt9VqWIuenz/Ehm1NO2Jc/mx6ATIxu9qPX5NuiC2f3XMPydw+HcQ== From: Louis Chauvet Date: Mon, 22 Dec 2025 11:11:15 +0100 Subject: [PATCH v3 13/33] drm/vkms: Introduce configfs for plane color encoding Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251222-vkms-all-config-v3-13-ba42dc3fb9ff@bootlin.com> References: <20251222-vkms-all-config-v3-0-ba42dc3fb9ff@bootlin.com> In-Reply-To: <20251222-vkms-all-config-v3-0-ba42dc3fb9ff@bootlin.com> To: Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , jose.exposito89@gmail.com, Jonathan Corbet Cc: victoria@system76.com, sebastian.wick@redhat.com, victoria@system76.com, airlied@gmail.com, thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Louis Chauvet X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6834; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=KrbZiegF6pw+Vnpcarfhl+XKg7MwzTvyPUzkLZmmKLU=; b=owEBiQJ2/ZANAwAIASCtLsZbECziAcsmYgBpSRlBBHucMxyz9B1Nn5jFC51nGjuwtJ9e7GWLC lRa8oeoRfWJAk8EAAEIADkWIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCaUkZQRsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMSwyLDIACgkQIK0uxlsQLOIb5A/+OsORggP4LYB/5rR+ArrFPjDeihGhT3n 8fVvekAlwgCa6Mrc9lwVv9Q0Mar/WW4UzqXPnqLb7p2wksZyY5RgtmGHxC1MMlpKWEwJ4s7XxkZ r0wpEJrItHjOKC7L0qVfCA+hx5x9RrGibn3jq9sBCJk7dwVDeBAHnSMqtc5WSJGu6XBi8SSIQBI Uv7xeDBqJW1koTnR+a+fbQ0BR7Axy1H0mAST3/1yCn/QZaMchtbHnAmD5PS+Z8toLCoZBP2Mn3b H3K+iHcMbb58s3CGf4mkbyTpmGZzENBjpWnBj3/oH5WetwtqejsG3UHUQ80mXAidhuOjSRf8Qka cEfM+O5F++WR+4nzWZiEH0pm4TzX0PavoGfQ+t6brz0ERRLkYYpxKQHcFWp7rcSd6Boy6HCf2Gk aIhpKKI3wFGw2s/ZigMhbajzBMPX7pz/CNVAhpRIN50Tu5dTu8Rf1Uc8QkWCs5r8QRL9L8EYhE5 hXrZXykc0nPzA7tbFDxc84MKXrWSKa19U//rZvrDlrTeaEsnXHeKBl+mv+o9UTwFe9XiDNGbNMj iD6tYgc4zVpd6FRt7ieRM3A2ovHKh5THRpMwvoDn6wZDHryQXyOVR2Yw2pnL6QyoNvcB2RgRQ8Y hlU69DmHP24MUqgzX8Yd2izgAsoJZJolaGk+46vy0iYk7gdOY21U= X-Developer-Key: i=louis.chauvet@bootlin.com; a=openpgp; fpr=8B7104AE9A272D6693F527F2EC1883F55E0B40A5 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 | 14 +++++ Documentation/gpu/vkms.rst | 8 ++- drivers/gpu/drm/vkms/vkms_configfs.c | 97 +++++++++++++++++++++++++++++= ++++ 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/configfs-vkms b/Documentation/ABI/te= sting/configfs-vkms index 9b74375bbf35..242aae91289c 100644 --- 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. =20 +What: /sys/kernel/config/vkms//planes//supported_color_enc= oding +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. + +What: /sys/kernel/config/vkms//planes//default_color_encod= ing +Date: Nov 2025 +Contact: dri-devel@lists.freedesktop.org +Description: + Default color encoding presented to userspace, same + values as supported_color_encoding. + 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 7fd746dd6ee2..0d4dae3ba8e5 100644 --- a/Documentation/gpu/vkms.rst +++ b/Documentation/gpu/vkms.rst @@ -87,7 +87,7 @@ Start by creating one or more planes:: =20 sudo mkdir /config/vkms/my-vkms/planes/plane0 =20 -Planes have 4 configurable attributes: +Planes have 6 configurable attributes: =20 - type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those exposed by the "type" property of a plane) @@ -97,6 +97,12 @@ Planes have 4 configurable attributes: (same values as those exposed by the "rotation" property of a plane) - default_rotation: Default rotation presented to the userspace, same valu= es as possible_rotations. +- supported_color_encodings: Available encodings for a plane, as a bitmask: + 0x01 YCBCR_BT601, 0x02 YCBCR_BT709, 0x04 YCBCR_BT2020 (same values as th= ose 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 userspac= e, same + values as supported_color_encodings =20 Continue by creating one or more CRTCs:: =20 diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vk= ms_configfs.c index bcc3e222e6b3..755978b17c95 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" =20 +/** + * VKMS_SUPPORTED_COLOR_ENCODINGS - Bitmask of all supported color encodin= gs 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; =20 @@ -446,16 +454,105 @@ static ssize_t plane_default_rotation_store(struct c= onfig_item *item, return count; } =20 +static ssize_t plane_supported_color_encodings_show(struct config_item *it= em, char *page) +{ + struct vkms_configfs_plane *plane =3D plane_item_to_vkms_configfs_plane(i= tem); + unsigned int supported_color_encodings; + + scoped_guard(mutex, &plane->dev->lock) + supported_color_encodings =3D vkms_config_plane_get_supported_color_enco= dings(plane->config); + + return sprintf(page, "%u", supported_color_encodings); +} + +static ssize_t plane_supported_color_encodings_store(struct config_item *i= tem, + const char *page, size_t count) +{ + struct vkms_configfs_plane *plane =3D plane_item_to_vkms_configfs_plane(i= tem); + int ret, val =3D 0; + + ret =3D 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)) =3D=3D 0) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->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; + unsigned int default_color_encoding; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + scoped_guard(mutex, &plane->dev->lock) + default_color_encoding =3D BIT(vkms_config_plane_get_default_color_encod= ing(plane->config)); + + return sprintf(page, "%u", 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 =3D plane_item_to_vkms_configfs_plane(i= tem); + int ret, val =3D 0; + + ret =3D 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) =3D=3D 0) + 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 =3D __ffs(val) + DRM_COLOR_YCBCR_BT601; + + scoped_guard(mutex, &plane->dev->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_, name); CONFIGFS_ATTR(plane_, supported_rotations); CONFIGFS_ATTR(plane_, default_rotation); +CONFIGFS_ATTR(plane_, supported_color_encodings); +CONFIGFS_ATTR(plane_, default_color_encoding); =20 static struct configfs_attribute *plane_item_attrs[] =3D { &plane_attr_type, &plane_attr_name, &plane_attr_supported_rotations, &plane_attr_default_rotation, + &plane_attr_supported_color_encodings, + &plane_attr_default_color_encoding, NULL, }; =20 --=20 2.51.2