bcm27xx: add kernel 5.10 support
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.10 / 950-0412-drm-vc4-Pass-the-atomic-state-to-encoder-hooks.patch
1 From a7a8569adc035cf74a3b82d00ba266ac9b249a15 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Tue, 15 Dec 2020 16:42:36 +0100
4 Subject: [PATCH] drm/vc4: Pass the atomic state to encoder hooks
5
6 We'll need to access the connector state in our encoder setup, so let's
7 just pass the whole DRM state to our private encoder hooks.
8
9 Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
10 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
11 ---
12 drivers/gpu/drm/vc4/vc4_crtc.c | 18 ++++++++++--------
13 drivers/gpu/drm/vc4/vc4_drv.h | 10 +++++-----
14 drivers/gpu/drm/vc4/vc4_hdmi.c | 15 ++++++++++-----
15 3 files changed, 25 insertions(+), 18 deletions(-)
16
17 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
18 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
19 @@ -420,7 +420,9 @@ static void require_hvs_enabled(struct d
20 SCALER_DISPCTRL_ENABLE);
21 }
22
23 -static int vc4_crtc_disable(struct drm_crtc *crtc, unsigned int channel)
24 +static int vc4_crtc_disable(struct drm_crtc *crtc,
25 + struct drm_atomic_state *state,
26 + unsigned int channel)
27 {
28 struct drm_encoder *encoder = vc4_get_crtc_encoder(crtc);
29 struct vc4_encoder *vc4_encoder = to_vc4_encoder(encoder);
30 @@ -452,13 +454,13 @@ static int vc4_crtc_disable(struct drm_c
31 mdelay(20);
32
33 if (vc4_encoder && vc4_encoder->post_crtc_disable)
34 - vc4_encoder->post_crtc_disable(encoder);
35 + vc4_encoder->post_crtc_disable(encoder, state);
36
37 vc4_crtc_pixelvalve_reset(crtc);
38 vc4_hvs_stop_channel(dev, channel);
39
40 if (vc4_encoder && vc4_encoder->post_crtc_powerdown)
41 - vc4_encoder->post_crtc_powerdown(encoder);
42 + vc4_encoder->post_crtc_powerdown(encoder, state);
43
44 return 0;
45 }
46 @@ -485,7 +487,7 @@ int vc4_crtc_disable_at_boot(struct drm_
47 if (channel < 0)
48 return 0;
49
50 - return vc4_crtc_disable(crtc, channel);
51 + return vc4_crtc_disable(crtc, NULL, channel);
52 }
53
54 static void vc4_crtc_atomic_disable(struct drm_crtc *crtc,
55 @@ -501,7 +503,7 @@ static void vc4_crtc_atomic_disable(stru
56 /* Disable vblank irq handling before crtc is disabled. */
57 drm_crtc_vblank_off(crtc);
58
59 - vc4_crtc_disable(crtc, old_vc4_state->assigned_channel);
60 + vc4_crtc_disable(crtc, state, old_vc4_state->assigned_channel);
61
62 /*
63 * Make sure we issue a vblank event after disabling the CRTC if
64 @@ -535,14 +537,14 @@ static void vc4_crtc_atomic_enable(struc
65 vc4_hvs_atomic_enable(crtc, state);
66
67 if (vc4_encoder->pre_crtc_configure)
68 - vc4_encoder->pre_crtc_configure(encoder);
69 + vc4_encoder->pre_crtc_configure(encoder, state);
70
71 vc4_crtc_config_pv(crtc);
72
73 CRTC_WRITE(PV_CONTROL, CRTC_READ(PV_CONTROL) | PV_CONTROL_EN);
74
75 if (vc4_encoder->pre_crtc_enable)
76 - vc4_encoder->pre_crtc_enable(encoder);
77 + vc4_encoder->pre_crtc_enable(encoder, state);
78
79 /* When feeding the transposer block the pixelvalve is unneeded and
80 * should not be enabled.
81 @@ -551,7 +553,7 @@ static void vc4_crtc_atomic_enable(struc
82 CRTC_READ(PV_V_CONTROL) | PV_VCONTROL_VIDEN);
83
84 if (vc4_encoder->post_crtc_enable)
85 - vc4_encoder->post_crtc_enable(encoder);
86 + vc4_encoder->post_crtc_enable(encoder, state);
87 }
88
89 static enum drm_mode_status vc4_crtc_mode_valid(struct drm_crtc *crtc,
90 --- a/drivers/gpu/drm/vc4/vc4_drv.h
91 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
92 @@ -449,12 +449,12 @@ struct vc4_encoder {
93 enum vc4_encoder_type type;
94 u32 clock_select;
95
96 - void (*pre_crtc_configure)(struct drm_encoder *encoder);
97 - void (*pre_crtc_enable)(struct drm_encoder *encoder);
98 - void (*post_crtc_enable)(struct drm_encoder *encoder);
99 + void (*pre_crtc_configure)(struct drm_encoder *encoder, struct drm_atomic_state *state);
100 + void (*pre_crtc_enable)(struct drm_encoder *encoder, struct drm_atomic_state *state);
101 + void (*post_crtc_enable)(struct drm_encoder *encoder, struct drm_atomic_state *state);
102
103 - void (*post_crtc_disable)(struct drm_encoder *encoder);
104 - void (*post_crtc_powerdown)(struct drm_encoder *encoder);
105 + void (*post_crtc_disable)(struct drm_encoder *encoder, struct drm_atomic_state *state);
106 + void (*post_crtc_powerdown)(struct drm_encoder *encoder, struct drm_atomic_state *state);
107 };
108
109 static inline struct vc4_encoder *
110 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
111 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
112 @@ -411,7 +411,8 @@ static void vc4_hdmi_set_infoframes(stru
113 vc4_hdmi_set_audio_infoframe(encoder);
114 }
115
116 -static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder)
117 +static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder,
118 + struct drm_atomic_state *state)
119 {
120 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
121
122 @@ -424,7 +425,8 @@ static void vc4_hdmi_encoder_post_crtc_d
123 HDMI_READ(HDMI_VID_CTL) | VC4_HD_VID_CTL_BLANKPIX);
124 }
125
126 -static void vc4_hdmi_encoder_post_crtc_powerdown(struct drm_encoder *encoder)
127 +static void vc4_hdmi_encoder_post_crtc_powerdown(struct drm_encoder *encoder,
128 + struct drm_atomic_state *state)
129 {
130 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
131 int ret;
132 @@ -637,7 +639,8 @@ static void vc4_hdmi_recenter_fifo(struc
133 "VC4_HDMI_FIFO_CTL_RECENTER_DONE");
134 }
135
136 -static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder)
137 +static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder,
138 + struct drm_atomic_state *state)
139 {
140 struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
141 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);
142 @@ -719,7 +722,8 @@ static void vc4_hdmi_encoder_pre_crtc_co
143 vc4_hdmi->variant->set_timings(vc4_hdmi, mode);
144 }
145
146 -static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder)
147 +static void vc4_hdmi_encoder_pre_crtc_enable(struct drm_encoder *encoder,
148 + struct drm_atomic_state *state)
149 {
150 struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
151 struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
152 @@ -741,7 +745,8 @@ static void vc4_hdmi_encoder_pre_crtc_en
153 HDMI_WRITE(HDMI_FIFO_CTL, VC4_HDMI_FIFO_CTL_MASTER_SLAVE_N);
154 }
155
156 -static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder)
157 +static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,
158 + struct drm_atomic_state *state)
159 {
160 struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode;
161 struct vc4_hdmi *vc4_hdmi = encoder_to_vc4_hdmi(encoder);