VKMS driver does not currently support connector hotpluging. Add an option to change the connector status once a device is created. Signed-off-by: José Expósito <jose.exposito89@xxxxxxxxx> [adpated it for my implementation] Signed-off-by: Louis Chauvet <louis.chauvet@xxxxxxxxxxx> --- drivers/gpu/drm/vkms/vkms_config.c | 10 ++++++++++ drivers/gpu/drm/vkms/vkms_config.h | 4 ++++ drivers/gpu/drm/vkms/vkms_output.c | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c index 57e211e48a90d3a4d7f8677c40a2b35d44b847e5..5eba4284269d058f12f78ddba96cb40215e85f72 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" @@ -160,10 +161,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 72bfaadd4322f9e1607a6b9425fb8aaf8bd9d5f6..8e0c9b753821f75f10b3090743905471d0abac36 100644 --- a/drivers/gpu/drm/vkms/vkms_config.h +++ b/drivers/gpu/drm/vkms/vkms_config.h @@ -103,11 +103,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 50aa802da479e5ba383e5db49dc2c7c6981f0bef..75d90df44da3b6dd3ed3ae104a6bc6d51c9bf089 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -7,9 +7,33 @@ #include <drm/drm_managed.h> #include <drm/drm_probe_helper.h> +static struct vkms_config_connector *vkms_config_connector_from_vkms_connector(struct drm_connector *connector) +{ + struct vkms_device *vkms_device = drm_device_to_vkms_device(connector->dev); + struct vkms_config_connector *connector_cfg; + + list_for_each_entry(connector_cfg, &vkms_device->config->connectors, link) { + if (connector_cfg->connector == connector) + return connector_cfg; + } + return NULL; +} + +static enum drm_connector_status vkms_connector_detect(struct drm_connector *connector, bool force) +{ + enum drm_connector_status status = connector->status; + struct vkms_config_connector *connector_cfg = vkms_config_connector_from_vkms_connector(connector); + + if (connector_cfg) + status = connector_cfg->status; + + 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, }; -- 2.47.1