The max bpp from intel_hdmi_dsc_get_min_max_bpp() is at most the uncompressed link bpp, so when picking the compressed bpp we reduce the target to keep it below the uncompressed link bpp. Doing this unconditionally makes the search skip both the max and min boundaries, returning 0 when max_dsc_bpp equals min_dsc_bpp.
That case isn't hit as of now, but an upcoming FRL link-bandwidth clamp can make max_dsc_bpp == min_dsc_bpp. Reduce the target only when it equals the uncompressed link bpp, start at max_dsc_bpp otherwise, and iterate down to and including min_dsc_bpp. v2: Use link bpp, reuse intel_dp_output_format_link_bpp_x16(). (Suraj) Signed-off-by: Ankit Nautiyal <[email protected]> --- drivers/gpu/drm/i915/display/intel_hdmi.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c index 7c44fb03f6c9..b4b39f5edfae 100644 --- a/drivers/gpu/drm/i915/display/intel_hdmi.c +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c @@ -3402,13 +3402,15 @@ intel_hdmi_dsc_bpp_fits_chunk_bytes(int bpp, int num_slices, int slice_width, } static int -get_dsc_compressed_bpp(int num_slices, int slice_width, int hdmi_max_chunk_bytes, +get_dsc_compressed_bpp(enum intel_output_format output_format, int bpc, + int num_slices, int slice_width, int hdmi_max_chunk_bytes, int src_fractional_bpp, int min_dsc_bpp, int max_dsc_bpp) { bool bpp_found = false; int bpp_decrement_x16; int bpp_target; int bpp_target_x16; + int link_bpp_x16 = intel_dp_output_format_link_bpp_x16(output_format, 3 * bpc); /* * The Sink has a limit of compressed data in bytes for a scanline, @@ -3433,9 +3435,13 @@ get_dsc_compressed_bpp(int num_slices, int slice_width, int hdmi_max_chunk_bytes if (!src_fractional_bpp) src_fractional_bpp = 1; bpp_decrement_x16 = DIV_ROUND_UP(16, src_fractional_bpp); - bpp_target_x16 = (bpp_target * 16) - bpp_decrement_x16; + bpp_target_x16 = bpp_target * 16; - while (bpp_target_x16 > (min_dsc_bpp * 16)) { + /* The compressed bpp can't be the same as the uncompressed link bpp */ + if (bpp_target_x16 == link_bpp_x16) + bpp_target_x16 -= bpp_decrement_x16; + + while (bpp_target_x16 >= (min_dsc_bpp * 16)) { int bpp; bpp = DIV_ROUND_UP(bpp_target_x16, 16); @@ -3477,7 +3483,8 @@ intel_hdmi_dsc_get_bpp(int src_fractional_bpp, int slice_width, int num_slices, intel_hdmi_dsc_get_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, + dsc_bpp_x16 = get_dsc_compressed_bpp(output_format, bpc, + num_slices, slice_width, hdmi_max_chunk_bytes, src_fractional_bpp, min_dsc_bpp, max_dsc_bpp); -- 2.50.1
