xf86-video-intel: src/sna/sna_display.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Feb 13 02:11:48 CET 2014


 src/sna/sna_display.c |   55 +++++++++++++++++++++++++-------------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

New commits:
commit 1c5ccf5d9d8beb7e8343eb2d07bbf97f53c1a224
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Feb 13 01:06:41 2014 +0000

    sna: Always assign a name to the modes
    
    In some cases, such as querying the mode from the CRTC, we may not have
    a name associated with the mode. However, RandR always expects a valid
    name. To satisfy this requirement, always generate the canonical mode
    name if no other is specified.
    
    References: https://bugs.freedesktop.org/show_bug.cgi?id=70132
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 9b05f74..32e74d0 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -710,6 +710,32 @@ done:
 }
 #endif
 
+static char *canonical_kmode_name(const struct drm_mode_modeinfo *kmode)
+{
+	char tmp[32], *buf;
+	int len;
+
+	len = sprintf(tmp, "%dx%d%s",
+		      kmode->hdisplay, kmode->vdisplay,
+		      kmode->flags & V_INTERLACE ? "i" : "");
+	if ((unsigned)len >= sizeof(tmp))
+		return NULL;
+
+	buf = malloc(len + 1);
+	if (buf == NULL)
+		return NULL;
+
+	return memcpy(buf, tmp, len + 1);
+}
+
+static char *get_kmode_name(const struct drm_mode_modeinfo *kmode)
+{
+	if (*kmode->name == '\0')
+		return canonical_kmode_name(kmode);
+
+	return strdup(kmode->name);
+}
+
 static DisplayModePtr
 mode_from_kmode(ScrnInfoPtr scrn,
 		const struct drm_mode_modeinfo *kmode,
@@ -738,7 +764,7 @@ mode_from_kmode(ScrnInfoPtr scrn,
 	mode->VScan = kmode->vscan;
 
 	mode->Flags = kmode->flags;
-	mode->name = strdup(kmode->name);
+	mode->name = get_kmode_name(kmode);
 
 	if (kmode->type & DRM_MODE_TYPE_DRIVER)
 		mode->type = M_T_DRIVER;
@@ -2360,24 +2386,6 @@ sna_output_panel_edid(xf86OutputPtr output, DisplayModePtr modes)
 	return xf86ModesAdd(modes, m);
 }
 
-static char *canonical_mode_name(DisplayModePtr mode)
-{
-	char tmp[32], *buf;
-	int len;
-
-	len = sprintf(tmp, "%dx%d%s",
-		      mode->HDisplay, mode->VDisplay,
-		      mode->Flags & V_INTERLACE ? "i" : "");
-	if ((unsigned)len >= sizeof(tmp))
-		return NULL;
-
-	buf = malloc(len + 1);
-	if (buf == NULL)
-		return NULL;
-
-	return memcpy(buf, tmp, len + 1);
-}
-
 static DisplayModePtr
 sna_output_get_modes(xf86OutputPtr output)
 {
@@ -2426,6 +2434,7 @@ sna_output_get_modes(xf86OutputPtr output)
 				Modes = xf86ModesAdd(Modes, Mode);
 				Mode = NULL;
 			} else {
+				free((void *)current->name);
 				current->name = strdup(Mode->name);
 				current->type = Mode->type;
 			}
@@ -2433,14 +2442,6 @@ sna_output_get_modes(xf86OutputPtr output)
 	}
 	free(Mode);
 
-	if (current && (current->name == NULL || *current->name == '\0')) {
-		char *str = canonical_mode_name(current);
-		if (str) {
-			free((char *)current->name);
-			current->name = str;
-		}
-	}
-
 	/*
 	 * If the connector type is a panel, we will traverse the kernel mode to
 	 * get the panel limit. And then add all the standard modes to fake


More information about the xorg-commit mailing list