@@ -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,
};
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> --- drivers/gpu/drm/vkms/vkms_configfs.c | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+)