drm/i915: Introduce intel_hpd_pin function.
authorRodrigo Vivi <rodrigo.vivi@intel.com>
Fri, 11 Aug 2017 18:26:50 +0000 (11:26 -0700)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Fri, 11 Aug 2017 18:53:47 +0000 (11:53 -0700)
The idea is to have an unique place to decide the pin-port
per platform.

So let's create this function now without any functional
change. Just adding together code from hdmi and dp together.

v2: Add missing pin for port A.
v3: Fix typo on subject.
    Avoid behaviour change so add WARN_ON and return
    if port A on HDMI. (by DK).

Cc: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20170811182650.14327-2-rodrigo.vivi@intel.com
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/intel_dp.c
drivers/gpu/drm/i915/intel_hdmi.c
drivers/gpu/drm/i915/intel_hotplug.c

index 68ec47b378acb01ff27392eadb1aa19e1bdf30fa..ba59e64eb378593bae5122d51bb28f3e8841e273 100644 (file)
@@ -3195,6 +3195,7 @@ void intel_hpd_init(struct drm_i915_private *dev_priv);
 void intel_hpd_init_work(struct drm_i915_private *dev_priv);
 void intel_hpd_cancel_work(struct drm_i915_private *dev_priv);
 enum port intel_hpd_pin_to_port(enum hpd_pin pin);
+enum hpd_pin intel_hpd_pin(enum port port);
 bool intel_hpd_disable(struct drm_i915_private *dev_priv, enum hpd_pin pin);
 void intel_hpd_enable(struct drm_i915_private *dev_priv, enum hpd_pin pin);
 
index e94f6fcfa53a6a8e846041d4c885b9531d111bb5..5ba8366ff1e5bcb5c68754e23c013528dcf179cf 100644 (file)
@@ -5916,26 +5916,22 @@ intel_dp_init_connector_port_info(struct intel_digital_port *intel_dig_port)
        struct intel_encoder *encoder = &intel_dig_port->base;
        struct intel_dp *intel_dp = &intel_dig_port->dp;
 
+       encoder->hpd_pin = intel_hpd_pin(intel_dig_port->port);
+
        switch (intel_dig_port->port) {
        case PORT_A:
-               encoder->hpd_pin = HPD_PORT_A;
                intel_dp->aux_power_domain = POWER_DOMAIN_AUX_A;
                break;
        case PORT_B:
-               encoder->hpd_pin = HPD_PORT_B;
                intel_dp->aux_power_domain = POWER_DOMAIN_AUX_B;
                break;
        case PORT_C:
-               encoder->hpd_pin = HPD_PORT_C;
                intel_dp->aux_power_domain = POWER_DOMAIN_AUX_C;
                break;
        case PORT_D:
-               encoder->hpd_pin = HPD_PORT_D;
                intel_dp->aux_power_domain = POWER_DOMAIN_AUX_D;
                break;
        case PORT_E:
-               encoder->hpd_pin = HPD_PORT_E;
-
                /* FIXME: Check VBT for actual wiring of PORT E */
                intel_dp->aux_power_domain = POWER_DOMAIN_AUX_D;
                break;
index 2ef1ee85129d1880c58c8cc6e395cbb0ce49fed1..e30c27acb94ffa346bf4639b2c5b38b8820b02d5 100644 (file)
@@ -1920,23 +1920,9 @@ void intel_hdmi_init_connector(struct intel_digital_port *intel_dig_port,
 
        intel_hdmi->ddc_bus = intel_hdmi_ddc_pin(dev_priv, port);
 
-       switch (port) {
-       case PORT_B:
-               intel_encoder->hpd_pin = HPD_PORT_B;
-               break;
-       case PORT_C:
-               intel_encoder->hpd_pin = HPD_PORT_C;
-               break;
-       case PORT_D:
-               intel_encoder->hpd_pin = HPD_PORT_D;
-               break;
-       case PORT_E:
-               intel_encoder->hpd_pin = HPD_PORT_E;
-               break;
-       default:
-               MISSING_CASE(port);
+       if (WARN_ON(port == PORT_A))
                return;
-       }
+       intel_encoder->hpd_pin = intel_hpd_pin(port);
 
        if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
                intel_hdmi->write_infoframe = vlv_write_infoframe;
index d442d9f012d6896094bb6cdf2022a432a24d288b..875d5d218d5cf07c5aaf36a04f95ceeba6610f43 100644 (file)
@@ -101,6 +101,32 @@ enum port intel_hpd_pin_to_port(enum hpd_pin pin)
        }
 }
 
+/**
+ * intel_hpd_pin - return pin hard associated with certain port.
+ * @port: the hpd port to get associated pin
+ *
+ * Return pin that is associatade with @port and HDP_NONE if no pin is
+ * hard associated with that @port.
+ */
+enum hpd_pin intel_hpd_pin(enum port port)
+{
+       switch (port) {
+       case PORT_A:
+               return HPD_PORT_A;
+       case PORT_B:
+               return HPD_PORT_B;
+       case PORT_C:
+               return HPD_PORT_C;
+       case PORT_D:
+               return HPD_PORT_D;
+       case PORT_E:
+               return HPD_PORT_E;
+       default:
+               MISSING_CASE(port);
+               return HPD_NONE;
+       }
+}
+
 #define HPD_STORM_DETECT_PERIOD                1000
 #define HPD_STORM_REENABLE_DELAY       (2 * 60 * 1000)