]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/i915/scaler: Add scaler prefill helpers
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Wed, 15 Oct 2025 12:56:45 +0000 (15:56 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 16 Oct 2025 15:21:24 +0000 (18:21 +0300)
Add helpers to compute the required prefill line count and
adjustment factors for the scalers.

The "1st" variants hand out numbers for the first scaler stage
in the pipeline (pipe scaler if no plane scalers are enabled,
or the max from all the plane scaler). The "2nd" variants deal
with second scaler stage (pipe scaler when plane scaling is also
enabled, otherwise there is no second stage).

The _worst() variants give out worst case estimates, meant for
guardband sizing. The other variants are meant for the actual
vblank/guardband length check vs. prefill+pkgc/sagv latency.

The returned numbers are in .16 binary fixed point.

TODO: pretty rough, should check the actual scaler max scaling
      factors instead of just assuming 3x everywhere
TODO: Reorder scaler assignment vs. vblank length check to get
      the actual scale factors

v2: Drop debugs
v3: Ignore scale factors for the vblank length check for now
    since we don't have the scalers assigned yet

Reviewed-by: Uma Shankar <uma.shankar@intel.com> #v1
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20251015125645.11230-1-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/skl_scaler.c
drivers/gpu/drm/i915/display/skl_scaler.h

index c6cccf170ff10f13d51fa83245b89d1a4bf89247..630fcf1cb9acc23e7361029a57665e3a704ef283 100644 (file)
@@ -968,3 +968,114 @@ void adl_scaler_ecc_unmask(const struct intel_crtc_state *crtc_state)
                          1);
        intel_de_write(display, XELPD_DISPLAY_ERR_FATAL_MASK, 0);
 }
+
+unsigned int skl_scaler_1st_prefill_adjustment(const struct intel_crtc_state *crtc_state)
+{
+       /*
+        * FIXME don't have scalers assigned yet
+        * so can't look up the scale factors
+        */
+       return 0x10000;
+}
+
+unsigned int skl_scaler_2nd_prefill_adjustment(const struct intel_crtc_state *crtc_state)
+{
+       /*
+        * FIXME don't have scalers assigned yet
+        * so can't look up the scale factors
+        */
+       return 0x10000;
+}
+
+unsigned int skl_scaler_1st_prefill_lines(const struct intel_crtc_state *crtc_state)
+{
+       const struct intel_crtc_scaler_state *scaler_state =
+               &crtc_state->scaler_state;
+       int num_scalers = hweight32(scaler_state->scaler_users);
+
+       if (num_scalers > 0)
+               return 4 << 16;
+
+       return 0;
+}
+
+unsigned int skl_scaler_2nd_prefill_lines(const struct intel_crtc_state *crtc_state)
+{
+       const struct intel_crtc_scaler_state *scaler_state =
+               &crtc_state->scaler_state;
+       int num_scalers = hweight32(scaler_state->scaler_users);
+
+       if (num_scalers > 1 && crtc_state->pch_pfit.enabled)
+               return 4 << 16;
+
+       return 0;
+}
+
+static unsigned int _skl_scaler_max_scale(const struct intel_crtc_state *crtc_state,
+                                         unsigned int max_scale)
+{
+       struct intel_display *display = to_intel_display(crtc_state);
+
+       /*
+        * Downscaling requires increasing cdclk, so max scale
+        * factor is limited to the max_dotclock/dotclock ratio.
+        *
+        * FIXME find out the max downscale factors properly
+        */
+       return min(max_scale, DIV_ROUND_UP_ULL((u64)display->cdclk.max_dotclk_freq << 16,
+                                              crtc_state->hw.pipe_mode.crtc_clock));
+}
+
+static unsigned int skl_scaler_max_scale(const struct intel_crtc_state *crtc_state)
+{
+       struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+       unsigned int max_scale;
+
+       if (crtc->num_scalers < 1)
+               return 0x10000;
+
+       /* FIXME find out the max downscale factors properly */
+       max_scale = 9 << 16;
+
+       return _skl_scaler_max_scale(crtc_state, max_scale);
+}
+
+unsigned int skl_scaler_1st_prefill_adjustment_worst(const struct intel_crtc_state *crtc_state)
+{
+       struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+
+       if (crtc->num_scalers > 0)
+               return skl_scaler_max_scale(crtc_state);
+       else
+               return 0x10000;
+}
+
+unsigned int skl_scaler_2nd_prefill_adjustment_worst(const struct intel_crtc_state *crtc_state)
+{
+       struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+
+       if (crtc->num_scalers > 1)
+               return skl_scaler_max_scale(crtc_state);
+       else
+               return 0x10000;
+}
+
+unsigned int skl_scaler_1st_prefill_lines_worst(const struct intel_crtc_state *crtc_state)
+{
+       struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+
+       if (crtc->num_scalers > 0)
+               return 4 << 16;
+       else
+               return 0;
+}
+
+unsigned int skl_scaler_2nd_prefill_lines_worst(const struct intel_crtc_state *crtc_state)
+{
+       struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+
+       if (crtc->num_scalers > 1)
+               return 4 << 16;
+       else
+               return 0;
+}
index 12a19016c5f6fac033f8d9182337813132b35b40..6fab40d2b4ee501ef540dd67746f3c77fcf98031 100644 (file)
@@ -45,4 +45,15 @@ skl_scaler_mode_valid(struct intel_display *display,
 void adl_scaler_ecc_mask(const struct intel_crtc_state *crtc_state);
 
 void adl_scaler_ecc_unmask(const struct intel_crtc_state *crtc_state);
+
+unsigned int skl_scaler_1st_prefill_adjustment_worst(const struct intel_crtc_state *crtc_state);
+unsigned int skl_scaler_2nd_prefill_adjustment_worst(const struct intel_crtc_state *crtc_state);
+unsigned int skl_scaler_1st_prefill_lines_worst(const struct intel_crtc_state *crtc_state);
+unsigned int skl_scaler_2nd_prefill_lines_worst(const struct intel_crtc_state *crtc_state);
+
+unsigned int skl_scaler_1st_prefill_adjustment(const struct intel_crtc_state *crtc_state);
+unsigned int skl_scaler_2nd_prefill_adjustment(const struct intel_crtc_state *crtc_state);
+unsigned int skl_scaler_1st_prefill_lines(const struct intel_crtc_state *crtc_state);
+unsigned int skl_scaler_2nd_prefill_lines(const struct intel_crtc_state *crtc_state);
+
 #endif