drm/i915: Refactor ilk_update_wm (v3)
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / drm / i915 / intel_pm.c
index b8c3e22061912967d67625537a8fae0a1f8b09dd..2f064de550abcd32652045437c089f5970714c31 100644 (file)
@@ -3148,18 +3148,9 @@ static void skl_compute_wm_global_parameters(struct drm_device *dev,
                                             struct intel_wm_config *config)
 {
        struct drm_crtc *crtc;
-       struct drm_plane *plane;
 
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
                config->num_pipes_active += to_intel_crtc(crtc)->active;
-
-       /* FIXME: I don't think we need those two global parameters on SKL */
-       list_for_each_entry(plane, &dev->mode_config.plane_list, head) {
-               struct intel_plane *intel_plane = to_intel_plane(plane);
-
-               config->sprites_enabled |= intel_plane->wm.enabled;
-               config->sprites_scaled |= intel_plane->wm.scaled;
-       }
 }
 
 static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
@@ -3682,51 +3673,45 @@ static void skl_update_wm(struct drm_crtc *crtc)
        dev_priv->wm.skl_hw = *results;
 }
 
-static void
-skl_update_sprite_wm(struct drm_plane *plane, struct drm_crtc *crtc,
-                    uint32_t sprite_width, uint32_t sprite_height,
-                    int pixel_size, bool enabled, bool scaled)
+static void ilk_program_watermarks(struct drm_i915_private *dev_priv)
 {
-       struct intel_plane *intel_plane = to_intel_plane(plane);
-       struct drm_framebuffer *fb = plane->state->fb;
+       struct drm_device *dev = dev_priv->dev;
+       struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;
+       struct ilk_wm_maximums max;
+       struct intel_wm_config config = {};
+       struct ilk_wm_values results = {};
+       enum intel_ddb_partitioning partitioning;
 
-       intel_plane->wm.enabled = enabled;
-       intel_plane->wm.scaled = scaled;
-       intel_plane->wm.horiz_pixels = sprite_width;
-       intel_plane->wm.vert_pixels = sprite_height;
-       intel_plane->wm.tiling = DRM_FORMAT_MOD_NONE;
+       ilk_compute_wm_config(dev, &config);
 
-       /* For planar: Bpp is for UV plane, y_Bpp is for Y plane */
-       intel_plane->wm.bytes_per_pixel =
-               (fb && fb->pixel_format == DRM_FORMAT_NV12) ?
-               drm_format_plane_cpp(plane->state->fb->pixel_format, 1) : pixel_size;
-       intel_plane->wm.y_bytes_per_pixel =
-               (fb && fb->pixel_format == DRM_FORMAT_NV12) ?
-               drm_format_plane_cpp(plane->state->fb->pixel_format, 0) : 0;
+       ilk_compute_wm_maximums(dev, 1, &config, INTEL_DDB_PART_1_2, &max);
+       ilk_wm_merge(dev, &config, &max, &lp_wm_1_2);
 
-       /*
-        * Framebuffer can be NULL on plane disable, but it does not
-        * matter for watermarks if we assume no tiling in that case.
-        */
-       if (fb)
-               intel_plane->wm.tiling = fb->modifier[0];
-       intel_plane->wm.rotation = plane->state->rotation;
+       /* 5/6 split only in single pipe config on IVB+ */
+       if (INTEL_INFO(dev)->gen >= 7 &&
+           config.num_pipes_active == 1 && config.sprites_enabled) {
+               ilk_compute_wm_maximums(dev, 1, &config, INTEL_DDB_PART_5_6, &max);
+               ilk_wm_merge(dev, &config, &max, &lp_wm_5_6);
+
+               best_lp_wm = ilk_find_best_result(dev, &lp_wm_1_2, &lp_wm_5_6);
+       } else {
+               best_lp_wm = &lp_wm_1_2;
+       }
+
+       partitioning = (best_lp_wm == &lp_wm_1_2) ?
+                      INTEL_DDB_PART_1_2 : INTEL_DDB_PART_5_6;
 
-       skl_update_wm(crtc);
+       ilk_compute_wm_results(dev, best_lp_wm, partitioning, &results);
+
+       ilk_write_wm_values(dev_priv, &results);
 }
 
 static void ilk_update_wm(struct drm_crtc *crtc)
 {
+       struct drm_i915_private *dev_priv = to_i915(crtc->dev);
        struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
        struct intel_crtc_state *cstate = to_intel_crtc_state(crtc->state);
-       struct drm_device *dev = crtc->dev;
-       struct drm_i915_private *dev_priv = dev->dev_private;
-       struct ilk_wm_maximums max;
-       struct ilk_wm_values results = {};
-       enum intel_ddb_partitioning partitioning;
        struct intel_pipe_wm pipe_wm = {};
-       struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;
-       struct intel_wm_config config = {};
 
        WARN_ON(cstate->base.active != intel_crtc->active);
 
@@ -3738,8 +3723,8 @@ static void ilk_update_wm(struct drm_crtc *crtc)
         * WaCxSRDisabledForSpriteScaling:ivb
         */
        if (cstate->disable_lp_wm) {
-               ilk_disable_lp_wm(dev);
-               intel_wait_for_vblank(dev, intel_crtc->pipe);
+               ilk_disable_lp_wm(crtc->dev);
+               intel_wait_for_vblank(crtc->dev, intel_crtc->pipe);
        }
 
        intel_compute_pipe_wm(cstate, &pipe_wm);
@@ -3749,28 +3734,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)
 
        intel_crtc->wm.active = pipe_wm;
 
