aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/bcm27xx/patches-5.15/950-0905-drm-vc4-crtc-Use-an-union-to-store-the-page-flip-cal.patch
blob: ef92e7b2aa490aa4aacb8c0091886b6cda0943a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From 92f7f613ece28ecff26cbe5b5af20343bb624db1 Mon Sep 17 00:00:00 2001
From: Maxime Ripard <maxime@cerno.tech>
Date: Mon, 2 May 2022 10:20:56 +0200
Subject: [PATCH] drm/vc4: crtc: Use an union to store the page flip
 callback

We'll need to extend the vc4_async_flip_state structure to rely on
another callback implementation, so let's move the current one into a
union.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/gpu/drm/vc4/vc4_crtc.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)

--- a/drivers/gpu/drm/vc4/vc4_crtc.c
+++ b/drivers/gpu/drm/vc4/vc4_crtc.c
@@ -818,18 +818,18 @@ struct vc4_async_flip_state {
 	struct drm_framebuffer *old_fb;
 	struct drm_pending_vblank_event *event;
 
-	struct vc4_seqno_cb cb;
-	struct dma_fence_cb fence_cb;
+	union {
+		struct dma_fence_cb fence;
+		struct vc4_seqno_cb seqno;
+	} cb;
 };
 
 /* Called when the V3D execution for the BO being flipped to is done, so that
  * we can actually update the plane's address to point to it.
  */
 static void
-vc4_async_page_flip_complete(struct vc4_seqno_cb *cb)
+vc4_async_page_flip_complete(struct vc4_async_flip_state *flip_state)
 {
-	struct vc4_async_flip_state *flip_state =
-		container_of(cb, struct vc4_async_flip_state, cb);
 	struct drm_crtc *crtc = flip_state->crtc;
 	struct drm_device *dev = crtc->dev;
 	struct drm_plane *plane = crtc->primary;
@@ -865,13 +865,21 @@ vc4_async_page_flip_complete(struct vc4_
 	kfree(flip_state);
 }
 
+static void vc4_async_page_flip_seqno_complete(struct vc4_seqno_cb *cb)
+{
+	struct vc4_async_flip_state *flip_state =
+		container_of(cb, struct vc4_async_flip_state, cb.seqno);
+
+	vc4_async_page_flip_complete(flip_state);
+}
+
 static void vc4_async_page_flip_fence_complete(struct dma_fence *fence,
 					       struct dma_fence_cb *cb)
 {
 	struct vc4_async_flip_state *flip_state =
-		container_of(cb, struct vc4_async_flip_state, fence_cb);
+		container_of(cb, struct vc4_async_flip_state, cb.fence);
 
-	vc4_async_page_flip_complete(&flip_state->cb);
+	vc4_async_page_flip_complete(flip_state);
 	dma_fence_put(fence);
 }
 
@@ -886,14 +894,14 @@ static int vc4_async_set_fence_cb(struct
 	if (!vc4->is_vc5) {
 		struct vc4_bo *bo = to_vc4_bo(&cma_bo->base);
 
-		return vc4_queue_seqno_cb(dev, &flip_state->cb, bo->seqno,
-					  vc4_async_page_flip_complete);
+		return vc4_queue_seqno_cb(dev, &flip_state->cb.seqno, bo->seqno,
+					  vc4_async_page_flip_seqno_complete);
 	}
 
 	fence = dma_fence_get(dma_resv_excl_fence(cma_bo->base.resv));
-	if (dma_fence_add_callback(fence, &flip_state->fence_cb,
+	if (dma_fence_add_callback(fence, &flip_state->cb.fence,
 				   vc4_async_page_flip_fence_complete))
-		vc4_async_page_flip_fence_complete(fence, &flip_state->fence_cb);
+		vc4_async_page_flip_fence_complete(fence, &flip_state->cb.fence);
 
 	return 0;
 }