xf86-video-ati: Branch 'master' - 3 commits

Dave Airlie airlied at kemper.freedesktop.org
Mon Nov 10 14:40:21 PST 2014


 src/drmmode_display.c |  283 ++++++++++++++++++++++++++++++++++++++++----------
 src/drmmode_display.h |    4 
 src/radeon.h          |    3 
 src/radeon_dri2.c     |    2 
 src/radeon_kms.c      |    7 +
 5 files changed, 242 insertions(+), 57 deletions(-)

New commits:
commit 2f11dcd43966cf2ee26e61960fd72e6644f5e037
Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Nov 10 13:49:29 2014 +1000

    radeon: add support for DP 1.2 display hotplug (v2)
    
    This allows for dynamic creation of conneectors when the
    kernel tells us.
    
    v2: fix dpms off crash
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index dd79db5..a7b75f0 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -978,6 +978,9 @@ drmmode_output_dpms(xf86OutputPtr output, int mode)
 	drmModeConnectorPtr koutput = drmmode_output->mode_output;
 	drmmode_ptr drmmode = drmmode_output->drmmode;
 
+	if (!koutput)
+		return;
+
 	if (mode != DPMSModeOn && output->crtc)
 		drmmode_do_crtc_dpms(output->crtc, mode);
 
@@ -1194,11 +1197,66 @@ const char *output_names[] = { "None",
 
 #define NUM_OUTPUT_NAMES (sizeof(output_names) / sizeof(output_names[0]))
 
+static xf86OutputPtr find_output(ScrnInfoPtr pScrn, int id)
+{
+	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+	int i;
+	for (i = 0; i < xf86_config->num_output; i++) {
+		xf86OutputPtr output = xf86_config->output[i];
+		drmmode_output_private_ptr drmmode_output;
+
+		drmmode_output = output->driver_private;
+		if (drmmode_output->output_id == id)
+			return output;
+	}
+	return NULL;
+}
+
+static int parse_path_blob(drmModePropertyBlobPtr path_blob, int *conn_base_id, char **path)
+{
+	char *conn;
+	char conn_id[5];
+	int id, len;
+	char *blob_data;
+
+	if (!path_blob)
+		return -1;
+
+	blob_data = path_blob->data;
+	/* we only handle MST paths for now */
+	if (strncmp(blob_data, "mst:", 4))
+		return -1;
+
+	conn = strchr(blob_data + 4, '-');
+	if (!conn)
+		return -1;
+	len = conn - (blob_data + 4);
+	if (len + 1 > 5)
+		return -1;
+	memcpy(conn_id, blob_data + 4, len);
+	conn_id[len] = '\0';
+	id = strtoul(conn_id, NULL, 10);
+
+	*conn_base_id = id;
+
+	*path = conn + 1;
+	return 0;
+}
+
 static void
 drmmode_create_name(ScrnInfoPtr pScrn, drmModeConnectorPtr koutput, char *name,
-		    int *num_dvi, int *num_hdmi)
+		    drmModePropertyBlobPtr path_blob, int *num_dvi, int *num_hdmi)
 {
-	{
+	xf86OutputPtr output;
+	int conn_id;
+	char *extra_path;
+
+	output = NULL;
+	if (parse_path_blob(path_blob, &conn_id, &extra_path) == 0)
+		output = find_output(pScrn, conn_id);
+	if (output) {
+		snprintf(name, 32, "%s-%s", output->name, extra_path);
+	} else {
 		if (koutput->connector_type >= NUM_OUTPUT_NAMES)
 			snprintf(name, 32, "Unknown%d-%d", koutput->connector_type,
 				 koutput->connector_type_id - 1);
@@ -1241,14 +1299,16 @@ drmmode_create_name(ScrnInfoPtr pScrn, drmModeConnectorPtr koutput, char *name,
 }
 
 static void
-drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res, int num, int *num_dvi, int *num_hdmi)
+drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res, int num, int *num_dvi, int *num_hdmi, int dynamic)
 {
+	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
 	RADEONInfoPtr info = RADEONPTR(pScrn);
 	xf86OutputPtr output;
 	drmModeConnectorPtr koutput;
 	drmModeEncoderPtr *kencoders = NULL;
 	drmmode_output_private_ptr drmmode_output;
 	drmModePropertyPtr props;
+	drmModePropertyBlobPtr path_blob = NULL;
 	char name[32];
 	int i;
 	const char *s;
@@ -1257,6 +1317,18 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 	if (!koutput)
 		return;
 
+	for (i = 0; i < koutput->count_props; i++) {
+		props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
+		if (props && (props->flags & DRM_MODE_PROP_BLOB)) {
+			if (!strcmp(props->name, "PATH")) {
+				path_blob = drmModeGetPropertyBlob(drmmode->fd, koutput->prop_values[i]);
+				drmModeFreeProperty(props);
+				break;
+			}
+			drmModeFreeProperty(props);
+		}
+	}
+
 	kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders);
 	if (!kencoders) {
 		goto out_free_encoders;
@@ -1269,7 +1341,26 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 		}
 	}
 
