[PATCH v2 1/8] drm/i915/hdmi: Split the intel_hdmi_dsc_get_bpp()
Ankit Nautiyal <[email protected]>
| 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. While at it, improve the comments in the helper. Signed-off-by: Ankit Nautiyal <[email protected]> --- drivers/gpu/drm/i915/display/intel_hdmi.c | 97 ++++++++++++++--------- 1 file changed, 59 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index 9b637e38a1a5..df88d7c141f7 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -3325,61 +3325,49 @@ 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 + * Get min bpp and max bpp that can be supported for a + * given bpc and output format. * 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; } /* - * Taking into account if all dsc_all_bpp supported by HDMI2.1 sink - * Section 7.7.34 : Source shall not enable compressed Video - * Transport with bpp_target settings above 12 bpp unless - * DSC_all_bpp is set to 1. + * Don't enable DSC bpp_target settings above 12 bpp, + * unless 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, @@ -3423,6 +3411,39 @@ 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; +} + int intel_hdmi_sink_max_frl_rate(struct drm_connector *connector) { int max_lanes = connector->display_info.hdmi.max_lanes; -- 2.50.1