bcm27xx: update patches from RPi foundation
[openwrt/staging/ldir.git] / target / linux / bcm27xx / patches-5.4 / 950-0575-drm-vc4-hdmi-Rename-hdmi-to-vc4_hdmi.patch
1 From 02b7a6ed6b9fc110dd26598d26c31c0837af6184 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Mon, 6 Jan 2020 18:07:05 +0100
4 Subject: [PATCH] drm/vc4: hdmi: Rename hdmi to vc4_hdmi
5
6 The driver isn't consistent with the name given to the vc4_hdmi
7 structure pointer in its functions. Make sure to use a consistent name.
8
9 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
10 ---
11 drivers/gpu/drm/vc4/vc4_hdmi.c | 271 +++++++++++++++++----------------
12 1 file changed, 136 insertions(+), 135 deletions(-)
13
14 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
15 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
16 @@ -108,11 +108,11 @@ static const struct debugfs_reg32 hd_reg
17 static int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused)
18 {
19 struct drm_info_node *node = (struct drm_info_node *)m->private;
20 - struct vc4_hdmi *hdmi = node->info_ent->data;
21 + struct vc4_hdmi *vc4_hdmi = node->info_ent->data;
22 struct drm_printer p = drm_seq_file_printer(m);
23
24 - drm_print_regset32(&p, &hdmi->hdmi_regset);
25 - drm_print_regset32(&p, &hdmi->hd_regset);
26 + drm_print_regset32(&p, &vc4_hdmi->hdmi_regset);
27 + drm_print_regset32(&p, &vc4_hdmi->hd_regset);
28
29 return 0;
30 }
31 @@ -297,8 +297,8 @@ static void vc4_hdmi_set_avi_infoframe(s
32 {
33 struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
34 struct vc4_dev *vc4 = encoder->dev->dev_private;
35 - struct vc4_hdmi *hdmi = vc4->hdmi;
36 - struct drm_connector *connector = &hdmi->connector.base;
37 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
38 + struct drm_connector *connector = &vc4_hdmi->connector.base;
39 struct drm_connector_state *cstate = connector->state;
40 struct drm_crtc *crtc = encoder->crtc;
41 const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
42 @@ -346,7 +346,7 @@ static void vc4_hdmi_set_audio_infoframe
43 {
44 struct drm_device *drm = encoder->dev;
45 struct vc4_dev *vc4 = drm->dev_private;
46 - struct vc4_hdmi *hdmi = vc4->hdmi;
47 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
48 union hdmi_infoframe frame;
49 int ret;
50
51 @@ -355,7 +355,7 @@ static void vc4_hdmi_set_audio_infoframe
52 frame.audio.coding_type = HDMI_AUDIO_CODING_TYPE_STREAM;
53 frame.audio.sample_frequency = HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM;
54 frame.audio.sample_size = HDMI_AUDIO_SAMPLE_SIZE_STREAM;
55 - frame.audio.channels = hdmi->audio.channels;
56 + frame.audio.channels = vc4_hdmi->audio.channels;
57
58 vc4_hdmi_write_infoframe(encoder, &frame);
59 }
60 @@ -370,7 +370,7 @@ static void vc4_hdmi_encoder_disable(str
61 {
62 struct drm_device *dev = encoder->dev;
63 struct vc4_dev *vc4 = to_vc4_dev(dev);
64 - struct vc4_hdmi *hdmi = vc4->hdmi;
65 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
66 int ret;
67
68 HDMI_WRITE(VC4_HDMI_RAM_PACKET_CONFIG, 0);
69 @@ -379,9 +379,9 @@ static void vc4_hdmi_encoder_disable(str
70 HD_WRITE(VC4_HD_VID_CTL,
71 HD_READ(VC4_HD_VID_CTL) & ~VC4_HD_VID_CTL_ENABLE);
72
73 - clk_disable_unprepare(hdmi->pixel_clock);
74 + clk_disable_unprepare(vc4_hdmi->pixel_clock);
75
76 - ret = pm_runtime_put(&hdmi->pdev->dev);
77 + ret = pm_runtime_put(&vc4_hdmi->pdev->dev);
78 if (ret < 0)
79 DRM_ERROR("Failed to release power domain: %d\n", ret);
80 }
81 @@ -392,7 +392,7 @@ static void vc4_hdmi_encoder_enable(stru
82 struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
83 struct drm_device *dev = encoder->dev;
84 struct vc4_dev *vc4 = to_vc4_dev(dev);
85 - struct vc4_hdmi *hdmi = vc4->hdmi;
86 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
87 bool debug_dump_regs = false;
88 bool hsync_pos = mode->flags & DRM_MODE_FLAG_PHSYNC;
89 bool vsync_pos = mode->flags & DRM_MODE_FLAG_PVSYNC;
90 @@ -414,13 +414,13 @@ static void vc4_hdmi_encoder_enable(stru
91 u32 csc_ctl;
92 int ret;
93
94 - ret = pm_runtime_get_sync(&hdmi->pdev->dev);
95 + ret = pm_runtime_get_sync(&vc4_hdmi->pdev->dev);
96 if (ret < 0) {
97 DRM_ERROR("Failed to retain power domain: %d\n", ret);
98 return;
99 }
100
101 - ret = clk_set_rate(hdmi->pixel_clock,
102 + ret = clk_set_rate(vc4_hdmi->pixel_clock,
103 mode->clock * 1000 *
104 ((mode->flags & DRM_MODE_FLAG_DBLCLK) ? 2 : 1));
105 if (ret) {
106 @@ -428,7 +428,7 @@ static void vc4_hdmi_encoder_enable(stru
107 return;
108 }
109
110 - ret = clk_prepare_enable(hdmi->pixel_clock);
111 + ret = clk_prepare_enable(vc4_hdmi->pixel_clock);
112 if (ret) {
113 DRM_ERROR("Failed to turn on pixel clock: %d\n", ret);
114 return;
115 @@ -448,11 +448,11 @@ static void vc4_hdmi_encoder_enable(stru
116 HDMI_WRITE(VC4_HDMI_TX_PHY_RESET_CTL, 0);
117
118 if (debug_dump_regs) {
119 - struct drm_printer p = drm_info_printer(&hdmi->pdev->dev);
120 + struct drm_printer p = drm_info_printer(&vc4_hdmi->pdev->dev);
121
122 - dev_info(&hdmi->pdev->dev, "HDMI regs before:\n");
123 - drm_print_regset32(&p, &hdmi->hdmi_regset);
124 - drm_print_regset32(&p, &hdmi->hd_regset);
125 + dev_info(&vc4_hdmi->pdev->dev, "HDMI regs before:\n");
126 + drm_print_regset32(&p, &vc4_hdmi->hdmi_regset);
127 + drm_print_regset32(&p, &vc4_hdmi->hd_regset);
128 }
129
130 HD_WRITE(VC4_HD_VID_CTL, 0);
131 @@ -527,11 +527,11 @@ static void vc4_hdmi_encoder_enable(stru
132 HDMI_WRITE(VC4_HDMI_FIFO_CTL, VC4_HDMI_FIFO_CTL_MASTER_SLAVE_N);
133
134 if (debug_dump_regs) {
135 - struct drm_printer p = drm_info_printer(&hdmi->pdev->dev);
136 + struct drm_printer p = drm_info_printer(&vc4_hdmi->pdev->dev);
137
138 - dev_info(&hdmi->pdev->dev, "HDMI regs after:\n");
139 - drm_print_regset32(&p, &hdmi->hdmi_regset);
140 - drm_print_regset32(&p, &hdmi->hd_regset);
141 + dev_info(&vc4_hdmi->pdev->dev, "HDMI regs after:\n");
142 + drm_print_regset32(&p, &vc4_hdmi->hdmi_regset);
143 + drm_print_regset32(&p, &vc4_hdmi->hd_regset);
144 }
145
146 HD_WRITE(VC4_HD_VID_CTL,
147 @@ -630,15 +630,15 @@ static const struct drm_encoder_helper_f
148 };
149
150 /* HDMI audio codec callbacks */
151 -static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *hdmi)
152 +static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *vc4_hdmi)
153 {
154 - struct drm_encoder *encoder = &hdmi->encoder.base.base;
155 + struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
156 struct drm_device *drm = encoder->dev;
157 struct vc4_dev *vc4 = to_vc4_dev(drm);
158 - u32 hsm_clock = clk_get_rate(hdmi->hsm_clock);
159 + u32 hsm_clock = clk_get_rate(vc4_hdmi->hsm_clock);
160 unsigned long n, m;
161
162 - rational_best_approximation(hsm_clock, hdmi->audio.samplerate,
163 + rational_best_approximation(hsm_clock, vc4_hdmi->audio.samplerate,
164 VC4_HD_MAI_SMP_N_MASK >>
165 VC4_HD_MAI_SMP_N_SHIFT,
166 (VC4_HD_MAI_SMP_M_MASK >>
167 @@ -650,14 +650,14 @@ static void vc4_hdmi_audio_set_mai_clock
168 VC4_SET_FIELD(m - 1, VC4_HD_MAI_SMP_M));
169 }
170
171 -static void vc4_hdmi_set_n_cts(struct vc4_hdmi *hdmi)
172 +static void vc4_hdmi_set_n_cts(struct vc4_hdmi *vc4_hdmi)
173 {
174 - struct drm_encoder *encoder = &hdmi->encoder.base.base;
175 + struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
176 struct drm_crtc *crtc = encoder->crtc;
177 struct drm_device *drm = encoder->dev;
178 struct vc4_dev *vc4 = to_vc4_dev(drm);
179 const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
180 - u32 samplerate = hdmi->audio.samplerate;
181 + u32 samplerate = vc4_hdmi->audio.samplerate;
182 u32 n, cts;
183 u64 tmp;
184
185 @@ -689,16 +689,16 @@ static inline struct vc4_hdmi *dai_to_hd
186 static int vc4_hdmi_audio_startup(struct snd_pcm_substream *substream,
187 struct snd_soc_dai *dai)
188 {
189 - struct vc4_hdmi *hdmi = dai_to_hdmi(dai);
190 - struct drm_encoder *encoder = &hdmi->encoder.base.base;
191 - struct drm_connector *connector = &hdmi->connector.base;
192 + struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
193 + struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
194 + struct drm_connector *connector = &vc4_hdmi->connector.base;
195 struct vc4_dev *vc4 = to_vc4_dev(encoder->dev);
196 int ret;
197
198 - if (hdmi->audio.substream && hdmi->audio.substream != substream)
199 + if (vc4_hdmi->audio.substream && vc4_hdmi->audio.substream != substream)
200 return -EINVAL;
201
202 - hdmi->audio.substream = substream;
203 + vc4_hdmi->audio.substream = substream;
204
205 /*
206 * If the HDMI encoder hasn't probed, or the encoder is
207 @@ -720,11 +720,11 @@ static int vc4_hdmi_audio_set_fmt(struct
208 return 0;
209 }
210
211 -static void vc4_hdmi_audio_reset(struct vc4_hdmi *hdmi)
212 +static void vc4_hdmi_audio_reset(struct vc4_hdmi *vc4_hdmi)
213 {
214 - struct drm_encoder *encoder = &hdmi->encoder.base.base;
215 + struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
216 struct drm_device *drm = encoder->dev;
217 - struct device *dev = &hdmi->pdev->dev;
218 + struct device *dev = &vc4_hdmi->pdev->dev;
219 struct vc4_dev *vc4 = to_vc4_dev(drm);
220 int ret;
221
222 @@ -740,14 +740,14 @@ static void vc4_hdmi_audio_reset(struct
223 static void vc4_hdmi_audio_shutdown(struct snd_pcm_substream *substream,
224 struct snd_soc_dai *dai)
225 {
226 - struct vc4_hdmi *hdmi = dai_to_hdmi(dai);
227 + struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
228
229 - if (substream != hdmi->audio.substream)
230 + if (substream != vc4_hdmi->audio.substream)
231 return;
232
233 - vc4_hdmi_audio_reset(hdmi);
234 + vc4_hdmi_audio_reset(vc4_hdmi);
235
236 - hdmi->audio.substream = NULL;
237 + vc4_hdmi->audio.substream = NULL;
238 }
239
240 /* HDMI audio codec callbacks */
241 @@ -755,23 +755,23 @@ static int vc4_hdmi_audio_hw_params(stru
242 struct snd_pcm_hw_params *params,
243 struct snd_soc_dai *dai)
244 {
245 - struct vc4_hdmi *hdmi = dai_to_hdmi(dai);
246 - struct drm_encoder *encoder = &hdmi->encoder.base.base;
247 + struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
248 + struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
249 struct drm_device *drm = encoder->dev;
250 - struct device *dev = &hdmi->pdev->dev;
251 + struct device *dev = &vc4_hdmi->pdev->dev;
252 struct vc4_dev *vc4 = to_vc4_dev(drm);
253 u32 audio_packet_config, channel_mask;
254 u32 channel_map, i;
255
256 - if (substream != hdmi->audio.substream)
257 + if (substream != vc4_hdmi->audio.substream)
258 return -EINVAL;
259
260 dev_dbg(dev, "%s: %u Hz, %d bit, %d channels\n", __func__,
261 params_rate(params), params_width(params),
262 params_channels(params));
263
264 - hdmi->audio.channels = params_channels(params);
265 - hdmi->audio.samplerate = params_rate(params);
266 + vc4_hdmi->audio.channels = params_channels(params);
267 + vc4_hdmi->audio.samplerate = params_rate(params);
268
269 HD_WRITE(VC4_HD_MAI_CTL,
270 VC4_HD_MAI_CTL_RESET |
271 @@ -780,23 +780,23 @@ static int vc4_hdmi_audio_hw_params(stru
272 VC4_HD_MAI_CTL_ERRORE |
273 VC4_HD_MAI_CTL_ERRORF);
274
275 - vc4_hdmi_audio_set_mai_clock(hdmi);
276 + vc4_hdmi_audio_set_mai_clock(vc4_hdmi);
277
278 audio_packet_config =
279 VC4_HDMI_AUDIO_PACKET_ZERO_DATA_ON_SAMPLE_FLAT |
280 VC4_HDMI_AUDIO_PACKET_ZERO_DATA_ON_INACTIVE_CHANNELS |
281 VC4_SET_FIELD(0xf, VC4_HDMI_AUDIO_PACKET_B_FRAME_IDENTIFIER);
282
283 - channel_mask = GENMASK(hdmi->audio.channels - 1, 0);
284 + channel_mask = GENMASK(vc4_hdmi->audio.channels - 1, 0);
285 audio_packet_config |= VC4_SET_FIELD(channel_mask,
286 VC4_HDMI_AUDIO_PACKET_CEA_MASK);
287
288 /* Set the MAI threshold. This logic mimics the firmware's. */
289 - if (hdmi->audio.samplerate > 96000) {
290 + if (vc4_hdmi->audio.samplerate > 96000) {
291 HD_WRITE(VC4_HD_MAI_THR,
292 VC4_SET_FIELD(0x12, VC4_HD_MAI_THR_DREQHIGH) |
293 VC4_SET_FIELD(0x12, VC4_HD_MAI_THR_DREQLOW));
294 - } else if (hdmi->audio.samplerate > 48000) {
295 + } else if (vc4_hdmi->audio.samplerate > 48000) {
296 HD_WRITE(VC4_HD_MAI_THR,
297 VC4_SET_FIELD(0x14, VC4_HD_MAI_THR_DREQHIGH) |
298 VC4_SET_FIELD(0x12, VC4_HD_MAI_THR_DREQLOW));
299 @@ -820,7 +820,7 @@ static int vc4_hdmi_audio_hw_params(stru
300
301 HDMI_WRITE(VC4_HDMI_MAI_CHANNEL_MAP, channel_map);
302 HDMI_WRITE(VC4_HDMI_AUDIO_PACKET_CONFIG, audio_packet_config);
303 - vc4_hdmi_set_n_cts(hdmi);
304 + vc4_hdmi_set_n_cts(vc4_hdmi);
305
306 return 0;
307 }
308 @@ -828,8 +828,8 @@ static int vc4_hdmi_audio_hw_params(stru
309 static int vc4_hdmi_audio_trigger(struct snd_pcm_substream *substream, int cmd,
310 struct snd_soc_dai *dai)
311 {
312 - struct vc4_hdmi *hdmi = dai_to_hdmi(dai);
313 - struct drm_encoder *encoder = &hdmi->encoder.base.base;
314 + struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
315 + struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
316 struct drm_device *drm = encoder->dev;
317 struct vc4_dev *vc4 = to_vc4_dev(drm);
318
319 @@ -840,7 +840,7 @@ static int vc4_hdmi_audio_trigger(struct
320 HDMI_READ(VC4_HDMI_TX_PHY_CTL0) &
321 ~VC4_HDMI_TX_PHY_RNG_PWRDN);
322 HD_WRITE(VC4_HD_MAI_CTL,
323 - VC4_SET_FIELD(hdmi->audio.channels,
324 + VC4_SET_FIELD(vc4_hdmi->audio.channels,
325 VC4_HD_MAI_CTL_CHNUM) |
326 VC4_HD_MAI_CTL_ENABLE);
327 break;
328 @@ -872,8 +872,8 @@ static int vc4_hdmi_audio_eld_ctl_info(s
329 struct snd_ctl_elem_info *uinfo)
330 {
331 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
332 - struct vc4_hdmi *hdmi = snd_component_to_hdmi(component);
333 - struct drm_connector *connector = &hdmi->connector.base;
334 + struct vc4_hdmi *vc4_hdmi = snd_component_to_hdmi(component);
335 + struct drm_connector *connector = &vc4_hdmi->connector.base;
336
337 uinfo->type = SNDRV_CTL_ELEM_TYPE_BYTES;
338 uinfo->count = sizeof(connector->eld);
339 @@ -885,8 +885,8 @@ static int vc4_hdmi_audio_eld_ctl_get(st
340 struct snd_ctl_elem_value *ucontrol)
341 {
342 struct snd_soc_component *component = snd_kcontrol_chip(kcontrol);
343 - struct vc4_hdmi *hdmi = snd_component_to_hdmi(component);
344 - struct drm_connector *connector = &hdmi->connector.base;
345 + struct vc4_hdmi *vc4_hdmi = snd_component_to_hdmi(component);
346 + struct drm_connector *connector = &vc4_hdmi->connector.base;
347
348 memcpy(ucontrol->value.bytes.data, connector->eld,
349 sizeof(connector->eld));
350 @@ -954,9 +954,9 @@ static const struct snd_soc_component_dr
351
352 static int vc4_hdmi_audio_cpu_dai_probe(struct snd_soc_dai *dai)
353 {
354 - struct vc4_hdmi *hdmi = dai_to_hdmi(dai);
355 + struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
356
357 - snd_soc_dai_init_dma_data(dai, &hdmi->audio.dma_data, NULL);
358 + snd_soc_dai_init_dma_data(dai, &vc4_hdmi->audio.dma_data, NULL);
359
360 return 0;
361 }
362 @@ -982,11 +982,11 @@ static const struct snd_dmaengine_pcm_co
363 .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config,
364 };
365
366 -static int vc4_hdmi_audio_init(struct vc4_hdmi *hdmi)
367 +static int vc4_hdmi_audio_init(struct vc4_hdmi *vc4_hdmi)
368 {
369 - struct snd_soc_dai_link *dai_link = &hdmi->audio.link;
370 - struct snd_soc_card *card = &hdmi->audio.card;
371 - struct device *dev = &hdmi->pdev->dev;
372 + struct snd_soc_dai_link *dai_link = &vc4_hdmi->audio.link;
373 + struct snd_soc_card *card = &vc4_hdmi->audio.card;
374 + struct device *dev = &vc4_hdmi->pdev->dev;
375 const __be32 *addr;
376 int ret;
377 int len;
378 @@ -1006,9 +1006,9 @@ static int vc4_hdmi_audio_init(struct vc
379 * This VC/MMU should probably be exposed to avoid this kind of hacks.
380 */
381 addr = of_get_address(dev->of_node, 1, NULL, NULL);
382 - hdmi->audio.dma_data.addr = be32_to_cpup(addr) + VC4_HD_MAI_DATA;
383 - hdmi->audio.dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
384 - hdmi->audio.dma_data.maxburst = 2;
385 + vc4_hdmi->audio.dma_data.addr = be32_to_cpup(addr) + VC4_HD_MAI_DATA;
386 + vc4_hdmi->audio.dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
387 + vc4_hdmi->audio.dma_data.maxburst = 2;
388
389 ret = devm_snd_dmaengine_pcm_register(dev, &pcm_conf, 0);
390 if (ret) {
391 @@ -1031,9 +1031,9 @@ static int vc4_hdmi_audio_init(struct vc
392 return ret;
393 }
394
395 - dai_link->cpus = &hdmi->audio.cpu;
396 - dai_link->codecs = &hdmi->audio.codec;
397 - dai_link->platforms = &hdmi->audio.platform;
398 + dai_link->cpus = &vc4_hdmi->audio.cpu;
399 + dai_link->codecs = &vc4_hdmi->audio.codec;
400 + dai_link->platforms = &vc4_hdmi->audio.platform;
401
402 dai_link->num_cpus = 1;
403 dai_link->num_codecs = 1;
404 @@ -1058,7 +1058,7 @@ static int vc4_hdmi_audio_init(struct vc
405 * now stored in card->drvdata and should be retrieved with
406 * snd_soc_card_get_drvdata() if needed.
407 */
408 - snd_soc_card_set_drvdata(card, hdmi);
409 + snd_soc_card_set_drvdata(card, vc4_hdmi);
410 ret = devm_snd_soc_register_card(dev, card);
411 if (ret)
412 dev_err(dev, "Could not register sound card: %d\n", ret);
413 @@ -1071,20 +1071,21 @@ static int vc4_hdmi_audio_init(struct vc
414 static irqreturn_t vc4_cec_irq_handler_thread(int irq, void *priv)
415 {
416 struct vc4_dev *vc4 = priv;
417 - struct vc4_hdmi *hdmi = vc4->hdmi;
418 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
419
420 - if (hdmi->cec_irq_was_rx) {
421 - if (hdmi->cec_rx_msg.len)
422 - cec_received_msg(hdmi->cec_adap, &hdmi->cec_rx_msg);
423 - } else if (hdmi->cec_tx_ok) {
424 - cec_transmit_done(hdmi->cec_adap, CEC_TX_STATUS_OK,
425 + if (vc4_hdmi->cec_irq_was_rx) {
426 + if (vc4_hdmi->cec_rx_msg.len)
427 + cec_received_msg(vc4_hdmi->cec_adap,
428 + &vc4_hdmi->cec_rx_msg);
429 + } else if (vc4_hdmi->cec_tx_ok) {
430 + cec_transmit_done(vc4_hdmi->cec_adap, CEC_TX_STATUS_OK,
431 0, 0, 0, 0);
432 } else {
433 /*
434 * This CEC implementation makes 1 retry, so if we
435 * get a NACK, then that means it made 2 attempts.
436 */
437 - cec_transmit_done(hdmi->cec_adap, CEC_TX_STATUS_NACK,
438 + cec_transmit_done(vc4_hdmi->cec_adap, CEC_TX_STATUS_NACK,
439 0, 2, 0, 0);
440 }
441 return IRQ_HANDLED;
442 @@ -1110,23 +1111,23 @@ static void vc4_cec_read_msg(struct vc4_
443 static irqreturn_t vc4_cec_irq_handler(int irq, void *priv)
444 {
445 struct vc4_dev *vc4 = priv;
446 - struct vc4_hdmi *hdmi = vc4->hdmi;
447 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
448 u32 stat = HDMI_READ(VC4_HDMI_CPU_STATUS);
449 u32 cntrl1, cntrl5;
450
451 if (!(stat & VC4_HDMI_CPU_CEC))
452 return IRQ_NONE;
453 - hdmi->cec_rx_msg.len = 0;
454 + vc4_hdmi->cec_rx_msg.len = 0;
455 cntrl1 = HDMI_READ(VC4_HDMI_CEC_CNTRL_1);
456 cntrl5 = HDMI_READ(VC4_HDMI_CEC_CNTRL_5);
457 - hdmi->cec_irq_was_rx = cntrl5 & VC4_HDMI_CEC_RX_CEC_INT;
458 - if (hdmi->cec_irq_was_rx) {
459 + vc4_hdmi->cec_irq_was_rx = cntrl5 & VC4_HDMI_CEC_RX_CEC_INT;
460 + if (vc4_hdmi->cec_irq_was_rx) {
461 vc4_cec_read_msg(vc4, cntrl1);
462 cntrl1 |= VC4_HDMI_CEC_CLEAR_RECEIVE_OFF;
463 HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1, cntrl1);
464 cntrl1 &= ~VC4_HDMI_CEC_CLEAR_RECEIVE_OFF;
465 } else {
466 - hdmi->cec_tx_ok = cntrl1 & VC4_HDMI_CEC_TX_STATUS_GOOD;
467 + vc4_hdmi->cec_tx_ok = cntrl1 & VC4_HDMI_CEC_TX_STATUS_GOOD;
468 cntrl1 &= ~VC4_HDMI_CEC_START_XMIT_BEGIN;
469 }
470 HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1, cntrl1);
471 @@ -1228,44 +1229,44 @@ static int vc4_hdmi_bind(struct device *
472 struct platform_device *pdev = to_platform_device(dev);
473 struct drm_device *drm = dev_get_drvdata(master);
474 struct vc4_dev *vc4 = drm->dev_private;
475 - struct vc4_hdmi *hdmi;
476 + struct vc4_hdmi *vc4_hdmi;
477 struct drm_encoder *encoder;
478 struct device_node *ddc_node;
479 u32 value;
480 int ret;
481
482 - hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
483 - if (!hdmi)
484 + vc4_hdmi = devm_kzalloc(dev, sizeof(*vc4_hdmi), GFP_KERNEL);
485 + if (!vc4_hdmi)
486 return -ENOMEM;
487
488 - hdmi->pdev = pdev;
489 - encoder = &hdmi->encoder.base.base;
490 + vc4_hdmi->pdev = pdev;
491 + encoder = &vc4_hdmi->encoder.base.base;
492 encoder->base.type = VC4_ENCODER_TYPE_HDMI0;
493
494 - hdmi->hdmicore_regs = vc4_ioremap_regs(pdev, 0);
495 - if (IS_ERR(hdmi->hdmicore_regs))
496 - return PTR_ERR(hdmi->hdmicore_regs);
497 -
498 - hdmi->hd_regs = vc4_ioremap_regs(pdev, 1);
499 - if (IS_ERR(hdmi->hd_regs))
500 - return PTR_ERR(hdmi->hd_regs);
501 -
502 - hdmi->hdmi_regset.base = hdmi->hdmicore_regs;
503 - hdmi->hdmi_regset.regs = hdmi_regs;
504 - hdmi->hdmi_regset.nregs = ARRAY_SIZE(hdmi_regs);
505 - hdmi->hd_regset.base = hdmi->hd_regs;
506 - hdmi->hd_regset.regs = hd_regs;
507 - hdmi->hd_regset.nregs = ARRAY_SIZE(hd_regs);
508 + vc4_hdmi->hdmicore_regs = vc4_ioremap_regs(pdev, 0);
509 + if (IS_ERR(vc4_hdmi->hdmicore_regs))
510 + return PTR_ERR(vc4_hdmi->hdmicore_regs);
511 +
512 + vc4_hdmi->hd_regs = vc4_ioremap_regs(pdev, 1);
513 + if (IS_ERR(vc4_hdmi->hd_regs))
514 + return PTR_ERR(vc4_hdmi->hd_regs);
515 +
516 + vc4_hdmi->hdmi_regset.base = vc4_hdmi->hdmicore_regs;
517 + vc4_hdmi->hdmi_regset.regs = hdmi_regs;
518 + vc4_hdmi->hdmi_regset.nregs = ARRAY_SIZE(hdmi_regs);
519 + vc4_hdmi->hd_regset.base = vc4_hdmi->hd_regs;
520 + vc4_hdmi->hd_regset.regs = hd_regs;
521 + vc4_hdmi->hd_regset.nregs = ARRAY_SIZE(hd_regs);
522
523 - hdmi->pixel_clock = devm_clk_get(dev, "pixel");
524 - if (IS_ERR(hdmi->pixel_clock)) {
525 + vc4_hdmi->pixel_clock = devm_clk_get(dev, "pixel");
526 + if (IS_ERR(vc4_hdmi->pixel_clock)) {
527 DRM_ERROR("Failed to get pixel clock\n");
528 - return PTR_ERR(hdmi->pixel_clock);
529 + return PTR_ERR(vc4_hdmi->pixel_clock);
530 }
531 - hdmi->hsm_clock = devm_clk_get(dev, "hdmi");
532 - if (IS_ERR(hdmi->hsm_clock)) {
533 + vc4_hdmi->hsm_clock = devm_clk_get(dev, "hdmi");
534 + if (IS_ERR(vc4_hdmi->hsm_clock)) {
535 DRM_ERROR("Failed to get HDMI state machine clock\n");
536 - return PTR_ERR(hdmi->hsm_clock);
537 + return PTR_ERR(vc4_hdmi->hsm_clock);
538 }
539
540 ddc_node = of_parse_phandle(dev->of_node, "ddc", 0);
541 @@ -1274,9 +1275,9 @@ static int vc4_hdmi_bind(struct device *
542 return -ENODEV;
543 }
544
545 - hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
546 + vc4_hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
547 of_node_put(ddc_node);
548 - if (!hdmi->ddc) {
549 + if (!vc4_hdmi->ddc) {
550 DRM_DEBUG("Failed to get ddc i2c adapter by node\n");
551 return -EPROBE_DEFER;
552 }
553 @@ -1285,13 +1286,13 @@ static int vc4_hdmi_bind(struct device *
554 * needs to be a bit higher than the pixel clock rate
555 * (generally 148.5Mhz).
556 */
557 - ret = clk_set_rate(hdmi->hsm_clock, HSM_CLOCK_FREQ);
558 + ret = clk_set_rate(vc4_hdmi->hsm_clock, HSM_CLOCK_FREQ);
559 if (ret) {
560 DRM_ERROR("Failed to set HSM clock rate: %d\n", ret);
561 goto err_put_i2c;
562 }
563
564 - ret = clk_prepare_enable(hdmi->hsm_clock);
565 + ret = clk_prepare_enable(vc4_hdmi->hsm_clock);
566 if (ret) {
567 DRM_ERROR("Failed to turn on HDMI state machine clock: %d\n",
568 ret);
569 @@ -1304,18 +1305,18 @@ static int vc4_hdmi_bind(struct device *
570 if (of_find_property(dev->of_node, "hpd-gpios", &value)) {
571 enum of_gpio_flags hpd_gpio_flags;
572
573 - hdmi->hpd_gpio = of_get_named_gpio_flags(dev->of_node,
574 + vc4_hdmi->hpd_gpio = of_get_named_gpio_flags(dev->of_node,
575 "hpd-gpios", 0,
576 &hpd_gpio_flags);
577 - if (hdmi->hpd_gpio < 0) {
578 - ret = hdmi->hpd_gpio;
579 + if (vc4_hdmi->hpd_gpio < 0) {
580 + ret = vc4_hdmi->hpd_gpio;
581 goto err_unprepare_hsm;
582 }
583
584 - hdmi->hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW;
585 + vc4_hdmi->hpd_active_low = hpd_gpio_flags & OF_GPIO_ACTIVE_LOW;
586 }
587
588 - vc4->hdmi = hdmi;
589 + vc4->hdmi = vc4_hdmi;
590
591 /* HDMI core must be enabled. */
592 if (!(HD_READ(VC4_HD_M_CTL) & VC4_HD_M_ENABLE)) {
593 @@ -1331,21 +1332,21 @@ static int vc4_hdmi_bind(struct device *
594 DRM_MODE_ENCODER_TMDS, NULL);
595 drm_encoder_helper_add(encoder, &vc4_hdmi_encoder_helper_funcs);
596
597 - ret = vc4_hdmi_connector_init(drm, hdmi);
598 + ret = vc4_hdmi_connector_init(drm, vc4_hdmi);
599 if (ret)
600 goto err_destroy_encoder;
601
602 #ifdef CONFIG_DRM_VC4_HDMI_CEC
603 - hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops,
604 + vc4_hdmi->cec_adap = cec_allocate_adapter(&vc4_hdmi_cec_adap_ops,
605 vc4, "vc4",
606 CEC_CAP_DEFAULTS |
607 CEC_CAP_CONNECTOR_INFO, 1);
608 - ret = PTR_ERR_OR_ZERO(hdmi->cec_adap);
609 + ret = PTR_ERR_OR_ZERO(vc4_hdmi->cec_adap);
610 if (ret < 0)
611 goto err_destroy_conn;
612
613 - cec_fill_conn_info_from_drm(&conn_info, &hdmi->connector.base);
614 - cec_s_conn_info(hdmi->cec_adap, &conn_info);
615 + cec_fill_conn_info_from_drm(&conn_info, &vc4_hdmi->connector.base);
616 + cec_s_conn_info(vc4_hdmi->cec_adap, &conn_info);
617
618 HDMI_WRITE(VC4_HDMI_CPU_MASK_SET, 0xffffffff);
619 value = HDMI_READ(VC4_HDMI_CEC_CNTRL_1);
620 @@ -1364,32 +1365,32 @@ static int vc4_hdmi_bind(struct device *
621 "vc4 hdmi cec", vc4);
622 if (ret)
623 goto err_delete_cec_adap;
624 - ret = cec_register_adapter(hdmi->cec_adap, dev);
625 + ret = cec_register_adapter(vc4_hdmi->cec_adap, dev);
626 if (ret < 0)
627 goto err_delete_cec_adap;
628 #endif
629
630 - ret = vc4_hdmi_audio_init(hdmi);
631 + ret = vc4_hdmi_audio_init(vc4_hdmi);
632 if (ret)
633 goto err_destroy_encoder;
634
635 - vc4_debugfs_add_file(drm, "hdmi_regs", vc4_hdmi_debugfs_regs, hdmi);
636 + vc4_debugfs_add_file(drm, "hdmi_regs", vc4_hdmi_debugfs_regs, vc4_hdmi);
637
638 return 0;
639
640 #ifdef CONFIG_DRM_VC4_HDMI_CEC
641 err_delete_cec_adap:
642 - cec_delete_adapter(hdmi->cec_adap);
643 + cec_delete_adapter(vc4_hdmi->cec_adap);
644 err_destroy_conn:
645 - vc4_hdmi_connector_destroy(&hdmi->connector.base);
646 + vc4_hdmi_connector_destroy(&vc4_hdmi->connector.base);
647 #endif
648 err_destroy_encoder:
649 vc4_hdmi_encoder_destroy(encoder);
650 err_unprepare_hsm:
651 - clk_disable_unprepare(hdmi->hsm_clock);
652 + clk_disable_unprepare(vc4_hdmi->hsm_clock);
653 pm_runtime_disable(dev);
654 err_put_i2c:
655 - put_device(&hdmi->ddc->dev);
656 + put_device(&vc4_hdmi->ddc->dev);
657
658 return ret;
659 }
660 @@ -1399,16 +1400,16 @@ static void vc4_hdmi_unbind(struct devic
661 {
662 struct drm_device *drm = dev_get_drvdata(master);
663 struct vc4_dev *vc4 = drm->dev_private;
664 - struct vc4_hdmi *hdmi = vc4->hdmi;
665 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
666
667 - cec_unregister_adapter(hdmi->cec_adap);
668 - vc4_hdmi_connector_destroy(&hdmi->connector.base);
669 - vc4_hdmi_encoder_destroy(&hdmi->encoder.base.base);
670 + cec_unregister_adapter(vc4_hdmi->cec_adap);
671 + vc4_hdmi_connector_destroy(&vc4_hdmi->connector.base);
672 + vc4_hdmi_encoder_destroy(&vc4_hdmi->encoder.base.base);
673
674 - clk_disable_unprepare(hdmi->hsm_clock);
675 + clk_disable_unprepare(vc4_hdmi->hsm_clock);
676 pm_runtime_disable(dev);
677
678 - put_device(&hdmi->ddc->dev);
679 + put_device(&vc4_hdmi->ddc->dev);
680
681 vc4->hdmi = NULL;
682 }