Skip to contentSkip to conversation

intel/uxa/display: drop mode_res caching.

PATCH In review Dave Airlie 2 participants 4 messages Sep 3, 2014 – Sep 7, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 intel/uxa/display: drop mode_res caching.

From: Dave Airlie <[email protected]>

This will cause problems with MST displays.

---
 src/uxa/intel_display.c | 39 ++++++++++++++++++++-------------------
 1 file changed, 20 insertions(+), 19 deletions(-)
src/uxa/intel_display.c +20 -19
index 0b83140..7cdb85f 100644
@@ -80,7 +80,6 @@ static struct list intel_drm_queue;
 struct intel_mode {
 	int fd;
 	uint32_t fb_id;
-	drmModeResPtr mode_res;
 	int cpp;
 
 	drmEventContext event_context;
@@ -706,7 +705,7 @@ static const xf86CrtcFuncsRec intel_crtc_funcs = {
 };
 
 static void
-intel_crtc_init(ScrnInfoPtr scrn, struct intel_mode *mode, int num)
+intel_crtc_init(ScrnInfoPtr scrn, struct intel_mode *mode, drmModeResPtr mode_res, int num)
 {
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 	xf86CrtcPtr crtc;
@@ -723,7 +722,7 @@ intel_crtc_init(ScrnInfoPtr scrn, struct intel_mode *mode, int num)
 	}
 
 	intel_crtc->mode_crtc = drmModeGetCrtc(mode->fd,
-					       mode->mode_res->crtcs[num]);
+					       mode_res->crtcs[num]);
 	if (intel_crtc->mode_crtc == NULL) {
 		free(intel_crtc);
 		return;
@@ -1340,7 +1339,7 @@ static const char *output_names[] = {
 };
 
 static void
-intel_output_init(ScrnInfoPtr scrn, struct intel_mode *mode, int num)
+intel_output_init(ScrnInfoPtr scrn, struct intel_mode *mode, drmModeResPtr mode_res, int num)
 {
 	xf86OutputPtr output;
 	drmModeConnectorPtr koutput;
@@ -1350,7 +1349,7 @@ intel_output_init(ScrnInfoPtr scrn, struct intel_mode *mode, int num)
 	char name[32];
 
 	koutput = drmModeGetConnector(mode->fd,
-				      mode->mode_res->connectors[num]);
+				      mode_res->connectors[num]);
 	if (!koutput)
 		return;
 
@@ -1381,7 +1380,7 @@ intel_output_init(ScrnInfoPtr scrn, struct intel_mode *mode, int num)
 		return;
 	}
 
-	intel_output->output_id = mode->mode_res->connectors[num];
+	intel_output->output_id = mode_res->connectors[num];
 	intel_output->mode_output = koutput;
 	intel_output->mode_encoder = kencoder;
 	intel_output->mode = mode;
@@ -1964,10 +1963,10 @@ intel_mode_read_drm_events(struct intel_screen_private *intel)
 }
 
 static drmModeEncoderPtr
-intel_get_kencoder(struct intel_mode *mode, int num)
+intel_get_kencoder(struct intel_mode *mode, drmModeResPtr mode_res, int num)
 {
 	struct intel_output *iterator;
-	int id = mode->mode_res->encoders[num];
+	int id = mode_res->encoders[num];
 
 	list_for_each_entry(iterator, &mode->outputs, link)
 		if (iterator->mode_encoder->encoder_id == id)
@@ -1982,7 +1981,7 @@ intel_get_kencoder(struct intel_mode *mode, int num)
  * values read from libdrm.
  */
 static void
-intel_compute_possible_clones(ScrnInfoPtr scrn, struct intel_mode *mode)
+intel_compute_possible_clones(ScrnInfoPtr scrn, struct intel_mode *mode, drmModeResPtr mode_res)
 {
 	xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
 	struct intel_output *intel_output, *clone;
@@ -2001,7 +2000,7 @@ intel_compute_possible_clones(ScrnInfoPtr scrn, struct intel_mode *mode)
 			if ((mask & 1) == 0)
 				continue;
 
-			cloned_encoder = intel_get_kencoder(mode, j);
+			cloned_encoder = intel_get_kencoder(mode, mode_res, j);
 			if (!cloned_encoder)
 				continue;
 
@@ -2024,6 +2023,7 @@ Bool intel_mode_pre_init(ScrnInfoPtr scrn, int fd, int cpp)
 	struct intel_mode *mode;
 	unsigned int i;
 	int has_flipping;
+	drmModeResPtr mode_res;
 
 	mode = calloc(1, sizeof *mode);
 	if (!mode)
@@ -2037,23 +2037,23 @@ Bool intel_mode_pre_init(ScrnInfoPtr scrn, int fd, int cpp)
 	xf86CrtcConfigInit(scrn, &intel_xf86crtc_config_funcs);
 
 	mode->cpp = cpp;
-	mode->mode_res = drmModeGetResources(mode->fd);
-	if (!mode->mode_res) {
+	mode_res = drmModeGetResources(mode->fd);
+	if (!mode_res) {
 		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 			   "failed to get resources: %s\n", strerror(errno));
 		free(mode);
 		return FALSE;
 	}
 
-	xf86CrtcSetSizeRange(scrn, 320, 200, mode->mode_res->max_width,
-			     mode->mode_res->max_height);
-	for (i = 0; i < mode->mode_res->count_crtcs; i++)
-		intel_crtc_init(scrn, mode, i);
+	xf86CrtcSetSizeRange(scrn, 320, 200, mode_res->max_width,
+			     mode_res->max_height);
+	for (i = 0; i < mode_res->count_crtcs; i++)
+		intel_crtc_init(scrn, mode, mode_res, i);
 
-	for (i = 0; i < mode->mode_res->count_connectors; i++)
-		intel_output_init(scrn, mode, i);
+	for (i = 0; i < mode_res->count_connectors; i++)
+		intel_output_init(scrn, mode, mode_res, i);
 
-	intel_compute_possible_clones(scrn, mode);
+	intel_compute_possible_clones(scrn, mode, mode_res);
 
 #ifdef INTEL_PIXMAP_SHARING
 	xf86ProviderSetup(scrn, NULL, "Intel");
@@ -2081,6 +2081,7 @@ Bool intel_mode_pre_init(ScrnInfoPtr scrn, int fd, int cpp)
 	}
 
 	intel->modes = mode;
+	drmModeFreeResources(mode_res);
 	return TRUE;
 }
 
