OSDN Git Service

drm/i915: Simplify skl_max_scale()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 15 Oct 2019 19:30:28 +0000 (22:30 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 24 Oct 2019 18:22:25 +0000 (21:22 +0300)
Now that the planes declare their minimum cdclk requirements properly
we don't need to check the cdclk in skl_max_scale() anymore. Just check
against the maximum downscale ratio, and move the code next to it's
only caller.

v2: Add a comment explaining the HQ vs. not thing

Reviewed-by: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191015193035.25982-7-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/intel_display.c
drivers/gpu/drm/i915/display/intel_display.h
drivers/gpu/drm/i915/display/intel_sprite.c

index f696fa2..af9e210 100644 (file)
@@ -15145,44 +15145,6 @@ intel_cleanup_plane_fb(struct drm_plane *plane,
        intel_plane_unpin_fb(old_plane_state);
 }
 
-int
-skl_max_scale(const struct intel_crtc_state *crtc_state,
-             const struct drm_format_info *format)
-{
-       struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
-       struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
-       int max_scale;
-       int crtc_clock, max_dotclk, tmpclk1, tmpclk2;
-
-       if (!crtc_state->base.enable)
-               return DRM_PLANE_HELPER_NO_SCALING;
-
-       crtc_clock = crtc_state->base.adjusted_mode.crtc_clock;
-       max_dotclk = to_intel_atomic_state(crtc_state->base.state)->cdclk.logical.cdclk;
-
-       if (IS_GEMINILAKE(dev_priv) || INTEL_GEN(dev_priv) >= 10)
-               max_dotclk *= 2;
-
-       if (WARN_ON_ONCE(!crtc_clock || max_dotclk < crtc_clock))
-               return DRM_PLANE_HELPER_NO_SCALING;
-
-       /*
-        * skl max scale is lower of:
-        *    close to 3 but not 3, -1 is for that purpose
-        *            or
-        *    cdclk/crtc_clock
-        */
-       if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv) ||
-           !drm_format_info_is_yuv_semiplanar(format))
-               tmpclk1 = 0x30000 - 1;
-       else
-               tmpclk1 = 0x20000 - 1;
-       tmpclk2 = (1 << 8) * ((max_dotclk << 8) / crtc_clock);
-       max_scale = min(tmpclk1, tmpclk2);
-
-       return max_scale;
-}
-
 /**
  * intel_plane_destroy - destroy a plane
  * @plane: plane to destroy
index 7dcb176..ca7ca28 100644 (file)
@@ -563,8 +563,6 @@ void intel_crtc_arm_fifo_underrun(struct intel_crtc *crtc,
 
 u16 skl_scaler_calc_phase(int sub, int scale, bool chroma_center);
 int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state);
-int skl_max_scale(const struct intel_crtc_state *crtc_state,
-                 const struct drm_format_info *format);
 u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
                        const struct intel_plane_state *plane_state);
 u32 glk_plane_color_ctl_crtc(const struct intel_crtc_state *crtc_state);
index 469f79b..6b2eaf2 100644 (file)
@@ -2120,6 +2120,22 @@ static int skl_plane_check_nv12_rotation(const struct intel_plane_state *plane_s
        return 0;
 }
 
+static int skl_plane_max_scale(struct drm_i915_private *dev_priv,
+                              const struct drm_framebuffer *fb)
+{
+       /*
+        * We don't yet know the final source width nor
+        * whether we can use the HQ scaler mode. Assume
+        * the best case.
+        * FIXME need to properly check this later.
+        */
+       if (INTEL_GEN(dev_priv) >= 10 || IS_GEMINILAKE(dev_priv) ||
+           !drm_format_info_is_yuv_semiplanar(fb->format))
+               return 0x30000 - 1;
+       else
+               return 0x20000 - 1;
+}
+
 static int skl_plane_check(struct intel_crtc_state *crtc_state,
                           struct intel_plane_state *plane_state)
 {
@@ -2137,7 +2153,7 @@ static int skl_plane_check(struct intel_crtc_state *crtc_state,
        /* use scaler when colorkey is not required */
        if (!plane_state->ckey.flags && intel_fb_scalable(fb)) {
                min_scale = 1;
-               max_scale = skl_max_scale(crtc_state, fb->format);
+               max_scale = skl_plane_max_scale(dev_priv, fb);
        }
 
        ret = drm_atomic_helper_check_plane_state(&plane_state->base,