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
7 DSI0 is misbehaving and needs to action things on vblank to
9 Add a new hook to call across during vblank.
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
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(-)
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
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);
27 if (!drm_dev_enter(dev, &idx))
30 - CRTC_WRITE(PV_INTEN, 0);
31 + if (vc4_encoder->type != VC4_ENCODER_TYPE_DSI0)
32 + CRTC_WRITE(PV_INTEN, 0);
36 @@ -877,7 +880,14 @@ static void vc4_crtc_handle_page_flip(st
38 void vc4_crtc_handle_vblank(struct vc4_crtc *crtc)
40 + struct drm_encoder *encoder = vc4_get_crtc_encoder(&crtc->base, crtc->base.state);
41 + struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
43 crtc->t_vblank = ktime_get();
45 + if (vc4_encoder && vc4_encoder->vblank)
46 + vc4_encoder->vblank(encoder);
48 drm_crtc_handle_vblank(&crtc->base);
49 vc4_crtc_handle_page_flip(crtc);
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 {
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);
60 #define to_vc4_encoder(_encoder) \