lantiq: fix broadcasts and vlans in two iface mode
[oweals/openwrt.git] / target / linux / brcm2708 / patches-4.9 / 0067-ASoC-Add-support-for-Rpi-DAC.patch
1 From 3a890b43d08fbfe10895f733578f095a6449ba0b Mon Sep 17 00:00:00 2001
2 From: Florian Meier <florian.meier@koalo.de>
3 Date: Mon, 25 Jan 2016 15:48:59 +0000
4 Subject: [PATCH] ASoC: Add support for Rpi-DAC
5
6 ---
7  sound/soc/bcm/Kconfig       |   7 +++
8  sound/soc/bcm/Makefile      |   2 +
9  sound/soc/bcm/rpi-dac.c     | 119 ++++++++++++++++++++++++++++++++++++++++++++
10  sound/soc/codecs/Kconfig    |   5 ++
11  sound/soc/codecs/Makefile   |   2 +
12  sound/soc/codecs/pcm1794a.c |  69 +++++++++++++++++++++++++
13  6 files changed, 204 insertions(+)
14  create mode 100644 sound/soc/bcm/rpi-dac.c
15  create mode 100644 sound/soc/codecs/pcm1794a.c
16
17 --- a/sound/soc/bcm/Kconfig
18 +++ b/sound/soc/bcm/Kconfig
19 @@ -23,3 +23,10 @@ config SND_BCM2708_SOC_HIFIBERRY_DAC
20          select SND_SOC_PCM5102A
21          help
22           Say Y or M if you want to add support for HifiBerry DAC.
23 +
24 +config SND_BCM2708_SOC_RPI_DAC
25 +        tristate "Support for RPi-DAC"
26 +        depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
27 +        select SND_SOC_PCM1794A
28 +        help
29 +         Say Y or M if you want to add support for RPi-DAC.
30 --- a/sound/soc/bcm/Makefile
31 +++ b/sound/soc/bcm/Makefile
32 @@ -10,5 +10,7 @@ obj-$(CONFIG_SND_SOC_CYGNUS) += snd-soc-
33  
34  # BCM2708 Machine Support
35  snd-soc-hifiberry-dac-objs := hifiberry_dac.o
36 +snd-soc-rpi-dac-objs := rpi-dac.o
37  
38  obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
39 +obj-$(CONFIG_SND_BCM2708_SOC_RPI_DAC) += snd-soc-rpi-dac.o
40 --- /dev/null
41 +++ b/sound/soc/bcm/rpi-dac.c
42 @@ -0,0 +1,119 @@
43 +/*
44 + * ASoC Driver for RPi-DAC.
45 + *
46 + * Author:     Florian Meier <florian.meier@koalo.de>
47 + *             Copyright 2013
48 + *
49 + * This program is free software; you can redistribute it and/or
50 + * modify it under the terms of the GNU General Public License
51 + * version 2 as published by the Free Software Foundation.
52 + *
53 + * This program is distributed in the hope that it will be useful, but
54 + * WITHOUT ANY WARRANTY; without even the implied warranty of
55 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
56 + * General Public License for more details.
57 + */
58 +
59 +#include <linux/module.h>
60 +#include <linux/platform_device.h>
61 +
62 +#include <sound/core.h>
63 +#include <sound/pcm.h>
64 +#include <sound/pcm_params.h>
65 +#include <sound/soc.h>
66 +#include <sound/jack.h>
67 +
68 +static int snd_rpi_rpi_dac_init(struct snd_soc_pcm_runtime *rtd)
69 +{
70 +       return 0;
71 +}
72 +
73 +static int snd_rpi_rpi_dac_hw_params(struct snd_pcm_substream *substream,
74 +                                      struct snd_pcm_hw_params *params)
75 +{
76 +       struct snd_soc_pcm_runtime *rtd = substream->private_data;
77 +       struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
78 +
79 +       return snd_soc_dai_set_bclk_ratio(cpu_dai, 32*2);
80 +}
81 +
82 +/* machine stream operations */
83 +static struct snd_soc_ops snd_rpi_rpi_dac_ops = {
84 +       .hw_params = snd_rpi_rpi_dac_hw_params,
85 +};
86 +
87 +static struct snd_soc_dai_link snd_rpi_rpi_dac_dai[] = {
88 +{
89 +       .name           = "RPi-DAC",
90 +       .stream_name    = "RPi-DAC HiFi",
91 +       .cpu_dai_name   = "bcm2708-i2s.0",
92 +       .codec_dai_name = "pcm1794a-hifi",
93 +       .platform_name  = "bcm2708-i2s.0",
94 +       .codec_name     = "pcm1794a-codec",
95 +       .dai_fmt        = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
96 +                               SND_SOC_DAIFMT_CBS_CFS,
97 +       .ops            = &snd_rpi_rpi_dac_ops,
98 +       .init           = snd_rpi_rpi_dac_init,
99 +},
100 +};
101 +
102 +/* audio machine driver */
103 +static struct snd_soc_card snd_rpi_rpi_dac = {
104 +       .name         = "snd_rpi_rpi_dac",
105 +       .owner        = THIS_MODULE,
106 +       .dai_link     = snd_rpi_rpi_dac_dai,
107 +       .num_links    = ARRAY_SIZE(snd_rpi_rpi_dac_dai),
108 +};
109 +
110 +static int snd_rpi_rpi_dac_probe(struct platform_device *pdev)
111 +{
112 +       int ret = 0;
113 +
114 +       snd_rpi_rpi_dac.dev = &pdev->dev;
115 +       
116 +       if (pdev->dev.of_node) {
117 +               struct device_node *i2s_node;
118 +               struct snd_soc_dai_link *dai = &snd_rpi_rpi_dac_dai[0];
119 +               i2s_node = of_parse_phandle(pdev->dev.of_node, "i2s-controller", 0);
120 +
121 +               if (i2s_node) {
122 +                       dai->cpu_dai_name = NULL;
123 +                       dai->cpu_of_node = i2s_node;
124 +                       dai->platform_name = NULL;
125 +                       dai->platform_of_node = i2s_node;
126 +               }
127 +       }
128 +       
129 +       ret = snd_soc_register_card(&snd_rpi_rpi_dac);
130 +       if (ret)
131 +               dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
132 +
133 +       return ret;
134 +}
135 +
136 +static int snd_rpi_rpi_dac_remove(struct platform_device *pdev)
137 +{
138 +       return snd_soc_unregister_card(&snd_rpi_rpi_dac);
139 +}
140 +
141 +static const struct of_device_id snd_rpi_rpi_dac_of_match[] = {
142 +       { .compatible = "rpi,rpi-dac", },
143 +       {},
144 +};
145 +MODULE_DEVICE_TABLE(of, snd_rpi_rpi_dac_of_match);
146 +
147 +static struct platform_driver snd_rpi_rpi_dac_driver = {
148 +        .driver = {
149 +                .name   = "snd-rpi-dac",
150 +                .owner  = THIS_MODULE,
151 +                .of_match_table = snd_rpi_rpi_dac_of_match,
152 +        },
153 +        .probe          = snd_rpi_rpi_dac_probe,
154 +        .remove         = snd_rpi_rpi_dac_remove,
155 +};
156 +
157 +module_platform_driver(snd_rpi_rpi_dac_driver);
158 +
159 +MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
160 +MODULE_DESCRIPTION("ASoC Driver for RPi-DAC");
161 +MODULE_LICENSE("GPL v2");
162 --- a/sound/soc/codecs/Kconfig
163 +++ b/sound/soc/codecs/Kconfig
164 @@ -98,6 +98,7 @@ config SND_SOC_ALL_CODECS
165         select SND_SOC_PCM1681 if I2C
166         select SND_SOC_PCM179X_I2C if I2C
167         select SND_SOC_PCM179X_SPI if SPI_MASTER
168 +       select SND_SOC_PCM1794A if I2C
169         select SND_SOC_PCM3008
170         select SND_SOC_PCM3168A_I2C if I2C
171         select SND_SOC_PCM3168A_SPI if SPI_MASTER
172 @@ -689,6 +690,10 @@ config SND_SOC_RT5616
173         tristate "Realtek RT5616 CODEC"
174         depends on I2C
175  
176 +config SND_SOC_PCM1794A
177 +       tristate
178 +       depends on I2C
179 +
180  config SND_SOC_RT5631
181         tristate "Realtek ALC5631/RT5631 CODEC"
182         depends on I2C
183 --- a/sound/soc/codecs/Makefile
184 +++ b/sound/soc/codecs/Makefile
185 @@ -93,6 +93,7 @@ snd-soc-pcm1681-objs := pcm1681.o
186  snd-soc-pcm179x-codec-objs := pcm179x.o
187  snd-soc-pcm179x-i2c-objs := pcm179x-i2c.o
188  snd-soc-pcm179x-spi-objs := pcm179x-spi.o
189 +snd-soc-pcm1794a-objs := pcm1794a.o
190  snd-soc-pcm3008-objs := pcm3008.o
191  snd-soc-pcm3168a-objs := pcm3168a.o
192  snd-soc-pcm3168a-i2c-objs := pcm3168a-i2c.o
193 @@ -325,6 +326,7 @@ obj-$(CONFIG_SND_SOC_PCM5102A)      += snd-so
194  obj-$(CONFIG_SND_SOC_PCM512x)  += snd-soc-pcm512x.o
195  obj-$(CONFIG_SND_SOC_PCM512x_I2C)      += snd-soc-pcm512x-i2c.o
196  obj-$(CONFIG_SND_SOC_PCM512x_SPI)      += snd-soc-pcm512x-spi.o
197 +obj-$(CONFIG_SND_SOC_PCM1794A) += snd-soc-pcm1794a.o
198  obj-$(CONFIG_SND_SOC_RL6231)   += snd-soc-rl6231.o
199  obj-$(CONFIG_SND_SOC_RL6347A)  += snd-soc-rl6347a.o
200  obj-$(CONFIG_SND_SOC_RT286)    += snd-soc-rt286.o
201 --- /dev/null
202 +++ b/sound/soc/codecs/pcm1794a.c
203 @@ -0,0 +1,69 @@
204 +/*
205 + * Driver for the PCM1794A codec
206 + *
207 + * Author:     Florian Meier <florian.meier@koalo.de>
208 + *             Copyright 2013
209 + *
210 + * This program is free software; you can redistribute it and/or
211 + * modify it under the terms of the GNU General Public License
212 + * version 2 as published by the Free Software Foundation.
213 + *
214 + * This program is distributed in the hope that it will be useful, but
215 + * WITHOUT ANY WARRANTY; without even the implied warranty of
216 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
217 + * General Public License for more details.
218 + */
219 +
220 +
221 +#include <linux/init.h>
222 +#include <linux/module.h>
223 +#include <linux/platform_device.h>
224 +
225 +#include <sound/soc.h>
226 +
227 +static struct snd_soc_dai_driver pcm1794a_dai = {
228 +       .name = "pcm1794a-hifi",
229 +       .playback = {
230 +               .channels_min = 2,
231 +               .channels_max = 2,
232 +               .rates = SNDRV_PCM_RATE_8000_192000,
233 +               .formats = SNDRV_PCM_FMTBIT_S16_LE |
234 +                          SNDRV_PCM_FMTBIT_S24_LE
235 +       },
236 +};
237 +
238 +static struct snd_soc_codec_driver soc_codec_dev_pcm1794a;
239 +
240 +static int pcm1794a_probe(struct platform_device *pdev)
241 +{
242 +       return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pcm1794a,
243 +                       &pcm1794a_dai, 1);
244 +}
245 +
246 +static int pcm1794a_remove(struct platform_device *pdev)
247 +{
248 +       snd_soc_unregister_codec(&pdev->dev);
249 +       return 0;
250 +}
251 +
252 +static const struct of_device_id pcm1794a_of_match[] = {
253 +       { .compatible = "ti,pcm1794a", },
254 +       { }
255 +};
256 +MODULE_DEVICE_TABLE(of, pcm1794a_of_match);
257 +
258 +static struct platform_driver pcm1794a_codec_driver = {
259 +       .probe          = pcm1794a_probe,
260 +       .remove         = pcm1794a_remove,
261 +       .driver         = {
262 +               .name   = "pcm1794a-codec",
263 +               .owner  = THIS_MODULE,
264 +               .of_match_table = of_match_ptr(pcm1794a_of_match),
265 +       },
266 +};
267 +
268 +module_platform_driver(pcm1794a_codec_driver);
269 +
270 +MODULE_DESCRIPTION("ASoC PCM1794A codec driver");
271 +MODULE_AUTHOR("Florian Meier <florian.meier@koalo.de>");
272 +MODULE_LICENSE("GPL v2");