[PATCH xserver 06/11] modesetting: Save number of encoders in drmmode_output

Daniel Martin consume.noise at gmail.com
Tue Nov 7 09:38:37 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 | 13 +++++++------
 hw/xfree86/drivers/modesetting/drmmode_display.h |  1 +
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index d19a81911..5bbbb202a 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1355,6 +1355,7 @@ drmmode_output_destroy(xf86OutputPtr output)
     drmmode_output_private_ptr drmmode_output = output->driver_private;
     int i;
 
+    drmModeFreeConnector(drmmode_output->mode_output);
     drmModeFreePropertyBlob(drmmode_output->edid_blob);
     drmModeFreePropertyBlob(drmmode_output->tile_blob);
 
@@ -1363,13 +1364,12 @@ drmmode_output_destroy(xf86OutputPtr output)
         free(drmmode_output->props[i].atoms);
     }
     free(drmmode_output->props);
-    if (drmmode_output->mode_output) {
-        for (i = 0; i < drmmode_output->mode_output->count_encoders; i++) {
-            drmModeFreeEncoder(drmmode_output->mode_encoders[i]);
-        }
-        drmModeFreeConnector(drmmode_output->mode_output);
+
+    for (i = 0; i < drmmode_output->num_encoders; i++) {
+        drmModeFreeEncoder(drmmode_output->mode_encoders[i]);
     }
     free(drmmode_output->mode_encoders);
+
     free(drmmode_output);
     output->driver_private = NULL;
 }
@@ -1757,6 +1757,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 
     drmmode_output->output_id = mode_res->connectors[num];
     drmmode_output->mode_output = koutput;
+    drmmode_output->num_encoders = koutput->count_encoders;
     drmmode_output->mode_encoders = kencoders;
     drmmode_output->drmmode = drmmode;
     output->mm_width = koutput->mmWidth;
@@ -1832,7 +1833,7 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode, drmModeResPtr mode_re
         drmmode_output = output->driver_private;
         drmmode_output->enc_clone_mask = 0xff;
         /* and all the possible encoder clones for this output together */
-        for (j = 0; j < drmmode_output->mode_output->count_encoders; j++) {
+        for (j = 0; j < drmmode_output->num_encoders; j++) {
             int k;
 
             for (k = 0; k < mode_res->count_encoders; k++) {
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index 2630f9347..2174fe07e 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -130,6 +130,7 @@ typedef struct {
     drmmode_ptr drmmode;
     int output_id;
     drmModeConnectorPtr mode_output;
+    int num_encoders;
     drmModeEncoderPtr *mode_encoders;
     drmModePropertyBlobPtr edid_blob;
     drmModePropertyBlobPtr tile_blob;
-- 
2.13.6



More information about the xorg-devel mailing list