]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/dp: Use helpers to align min/max compressed BPPs
authorImre Deak <imre.deak@intel.com>
Mon, 22 Dec 2025 15:35:41 +0000 (17:35 +0200)
committerImre Deak <imre.deak@intel.com>
Tue, 13 Jan 2026 16:42:18 +0000 (18:42 +0200)
The minimum/maximum compressed BPP values are aligned/bounded in
intel_dp_compute_link_bpp_limits() to the corresponding source limits.
The minimum compressed BPP value doesn't change afterwards, so no need
to align it again, remove that.

The maximum compressed BPP, which depends on the pipe BPP value still
needs to be aligned, since the pipe BPP value could change after the
above limits were computed, via intel_dp_force_dsc_pipe_bpp(). Use the
corresponding helper for this alignment instead of open-coding the same.

Reviewed-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
Link: https://patch.msgid.link/20251222153547.713360-15-imre.deak@intel.com
drivers/gpu/drm/i915/display/intel_dp.c

index e59c06b6e0b9935ed455d93aebf9c47caa35bc00..36cbb6aef2434c008f3f9e609fe0adfed515579c 100644 (file)
@@ -2218,20 +2218,15 @@ static int dsc_compute_compressed_bpp(struct intel_dp *intel_dp,
        struct intel_display *display = to_intel_display(intel_dp);
        const struct intel_connector *connector = to_intel_connector(conn_state->connector);
        int min_bpp_x16, max_bpp_x16, bpp_step_x16;
-       int link_bpp_x16;
        int bpp_x16;
        int ret;
 
+       min_bpp_x16 = limits->link.min_bpp_x16;
        max_bpp_x16 = limits->link.max_bpp_x16;
        bpp_step_x16 = intel_dp_dsc_bpp_step_x16(connector);
 
-       /* Compressed BPP should be less than the Input DSC bpp */
-       link_bpp_x16 = intel_dp_output_format_link_bpp_x16(pipe_config->output_format, pipe_bpp);
-       max_bpp_x16 = min(max_bpp_x16, link_bpp_x16 - bpp_step_x16);
-
-       drm_WARN_ON(display->drm, !is_power_of_2(bpp_step_x16));
-       min_bpp_x16 = round_up(limits->link.min_bpp_x16, bpp_step_x16);
-       max_bpp_x16 = round_down(max_bpp_x16, bpp_step_x16);
+       max_bpp_x16 = align_max_compressed_bpp_x16(connector, pipe_config->output_format,
+                                                  pipe_bpp, max_bpp_x16);
 
        for (bpp_x16 = max_bpp_x16; bpp_x16 >= min_bpp_x16; bpp_x16 -= bpp_step_x16) {
                if (!intel_dp_dsc_valid_compressed_bpp(intel_dp, bpp_x16))
@@ -2347,8 +2342,6 @@ static int intel_edp_dsc_compute_pipe_bpp(struct intel_dp *intel_dp,
        struct intel_connector *connector =
                to_intel_connector(conn_state->connector);
        int pipe_bpp, forced_bpp;
-       int dsc_min_bpp;
-       int dsc_max_bpp;
 
        forced_bpp = intel_dp_force_dsc_pipe_bpp(intel_dp, limits);
 
@@ -2368,15 +2361,9 @@ static int intel_edp_dsc_compute_pipe_bpp(struct intel_dp *intel_dp,
        pipe_config->port_clock = limits->max_rate;
        pipe_config->lane_count = limits->max_lane_count;
 
-       dsc_min_bpp = fxp_q4_to_int_roundup(limits->link.min_bpp_x16);
-
-       dsc_max_bpp = fxp_q4_to_int(limits->link.max_bpp_x16);
-
-       /* Compressed BPP should be less than the Input DSC bpp */
-       dsc_max_bpp = min(dsc_max_bpp, pipe_bpp - 1);
-
        pipe_config->dsc.compressed_bpp_x16 =
-               fxp_q4_from_int(max(dsc_min_bpp, dsc_max_bpp));
+               align_max_compressed_bpp_x16(connector, pipe_config->output_format,
+                                            pipe_bpp, limits->link.max_bpp_x16);
 
        pipe_config->pipe_bpp = pipe_bpp;