drm/i915/display: add a gelper to relative data rate handling
authorVinod Govindapillai <vinod.govindapillai@intel.com>
Thu, 21 Nov 2024 11:27:25 +0000 (13:27 +0200)
committerVinod Govindapillai <vinod.govindapillai@intel.com>
Thu, 12 Dec 2024 07:26:55 +0000 (09:26 +0200)
Add a helper to the relative data rate handling in skl_watermarks.c
where other similar functions are implemented. Also get rid of
use_min_ddb() and use use_minimal_wm0() instead to decide whether
the relative data rate can be returned as 0

v2: re-phrase the commit description (uma)

Signed-off-by: Vinod Govindapillai <vinod.govindapillai@intel.com>
Reviewed-by: Uma Shankar <uma.shankar@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241121112726.510220-3-vinod.govindapillai@intel.com
drivers/gpu/drm/i915/display/intel_atomic_plane.c
drivers/gpu/drm/i915/display/skl_watermark.c
drivers/gpu/drm/i915/display/skl_watermark.h

index d89630b2d5c19900133143647bd662ffbc163b4a..162bd20632cd11eacd8881ca8b2a4106a743f01b 100644 (file)
@@ -207,17 +207,6 @@ unsigned int intel_plane_data_rate(const struct intel_crtc_state *crtc_state,
                fb->format->cpp[color_plane];
 }
 
-static bool
-use_min_ddb(const struct intel_crtc_state *crtc_state,
-           struct intel_plane *plane)
-{
-       struct drm_i915_private *i915 = to_i915(plane->base.dev);
-
-       return DISPLAY_VER(i915) >= 13 &&
-              crtc_state->uapi.async_flip &&
-              plane->async_flip;
-}
-
 static unsigned int
 intel_plane_relative_data_rate(const struct intel_crtc_state *crtc_state,
                               const struct intel_plane_state *plane_state,
@@ -225,8 +214,8 @@ intel_plane_relative_data_rate(const struct intel_crtc_state *crtc_state,
 {
        struct intel_plane *plane = to_intel_plane(plane_state->uapi.plane);
        const struct drm_framebuffer *fb = plane_state->hw.fb;
-       int width, height;
        unsigned int rel_data_rate;
+       int width, height;
 
        if (plane->id == PLANE_CURSOR)
                return 0;
@@ -234,14 +223,6 @@ intel_plane_relative_data_rate(const struct intel_crtc_state *crtc_state,
        if (!plane_state->uapi.visible)
                return 0;
 
-       /*
-        * We calculate extra ddb based on ratio plane rate/total data rate
-        * in case, in some cases we should not allocate extra ddb for the plane,
-        * so do not count its data rate, if this is the case.
-        */
-       if (use_min_ddb(crtc_state, plane))
-               return 0;
-
        /*
         * Src coordinates are already rotated by 270 degrees for
         * the 90/270 degree plane rotation cases (to match the
@@ -256,7 +237,11 @@ intel_plane_relative_data_rate(const struct intel_crtc_state *crtc_state,
                height /= 2;
        }
 
-       rel_data_rate = width * height * fb->format->cpp[color_plane];
+       rel_data_rate =
+               skl_plane_relative_data_rate(crtc_state, plane, width, height,
+                                            fb->format->cpp[color_plane]);
+       if (!rel_data_rate)
+               return 0;
 
        return intel_adjusted_rate(&plane_state->uapi.src,
                                   &plane_state->uapi.dst,
index ea12476c0ff907272d248f70b31486c610e2b5a2..5176df50cfa08a2d0cdb03f22457afbc6b4ca608 100644 (file)
@@ -1383,6 +1383,22 @@ use_minimal_wm0_only(const struct intel_crtc_state *crtc_state,
               plane->async_flip;
 }
 
+unsigned int
+skl_plane_relative_data_rate(const struct intel_crtc_state *crtc_state,
+                            struct intel_plane *plane, int width, int height,
+                            int cpp)
+{
+       /*
+        * We calculate extra ddb based on ratio plane rate/total data rate
+        * in case, in some cases we should not allocate extra ddb for the plane,
+        * so do not count its data rate, if this is the case.
+        */
+       if (use_minimal_wm0_only(crtc_state, plane))
+               return 0;
+
+       return width * height * cpp;
+}
+
 static u64
 skl_total_relative_data_rate(const struct intel_crtc_state *crtc_state)
 {
index 35a1df7336e86cc3ded73171bdcc25f6c893557b..8659f89427f235a82ea489114ddcfa61ff7658c3 100644 (file)
@@ -18,6 +18,7 @@ struct intel_bw_state;
 struct intel_crtc;
 struct intel_crtc_state;
 struct intel_plane;
+struct intel_plane_state;
 struct skl_pipe_wm;
 struct skl_wm_level;
 
@@ -53,6 +54,9 @@ const struct skl_wm_level *skl_plane_wm_level(const struct skl_pipe_wm *pipe_wm,
                                              int level);
 const struct skl_wm_level *skl_plane_trans_wm(const struct skl_pipe_wm *pipe_wm,
                                              enum plane_id plane_id);
+unsigned int skl_plane_relative_data_rate(const struct intel_crtc_state *crtc_state,
+                                         struct intel_plane *plane, int width,
+                                         int height, int cpp);
 
 struct intel_dbuf_state {
        struct intel_global_state base;