[Intel-gfx] [PATCH] TV: update output and crtc modes when TV format change

Zhenyu Wang zhenyu.z.wang at intel.com
Wed Feb 18 09:12:24 CET 2009


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.

Any comments?

Thanks.

---
 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




More information about the Intel-gfx mailing list