drm: Pass in new and old plane state to prepare_fb and cleanup_fb
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Tue, 3 Mar 2015 14:22:31 +0000 (14:22 +0000)
committerDave Airlie <airlied@redhat.com>
Wed, 4 Mar 2015 23:49:02 +0000 (09:49 +1000)
Use cases like rotation require these hooks to have some context so they
know how to prepare and cleanup the frame buffer correctly.

For i915 specifically, object backing pages need to be mapped differently
for different rotation modes and the driver needs to know which mapping to
instantiate and which to tear down when transitioning between them.

v2: Made passed in states const. (Daniel Vetter)

[airlied: add mdp5 and atmel fixups]
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Rob Clark <robdclark@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_plane_helper.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_drv.h
drivers/gpu/drm/msm/mdp/mdp4/mdp4_plane.c
drivers/gpu/drm/msm/mdp/mdp5/mdp5_plane.c
drivers/gpu/drm/tegra/dc.c
include/drm/drm_plane_helper.h

index dbf97d999d4075d9cc9890334fc3f29397512d2f..be9fa8220499cf786e27a7ddfb449f2e94b322f2 100644 (file)
@@ -712,7 +712,8 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
 }
 
 static int atmel_hlcdc_plane_prepare_fb(struct drm_plane *p,
-                                       struct drm_framebuffer *fb)
+                                       struct drm_framebuffer *fb,
+                                       const struct drm_plane_state *new_state)
 {
        struct atmel_hlcdc_plane *plane = drm_plane_to_atmel_hlcdc_plane(p);
 
index 28aa875105510b788b0b1f78d78aac916ee70913..7715c40d4e742746642376d121c1d42a743a72ac 100644 (file)
@@ -1116,6 +1116,7 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
        for (i = 0; i < nplanes; i++) {
                struct drm_plane_helper_funcs *funcs;
                struct drm_plane *plane = state->planes[i];
+               struct drm_plane_state *plane_state = state->plane_states[i];
                struct drm_framebuffer *fb;
 
                if (!plane)
@@ -1123,10 +1124,10 @@ int drm_atomic_helper_prepare_planes(struct drm_device *dev,
 
                funcs = plane->helper_private;
 
-               fb = state->plane_states[i]->fb;
+               fb = plane_state->fb;
 
                if (fb && funcs->prepare_fb) {
-                       ret = funcs->prepare_fb(plane, fb);
+                       ret = funcs->prepare_fb(plane, fb, plane_state);
                        if (ret)
                                goto fail;
                }
@@ -1138,6 +1139,7 @@ fail:
        for (i--; i >= 0; i--) {
                struct drm_plane_helper_funcs *funcs;
                struct drm_plane *plane = state->planes[i];
+               struct drm_plane_state *plane_state = state->plane_states[i];
                struct drm_framebuffer *fb;
 
                if (!plane)
@@ -1148,7 +1150,7 @@ fail:
                fb = state->plane_states[i]->fb;
 
                if (fb && funcs->cleanup_fb)
-                       funcs->cleanup_fb(plane, fb);
+                       funcs->cleanup_fb(plane, fb, plane_state);
 
        }
 
@@ -1254,6 +1256,7 @@ void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
        for (i = 0; i < nplanes; i++) {
                struct drm_plane_helper_funcs *funcs;
                struct drm_plane *plane = old_state->planes[i];
+               struct drm_plane_state *plane_state = old_state->plane_states[i];
                struct drm_framebuffer *old_fb;
 
                if (!plane)
@@ -1261,10 +1264,10 @@ void drm_atomic_helper_cleanup_planes(struct drm_device *dev,
 
                funcs = plane->helper_private;
 
-               old_fb = old_state->plane_states[i]->fb;
+               old_fb = plane_state->fb;
 
                if (old_fb && funcs->cleanup_fb)
-                       funcs->cleanup_fb(plane, old_fb);
+                       funcs->cleanup_fb(plane, old_fb, plane_state);
        }
 }
 EXPORT_SYMBOL(drm_atomic_helper_cleanup_planes);
index 5ba5792bfdbabd920b5678740a1930f1d90ace2b..813a06627eb33ea3908d225271d6c72ebba5c973 100644 (file)
@@ -437,7 +437,8 @@ int drm_plane_helper_commit(struct drm_plane *plane,
 
        if (plane_funcs->prepare_fb && plane_state->fb &&
            plane_state->fb != old_fb) {
-               ret = plane_funcs->prepare_fb(plane, plane_state->fb);
+               ret = plane_funcs->prepare_fb(plane, plane_state->fb,
+                                             plane_state);
                if (ret)
                        goto out;
        }
@@ -487,7 +488,7 @@ int drm_plane_helper_commit(struct drm_plane *plane,
        }
 
        if (plane_funcs->cleanup_fb && old_fb)
-               plane_funcs->cleanup_fb(plane, old_fb);
+               plane_funcs->cleanup_fb(plane, old_fb, plane_state);
 out:
        if (plane_state) {
                if (plane->funcs->atomic_destroy_state)
index 3b0fe9f1f3c9e6b5e00e3782c2fa96f6271d0e47..c234af0379fca4edb2c9a56f92a3b7af5498e7cf 100644 (file)
@@ -11776,7 +11776,8 @@ static void intel_shared_dpll_init(struct drm_device *dev)
  */
 int
 intel_prepare_plane_fb(struct drm_plane *plane,
-                      struct drm_framebuffer *fb)
+                      struct drm_framebuffer *fb,
+                      const struct drm_plane_state *new_state)
 {
        struct drm_device *dev = plane->dev;
        struct intel_plane *intel_plane = to_intel_plane(plane);
@@ -11830,7 +11831,8 @@ intel_prepare_plane_fb(struct drm_plane *plane,
  */
 void
 intel_cleanup_plane_fb(struct drm_plane *plane,
-                      struct drm_framebuffer *fb)
+                      struct drm_framebuffer *fb,
+                      const struct drm_plane_state *old_state)
 {
        struct drm_device *dev = plane->dev;
        struct drm_i915_gem_object *obj = intel_fb_obj(fb);
index 1de8e20474d74d69738abab79e9cfe7775ab0779..58d11a8066d4ea3f1c38d031283b3dd9840f338a 100644 (file)
@@ -943,9 +943,11 @@ void intel_finish_page_flip(struct drm_device *dev, int pipe);
 void intel_finish_page_flip_plane(struct drm_device *dev, int plane);
 void intel_check_page_flip(struct drm_device *dev, int pipe);
 int intel_prepare_plane_fb(struct drm_plane *plane,
-                          struct drm_framebuffer *fb);
+                          struct drm_framebuffer *fb,
+                          const struct drm_plane_state *new_state);
 void intel_cleanup_plane_fb(struct drm_plane *plane,
-                           struct drm_framebuffer *fb);
+                           struct drm_framebuffer *fb,
+                           const struct drm_plane_state *old_state);
 int intel_plane_atomic_get_property(struct drm_plane *plane,
                                    const struct drm_plane_state *state,
                                    struct drm_property *property,
index cde25009203aa56e015da468a2c4a1b22bd43535..dbc068988377fee6a274ec4b623cc8ffaeddbb3e 100644 (file)
@@ -83,7 +83,8 @@ static const struct drm_plane_funcs mdp4_plane_funcs = {
 };
 
 static int mdp4_plane_prepare_fb(struct drm_plane *plane,
-               struct drm_framebuffer *fb)
+               struct drm_framebuffer *fb,
+               const struct drm_plane_state *new_state)
 {
        struct mdp4_plane *mdp4_plane = to_mdp4_plane(plane);
        struct mdp4_kms *mdp4_kms = get_kms(plane);
@@ -93,7 +94,8 @@ static int mdp4_plane_prepare_fb(struct drm_plane *plane,
 }
 
 static void mdp4_plane_cleanup_fb(struct drm_plane *plane,
-               struct drm_framebuffer *fb)
+               struct drm_framebuffer *fb,
+               const struct drm_plane_state *old_state)
 {
        struct mdp4_plane *mdp4_plane = to_mdp4_plane(plane);
        struct mdp4_kms *mdp4_kms = get_kms(plane);
index 05cf9ab2a87691fa2bf403ff6f48c66c921a239f..6bd48e2462833e03e63a2d2967cda30db2cce8da 100644 (file)
@@ -156,7 +156,8 @@ static const struct drm_plane_funcs mdp5_plane_funcs = {
 };
 
 static int mdp5_plane_prepare_fb(struct drm_plane *plane,
-               struct drm_framebuffer *fb)
+               struct drm_framebuffer *fb,
+               const struct drm_plane_state *new_state)
 {
        struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
        struct mdp5_kms *mdp5_kms = get_kms(plane);
@@ -166,7 +167,8 @@ static int mdp5_plane_prepare_fb(struct drm_plane *plane,
 }
 
 static void mdp5_plane_cleanup_fb(struct drm_plane *plane,
-               struct drm_framebuffer *fb)
+               struct drm_framebuffer *fb,
+               const struct drm_plane_state *old_state)
 {
        struct mdp5_plane *mdp5_plane = to_mdp5_plane(plane);
        struct mdp5_kms *mdp5_kms = get_kms(plane);
index 3aaa84ae26811fb8c731a89e76b91297b1ff3bf3..bc3e85186b88078119f30a136dd0000c2c0204e9 100644 (file)
@@ -472,13 +472,15 @@ static const struct drm_plane_funcs tegra_primary_plane_funcs = {
 };
 
 static int tegra_plane_prepare_fb(struct drm_plane *plane,
-                                 struct drm_framebuffer *fb)
+                                 struct drm_framebuffer *fb,
+                                 const struct drm_plane_state *new_state)
 {
        return 0;
 }
 
 static void tegra_plane_cleanup_fb(struct drm_plane *plane,
-                                  struct drm_framebuffer *fb)
+                                  struct drm_framebuffer *fb,
+                                  const struct drm_plane_state *old_fb)
 {
 }
 
index 31c11d36fae6e1ca285f56111bcc8ff93770db51..72ddab02ebd920a4773fa20cb3df4c8252e15b01 100644 (file)
@@ -59,9 +59,11 @@ extern int drm_crtc_init(struct drm_device *dev,
  */
 struct drm_plane_helper_funcs {
        int (*prepare_fb)(struct drm_plane *plane,
-                         struct drm_framebuffer *fb);
+                         struct drm_framebuffer *fb,
+                         const struct drm_plane_state *new_state);
        void (*cleanup_fb)(struct drm_plane *plane,
-                          struct drm_framebuffer *fb);
+                          struct drm_framebuffer *fb,
+                          const struct drm_plane_state *old_state);
 
        int (*atomic_check)(struct drm_plane *plane,
                            struct drm_plane_state *state);