summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-02-13 01:06:41 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2014-02-13 01:10:48 +0000
commit1c5ccf5d9d8beb7e8343eb2d07bbf97f53c1a224 (patch)
treeff44f89ac3e26843bf0e4c227662050924287b1c
parentfb89bfc73f4103ca6116c8f91970f4bfa491636c (diff)
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@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_display.c55
1 files changed, 28 insertions, 27 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 9b05f740..32e74d0b 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