[PATCH 04/14] drm/i915/hdmi21/mtl: Split the intel_hdmi_dsc_get_bpp()
Ankit Nautiyal <[email protected]> Thu, 30 Jul 2026 16:22:16 +0530
| Newsgroups | org.freedesktop.lists.intel-gfx,org.freedesktop.lists.intel-xe |
|---|---|
| Message-ID | <[email protected]> |
Split the intel_hdmi_dsc_get_bpp() into two helper functions that can be called independently. Signed-off-by: Ankit Nautiyal <[email protected]> --- drivers/gpu/drm/i915/display/intel_hdmi.c | 88 ++++++++++++++--------- 1 file changed, 55 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index d3efd9e4e86a..428631abca74 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -3325,51 +3325,29 @@ intel_hdmi_dsc_get_num_slices(const struct drm_display_mode *mode, return target_slices; } -/* - * intel_hdmi_dsc_get_bpp - get the appropriate compressed bits_per_pixel based on - * source and sink capabilities. - * - * @src_fraction_bpp: fractional bpp supported by the source - * @slice_width: dsc slice width supported by the source and sink - * @num_slices: num of slices supported by the source and sink - * @output_format: video output format - * @bpc: bits per color - * @hdmi_all_bpp: sink supports decoding of 1/16th bpp setting - * @hdmi_max_chunk_bytes: max bytes in a line of chunks supported by sink - * - * @return: compressed bits_per_pixel in step of 1/16 of bits_per_pixel - */ -int -intel_hdmi_dsc_get_bpp(int src_fractional_bpp, int slice_width, int num_slices, - enum intel_output_format output_format, int bpc, - bool hdmi_all_bpp, int hdmi_max_chunk_bytes) +static void +get_dsc_min_max_bpp(enum intel_output_format output_format, u8 bpc, + bool hdmi_all_bpp, int *min_dsc_bpp, int *max_dsc_bpp) { - int max_dsc_bpp, min_dsc_bpp; - int target_bytes; - bool bpp_found = false; - int bpp_decrement_x16; - int bpp_target; - int bpp_target_x16; - /* * Get min bpp and max bpp as per Table 7.23, in HDMI2.1 spec * Start with the max bpp and keep on decrementing with - * fractional bpp, if supported by PCON DSC encoder + * fractional bpp, if supported by the DSC encoder * * for each bpp we check if no of bytes can be supported by HDMI sink */ if (output_format == INTEL_OUTPUT_FORMAT_YCBCR420) { - min_dsc_bpp = 6; - max_dsc_bpp = 3 * bpc / 2; + *min_dsc_bpp = 6; + *max_dsc_bpp = 3 * bpc / 2; } else if (output_format == INTEL_OUTPUT_FORMAT_YCBCR444 || output_format == INTEL_OUTPUT_FORMAT_RGB) { - min_dsc_bpp = 8; - max_dsc_bpp = 3 * bpc; + *min_dsc_bpp = 8; + *max_dsc_bpp = 3 * bpc; } else { /* Assuming 4:2:2 encoding */ - min_dsc_bpp = 7; - max_dsc_bpp = 2 * bpc; + *min_dsc_bpp = 7; + *max_dsc_bpp = 2 * bpc; } /* @@ -3379,7 +3357,18 @@ intel_hdmi_dsc_get_bpp(int src_fractional_bpp, int slice_width, int num_slices, * DSC_all_bpp is set to 1. */ if (!hdmi_all_bpp) - max_dsc_bpp = min(max_dsc_bpp, 12); + *max_dsc_bpp = min(*max_dsc_bpp, 12); +} + +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; + int bpp_target_x16; /* * The Sink has a limit of compressed data in bytes for a scanline, @@ -3422,3 +3411,36 @@ intel_hdmi_dsc_get_bpp(int src_fractional_bpp, int slice_width, int num_slices, return 0; } + +/* + * intel_hdmi_dsc_get_bpp - get the appropriate compressed bits_per_pixel based on + * source and sink capabilities. + * + * @src_fraction_bpp: fractional bpp supported by the source + * @slice_width: dsc slice width supported by the source and sink + * @num_slices: num of slices supported by the source and sink + * @output_format: video output format + * @bpc: bits per color + * @hdmi_all_bpp: sink supports decoding of 1/16th bpp setting + * @hdmi_max_chunk_bytes: max bytes in a line of chunks supported by sink + * + * @return: compressed bits_per_pixel in step of 1/16 of bits_per_pixel + */ +int +intel_hdmi_dsc_get_bpp(int src_fractional_bpp, int slice_width, int num_slices, + enum intel_output_format output_format, int bpc, + bool hdmi_all_bpp, int hdmi_max_chunk_bytes) +{ + int max_dsc_bpp, min_dsc_bpp; + int dsc_bpp_x16; + + get_dsc_min_max_bpp(output_format, bpc, hdmi_all_bpp, + &min_dsc_bpp, &max_dsc_bpp); + + dsc_bpp_x16 = get_dsc_compressed_bpp(num_slices, slice_width, + hdmi_max_chunk_bytes, + src_fractional_bpp, + min_dsc_bpp, max_dsc_bpp); + + return dsc_bpp_x16; +} -- 2.50.1