-       ilk_compute_wm_config(dev, &config);
-
-       ilk_compute_wm_maximums(dev, 1, &config, INTEL_DDB_PART_1_2, &max);
-       ilk_wm_merge(dev, &config, &max, &lp_wm_1_2);
-
-       /* 5/6 split only in single pipe config on IVB+ */
-       if (INTEL_INFO(dev)->gen >= 7 &&
-           config.num_pipes_active == 1 && config.sprites_enabled) {
-               ilk_compute_wm_maximums(dev, 1, &config, INTEL_DDB_PART_5_6, &max);
-               ilk_wm_merge(dev, &config, &max, &lp_wm_5_6);
-
-               best_lp_wm = ilk_find_best_result(dev, &lp_wm_1_2, &lp_wm_5_6);
-       } else {
-               best_lp_wm = &lp_wm_1_2;
-       }
-
-       partitioning = (best_lp_wm == &lp_wm_1_2) ?
-                      INTEL_DDB_PART_1_2 : INTEL_DDB_PART_5_6;
-
-       ilk_compute_wm_results(dev, best_lp_wm, partitioning, &results);
-
-       ilk_write_wm_values(dev_priv, &results);
+       ilk_program_watermarks(dev_priv);
 }
 
 static void skl_pipe_wm_active_state(uint32_t val,
@@ -4150,21 +4114,6 @@ void intel_update_watermarks(struct drm_crtc *crtc)
                dev_priv->display.update_wm(crtc);
 }
 
-void intel_update_sprite_watermarks(struct drm_plane *plane,
-                                   struct drm_crtc *crtc,
-                                   uint32_t sprite_width,
-                                   uint32_t sprite_height,
-                                   int pixel_size,
-                                   bool enabled, bool scaled)
-{
-       struct drm_i915_private *dev_priv = plane->dev->dev_private;
-
-       if (dev_priv->display.update_sprite_wm)
-               dev_priv->display.update_sprite_wm(plane, crtc,
-                                                  sprite_width, sprite_height,
-                                                  pixel_size, enabled, scaled);
-}
-
 /**
  * Lock protecting IPS related data structures
  */
@@ -7089,7 +7038,6 @@ void intel_init_pm(struct drm_device *dev)
                        dev_priv->display.init_clock_gating =
                                skl_init_clock_gating;
                dev_priv->display.update_wm = skl_update_wm;
-               dev_priv->display.update_sprite_wm = skl_update_sprite_wm;
        } else if (HAS_PCH_SPLIT(dev)) {
                ilk_setup_wm_latency(dev);