提交 7533eb4f 编写于 作者: R Rodrigo Vivi

drm/i915: For HPD connected port use hpd_pin instead of port.

Let's try to simplify this mapping to hpd_pin -> bit
instead using port.
So for CNL with port F where we have this port using
hdp_pin and bits of other ports we don't need to duplicated
the mapping.

But for now this is only a re-org with no functional change
expected.

v2: Add missing lines and nuke @port reference from code
    documentation. (Ville)

Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Suggested-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: NRodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: NVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180129232223.766-7-rodrigo.vivi@intel.com
上级 3a2a59cc
...@@ -4461,173 +4461,174 @@ edp_detect(struct intel_dp *intel_dp) ...@@ -4461,173 +4461,174 @@ edp_detect(struct intel_dp *intel_dp)
return status; return status;
} }
static bool ibx_digital_port_connected(struct drm_i915_private *dev_priv, static bool ibx_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
u32 bit; u32 bit;
switch (port->base.port) { switch (encoder->hpd_pin) {
case PORT_B: case HPD_PORT_B:
bit = SDE_PORTB_HOTPLUG; bit = SDE_PORTB_HOTPLUG;
break; break;
case PORT_C: case HPD_PORT_C:
bit = SDE_PORTC_HOTPLUG; bit = SDE_PORTC_HOTPLUG;
break; break;
case PORT_D: case HPD_PORT_D:
bit = SDE_PORTD_HOTPLUG; bit = SDE_PORTD_HOTPLUG;
break; break;
default: default:
MISSING_CASE(port->base.port); MISSING_CASE(encoder->hpd_pin);
return false; return false;
} }
return I915_READ(SDEISR) & bit; return I915_READ(SDEISR) & bit;
} }
static bool cpt_digital_port_connected(struct drm_i915_private *dev_priv, static bool cpt_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
u32 bit; u32 bit;
switch (port->base.port) { switch (encoder->hpd_pin) {
case PORT_B: case HPD_PORT_B:
bit = SDE_PORTB_HOTPLUG_CPT; bit = SDE_PORTB_HOTPLUG_CPT;
break; break;
case PORT_C: case HPD_PORT_C:
bit = SDE_PORTC_HOTPLUG_CPT; bit = SDE_PORTC_HOTPLUG_CPT;
break; break;
case PORT_D: case HPD_PORT_D:
bit = SDE_PORTD_HOTPLUG_CPT; bit = SDE_PORTD_HOTPLUG_CPT;
break; break;
default: default:
MISSING_CASE(port->base.port); MISSING_CASE(encoder->hpd_pin);
return false; return false;
} }
return I915_READ(SDEISR) & bit; return I915_READ(SDEISR) & bit;
} }
static bool spt_digital_port_connected(struct drm_i915_private *dev_priv, static bool spt_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
u32 bit; u32 bit;
switch (port->base.port) { switch (encoder->hpd_pin) {
case PORT_A: case HPD_PORT_A:
bit = SDE_PORTA_HOTPLUG_SPT; bit = SDE_PORTA_HOTPLUG_SPT;
break; break;
case PORT_E: case HPD_PORT_E:
bit = SDE_PORTE_HOTPLUG_SPT; bit = SDE_PORTE_HOTPLUG_SPT;
break; break;
default: default:
return cpt_digital_port_connected(dev_priv, port); return cpt_digital_port_connected(encoder);
} }
return I915_READ(SDEISR) & bit; return I915_READ(SDEISR) & bit;
} }
static bool g4x_digital_port_connected(struct drm_i915_private *dev_priv, static bool g4x_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
u32 bit; u32 bit;
switch (port->base.port) { switch (encoder->hpd_pin) {
case PORT_B: case HPD_PORT_B:
bit = PORTB_HOTPLUG_LIVE_STATUS_G4X; bit = PORTB_HOTPLUG_LIVE_STATUS_G4X;
break; break;
case PORT_C: case HPD_PORT_C:
bit = PORTC_HOTPLUG_LIVE_STATUS_G4X; bit = PORTC_HOTPLUG_LIVE_STATUS_G4X;
break; break;
case PORT_D: case HPD_PORT_D:
bit = PORTD_HOTPLUG_LIVE_STATUS_G4X; bit = PORTD_HOTPLUG_LIVE_STATUS_G4X;
break; break;
default: default:
MISSING_CASE(port->base.port); MISSING_CASE(encoder->hpd_pin);
return false; return false;
} }
return I915_READ(PORT_HOTPLUG_STAT) & bit; return I915_READ(PORT_HOTPLUG_STAT) & bit;
} }
static bool gm45_digital_port_connected(struct drm_i915_private *dev_priv, static bool gm45_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
u32 bit; u32 bit;
switch (port->base.port) { switch (encoder->hpd_pin) {
case PORT_B: case HPD_PORT_B:
bit = PORTB_HOTPLUG_LIVE_STATUS_GM45; bit = PORTB_HOTPLUG_LIVE_STATUS_GM45;
break; break;
case PORT_C: case HPD_PORT_C:
bit = PORTC_HOTPLUG_LIVE_STATUS_GM45; bit = PORTC_HOTPLUG_LIVE_STATUS_GM45;
break; break;
case PORT_D: case HPD_PORT_D:
bit = PORTD_HOTPLUG_LIVE_STATUS_GM45; bit = PORTD_HOTPLUG_LIVE_STATUS_GM45;
break; break;
default: default:
MISSING_CASE(port->base.port); MISSING_CASE(encoder->hpd_pin);
return false; return false;
} }
return I915_READ(PORT_HOTPLUG_STAT) & bit; return I915_READ(PORT_HOTPLUG_STAT) & bit;
} }
static bool ilk_digital_port_connected(struct drm_i915_private *dev_priv, static bool ilk_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
if (port->base.port == PORT_A) struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
if (encoder->hpd_pin == HPD_PORT_A)
return I915_READ(DEISR) & DE_DP_A_HOTPLUG; return I915_READ(DEISR) & DE_DP_A_HOTPLUG;
else else
return ibx_digital_port_connected(dev_priv, port); return ibx_digital_port_connected(encoder);
} }
static bool snb_digital_port_connected(struct drm_i915_private *dev_priv, static bool snb_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
if (port->base.port == PORT_A) struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
if (encoder->hpd_pin == HPD_PORT_A)
return I915_READ(DEISR) & DE_DP_A_HOTPLUG; return I915_READ(DEISR) & DE_DP_A_HOTPLUG;
else else
return cpt_digital_port_connected(dev_priv, port); return cpt_digital_port_connected(encoder);
} }
static bool ivb_digital_port_connected(struct drm_i915_private *dev_priv, static bool ivb_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
if (port->base.port == PORT_A) struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
if (encoder->hpd_pin == HPD_PORT_A)
return I915_READ(DEISR) & DE_DP_A_HOTPLUG_IVB; return I915_READ(DEISR) & DE_DP_A_HOTPLUG_IVB;
else else
return cpt_digital_port_connected(dev_priv, port); return cpt_digital_port_connected(encoder);
} }
static bool bdw_digital_port_connected(struct drm_i915_private *dev_priv, static bool bdw_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
if (port->base.port == PORT_A) struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
if (encoder->hpd_pin == HPD_PORT_A)
return I915_READ(GEN8_DE_PORT_ISR) & GEN8_PORT_DP_A_HOTPLUG; return I915_READ(GEN8_DE_PORT_ISR) & GEN8_PORT_DP_A_HOTPLUG;
else else
return cpt_digital_port_connected(dev_priv, port); return cpt_digital_port_connected(encoder);
} }
static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv, static bool bxt_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *intel_dig_port)
{ {
struct intel_encoder *intel_encoder = &intel_dig_port->base; struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
enum port port;
u32 bit; u32 bit;
port = intel_hpd_pin_to_port(intel_encoder->hpd_pin); switch (encoder->hpd_pin) {
switch (port) { case HPD_PORT_A:
case PORT_A:
bit = BXT_DE_PORT_HP_DDIA; bit = BXT_DE_PORT_HP_DDIA;
break; break;
case PORT_B: case HPD_PORT_B:
bit = BXT_DE_PORT_HP_DDIB; bit = BXT_DE_PORT_HP_DDIB;
break; break;
case PORT_C: case HPD_PORT_C:
bit = BXT_DE_PORT_HP_DDIC; bit = BXT_DE_PORT_HP_DDIC;
break; break;
default: default:
MISSING_CASE(port); MISSING_CASE(encoder->hpd_pin);
return false; return false;
} }
...@@ -4636,33 +4637,33 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv, ...@@ -4636,33 +4637,33 @@ static bool bxt_digital_port_connected(struct drm_i915_private *dev_priv,
/* /*
* intel_digital_port_connected - is the specified port connected? * intel_digital_port_connected - is the specified port connected?
* @dev_priv: i915 private structure * @encoder: intel_encoder
* @port: the port to test
* *
* Return %true if @port is connected, %false otherwise. * Return %true if port is connected, %false otherwise.
*/ */
bool intel_digital_port_connected(struct drm_i915_private *dev_priv, bool intel_digital_port_connected(struct intel_encoder *encoder)
struct intel_digital_port *port)
{ {
struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
if (HAS_GMCH_DISPLAY(dev_priv)) { if (HAS_GMCH_DISPLAY(dev_priv)) {
if (IS_GM45(dev_priv)) if (IS_GM45(dev_priv))
return gm45_digital_port_connected(dev_priv, port); return gm45_digital_port_connected(encoder);
else else
return g4x_digital_port_connected(dev_priv, port); return g4x_digital_port_connected(encoder);
} }
if (IS_GEN5(dev_priv)) if (IS_GEN5(dev_priv))
return ilk_digital_port_connected(dev_priv, port); return ilk_digital_port_connected(encoder);
else if (IS_GEN6(dev_priv)) else if (IS_GEN6(dev_priv))
return snb_digital_port_connected(dev_priv, port); return snb_digital_port_connected(encoder);
else if (IS_GEN7(dev_priv)) else if (IS_GEN7(dev_priv))
return ivb_digital_port_connected(dev_priv, port); return ivb_digital_port_connected(encoder);
else if (IS_GEN8(dev_priv)) else if (IS_GEN8(dev_priv))
return bdw_digital_port_connected(dev_priv, port); return bdw_digital_port_connected(encoder);
else if (IS_GEN9_LP(dev_priv)) else if (IS_GEN9_LP(dev_priv))
return bxt_digital_port_connected(dev_priv, port); return bxt_digital_port_connected(encoder);
else else
return spt_digital_port_connected(dev_priv, port); return spt_digital_port_connected(encoder);
} }
static struct edid * static struct edid *
...@@ -4721,8 +4722,7 @@ intel_dp_long_pulse(struct intel_connector *connector) ...@@ -4721,8 +4722,7 @@ intel_dp_long_pulse(struct intel_connector *connector)
/* Can't disconnect eDP, but you can close the lid... */ /* Can't disconnect eDP, but you can close the lid... */
if (intel_dp_is_edp(intel_dp)) if (intel_dp_is_edp(intel_dp))
status = edp_detect(intel_dp); status = edp_detect(intel_dp);
else if (intel_digital_port_connected(dev_priv, else if (intel_digital_port_connected(&dp_to_dig_port(intel_dp)->base))
dp_to_dig_port(intel_dp)))
status = intel_dp_detect_dpcd(intel_dp); status = intel_dp_detect_dpcd(intel_dp);
else else
status = connector_status_disconnected; status = connector_status_disconnected;
......
...@@ -1591,8 +1591,7 @@ static inline unsigned int intel_dp_unused_lane_mask(int lane_count) ...@@ -1591,8 +1591,7 @@ static inline unsigned int intel_dp_unused_lane_mask(int lane_count)
bool intel_dp_read_dpcd(struct intel_dp *intel_dp); bool intel_dp_read_dpcd(struct intel_dp *intel_dp);
int intel_dp_link_required(int pixel_clock, int bpp); int intel_dp_link_required(int pixel_clock, int bpp);
int intel_dp_max_data_rate(int max_link_clock, int max_lanes); int intel_dp_max_data_rate(int max_link_clock, int max_lanes);
bool intel_digital_port_connected(struct drm_i915_private *dev_priv, bool intel_digital_port_connected(struct intel_encoder *encoder);
struct intel_digital_port *port);
/* intel_dp_aux_backlight.c */ /* intel_dp_aux_backlight.c */
int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector); int intel_dp_aux_init_backlight_funcs(struct intel_connector *intel_connector);
......
...@@ -167,11 +167,10 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon) ...@@ -167,11 +167,10 @@ static void lspcon_resume_in_pcon_wa(struct intel_lspcon *lspcon)
{ {
struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon); struct intel_dp *intel_dp = lspcon_to_intel_dp(lspcon);
struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp); struct intel_digital_port *dig_port = dp_to_dig_port(intel_dp);
struct drm_i915_private *dev_priv = to_i915(dig_port->base.base.dev);
unsigned long start = jiffies; unsigned long start = jiffies;
while (1) { while (1) {
if (intel_digital_port_connected(dev_priv, dig_port)) { if (intel_digital_port_connected(&dig_port->base)) {
DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n", DRM_DEBUG_KMS("LSPCON recovering in PCON mode after %u ms\n",
jiffies_to_msecs(jiffies - start)); jiffies_to_msecs(jiffies - start));
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册