8137b10592d388d9e2821efd27420c3bc1c1ce33
[openwrt/staging/wigyori.git] /
1 From 63c0bcc4b7474c220c47a661526744edac18e75a Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 5 Apr 2024 17:34:09 +0100
4 Subject: [PATCH 1065/1085] drm/vc4: Add option to call from crtc to encoder on
5 vblank
6
7 DSI0 is misbehaving and needs to action things on vblank to
8 work around it.
9 Add a new hook to call across during vblank.
10
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
12 ---
13 drivers/gpu/drm/vc4/vc4_crtc.c | 12 +++++++++++-
14 drivers/gpu/drm/vc4/vc4_drv.h | 1 +
15 2 files changed, 12 insertions(+), 1 deletion(-)
16
17 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
18 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
19 @@ -827,12 +827,15 @@ static void vc4_disable_vblank(struct dr
20 {
21 struct vc4_crtc *vc4_crtc = to_vc4_crtc(crtc);
22 struct drm_device *dev = crtc->dev;
23 + struct drm_encoder *encoder = vc4_get_crtc_encoder(crtc, crtc->state);
24 + struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
25 int idx;
26
27 if (!drm_dev_enter(dev, &idx))
28 return;
29
30 - CRTC_WRITE(PV_INTEN, 0);
31 + if (vc4_encoder->type != VC4_ENCODER_TYPE_DSI0)
32 + CRTC_WRITE(PV_INTEN, 0);
33
34 drm_dev_exit(idx);
35 }
36 @@ -877,7 +880,14 @@ static void vc4_crtc_handle_page_flip(st
37
38 void vc4_crtc_handle_vblank(struct vc4_crtc *crtc)
39 {
40 + struct drm_encoder *encoder = vc4_get_crtc_encoder(&crtc->base, crtc->base.state);
41 + struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
42 +
43 crtc->t_vblank = ktime_get();
44 +
45 + if (vc4_encoder && vc4_encoder->vblank)
46 + vc4_encoder->vblank(encoder);
47 +
48 drm_crtc_handle_vblank(&crtc->base);
49 vc4_crtc_handle_page_flip(crtc);
50 }
51 --- a/drivers/gpu/drm/vc4/vc4_drv.h
52 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
53 @@ -503,6 +503,7 @@ struct vc4_encoder {
54
55 void (*post_crtc_disable)(struct drm_encoder *encoder, struct drm_atomic_state *state);
56 void (*post_crtc_powerdown)(struct drm_encoder *encoder, struct drm_atomic_state *state);
57 + void (*vblank)(struct drm_encoder *encoder);
58 };
59
60 #define to_vc4_encoder(_encoder) \