]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
drm/atomic: add drm_atomic_set_fence_for_plane()
authorGustavo Padovan <gustavo.padovan@collabora.co.uk>
Mon, 7 Nov 2016 10:03:30 +0000 (19:03 +0900)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 8 Nov 2016 10:22:54 +0000 (11:22 +0100)
This new function should be used by drivers when setting a implicit
fence for the plane. It abstracts the fact that the user might have
chosen explicit fencing instead.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1478513013-3221-1-git-send-email-gustavo@padovan.org
drivers/gpu/drm/drm_atomic.c
include/drm/drm_atomic.h
include/drm/drm_plane.h

index c32fb3c1d6f048e5f39876e7875336ea221dcbc3..5e73954551085608bd01e2a3df8e4a84bd153cfb 100644 (file)
@@ -1146,6 +1146,36 @@ drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
 }
 EXPORT_SYMBOL(drm_atomic_set_fb_for_plane);
 
+/**
+ * drm_atomic_set_fence_for_plane - set fence for plane
+ * @plane_state: atomic state object for the plane
+ * @fence: dma_fence to use for the plane
+ *
+ * Helper to setup the plane_state fence in case it is not set yet.
+ * By using this drivers doesn't need to worry if the user choose
+ * implicit or explicit fencing.
+ *
+ * This function will not set the fence to the state if it was set
+ * via explicit fencing interfaces on the atomic ioctl. It will
+ * all drope the reference to the fence as we not storing it
+ * anywhere.
+ *
+ * Otherwise, if plane_state->fence is not set this function we
+ * just set it with the received implict fence.
+ */
+void
+drm_atomic_set_fence_for_plane(struct drm_plane_state *plane_state,
+                              struct dma_fence *fence)
+{
+       if (plane_state->fence) {
+               dma_fence_put(fence);
+               return;
+       }
+
+       plane_state->fence = fence;
+}
+EXPORT_SYMBOL(drm_atomic_set_fence_for_plane);
+
 /**
  * drm_atomic_set_crtc_for_connector - set crtc for connector
  * @conn_state: atomic state object for the connector
index fc8af53b18aa5fba3422250dafcb60eb458cc539..2d1e9c944b5421c18a52cf839aae3bc75da157bf 100644 (file)
@@ -345,6 +345,8 @@ drm_atomic_set_crtc_for_plane(struct drm_plane_state *plane_state,
                              struct drm_crtc *crtc);
 void drm_atomic_set_fb_for_plane(struct drm_plane_state *plane_state,
                                 struct drm_framebuffer *fb);
+void drm_atomic_set_fence_for_plane(struct drm_plane_state *plane_state,
+                                   struct dma_fence *fence);
 int __must_check
 drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
                                  struct drm_crtc *crtc);
index c5e8a0df1623379b1bdb9818fee2afd29af0d93e..68f6d221a3da2994c119a6b982717233dc09411e 100644 (file)
@@ -59,7 +59,7 @@ struct drm_plane_state {
 
        struct drm_crtc *crtc;   /* do not write directly, use drm_atomic_set_crtc_for_plane() */
        struct drm_framebuffer *fb;  /* do not write directly, use drm_atomic_set_fb_for_plane() */
-       struct dma_fence *fence;
+       struct dma_fence *fence; /* do not write directly, use drm_atomic_set_fence_for_plane() */
 
        /* Signed dest location allows it to be partially off screen */
        int32_t crtc_x, crtc_y;