> Subject: [PATCH 10/14] drm/i915/hdmi: Add helper to check if DSC chunksize
> fits the sink limits
> 
> Introduce the helper intel_hdmi_dsc_bpp_fits_chunk_bytes() to check whether
> the chunksize computed for the given slice configuration is with in the sink's
> max chunksize limits.
> 
> Signed-off-by: Ankit Nautiyal <[email protected]>

LGTM,
Reviewed-by: Suraj Kandpal <[email protected]>

> ---
>  drivers/gpu/drm/i915/display/intel_hdmi.c | 25 ++++++++++++++++++++---
> drivers/gpu/drm/i915/display/intel_hdmi.h |  2 ++
>  2 files changed, 24 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c
> b/drivers/gpu/drm/i915/display/intel_hdmi.c
> index c58c9202fc10..c26a3d0b2d2e 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> @@ -3370,11 +3370,30 @@ intel_hdmi_dsc_get_min_max_bpp(enum
> intel_output_format output_format, u8 bpc,
>               *max_dsc_bpp = min(*max_dsc_bpp, 12);  }
> 
> +/*
> + * intel_hdmi_dsc_bpp_fits_chunk_bytes - check if a given compressed
> +bpp keeps
> + * the per-scanline chunk size within the sink's max_chunk_bytes limit.
> + *
> + * @bpp: compressed bits per pixel to test
> + * @num_slices: num of slices supported by the source and sink
> + * @slice_width: dsc slice width supported by the source and sink
> + * @hdmi_max_chunk_bytes: max bytes in a line of chunks supported by
> +sink
> + *
> + * @return: true if the resulting chunk size fits the sink limit  */
> +bool intel_hdmi_dsc_bpp_fits_chunk_bytes(int bpp, int num_slices, int
> +slice_width,
> +                                 int hdmi_max_chunk_bytes)
> +{
> +     int target_bytes = DIV_ROUND_UP((num_slices * slice_width * bpp), 8);
> +
> +     return target_bytes <= hdmi_max_chunk_bytes; }
> +
>  static int
>  get_dsc_compressed_bpp(int num_slices, int slice_width, int
> hdmi_max_chunk_bytes,
>                      int src_fractional_bpp, int min_dsc_bpp, int max_dsc_bpp)
> {
> -     int target_bytes;
>       bool bpp_found = false;
>       int bpp_decrement_x16;
>       int bpp_target;
> @@ -3409,8 +3428,8 @@ get_dsc_compressed_bpp(int num_slices, int
> slice_width, int hdmi_max_chunk_bytes
>               int bpp;
> 
>               bpp = DIV_ROUND_UP(bpp_target_x16, 16);
> -             target_bytes = DIV_ROUND_UP((num_slices * slice_width *
> bpp), 8);
> -             if (target_bytes <= hdmi_max_chunk_bytes) {
> +             if (intel_hdmi_dsc_bpp_fits_chunk_bytes(bpp, num_slices,
> slice_width,
> +
>       hdmi_max_chunk_bytes)) {
>                       bpp_found = true;
>                       break;
>               }
> diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.h
> b/drivers/gpu/drm/i915/display/intel_hdmi.h
> index dc81a62aac5e..e7d0cd5bc293 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdmi.h
> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.h
> @@ -59,6 +59,8 @@ int intel_hdmi_dsc_get_bpp(int src_fractional_bpp, int
> slice_width,
>                          int bpc, bool hdmi_all_bpp, int
> hdmi_max_chunk_bytes);  void intel_hdmi_dsc_get_min_max_bpp(enum
> intel_output_format output_format, u8 bpc,
>                                   bool hdmi_all_bpp, int *min_dsc_bpp, int
> *max_dsc_bpp);
> +bool intel_hdmi_dsc_bpp_fits_chunk_bytes(int bpp, int num_slices, int
> slice_width,
> +                                      int hdmi_max_chunk_bytes);
>  int intel_hdmi_dsc_get_num_slices(const struct drm_display_mode *mode,
>                                 enum intel_output_format output_format,
>                                 int src_max_slices, int src_max_slice_width,
> --
> 2.50.1

Reply via email to