From nobody Mon Feb 9 17:05:30 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 35D48327206 for ; Wed, 29 Oct 2025 14:37:19 +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=1761748641; cv=none; b=UpHfi07vY+b4/EQB8awB5xpOgw7u3+QndAKwZCPY6JwhZeIVkbOV3bdv89NojODt43xrYxUDCuIe9E6BcuEC+9AAzS29dSiVPWW6+mUdF9Bx7i9pbB2aU46SFaJ/PFcIkDW2oE+TDq1Qh3gMtbxl5gVxcPOCtyeaLyVxOWBnf5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761748641; c=relaxed/simple; bh=C/MMRwVv7tqxhyIue1VDDpDHYOcgFuMbnkd6mU2hgRk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=luJin8+o71Vof3F5gYbxgmGFkOC6cEglVZFgRSX3DsZzwfE7OgDiDw9TYMn9vcuZGGEL2zw8PNmqzS/GlPBjuKv+JkKF+bdSXf30UJM8/MOjY7qvDr5bH2bRxXqJbJbF2L+QeUfWInln3m4HwYowH/dO+6ugT3J/pcd1wGL4llE= 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=zJj11w7S; 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="zJj11w7S" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 880C3C0DA85; Wed, 29 Oct 2025 14:36:57 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E0B31606E8; Wed, 29 Oct 2025 14:37:17 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id A5807117F813D; Wed, 29 Oct 2025 15:37:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761748637; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=+evWkGwW+11FOg/3gUJ1wDOagGB2wDut1Bio9XWm4W4=; b=zJj11w7SNSYwFYSv9EcCygXSsMPf7NZ0TTou9dRom3cMxkLBnP7hbY8HM3QdaDOdeWmIms F/A0UWrudYz8bOHluceZ99Cei2mthex1d3+V+NeH9dGDYvRXQXRspbJPRMsq1OGSRUD3tU YoxmafnU3Lte9t7NA4r/6pLUrJeRpX/qa+YcGcGEZSlUz2mMqvevgAXXX///drvh0eXF7u 91YHoxDFnx30OCyORGxBYtUKHzFzf15pEBPhSWdB4dNyzoF7VQwt0p2MLURx8Yi0C6YK3c Xyqr7Hw1a3HA6yqaCq1mghAELviWy178UI7WtfokF/7txqRgVmFVOSdXtTZWrg== From: Louis Chauvet Date: Wed, 29 Oct 2025 15:36:52 +0100 Subject: [PATCH RESEND v2 15/32] drm/vkms: Introduce configfs for plane color range 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: <20251029-vkms-all-config-v2-15-a49a2d4cba26@bootlin.com> References: <20251029-vkms-all-config-v2-0-a49a2d4cba26@bootlin.com> In-Reply-To: <20251029-vkms-all-config-v2-0-a49a2d4cba26@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=5958; i=louis.chauvet@bootlin.com; h=from:subject:message-id; bh=C/MMRwVv7tqxhyIue1VDDpDHYOcgFuMbnkd6mU2hgRk=; b=owEBbQKS/ZANAwAKASCtLsZbECziAcsmYgBpAiZ8mCOZSmwAYSOfrN7feGUYXPMdTreMd/Zz9 isp4j9IoZaJAjMEAAEKAB0WIQRPj7g/vng8MQxQWQQgrS7GWxAs4gUCaQImfAAKCRAgrS7GWxAs 4iYUD/sFZo9/1shihaPLulldv/eYRBnjsHHqZaF8uEiYpFDNgMCpv+VXMOjAzduR1Gp/h7CFO9X HRAE4N/1MZXzx4KEsgfhM5Mv2dK0Pi8AszgAVdL7tBr+cKS9oLRC8zsx9Ligl45yVKNYAz/vt6A NGIXnWq4gVPsjOmkUSW/pTDnX/GlngWXWDa5E/e9LIKC9X5H8xvVwi1Zf7cR4KapKf+O+TPvAm9 2PdLnrtAc7s7iQjZimrcQ4GBNfpifDlU8GZF6p3dOpRFSUUH29sxn7lU6wg7hXhlU6Bx8GMU0Lq lcg8Wq3DMrTborx4RFGcMG3RbuIRgjIdbLyNZTuBzVNcxnS9eGVeizdr2MKBIYNAh0zJEs9u6Rw clfqME5Wcla/e0SBcxFyw95aaeLPpGYeQ9j9HG5Egc4jgx6hgxbrFUx52Fc079Hl/2rk2wJhK1K z9wtBCMYJGAzJZKmhYWM1gyz3SVXqOZrzsoczTDGsOqMVagZdWiZi0uCO0r7nNtFD9l+gI6eXDQ rSLiUPJfmGWmKB3AXSBgrpcWyzVL4QQo10nZ4Gq3K13HiiPhF1Hy1LRm7XtsMeO1Me/OJZVZa65 iPwY/jvvbJECZUN3bZPUssq9o2Y+DBYa822IEda/dBzIiYyAKqJKO9PCyt9f/hku8sulBhweALg QLEpZNyitb0nMpw== 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 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`. Signed-off-by: Louis Chauvet --- Documentation/gpu/vkms.rst | 11 ++++- drivers/gpu/drm/vkms/vkms_configfs.c | 89 ++++++++++++++++++++++++++++++++= ++++ 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst index dab6811687a2..8383e1b94668 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 6 configurable attributes: +Planes have 8 configurable attributes: =20 - type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those exposed by the "type" property of a plane) @@ -99,9 +99,16 @@ Planes have 6 configurable attributes: possible_rotations. - supported_color_encoding: Available encoding for a plane, as a bitmask: 0x01 YCBCR_BT601, 0x02: YCBCR_BT709, 0x04 YCBCR_BT2020 (same values as t= hose exposed - by the COLOR_ENCODING property of a plane) + 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_encoding +- supported_color_range: Available color range for a plane, as a bitmask: + 0x1 DRM_COLOR_YCBCR_LIMITED_RANGE, 0x2 DRM_COLOR_YCBCR_FULL_RANGE (same = values as + those exposed by the COLOR_RANGE property of a plane). If set, supported= _color_encoding + must be set too. +- default_color_range: Default color range presented to the userspace, same + values as supported_color_range =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 ee2e8d141f9e..3f658dd41272 100644 --- a/drivers/gpu/drm/vkms/vkms_configfs.c +++ b/drivers/gpu/drm/vkms/vkms_configfs.c @@ -439,6 +439,91 @@ static ssize_t plane_default_rotation_store(struct con= fig_item *item, return count; } =20 +static ssize_t plane_supported_color_ranges_show(struct config_item *item,= char *page) +{ + struct vkms_configfs_plane *plane; + unsigned int supported_color_range; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + scoped_guard(mutex, &plane->dev->lock) { + supported_color_range =3D vkms_config_plane_get_supported_color_ranges(p= lane->config); + } + + return sprintf(page, "%u", supported_color_range); +} + +static ssize_t plane_supported_color_ranges_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 & ~(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))) =3D=3D 0) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->lock) { + /* Ensures that the default rotation is included in supported rotation */ + if (plane->dev->enabled) + return -EINVAL; + vkms_config_plane_set_supported_color_ranges(plane->config, val); + } + + return count; +} + +static ssize_t plane_default_color_range_show(struct config_item *item, ch= ar *page) +{ + struct vkms_configfs_plane *plane; + unsigned int default_color_range; + + plane =3D plane_item_to_vkms_configfs_plane(item); + + scoped_guard(mutex, &plane->dev->lock) + default_color_range =3D vkms_config_plane_get_default_color_range(plane-= >config); + + return sprintf(page, "%u", default_color_range); +} + +static ssize_t plane_default_color_range_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 & ~(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))) =3D=3D 0) + return -EINVAL; + + scoped_guard(mutex, &plane->dev->lock) { + /* Ensures that the default rotation is included in supported rotation */ + if (plane->dev->enabled) + return -EINVAL; + vkms_config_plane_set_default_color_range(plane->config, val); + } + + return count; +} + static ssize_t plane_supported_color_encodings_show(struct config_item *it= em, char *page) { struct vkms_configfs_plane *plane; @@ -537,6 +622,8 @@ CONFIGFS_ATTR(plane_, type); CONFIGFS_ATTR(plane_, name); CONFIGFS_ATTR(plane_, supported_rotations); CONFIGFS_ATTR(plane_, default_rotation); +CONFIGFS_ATTR(plane_, supported_color_ranges); +CONFIGFS_ATTR(plane_, default_color_range); CONFIGFS_ATTR(plane_, supported_color_encodings); CONFIGFS_ATTR(plane_, default_color_encoding); =20 @@ -545,6 +632,8 @@ static struct configfs_attribute *plane_item_attrs[] = =3D { &plane_attr_name, &plane_attr_supported_rotations, &plane_attr_default_rotation, + &plane_attr_supported_color_ranges, + &plane_attr_default_color_range, &plane_attr_supported_color_encodings, &plane_attr_default_color_encoding, NULL, --=20 2.51.0