From: Louis Chauvet <louis.chauvet@bootlin.com>
To: "Rodrigo Siqueira" <rodrigosiqueiramelo@gmail.com>,
"Melissa Wen" <melissa.srw@gmail.com>,
"Maíra Canal" <mairacanal@riseup.net>,
"Haneen Mohammed" <hamohammed.sa@gmail.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Simona Vetter" <simona.vetter@ffwll.ch>
Cc: jose.exposito89@gmail.com, dri-devel@lists.freedesktop.org,
arthurgrillo@riseup.net, linux-kernel@vger.kernel.org,
jeremie.dautheribes@bootlin.com, miquel.raynal@bootlin.com,
thomas.petazzoni@bootlin.com, seanpaul@google.com,
nicolejadeyee@google.com,
Louis Chauvet <louis.chauvet@bootlin.com>
Subject: [PATCH RFC v3 09/14] drm/vkms: Introduce configfs for plane format
Date: Tue, 21 Jan 2025 15:34:53 +0100 [thread overview]
Message-ID: <20250121-google-config-fs-v3-9-8154a6945142@bootlin.com> (raw)
In-Reply-To: <20250121-google-config-fs-v3-0-8154a6945142@bootlin.com>
To allows the userspace to test many hardware configuration, introduce a
new interface to configure the available formats per planes. VKMS
supports many formats, so the userspace can choose any combination of
them.
The supported formats are configured by writing in the file
supported_formats:
- `+*` - Add all available formats
- `-*` - Remove all formats
- `+<fourcc>` - Add the format (for example `+AR24` to add ARGB8888
format)
- `-<FOURCC>` - Remove the format
The current interface is:
/config/vkms
DEVICE_1
┣━ enable
┗━ planes
┗━ PLANE_1
┗━ supported_formats
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
drivers/gpu/drm/vkms/vkms_configfs.c | 75 ++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 5f416260f209fc98939f8addd175e5c3b8e35353..eeb0c1e1b225f2a1a35ac6deb9457b90ba6542e5 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -153,14 +153,89 @@ static ssize_t plane_default_rotation_store(struct config_item *item,
return count;
}
+static ssize_t plane_supported_formats_show(struct config_item *item, char *page)
+{
+ struct vkms_config_plane *plane = plane_item_to_vkms_configfs_plane(item)->vkms_config_plane;
+ struct vkms_configfs_device *vkms_configfs = plane_item_to_vkms_configfs_device(item);
+
+ page[0] = '\0';
+
+ scoped_guard(mutex, &vkms_configfs->lock)
+ {
+ for (int i = 0; i < plane->supported_formats_count; i++) {
+ char tmp[6] = { 0 };
+ const ssize_t ret = snprintf(tmp, ARRAY_SIZE(tmp), "%.*s\n",
+ (int)sizeof(plane->supported_formats[i]),
+ (char *)&plane->supported_formats[i]);
+ if (ret < 0)
+ return ret;
+ /* Limitation of ConfigFS attributes, an attribute can't be bigger than PAGE_SIZE */
+ if (ret + strlen(page) > PAGE_SIZE - 1)
+ return -ENOMEM;
+ strncat(page, tmp, ARRAY_SIZE(tmp));
+ }
+ }
+
+ return strlen(page);
+}
+
+static ssize_t plane_supported_formats_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_config_plane *plane = plane_item_to_vkms_configfs_plane(item)->vkms_config_plane;
+ struct vkms_configfs_device *vkms_configfs = plane_item_to_vkms_configfs_device(item);
+ int ret = 0;
+ int ptr = 0;
+
+ scoped_guard(mutex, &vkms_configfs->lock)
+ {
+ while (ptr < count) {
+ if (page[ptr] == '+') {
+ char tmp[4] = { ' ', ' ', ' ', ' ' };
+
+ memcpy(tmp, &page[ptr + 1], min(sizeof(tmp), count - (ptr + 1)));
+ if (tmp[0] == '*') {
+ ret = vkms_config_plane_add_all_formats(plane);
+ if (ret)
+ return ret;
+ ptr += 1;
+ } else {
+ ret = vkms_config_plane_add_format(plane, *(int *)tmp);
+ if (ret)
+ return ret;
+ ptr += 4;
+ }
+ } else if (page[ptr] == '-') {
+ char tmp[4] = { ' ', ' ', ' ', ' ' };
+
+ memcpy(tmp, &page[ptr + 1], min(sizeof(tmp), count - (ptr + 1)));
+ if (tmp[0] == '*') {
+ vkms_config_plane_remove_all_formats(plane);
+ ptr += 1;
+ } else {
+ vkms_config_plane_remove_format(plane, *(int *)tmp);
+
+ ptr += 4;
+ }
+ }
+ /* Skip anything that is not a + or a - */
+ ptr += 1;
+ }
+ }
+
+ return count;
+}
+
CONFIGFS_ATTR(plane_, type);
CONFIGFS_ATTR(plane_, supported_rotations);
CONFIGFS_ATTR(plane_, default_rotation);
+CONFIGFS_ATTR(plane_, supported_formats);
static struct configfs_attribute *plane_attrs[] = {
&plane_attr_type,
&plane_attr_supported_rotations,
&plane_attr_default_rotation,
+ &plane_attr_supported_formats,
NULL,
};
--
2.47.1
next prev parent reply other threads:[~2025-01-21 14:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-21 14:34 [PATCH RFC v3 00/14] drm/vkms: ConfigFS interface Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 01/14] drm/vkms: Add vkms_delete/create_device helper Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 02/14] drm/vkms: Cleanup configuration field on device destroy Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 03/14] drm/vkms: Introduce ConfigFS interface Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 04/14] drm/vkms: Introduce configfs for plane Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 05/14] drm/vkms: Introduce configfs for plane rotation Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 06/14] drm/vkms: Introduce configfs for crtc and encoder Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 07/14] drm/vkms: Introduce configfs for connectors Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 08/14] drm/vkms: Introduce configfs for connector type Louis Chauvet
2025-01-21 14:34 ` Louis Chauvet [this message]
2025-01-21 14:34 ` [PATCH RFC v3 10/14] drm/vkms: Introduce configfs for device name Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 11/14] drm/vkms: Introduce configfs for connector status Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 12/14] drm/vkms: Introduce configfs for connector id Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 13/14] drm/vkms: Introduce configfs for connector EDID Louis Chauvet
2025-01-21 14:34 ` [PATCH RFC v3 14/14] drm/vkms: Introduce configfs for encoder type Louis Chauvet
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=20250121-google-config-fs-v3-9-8154a6945142@bootlin.com \
--to=louis.chauvet@bootlin.com \
--cc=airlied@gmail.com \
--cc=arthurgrillo@riseup.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=hamohammed.sa@gmail.com \
--cc=jeremie.dautheribes@bootlin.com \
--cc=jose.exposito89@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mairacanal@riseup.net \
--cc=melissa.srw@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=mripard@kernel.org \
--cc=nicolejadeyee@google.com \
--cc=rodrigosiqueiramelo@gmail.com \
--cc=seanpaul@google.com \
--cc=simona.vetter@ffwll.ch \
--cc=simona@ffwll.ch \
--cc=thomas.petazzoni@bootlin.com \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®