firmware-utils: bump to git HEAD
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.4 / 950-0568-drm-vc4-hdmi-Move-accessors-to-vc4_hdmi.patch
1 From d1ced662ff5ed90a489b6610144d480bfd7a64e9 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Mon, 6 Jan 2020 18:21:44 +0100
4 Subject: [PATCH] drm/vc4: hdmi: Move accessors to vc4_hdmi
5
6 The current driver only supports a single HDMI controller, and part of
7 the issue is that the main vc4_dev structure holds a pointer to its
8 (only) HDMI controller, and the HDMI registers accessors will use it to
9 retrieve the mapped addresses.
10
11 Let's modify those accessors to use directly the vc4_hdmi structure so
12 that we can eventually get rid of that single global pointer.
13
14 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
15 ---
16 drivers/gpu/drm/vc4/vc4_hdmi.c | 22 ++++++++--------------
17 drivers/gpu/drm/vc4/vc4_hdmi.h | 8 ++++----
18 2 files changed, 12 insertions(+), 18 deletions(-)
19
20 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
21 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
22 @@ -122,6 +122,7 @@ vc4_hdmi_connector_detect(struct drm_con
23 {
24 struct drm_device *dev = connector->dev;
25 struct vc4_dev *vc4 = to_vc4_dev(dev);
26 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
27
28 if (vc4->hdmi->hpd_gpio) {
29 if (gpio_get_value_cansleep(vc4->hdmi->hpd_gpio) ^
30 @@ -236,6 +237,7 @@ static int vc4_hdmi_stop_packet(struct d
31 {
32 struct drm_device *dev = encoder->dev;
33 struct vc4_dev *vc4 = to_vc4_dev(dev);
34 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
35 u32 packet_id = type - 0x80;
36
37 HDMI_WRITE(VC4_HDMI_RAM_PACKET_CONFIG,
38 @@ -250,6 +252,7 @@ static void vc4_hdmi_write_infoframe(str
39 {
40 struct drm_device *dev = encoder->dev;
41 struct vc4_dev *vc4 = to_vc4_dev(dev);
42 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
43 u32 packet_id = frame->any.type - 0x80;
44 u32 packet_reg = VC4_HDMI_RAM_PACKET(packet_id);
45 uint8_t buffer[VC4_HDMI_PACKET_STRIDE];
46 @@ -632,9 +635,6 @@ static const struct drm_encoder_helper_f
47 /* HDMI audio codec callbacks */
48 static void vc4_hdmi_audio_set_mai_clock(struct vc4_hdmi *vc4_hdmi)
49 {
50 - struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
51 - struct drm_device *drm = encoder->dev;
52 - struct vc4_dev *vc4 = to_vc4_dev(drm);
53 u32 hsm_clock = clk_get_rate(vc4_hdmi->hsm_clock);
54 unsigned long n, m;
55
56 @@ -654,8 +654,6 @@ static void vc4_hdmi_set_n_cts(struct vc
57 {
58 struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
59 struct drm_crtc *crtc = encoder->crtc;
60 - struct drm_device *drm = encoder->dev;
61 - struct vc4_dev *vc4 = to_vc4_dev(drm);
62 const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
63 u32 samplerate = vc4_hdmi->audio.samplerate;
64 u32 n, cts;
65 @@ -692,7 +690,6 @@ static int vc4_hdmi_audio_startup(struct
66 struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
67 struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
68 struct drm_connector *connector = &vc4_hdmi->connector.base;
69 - struct vc4_dev *vc4 = to_vc4_dev(encoder->dev);
70 int ret;
71
72 if (vc4_hdmi->audio.substream && vc4_hdmi->audio.substream != substream)
73 @@ -723,9 +720,7 @@ static int vc4_hdmi_audio_set_fmt(struct
74 static void vc4_hdmi_audio_reset(struct vc4_hdmi *vc4_hdmi)
75 {
76 struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
77 - struct drm_device *drm = encoder->dev;
78 struct device *dev = &vc4_hdmi->pdev->dev;
79 - struct vc4_dev *vc4 = to_vc4_dev(drm);
80 int ret;
81
82 ret = vc4_hdmi_stop_packet(encoder, HDMI_INFOFRAME_TYPE_AUDIO);
83 @@ -756,10 +751,7 @@ static int vc4_hdmi_audio_hw_params(stru
84 struct snd_soc_dai *dai)
85 {
86 struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
87 - struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
88 - struct drm_device *drm = encoder->dev;
89 struct device *dev = &vc4_hdmi->pdev->dev;
90 - struct vc4_dev *vc4 = to_vc4_dev(drm);
91 u32 audio_packet_config, channel_mask;
92 u32 channel_map, i;
93
94 @@ -830,8 +822,6 @@ static int vc4_hdmi_audio_trigger(struct
95 {
96 struct vc4_hdmi *vc4_hdmi = dai_to_hdmi(dai);
97 struct drm_encoder *encoder = &vc4_hdmi->encoder.base.base;
98 - struct drm_device *drm = encoder->dev;
99 - struct vc4_dev *vc4 = to_vc4_dev(drm);
100
101 switch (cmd) {
102 case SNDRV_PCM_TRIGGER_START:
103 @@ -1094,7 +1084,8 @@ static irqreturn_t vc4_cec_irq_handler_t
104
105 static void vc4_cec_read_msg(struct vc4_dev *vc4, u32 cntrl1)
106 {
107 - struct cec_msg *msg = &vc4->hdmi->cec_rx_msg;
108 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
109 + struct cec_msg *msg = &vc4_hdmi->cec_rx_msg;
110 unsigned int i;
111
112 msg->len = 1 + ((cntrl1 & VC4_HDMI_CEC_REC_WRD_CNT_MASK) >>
113 @@ -1140,6 +1131,7 @@ static irqreturn_t vc4_cec_irq_handler(i
114 static int vc4_hdmi_cec_adap_enable(struct cec_adapter *adap, bool enable)
115 {
116 struct vc4_dev *vc4 = cec_get_drvdata(adap);
117 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
118 /* clock period in microseconds */
119 const u32 usecs = 1000000 / CEC_CLOCK_FREQ;
120 u32 val = HDMI_READ(VC4_HDMI_CEC_CNTRL_5);
121 @@ -1183,6 +1175,7 @@ static int vc4_hdmi_cec_adap_enable(stru
122 static int vc4_hdmi_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
123 {
124 struct vc4_dev *vc4 = cec_get_drvdata(adap);
125 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
126
127 HDMI_WRITE(VC4_HDMI_CEC_CNTRL_1,
128 (HDMI_READ(VC4_HDMI_CEC_CNTRL_1) & ~VC4_HDMI_CEC_ADDR_MASK) |
129 @@ -1194,6 +1187,7 @@ static int vc4_hdmi_cec_adap_transmit(st
130 u32 signal_free_time, struct cec_msg *msg)
131 {
132 struct vc4_dev *vc4 = cec_get_drvdata(adap);
133 + struct vc4_hdmi *vc4_hdmi = vc4->hdmi;
134 u32 val;
135 unsigned int i;
136
137 --- a/drivers/gpu/drm/vc4/vc4_hdmi.h
138 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h
139 @@ -78,9 +78,9 @@ struct vc4_hdmi {
140 struct debugfs_regset32 hd_regset;
141 };
142
143 -#define HDMI_READ(offset) readl(vc4->hdmi->hdmicore_regs + offset)
144 -#define HDMI_WRITE(offset, val) writel(val, vc4->hdmi->hdmicore_regs + offset)
145 -#define HD_READ(offset) readl(vc4->hdmi->hd_regs + offset)
146 -#define HD_WRITE(offset, val) writel(val, vc4->hdmi->hd_regs + offset)
147 +#define HDMI_READ(offset) readl(vc4_hdmi->hdmicore_regs + offset)
148 +#define HDMI_WRITE(offset, val) writel(val, vc4_hdmi->hdmicore_regs + offset)
149 +#define HD_READ(offset) readl(vc4_hdmi->hd_regs + offset)
150 +#define HD_WRITE(offset, val) writel(val, vc4_hdmi->hd_regs + offset)
151
152 #endif /* _VC4_HDMI_H_ */