From c81a8ba790923045496fc722e0b2a5a982d5c5f7 Mon Sep 17 00:00:00 2001 From: Zhao Yakui Date: Fri, 26 Mar 2010 17:24:17 +0800 Subject: [PATCH] drm/i915: Use TV detection mechanism in bios to avoid TV misdetection Signed-off-by: Zhao Yakui --- drivers/gpu/drm/i915/intel_tv.c | 39 +++++++++++++++++++++++++++------------ 1 files changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_tv.c b/drivers/gpu/drm/i915/intel_tv.c index 552ec11..2044bdc 100644 --- a/drivers/gpu/drm/i915/intel_tv.c +++ b/drivers/gpu/drm/i915/intel_tv.c @@ -1384,24 +1384,39 @@ intel_tv_detect_type (struct drm_crtc *crtc, struct intel_output *intel_output) save_tv_dac = tv_dac; tv_ctl = I915_READ(TV_CTL); save_tv_ctl = tv_ctl; + + /* Disable TV encoder */ tv_ctl &= ~TV_ENC_ENABLE; + I915_WRITE(TV_CTL, tv_ctl); + intel_wait_for_vblank(dev); + /* + * Set TV DACs voltage level to 0.7V first. This gives time for DAC + * to be ready + */ + tv_dac &= ~(DAC_A_MASK | DAC_B_MASK | + DAC_C_MASK | DAC_CTL_OVERRIDE); + tv_dac |= (DAC_A_0_7_V | DAC_B_0_7_V | + DAC_C_0_7_V | DAC_CTL_OVERRIDE); + I915_WRITE(TV_DAC, tv_dac); + + /* Turn on TV monitor detection mode */ tv_ctl &= ~TV_TEST_MODE_MASK; tv_ctl |= TV_TEST_MODE_MONITOR_DETECT; - tv_dac &= ~TVDAC_SENSE_MASK; - tv_dac &= ~DAC_A_MASK; - tv_dac &= ~DAC_B_MASK; - tv_dac &= ~DAC_C_MASK; - tv_dac |= (TVDAC_STATE_CHG_EN | - TVDAC_A_SENSE_CTL | - TVDAC_B_SENSE_CTL | - TVDAC_C_SENSE_CTL | - DAC_CTL_OVERRIDE | - DAC_A_0_7_V | - DAC_B_0_7_V | - DAC_C_0_7_V); I915_WRITE(TV_CTL, tv_ctl); + + /* Turn on TV sense logic */ + tv_dac &= ~(TVDAC_STATE_CHG_EN | TVDAC_A_SENSE_CTL | + TVDAC_B_SENSE_CTL | TVDAC_C_SENSE_CTL); + /* + * copy from bios. The corresponding bit of TV Sense logic is set + * to zero on cantiga platform + */ + if (!IS_GM45(dev)) + tv_dac |= (TVDAC_STATE_CHG_EN | TVDAC_A_SENSE_CTL | + TVDAC_B_SENSE_CTL | TVDAC_C_SENSE_CTL); I915_WRITE(TV_DAC, tv_dac); intel_wait_for_vblank(dev); + /* The sense bits are updated after vblank */ tv_dac = I915_READ(TV_DAC); I915_WRITE(TV_DAC, save_tv_dac); I915_WRITE(TV_CTL, save_tv_ctl); -- 1.5.4.5