[PATCH 9/9] modesetting: XXX - Only track connected outputs

Daniel Martin daniel.martin at secunet.com
Mon Dec 8 03:03:08 PST 2014


This patch is not meant to be merged. Its purpose is to be able to test
the output hotplug handling on maschines that don't hotplug outputs.

With this patch an output will be added or removed depending on its
connector state (connected? -> add, otherwise -> remove or ignore).
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 28 +++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 23be9ef..293e907 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -617,6 +617,22 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
     crtc->driver_private = drmmode_crtc;
 }
 
+static Bool /* XXX - for testing: helper function */
+drmmode_output_is_connected(int fd, uint32_t connector_id)
+{
+    Bool is_connected = FALSE;
+    drmModeConnectorPtr mode_connector;
+
+    if ((mode_connector = drmModeGetConnector(fd, connector_id))) {
+        if (mode_connector->connection == DRM_MODE_CONNECTED)
+            is_connected = TRUE;
+
+        drmModeFreeConnector(mode_connector);
+    }
+
+    return is_connected;
+}
+
 static xf86OutputStatus
 drmmode_output_detect(xf86OutputPtr output)
 {
@@ -1329,7 +1345,11 @@ drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
             drmmode_crtc_init(pScrn, drmmode, i);
 
     for (i = 0; i < drmmode->mode_res->count_connectors; i++)
-        drmmode_output_init(pScrn, drmmode, i);
+        /* XXX - for testing: only track connected outputs */
+        if (drmmode_output_is_connected(drmmode->fd,
+                                        drmmode->mode_res->connectors[i])) {
+            drmmode_output_init(pScrn, drmmode, i);
+        }
 
     /* workout clones */
     drmmode_clones_init(pScrn, drmmode);
@@ -1605,6 +1625,12 @@ drmmode_output_eval(drmmode_ptr drmmode)
     for (i = 0; i < mode_res->count_connectors; i++) {
         Bool found = FALSE;
 
+        /* XXX - for testing: only track connected outputs */
+        if (!drmmode_output_is_connected(drmmode->fd,
+                                         mode_res->connectors[i])) {
+            continue;
+        }
+
         for (j = 0; j < old_num_output; j++) {
             drmmode_output_private_ptr drmmode_output;
 
-- 
2.1.3



More information about the xorg-devel mailing list