[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250121-google-config-fs-v3-11-8154a6945142@bootlin.com>
Date: Tue, 21 Jan 2025 15:34:55 +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 v3 11/14] drm/vkms: Introduce configfs for connector
status
As a connector can be connected and disconnected once a device is created,
create a file to allow changing this status.
Signed-off-by: Louis Chauvet <louis.chauvet@...tlin.com>
---
drivers/gpu/drm/vkms/vkms_configfs.c | 45 ++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
index d0bc6adfdae85b82ca043d318f84fca70840526c..09d9ac3cb3e25e980473686b7b0d2e66e78cf163 100644
--- a/drivers/gpu/drm/vkms/vkms_configfs.c
+++ b/drivers/gpu/drm/vkms/vkms_configfs.c
@@ -771,10 +771,55 @@ static ssize_t connector_type_store(struct config_item *item,
return count;
}
+static ssize_t connector_status_show(struct config_item *item, char *page)
+{
+ struct vkms_config_connector *connector;
+ enum drm_connector_status status;
+ struct vkms_configfs_device *vkms_configfs = connector_child_item_to_vkms_configfs_device(item);
+
+ mutex_lock(&vkms_configfs->lock);
+ connector = connector_item_to_vkms_configfs_connector(item)->vkms_config_connector;
+ status = connector->status;
+ mutex_unlock(&vkms_configfs->lock);
+
+ return sprintf(page, "%u", status);
+}
+
+static ssize_t connector_status_store(struct config_item *item,
+ const char *page, size_t count)
+{
+ struct vkms_config_connector *connector;
+ enum drm_connector_status status = connector_status_unknown;
+ struct vkms_configfs_device *vkms_configfs = connector_child_item_to_vkms_configfs_device(item);
+ int ret;
+
+ ret = kstrtouint(page, 10, &status);
+ if (ret)
+ return ret;
+
+ switch (status) {
+ case connector_status_unknown:
+ case connector_status_connected:
+ case connector_status_disconnected:
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ scoped_guard(mutex, &vkms_configfs->lock) {
+ connector = connector_item_to_vkms_configfs_connector(item)->vkms_config_connector;
+ vkms_config_connector_update_status(connector, status);
+ }
+
+ return count;
+}
+
CONFIGFS_ATTR(connector_, type);
+CONFIGFS_ATTR(connector_, status);
static struct configfs_attribute *connector_attrs[] = {
&connector_attr_type,
+ &connector_attr_status,
NULL,
};
--
2.47.1
Powered by blists - more mailing lists