From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E511BCCD1BF for ; Fri, 24 Oct 2025 15:16:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 55ECD10EAB4; Fri, 24 Oct 2025 15:16:46 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MrFIyjT8"; dkim-atps=neutral Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9C11210EAB4 for ; Fri, 24 Oct 2025 15:16:44 +0000 (UTC) Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-47114a40161so22773265e9.3 for ; Fri, 24 Oct 2025 08:16:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761319003; x=1761923803; darn=lists.freedesktop.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=mevfSuNrxwVFTOkyY7Tm8OrvABJ1d1Eojo95+k8sZtc=; b=MrFIyjT8uyKDpIg0caohduT7RboYsnGwXeo8OJpTPxuATzS+xvzMlhGoHOUJ6Lh3XS FgJiN+m/mmAH8NiDrEqzxLf9+2VSKjJgZDxPD3MVHA6JOja8vJljpG6dtu8nX85DcE0y WFYgUKdZgn3N+b0ogbrPPbUxCco9IQD2g1n2qQTEQAk/SVriLLv+9PyymZaCe13q1muj QS1v6XCZp28mvvhkfHM/5wWpSI6Z63LJPtWB4xtWMMUYPYxjKE4Cj0ONtt4Rl3l6yPiN V6/4MkzfdJgi4UOr/vNNa/NsUGBa/x/mMKUFUpO4CB2JXgaqEwMvyJvCK79Jn6NmzsPP FjjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761319003; x=1761923803; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mevfSuNrxwVFTOkyY7Tm8OrvABJ1d1Eojo95+k8sZtc=; b=VmI+Gf8fF7R4tgGFn0bU/cz2npSncAATkucveU66S7ST3aJ2M41P/z+buVgODIfFNH rRHoSAqgNp2Qyhrq2fdqdC8YkUGxic5aaaMe8EbJGYyKVL6DeyeB91Y30KXTOXDQmdk0 AEdyyDCmvBcGTDPxKb5HV/2qCnOHEiMaqDLddftXdPnzXCtfMtpipMVqszuJaHn+dxSs RsPO4VlbNLwdUMFbJfBuiwMSBUx+Ax/5Ut20LPlB5hJB5wELhzM5hRb/7YrN22fjdw5B k+xAF3pwE//gl46YORFdFDWu0w6x18brB2ZWy52eJhUelUlZwiNNFgTcL+BK9MJdkwE+ BrjA== X-Forwarded-Encrypted: i=1; AJvYcCVCk/iVYDAPhf4v2YTFK+9SCasZASer3If4OrKpm59BGW3gXn+/6XPcW4mbAS/M0/8+5D8H+qfigkY=@lists.freedesktop.org X-Gm-Message-State: AOJu0YzPrAvq7nlVXZ5nCQoQ83Tz5e40U9j4ijMNxFbNwQ8nAZAmu4mu tDw7bEwWRsghgSqYYeEphyUdyysdnAdyfTHp12ix65/U6M44Ok39sYse X-Gm-Gg: ASbGncuToxgwX+gJXebS/69ge2WhjzyUbDSJAt0k7ICV6t1LVDnQFawOQkpeFApkGU5 uB63lzsOlvFf0gDqwe2Izzcno29ZvjhysrR2M3iCHy02pdwfl0m8zJ0dqGpzePqb2qKqQDPUgqz xOkLC8dqjBlEcnQ1Um5v7ZqAYZFpZwgWUoLVXbEodRlkt4uI7v4nZQ9nlBOieoYJnw0K0Gk/Ano 7JxUvtsfltWTb+zqgdIYPIumAKxziRlc1rjTWCHDksjAObv+zFQL0Or4itcSMgtpeAVJxr+OdYr iQXlMiYsHTaOHrbh4D+J6icZhh54KQrMPEah1bscH8NhE3VIfyHuyKAQeGYrG36stGeITmwKgXw tX65lxH36x15FRE4F5Q68nYlsgSqK9EruLrhHpPWoPe4FfS72ZKWkiFmm5pXZS06yYnDEhiQM/X sjcXqnbsdWpw== X-Google-Smtp-Source: AGHT+IEA18WK4Q9IiYqGhwYZgRRsCaQtZ15viH6p/QSrbM4l3uPsWojVndH+d8P9+fufilJ2qEw4Ew== X-Received: by 2002:a05:600c:3512:b0:46e:5b74:4858 with SMTP id 5b1f17b1804b1-47117877122mr173891065e9.13.1761319002904; Fri, 24 Oct 2025 08:16:42 -0700 (PDT) Received: from fedora ([37.29.213.75]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-475c4378cbesm150983915e9.16.2025.10.24.08.16.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Oct 2025 08:16:42 -0700 (PDT) Date: Fri, 24 Oct 2025 17:16:39 +0200 From: =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= To: Louis Chauvet Cc: Haneen Mohammed , Simona Vetter , Melissa Wen , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Jonathan Corbet , victoria@system76.com, sebastian.wick@redhat.com, thomas.petazzoni@bootlin.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [PATCH 06/22] drm/vkms: Introduce configfs for plane color encoding Message-ID: References: <20251018-vkms-all-config-v1-0-a7760755d92d@bootlin.com> <20251018-vkms-all-config-v1-6-a7760755d92d@bootlin.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20251018-vkms-all-config-v1-6-a7760755d92d@bootlin.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Sat, Oct 18, 2025 at 04:01:06AM +0200, 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 > --- > Documentation/gpu/vkms.rst | 7 ++- > drivers/gpu/drm/vkms/vkms_configfs.c | 102 +++++++++++++++++++++++++++++++++++ > 2 files changed, 108 insertions(+), 1 deletion(-) > > diff --git a/Documentation/gpu/vkms.rst b/Documentation/gpu/vkms.rst > index a432968cc711..4ff75b53a386 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 attribute: > +Planes have 5 configurable attribute: > > - type: Plane type: 0 overlay, 1 primary, 2 cursor (same values as those > exposed by the "type" property of a plane) > @@ -96,6 +96,11 @@ Planes have 3 configurable attribute: > (same values as those exposed by the "rotation" property of a plane) > - default_rotation: Default rotation presented to the userspace, same values as > 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 those exposed > + by the COLOR_ENCODING property of a plane) > +- default_color_encoding: Default color encoding presented to the userspace, same > + values as supported_color_encoding > > 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 450e45e66a45..a4e0e054cf2d 100644 > --- a/drivers/gpu/drm/vkms/vkms_configfs.c > +++ b/drivers/gpu/drm/vkms/vkms_configfs.c > @@ -412,14 +412,116 @@ static ssize_t plane_default_rotation_store(struct config_item *item, > return count; > } > > +static ssize_t plane_supported_color_encoding_show(struct config_item *item, char *page) > +{ > + struct vkms_configfs_plane *plane; > + unsigned int supported_color_encoding; > + > + plane = plane_item_to_vkms_configfs_plane(item); > + > + scoped_guard(mutex, &plane->dev->lock) { > + supported_color_encoding = vkms_config_plane_get_supported_color_encoding(plane->config); > + } > + > + return sprintf(page, "%u", supported_color_encoding); > +} > + > +static ssize_t plane_supported_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 & ~(BIT(DRM_COLOR_YCBCR_BT601) | > + BIT(DRM_COLOR_YCBCR_BT709) | > + BIT(DRM_COLOR_YCBCR_BT2020))) > + return -EINVAL; > + /* Should at least provide one color range */ > + if ((val & (BIT(DRM_COLOR_YCBCR_BT601) | > + BIT(DRM_COLOR_YCBCR_BT709) | > + BIT(DRM_COLOR_YCBCR_BT2020))) == 0) > + return -EINVAL; > + > + scoped_guard(mutex, &plane->dev->lock) { > + /* Ensures that the default rotation is included in supported rotation */ > + if (plane->dev->enabled || > + (val & vkms_config_plane_get_default_color_encoding(plane->config)) != > + vkms_config_plane_get_default_color_encoding(plane->config)) > + return -EINVAL; I think that the same problem that I mention having to configure plane rotation in 2 steps applies for color encoding. > + vkms_config_plane_set_supported_color_encoding(plane->config, val); > + } > + > + return count; > +} > + > +/* Plane default_color_encoding : vkms//planes//default_color_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); > + > + scoped_guard(mutex, &plane->dev->lock) { > + default_color_encoding = vkms_config_plane_get_default_color_encoding(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 = 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 & ~(BIT(DRM_COLOR_YCBCR_BT601) | > + BIT(DRM_COLOR_YCBCR_BT709) | > + BIT(DRM_COLOR_YCBCR_BT2020))) > + return -EINVAL; > + /* Should at least provide one color range */ > + if ((val & (BIT(DRM_COLOR_YCBCR_BT601) | > + BIT(DRM_COLOR_YCBCR_BT709) | > + BIT(DRM_COLOR_YCBCR_BT2020))) == 0) > + return -EINVAL; > + > + scoped_guard(mutex, &plane->dev->lock) { > + /* Ensures that the default rotation is included in supported rotation */ > + if (plane->dev->enabled || > + (val & vkms_config_plane_get_supported_color_encoding(plane->config)) != > + val) > + return -EINVAL; > + > + vkms_config_plane_set_default_color_encoding(plane->config, val); As I mentioned in the previous patch, I think that default color encoding is sometimes a bitmask and sometimes the actual color? > + } > + > + return count; > +} > + > CONFIGFS_ATTR(plane_, type); > CONFIGFS_ATTR(plane_, supported_rotations); > CONFIGFS_ATTR(plane_, default_rotation); > +CONFIGFS_ATTR(plane_, supported_color_encoding); > +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_encoding, > + &plane_attr_default_color_encoding, > NULL, > }; > > > -- > 2.51.0 >