-	drmmode_create_name(pScrn, koutput, name, num_dvi, num_hdmi);
+	drmmode_create_name(pScrn, koutput, name, path_blob, num_dvi, num_hdmi);
+	if (path_blob)
+		drmModeFreePropertyBlob(path_blob);
+
+	if (path_blob && dynamic) {
+		/* See if we have an output with this name already
+		 * and hook stuff up.
+		 */
+		for (i = 0; i < xf86_config->num_output; i++) {
+			output = xf86_config->output[i];
+
+			if (strncmp(output->name, name, 32))
+				continue;
+
+			drmmode_output = output->driver_private;
+			drmmode_output->output_id = mode_res->connectors[num];
+			drmmode_output->mode_output = koutput;
+			return;
+		}
+	}
 
 	if (xf86IsEntityShared(pScrn->entityList[0])) {
 		if ((s = xf86GetOptValString(info->Options, OPTION_ZAPHOD_HEADS))) {
@@ -1325,6 +1416,11 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 		}
 	}
 
+	if (dynamic) {
+		output->randr_output = RROutputCreate(xf86ScrnToScreen(pScrn), output->name, strlen(output->name), output);
+		drmmode_output_create_resources(output);
+	}
+
 	return;
 out_free_encoders:
 	if (kencoders){
@@ -1756,7 +1852,7 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 			drmmode_crtc_init(pScrn, drmmode, mode_res, i);
 
 	for (i = 0; i < mode_res->count_connectors; i++)
-		drmmode_output_init(pScrn, drmmode, mode_res, i, &num_dvi, &num_hdmi);
+		drmmode_output_init(pScrn, drmmode, mode_res, i, &num_dvi, &num_hdmi, 0);
 
 	/* workout clones */
 	drmmode_clones_init(pScrn, drmmode, mode_res);
@@ -1982,6 +2078,75 @@ Bool drmmode_setup_colormap(ScreenPtr pScreen, ScrnInfoPtr pScrn)
     return TRUE;
 }
 
