From 001e272437a0247ffbc4b9ff8a3f2b437cf4c533 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 13 Dec 2006 12:08:58 -0800 Subject: [PATCH] Auto-detect working TV output by checking TV regs functionality. We can't figure out which chips are supposed to have TV out, so instead we prod the TV_DAC register to see if it will hold the value written to it, if not, we assume the chip doesn't have TV out. --- src/i830_tv.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/src/i830_tv.c b/src/i830_tv.c index b6cc2c9b..42c2aadd 100644 --- a/src/i830_tv.c +++ b/src/i830_tv.c @@ -583,8 +583,11 @@ i830_tv_detect_type (xf86CrtcPtr crtc, tv_dac |= (TVDAC_STATE_CHG_EN | TVDAC_A_SENSE_CTL | TVDAC_B_SENSE_CTL | - TVDAC_C_SENSE_CTL); - tv_dac = DAC_CTL_OVERRIDE | DAC_A_0_7_V | DAC_B_0_7_V | DAC_C_0_7_V; + TVDAC_C_SENSE_CTL | + DAC_CTL_OVERRIDE | + DAC_A_0_7_V | + DAC_B_0_7_V | + DAC_C_0_7_V); OUTREG(TV_CTL, tv_ctl); OUTREG(TV_DAC, tv_dac); i830WaitForVblank(pScrn); @@ -612,7 +615,7 @@ i830_tv_detect_type (xf86CrtcPtr crtc, type = TV_TYPE_COMPONENT; } else { xf86DrvMsg(pScrn->scrnIndex, X_INFO, - "Couldn't detect TV connection\n"); + "No TV connection detected\n"); type = TV_TYPE_NONE; } @@ -730,10 +733,34 @@ i830_tv_init(ScrnInfoPtr pScrn) xf86OutputPtr output; I830OutputPrivatePtr intel_output; struct i830_tv_priv *dev_priv; + CARD32 tv_dac_on, tv_dac_off, save_tv_dac; if ((INREG(TV_CTL) & TV_FUSE_STATE_MASK) == TV_FUSE_STATE_DISABLED) return; + /* + * Sanity check the TV output by checking to see if the + * DAC register holds a value + */ + save_tv_dac = INREG(TV_DAC); + + OUTREG(TV_DAC, save_tv_dac | TVDAC_STATE_CHG_EN); + tv_dac_on = INREG(TV_DAC); + + OUTREG(TV_DAC, save_tv_dac & ~TVDAC_STATE_CHG_EN); + tv_dac_off = INREG(TV_DAC); + + OUTREG(TV_DAC, save_tv_dac); + + /* + * If the register does not hold the state change enable + * bit, (either as a 0 or a 1), assume it doesn't really + * exist + */ + if ((tv_dac_on & TVDAC_STATE_CHG_EN) == 0 || + (tv_dac_off & TVDAC_STATE_CHG_EN) != 0) + return; + output = xf86OutputCreate (pScrn, &i830_tv_output_funcs, "TV"); if (!output)