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 799/806] Add Hifiberry DAC+DSP soundcard driver (#3224)
7 Adds the driver for the Hifiberry DAC+DSP. It supports capture and
8 playback depending on the DSP firmware.
10 Signed-off-by: Joerg Schambacher <joerg@i2audio.com>
12 arch/arm/boot/dts/overlays/Makefile | 1 +
13 arch/arm/boot/dts/overlays/README | 6 ++
14 .../overlays/hifiberry-dacplusdsp-overlay.dts | 34 +++++++
15 arch/arm/configs/bcm2709_defconfig | 1 +
16 arch/arm/configs/bcm2711_defconfig | 1 +
17 arch/arm/configs/bcmrpi_defconfig | 1 +
18 sound/soc/bcm/Kconfig | 7 ++
19 sound/soc/bcm/Makefile | 2 +
20 sound/soc/bcm/hifiberry_dacplusdsp.c | 90 +++++++++++++++++++
21 sound/soc/bcm/rpi-simple-soundcard.c | 19 ++++
22 10 files changed, 162 insertions(+)
23 create mode 100644 arch/arm/boot/dts/overlays/hifiberry-dacplusdsp-overlay.dts
24 create mode 100644 sound/soc/bcm/hifiberry_dacplusdsp.c
26 --- a/arch/arm/boot/dts/overlays/Makefile
27 +++ b/arch/arm/boot/dts/overlays/Makefile
28 @@ -54,6 +54,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
29 hifiberry-dacplus.dtbo \
30 hifiberry-dacplusadc.dtbo \
31 hifiberry-dacplusadcpro.dtbo \
32 + hifiberry-dacplusdsp.dtbo \
34 hifiberry-digi-pro.dtbo \
36 --- a/arch/arm/boot/dts/overlays/README
37 +++ b/arch/arm/boot/dts/overlays/README
38 @@ -904,6 +904,12 @@ Params: 24db_digital_gain Allow ga
39 master for bit clock and frame clock.
42 +Name: hifiberry-dacplusdsp
43 +Info: Configures the HifiBerry DAC+DSP audio card
44 +Load: dtoverlay=hifiberry-dacplusdsp
49 Info: Configures the HifiBerry Digi and Digi+ audio card
50 Load: dtoverlay=hifiberry-digi
52 +++ b/arch/arm/boot/dts/overlays/hifiberry-dacplusdsp-overlay.dts
54 +// Definitions for hifiberry DAC+DSP soundcard overlay
59 + compatible = "brcm,bcm2835";
72 + #sound-dai-cells = <0>;
73 + compatible = "hifiberry,dacplusdsp";
82 + compatible = "hifiberrydacplusdsp,hifiberrydacplusdsp-soundcard";
83 + i2s-controller = <&i2s>;
88 --- a/arch/arm/configs/bcm2709_defconfig
89 +++ b/arch/arm/configs/bcm2709_defconfig
90 @@ -970,6 +970,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
91 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
92 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC=m
93 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO=m
94 +CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP=m
95 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
96 CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
97 CONFIG_SND_BCM2708_SOC_RPI_CIRRUS=m
98 --- a/arch/arm/configs/bcm2711_defconfig
99 +++ b/arch/arm/configs/bcm2711_defconfig
100 @@ -981,6 +981,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
101 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
102 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC=m
103 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO=m
104 +CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP=m
105 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
106 CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
107 CONFIG_SND_BCM2708_SOC_RPI_CIRRUS=m
108 --- a/arch/arm/configs/bcmrpi_defconfig
109 +++ b/arch/arm/configs/bcmrpi_defconfig
110 @@ -962,6 +962,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
111 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
112 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC=m
113 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO=m
114 +CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP=m
115 CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
116 CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
117 CONFIG_SND_BCM2708_SOC_RPI_CIRRUS=m
118 --- a/sound/soc/bcm/Kconfig
119 +++ b/sound/soc/bcm/Kconfig
120 @@ -56,6 +56,13 @@ config SND_BCM2708_SOC_HIFIBERRY_DACPLUS
122 Say Y or M if you want to add support for HifiBerry DAC+ADC PRO.
124 +config SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP
125 + tristate "Support for HifiBerry DAC+DSP"
126 + depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
127 + select SND_RPI_SIMPLE_SOUNDCARD
129 + Say Y or M if you want to add support for HifiBerry DSP-DAC.
131 config SND_BCM2708_SOC_HIFIBERRY_DIGI
132 tristate "Support for HifiBerry Digi"
133 depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
134 --- a/sound/soc/bcm/Makefile
135 +++ b/sound/soc/bcm/Makefile
136 @@ -15,6 +15,7 @@ snd-soc-googlevoicehat-codec-objs := goo
137 snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
138 snd-soc-hifiberry-dacplusadc-objs := hifiberry_dacplusadc.o
139 snd-soc-hifiberry-dacplusadcpro-objs := hifiberry_dacplusadcpro.o
140 +snd-soc-hifiberry-dacplusdsp-objs := hifiberry_dacplusdsp.o
141 snd-soc-justboom-dac-objs := justboom-dac.o
142 snd-soc-rpi-cirrus-objs := rpi-cirrus.o
143 snd-soc-rpi-proto-objs := rpi-proto.o
144 @@ -40,6 +41,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_GOOGLEVOICE
145 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
146 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC) += snd-soc-hifiberry-dacplusadc.o
147 obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO) += snd-soc-hifiberry-dacplusadcpro.o
148 +obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP) += snd-soc-hifiberry-dacplusdsp.o
149 obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_DAC) += snd-soc-justboom-dac.o
150 obj-$(CONFIG_SND_BCM2708_SOC_RPI_CIRRUS) += snd-soc-rpi-cirrus.o
151 obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o
153 +++ b/sound/soc/bcm/hifiberry_dacplusdsp.c
155 +// SPDX-License-Identifier: GPL-2.0
157 + * ASoC Driver for HiFiBerry DAC + DSP
159 + * Author: Joerg Schambacher <joscha@schambacher.com>
162 + * This program is free software; you can redistribute it and/or
163 + * modify it under the terms of the GNU General Public License
164 + * version 2 as published by the Free Software Foundation.
166 + * This program is distributed in the hope that it will be useful, but
167 + * WITHOUT ANY WARRANTY; without even the implied warranty of
168 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
169 + * General Public License for more details.
172 +#include <linux/init.h>
173 +#include <linux/module.h>
174 +#include <linux/of.h>
175 +#include <linux/platform_device.h>
176 +#include <sound/soc.h>
178 +static struct snd_soc_component_driver dacplusdsp_component_driver;
180 +static struct snd_soc_dai_driver dacplusdsp_dai = {
181 + .name = "dacplusdsp-hifi",
183 + .stream_name = "DAC+DSP Capture",
186 + .rates = SNDRV_PCM_RATE_CONTINUOUS,
187 + .formats = SNDRV_PCM_FMTBIT_S16_LE |
188 + SNDRV_PCM_FMTBIT_S24_LE |
189 + SNDRV_PCM_FMTBIT_S32_LE,
192 + .stream_name = "DACP+DSP Playback",
195 + .rates = SNDRV_PCM_RATE_CONTINUOUS,
196 + .formats = SNDRV_PCM_FMTBIT_S16_LE |
197 + SNDRV_PCM_FMTBIT_S24_LE |
198 + SNDRV_PCM_FMTBIT_S32_LE,
200 + .symmetric_rates = 1};
203 +static const struct of_device_id dacplusdsp_ids[] = {
205 + .compatible = "hifiberry,dacplusdsp",
208 +MODULE_DEVICE_TABLE(of, dacplusdsp_ids);
211 +static int dacplusdsp_platform_probe(struct platform_device *pdev)
215 + ret = snd_soc_register_component(&pdev->dev,
216 + &dacplusdsp_component_driver, &dacplusdsp_dai, 1);
218 + pr_alert("snd_soc_register_component failed\n");
225 +static int dacplusdsp_platform_remove(struct platform_device *pdev)
227 + snd_soc_unregister_component(&pdev->dev);
231 +static struct platform_driver dacplusdsp_driver = {
233 + .name = "hifiberry-dacplusdsp-codec",
234 + .of_match_table = of_match_ptr(dacplusdsp_ids),
236 + .probe = dacplusdsp_platform_probe,
237 + .remove = dacplusdsp_platform_remove,
240 +module_platform_driver(dacplusdsp_driver);
242 +MODULE_AUTHOR("Joerg Schambacher <joerg@i2audio.com>");
243 +MODULE_DESCRIPTION("ASoC Driver for HiFiBerry DAC+DSP");
244 +MODULE_LICENSE("GPL v2");
245 --- a/sound/soc/bcm/rpi-simple-soundcard.c
246 +++ b/sound/soc/bcm/rpi-simple-soundcard.c
247 @@ -136,6 +136,23 @@ static struct snd_rpi_simple_drvdata drv
248 .dai = snd_googlevoicehat_soundcard_dai,
251 +static struct snd_soc_dai_link snd_hifiberrydacplusdsp_soundcard_dai[] = {
253 + .name = "Hifiberry DAC+DSP SoundCard",
254 + .stream_name = "Hifiberry DAC+DSP SoundCard HiFi",
255 + .codec_dai_name = "dacplusdsp-hifi",
256 + .codec_name = "dacplusdsp-codec",
257 + .dai_fmt = SND_SOC_DAIFMT_I2S |
258 + SND_SOC_DAIFMT_NB_NF |
259 + SND_SOC_DAIFMT_CBS_CFS,
263 +static struct snd_rpi_simple_drvdata drvdata_hifiberrydacplusdsp = {
264 + .card_name = "snd_rpi_hifiberrydacplusdsp_soundcard",
265 + .dai = snd_hifiberrydacplusdsp_soundcard_dai,
268 static struct snd_soc_dai_link snd_hifiberry_amp_dai[] = {
270 .name = "HifiBerry AMP",
271 @@ -193,6 +210,8 @@ static const struct of_device_id snd_rpi
272 .data = (void *) &drvdata_adau1977 },
273 { .compatible = "googlevoicehat,googlevoicehat-soundcard",
274 .data = (void *) &drvdata_googlevoicehat },
275 + { .compatible = "hifiberrydacplusdsp,hifiberrydacplusdsp-soundcard",
276 + .data = (void *) &drvdata_hifiberrydacplusdsp },
277 { .compatible = "hifiberry,hifiberry-amp",
278 .data = (void *) &drvdata_hifiberry_amp },
279 { .compatible = "hifiberry,hifiberry-dac",