diff mbox series

[06/19] drm/i915/display: Simplify intel_joiner_num_pipes and its usage

Message ID 20240911131349.933814-7-ankit.k.nautiyal@intel.com (mailing list archive)
State New, archived
Headers show
Series Ultrajoiner basic functionality series | expand

Commit Message

Ankit Nautiyal Sept. 11, 2024, 1:13 p.m. UTC
Currently intel_joiner_num_pipes is used to get num of pipes wrt num of
pipes joined. Simplify this by returning 1 when no joiner is used and
update the checks for no joiner case.

Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
---
 drivers/gpu/drm/i915/display/intel_display.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Ville Syrjala Sept. 11, 2024, 8:14 p.m. UTC | #1
On Wed, Sep 11, 2024 at 06:43:36PM +0530, Ankit Nautiyal wrote:
> Currently intel_joiner_num_pipes is used to get num of pipes wrt num of
> pipes joined. Simplify this by returning 1 when no joiner is used and
> update the checks for no joiner case.
> 
> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_display.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index 486bade9e927..4751ee20216d 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -280,7 +280,7 @@ bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state)
>  
>  static int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
>  {
> -	return hweight8(crtc_state->joiner_pipes);
> +	return hweight8(crtc_state->joiner_pipes) ?: 1;

If we want to deal with this here, then the function probably needs
to be renamed to something like intel_crtc_num_joined_pipes().

In fact we could implement it using the already exising
intel_crtc_joined_pipe_mask() and avoid the ?:1 stuff.

>  }
>  
>  u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
> @@ -2347,7 +2347,7 @@ static void intel_joiner_adjust_timings(const struct intel_crtc_state *crtc_stat
>  {
>  	int num_pipes = intel_joiner_num_pipes(crtc_state);
>  
> -	if (num_pipes < 2)
> +	if (num_pipes == 1)
>  		return;
>  
>  	mode->crtc_clock /= num_pipes;
> @@ -2409,7 +2409,7 @@ static void intel_crtc_readout_derived_state(struct intel_crtc_state *crtc_state
>  	drm_mode_copy(mode, pipe_mode);
>  	intel_mode_from_crtc_timings(mode, mode);
>  	mode->hdisplay = drm_rect_width(&crtc_state->pipe_src) *
> -		(intel_joiner_num_pipes(crtc_state) ?: 1);
> +		intel_joiner_num_pipes(crtc_state);
>  	mode->vdisplay = drm_rect_height(&crtc_state->pipe_src);
>  
>  	/* Derive per-pipe timings in case joiner is used */
> @@ -2432,7 +2432,7 @@ static void intel_joiner_compute_pipe_src(struct intel_crtc_state *crtc_state)
>  	int num_pipes = intel_joiner_num_pipes(crtc_state);
>  	int width, height;
>  
> -	if (num_pipes < 2)
> +	if (num_pipes == 1)
>  		return;
>  
>  	width = drm_rect_width(&crtc_state->pipe_src);
> @@ -2893,7 +2893,7 @@ static void intel_joiner_adjust_pipe_src(struct intel_crtc_state *crtc_state)
>  	enum pipe primary_pipe, pipe = crtc->pipe;
>  	int width;
>  
> -	if (num_pipes < 2)
> +	if (num_pipes == 1)
>  		return;
>  
>  	primary_pipe = joiner_primary_pipe(crtc_state);
> -- 
> 2.45.2
Ankit Nautiyal Sept. 12, 2024, 10:15 a.m. UTC | #2
On 9/12/2024 1:44 AM, Ville Syrjälä wrote:
> On Wed, Sep 11, 2024 at 06:43:36PM +0530, Ankit Nautiyal wrote:
>> Currently intel_joiner_num_pipes is used to get num of pipes wrt num of
>> pipes joined. Simplify this by returning 1 when no joiner is used and
>> update the checks for no joiner case.
>>
>> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
>> ---
>>   drivers/gpu/drm/i915/display/intel_display.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
>> index 486bade9e927..4751ee20216d 100644
>> --- a/drivers/gpu/drm/i915/display/intel_display.c
>> +++ b/drivers/gpu/drm/i915/display/intel_display.c
>> @@ -280,7 +280,7 @@ bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state)
>>   
>>   static int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
>>   {
>> -	return hweight8(crtc_state->joiner_pipes);
>> +	return hweight8(crtc_state->joiner_pipes) ?: 1;
> If we want to deal with this here, then the function probably needs
> to be renamed to something like intel_crtc_num_joined_pipes().
>
> In fact we could implement it using the already exising
> intel_crtc_joined_pipe_mask() and avoid the ?:1 stuff.

Alright I will rename the function as suggested and use:

int intel_crtc_num_joined_pipes(const struct intel_crtc_state *crtc_state)
{
         return hweight8(intel_crtc_joined_pipe_mask(crtc_state));
}

Regards,

Ankit

>
>>   }
>>   
>>   u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
>> @@ -2347,7 +2347,7 @@ static void intel_joiner_adjust_timings(const struct intel_crtc_state *crtc_stat
>>   {
>>   	int num_pipes = intel_joiner_num_pipes(crtc_state);
>>   
>> -	if (num_pipes < 2)
>> +	if (num_pipes == 1)
>>   		return;
>>   
>>   	mode->crtc_clock /= num_pipes;
>> @@ -2409,7 +2409,7 @@ static void intel_crtc_readout_derived_state(struct intel_crtc_state *crtc_state
>>   	drm_mode_copy(mode, pipe_mode);
>>   	intel_mode_from_crtc_timings(mode, mode);
>>   	mode->hdisplay = drm_rect_width(&crtc_state->pipe_src) *
>> -		(intel_joiner_num_pipes(crtc_state) ?: 1);
>> +		intel_joiner_num_pipes(crtc_state);
>>   	mode->vdisplay = drm_rect_height(&crtc_state->pipe_src);
>>   
>>   	/* Derive per-pipe timings in case joiner is used */
>> @@ -2432,7 +2432,7 @@ static void intel_joiner_compute_pipe_src(struct intel_crtc_state *crtc_state)
>>   	int num_pipes = intel_joiner_num_pipes(crtc_state);
>>   	int width, height;
>>   
>> -	if (num_pipes < 2)
>> +	if (num_pipes == 1)
>>   		return;
>>   
>>   	width = drm_rect_width(&crtc_state->pipe_src);
>> @@ -2893,7 +2893,7 @@ static void intel_joiner_adjust_pipe_src(struct intel_crtc_state *crtc_state)
>>   	enum pipe primary_pipe, pipe = crtc->pipe;
>>   	int width;
>>   
>> -	if (num_pipes < 2)
>> +	if (num_pipes == 1)
>>   		return;
>>   
>>   	primary_pipe = joiner_primary_pipe(crtc_state);
>> -- 
>> 2.45.2
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index 486bade9e927..4751ee20216d 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -280,7 +280,7 @@  bool intel_crtc_is_joiner_primary(const struct intel_crtc_state *crtc_state)
 
 static int intel_joiner_num_pipes(const struct intel_crtc_state *crtc_state)
 {
-	return hweight8(crtc_state->joiner_pipes);
+	return hweight8(crtc_state->joiner_pipes) ?: 1;
 }
 
 u8 intel_crtc_joined_pipe_mask(const struct intel_crtc_state *crtc_state)
@@ -2347,7 +2347,7 @@  static void intel_joiner_adjust_timings(const struct intel_crtc_state *crtc_stat
 {
 	int num_pipes = intel_joiner_num_pipes(crtc_state);
 
-	if (num_pipes < 2)
+	if (num_pipes == 1)
 		return;
 
 	mode->crtc_clock /= num_pipes;
@@ -2409,7 +2409,7 @@  static void intel_crtc_readout_derived_state(struct intel_crtc_state *crtc_state
 	drm_mode_copy(mode, pipe_mode);
 	intel_mode_from_crtc_timings(mode, mode);
 	mode->hdisplay = drm_rect_width(&crtc_state->pipe_src) *
-		(intel_joiner_num_pipes(crtc_state) ?: 1);
+		intel_joiner_num_pipes(crtc_state);
 	mode->vdisplay = drm_rect_height(&crtc_state->pipe_src);
 
 	/* Derive per-pipe timings in case joiner is used */
@@ -2432,7 +2432,7 @@  static void intel_joiner_compute_pipe_src(struct intel_crtc_state *crtc_state)
 	int num_pipes = intel_joiner_num_pipes(crtc_state);
 	int width, height;
 
-	if (num_pipes < 2)
+	if (num_pipes == 1)
 		return;
 
 	width = drm_rect_width(&crtc_state->pipe_src);
@@ -2893,7 +2893,7 @@  static void intel_joiner_adjust_pipe_src(struct intel_crtc_state *crtc_state)
 	enum pipe primary_pipe, pipe = crtc->pipe;
 	int width;
 
-	if (num_pipes < 2)
+	if (num_pipes == 1)
 		return;
 
 	primary_pipe = joiner_primary_pipe(crtc_state);