diff mbox series

[06/15] drm/i915: Extract intel_edp_backlight_setup()

Message ID 20220912111814.17466-7-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: Some house cleaning | expand

Commit Message

Ville Syrjälä Sept. 12, 2022, 11:18 a.m. UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Pull the eDP backlight setup ino its own function. No
reason to pollute intel_edp_init_connector() with all
the mundane details.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/display/intel_dp.c | 51 +++++++++++++++----------
 1 file changed, 30 insertions(+), 21 deletions(-)

Comments

Jani Nikula Sept. 12, 2022, 11:57 a.m. UTC | #1
On Mon, 12 Sep 2022, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Pull the eDP backlight setup ino its own function. No

*into

> reason to pollute intel_edp_init_connector() with all
> the mundane details.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dp.c | 51 +++++++++++++++----------
>  1 file changed, 30 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index a5eca5396fed..de5a4d2df78e 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -5217,6 +5217,35 @@ intel_edp_add_properties(struct intel_dp *intel_dp)
>  						       fixed_mode->vdisplay);
>  }
>  
> +static void intel_edp_backlight_setup(struct intel_dp *intel_dp,
> +				      struct intel_connector *connector)
> +{
> +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> +	enum pipe pipe = INVALID_PIPE;
> +
> +	if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {
> +		/*
> +		 * Figure out the current pipe for the initial backlight setup.
> +		 * If the current pipe isn't valid, try the PPS pipe, and if that
> +		 * fails just assume pipe A.
> +		 */
> +		pipe = vlv_active_pipe(intel_dp);
> +
> +		if (pipe != PIPE_A && pipe != PIPE_B)
> +			pipe = intel_dp->pps.pps_pipe;
> +
> +		if (pipe != PIPE_A && pipe != PIPE_B)
> +			pipe = PIPE_A;
> +
> +		drm_dbg_kms(&i915->drm,
> +			    "[CONNECTOR:%d:%s] using pipe %c for initial backlight setup\n",
> +			    connector->base.base.id, connector->base.name,
> +			    pipe_name(pipe));
> +	}
> +
> +	intel_backlight_setup(connector, pipe);
> +}
> +
>  static bool intel_edp_init_connector(struct intel_dp *intel_dp,
>  				     struct intel_connector *intel_connector)
>  {
> @@ -5226,7 +5255,6 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
>  	struct drm_display_mode *fixed_mode;
>  	struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
>  	bool has_dpcd;
> -	enum pipe pipe = INVALID_PIPE;
>  	struct edid *edid;
>  
>  	if (!intel_dp_is_edp(intel_dp))
> @@ -5301,28 +5329,9 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
>  
>  	mutex_unlock(&dev->mode_config.mutex);
>  
> -	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
> -		/*
> -		 * Figure out the current pipe for the initial backlight setup.
> -		 * If the current pipe isn't valid, try the PPS pipe, and if that
> -		 * fails just assume pipe A.
> -		 */
> -		pipe = vlv_active_pipe(intel_dp);
> -
> -		if (pipe != PIPE_A && pipe != PIPE_B)
> -			pipe = intel_dp->pps.pps_pipe;
> -
> -		if (pipe != PIPE_A && pipe != PIPE_B)
> -			pipe = PIPE_A;
> -
> -		drm_dbg_kms(&dev_priv->drm,
> -			    "using pipe %c for initial backlight setup\n",
> -			    pipe_name(pipe));
> -	}
> -
>  	intel_panel_init(intel_connector);
>  
> -	intel_backlight_setup(intel_connector, pipe);
> +	intel_edp_backlight_setup(intel_dp, intel_connector);
>  
>  	intel_edp_add_properties(intel_dp);
Luca Coelho Sept. 26, 2022, 10:58 a.m. UTC | #2
On Mon, 2022-09-12 at 14:18 +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Pull the eDP backlight setup ino its own function. No
> reason to pollute intel_edp_init_connector() with all
> the mundane details.
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dp.c | 51 +++++++++++++++----------
>  1 file changed, 30 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index a5eca5396fed..de5a4d2df78e 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -5217,6 +5217,35 @@ intel_edp_add_properties(struct intel_dp *intel_dp)
>  						       fixed_mode->vdisplay);
>  }
>  
> +static void intel_edp_backlight_setup(struct intel_dp *intel_dp,
> +				      struct intel_connector *connector)
> +{
> +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> +	enum pipe pipe = INVALID_PIPE;
> +
> +	if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {

Isn't this too restrictive? Isn't there another way to check whether
the hardware supports backlight?


> +		/*
> +		 * Figure out the current pipe for the initial backlight setup.
> +		 * If the current pipe isn't valid, try the PPS pipe, and if that
> +		 * fails just assume pipe A.
> +		 */
> +		pipe = vlv_active_pipe(intel_dp);
> +
> +		if (pipe != PIPE_A && pipe != PIPE_B)
> +			pipe = intel_dp->pps.pps_pipe;
> +
> +		if (pipe != PIPE_A && pipe != PIPE_B)
> +			pipe = PIPE_A;
> +
> +		drm_dbg_kms(&i915->drm,
> +			    "[CONNECTOR:%d:%s] using pipe %c for initial backlight setup\n",
> +			    connector->base.base.id, connector->base.name,
> +			    pipe_name(pipe));
> +	}
> +
> +	intel_backlight_setup(connector, pipe);

In most cases we will call intel_backlight_setup() with INVALID_PIPE. 
Wouldn't it be better to skip this call completely in that case?

--
Cheers,
Luca.
Ville Syrjälä Sept. 26, 2022, 11:16 a.m. UTC | #3
On Mon, Sep 26, 2022 at 01:58:42PM +0300, Luca Coelho wrote:
> On Mon, 2022-09-12 at 14:18 +0300, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > Pull the eDP backlight setup ino its own function. No
> > reason to pollute intel_edp_init_connector() with all
> > the mundane details.
> > 
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_dp.c | 51 +++++++++++++++----------
> >  1 file changed, 30 insertions(+), 21 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> > index a5eca5396fed..de5a4d2df78e 100644
> > --- a/drivers/gpu/drm/i915/display/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> > @@ -5217,6 +5217,35 @@ intel_edp_add_properties(struct intel_dp *intel_dp)
> >  						       fixed_mode->vdisplay);
> >  }
> >  
> > +static void intel_edp_backlight_setup(struct intel_dp *intel_dp,
> > +				      struct intel_connector *connector)
> > +{
> > +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> > +	enum pipe pipe = INVALID_PIPE;
> > +
> > +	if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {
> 
> Isn't this too restrictive? Isn't there another way to check whether
> the hardware supports backlight?

That's not what we're checking.

Only VLV/CHV have per-pipe backlight registers, whereas
other platforms have less insane design. So we only need
to figure out the pipe on VLV/CHV.

> 
> 
> > +		/*
> > +		 * Figure out the current pipe for the initial backlight setup.
> > +		 * If the current pipe isn't valid, try the PPS pipe, and if that
> > +		 * fails just assume pipe A.
> > +		 */
> > +		pipe = vlv_active_pipe(intel_dp);
> > +
> > +		if (pipe != PIPE_A && pipe != PIPE_B)
> > +			pipe = intel_dp->pps.pps_pipe;
> > +
> > +		if (pipe != PIPE_A && pipe != PIPE_B)
> > +			pipe = PIPE_A;
> > +
> > +		drm_dbg_kms(&i915->drm,
> > +			    "[CONNECTOR:%d:%s] using pipe %c for initial backlight setup\n",
> > +			    connector->base.base.id, connector->base.name,
> > +			    pipe_name(pipe));
> > +	}
> > +
> > +	intel_backlight_setup(connector, pipe);
> 
> In most cases we will call intel_backlight_setup() with INVALID_PIPE. 
> Wouldn't it be better to skip this call completely in that case?

INVALD_PIPE doesn't mean "no backlight", it just means we don't
care about the pipe.
Luca Coelho Sept. 26, 2022, 11:33 a.m. UTC | #4
On Mon, 2022-09-26 at 14:16 +0300, Ville Syrjälä wrote:
> On Mon, Sep 26, 2022 at 01:58:42PM +0300, Luca Coelho wrote:
> > On Mon, 2022-09-12 at 14:18 +0300, Ville Syrjala wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > 
> > > Pull the eDP backlight setup ino its own function. No
> > > reason to pollute intel_edp_init_connector() with all
> > > the mundane details.
> > > 
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/i915/display/intel_dp.c | 51 +++++++++++++++----------
> > >  1 file changed, 30 insertions(+), 21 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> > > index a5eca5396fed..de5a4d2df78e 100644
> > > --- a/drivers/gpu/drm/i915/display/intel_dp.c
> > > +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> > > @@ -5217,6 +5217,35 @@ intel_edp_add_properties(struct intel_dp *intel_dp)
> > >  						       fixed_mode->vdisplay);
> > >  }
> > >  
> > > +static void intel_edp_backlight_setup(struct intel_dp *intel_dp,
> > > +				      struct intel_connector *connector)
> > > +{
> > > +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> > > +	enum pipe pipe = INVALID_PIPE;
> > > +
> > > +	if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {
> > 
> > Isn't this too restrictive? Isn't there another way to check whether
> > the hardware supports backlight?
> 
> That's not what we're checking.
> 
> Only VLV/CHV have per-pipe backlight registers, whereas
> other platforms have less insane design. So we only need
> to figure out the pipe on VLV/CHV.
> 
> > 
> > 
> > > +		/*
> > > +		 * Figure out the current pipe for the initial backlight setup.
> > > +		 * If the current pipe isn't valid, try the PPS pipe, and if that
> > > +		 * fails just assume pipe A.
> > > +		 */
> > > +		pipe = vlv_active_pipe(intel_dp);
> > > +
> > > +		if (pipe != PIPE_A && pipe != PIPE_B)
> > > +			pipe = intel_dp->pps.pps_pipe;
> > > +
> > > +		if (pipe != PIPE_A && pipe != PIPE_B)
> > > +			pipe = PIPE_A;
> > > +
> > > +		drm_dbg_kms(&i915->drm,
> > > +			    "[CONNECTOR:%d:%s] using pipe %c for initial backlight setup\n",
> > > +			    connector->base.base.id, connector->base.name,
> > > +			    pipe_name(pipe));
> > > +	}
> > > +
> > > +	intel_backlight_setup(connector, pipe);
> > 
> > In most cases we will call intel_backlight_setup() with INVALID_PIPE. 
> > Wouldn't it be better to skip this call completely in that case?
> 
> INVALD_PIPE doesn't mean "no backlight", it just means we don't
> care about the pipe.
> 

Thanks for clarifying!

Reviewed-by: Luca Coelho <luciano.coelho@intel.com>

--
Cheers,
Luca.
Luca Coelho Sept. 26, 2022, 11:38 a.m. UTC | #5
On Mon, 2022-09-26 at 14:33 +0300, Luca Coelho wrote:
> On Mon, 2022-09-26 at 14:16 +0300, Ville Syrjälä wrote:
> > On Mon, Sep 26, 2022 at 01:58:42PM +0300, Luca Coelho wrote:
> > > On Mon, 2022-09-12 at 14:18 +0300, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > 
> > > > Pull the eDP backlight setup ino its own function. No
> > > > reason to pollute intel_edp_init_connector() with all
> > > > the mundane details.
> > > > 
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > > ---
> > > >  drivers/gpu/drm/i915/display/intel_dp.c | 51 +++++++++++++++----------
> > > >  1 file changed, 30 insertions(+), 21 deletions(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> > > > index a5eca5396fed..de5a4d2df78e 100644
> > > > --- a/drivers/gpu/drm/i915/display/intel_dp.c
> > > > +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> > > > @@ -5217,6 +5217,35 @@ intel_edp_add_properties(struct intel_dp *intel_dp)
> > > >  						       fixed_mode->vdisplay);
> > > >  }
> > > >  
> > > > +static void intel_edp_backlight_setup(struct intel_dp *intel_dp,
> > > > +				      struct intel_connector *connector)
> > > > +{
> > > > +	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
> > > > +	enum pipe pipe = INVALID_PIPE;
> > > > +
> > > > +	if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {
> > > 
> > > Isn't this too restrictive? Isn't there another way to check whether
> > > the hardware supports backlight?
> > 
> > That's not what we're checking.
> > 
> > Only VLV/CHV have per-pipe backlight registers, whereas
> > other platforms have less insane design. So we only need
> > to figure out the pipe on VLV/CHV.

BTW, this is exactly the kind of code that I think deserves some
comments. 
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index a5eca5396fed..de5a4d2df78e 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -5217,6 +5217,35 @@  intel_edp_add_properties(struct intel_dp *intel_dp)
 						       fixed_mode->vdisplay);
 }
 
+static void intel_edp_backlight_setup(struct intel_dp *intel_dp,
+				      struct intel_connector *connector)
+{
+	struct drm_i915_private *i915 = dp_to_i915(intel_dp);
+	enum pipe pipe = INVALID_PIPE;
+
+	if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915)) {
+		/*
+		 * Figure out the current pipe for the initial backlight setup.
+		 * If the current pipe isn't valid, try the PPS pipe, and if that
+		 * fails just assume pipe A.
+		 */
+		pipe = vlv_active_pipe(intel_dp);
+
+		if (pipe != PIPE_A && pipe != PIPE_B)
+			pipe = intel_dp->pps.pps_pipe;
+
+		if (pipe != PIPE_A && pipe != PIPE_B)
+			pipe = PIPE_A;
+
+		drm_dbg_kms(&i915->drm,
+			    "[CONNECTOR:%d:%s] using pipe %c for initial backlight setup\n",
+			    connector->base.base.id, connector->base.name,
+			    pipe_name(pipe));
+	}
+
+	intel_backlight_setup(connector, pipe);
+}
+
 static bool intel_edp_init_connector(struct intel_dp *intel_dp,
 				     struct intel_connector *intel_connector)
 {
@@ -5226,7 +5255,6 @@  static bool intel_edp_init_connector(struct intel_dp *intel_dp,
 	struct drm_display_mode *fixed_mode;
 	struct intel_encoder *encoder = &dp_to_dig_port(intel_dp)->base;
 	bool has_dpcd;
-	enum pipe pipe = INVALID_PIPE;
 	struct edid *edid;
 
 	if (!intel_dp_is_edp(intel_dp))
@@ -5301,28 +5329,9 @@  static bool intel_edp_init_connector(struct intel_dp *intel_dp,
 
 	mutex_unlock(&dev->mode_config.mutex);
 
-	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) {
-		/*
-		 * Figure out the current pipe for the initial backlight setup.
-		 * If the current pipe isn't valid, try the PPS pipe, and if that
-		 * fails just assume pipe A.
-		 */
-		pipe = vlv_active_pipe(intel_dp);
-
-		if (pipe != PIPE_A && pipe != PIPE_B)
-			pipe = intel_dp->pps.pps_pipe;
-
-		if (pipe != PIPE_A && pipe != PIPE_B)
-			pipe = PIPE_A;
-
-		drm_dbg_kms(&dev_priv->drm,
-			    "using pipe %c for initial backlight setup\n",
-			    pipe_name(pipe));
-	}
-
 	intel_panel_init(intel_connector);
 
-	intel_backlight_setup(intel_connector, pipe);
+	intel_edp_backlight_setup(intel_dp, intel_connector);
 
 	intel_edp_add_properties(intel_dp);