brcm63xx: rename target to bcm63xx
[openwrt/staging/stintel.git] / target / linux / brcm2708 / patches-4.19 / 950-0695-Add-Hifiberry-DAC-DSP-soundcard-driver-3224.patch
1 From f0715f5e178f2f7c0afb719a3a35c8ac250b7586 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?J=C3=B6rg=20Schambacher?=
3 <j-schambacher@users.noreply.github.com>
4 Date: Thu, 12 Sep 2019 14:57:32 +0200
5 Subject: [PATCH] Add Hifiberry DAC+DSP soundcard driver (#3224)
6
7 Adds the driver for the Hifiberry DAC+DSP. It supports capture and
8 playback depending on the DSP firmware.
9
10 Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
11 ---
12 arch/arm/boot/dts/overlays/Makefile | 1 +
13 arch/arm/boot/dts/overlays/README | 6 ++
14 .../overlays/hifiberry-dacplusdsp-overlay.dts | 34 +++++++
15 sound/soc/bcm/Kconfig | 7 ++
16 sound/soc/bcm/Makefile | 2 +
17 sound/soc/bcm/hifiberry_dacplusdsp.c | 90 +++++++++++++++++++
18 sound/soc/bcm/rpi-simple-soundcard.c | 19 ++++
19 10 files changed, 162 insertions(+)
20 create mode 100644 arch/arm/boot/dts/overlays/hifiberry-dacplusdsp-overlay.dts
21 create mode 100644 sound/soc/bcm/hifiberry_dacplusdsp.c
22
23 --- a/arch/arm/boot/dts/overlays/Makefile
24 +++ b/arch/arm/boot/dts/overlays/Makefile
25 @@ -54,6 +54,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
26 hifiberry-dacplus.dtbo \
27 hifiberry-dacplusadc.dtbo \
28 hifiberry-dacplusadcpro.dtbo \
29 + hifiberry-dacplusdsp.dtbo \
30 hifiberry-digi.dtbo \
31 hifiberry-digi-pro.dtbo \
32 hy28a.dtbo \
33 --- a/arch/arm/boot/dts/overlays/README
34 +++ b/arch/arm/boot/dts/overlays/README
35 @@ -904,6 +904,12 @@ Params: 24db_digital_gain Allow ga
36 master for bit clock and frame clock.
37
38
39 +Name: hifiberry-dacplusdsp
40 +Info: Configures the HifiBerry DAC+DSP audio card
41 +Load: dtoverlay=hifiberry-dacplusdsp
42 +Params: <None>
43 +
44 +
45 Name: hifiberry-digi
46 Info: Configures the HifiBerry Digi and Digi+ audio card
47 Load: dtoverlay=hifiberry-digi
48 --- /dev/null
49 +++ b/arch/arm/boot/dts/overlays/hifiberry-dacplusdsp-overlay.dts
50 @@ -0,0 +1,34 @@
51 +// Definitions for hifiberry DAC+DSP soundcard overlay
52 +/dts-v1/;
53 +/plugin/;
54 +
55 +/ {
56 + compatible = "brcm,bcm2835";
57 +
58 + fragment@0 {
59 + target = <&i2s>;
60 + __overlay__ {
61 + status = "okay";
62 + };
63 + };
64 +
65 + fragment@1 {
66 + target-path = "/";
67 + __overlay__ {
68 + dacplusdsp-codec {
69 + #sound-dai-cells = <0>;
70 + compatible = "hifiberry,dacplusdsp";
71 + status = "okay";
72 + };
73 + };
74 + };
75 +
76 + fragment@2 {
77 + target = <&sound>;
78 + __overlay__ {
79 + compatible = "hifiberrydacplusdsp,hifiberrydacplusdsp-soundcard";
80 + i2s-controller = <&i2s>;
81 + status = "okay";
82 + };
83 + };
84 +};
85 --- a/sound/soc/bcm/Kconfig
86 +++ b/sound/soc/bcm/Kconfig
87 @@ -56,6 +56,13 @@ config SND_BCM2708_SOC_HIFIBERRY_DACPLUS
88 help
89 Say Y or M if you want to add support for HifiBerry DAC+ADC PRO.
90
91 +config SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP
92 + tristate "Support for HifiBerry DAC+DSP"
93 + depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
94 + select SND_RPI_SIMPLE_SOUNDCARD
95 + help
96 + Say Y or M if you want to add support for HifiBerry DSP-DAC.
97 +
98 config SND_BCM2708_SOC_HIFIBERRY_DIGI
99 tristate "Support for HifiBerry Digi"
100 depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
101 --- a/sound/soc/bcm/Makefile
102 +++ b/sound/soc/bcm/Makefile
103 @@ -15,6 +15,7 @@ snd-soc-googlevoicehat-codec-objs := goo
104 snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
105 snd-soc-hifiberry-dacplusadc-objs := hifiberry_dacplusadc.o
106 snd-soc-hifiberry-dacplusadcpro-objs := hifiberry_dacplusadcpro.o
107 +snd-soc-hifiberry-dacplusdsp-objs := hifiberry_dacplusdsp.o
108 snd-soc-justboom-dac-objs := justboom-dac.o
109 snd-soc-rpi-cirrus-objs := rpi-cirrus.o
110 snd-soc-rpi-proto-objs := rpi-proto.o
111 @@ -40,6 +41,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_GOOGLEVOICE
112 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
113 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC) += snd-soc-hifiberry-dacplusadc.o
114 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO) += snd-soc-hifiberry-dacplusadcpro.o
115 +obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP) += snd-soc-hifiberry-dacplusdsp.o
116 obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_DAC) += snd-soc-justboom-dac.o
117 obj-$(CONFIG_SND_BCM2708_SOC_RPI_CIRRUS) += snd-soc-rpi-cirrus.o
118 obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o
119 --- /dev/null
120 +++ b/sound/soc/bcm/hifiberry_dacplusdsp.c
121 @@ -0,0 +1,90 @@
122 +// SPDX-License-Identifier: GPL-2.0
123 +/*
124 + * ASoC Driver for HiFiBerry DAC + DSP
125 + *
126 + * Author: Joerg Schambacher <joscha@schambacher.com>
127 + * Copyright 2018
128 + *
129 + * This program is free software; you can redistribute it and/or
130 + * modify it under the terms of the GNU General Public License
131 + * version 2 as published by the Free Software Foundation.
132 + *
133 + * This program is distributed in the hope that it will be useful, but
134 + * WITHOUT ANY WARRANTY; without even the implied warranty of
135 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
136 + * General Public License for more details.
137 + */
138 +
139 +#include <linux/init.h>
140 +#include <linux/module.h>
141 +#include <linux/of.h>
142 +#include <linux/platform_device.h>
143 +#include <sound/soc.h>
144 +
145 +static struct snd_soc_component_driver dacplusdsp_component_driver;
146 +
147 +static struct snd_soc_dai_driver dacplusdsp_dai = {
148 + .name = "dacplusdsp-hifi",
149 + .capture = {
150 + .stream_name = "DAC+DSP Capture",
151 + .channels_min = 2,
152 + .channels_max = 2,
153 + .rates = SNDRV_PCM_RATE_CONTINUOUS,
154 + .formats = SNDRV_PCM_FMTBIT_S16_LE |
155 + SNDRV_PCM_FMTBIT_S24_LE |
156 + SNDRV_PCM_FMTBIT_S32_LE,
157 + },
158 + .playback = {
159 + .stream_name = "DACP+DSP Playback",
160 + .channels_min = 2,
161 + .channels_max = 2,
162 + .rates = SNDRV_PCM_RATE_CONTINUOUS,
163 + .formats = SNDRV_PCM_FMTBIT_S16_LE |
164 + SNDRV_PCM_FMTBIT_S24_LE |
165 + SNDRV_PCM_FMTBIT_S32_LE,
166 + },
167 + .symmetric_rates = 1};
168 +
169 +#ifdef CONFIG_OF
170 +static const struct of_device_id dacplusdsp_ids[] = {
171 + {
172 + .compatible = "hifiberry,dacplusdsp",
173 + },
174 + {} };
175 +MODULE_DEVICE_TABLE(of, dacplusdsp_ids);
176 +#endif
177 +
178 +static int dacplusdsp_platform_probe(struct platform_device *pdev)
179 +{
180 + int ret;
181 +
182 + ret = snd_soc_register_component(&pdev->dev,
183 + &dacplusdsp_component_driver, &dacplusdsp_dai, 1);
184 + if (ret) {
185 + pr_alert("snd_soc_register_component failed\n");
186 + return ret;
187 + }
188 +
189 + return 0;
190 +}
191 +
192 +static int dacplusdsp_platform_remove(struct platform_device *pdev)
193 +{
194 + snd_soc_unregister_component(&pdev->dev);
195 + return 0;
196 +}
197 +
198 +static struct platform_driver dacplusdsp_driver = {
199 + .driver = {
200 + .name = "hifiberry-dacplusdsp-codec",
201 + .of_match_table = of_match_ptr(dacplusdsp_ids),
202 + },
203 + .probe = dacplusdsp_platform_probe,
204 + .remove = dacplusdsp_platform_remove,
205 +};
206 +
207 +module_platform_driver(dacplusdsp_driver);
208 +
209 +MODULE_AUTHOR("Joerg Schambacher <joerg@i2audio.com>");
210 +MODULE_DESCRIPTION("ASoC Driver for HiFiBerry DAC+DSP");
211 +MODULE_LICENSE("GPL v2");
212 --- a/sound/soc/bcm/rpi-simple-soundcard.c
213 +++ b/sound/soc/bcm/rpi-simple-soundcard.c
214 @@ -136,6 +136,23 @@ static struct snd_rpi_simple_drvdata drv
215 .dai = snd_googlevoicehat_soundcard_dai,
216 };
217
218 +static struct snd_soc_dai_link snd_hifiberrydacplusdsp_soundcard_dai[] = {
219 +{
220 + .name = "Hifiberry DAC+DSP SoundCard",
221 + .stream_name = "Hifiberry DAC+DSP SoundCard HiFi",
222 + .codec_dai_name = "dacplusdsp-hifi",
223 + .codec_name = "dacplusdsp-codec",
224 + .dai_fmt = SND_SOC_DAIFMT_I2S |
225 + SND_SOC_DAIFMT_NB_NF |
226 + SND_SOC_DAIFMT_CBS_CFS,
227 +},
228 +};
229 +
230 +static struct snd_rpi_simple_drvdata drvdata_hifiberrydacplusdsp = {
231 + .card_name = "snd_rpi_hifiberrydacplusdsp_soundcard",
232 + .dai = snd_hifiberrydacplusdsp_soundcard_dai,
233 +};
234 +
235 static struct snd_soc_dai_link snd_hifiberry_amp_dai[] = {
236 {
237 .name = "HifiBerry AMP",
238 @@ -193,6 +210,8 @@ static const struct of_device_id snd_rpi
239 .data = (void *) &drvdata_adau1977 },
240 { .compatible = "googlevoicehat,googlevoicehat-soundcard",
241 .data = (void *) &drvdata_googlevoicehat },
242 + { .compatible = "hifiberrydacplusdsp,hifiberrydacplusdsp-soundcard",
243 + .data = (void *) &drvdata_hifiberrydacplusdsp },
244 { .compatible = "hifiberry,hifiberry-amp",
245 .data = (void *) &drvdata_hifiberry_amp },
246 { .compatible = "hifiberry,hifiberry-dac",