1 From 13bb65d33681b0095214033a5e80186faa325854 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Wed, 18 Dec 2019 18:35:12 +0100
4 Subject: [PATCH] drm/vc4: hdmi: Move structure to header
6 We will need to share the vc4_hdmi and related structures with multiple
7 files, so let's create a header for it.
9 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
11 drivers/gpu/drm/vc4/vc4_hdmi.c | 76 +-----------------------------
12 drivers/gpu/drm/vc4/vc4_hdmi.h | 86 ++++++++++++++++++++++++++++++++++
13 2 files changed, 87 insertions(+), 75 deletions(-)
14 create mode 100644 drivers/gpu/drm/vc4/vc4_hdmi.h
16 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
17 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
19 #include <sound/soc.h>
20 #include "media/cec.h"
22 +#include "vc4_hdmi.h"
25 #define HSM_CLOCK_FREQ 163682864
26 #define CEC_CLOCK_FREQ 40000
27 #define CEC_CLOCK_DIV (HSM_CLOCK_FREQ / CEC_CLOCK_FREQ)
29 -/* HDMI audio information */
30 -struct vc4_hdmi_audio {
31 - struct snd_soc_card card;
32 - struct snd_soc_dai_link link;
33 - struct snd_soc_dai_link_component cpu;
34 - struct snd_soc_dai_link_component codec;
35 - struct snd_soc_dai_link_component platform;
38 - struct snd_dmaengine_dai_dma_data dma_data;
39 - struct snd_pcm_substream *substream;
42 -/* General HDMI hardware state. */
44 - struct platform_device *pdev;
46 - struct drm_encoder *encoder;
47 - struct drm_connector *connector;
49 - struct vc4_hdmi_audio audio;
51 - struct i2c_adapter *ddc;
52 - void __iomem *hdmicore_regs;
53 - void __iomem *hd_regs;
55 - bool hpd_active_low;
57 - struct cec_adapter *cec_adap;
58 - struct cec_msg cec_rx_msg;
60 - bool cec_irq_was_rx;
62 - struct clk *pixel_clock;
63 - struct clk *hsm_clock;
65 - struct debugfs_regset32 hdmi_regset;
66 - struct debugfs_regset32 hd_regset;
69 -#define HDMI_READ(offset) readl(vc4->hdmi->hdmicore_regs + offset)
70 -#define HDMI_WRITE(offset, val) writel(val, vc4->hdmi->hdmicore_regs + offset)
71 -#define HD_READ(offset) readl(vc4->hdmi->hd_regs + offset)
72 -#define HD_WRITE(offset, val) writel(val, vc4->hdmi->hd_regs + offset)
74 -/* VC4 HDMI encoder KMS struct */
75 -struct vc4_hdmi_encoder {
76 - struct vc4_encoder base;
78 - bool limited_rgb_range;
81 -static inline struct vc4_hdmi_encoder *
82 -to_vc4_hdmi_encoder(struct drm_encoder *encoder)
84 - return container_of(encoder, struct vc4_hdmi_encoder, base.base);
87 -/* VC4 HDMI connector KMS struct */
88 -struct vc4_hdmi_connector {
89 - struct drm_connector base;
91 - /* Since the connector is attached to just the one encoder,
92 - * this is the reference to it so we can do the best_encoder()
95 - struct drm_encoder *encoder;
98 -static inline struct vc4_hdmi_connector *
99 -to_vc4_hdmi_connector(struct drm_connector *connector)
101 - return container_of(connector, struct vc4_hdmi_connector, base);
104 static const struct debugfs_reg32 hdmi_regs[] = {
105 VC4_REG32(VC4_HDMI_CORE_REV),
106 VC4_REG32(VC4_HDMI_SW_RESET_CONTROL),
108 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.h
110 +#ifndef _VC4_HDMI_H_
111 +#define _VC4_HDMI_H_
113 +#include <drm/drm_connector.h>
114 +#include <media/cec.h>
115 +#include <sound/dmaengine_pcm.h>
116 +#include <sound/soc.h>
118 +#include "vc4_drv.h"
120 +/* HDMI audio information */
121 +struct vc4_hdmi_audio {
122 + struct snd_soc_card card;
123 + struct snd_soc_dai_link link;
124 + struct snd_soc_dai_link_component cpu;
125 + struct snd_soc_dai_link_component codec;
126 + struct snd_soc_dai_link_component platform;
129 + struct snd_dmaengine_dai_dma_data dma_data;
130 + struct snd_pcm_substream *substream;
133 +/* General HDMI hardware state. */
135 + struct platform_device *pdev;
137 + struct drm_encoder *encoder;
138 + struct drm_connector *connector;
140 + struct vc4_hdmi_audio audio;
142 + struct i2c_adapter *ddc;
143 + void __iomem *hdmicore_regs;
144 + void __iomem *hd_regs;
146 + bool hpd_active_low;
148 + struct cec_adapter *cec_adap;
149 + struct cec_msg cec_rx_msg;
151 + bool cec_irq_was_rx;
153 + struct clk *pixel_clock;
154 + struct clk *hsm_clock;
156 + struct debugfs_regset32 hdmi_regset;
157 + struct debugfs_regset32 hd_regset;
160 +#define HDMI_READ(offset) readl(vc4->hdmi->hdmicore_regs + offset)
161 +#define HDMI_WRITE(offset, val) writel(val, vc4->hdmi->hdmicore_regs + offset)
162 +#define HD_READ(offset) readl(vc4->hdmi->hd_regs + offset)
163 +#define HD_WRITE(offset, val) writel(val, vc4->hdmi->hd_regs + offset)
165 +/* VC4 HDMI encoder KMS struct */
166 +struct vc4_hdmi_encoder {
167 + struct vc4_encoder base;
169 + bool limited_rgb_range;
172 +static inline struct vc4_hdmi_encoder *
173 +to_vc4_hdmi_encoder(struct drm_encoder *encoder)
175 + return container_of(encoder, struct vc4_hdmi_encoder, base.base);
178 +/* VC4 HDMI connector KMS struct */
179 +struct vc4_hdmi_connector {
180 + struct drm_connector base;
182 + /* Since the connector is attached to just the one encoder,
183 + * this is the reference to it so we can do the best_encoder()
186 + struct drm_encoder *encoder;
189 +static inline struct vc4_hdmi_connector *
190 +to_vc4_hdmi_connector(struct drm_connector *connector)
192 + return container_of(connector, struct vc4_hdmi_connector, base);
195 +#endif /* _VC4_HDMI_H_ */