brcm2708: update 3.10 patches with raspberrypi/rpi-3.10.y of 27 Apr. 2014
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-3.10 / 0124-ASoC-BCM2708-Add-support-for-RPi-DAC.patch
1 From 50720aa9a0e4af2d8c6dbf9305d45e0a91929951 Mon Sep 17 00:00:00 2001
2 From: Florian Meier <florian.meier@koalo.de>
3 Date: Fri, 6 Dec 2013 20:50:28 +0100
4 Subject: [PATCH 124/196] ASoC: BCM2708: Add support for RPi-DAC
5
6 This adds a machine driver for the RPi-DAC.
7
8 Signed-off-by: Florian Meier <florian.meier@koalo.de>
9 ---
10 arch/arm/configs/bcmrpi_defconfig | 2 +
11 arch/arm/mach-bcm2708/bcm2708.c | 19 ++++++++
12 sound/soc/bcm/Kconfig | 7 +++
13 sound/soc/bcm/Makefile | 2 +
14 sound/soc/bcm/rpi-dac.c | 97 +++++++++++++++++++++++++++++++++++++++
15 sound/soc/codecs/Kconfig | 4 ++
16 sound/soc/codecs/Makefile | 2 +
17 sound/soc/codecs/pcm1794a.c | 62 +++++++++++++++++++++++++
18 8 files changed, 195 insertions(+)
19 create mode 100644 sound/soc/bcm/rpi-dac.c
20 create mode 100644 sound/soc/codecs/pcm1794a.c
21
22 diff --git a/arch/arm/configs/bcmrpi_defconfig b/arch/arm/configs/bcmrpi_defconfig
23 index c3c4e1a..d0328d8 100644
24 --- a/arch/arm/configs/bcmrpi_defconfig
25 +++ b/arch/arm/configs/bcmrpi_defconfig
26 @@ -738,8 +738,10 @@ CONFIG_SND_SOC_DMAENGINE_PCM=y
27 CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM=y
28 CONFIG_SND_BCM2708_SOC_I2S=m
29 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
30 +CONFIG_SND_BCM2708_SOC_RPI_DAC=m
31 CONFIG_SND_SOC_I2C_AND_SPI=m
32 CONFIG_SND_SOC_PCM5102A=m
33 +CONFIG_SND_SOC_PCM1794A=m
34 CONFIG_SOUND_PRIME=m
35 CONFIG_HIDRAW=y
36 CONFIG_HID_A4TECH=m
37 diff --git a/arch/arm/mach-bcm2708/bcm2708.c b/arch/arm/mach-bcm2708/bcm2708.c
38 index 155a50c..90debb4 100644
39 --- a/arch/arm/mach-bcm2708/bcm2708.c
40 +++ b/arch/arm/mach-bcm2708/bcm2708.c
41 @@ -653,6 +653,20 @@ static struct platform_device snd_pcm5102a_codec_device = {
42 };
43 #endif
44
45 +#if defined(CONFIG_SND_BCM2708_SOC_RPI_DAC) || defined(CONFIG_SND_BCM2708_SOC_RPI_DAC_MODULE)
46 +static struct platform_device snd_rpi_dac_device = {
47 + .name = "snd-rpi-dac",
48 + .id = 0,
49 + .num_resources = 0,
50 +};
51 +
52 +static struct platform_device snd_pcm1794a_codec_device = {
53 + .name = "pcm1794a-codec",
54 + .id = -1,
55 + .num_resources = 0,
56 +};
57 +#endif
58 +
59 int __init bcm_register_device(struct platform_device *pdev)
60 {
61 int ret;
62 @@ -788,6 +802,11 @@ void __init bcm2708_init(void)
63 bcm_register_device(&snd_pcm5102a_codec_device);
64 #endif
65
66 +#if defined(CONFIG_SND_BCM2708_SOC_RPI_DAC) || defined(CONFIG_SND_BCM2708_SOC_RPI_DAC_MODULE)
67 + bcm_register_device(&snd_rpi_dac_device);
68 + bcm_register_device(&snd_pcm1794a_codec_device);
69 +#endif
70 +
71 for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
72 struct amba_device *d = amba_devs[i];
73 amba_device_register(d, &iomem_resource);
74 diff --git a/sound/soc/bcm/Kconfig b/sound/soc/bcm/Kconfig
75 index 8b14e37..1c1f5cf 100644
76 --- a/sound/soc/bcm/Kconfig
77 +++ b/sound/soc/bcm/Kconfig
78 @@ -15,3 +15,10 @@ config SND_BCM2708_SOC_HIFIBERRY_DAC
79 select SND_SOC_PCM5102A
80 help
81 Say Y or M if you want to add support for HifiBerry DAC.
82 +
83 +config SND_BCM2708_SOC_RPI_DAC
84 + tristate "Support for RPi-DAC"
85 + depends on SND_BCM2708_SOC_I2S
86 + select SND_SOC_PCM1794A
87 + help
88 + Say Y or M if you want to add support for RPi-DAC.
89 \ No newline at end of file
90 diff --git a/sound/soc/bcm/Makefile b/sound/soc/bcm/Makefile
91 index 6834b4d..95a9d44 100644
92 --- a/sound/soc/bcm/Makefile
93 +++ b/sound/soc/bcm/Makefile
94 @@ -5,5 +5,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd-soc-bcm2708-i2s.o
95
96 # BCM2708 Machine Support
97 snd-soc-hifiberry-dac-objs := hifiberry_dac.o
98 +snd-soc-rpi-dac-objs := rpi-dac.o
99
100 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
101 +obj-$(CONFIG_SND_BCM2708_SOC_RPI_DAC) += snd-soc-rpi-dac.o
102 diff --git a/sound/soc/bcm/rpi-dac.c b/sound/soc/bcm/rpi-dac.c
103 new file mode 100644
104 index 0000000..ef3cd93
105 --- /dev/null
106 +++ b/sound/soc/bcm/rpi-dac.c
107 @@ -0,0 +1,97 @@
108 +/*
109 + * ASoC Driver for RPi-DAC.
110 + *
111 + * Author: Florian Meier <florian.meier@koalo.de>
112 + * Copyright 2013
113 + *
114 + * This program is free software; you can redistribute it and/or
115 + * modify it under the terms of the GNU General Public License
116 + * version 2 as published by the Free Software Foundation.
117 + *
118 + * This program is distributed in the hope that it will be useful, but
119 + * WITHOUT ANY WARRANTY; without even the implied warranty of
120 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
121 + * General Public License for more details.
122 + */
123 +
124 +#include <linux/module.h>
125 +#include <linux/platform_device.h>
126 +
127 +#include <sound/core.h>
128 +#include <sound/pcm.h>
129 +#include <sound/pcm_params.h>
130 +#include <sound/soc.h>
131 +#include <sound/jack.h>
132 +
133 +static int snd_rpi_rpi_dac_init(struct snd_soc_pcm_runtime *rtd)
134 +{
135 + return 0;
136 +}
137 +
138 +static int snd_rpi_rpi_dac_hw_params(struct snd_pcm_substream *substream,
139 + struct snd_pcm_hw_params *params)
140 +{
141 + struct snd_soc_pcm_runtime *rtd = substream->private_data;
142 + struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
143 +
144 + return snd_soc_dai_set_bclk_ratio(cpu_dai, 32*2);
145 +}
146 +
147 +/* machine stream operations */
148 +static struct snd_soc_ops snd_rpi_rpi_dac_ops = {
149 + .hw_params = snd_rpi_rpi_dac_hw_params,
150 +};
151 +
152 +static struct snd_soc_dai_link snd_rpi_rpi_dac_dai[] = {
153 +{
154 + .name = "HifiBerry Mini",
155 + .stream_name = "HifiBerry Mini HiFi",
156 + .cpu_dai_name = "bcm2708-i2s.0",
157 + .codec_dai_name = "pcm1794a-hifi",
158 + .platform_name = "bcm2708-i2s.0",
159 + .codec_name = "pcm1794a-codec",
160 + .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
161 + SND_SOC_DAIFMT_CBS_CFS,
162 + .ops = &snd_rpi_rpi_dac_ops,
163 + .init = snd_rpi_rpi_dac_init,
164 +},
165 +};
166 +
167 +/* audio machine driver */
168 +static struct snd_soc_card snd_rpi_rpi_dac = {
169 + .name = "snd_rpi_rpi_dac",
170 + .dai_link = snd_rpi_rpi_dac_dai,
171 + .num_links = ARRAY_SIZE(snd_rpi_rpi_dac_dai),
172 +};
173 +
174 +static int snd_rpi_rpi_dac_probe(struct platform_device *pdev)
175 +{
176 + int ret = 0;
177 +
178 + snd_rpi_rpi_dac.dev = &pdev->dev;
179 + ret = snd_soc_register_card(&snd_rpi_rpi_dac);
180 + if (ret)
181 + dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
182 +
183 + return ret;
184 +}
185 +
186 +static int snd_rpi_rpi_dac_remove(struct platform_device *pdev)
187 +{
188 + return snd_soc_unregister_card(&snd_rpi_rpi_dac);
189 +}
190 +
191 +static struct platform_driver snd_rpi_rpi_dac_driver = {
192 + .driver = {
193 + .name = "snd-rpi-dac",
194 + .owner = THIS_MODULE,
195 + },
196 + .probe = snd_rpi_rpi_dac_probe,
197 + .remove = snd_rpi_rpi_dac_remove,
198 +};
199 +
200 +module_platform_driver(snd_rpi_rpi_dac_driver);
201 +
202 +MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
203 +MODULE_DESCRIPTION("ASoC Driver for RPi-DAC");
204 +MODULE_LICENSE("GPL v2");
205 diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig
206 index 7c43413..ef9ac1e 100644
207 --- a/sound/soc/codecs/Kconfig
208 +++ b/sound/soc/codecs/Kconfig
209 @@ -55,6 +55,7 @@ config SND_SOC_ALL_CODECS
210 select SND_SOC_ML26124 if I2C
211 select SND_SOC_OMAP_HDMI_CODEC if OMAP4_DSS_HDMI
212 select SND_SOC_PCM3008
213 + select SND_SOC_PCM1794A
214 select SND_SOC_PCM5102A
215 select SND_SOC_RT5631 if I2C
216 select SND_SOC_SGTL5000 if I2C
217 @@ -294,6 +295,9 @@ config SND_SOC_OMAP_HDMI_CODEC
218 config SND_SOC_PCM3008
219 tristate
220
221 +config SND_SOC_PCM1794A
222 + tristate
223 +
224 config SND_SOC_PCM5102A
225 tristate
226
227 diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile
228 index 0677eb5..e98b865 100644
229 --- a/sound/soc/codecs/Makefile
230 +++ b/sound/soc/codecs/Makefile
231 @@ -43,6 +43,7 @@ snd-soc-mc13783-objs := mc13783.o
232 snd-soc-ml26124-objs := ml26124.o
233 snd-soc-omap-hdmi-codec-objs := omap-hdmi.o
234 snd-soc-pcm3008-objs := pcm3008.o
235 +snd-soc-pcm1794a-objs := pcm1794a.o
236 snd-soc-pcm5102a-objs := pcm5102a.o
237 snd-soc-rt5631-objs := rt5631.o
238 snd-soc-sgtl5000-objs := sgtl5000.o
239 @@ -171,6 +172,7 @@ obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o
240 obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o
241 obj-$(CONFIG_SND_SOC_OMAP_HDMI_CODEC) += snd-soc-omap-hdmi-codec.o
242 obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o
243 +obj-$(CONFIG_SND_SOC_PCM1794A) += snd-soc-pcm1794a.o
244 obj-$(CONFIG_SND_SOC_PCM5102A) += snd-soc-pcm5102a.o
245 obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o
246 obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o
247 diff --git a/sound/soc/codecs/pcm1794a.c b/sound/soc/codecs/pcm1794a.c
248 new file mode 100644
249 index 0000000..b4eaa44
250 --- /dev/null
251 +++ b/sound/soc/codecs/pcm1794a.c
252 @@ -0,0 +1,62 @@
253 +/*
254 + * Driver for the PCM1794A codec
255 + *
256 + * Author: Florian Meier <florian.meier@koalo.de>
257 + * Copyright 2013
258 + *
259 + * This program is free software; you can redistribute it and/or
260 + * modify it under the terms of the GNU General Public License
261 + * version 2 as published by the Free Software Foundation.
262 + *
263 + * This program is distributed in the hope that it will be useful, but
264 + * WITHOUT ANY WARRANTY; without even the implied warranty of
265 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
266 + * General Public License for more details.
267 + */
268 +
269 +
270 +#include <linux/init.h>
271 +#include <linux/module.h>
272 +#include <linux/platform_device.h>
273 +
274 +#include <sound/soc.h>
275 +
276 +static struct snd_soc_dai_driver pcm1794a_dai = {
277 + .name = "pcm1794a-hifi",
278 + .playback = {
279 + .channels_min = 2,
280 + .channels_max = 2,
281 + .rates = SNDRV_PCM_RATE_8000_192000,
282 + .formats = SNDRV_PCM_FMTBIT_S16_LE |
283 + SNDRV_PCM_FMTBIT_S24_LE
284 + },
285 +};
286 +
287 +static struct snd_soc_codec_driver soc_codec_dev_pcm1794a;
288 +
289 +static int pcm1794a_probe(struct platform_device *pdev)
290 +{
291 + return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pcm1794a,
292 + &pcm1794a_dai, 1);
293 +}
294 +
295 +static int pcm1794a_remove(struct platform_device *pdev)
296 +{
297 + snd_soc_unregister_codec(&pdev->dev);
298 + return 0;
299 +}
300 +
301 +static struct platform_driver pcm1794a_codec_driver = {
302 + .probe = pcm1794a_probe,
303 + .remove = pcm1794a_remove,
304 + .driver = {
305 + .name = "pcm1794a-codec",
306 + .owner = THIS_MODULE,
307 + },
308 +};
309 +
310 +module_platform_driver(pcm1794a_codec_driver);
311 +
312 +MODULE_DESCRIPTION("ASoC PCM1794A codec driver");
313 +MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
314 +MODULE_LICENSE("GPL v2");
315 --
316 1.9.1
317