In mdp5_plane_atomic_check, we get crtc_state from drm_plane_state.

Later, for cursor planes, we'll populate the update_plane() func that
takes a fast asynchronous path to implement cursor movements. There, we
would need to call a similar atomic_check func to validate the plane
state, but crtc_state would need to be derived differently.

Refactor mdp5_plane_atomic_check to mdp5_plane_atomic_check_with_state
such that the latter takes crtc_state as an argument.

This is similar to what the intel driver has done for async cursor
updates.

Signed-off-by: Archit Taneja <arch...@codeaurora.org>
---
 drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c | 32 +++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c 
b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
index 7409e959d810..504201b710d9 100644
--- a/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
+++ b/drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
@@ -270,17 +270,16 @@ static void mdp5_plane_cleanup_fb(struct drm_plane *plane,
 }
 
 #define FRAC_16_16(mult, div)    (((mult) << 16) / (div))
-static int mdp5_plane_atomic_check(struct drm_plane *plane,
-               struct drm_plane_state *state)
+static int mdp5_plane_atomic_check_with_state(struct drm_crtc_state 
*crtc_state,
+                                             struct drm_plane_state *state)
 {
        struct mdp5_plane_state *mdp5_state = to_mdp5_plane_state(state);
+       struct drm_plane *plane = state->plane;
        struct drm_plane_state *old_state = plane->state;
        struct mdp5_cfg *config = mdp5_cfg_get_config(get_kms(plane)->cfg);
        bool new_hwpipe = false;
        uint32_t max_width, max_height;
        uint32_t caps = 0;
-       struct drm_crtc *crtc;
-       struct drm_crtc_state *crtc_state;
        struct drm_rect clip;
        int min_scale, max_scale;
        int ret;
@@ -288,10 +287,6 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
        DBG("%s: check (%d -> %d)", plane->name,
                        plane_enabled(old_state), plane_enabled(state));
 
-       crtc = state->crtc ? state->crtc : plane->state->crtc;
-       if (!crtc)
-               return 0;
-
        max_width = config->hw->lm.max_width << 16;
        max_height = config->hw->lm.max_height << 16;
 
@@ -303,10 +298,6 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
                return -ERANGE;
        }
 
-       crtc_state = drm_atomic_get_existing_crtc_state(state->state, crtc);
-       if (WARN_ON(!crtc_state))
-               return -EINVAL;
-
        clip.x1 = 0;
        clip.y1 = 0;
        clip.x2 = crtc_state->adjusted_mode.hdisplay;
@@ -382,6 +373,23 @@ static int mdp5_plane_atomic_check(struct drm_plane *plane,
        return 0;
 }
 
+static int mdp5_plane_atomic_check(struct drm_plane *plane,
+                                  struct drm_plane_state *state)
+{
+       struct drm_crtc *crtc;
+       struct drm_crtc_state *crtc_state;
+
+       crtc = state->crtc ? state->crtc : plane->state->crtc;
+       if (!crtc)
+               return 0;
+
+       crtc_state = drm_atomic_get_existing_crtc_state(state->state, crtc);
+       if (WARN_ON(!crtc_state))
+               return -EINVAL;
+
+       return mdp5_plane_atomic_check_with_state(crtc_state, state);
+}
+
 static void mdp5_plane_atomic_update(struct drm_plane *plane,
                                     struct drm_plane_state *old_state)
 {
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to