Skip to contentSkip to conversation

drm/kms: Add separate hotplug event call for drm connector

RFC PATCH New Mohammed Khajapasha 2 participants 2 messages Sep 2, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 drm/kms: Add separate hotplug event call for drm connector

Add separate hotplug event call for drm connector. Currently from uevent, user space doesn't know which connector got disconnected when multiple connectors are connected to DRM.

---
 drivers/gpu/drm/drm_probe_helper.c | 30 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/drm_sysfs.c        | 26 ++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)
drivers/gpu/drm/drm_probe_helper.c +30 -0
index d6017726cc2a..d9a38569cfe1 100644
@@ -588,6 +588,36 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector,
 }
 EXPORT_SYMBOL(drm_helper_probe_single_connector_modes);
 
+/**
+ * drm_kms_connector_hotplug_helper - fire off KMS connector hotplug event
+ * @dev: drm_device whose connector state changed
+ * @connector: drm_connector which connected/disconnected
+ *
+ * This function fires off the uevent for userspace and also calls the
+ * output_poll_changed function, which is most commonly used to inform the fbdev
+ * emulation code and allow it to update the fbcon output configuration.
+ *
+ * Drivers should call this from their hotplug handling code when a change is
+ * detected. Note that this function does not do any output detection of its
+ * own, like drm_helper_hpd_irq_event() does - this is assumed to be done by the
+ * driver already.
+ *
+ * This function must be called from process context with no mode
+ * setting locks held.
+ *
+ */
+void drm_kms_connector_hotplug_helper(struct drm_device *dev,
+		struct drm_connector *connector)
+{
+	drm_sysfs_connector_hotplug_event(dev, connector);
+
+	if (dev->mode_config.funcs->output_poll_changed)
+		dev->mode_config.funcs->output_poll_changed(dev);
+
+	drm_client_dev_hotplug(dev);
+}
+EXPORT_SYMBOL(drm_kms_connector_hotplug_helper);
+
 /**
  * drm_kms_helper_hotplug_event - fire off KMS hotplug events
  * @dev: drm_device whose connector state changed
drivers/gpu/drm/drm_sysfs.c +26 -0
index f0336c804639..31bd08e1f77d 100644
@@ -344,6 +344,32 @@ void drm_sysfs_hotplug_event(struct drm_device *dev)
 }
 EXPORT_SYMBOL(drm_sysfs_hotplug_event);
 
+/**
+ * drm_sysfs_connector_hotplug_event - generate a connector hotplug uevent
+ * @dev: DRM device
+ *
+ * Send a uevent for the DRM device specified by @dev. Currently we only
+ * set HOTPLUG=1 and connector id in the uevent environment, but this could be
+ * expanded to deal with other types of events.
+ *
+ * Any new uapi should be using the drm_sysfs_connector_status_event()
+ * for uevents on connector status change.
+ */
+void drm_sysfs_connector_hotplug_event(struct drm_device *dev,
+		struct drm_connector *connector)
+{
+	char hotplug_str[] = "HOTPLUG=1", conn_id[21];
+	char *envp[] = { hotplug_str, conn_id, NULL };
+
+	snprintf(conn_id, ARRAY_SIZE(conn_id),
+			"CONNECTOR=%u", connector->base.id);
+
+	DRM_DEBUG("generating connector hotplug event\n");
+
+	kobject_uevent_env(&dev->primary->kdev->kobj, KOBJ_CHANGE, envp);
+}
+EXPORT_SYMBOL(drm_sysfs_connector_hotplug_event);
+
 /**
  * drm_sysfs_connector_status_event - generate a DRM uevent for connector
  * property status change
Signature · 6 lines
2.24.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/kms: Add separate hotplug event call for drm connector

== Series Details ==

== Series Details ==

Series: drm/kms: Add separate hotplug event call for drm connector
URL : https://patchwork.freedesktop.org/series/81257/
State : failure

== Summary ==

CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
CC drivers/gpu/drm/drm_probe_helper.o
drivers/gpu/drm/drm_probe_helper.c: In function ‘drm_kms_connector_hotplug_helper’:
drivers/gpu/drm/drm_probe_helper.c:612:2: error: implicit declaration of function ‘drm_sysfs_connector_hotplug_event’; did you mean ‘drm_sysfs_connector_status_event’? [-Werror=implicit-function-declaration]
drm_sysfs_connector_hotplug_event(dev, connector);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drm_sysfs_connector_status_event
cc1: some warnings being treated as errors
scripts/Makefile.build:283: recipe for target 'drivers/gpu/drm/drm_probe_helper.o' failed
make[3]: *** [drivers/gpu/drm/drm_probe_helper.o] Error 1
scripts/Makefile.build:500: recipe for target 'drivers/gpu/drm' failed
make[2]: *** [drivers/gpu/drm] Error 2
scripts/Makefile.build:500: recipe for target 'drivers/gpu' failed
make[1]: *** [drivers/gpu] Error 2
Makefile:1788: recipe for target 'drivers' failed
make: *** [drivers] Error 2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx