From 2f8bc8c1d4778f271ab342f22dc859c9dcf8c487 Mon Sep 17 00:00:00 2001 From: Zhenyu Wang Date: Thu, 19 Feb 2009 01:01:42 +0800 Subject: [PATCH] TV: update output and crtc modes when TV format change This is to fix bug #16566, change TV format will cause BadMatch error when crtc config apply. Everytime when we change TV format, we may generate a new list of modelines as TV clock changed. After randr get info request, new modelines will be probed and randr output's modes will be renewed too. But crtc's mode failed to be updated, as it never can find a matching mode now within new modes list. So get info will return an invalid crtc's mode, later set crtc config will pass that info, and xserver catches a bad match. This patch trys to refresh output modes and setup crtc's mode with new modelines in TV format change. So get info would be sure to turn valid crtc mode that reference in current new modelines. --- src/i830_tv.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 46 insertions(+), 1 deletions(-) diff --git a/src/i830_tv.c b/src/i830_tv.c index fdd8a18..e03ef71 100644 --- a/src/i830_tv.c +++ b/src/i830_tv.c @@ -1606,8 +1606,12 @@ i830_tv_set_property(xf86OutputPtr output, Atom property, I830OutputPrivatePtr intel_output = output->driver_private; struct i830_tv_priv *dev_priv = intel_output->dev_priv; Atom atom; - char *name; + const char *name; char *val; + RRCrtcPtr randr_crtc = output->crtc->randr_crtc; + xRRModeInfo modeinfo; + RRModePtr mode; + DisplayModePtr crtc_mode; if (value->type != XA_ATOM || value->format != 32 || value->size != 1) return FALSE; @@ -1626,6 +1630,47 @@ i830_tv_set_property(xf86OutputPtr output, Atom property, } xfree (dev_priv->tv_format); dev_priv->tv_format = val; + + /* TV format change will generate new modelines, try + to probe them and update outputs. */ + xf86ProbeOutputModes(output->scrn, 0, 0); + /* Mirror output modes to scrn mode list */ + xf86SetScrnInfoModes (output->scrn); + + for (crtc_mode = output->probed_modes; crtc_mode; + crtc_mode = crtc_mode->next) + { + if (output->crtc->mode.HDisplay == crtc_mode->HDisplay && + output->crtc->mode.VDisplay == crtc_mode->VDisplay) + break; + } + if (!crtc_mode) + return FALSE; + + xf86CrtcSetMode(output->crtc, crtc_mode, output->crtc->rotation, + output->crtc->x, output->crtc->y); + + xf86RandR12TellChanged(output->scrn->pScreen); + + modeinfo.width = crtc_mode->HDisplay; + modeinfo.height = crtc_mode->VDisplay; + modeinfo.dotClock = crtc_mode->Clock * 1000; + modeinfo.hSyncStart = crtc_mode->HSyncStart; + modeinfo.hSyncEnd = crtc_mode->HSyncEnd; + modeinfo.hTotal = crtc_mode->HTotal; + modeinfo.hSkew = crtc_mode->HSkew; + modeinfo.vSyncStart = crtc_mode->VSyncStart; + modeinfo.vSyncEnd = crtc_mode->VSyncEnd; + modeinfo.vTotal = crtc_mode->VTotal; + modeinfo.nameLength = strlen(crtc_mode->name); + modeinfo.modeFlags = crtc_mode->Flags; + + mode = RRModeGet(&modeinfo, crtc_mode->name); + if (mode != randr_crtc->mode) { + if (randr_crtc->mode) + RRModeDestroy(randr_crtc->mode); + randr_crtc->mode = mode; + } return TRUE; } for (i = 0; i < 4; i++) -- 1.5.6.5