[PATCH] Churn output names

Gregory M. Turner gmt at be-evil.net
Tue May 27 04:28:49 PDT 2014


If a non-primary card (from BIOS's/vgaswitcheroo perspective) was made
the xorg primary Driver, the old "UMS naming compatibilty" code in
drmmode_output_init never ran, because the associated connector_type
value was not 1.  On my workstation that was resulting in an output
name conflict (and painful consequent woes in randr).

This drops the UMS output naming hacks entirely, which don't seem
particularly maintainable in the post-randr-1.4 era.

Instead, it gambles on the hypothesis that the
<connector_type, connector_type_id> tuple will always be unique on a
per-provider basis, by introducing explicit, unique per-connector-type
names: DVI-{I,D,A} and (somewhat awkwardly) HDMI{,-B}.

This will break some xorg.conf's using the "Monitor-OutputName"
convention, unfortunately.  We might spare the occasional victim by using
"DVI" for DVI-I, but I figured that was too confusing/random.

Signed-off-by: Gregory M. Turner <gmt at be-evil.net>
---
 src/drmmode_display.c | 66 +++++++++++++++++++--------------------------------
 1 file changed, 24 insertions(+), 42 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index bd8e701..966f873 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -32,6 +32,7 @@
 #include <errno.h>
 #include <sys/ioctl.h>
 #include <time.h>
+#include <string.h>
 #include "micmap.h"
 #include "xf86cmap.h"
 #include "radeon.h"
@@ -1167,9 +1168,9 @@ static int subpixel_conv_table[7] = { 0, SubPixelUnknown,
 
 const char *output_names[] = { "None",
 			       "VGA",
-			       "DVI",
-			       "DVI",
-			       "DVI",
+			       "DVI-I",
+			       "DVI-D",
+			       "DVI-A",
 			       "Composite",
 			       "S-video",
 			       "LVDS",
@@ -1177,7 +1178,7 @@ const char *output_names[] = { "None",
 			       "DIN",
 			       "DisplayPort",
 			       "HDMI",
-			       "HDMI",
+			       "HDMI-B",
 			       "TV",
 			       "eDP"
 };
@@ -1185,7 +1186,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, int num)
 {
 	RADEONInfoPtr info = RADEONPTR(pScrn);
 	xf86OutputPtr output;
@@ -1193,7 +1194,7 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dv
 	drmModeEncoderPtr *kencoders = NULL;
 	drmmode_output_private_ptr drmmode_output;
 	drmModePropertyPtr props;
-	char name[32];
+	char prefix[32], name[32];
 	int i;
 	const char *s;
 
@@ -1213,43 +1214,24 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int num, int *num_dv
 		}
 	}
 
-	if (koutput->connector_type >= NUM_OUTPUT_NAMES)
-		snprintf(name, 32, "Unknown%d-%d", koutput->connector_type,
-			 koutput->connector_type_id - 1);
+	if (koutput->connector_type >= NUM_OUTPUT_NAMES) {
 #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,
+		if (pScrn->is_gpu)
+			snprintf(prefix, 32, "Unknown-%d", pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1);
+		else
+#endif
+			strncpy(prefix, "Unknown", 32);
+		snprintf(name, 32, "%s-%d-%d", prefix, koutput->connector_type,
 			 koutput->connector_type_id - 1);
+	} else {
+#ifdef RADEON_PIXMAP_SHARING
+		if (pScrn->is_gpu)
+			snprintf(prefix, 32, "%s-%d", output_names[koutput->connector_type],
+				 pScrn->scrnIndex - GPU_SCREEN_OFFSET + 1);
+		else
 #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);
-		}
+			strncpy(prefix, output_names[koutput->connector_type], 32);
+		snprintf(name, 32, "%s-%d", prefix, koutput->connector_type_id - 1);
 	}
 
 	if (xf86IsEntityShared(pScrn->entityList[0])) {
@@ -1719,7 +1701,7 @@ 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;
+	int i;
 
 	xf86CrtcConfigInit(pScrn, &drmmode_xf86crtc_config_funcs);
 
@@ -1735,7 +1717,7 @@ Bool 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, &num_dvi, &num_hdmi);
+		drmmode_output_init(pScrn, drmmode, i);
 
 	/* workout clones */
 	drmmode_clones_init(pScrn, drmmode);
-- 
1.9.3



More information about the xorg-driver-ati mailing list