ryantimwilson / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone
Blob Blame History Raw
From a3eabec96b872bbf581c9bfa81ecc9c2819b8de8 Mon Sep 17 00:00:00 2001
From: David Herrmann <dh.herrmann@gmail.com>
Date: Sat, 20 Sep 2014 09:48:22 +0200
Subject: [PATCH] terminal: grdev: treat udev-devices without devnum as hotplug

If we get udev-device events via sysview, but they lack devnum
annotations, we know it cannot be a DRM card. Look through it's parents
and treat it as hotplug event in case we find such a card.

This will treat any new/removed connectors as sub-devices of the real
card, instead of as devices on its own.
---
 src/libsystemd-terminal/grdev.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/src/libsystemd-terminal/grdev.c b/src/libsystemd-terminal/grdev.c
index 1e02a6799c..bb89ee7170 100644
--- a/src/libsystemd-terminal/grdev.c
+++ b/src/libsystemd-terminal/grdev.c
@@ -1095,7 +1095,7 @@ void grdev_session_add_drm(grdev_session *session, struct udev_device *ud) {
 
         devnum = udev_device_get_devnum(ud);
         if (devnum == 0)
-                return;
+                return grdev_session_hotplug_drm(session, ud);
 
         card = grdev_find_drm_card(session, devnum);
         if (card)
@@ -1120,7 +1120,7 @@ void grdev_session_remove_drm(grdev_session *session, struct udev_device *ud) {
 
         devnum = udev_device_get_devnum(ud);
         if (devnum == 0)
-                return;
+                return grdev_session_hotplug_drm(session, ud);
 
         card = grdev_find_drm_card(session, devnum);
         if (!card)
@@ -1130,17 +1130,23 @@ void grdev_session_remove_drm(grdev_session *session, struct udev_device *ud) {
 }
 
 void grdev_session_hotplug_drm(grdev_session *session, struct udev_device *ud) {
-        grdev_card *card;
+        grdev_card *card = NULL;
+        struct udev_device *p;
         dev_t devnum;
 
         assert(session);
         assert(ud);
 
-        devnum = udev_device_get_devnum(ud);
-        if (devnum == 0)
-                return;
+        for (p = ud; p; p = udev_device_get_parent_with_subsystem_devtype(p, "drm", NULL)) {
+                devnum = udev_device_get_devnum(ud);
+                if (devnum == 0)
+                        continue;
+
+                card = grdev_find_drm_card(session, devnum);
+                if (card)
+                        break;
+        }
 
-        card = grdev_find_drm_card(session, devnum);
         if (!card)
                 return;