[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241122-google-config-fs-v2-16-4b7e6f183320@bootlin.com>
Date: Fri, 22 Nov 2024 18:38:42 +0100
From: Louis Chauvet <louis.chauvet@...tlin.com>
To: Rodrigo Siqueira <rodrigosiqueiramelo@...il.com>,
Melissa Wen <melissa.srw@...il.com>,
MaĆra Canal <mairacanal@...eup.net>,
Haneen Mohammed <hamohammed.sa@...il.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
Simona Vetter <simona.vetter@...ll.ch>
Cc: jose.exposito89@...il.com, dri-devel@...ts.freedesktop.org,
arthurgrillo@...eup.net, linux-kernel@...r.kernel.org,
jeremie.dautheribes@...tlin.com, miquel.raynal@...tlin.com,
thomas.petazzoni@...tlin.com, seanpaul@...gle.com, nicolejadeyee@...gle.com,
Louis Chauvet <louis.chauvet@...tlin.com>
Subject: [PATCH RFC v2 16/16] drm/vkms: Introduce configfs for encoder type
Signed-off-by: Louis Chauvet <louis.chauvet@...tlin.com>
---
drivers/gpu/drm/vkms/vkms_configfs.c | 57 ++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index 55bd0b9a31d35eca49c67a2fe2d58e3ea84367a4..bfd3c3a0851b2cc76da52b8a190511f22d3f9fbc 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0+
+#include "drm/drm_mode.h"
#include <linux/configfs.h>
#include <linux/mutex.h>
#include <drm/drm_print.h>
@@ -754,6 +755,61 @@ static void encoder_possible_crtcs_drop_link(struct config_item *src,
mutex_unlock(&vkms_configfs->lock);
}
+static ssize_t encoder_type_show(struct config_item *item, char *page)
+{
+ struct vkms_config_encoder *encoder;
+ char encoder_type = DRM_MODE_ENCODER_NONE;
+ struct vkms_configfs_device *vkms_configfs = encoder_item_to_vkms_configfs_device(item);
+
+ scoped_guard(mutex, &vkms_configfs->lock)
+ {
+ encoder = encoder_item_to_vkms_configfs_encoder(item)->vkms_config_encoder;
+ encoder_type = encoder->type;
+ }
+
+ return sprintf(page, "%u", encoder_type);
+}
+
+static ssize_t encoder_type_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_configfs_device *vkms_configfs = encoder_item_to_vkms_configfs_device(item);
+ int val = DRM_MODE_ENCODER_VIRTUAL;
+ struct vkms_config_encoder *encoder;
+ int ret;
+
+ ret = kstrtouint(page, 10, &val);
+ if (ret)
+ return ret;
+
+ if (val != DRM_MODE_ENCODER_DAC &&
+ val != DRM_MODE_ENCODER_DPI &&
+ val != DRM_MODE_ENCODER_DSI &&
+ val != DRM_MODE_ENCODER_LVDS &&
+ val != DRM_MODE_ENCODER_NONE &&
+ val != DRM_MODE_ENCODER_TMDS &&
+ val != DRM_MODE_ENCODER_TVDAC &&
+ val != DRM_MODE_ENCODER_VIRTUAL)
+ return -EINVAL;
+
+ scoped_guard(mutex, &vkms_configfs->lock) {
+ if (vkms_configfs->enabled)
+ return -EINVAL;
+
+ encoder = encoder_item_to_vkms_configfs_encoder(item)->vkms_config_encoder;
+ encoder->type = val;
+ }
+
+ return count;
+}
+
+CONFIGFS_ATTR(encoder_, type);
+
+static struct configfs_attribute *encoder_attrs[] = {
+ &encoder_attr_type,
+ NULL,
+};
+
static struct configfs_item_operations encoder_possible_crtcs_item_operations = {
.allow_link = &encoder_possible_crtcs_allow_link,
.drop_link = &encoder_possible_crtcs_drop_link,
@@ -782,6 +838,7 @@ static struct configfs_item_operations encoder_item_operations = {
static const struct config_item_type encoder_item_type = {
.ct_item_ops = &encoder_item_operations,
+ .ct_attrs = encoder_attrs,
.ct_owner = THIS_MODULE,
};
--
2.47.0
Powered by blists - more mailing lists