]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - drivers/gpu/drm/i915/intel_crt.c
drm/i915: wait for actual vblank, not just 20ms
[net-next-2.6.git] / drivers / gpu / drm / i915 / intel_crt.c
index e16ac5a28c3cb178550f4f1763ea81fdd25d801e..eb31fdf758e822680069a1eca0987f73b90072b1 100644 (file)
@@ -185,8 +185,9 @@ static bool intel_ironlake_crt_detect_hotplug(struct drm_connector *connector)
        DRM_DEBUG_KMS("pch crt adpa 0x%x", adpa);
        I915_WRITE(PCH_ADPA, adpa);
 
-       while ((I915_READ(PCH_ADPA) & ADPA_CRT_HOTPLUG_FORCE_TRIGGER) != 0)
-               ;
+       if (wait_for((I915_READ(PCH_ADPA) & ADPA_CRT_HOTPLUG_FORCE_TRIGGER) == 0,
+                    1000, 1))
+               DRM_ERROR("timed out waiting for FORCE_TRIGGER");
 
        if (HAS_PCH_CPT(dev)) {
                I915_WRITE(PCH_ADPA, temp);
@@ -217,7 +218,8 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector)
 {
        struct drm_device *dev = connector->dev;
        struct drm_i915_private *dev_priv = dev->dev_private;
-       u32 hotplug_en;
+       u32 hotplug_en, orig, stat;
+       bool ret = false;
        int i, tries = 0;
 
        if (HAS_PCH_SPLIT(dev))
@@ -232,34 +234,30 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector)
                tries = 2;
        else
                tries = 1;
-       hotplug_en = I915_READ(PORT_HOTPLUG_EN);
-       hotplug_en &= CRT_FORCE_HOTPLUG_MASK;
+       hotplug_en = orig = I915_READ(PORT_HOTPLUG_EN);
        hotplug_en |= CRT_HOTPLUG_FORCE_DETECT;
 
-       if (IS_G4X(dev))
-               hotplug_en |= CRT_HOTPLUG_ACTIVATION_PERIOD_64;
-
-       hotplug_en |= CRT_HOTPLUG_VOLTAGE_COMPARE_50;
-
        for (i = 0; i < tries ; i++) {
-               unsigned long timeout;
                /* turn on the FORCE_DETECT */
                I915_WRITE(PORT_HOTPLUG_EN, hotplug_en);
-               timeout = jiffies + msecs_to_jiffies(1000);
                /* wait for FORCE_DETECT to go off */
-               do {
-                       if (!(I915_READ(PORT_HOTPLUG_EN) &
-                                       CRT_HOTPLUG_FORCE_DETECT))
-                               break;
-                       msleep(1);
-               } while (time_after(timeout, jiffies));
+               if (wait_for((I915_READ(PORT_HOTPLUG_EN) &
+                             CRT_HOTPLUG_FORCE_DETECT) == 0,
+                            1000, 1))
+                       DRM_ERROR("timed out waiting for FORCE_DETECT to go off");
        }
 
-       if ((I915_READ(PORT_HOTPLUG_STAT) & CRT_HOTPLUG_MONITOR_MASK) !=
-           CRT_HOTPLUG_MONITOR_NONE)
-               return true;
+       stat = I915_READ(PORT_HOTPLUG_STAT);
+       if ((stat & CRT_HOTPLUG_MONITOR_MASK) != CRT_HOTPLUG_MONITOR_NONE)
+               ret = true;
+
+       /* clear the interrupt we just generated, if any */
+       I915_WRITE(PORT_HOTPLUG_STAT, CRT_HOTPLUG_INT_STATUS);
+
+       /* and put the bits back */
+       I915_WRITE(PORT_HOTPLUG_EN, orig);
 
-       return false;
+       return ret;
 }
 
 static bool intel_crt_detect_ddc(struct drm_encoder *encoder)
@@ -330,7 +328,7 @@ intel_crt_load_detect(struct drm_crtc *crtc, struct intel_encoder *intel_encoder
                I915_WRITE(pipeconf_reg, pipeconf | PIPECONF_FORCE_BORDER);
                /* Wait for next Vblank to substitue
                 * border color for Color info */
-               intel_wait_for_vblank(dev);
+               intel_wait_for_vblank(dev, pipe);
                st00 = I915_READ8(VGA_MSR_WRITE);
                status = ((st00 & (1 << 4)) != 0) ?
                        connector_status_connected :
@@ -507,17 +505,8 @@ static const struct drm_connector_helper_funcs intel_crt_connector_helper_funcs
        .best_encoder = intel_attached_encoder,
 };
 
-static void intel_crt_enc_destroy(struct drm_encoder *encoder)
-{
-       struct intel_encoder *intel_encoder = enc_to_intel_encoder(encoder);
-
-       intel_i2c_destroy(intel_encoder->ddc_bus);
-       drm_encoder_cleanup(encoder);
-       kfree(intel_encoder);
-}
-
 static const struct drm_encoder_funcs intel_crt_enc_funcs = {
-       .destroy = intel_crt_enc_destroy,
+       .destroy = intel_encoder_destroy,
 };
 
 void intel_crt_init(struct drm_device *dev)
@@ -569,7 +558,7 @@ void intel_crt_init(struct drm_device *dev)
                                   (1 << INTEL_ANALOG_CLONE_BIT) |
                                   (1 << INTEL_SDVO_LVDS_CLONE_BIT);
        intel_encoder->crtc_mask = (1 << 0) | (1 << 1);
-       connector->interlace_allowed = 0;
+       connector->interlace_allowed = 1;
        connector->doublescan_allowed = 0;
 
        drm_encoder_helper_add(&intel_encoder->enc, &intel_crt_helper_funcs);