[PATCH xserver 3/6] modesetting: Retrieve drm connector in drmmode_output_create_resources()

Daniel Martin consume.noise at gmail.com
Mon Nov 20 09:54:03 UTC 2017


So, we don't rely on the mode_output member.

Signed-off-by: Daniel Martin <consume.noise at gmail.com>
---
 hw/xfree86/drivers/modesetting/drmmode_display.c | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index f17598c23..4e8b7e51b 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1424,25 +1424,31 @@ static void
 drmmode_output_create_resources(xf86OutputPtr output)
 {
     drmmode_output_private_ptr drmmode_output = output->driver_private;
-    drmModeConnectorPtr mode_output = drmmode_output->mode_output;
     drmmode_ptr drmmode = drmmode_output->drmmode;
+    drmModeConnectorPtr koutput;
     drmModePropertyPtr drmmode_prop;
     int i, j, err;
 
+    /* Just need properties. drmModeGetConnectorCurrent() is sufficient. */
+    koutput = drmModeGetConnectorCurrent(drmmode->fd,
+            drmmode_output->output_id);
+    if (!koutput)
+        return;
+
     drmmode_output->props =
-        calloc(mode_output->count_props, sizeof(drmmode_prop_rec));
+        calloc(koutput->count_props, sizeof(drmmode_prop_rec));
     if (!drmmode_output->props)
-        return;
+        goto bail_out;
 
     drmmode_output->num_props = 0;
-    for (i = 0, j = 0; i < mode_output->count_props; i++) {
-        drmmode_prop = drmModeGetProperty(drmmode->fd, mode_output->props[i]);
+    for (i = 0, j = 0; i < koutput->count_props; i++) {
+        drmmode_prop = drmModeGetProperty(drmmode->fd, koutput->props[i]);
         if (drmmode_property_ignore(drmmode_prop)) {
             drmModeFreeProperty(drmmode_prop);
             continue;
         }
         drmmode_output->props[j].mode_prop = drmmode_prop;
-        drmmode_output->props[j].value = mode_output->prop_values[i];
+        drmmode_output->props[j].value = koutput->prop_values[i];
         drmmode_output->num_props++;
         j++;
     }
@@ -1516,6 +1522,9 @@ drmmode_output_create_resources(xf86OutputPtr output)
             }
         }
     }
+
+bail_out:
+    drmModeFreeConnector(koutput);
 }
 
 static Bool
-- 
2.13.6



More information about the xorg-devel mailing list