diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-08-04 16:23:00 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-08-05 06:25:57 +0100 |
commit | ab3f1526f19ec405dca8ab3094a626096dc30358 (patch) | |
tree | 9a64aa27ba0880688bffc204ddd0bd94fb83bca8 | |
parent | ebd1907304c538bcc27614bc8e2e29f317ffb390 (diff) |
sna: Add the current CRTC mode last
We only want to add the current mode to the modelist if it is not
already present in the EDID. At the moment, we always add the current
mode first which causes the list to be reordered. If we add it after
checking the EDID, then we will not perturb the list.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82068
-rw-r--r-- | src/sna/sna_display.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 9906dfb3..80a5bb16 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -2778,7 +2778,7 @@ static DisplayModePtr sna_output_get_modes(xf86OutputPtr output) { struct sna_output *sna_output = output->driver_private; - DisplayModePtr Modes = NULL, Mode, current = NULL; + DisplayModePtr Modes = NULL, current = NULL; int i; DBG(("%s(%s:%d)\n", __FUNCTION__, output->name, sna_output->id)); @@ -2801,36 +2801,34 @@ sna_output_get_modes(xf86OutputPtr output) if (mode.mode_valid && mode.mode.clock) { current = calloc(1, sizeof(DisplayModeRec)); - if (current) { + if (current) mode_from_kmode(output->scrn, &mode.mode, current); - Modes = xf86ModesAdd(Modes, current); - } } } } DBG(("%s: adding %d probed modes\n", __FUNCTION__, sna_output->num_modes)); - Mode = NULL; for (i = 0; i < sna_output->num_modes; i++) { - if (Mode == NULL) - Mode = calloc(1, sizeof(DisplayModeRec)); - if (Mode) { - Mode = mode_from_kmode(output->scrn, - &sna_output->modes[i], - Mode); - - if (!current || !xf86ModesEqual(Mode, current)) { - Modes = xf86ModesAdd(Modes, Mode); - Mode = NULL; - } else { - free((void *)current->name); - current->name = strdup(Mode->name); - current->type = Mode->type; - } + DisplayModePtr mode; + + mode = calloc(1, sizeof(DisplayModeRec)); + if (mode == NULL) + continue; + + mode = mode_from_kmode(output->scrn, + &sna_output->modes[i], + mode); + Modes = xf86ModesAdd(Modes, mode); + if (current && xf86ModesEqual(mode, current)) { + free(current->name); + free(current); + current = NULL; } } - free(Mode); + + if (current) + Modes = xf86ModesAdd(current, Modes); /* * If the connector type is a panel, we will traverse the kernel mode to |