diff mbox series

[12/17] drm/i915/dp: Simplify the helper get_max_compressed_bpp_with_joiner

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

Commit Message

Nautiyal, Ankit K Sept. 27, 2024, 8:38 a.m. UTC
Streamline the helper to get max compressed bpp for joiner case, to
effectively use num of pipes joined. This will make the addition of
ultrajoiner limitations easier and improve redability.

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

Comments

Ville Syrjälä Sept. 27, 2024, 12:31 p.m. UTC | #1
On Fri, Sep 27, 2024 at 02:08:26PM +0530, Ankit Nautiyal wrote:
> Streamline the helper to get max compressed bpp for joiner case, to
> effectively use num of pipes joined. This will make the addition of
> ultrajoiner limitations easier and improve redability.
> 
> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dp.c | 20 ++++++++------------
>  1 file changed, 8 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 7db037f631f7..e7fe100ef8db 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -882,7 +882,8 @@ static u32 bigjoiner_bw_max_bpp(struct intel_display *display, u32 mode_clock,
>  	return max_bpp;
>  }
>  
> -static u32 small_joiner_ram_max_bpp(struct intel_display *display, u32 mode_hdisplay)
> +static u32 small_joiner_ram_max_bpp(struct intel_display *display, u32 mode_hdisplay,
> +				    int num_joined_pipes)
>  {
>  	struct drm_i915_private *i915 = to_i915(display->drm);
>  	u32 max_bpp;
> @@ -890,6 +891,8 @@ static u32 small_joiner_ram_max_bpp(struct intel_display *display, u32 mode_hdis
>  	/* Small Joiner Check: output bpp <= joiner RAM (bits) / Horiz. width */
>  	max_bpp = small_joiner_ram_size_bits(i915) / mode_hdisplay;
>  
> +	max_bpp *= num_joined_pipes;
> +

lgtm, with the caveat that this part needs a bit of adjustment
after the *=2 gets moved here when respinning the previous patch.

Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

>  	return max_bpp;
>  }
>  
> @@ -899,19 +902,12 @@ u32 get_max_compressed_bpp_with_joiner(struct drm_i915_private *i915,
>  				       int num_joined_pipes)
>  {
>  	struct intel_display *display = to_intel_display(&i915->drm);
> -	u32 max_bpp_small_joiner_ram;
> -
> -	max_bpp_small_joiner_ram = small_joiner_ram_max_bpp(display, mode_hdisplay);
> -
> -	if (num_joined_pipes == 2) {
> -		u32 max_bpp_bigjoiner = bigjoiner_bw_max_bpp(display, mode_clock, num_joined_pipes);
> -
> -		max_bpp_small_joiner_ram *= 2;
> +	u32 max_bpp;
>  
> -		return min(max_bpp_small_joiner_ram, max_bpp_bigjoiner);
> -	}
> +	max_bpp = small_joiner_ram_max_bpp(display, mode_hdisplay, num_joined_pipes);
> +	max_bpp = min(max_bpp, bigjoiner_bw_max_bpp(display, mode_clock, num_joined_pipes));
>  
> -	return max_bpp_small_joiner_ram;
> +	return max_bpp;
>  }
>  
>  u16 intel_dp_dsc_get_max_compressed_bpp(struct drm_i915_private *i915,
> -- 
> 2.45.2
Ville Syrjälä Sept. 27, 2024, 12:38 p.m. UTC | #2
On Fri, Sep 27, 2024 at 03:31:29PM +0300, Ville Syrjälä wrote:
> On Fri, Sep 27, 2024 at 02:08:26PM +0530, Ankit Nautiyal wrote:
> > Streamline the helper to get max compressed bpp for joiner case, to
> > effectively use num of pipes joined. This will make the addition of
> > ultrajoiner limitations easier and improve redability.
> > 
> > Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_dp.c | 20 ++++++++------------
> >  1 file changed, 8 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> > index 7db037f631f7..e7fe100ef8db 100644
> > --- a/drivers/gpu/drm/i915/display/intel_dp.c
> > +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> > @@ -882,7 +882,8 @@ static u32 bigjoiner_bw_max_bpp(struct intel_display *display, u32 mode_clock,
> >  	return max_bpp;
> >  }
> >  
> > -static u32 small_joiner_ram_max_bpp(struct intel_display *display, u32 mode_hdisplay)
> > +static u32 small_joiner_ram_max_bpp(struct intel_display *display, u32 mode_hdisplay,
> > +				    int num_joined_pipes)
> >  {
> >  	struct drm_i915_private *i915 = to_i915(display->drm);
> >  	u32 max_bpp;
> > @@ -890,6 +891,8 @@ static u32 small_joiner_ram_max_bpp(struct intel_display *display, u32 mode_hdis
> >  	/* Small Joiner Check: output bpp <= joiner RAM (bits) / Horiz. width */
> >  	max_bpp = small_joiner_ram_size_bits(i915) / mode_hdisplay;
> >  
> > +	max_bpp *= num_joined_pipes;
> > +
> 
> lgtm, with the caveat that this part needs a bit of adjustment
> after the *=2 gets moved here when respinning the previous patch.
> 
> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> >  	return max_bpp;
> >  }
> >  
> > @@ -899,19 +902,12 @@ u32 get_max_compressed_bpp_with_joiner(struct drm_i915_private *i915,
> >  				       int num_joined_pipes)
> >  {
> >  	struct intel_display *display = to_intel_display(&i915->drm);
> > -	u32 max_bpp_small_joiner_ram;
> > -
> > -	max_bpp_small_joiner_ram = small_joiner_ram_max_bpp(display, mode_hdisplay);
> > -
> > -	if (num_joined_pipes == 2) {
> > -		u32 max_bpp_bigjoiner = bigjoiner_bw_max_bpp(display, mode_clock, num_joined_pipes);
> > -
> > -		max_bpp_small_joiner_ram *= 2;
> > +	u32 max_bpp;
> >  
> > -		return min(max_bpp_small_joiner_ram, max_bpp_bigjoiner);
> > -	}
> > +	max_bpp = small_joiner_ram_max_bpp(display, mode_hdisplay, num_joined_pipes);
> > +	max_bpp = min(max_bpp, bigjoiner_bw_max_bpp(display, mode_clock, num_joined_pipes));

Actually, this isn't quite right. We now call bigjoiner_bw_max_bpp()
unconditioanlly (which I kinda do like), but it doesn't handle the
num_joined_pipes==1 case.

Hmm, the fact that we use min() on these makes it a bit more awkward to
handle it all in there. We'd probably have to return <TYPE>_MAX from
there to make sure the min() ignores it.

The alternative is to call these conditionally based on
num_joined_pipes. I suppose that's not all that terrible.

> >  
> > -	return max_bpp_small_joiner_ram;
> > +	return max_bpp;
> >  }
> >  
> >  u16 intel_dp_dsc_get_max_compressed_bpp(struct drm_i915_private *i915,
> > -- 
> > 2.45.2
> 
> -- 
> Ville Syrjälä
> Intel
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 7db037f631f7..e7fe100ef8db 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -882,7 +882,8 @@  static u32 bigjoiner_bw_max_bpp(struct intel_display *display, u32 mode_clock,
 	return max_bpp;
 }
 
-static u32 small_joiner_ram_max_bpp(struct intel_display *display, u32 mode_hdisplay)
+static u32 small_joiner_ram_max_bpp(struct intel_display *display, u32 mode_hdisplay,
+				    int num_joined_pipes)
 {
 	struct drm_i915_private *i915 = to_i915(display->drm);
 	u32 max_bpp;
@@ -890,6 +891,8 @@  static u32 small_joiner_ram_max_bpp(struct intel_display *display, u32 mode_hdis
 	/* Small Joiner Check: output bpp <= joiner RAM (bits) / Horiz. width */
 	max_bpp = small_joiner_ram_size_bits(i915) / mode_hdisplay;
 
+	max_bpp *= num_joined_pipes;
+
 	return max_bpp;
 }
 
@@ -899,19 +902,12 @@  u32 get_max_compressed_bpp_with_joiner(struct drm_i915_private *i915,
 				       int num_joined_pipes)
 {
 	struct intel_display *display = to_intel_display(&i915->drm);
-	u32 max_bpp_small_joiner_ram;
-
-	max_bpp_small_joiner_ram = small_joiner_ram_max_bpp(display, mode_hdisplay);
-
-	if (num_joined_pipes == 2) {
-		u32 max_bpp_bigjoiner = bigjoiner_bw_max_bpp(display, mode_clock, num_joined_pipes);
-
-		max_bpp_small_joiner_ram *= 2;
+	u32 max_bpp;
 
-		return min(max_bpp_small_joiner_ram, max_bpp_bigjoiner);
-	}
+	max_bpp = small_joiner_ram_max_bpp(display, mode_hdisplay, num_joined_pipes);
+	max_bpp = min(max_bpp, bigjoiner_bw_max_bpp(display, mode_clock, num_joined_pipes));
 
-	return max_bpp_small_joiner_ram;
+	return max_bpp;
 }
 
 u16 intel_dp_dsc_get_max_compressed_bpp(struct drm_i915_private *i915,