summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-10-21 13:35:24 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-10-21 13:37:40 +0100
commit11211cd7c06a80c2dbbe07360857486b5b0d3094 (patch)
treed44bd5b832a2f7d26a59ca3f61adb4d6d2176a5b
parent5d5dfb3e7a6056df7f6af1bcdc789a50ed00b068 (diff)
sna: Set the canonical name for the current mode if none match
Always give the mode a name for pretty printing for the user. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/sna_display.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index d7ef344f..d630d763 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -2089,6 +2089,29 @@ sna_output_panel_edid(xf86OutputPtr output, DisplayModePtr modes)
return xf86ModesAdd(modes, m);
}
+static int _canonical_mode_name(DisplayModePtr mode, char *str)
+{
+ return sprintf(str, "%dx%d%s",
+ mode->HDisplay, mode->VDisplay,
+ mode->Flags & V_INTERLACE ? "i" : "");
+}
+
+static char *canonical_mode_name(DisplayModePtr mode)
+{
+ char *str;
+ int len;
+
+ len = _canonical_mode_name(mode, NULL);
+ if (len < 0)
+ return NULL;
+
+ str = malloc(len + 1);
+ if (str != NULL)
+ _canonical_mode_name(mode, str);
+
+ return str;
+}
+
static DisplayModePtr
sna_output_get_modes(xf86OutputPtr output)
{
@@ -2144,6 +2167,14 @@ 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(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