Signature · 1 line
1.9.3
#1 lore raw

PATCH 2/2 intel/uxa: add MST support.

From: Dave Airlie <[email protected]>

This adds MST support to the UXA paths in the driver.

---
 src/uxa/intel.h         |   1 +
 src/uxa/intel_display.c | 345 +++++++++++++++++++++++++++++++++++++++---------
 src/uxa/intel_driver.c  |   4 +-
 3 files changed, 289 insertions(+), 61 deletions(-)
src/uxa/intel.h +1 -0
index 409635d..eebe08f 100644
@@ -408,6 +408,7 @@ extern void intel_mode_remove_fb(intel_screen_private *intel);
 extern void intel_mode_close(intel_screen_private *intel);
 extern void intel_mode_fini(intel_screen_private *intel);
 extern int intel_mode_read_drm_events(intel_screen_private *intel);
+extern void intel_mode_hotplug(intel_screen_private *intel);
 
 typedef void (*intel_drm_handler_proc)(ScrnInfoPtr scrn,
                                        xf86CrtcPtr crtc,
src/uxa/intel_display.c +285 -60

470 lines not on this page · raw message

src/uxa/intel_driver.c +3 -1
index a7ca906..7877eb5 100644
@@ -779,7 +779,9 @@ I830HandleUEvents(int fd, void *closure)
 
 	if (memcmp(&s.st_rdev, &udev_devnum, sizeof (dev_t)) == 0 &&
 			hotplug && atoi(hotplug) == 1)
-		RRGetInfo(xf86ScrnToScreen(scrn), TRUE);
+	{
+		intel_mode_hotplug(intel);
+	}
 
 	udev_device_unref(dev);
 }
Signature · 1 line
1.9.3
#2 lore raw

Re: [PATCH 2/2] intel/uxa: add MST support.

Quoted 13 lines · Dave Airlie
src/uxa/intel_display.c +5 -0
@@ -808,6 +815,11 @@ intel_output_attach_edid(xf86OutputPtr output)
 	xf86MonPtr mon = NULL;
 	int i;
 
+	if (!koutput) {
+		xf86OutputSetEDID(output, mon);
+		return;
+	}
+
 	/* look for an EDID property */
 	for (i = 0; i < koutput->count_props; i++) {
 		drmModePropertyPtr props;

src/uxa/intel_display.c intel_output_get_modes(xf86OutputPtr output) · line 917

Quoted 9 lines
src/uxa/intel_display.c +3 -0
@@ -897,6 +909,9 @@ intel_output_get_modes(xf86OutputPtr output)
 
 	intel_output_attach_edid(output);
 
+	if (!koutput)
+		return Modes;
+
 	/* modes should already be available */
 	for (i = 0; i < koutput->count_modes; i++) {
 		DisplayModePtr Mode;

You don't hook into intel_output_detect() and report disconnected? Oh, the code will already fail at drmModeGetConector().

So given that the output is disconnected, these two should never be called?
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw

Re: [PATCH 2/2] intel/uxa: add MST support.

In reply to Dave Airlie
Quoted 5 lines · Dave Airlie

From: Dave Airlie <[email protected]>

This adds MST support to the UXA paths in the driver.

I noticed that you changed the output naming scheme, so I restored the current scheme and pushed,
aa10f48..908520a master -> master

Thanks,
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre