Re: [PATCH 2/2] drm/i915: s/intel_dp_sink_dpms/intel_dp_set_power/

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

 



On Fri, Oct 16, 2020 at 10:48:00PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>
> 
> Rename intel_dp_sink_dpms() to intel_dp_set_power()
> so one doesn't always have to convert from the DPMS
> enum values to the actual DP D-states.
> 
> Also when dealing with a branch device this has nothing to
> do with any sink, so the old name was nonsense anyway.
> Also adjust the debug message accordingly, and pimp it
> with the standard encoder id+name thing.
> 
> Trivial bits done with cocci:
> @@
> expression DP;
> @@
> (
> - intel_dp_sink_dpms(DP, DRM_MODE_DPMS_OFF)
> + intel_dp_set_power(DP, DP_SET_POWER_D3)
> |
> - intel_dp_sink_dpms(DP, DRM_MODE_DPMS_ON)
> + intel_dp_set_power(DP, DP_SET_POWER_D0)
> )
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@xxxxxxxxxxxxxxx>

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

> ---
>  drivers/gpu/drm/i915/display/intel_ddi.c    |  6 +++---
>  drivers/gpu/drm/i915/display/intel_dp.c     | 24 ++++++++++-----------
>  drivers/gpu/drm/i915/display/intel_dp.h     |  2 +-
>  drivers/gpu/drm/i915/display/intel_dp_mst.c |  2 +-
>  4 files changed, 17 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_ddi.c b/drivers/gpu/drm/i915/display/intel_ddi.c
> index bb0b9930958f..09811be08cfe 100644
> --- a/drivers/gpu/drm/i915/display/intel_ddi.c
> +++ b/drivers/gpu/drm/i915/display/intel_ddi.c
> @@ -3482,7 +3482,7 @@ static void tgl_ddi_pre_enable_dp(struct intel_atomic_state *state,
>  	intel_ddi_init_dp_buf_reg(encoder, crtc_state);
>  
>  	if (!is_mst)
> -		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> +		intel_dp_set_power(intel_dp, DP_SET_POWER_D0);
>  
>  	intel_dp_sink_set_decompression_state(intel_dp, crtc_state, true);
>  	/*
> @@ -3564,7 +3564,7 @@ static void hsw_ddi_pre_enable_dp(struct intel_atomic_state *state,
>  
>  	intel_ddi_init_dp_buf_reg(encoder, crtc_state);
>  	if (!is_mst)
> -		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> +		intel_dp_set_power(intel_dp, DP_SET_POWER_D0);
>  	intel_dp_configure_protocol_converter(intel_dp);
>  	intel_dp_sink_set_decompression_state(intel_dp, crtc_state,
>  					      true);
> @@ -3738,7 +3738,7 @@ static void intel_ddi_post_disable_dp(struct intel_atomic_state *state,
>  	 * Power down sink before disabling the port, otherwise we end
>  	 * up getting interrupts from the sink on detecting link loss.
>  	 */
> -	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
> +	intel_dp_set_power(intel_dp, DP_SET_POWER_D3);
>  
>  	if (INTEL_GEN(dev_priv) >= 12) {
>  		if (is_mst) {
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 4784aaeb934e..818daab252f3 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -3471,22 +3471,22 @@ void intel_dp_sink_set_decompression_state(struct intel_dp *intel_dp,
>  			    enable ? "enable" : "disable");
>  }
>  
> -/* If the sink supports it, try to set the power state appropriately */
> -void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode)
> +/* If the device supports it, try to set the power state appropriately */
> +void intel_dp_set_power(struct intel_dp *intel_dp, u8 mode)
>  {
> -	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> +	struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
> +	struct drm_i915_private *i915 = to_i915(encoder->base.dev);
>  	int ret, i;
>  
>  	/* Should have a valid DPCD by this point */
>  	if (intel_dp->dpcd[DP_DPCD_REV] < 0x11)
>  		return;
>  
> -	if (mode != DRM_MODE_DPMS_ON) {
> +	if (mode != DP_SET_POWER_D0) {
>  		if (downstream_hpd_needs_d0(intel_dp))
>  			return;
>  
> -		ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER,
> -					 DP_SET_POWER_D3);
> +		ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, mode);
>  	} else {
>  		struct intel_lspcon *lspcon = dp_to_lspcon(intel_dp);
>  
> @@ -3497,8 +3497,7 @@ void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode)
>  		 * time to wake up.
>  		 */
>  		for (i = 0; i < 3; i++) {
> -			ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER,
> -						 DP_SET_POWER_D0);
> +			ret = drm_dp_dpcd_writeb(&intel_dp->aux, DP_SET_POWER, mode);
>  			if (ret == 1)
>  				break;
>  			msleep(1);
> @@ -3509,8 +3508,9 @@ void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode)
>  	}
>  
>  	if (ret != 1)
> -		drm_dbg_kms(&i915->drm, "failed to %s sink power state\n",
> -			    mode == DRM_MODE_DPMS_ON ? "enable" : "disable");
> +		drm_dbg_kms(&i915->drm, "[ENCODER:%d:%s] Set power to %s failed\n",
> +			    encoder->base.base.id, encoder->base.name,
> +			    mode == DP_SET_POWER_D0 ? "D0" : "D3");
>  }
>  
>  static bool cpt_dp_port_selected(struct drm_i915_private *dev_priv,
> @@ -3744,7 +3744,7 @@ static void intel_disable_dp(struct intel_atomic_state *state,
>  	 * ensure that we have vdd while we switch off the panel. */
>  	intel_edp_panel_vdd_on(intel_dp);
>  	intel_edp_backlight_off(old_conn_state);
> -	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_OFF);
> +	intel_dp_set_power(intel_dp, DP_SET_POWER_D3);
>  	intel_edp_panel_off(intel_dp);
>  }
>  
> @@ -3969,7 +3969,7 @@ static void intel_enable_dp(struct intel_atomic_state *state,
>  				    lane_mask);
>  	}
>  
> -	intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> +	intel_dp_set_power(intel_dp, DP_SET_POWER_D0);
>  	intel_dp_configure_protocol_converter(intel_dp);
>  	intel_dp_start_link_train(intel_dp, pipe_config);
>  	intel_dp_stop_link_train(intel_dp, pipe_config);
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.h b/drivers/gpu/drm/i915/display/intel_dp.h
> index fcc28eb242f2..3f862b4fd34f 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.h
> +++ b/drivers/gpu/drm/i915/display/intel_dp.h
> @@ -50,7 +50,7 @@ int intel_dp_get_link_train_fallback_values(struct intel_dp *intel_dp,
>  					    int link_rate, u8 lane_count);
>  int intel_dp_retrain_link(struct intel_encoder *encoder,
>  			  struct drm_modeset_acquire_ctx *ctx);
> -void intel_dp_sink_dpms(struct intel_dp *intel_dp, int mode);
> +void intel_dp_set_power(struct intel_dp *intel_dp, u8 mode);
>  void intel_dp_configure_protocol_converter(struct intel_dp *intel_dp);
>  void intel_dp_sink_set_decompression_state(struct intel_dp *intel_dp,
>  					   const struct intel_crtc_state *crtc_state,
> diff --git a/drivers/gpu/drm/i915/display/intel_dp_mst.c b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> index e948aacbd4ab..c8fcec4d0788 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp_mst.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp_mst.c
> @@ -492,7 +492,7 @@ static void intel_mst_pre_enable_dp(struct intel_atomic_state *state,
>  		    intel_dp->active_mst_links);
>  
>  	if (first_mst_stream)
> -		intel_dp_sink_dpms(intel_dp, DRM_MODE_DPMS_ON);
> +		intel_dp_set_power(intel_dp, DP_SET_POWER_D0);
>  
>  	drm_dp_send_power_updown_phy(&intel_dp->mst_mgr, connector->port, true);
>  
> -- 
> 2.26.2
> 
> _______________________________________________
> 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