From: "José Expósito" <jose.exposito89@gmail.com>
To: Louis Chauvet <louis.chauvet@bootlin.com>
Cc: Haneen Mohammed <hamohammed.sa@gmail.com>,
Simona Vetter <simona@ffwll.ch>,
Melissa Wen <melissa.srw@gmail.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
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 09/22] drm/vkms: Introduce config for plane format
Date: Fri, 24 Oct 2025 17:44:09 +0200 [thread overview]
Message-ID: <aPueydZ1bdmEQ8VE@fedora> (raw)
In-Reply-To: <20251018-vkms-all-config-v1-9-a7760755d92d@bootlin.com>
On Sat, Oct 18, 2025 at 04:01:09AM +0200, Louis Chauvet wrote:
> VKMS driver supports all the pixel formats for planes, but for testing it
> can be useful to only advertise few of them. This new configuration
> interface will allow configuring the pixel format per planes.
>
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---
> drivers/gpu/drm/vkms/vkms_config.c | 99 ++++++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/vkms/vkms_config.h | 49 +++++++++++++++++++
> drivers/gpu/drm/vkms/vkms_plane.c | 39 +--------------
> 3 files changed, 150 insertions(+), 37 deletions(-)
>
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index 8f00ca21ed6e..0b975a0d47aa 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
> @@ -8,6 +8,42 @@
>
> #include "vkms_config.h"
>
> +static const u32 vkms_supported_plane_formats[] = {
> + DRM_FORMAT_ARGB8888,
> + DRM_FORMAT_ABGR8888,
> + DRM_FORMAT_BGRA8888,
> + DRM_FORMAT_RGBA8888,
> + DRM_FORMAT_XRGB8888,
> + DRM_FORMAT_XBGR8888,
> + DRM_FORMAT_RGB888,
> + DRM_FORMAT_BGR888,
> + DRM_FORMAT_XRGB16161616,
> + DRM_FORMAT_XBGR16161616,
> + DRM_FORMAT_ARGB16161616,
> + DRM_FORMAT_ABGR16161616,
> + DRM_FORMAT_RGB565,
> + DRM_FORMAT_BGR565,
> + DRM_FORMAT_NV12,
> + DRM_FORMAT_NV16,
> + DRM_FORMAT_NV24,
> + DRM_FORMAT_NV21,
> + DRM_FORMAT_NV61,
> + DRM_FORMAT_NV42,
> + DRM_FORMAT_YUV420,
> + DRM_FORMAT_YUV422,
> + DRM_FORMAT_YUV444,
> + DRM_FORMAT_YVU420,
> + DRM_FORMAT_YVU422,
> + DRM_FORMAT_YVU444,
> + DRM_FORMAT_P010,
> + DRM_FORMAT_P012,
> + DRM_FORMAT_P016,
> + DRM_FORMAT_R1,
> + DRM_FORMAT_R2,
> + DRM_FORMAT_R4,
> + DRM_FORMAT_R8,
> +};
> +
> struct vkms_config *vkms_config_create(const char *dev_name)
> {
> struct vkms_config *config;
> @@ -435,6 +471,11 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config)
> if (!plane_cfg)
> return ERR_PTR(-ENOMEM);
>
> + if (vkms_config_plane_add_all_formats(plane_cfg)) {
> + kfree(plane_cfg);
> + return ERR_PTR(-ENOMEM);
> + }
> +
> plane_cfg->config = config;
> vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_OVERLAY);
> vkms_config_plane_set_name(plane_cfg, NULL);
> @@ -563,6 +604,64 @@ static struct vkms_config_plane *vkms_config_crtc_get_plane(const struct vkms_co
> return NULL;
> }
>
> +int __must_check vkms_config_plane_add_all_formats(struct vkms_config_plane *plane_cfg)
> +{
> + u32 *ret = krealloc_array(plane_cfg->supported_formats,
> + ARRAY_SIZE(vkms_supported_plane_formats),
> + sizeof(uint32_t), GFP_KERNEL);
> + if (!ret)
> + return -ENOMEM;
> + plane_cfg->supported_formats = ret;
> +
> + memcpy(plane_cfg->supported_formats, vkms_supported_plane_formats,
> + sizeof(vkms_supported_plane_formats));
> + plane_cfg->supported_formats_count = ARRAY_SIZE(vkms_supported_plane_formats);
> + return 0;
> +}
> +
> +int __must_check vkms_config_plane_add_format(struct vkms_config_plane *plane_cfg, u32 drm_format)
> +{
> + bool found = false;
> +
> + for (int i = 0; i < ARRAY_SIZE(vkms_supported_plane_formats); i++) {
> + if (vkms_supported_plane_formats[i] == drm_format)
> + found = true;
Missing break?
> + }
> +
> + if (!found)
> + return -EINVAL;
> + for (unsigned int i = 0; i < plane_cfg->supported_formats_count; i++) {
> + if (plane_cfg->supported_formats[i] == drm_format)
> + return 0;
> + }
> + u32 *new_ptr = krealloc_array(plane_cfg->supported_formats,
> + plane_cfg->supported_formats_count + 1,
> + sizeof(*plane_cfg->supported_formats), GFP_KERNEL);
> + if (!new_ptr)
> + return -ENOMEM;
> +
> + plane_cfg->supported_formats = new_ptr;
> + plane_cfg->supported_formats[plane_cfg->supported_formats_count] = drm_format;
> + plane_cfg->supported_formats_count++;
> +
> + return 0;
> +}
> +
> +void vkms_config_plane_remove_all_formats(struct vkms_config_plane *plane_cfg)
> +{
> + plane_cfg->supported_formats_count = 0;
> +}
> +
> +void vkms_config_plane_remove_format(struct vkms_config_plane *plane_cfg, u32 drm_format)
> +{
> + for (unsigned int i = 0; i < plane_cfg->supported_formats_count; i++) {
> + if (plane_cfg->supported_formats[i] == drm_format) {
> + plane_cfg->supported_formats[i] = plane_cfg->supported_formats[plane_cfg->supported_formats_count - 1];
> + plane_cfg->supported_formats_count--;
> + }
> + }
> +}
> +
> struct vkms_config_plane *vkms_config_crtc_primary_plane(const struct vkms_config *config,
> struct vkms_config_crtc *crtc_cfg)
> {
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index 8127e12f00dc..0b7067508e5f 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.h
> +++ b/drivers/gpu/drm/vkms/vkms_config.h
> @@ -62,6 +62,8 @@ struct vkms_config_plane {
> unsigned int supported_color_encoding;
> enum drm_color_range default_color_range;
> unsigned int supported_color_range;
> + u32 *supported_formats;
> + unsigned int supported_formats_count;
> struct xarray possible_crtcs;
>
> /* Internal usage */
> @@ -404,6 +406,53 @@ vkms_config_plane_set_supported_color_range(struct vkms_config_plane *plane_cfg,
> plane_cfg->supported_color_range = supported_color_range;
> }
>
> +static inline u32 *
> +vkms_config_plane_get_supported_formats(struct vkms_config_plane *plane_cfg)
> +{
> + return plane_cfg->supported_formats;
> +}
> +
> +static inline unsigned int
> +vkms_config_plane_get_supported_formats_count(struct vkms_config_plane *plane_cfg)
> +{
> + return plane_cfg->supported_formats_count;
> +}
> +
> +/** vkms_config_plane_add_format - Add a format to the list of supported format of a plane
> + *
> + * The passed drm_format can already be present in the list. This may fail if the allocation of a
> + * bigger array fails.
> + *
> + * @plane_cfg: Plane to add the format to
> + * @drm_format: Format to add to this plane
> + *
> + * Returns: 0 on success, -ENOMEM if array allocation fails, -EINVAL if the format is not supported
> + * by VKMS
> + */
> +int __must_check vkms_config_plane_add_format(struct vkms_config_plane *plane_cfg, u32 drm_format);
> +
> +/**
> + * vkms_config_plane_add_all_formats - Helper to quickly add all the supported formats
> + * @plane_cfg: Plane to add the formats to
> + *
> + * Returns: 0 on success, -ENOMEM if array allocation fails, -EINVAL if the format is not supported
> + * by VKMS
> + */
> +int __must_check vkms_config_plane_add_all_formats(struct vkms_config_plane *plane_cfg);
> +
> +/**
> + * vkms_config_plane_remove_format - Remove a specific format from a plane
> + * @plane_cfg: Plane to remove the format to
> + * @drm_format: Format to remove
> + */
> +void vkms_config_plane_remove_format(struct vkms_config_plane *plane_cfg, u32 drm_format);
> +
> +/**
> + * vkms_config_plane_remove_all_formats - Remove all formast from a plane
> + * @plane_cfg: Plane to remove the formats from
> + */
> +void vkms_config_plane_remove_all_formats(struct vkms_config_plane *plane_cfg);
> +
> /**
> * vkms_config_plane_set_name() - Set the plane name
> * @plane_cfg: Plane to set the name to
> diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c
> index ab719da2ca0b..0414865915d8 100644
> --- a/drivers/gpu/drm/vkms/vkms_plane.c
> +++ b/drivers/gpu/drm/vkms/vkms_plane.c
> @@ -14,42 +14,6 @@
> #include "vkms_formats.h"
> #include "vkms_config.h"
>
> -static const u32 vkms_formats[] = {
> - DRM_FORMAT_ARGB8888,
> - DRM_FORMAT_ABGR8888,
> - DRM_FORMAT_BGRA8888,
> - DRM_FORMAT_RGBA8888,
> - DRM_FORMAT_XRGB8888,
> - DRM_FORMAT_XBGR8888,
> - DRM_FORMAT_RGB888,
> - DRM_FORMAT_BGR888,
> - DRM_FORMAT_XRGB16161616,
> - DRM_FORMAT_XBGR16161616,
> - DRM_FORMAT_ARGB16161616,
> - DRM_FORMAT_ABGR16161616,
> - DRM_FORMAT_RGB565,
> - DRM_FORMAT_BGR565,
> - DRM_FORMAT_NV12,
> - DRM_FORMAT_NV16,
> - DRM_FORMAT_NV24,
> - DRM_FORMAT_NV21,
> - DRM_FORMAT_NV61,
> - DRM_FORMAT_NV42,
> - DRM_FORMAT_YUV420,
> - DRM_FORMAT_YUV422,
> - DRM_FORMAT_YUV444,
> - DRM_FORMAT_YVU420,
> - DRM_FORMAT_YVU422,
> - DRM_FORMAT_YVU444,
> - DRM_FORMAT_P010,
> - DRM_FORMAT_P012,
> - DRM_FORMAT_P016,
> - DRM_FORMAT_R1,
> - DRM_FORMAT_R2,
> - DRM_FORMAT_R4,
> - DRM_FORMAT_R8,
> -};
> -
> static struct drm_plane_state *
> vkms_plane_duplicate_state(struct drm_plane *plane)
> {
> @@ -226,7 +190,8 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
>
> plane = drmm_universal_plane_alloc(dev, struct vkms_plane, base, 0,
> &vkms_plane_funcs,
> - vkms_formats, ARRAY_SIZE(vkms_formats),
> + vkms_config_plane_get_supported_formats(config),
> + vkms_config_plane_get_supported_formats_count(config),
> NULL, vkms_config_plane_get_type(config),
> vkms_config_plane_get_name(config));
> if (IS_ERR(plane))
>
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-10-24 15:44 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-18 2:01 [PATCH 00/22] VKMS: Introduce multiple configFS attributes Louis Chauvet
2025-10-18 2:01 ` [PATCH 01/22] drm/vkms: Introduce config for plane name Louis Chauvet
2025-10-24 11:16 ` José Expósito
2025-10-27 10:15 ` Jani Nikula
2025-10-18 2:01 ` [PATCH 02/22] drm/vkms: Introduce configfs " Louis Chauvet
2025-10-24 11:20 ` José Expósito
2025-10-18 2:01 ` [PATCH 03/22] drm/vkms: Introduce config for plane rotation Louis Chauvet
2025-10-24 11:53 ` José Expósito
2025-10-18 2:01 ` [PATCH 04/22] drm/vkms: Introduce configfs " Louis Chauvet
2025-10-24 14:50 ` José Expósito
2025-10-18 2:01 ` [PATCH 05/22] drm/vkms: Introduce config for plane color encoding Louis Chauvet
2025-10-24 15:14 ` José Expósito
2025-10-18 2:01 ` [PATCH 06/22] drm/vkms: Introduce configfs " Louis Chauvet
2025-10-24 15:16 ` José Expósito
2025-10-18 2:01 ` [PATCH 07/22] drm/vkms: Introduce config for plane color range Louis Chauvet
2025-10-24 15:25 ` José Expósito
2025-10-18 2:01 ` [PATCH 08/22] drm/vkms: Introduce configfs " Louis Chauvet
2025-10-24 15:27 ` José Expósito
2025-10-18 2:01 ` [PATCH 09/22] drm/vkms: Introduce config for plane format Louis Chauvet
2025-10-24 15:44 ` José Expósito [this message]
2025-10-18 2:01 ` [PATCH 10/22] drm/vkms: Introduce configfs " Louis Chauvet
2025-10-27 8:55 ` José Expósito
2025-10-18 2:01 ` [PATCH 11/22] drm/vkms: Properly render plane using their zpos Louis Chauvet
2025-10-18 2:01 ` [PATCH 12/22] drm/vkms: Introduce config for plane zpos property Louis Chauvet
2025-10-27 9:12 ` José Expósito
2025-10-18 2:01 ` [PATCH 13/22] drm/vkms: Introduce configfs " Louis Chauvet
2025-10-27 9:19 ` José Expósito
2025-10-18 2:01 ` [PATCH 14/22] drm/vkms: Introduce config for connector type Louis Chauvet
2025-10-27 9:27 ` José Expósito
2025-10-18 2:01 ` [PATCH 15/22] drm/vkms: Introduce configfs " Louis Chauvet
2025-10-18 2:01 ` [PATCH 16/22] drm/vkms: Introduce config for connector supported colorspace Louis Chauvet
2025-10-27 9:35 ` José Expósito
2025-10-27 9:38 ` José Expósito
2025-10-18 2:01 ` [PATCH 17/22] drm/vkms: Introduce configfs " Louis Chauvet
2025-10-18 2:01 ` [PATCH 18/22] drm/vkms: Introduce config for connector EDID Louis Chauvet
2025-10-27 10:02 ` José Expósito
2025-10-18 2:01 ` [PATCH 19/22] drm/vkms: Introduce configfs " Louis Chauvet
2025-10-27 10:16 ` José Expósito
2025-10-27 17:18 ` Louis Chauvet
2025-10-18 2:01 ` [PATCH 20/22] drm/vkms: Store the enabled/disabled status for connector Louis Chauvet
2025-10-27 14:52 ` José Expósito
2025-10-18 2:01 ` [PATCH 21/22] drm/vkms: Allow to hot-add connectors Louis Chauvet
2025-10-27 15:01 ` José Expósito
2025-10-18 2:01 ` [PATCH 22/22] drm/vkms: Allows the creation of connector at runtime Louis Chauvet
2025-10-27 15:17 ` José Expósito
2025-10-27 15:22 ` [PATCH 00/22] VKMS: Introduce multiple configFS attributes José Expósito
2025-10-27 15:53 ` Louis Chauvet
2025-10-28 7:32 ` José Expósito
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aPueydZ1bdmEQ8VE@fedora \
--to=jose.exposito89@gmail.com \
--cc=airlied@gmail.com \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=hamohammed.sa@gmail.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=louis.chauvet@bootlin.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=melissa.srw@gmail.com \
--cc=mripard@kernel.org \
--cc=sebastian.wick@redhat.com \
--cc=simona@ffwll.ch \
--cc=thomas.petazzoni@bootlin.com \
--cc=tzimmermann@suse.de \
--cc=victoria@system76.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).