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)
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 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
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 \
31 hifiberry-digi-pro.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.
39 +Name: hifiberry-dacplusdsp
40 +Info: Configures the HifiBerry DAC+DSP audio card
41 +Load: dtoverlay=hifiberry-dacplusdsp
46 Info: Configures the HifiBerry Digi and Digi+ audio card
47 Load: dtoverlay=hifiberry-digi
49 +++ b/arch/arm/boot/dts/overlays/hifiberry-dacplusdsp-overlay.dts
51 +// Definitions for hifiberry DAC+DSP soundcard overlay
56 + compatible = "brcm,bcm2835";
69 + #sound-dai-cells = <0>;
70 + compatible = "hifiberry,dacplusdsp";
79 + compatible = "hifiberrydacplusdsp,hifiberrydacplusdsp-soundcard";
80 + i2s-controller = <&i2s>;
85 --- a/sound/soc/bcm/Kconfig
86 +++ b/sound/soc/bcm/Kconfig
87 @@ -56,6 +56,13 @@ config SND_BCM2708_SOC_HIFIBERRY_DACPLUS
89 Say Y or M if you want to add support for HifiBerry DAC+ADC PRO.
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
96 + Say Y or M if you want to add support for HifiBerry DSP-DAC.
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
120 +++ b/sound/soc/bcm/hifiberry_dacplusdsp.c
122 +// SPDX-License-Identifier: GPL-2.0
124 + * ASoC Driver for HiFiBerry DAC + DSP
126 + * Author: Joerg Schambacher <joscha@schambacher.com>
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.
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.
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>
145 +static struct snd_soc_component_driver dacplusdsp_component_driver;
147 +static struct snd_soc_dai_driver dacplusdsp_dai = {
148 + .name = "dacplusdsp-hifi",
150 + .stream_name = "DAC+DSP Capture",
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,
159 + .stream_name = "DACP+DSP Playback",
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,
167 + .symmetric_rates = 1};
170 +static const struct of_device_id dacplusdsp_ids[] = {
172 + .compatible = "hifiberry,dacplusdsp",
175 +MODULE_DEVICE_TABLE(of, dacplusdsp_ids);
178 +static int dacplusdsp_platform_probe(struct platform_device *pdev)
182 + ret = snd_soc_register_component(&pdev->dev,
183 + &dacplusdsp_component_driver, &dacplusdsp_dai, 1);
185 + pr_alert("snd_soc_register_component failed\n");
192 +static int dacplusdsp_platform_remove(struct platform_device *pdev)
194 + snd_soc_unregister_component(&pdev->dev);
198 +static struct platform_driver dacplusdsp_driver = {
200 + .name = "hifiberry-dacplusdsp-codec",
201 + .of_match_table = of_match_ptr(dacplusdsp_ids),
203 + .probe = dacplusdsp_platform_probe,
204 + .remove = dacplusdsp_platform_remove,
207 +module_platform_driver(dacplusdsp_driver);
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,
218 +static struct snd_soc_dai_link snd_hifiberrydacplusdsp_soundcard_dai[] = {
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,
230 +static struct snd_rpi_simple_drvdata drvdata_hifiberrydacplusdsp = {
231 + .card_name = "snd_rpi_hifiberrydacplusdsp_soundcard",
232 + .dai = snd_hifiberrydacplusdsp_soundcard_dai,
235 static struct snd_soc_dai_link snd_hifiberry_amp_dai[] = {
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",