diff mbox series

[RFC,v2,16/18] drm/vkms: Introduce config for connector status

Message ID 20241122-google-remove-crtc-index-from-parameter-v2-16-81540742535a@bootlin.com (mailing list archive)
State New
Headers show
Series drm/vkms: Introduce detailed configuration | expand

Commit Message

Louis Chauvet Nov. 22, 2024, 5:20 p.m. UTC
Signed-off-by: José Expósito <jose.exposito89@gmail.com>
[adpated it for my implementation]
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
 drivers/gpu/drm/vkms/vkms_config.c | 10 ++++++++++
 drivers/gpu/drm/vkms/vkms_config.h |  4 ++++
 drivers/gpu/drm/vkms/vkms_output.c | 17 +++++++++++++++++
 3 files changed, 31 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
index 4726929c2b54b2e670f9ef53b05ec009ca495e08..ac1a9658c5075c118d59da965ca3392355ccb2b2 100644
--- a/drivers/gpu/drm/vkms/vkms_config.c
+++ b/drivers/gpu/drm/vkms/vkms_config.c
@@ -2,6 +2,7 @@ 
 
 #include <kunit/visibility.h>
 #include <drm/drm_debugfs.h>
+#include <drm/drm_probe_helper.h>
 
 #include "vkms_config.h"
 #include "vkms_drv.h"
@@ -197,10 +198,19 @@  struct vkms_config_connector *vkms_config_create_connector(struct vkms_config *v
 	list_add(&vkms_config_connector->link, &vkms_config->connectors);
 	xa_init_flags(&vkms_config_connector->possible_encoders, XA_FLAGS_ALLOC);
 	vkms_config_connector->type = DRM_MODE_CONNECTOR_VIRTUAL;
+	vkms_config_connector->status = connector_status_unknown;
 
 	return vkms_config_connector;
 }
 
+void vkms_config_connector_update_status(struct vkms_config_connector *vkms_config_connector,
+					 enum drm_connector_status status)
+{
+	vkms_config_connector->status = status;
+	if (vkms_config_connector->connector)
+		drm_kms_helper_hotplug_event(vkms_config_connector->connector->dev);
+}
+
 struct vkms_config_crtc *vkms_config_create_crtc(struct vkms_config *vkms_config)
 {
 	if (!vkms_config)
diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
index 5487e0140da0e111c36f9a22d4e783a20c880a1d..bba56c9d8aeceac97a4339ef42ab663c5dc54e65 100644
--- a/drivers/gpu/drm/vkms/vkms_config.h
+++ b/drivers/gpu/drm/vkms/vkms_config.h
@@ -111,11 +111,15 @@  struct vkms_config_connector {
 
 	struct xarray possible_encoders;
 	int type;
+	enum drm_connector_status status;
 
 	/* Internal usage */
 	struct drm_connector *connector;
 };
 
+void vkms_config_connector_update_status(struct vkms_config_connector *vkms_config_connector,
+					 enum drm_connector_status status);
+
 /**
  * vkms_config_register_debugfs() - Register the debugfs file to display current configuration
  */
diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c
index aea6366fd9a662483ed5a255d02d5025a30297f7..fc6a0cdade0739b94820ed4e0924cf355137fe79 100644
--- a/drivers/gpu/drm/vkms/vkms_output.c
+++ b/drivers/gpu/drm/vkms/vkms_output.c
@@ -7,9 +7,26 @@ 
 #include <drm/drm_managed.h>
 #include <drm/drm_probe_helper.h>
 
+static enum drm_connector_status vkms_connector_detect(struct drm_connector *connector, bool force)
+{
+	struct vkms_device *vkmsdev = drm_device_to_vkms_device(connector->dev);
+	enum drm_connector_status status = connector->status;
+	struct vkms_config_connector *connector_cfg;
+
+	list_for_each_entry(connector_cfg, &vkmsdev->config->connectors, link) {
+		if (connector_cfg->connector == connector) {
+			status = connector_cfg->status;
+			break;
+		}
+	}
+
+	return status;
+}
+
 static const struct drm_connector_funcs vkms_connector_funcs = {
 	.fill_modes = drm_helper_probe_single_connector_modes,
 	.reset = drm_atomic_helper_connector_reset,
+	.detect = vkms_connector_detect,
 	.atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
 };