+void
+radeon_mode_hotplug(ScrnInfoPtr scrn, drmmode_ptr drmmode)
+{
+	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
+	drmModeResPtr mode_res;
+	int i, j;
+	Bool found;
+	Bool changed = FALSE;
+
+	mode_res = drmModeGetResources(drmmode->fd);
+	if (!mode_res)
+		goto out;
+
+restart_destroy:
+	for (i = 0; i < config->num_output; i++) {
+		xf86OutputPtr output = config->output[i];
+		drmmode_output_private_ptr drmmode_output = output->driver_private;
+		found = FALSE;
+		for (j = 0; j < mode_res->count_connectors; j++) {
+			if (mode_res->connectors[j] == drmmode_output->output_id) {
+				found = TRUE;
+				break;
+			}
+		}
+		if (found)
+			continue;
+
+		drmModeFreeConnector(drmmode_output->mode_output);
+		drmmode_output->mode_output = NULL;
+		drmmode_output->output_id = -1;
+
+		changed = TRUE;
+		if (drmmode->delete_dp_12_displays) {
+			RROutputDestroy(output->randr_output);
+			xf86OutputDestroy(output);
+			goto restart_destroy;
+		}
+	}
+
+	/* find new output ids we don't have outputs for */
+	for (i = 0; i < mode_res->count_connectors; i++) {
+		found = FALSE;
+
+		for (j = 0; j < config->num_output; j++) {
+			xf86OutputPtr output = config->output[j];
+			drmmode_output_private_ptr drmmode_output;
+
+			drmmode_output = output->driver_private;
+			if (mode_res->connectors[i] == drmmode_output->output_id) {
+				found = TRUE;
+				break;
+			}
+		}
+		if (found)
+			continue;
+
+		changed = TRUE;
+		drmmode_output_init(scrn, drmmode, mode_res, i, NULL, NULL, 1);
+	}
+
+	if (changed) {
+		RRSetChanged(xf86ScrnToScreen(scrn));
+		RRTellChanged(xf86ScrnToScreen(scrn));
+	}
+
+	drmModeFreeResources(mode_res);
+out:
+	RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
+}
 #ifdef HAVE_LIBUDEV
 static void
 drmmode_handle_uevents(int fd, void *closure)
@@ -1993,7 +2158,7 @@ drmmode_handle_uevents(int fd, void *closure)
 	if (!dev)
 		return;
 
