Re: [PATCH v3 3/3] drm/i915: Use stashed away hpd isr bits in intel_digital_port_connected()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 11, 2020 at 05:54:22PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> 
> Get rid of several platform specific variants of
> intel_digital_port_connected() and just use the ISR bits we've
> stashed away.
> 
> v2: Duplicate stuff to avoid exposing platform specific
>     functions across files (Jani)
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

Reviewed-by: Imre Deak <imre.deak@xxxxxxxxx>

> ---
>  drivers/gpu/drm/i915/display/intel_ddi.c | 88 +++---------------------
>  drivers/gpu/drm/i915/display/intel_dp.c  | 59 ++--------------
>  drivers/gpu/drm/i915/display/intel_tc.c  |  4 +-
>  3 files changed, 17 insertions(+), 134 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> index c8ceb08f8d05..d64fcc18ae4d 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -4346,41 +4346,7 @@ intel_ddi_hotplug(struct intel_encoder *encoder,
>  static bool lpt_digital_port_connected(struct intel_encoder *encoder)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> -	u32 bit;
> -
> -	switch (encoder->hpd_pin) {
> -	case HPD_PORT_B:
> -		bit = SDE_PORTB_HOTPLUG_CPT;
> -		break;
> -	case HPD_PORT_C:
> -		bit = SDE_PORTC_HOTPLUG_CPT;
> -		break;
> -	case HPD_PORT_D:
> -		bit = SDE_PORTD_HOTPLUG_CPT;
> -		break;
> -	default:
> -		MISSING_CASE(encoder->hpd_pin);
> -		return false;
> -	}
> -
> -	return intel_de_read(dev_priv, SDEISR) & bit;
> -}
> -
> -static bool spt_digital_port_connected(struct intel_encoder *encoder)
> -{
> -	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> -	u32 bit;
> -
> -	switch (encoder->hpd_pin) {
> -	case HPD_PORT_A:
> -		bit = SDE_PORTA_HOTPLUG_SPT;
> -		break;
> -	case HPD_PORT_E:
> -		bit = SDE_PORTE_HOTPLUG_SPT;
> -		break;
> -	default:
> -		return lpt_digital_port_connected(encoder);
> -	}
> +	u32 bit = dev_priv->hotplug.pch_hpd[encoder->hpd_pin];
>  
>  	return intel_de_read(dev_priv, SDEISR) & bit;
>  }
> @@ -4388,51 +4354,19 @@ static bool spt_digital_port_connected(struct intel_encoder *encoder)
>  static bool hsw_digital_port_connected(struct intel_encoder *encoder)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> +	u32 bit = dev_priv->hotplug.hpd[encoder->hpd_pin];
>  
> -	return intel_de_read(dev_priv, DEISR) & DE_DP_A_HOTPLUG_IVB;
> +	return intel_de_read(dev_priv, DEISR) & bit;
>  }
>  
>  static bool bdw_digital_port_connected(struct intel_encoder *encoder)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> -
> -	return intel_de_read(dev_priv, GEN8_DE_PORT_ISR) & GEN8_PORT_DP_A_HOTPLUG;
> -}
> -
> -static bool bxt_digital_port_connected(struct intel_encoder *encoder)
> -{
> -	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> -	u32 bit;
> -
> -	switch (encoder->hpd_pin) {
> -	case HPD_PORT_A:
> -		bit = BXT_DE_PORT_HP_DDIA;
> -		break;
> -	case HPD_PORT_B:
> -		bit = BXT_DE_PORT_HP_DDIB;
> -		break;
> -	case HPD_PORT_C:
> -		bit = BXT_DE_PORT_HP_DDIC;
> -		break;
> -	default:
> -		MISSING_CASE(encoder->hpd_pin);
> -		return false;
> -	}
> +	u32 bit = dev_priv->hotplug.hpd[encoder->hpd_pin];
>  
>  	return intel_de_read(dev_priv, GEN8_DE_PORT_ISR) & bit;
>  }
>  
> -static bool icp_digital_port_connected(struct intel_encoder *encoder)
> -{
> -	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> -	enum phy phy = intel_port_to_phy(dev_priv, encoder->port);
> -
> -	if (HAS_PCH_MCC(dev_priv) && phy == PHY_C)
> -		return intel_de_read(dev_priv, SDEISR) & SDE_TC_HOTPLUG_ICP(PORT_TC1);
> -
> -	return intel_de_read(dev_priv, SDEISR) & SDE_DDI_HOTPLUG_ICP(phy);
> -}
> -
>  static struct intel_connector *
>  intel_ddi_init_hdmi_connector(struct intel_digital_port *intel_dig_port)
>  {
> @@ -4628,17 +4562,15 @@ void intel_ddi_init(struct drm_i915_private *dev_priv, enum port port)
>  		if (intel_phy_is_tc(dev_priv, phy))
>  			intel_dig_port->connected = intel_tc_port_connected;
>  		else
> -			intel_dig_port->connected = icp_digital_port_connected;
> -	} else if (IS_GEN9_LP(dev_priv)) {
> -		intel_dig_port->connected = bxt_digital_port_connected;
> -	} else if (port == PORT_A) {
> -		if (INTEL_GEN(dev_priv) >= 8)
> +			intel_dig_port->connected = lpt_digital_port_connected;
> +	} else if (INTEL_GEN(dev_priv) >= 8) {
> +		if (port == PORT_A || IS_GEN9_LP(dev_priv))
>  			intel_dig_port->connected = bdw_digital_port_connected;
>  		else
> +			intel_dig_port->connected = lpt_digital_port_connected;
> +	} else {
> +		if (port == PORT_A)
>  			intel_dig_port->connected = hsw_digital_port_connected;
> -	} else {
> -		if (INTEL_PCH_TYPE(dev_priv) >= PCH_SPT)
> -			intel_dig_port->connected = spt_digital_port_connected;
>  		else
>  			intel_dig_port->connected = lpt_digital_port_connected;
>  	}
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index cff14f52c391..b34933959e54 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -5404,45 +5404,7 @@ edp_detect(struct intel_dp *intel_dp)
>  static bool ibx_digital_port_connected(struct intel_encoder *encoder)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> -	u32 bit;
> -
> -	switch (encoder->hpd_pin) {
> -	case HPD_PORT_B:
> -		bit = SDE_PORTB_HOTPLUG;
> -		break;
> -	case HPD_PORT_C:
> -		bit = SDE_PORTC_HOTPLUG;
> -		break;
> -	case HPD_PORT_D:
> -		bit = SDE_PORTD_HOTPLUG;
> -		break;
> -	default:
> -		MISSING_CASE(encoder->hpd_pin);
> -		return false;
> -	}
> -
> -	return intel_de_read(dev_priv, SDEISR) & bit;
> -}
> -
> -static bool cpt_digital_port_connected(struct intel_encoder *encoder)
> -{
> -	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> -	u32 bit;
> -
> -	switch (encoder->hpd_pin) {
> -	case HPD_PORT_B:
> -		bit = SDE_PORTB_HOTPLUG_CPT;
> -		break;
> -	case HPD_PORT_C:
> -		bit = SDE_PORTC_HOTPLUG_CPT;
> -		break;
> -	case HPD_PORT_D:
> -		bit = SDE_PORTD_HOTPLUG_CPT;
> -		break;
> -	default:
> -		MISSING_CASE(encoder->hpd_pin);
> -		return false;
> -	}
> +	u32 bit = dev_priv->hotplug.pch_hpd[encoder->hpd_pin];
>  
>  	return intel_de_read(dev_priv, SDEISR) & bit;
>  }
> @@ -5496,15 +5458,9 @@ static bool gm45_digital_port_connected(struct intel_encoder *encoder)
>  static bool ilk_digital_port_connected(struct intel_encoder *encoder)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> +	u32 bit = dev_priv->hotplug.hpd[encoder->hpd_pin];
>  
> -	return intel_de_read(dev_priv, DEISR) & DE_DP_A_HOTPLUG;
> -}
> -
> -static bool ivb_digital_port_connected(struct intel_encoder *encoder)
> -{
> -	struct drm_i915_private *dev_priv = to_i915(encoder->base.dev);
> -
> -	return intel_de_read(dev_priv, DEISR) & DE_DP_A_HOTPLUG_IVB;
> +	return intel_de_read(dev_priv, DEISR) & bit;
>  }
>  
>  /*
> @@ -7735,14 +7691,9 @@ bool intel_dp_init(struct drm_i915_private *dev_priv,
>  			intel_dig_port->connected = gm45_digital_port_connected;
>  		else
>  			intel_dig_port->connected = g4x_digital_port_connected;
> -	} else if (port == PORT_A) {
> -		if (IS_IVYBRIDGE(dev_priv))
> -			intel_dig_port->connected = ivb_digital_port_connected;
> -		else
> +	} else {
> +		if (port == PORT_A)
>  			intel_dig_port->connected = ilk_digital_port_connected;
> -	} else {
> -		if (HAS_PCH_CPT(dev_priv))
> -			intel_dig_port->connected = cpt_digital_port_connected;
>  		else
>  			intel_dig_port->connected = ibx_digital_port_connected;
>  	}
> diff --git a/drivers/gpu/drm/i915/display/intel_tc.c b/drivers/gpu/drm/i915/display/intel_tc.c
> index 1e64b4c92eec..0b6c1950ec6d 100644
> --- a/drivers/gpu/drm/i915/display/intel_tc.c
> +++ b/drivers/gpu/drm/i915/display/intel_tc.c
> @@ -173,8 +173,8 @@ static void tc_port_fixup_legacy_flag(struct intel_digital_port *dig_port,
>  static u32 tc_port_live_status_mask(struct intel_digital_port *dig_port)
>  {
>  	struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev);
> -	enum tc_port tc_port = intel_port_to_tc(i915, dig_port->base.port);
>  	struct intel_uncore *uncore = &i915->uncore;
> +	u32 isr_bit = i915->hotplug.pch_hpd[dig_port->base.hpd_pin];
>  	u32 mask = 0;
>  	u32 val;
>  
> @@ -193,7 +193,7 @@ static u32 tc_port_live_status_mask(struct intel_digital_port *dig_port)
>  	if (val & TC_LIVE_STATE_TC(dig_port->tc_phy_fia_idx))
>  		mask |= BIT(TC_PORT_DP_ALT);
>  
> -	if (intel_uncore_read(uncore, SDEISR) & SDE_TC_HOTPLUG_ICP(tc_port))
> +	if (intel_uncore_read(uncore, SDEISR) & isr_bit)
>  		mask |= BIT(TC_PORT_LEGACY);
>  
>  	/* The sink can be connected only in a single mode. */
> -- 
> 2.24.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux