drm/i915: clean up atomic plane check functions, v2.
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Mon, 15 Jun 2015 10:33:46 +0000 (12:33 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Mon, 22 Jun 2015 12:20:48 +0000 (14:20 +0200)
By passing crtc_state to the check_plane functions a lot of duplicated
code can be removed. There are still some transitional helper calls,
they will be removed later.

Changes since v1:
- Revert state->visible changes.
- Use plane->state->crtc instead of plane->crtc.
- Use drm_atomic_get_existing_crtc_state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Tested-by(IVB): Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/intel_atomic_plane.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/i915/intel_sprite.c

index aa2128369a0acf364867f1e8235cac023fd1d0d3..91d53768df9d53e180341ccc358882956cf6805b 100644 (file)
@@ -116,7 +116,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
        struct intel_plane_state *intel_state = to_intel_plane_state(state);
        int ret;
 
-       crtc = crtc ? crtc : plane->crtc;
+       crtc = crtc ? crtc : plane->state->crtc;
        intel_crtc = to_intel_crtc(crtc);
 
        /*
@@ -131,10 +131,13 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
        /* FIXME: temporary hack necessary while we still use the plane update
         * helper. */
        if (state->state) {
-               crtc_state =
-                       intel_atomic_get_crtc_state(state->state, intel_crtc);
-               if (IS_ERR(crtc_state))
-                       return PTR_ERR(crtc_state);
+               struct drm_crtc_state *drm_crtc_state =
+                       drm_atomic_get_existing_crtc_state(state->state, crtc);
+
+               if (WARN_ON(!drm_crtc_state))
+                       return -EINVAL;
+
+               crtc_state = to_intel_crtc_state(drm_crtc_state);
        } else {
                crtc_state = intel_crtc->config;
        }
@@ -185,7 +188,8 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
                }
        }
 
-       ret = intel_plane->check_plane(plane, intel_state);
+       intel_state->visible = false;
+       ret = intel_plane->check_plane(plane, crtc_state, intel_state);
        if (ret || !state->state)
                return ret;
 
index 2f50c73653d956abdb153d2788069931008c514a..d7ad8449a9e14207f0ebe9db032f12e416799248 100644 (file)
@@ -13716,36 +13716,25 @@ skl_max_scale(struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state
 
 static int
 intel_check_primary_plane(struct drm_plane *plane,
+                         struct intel_crtc_state *crtc_state,
                          struct intel_plane_state *state)
 {
-       struct drm_device *dev = plane->dev;
        struct drm_crtc *crtc = state->base.crtc;
-       struct intel_crtc *intel_crtc;
-       struct intel_crtc_state *crtc_state;
        struct drm_framebuffer *fb = state->base.fb;
-       struct drm_rect *dest = &state->dst;
-       struct drm_rect *src = &state->src;
-       const struct drm_rect *clip = &state->clip;
-       bool can_position = false;
-       int max_scale = DRM_PLANE_HELPER_NO_SCALING;
        int min_scale = DRM_PLANE_HELPER_NO_SCALING;
+       int max_scale = DRM_PLANE_HELPER_NO_SCALING;
+       bool can_position = false;
 
-       crtc = crtc ? crtc : plane->crtc;
-       intel_crtc = to_intel_crtc(crtc);
-       crtc_state = state->base.state ?
-               intel_atomic_get_crtc_state(state->base.state, intel_crtc) : NULL;
-
-       if (INTEL_INFO(dev)->gen >= 9) {
-               /* use scaler when colorkey is not required */
-               if (to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
-                       min_scale = 1;
-                       max_scale = skl_max_scale(intel_crtc, crtc_state);
-               }
+       /* use scaler when colorkey is not required */
+       if (INTEL_INFO(plane->dev)->gen >= 9 &&
+           to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
+               min_scale = 1;
+               max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state);
                can_position = true;
        }
 
-       return drm_plane_helper_check_update(plane, crtc, fb,
-                                            src, dest, clip,
+       return drm_plane_helper_check_update(plane, crtc, fb, &state->src,
+                                            &state->dst, &state->clip,
                                             min_scale, max_scale,
                                             can_position, true,
                                             &state->visible);
@@ -13984,24 +13973,17 @@ void intel_create_rotation_property(struct drm_device *dev, struct intel_plane *
 
 static int
 intel_check_cursor_plane(struct drm_plane *plane,
+                        struct intel_crtc_state *crtc_state,
                         struct intel_plane_state *state)
 {
-       struct drm_crtc *crtc = state->base.crtc;
-       struct drm_device *dev = plane->dev;
+       struct drm_crtc *crtc = crtc_state->base.crtc;
        struct drm_framebuffer *fb = state->base.fb;
-       struct drm_rect *dest = &state->dst;
-       struct drm_rect *src = &state->src;
-       const struct drm_rect *clip = &state->clip;
        struct drm_i915_gem_object *obj = intel_fb_obj(fb);
-       struct intel_crtc *intel_crtc;
        unsigned stride;
        int ret;
 
-       crtc = crtc ? crtc : plane->crtc;
-       intel_crtc = to_intel_crtc(crtc);
-
-       ret = drm_plane_helper_check_update(plane, crtc, fb,
-                                           src, dest, clip,
+       ret = drm_plane_helper_check_update(plane, crtc, fb, &state->src,
+                                           &state->dst, &state->clip,
                                            DRM_PLANE_HELPER_NO_SCALING,
                                            DRM_PLANE_HELPER_NO_SCALING,
                                            true, true, &state->visible);
@@ -14013,7 +13995,7 @@ intel_check_cursor_plane(struct drm_plane *plane,
                return 0;
 
        /* Check for which cursor types we support */
-       if (!cursor_size_ok(dev, state->base.crtc_w, state->base.crtc_h)) {
+       if (!cursor_size_ok(plane->dev, state->base.crtc_w, state->base.crtc_h)) {
                DRM_DEBUG("Cursor dimension %dx%d not supported\n",
                          state->base.crtc_w, state->base.crtc_h);
                return -EINVAL;
index 198cb20d9193b008f454e85fdbb93c5b12adf7fd..0145e0878be5400162f4271568068832b298ae46 100644 (file)
@@ -613,6 +613,7 @@ struct intel_plane {
        void (*disable_plane)(struct drm_plane *plane,
                              struct drm_crtc *crtc, bool force);
        int (*check_plane)(struct drm_plane *plane,
+                          struct intel_crtc_state *crtc_state,
                           struct intel_plane_state *state);
        void (*commit_plane)(struct drm_plane *plane,
                             struct intel_plane_state *state);
index 48353b34d0f52eac3aae44eb028255008ffb36a3..cc18605ab7a8f4123103f7aaf79b25a3fc3ab80f 100644 (file)
@@ -742,11 +742,12 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc, bool force)
 
 static int
 intel_check_sprite_plane(struct drm_plane *plane,
+                        struct intel_crtc_state *crtc_state,
                         struct intel_plane_state *state)
 {
        struct drm_device *dev = plane->dev;
-       struct intel_crtc *intel_crtc = to_intel_crtc(state->base.crtc);
-       struct intel_crtc_state *crtc_state;
+       struct drm_crtc *crtc = state->base.crtc;
+       struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
        struct intel_plane *intel_plane = to_intel_plane(plane);
        struct drm_framebuffer *fb = state->base.fb;
        int crtc_x, crtc_y;
@@ -760,10 +761,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
        bool can_scale;
        int pixel_size;
 
-       intel_crtc = intel_crtc ? intel_crtc : to_intel_crtc(plane->crtc);
-       crtc_state = state->base.state ?
-               intel_atomic_get_crtc_state(state->base.state, intel_crtc) : NULL;
-
        if (!fb) {
                state->visible = false;
                return 0;