drm/i915/dp: Add intel_dp_dsc_bpp_step_x16() helper to get DSC BPP precision
authorJani Nikula <jani.nikula@intel.com>
Fri, 31 Jan 2025 23:28:15 +0000 (01:28 +0200)
committerJani Nikula <jani.nikula@intel.com>
Mon, 3 Feb 2025 14:31:02 +0000 (16:31 +0200)
Add a platform independent helper for getting the supported DSC BPP step
for the link.

v2: Use fxp_q4_from_int(1) (Imre)

Reviewed-by: Imre Deak <imre.deak@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250131232815.2046237-1-jani.nikula@intel.com
drivers/gpu/drm/i915/display/intel_dp.c

index f2c4afc5997c223f183d4dbb12604bc8866e1319..43c6f0ad0c011816146a21fd7297e802ced7b76f 100644 (file)
@@ -2054,6 +2054,21 @@ static int dsc_src_max_compressed_bpp(struct intel_dp *intel_dp)
                return 27;
 }
 
+/*
+ * Note: for pre-13 display you still need to check the validity of each step.
+ */
+static int intel_dp_dsc_bpp_step_x16(const struct intel_connector *connector)
+{
+       struct intel_display *display = to_intel_display(connector);
+       u8 incr = drm_dp_dsc_sink_bpp_incr(connector->dp.dsc_dpcd);
+
+       if (DISPLAY_VER(display) < 14 || !incr)
+               return fxp_q4_from_int(1);
+
+       /* fxp q4 */
+       return fxp_q4_from_int(1) / incr;
+}
+
 /*
  * From a list of valid compressed bpps try different compressed bpp and find a
  * suitable link configuration that can support it.
@@ -2110,16 +2125,12 @@ xelpd_dsc_compute_link_config(struct intel_dp *intel_dp,
                              int timeslots)
 {
        struct intel_display *display = to_intel_display(intel_dp);
-       u8 bppx16_incr = drm_dp_dsc_sink_bpp_incr(connector->dp.dsc_dpcd);
        int output_bpp = intel_dp_output_bpp(pipe_config->output_format, pipe_bpp);
        u16 compressed_bppx16;
        u8 bppx16_step;
        int ret;
 
-       if (DISPLAY_VER(display) < 14 || bppx16_incr <= 1)
-               bppx16_step = 16;
-       else
-               bppx16_step = 16 / bppx16_incr;
+       bppx16_step = intel_dp_dsc_bpp_step_x16(connector);
 
        /* Compressed BPP should be less than the Input DSC bpp */
        dsc_max_bpp = min(dsc_max_bpp << 4, (output_bpp << 4) - bppx16_step);