]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/gpu/drm/i915/intel_crt.c
drm/i915: Rearrange i915_wait_request() accounting with callers
[karo-tx-linux.git] / drivers / gpu / drm / i915 / intel_crt.c
index dfbcf16b41dfb956dddfff8f8cc90aef9d1b579c..a97151fcb9f4c67c2d55fb06a6b953de21c148e3 100644 (file)
@@ -84,7 +84,7 @@ static bool intel_crt_get_hw_state(struct intel_encoder *encoder,
        if (!(tmp & ADPA_DAC_ENABLE))
                goto out;
 
-       if (HAS_PCH_CPT(dev))
+       if (HAS_PCH_CPT(dev_priv))
                *pipe = PORT_TO_PIPE_CPT(tmp);
        else
                *pipe = PORT_TO_PIPE(tmp);
@@ -165,16 +165,16 @@ static void intel_crt_set_dpms(struct intel_encoder *encoder,
                adpa |= ADPA_VSYNC_ACTIVE_HIGH;
 
        /* For CPT allow 3 pipe config, for others just use A or B */
-       if (HAS_PCH_LPT(dev))
+       if (HAS_PCH_LPT(dev_priv))
                ; /* Those bits don't exist here */
-       else if (HAS_PCH_CPT(dev))
+       else if (HAS_PCH_CPT(dev_priv))
                adpa |= PORT_TRANS_SEL_CPT(crtc->pipe);
        else if (crtc->pipe == 0)
                adpa |= ADPA_PIPE_A_SELECT;
        else
                adpa |= ADPA_PIPE_B_SELECT;
 
-       if (!HAS_PCH_SPLIT(dev))
+       if (!HAS_PCH_SPLIT(dev_priv))
                I915_WRITE(BCLRPAT(crtc->pipe), 0);
 
        switch (mode) {
@@ -241,7 +241,8 @@ intel_crt_mode_valid(struct drm_connector *connector,
                     struct drm_display_mode *mode)
 {
        struct drm_device *dev = connector->dev;
-       int max_dotclk = to_i915(dev)->max_dotclk_freq;
+       struct drm_i915_private *dev_priv = to_i915(dev);
+       int max_dotclk = dev_priv->max_dotclk_freq;
        int max_clock;
 
        if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
@@ -250,15 +251,15 @@ intel_crt_mode_valid(struct drm_connector *connector,
        if (mode->clock < 25000)
                return MODE_CLOCK_LOW;
 
-       if (HAS_PCH_LPT(dev))
+       if (HAS_PCH_LPT(dev_priv))
                max_clock = 180000;
-       else if (IS_VALLEYVIEW(dev))
+       else if (IS_VALLEYVIEW(dev_priv))
                /*
                 * 270 MHz due to current DPLL limits,
                 * DAC limit supposedly 355 MHz.
                 */
                max_clock = 270000;
-       else if (IS_GEN3(dev) || IS_GEN4(dev))
+       else if (IS_GEN3(dev_priv) || IS_GEN4(dev_priv))
                max_clock = 400000;
        else
                max_clock = 350000;
@@ -269,7 +270,7 @@ intel_crt_mode_valid(struct drm_connector *connector,
                return MODE_CLOCK_HIGH;
 
        /* The FDI receiver on LPT only supports 8bpc and only has 2 lanes. */
-       if (HAS_PCH_LPT(dev) &&
+       if (HAS_PCH_LPT(dev_priv) &&
            (ironlake_get_lanes_required(mode->clock, 270000, 24) > 2))
                return MODE_CLOCK_HIGH;
 
@@ -280,13 +281,13 @@ static bool intel_crt_compute_config(struct intel_encoder *encoder,
                                     struct intel_crtc_state *pipe_config,
                                     struct drm_connector_state *conn_state)
 {
-       struct drm_device *dev = encoder->base.dev;
+       struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
 
-       if (HAS_PCH_SPLIT(dev))
+       if (HAS_PCH_SPLIT(dev_priv))
                pipe_config->has_pch_encoder = true;
 
        /* LPT FDI RX only supports 8bpc. */
-       if (HAS_PCH_LPT(dev)) {
+       if (HAS_PCH_LPT(dev_priv)) {
                if (pipe_config->bw_constrained && pipe_config->pipe_bpp < 24) {
                        DRM_DEBUG_KMS("LPT only supports 24bpp\n");
                        return false;
@@ -296,7 +297,7 @@ static bool intel_crt_compute_config(struct intel_encoder *encoder,
        }
 
        /* FDI must always be 2.7 GHz */
-       if (HAS_DDI(dev))
+       if (HAS_DDI(dev_priv))
                pipe_config->port_clock = 135000 * 2;
 
        return true;
@@ -312,7 +313,7 @@ static bool intel_ironlake_crt_detect_hotplug(struct drm_connector *connector)
 
        /* The first time through, trigger an explicit detection cycle */
        if (crt->force_hotplug_required) {
-               bool turn_off_dac = HAS_PCH_SPLIT(dev);
+               bool turn_off_dac = HAS_PCH_SPLIT(dev_priv);
                u32 save_adpa;
 
                crt->force_hotplug_required = 0;
@@ -419,10 +420,10 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector)
        bool ret = false;
        int i, tries = 0;
 
-       if (HAS_PCH_SPLIT(dev))
+       if (HAS_PCH_SPLIT(dev_priv))
                return intel_ironlake_crt_detect_hotplug(connector);
 
-       if (IS_VALLEYVIEW(dev))
+       if (IS_VALLEYVIEW(dev_priv))
                return valleyview_crt_detect_hotplug(connector);
 
        /*
@@ -430,7 +431,7 @@ static bool intel_crt_detect_hotplug(struct drm_connector *connector)
         * to get a reliable result.
         */
 
-       if (IS_G4X(dev) && !IS_GM45(dev))
+       if (IS_G4X(dev_priv) && !IS_GM45(dev_priv))
                tries = 2;
        else
                tries = 1;
@@ -566,7 +567,7 @@ intel_crt_load_detect(struct intel_crt *crt, uint32_t pipe)
        /* Set the border color to purple. */
        I915_WRITE(bclrpat_reg, 0x500050);
 
-       if (!IS_GEN2(dev)) {
+       if (!IS_GEN2(dev_priv)) {
                uint32_t pipeconf = I915_READ(pipeconf_reg);
                I915_WRITE(pipeconf_reg, pipeconf | PIPECONF_FORCE_BORDER);
                POSTING_READ(pipeconf_reg);
@@ -643,6 +644,32 @@ intel_crt_load_detect(struct intel_crt *crt, uint32_t pipe)
        return status;
 }
 
+static int intel_spurious_crt_detect_dmi_callback(const struct dmi_system_id *id)
+{
+       DRM_DEBUG_DRIVER("Skipping CRT detection for %s\n", id->ident);
+       return 1;
+}
+
+static const struct dmi_system_id intel_spurious_crt_detect[] = {
+       {
+               .callback = intel_spurious_crt_detect_dmi_callback,
+               .ident = "ACER ZGB",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
+               },
+       },
+       {
+               .callback = intel_spurious_crt_detect_dmi_callback,
+               .ident = "Intel DZ77BH-55K",
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_VENDOR, "Intel Corporation"),
+                       DMI_MATCH(DMI_BOARD_NAME, "DZ77BH-55K"),
+               },
+       },
+       { }
+};
+
 static enum drm_connector_status
 intel_crt_detect(struct drm_connector *connector, bool force)
 {
@@ -659,6 +686,10 @@ intel_crt_detect(struct drm_connector *connector, bool force)
                      connector->base.id, connector->name,
                      force);
 
+       /* Skip machines without VGA that falsely report hotplug events */
+       if (dmi_check_system(intel_spurious_crt_detect))
+               return connector_status_disconnected;
+
        power_domain = intel_display_port_power_domain(intel_encoder);
        intel_display_power_get(dev_priv, power_domain);
 
@@ -740,7 +771,7 @@ static int intel_crt_get_modes(struct drm_connector *connector)
 
        i2c = intel_gmbus_get_adapter(dev_priv, dev_priv->vbt.crt_ddc_pin);
        ret = intel_crt_ddc_get_modes(connector, i2c);
-       if (ret || !IS_G4X(dev))
+       if (ret || !IS_G4X(dev_priv))
                goto out;
 
        /* Try to probe digital port for output in DVI-I -> VGA mode. */
@@ -808,32 +839,6 @@ static const struct drm_encoder_funcs intel_crt_enc_funcs = {
        .destroy = intel_encoder_destroy,
 };
 
-static int intel_no_crt_dmi_callback(const struct dmi_system_id *id)
-{
-       DRM_INFO("Skipping CRT initialization for %s\n", id->ident);
-       return 1;
-}
-
-static const struct dmi_system_id intel_no_crt[] = {
-       {
-               .callback = intel_no_crt_dmi_callback,
-               .ident = "ACER ZGB",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "ACER"),
-                       DMI_MATCH(DMI_PRODUCT_NAME, "ZGB"),
-               },
-       },
-       {
-               .callback = intel_no_crt_dmi_callback,
-               .ident = "DELL XPS 8700",
-               .matches = {
-                       DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
-                       DMI_MATCH(DMI_PRODUCT_NAME, "XPS 8700"),
-               },
-       },
-       { }
-};
-
 void intel_crt_init(struct drm_device *dev)
 {
        struct drm_connector *connector;
@@ -843,13 +848,9 @@ void intel_crt_init(struct drm_device *dev)
        i915_reg_t adpa_reg;
        u32 adpa;
 
-       /* Skip machines without VGA that falsely report hotplug events */
-       if (dmi_check_system(intel_no_crt))
-               return;
-
-       if (HAS_PCH_SPLIT(dev))
+       if (HAS_PCH_SPLIT(dev_priv))
                adpa_reg = PCH_ADPA;
-       else if (IS_VALLEYVIEW(dev))
+       else if (IS_VALLEYVIEW(dev_priv))
                adpa_reg = VLV_ADPA;
        else
                adpa_reg = ADPA;
@@ -893,12 +894,12 @@ void intel_crt_init(struct drm_device *dev)
 
        crt->base.type = INTEL_OUTPUT_ANALOG;
        crt->base.cloneable = (1 << INTEL_OUTPUT_DVO) | (1 << INTEL_OUTPUT_HDMI);
-       if (IS_I830(dev))
+       if (IS_I830(dev_priv))
                crt->base.crtc_mask = (1 << 0);
        else
                crt->base.crtc_mask = (1 << 0) | (1 << 1) | (1 << 2);
 
-       if (IS_GEN2(dev))
+       if (IS_GEN2(dev_priv))
                connector->interlace_allowed = 0;
        else
                connector->interlace_allowed = 1;
@@ -907,20 +908,23 @@ void intel_crt_init(struct drm_device *dev)
        crt->adpa_reg = adpa_reg;
 
        crt->base.compute_config = intel_crt_compute_config;
-       if (HAS_PCH_SPLIT(dev)) {
+       if (HAS_PCH_SPLIT(dev_priv)) {
                crt->base.disable = pch_disable_crt;
                crt->base.post_disable = pch_post_disable_crt;
        } else {
                crt->base.disable = intel_disable_crt;
        }
        crt->base.enable = intel_enable_crt;
-       if (I915_HAS_HOTPLUG(dev))
+       if (I915_HAS_HOTPLUG(dev) &&
+           !dmi_check_system(intel_spurious_crt_detect))
                crt->base.hpd_pin = HPD_CRT;
-       if (HAS_DDI(dev)) {
+       if (HAS_DDI(dev_priv)) {
+               crt->base.port = PORT_E;
                crt->base.get_config = hsw_crt_get_config;
                crt->base.get_hw_state = intel_ddi_get_hw_state;
                crt->base.post_disable = hsw_post_disable_crt;
        } else {
+               crt->base.port = PORT_NONE;
                crt->base.get_config = intel_crt_get_config;
                crt->base.get_hw_state = intel_crt_get_hw_state;
        }
@@ -941,7 +945,7 @@ void intel_crt_init(struct drm_device *dev)
         * polarity and link reversal bits or not, instead of relying on the
         * BIOS.
         */
-       if (HAS_PCH_LPT(dev)) {
+       if (HAS_PCH_LPT(dev_priv)) {
                u32 fdi_config = FDI_RX_POLARITY_REVERSED_LPT |
                                 FDI_RX_LINK_REVERSAL_OVERRIDE;