-	RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
+	radeon_mode_hotplug(scrn, drmmode);
 	udev_device_unref(dev);
 }
 #endif
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 2e83ed5..c9920e0 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -51,6 +51,8 @@ typedef struct {
 #endif
   drmEventContext event_context;
   int count_crtcs;
+
+  Bool delete_dp_12_displays;
 } drmmode_rec, *drmmode_ptr;
 
 typedef struct {
diff --git a/src/radeon.h b/src/radeon.h
index 6123cc2..7b904de 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -148,7 +148,8 @@ typedef enum {
     OPTION_ACCELMETHOD,
     OPTION_EXA_VSYNC,
     OPTION_ZAPHOD_HEADS,
-    OPTION_SWAPBUFFERS_WAIT
+    OPTION_SWAPBUFFERS_WAIT,
+    OPTION_DELETE_DP12,
 } RADEONOpts;
 
 
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index c1a4dec..62364d9 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -73,6 +73,7 @@ const OptionInfoRec RADEONOptions_KMS[] = {
     { OPTION_EXA_PIXMAPS,    "EXAPixmaps",	 OPTV_BOOLEAN,   {0}, FALSE },
     { OPTION_ZAPHOD_HEADS,   "ZaphodHeads",      OPTV_STRING,  {0}, FALSE },
     { OPTION_SWAPBUFFERS_WAIT,"SwapbuffersWait", OPTV_BOOLEAN, {0}, FALSE },
+    { OPTION_DELETE_DP12,    "DeleteUnusedDP12Displays", OPTV_BOOLEAN, {0}, FALSE},
     { -1,                    NULL,               OPTV_NONE,    {0}, FALSE }
 };
 
@@ -937,6 +938,10 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
     xf86DrvMsg(pScrn->scrnIndex, X_INFO,
 	       "SwapBuffers wait for vsync: %sabled\n", info->swapBuffersWait ? "en" : "dis");
 
+    if (xf86ReturnOptValBool(info->Options, OPTION_DELETE_DP12, FALSE)) {
+        info->drmmode.delete_dp_12_displays = TRUE;
+    }
+
     if (drmmode_pre_init(pScrn, &info->drmmode, pScrn->bitsPerPixel / 8) == FALSE) {
 	xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Kernel modesetting setup failed\n");
 	goto fail;
commit c88424d1f4aaa78b569e5d44f0b4a47de2f422f4
Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Nov 10 14:17:54 2014 +1000

    radeon: move output name creation to its own function
    
    The secondary indent is deliberate to make the next patch more
    parseable for mst support.
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index c69abbf..dd79db5 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1195,6 +1195,52 @@ const char *output_names[] = { "None",
 #define NUM_OUTPUT_NAMES (sizeof(output_names) / sizeof(output_names[0]))
 
 static void
+drmmode_create_name(ScrnInfoPtr pScrn, drmModeConnectorPtr koutput, char *name,
+		    int *num_dvi, int *num_hdmi)
+{
+	{
+		if (koutput->connector_type >= NUM_OUTPUT_NAMES)
+			snprintf(name, 32, "Unknown%d-%d", koutput->connector_type,
+				 koutput->connector_type_id - 1);
+#ifdef RADEON_PIXMAP_SHARING
+		else if (pScrn->is_gpu)
+			snprintf(name, 32, "%s-%d-%d",
+				 output_names[koutput->connector_type], pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1,
+				 koutput->connector_type_id - 1);
+#endif
+		else {
+			/* need to do smart conversion here for compat with non-kms ATI driver */
+			if (koutput->connector_type_id == 1) {
+				switch(koutput->connector_type) {
+				case DRM_MODE_CONNECTOR_DVII:
+				case DRM_MODE_CONNECTOR_DVID:
+				case DRM_MODE_CONNECTOR_DVIA:
+					snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], *num_dvi);
+					(*num_dvi)++;
+					break;
+				case DRM_MODE_CONNECTOR_HDMIA:
+				case DRM_MODE_CONNECTOR_HDMIB:
+					snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], *num_hdmi);
+					(*num_hdmi)++;
+					break;
+				case DRM_MODE_CONNECTOR_VGA:
+				case DRM_MODE_CONNECTOR_DisplayPort:
+					snprintf(name, 32, "%s-%d", output_names[koutput->connector_type],
+						 koutput->connector_type_id - 1);
+					break;
+				default:
+					snprintf(name, 32, "%s", output_names[koutput->connector_type]);
+					break;
+				}
+			} else {
+				snprintf(name, 32, "%s-%d", output_names[koutput->connector_type],
+					 koutput->connector_type_id - 1);
+			}
+		}
+	}
+}
+
+static void
 drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res, int num, int *num_dvi, int *num_hdmi)
 {
 	RADEONInfoPtr info = RADEONPTR(pScrn);
@@ -1223,44 +1269,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_r
 		}
 	}
 
-	if (koutput->connector_type >= NUM_OUTPUT_NAMES)
-		snprintf(name, 32, "Unknown%d-%d", koutput->connector_type,
-			 koutput->connector_type_id - 1);
-#ifdef RADEON_PIXMAP_SHARING
-	else if (pScrn->is_gpu)
-		snprintf(name, 32, "%s-%d-%d",
-			 output_names[koutput->connector_type], pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1,
-			 koutput->connector_type_id - 1);
-#endif
-	else {
-		/* need to do smart conversion here for compat with non-kms ATI driver */
-		if (koutput->connector_type_id == 1) {
-			switch(koutput->connector_type) {
-			case DRM_MODE_CONNECTOR_DVII:
-			case DRM_MODE_CONNECTOR_DVID:
-			case DRM_MODE_CONNECTOR_DVIA:
-				snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], *num_dvi);
-				(*num_dvi)++;
-				break;
-			case DRM_MODE_CONNECTOR_HDMIA:
-			case DRM_MODE_CONNECTOR_HDMIB:
-				snprintf(name, 32, "%s-%d", output_names[koutput->connector_type], *num_hdmi);
-				(*num_hdmi)++;
-				break;
-			case DRM_MODE_CONNECTOR_VGA:
-			case DRM_MODE_CONNECTOR_DisplayPort:
-				snprintf(name, 32, "%s-%d", output_names[koutput->connector_type],
-					 koutput->connector_type_id - 1);
-				break;
-			default:
-				snprintf(name, 32, "%s", output_names[koutput->connector_type]);
-				break;
-			}
-		} else {
-			snprintf(name, 32, "%s-%d", output_names[koutput->connector_type],
-				 koutput->connector_type_id - 1);
-		}
-	}
+	drmmode_create_name(pScrn, koutput, name, num_dvi, num_hdmi);
 
 	if (xf86IsEntityShared(pScrn->entityList[0])) {
 		if ((s = xf86GetOptValString(info->Options, OPTION_ZAPHOD_HEADS))) {
commit 32b003cb7657e07d5af6338ad44d768eda87fd33
Author: Dave Airlie <airlied at redhat.com>
Date:   Mon Nov 10 14:12:34 2014 +1000

    radeon: stop caching mode resources
    
    This is step one towards MST connector hotplug support,
    it stop caching the mode resources structure, and
    just passes a pointer to it around.
    
    Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
    Signed-off-by: Dave Airlie <airlied at redhat.com>

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index ef5dfbe..c69abbf 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -850,7 +850,7 @@ void drmmode_crtc_hw_id(xf86CrtcPtr crtc)
 }
 
 static void
-drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
+drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res, int num)
 {
 	xf86CrtcPtr crtc;
 	drmmode_crtc_private_ptr drmmode_crtc;
@@ -860,7 +860,7 @@ drmmode_crtc_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num)
 		return;
 
 	drmmode_crtc = xnfcalloc(sizeof(drmmode_crtc_private_rec), 1);
-	drmmode_crtc->mode_crtc = drmModeGetCrtc(drmmode->fd, drmmode->mode_res->crtcs[num]);
+	drmmode_crtc->mode_crtc = drmModeGetCrtc(drmmode->fd, mode_res->crtcs[num]);
 	drmmode_crtc->drmmode = drmmode;
 	crtc->driver_private = drmmode_crtc;
 	drmmode_crtc_hw_id(crtc);
@@ -1195,7 +1195,7 @@ const char *output_names[] = { "None",
 #define NUM_OUTPUT_NAMES (sizeof(output_names) / sizeof(output_names[0]))
 
 static void
-drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dvi, int *num_hdmi)
+drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, drmModeResPtr mode_res, int num, int *num_dvi, int *num_hdmi)
 {
 	RADEONInfoPtr info = RADEONPTR(pScrn);
 	xf86OutputPtr output;
@@ -1207,7 +1207,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dv
 	int i;
 	const char *s;
 
-	koutput = drmModeGetConnector(drmmode->fd, drmmode->mode_res->connectors[num]);
+	koutput = drmModeGetConnector(drmmode->fd, mode_res->connectors[num]);
 	if (!koutput)
 		return;
 
@@ -1285,7 +1285,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dv
 		goto out_free_encoders;
 	}
 
-	drmmode_output->output_id = drmmode->mode_res->connectors[num];
+	drmmode_output->output_id = mode_res->connectors[num];
 	drmmode_output->mode_output = koutput;
 	drmmode_output->mode_encoders = kencoders;
 	drmmode_output->drmmode = drmmode;
@@ -1354,7 +1354,7 @@ uint32_t find_clones(ScrnInfoPtr scrn, xf86OutputPtr output)
 
 
 static void
-drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
+drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode, drmModeResPtr mode_res)
 {
 	int i, j;
 	xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(scrn);
@@ -1369,8 +1369,8 @@ drmmode_clones_init(ScrnInfoPtr scrn, drmmode_ptr drmmode)
 		for (j = 0; j < drmmode_output->mode_output->count_encoders; j++)
 		{
 			int k;
-			for (k = 0; k < drmmode->mode_res->count_encoders; k++) {
-				if (drmmode->mode_res->encoders[k] == drmmode_output->mode_encoders[j]->encoder_id)
+			for (k = 0; k < mode_res->count_encoders; k++) {
+				if (mode_res->encoders[k] == drmmode_output->mode_encoders[j]->encoder_id)
 					drmmode_output->enc_mask |= (1 << k);
 			}
 
@@ -1730,25 +1730,27 @@ drm_wakeup_handler(pointer data, int err, pointer p)
 Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 {
 	int i, num_dvi = 0, num_hdmi = 0;
+	drmModeResPtr mode_res;
 
 	xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs);
 
 	drmmode->scrn = pScrn;
 	drmmode->cpp = cpp;
-	drmmode->mode_res = drmModeGetResources(drmmode->fd);
-	if (!drmmode->mode_res)
+	mode_res = drmModeGetResources(drmmode->fd);
+	if (!mode_res)
 		return FALSE;
 
-	xf86CrtcSetSizeRange(pScrn, 320, 200, drmmode->mode_res->max_width, drmmode->mode_res->max_height);
-	for (i = 0; i < drmmode->mode_res->count_crtcs; i++)
+	drmmode->count_crtcs = mode_res->count_crtcs;
+	xf86CrtcSetSizeRange(pScrn, 320, 200, mode_res->max_width, mode_res->max_height);
+	for (i = 0; i < mode_res->count_crtcs; i++)
 		if (!xf86IsEntityShared(pScrn->entityList[0]) || pScrn->confScreen->device->screen == i)
-			drmmode_crtc_init(pScrn, drmmode, i);
+			drmmode_crtc_init(pScrn, drmmode, mode_res, i);
 
-	for (i = 0; i < drmmode->mode_res->count_connectors; i++)
-		drmmode_output_init(pScrn, drmmode, i, &num_dvi, &num_hdmi);
+	for (i = 0; i < mode_res->count_connectors; i++)
+		drmmode_output_init(pScrn, drmmode, mode_res, i, &num_dvi, &num_hdmi);
 
 	/* workout clones */
-	drmmode_clones_init(pScrn, drmmode);
+	drmmode_clones_init(pScrn, drmmode, mode_res);
 
 #ifdef RADEON_PIXMAP_SHARING
 	xf86ProviderSetup(pScrn, NULL, "radeon");
@@ -1760,6 +1762,7 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int cpp)
 	drmmode->event_context.vblank_handler = drmmode_vblank_handler;
 	drmmode->event_context.page_flip_handler = drmmode_flip_handler;
 
+	drmModeFreeResources(mode_res);
 	return TRUE;
 }
 
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 41e29f6..2e83ed5 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -41,7 +41,6 @@
 typedef struct {
   int fd;
   unsigned fb_id;
-  drmModeResPtr mode_res;
   drmModeFBPtr mode_fb;
   int cpp;
   struct radeon_bo_manager *bufmgr;
@@ -51,6 +50,7 @@ typedef struct {
   InputHandlerProc uevent_handler;
 #endif
   drmEventContext event_context;
+  int count_crtcs;
 } drmmode_rec, *drmmode_ptr;
 
 typedef struct {
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 64e541f..56beeec 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -1581,7 +1581,7 @@ radeon_dri2_screen_init(ScreenPtr pScreen)
 	scheduling_works = FALSE;
     }
 
-    if (scheduling_works && info->drmmode.mode_res->count_crtcs > 2) {
+    if (scheduling_works && info->drmmode.count_crtcs > 2) {
 #ifdef DRM_CAP_VBLANK_HIGH_CRTC
 	uint64_t cap_value;
 
diff --git a/src/radeon_kms.c b/src/radeon_kms.c
index b6d11e8..c1a4dec 100644
--- a/src/radeon_kms.c
+++ b/src/radeon_kms.c
@@ -942,7 +942,7 @@ Bool RADEONPreInit_KMS(ScrnInfoPtr pScrn, int flags)
 	goto fail;
     }
 
-    if (info->drmmode.mode_res->count_crtcs == 1)
+    if (info->drmmode.count_crtcs == 1)
         pRADEONEnt->HasCRTC2 = FALSE;
     else
         pRADEONEnt->HasCRTC2 = TRUE;


More information about the xorg-commit mailing list