Skip to content

Commit 3bcc0d7

Browse files
j-schambacherPhil Elwell
authored and
Phil Elwell
committed
Add Hifiberry DAC+DSP soundcard driver (#3224)
Adds the driver for the Hifiberry DAC+DSP. It supports capture and playback depending on the DSP firmware. Signed-off-by: Joerg Schambacher <[email protected]>
1 parent 6742f62 commit 3bcc0d7

11 files changed

+176
-18
lines changed

arch/arm/boot/dts/overlays/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
5454
hifiberry-dacplus.dtbo \
5555
hifiberry-dacplusadc.dtbo \
5656
hifiberry-dacplusadcpro.dtbo \
57+
hifiberry-dacplusdsp.dtbo \
5758
hifiberry-digi.dtbo \
5859
hifiberry-digi-pro.dtbo \
5960
hy28a.dtbo \

arch/arm/boot/dts/overlays/README

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,12 @@ Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec
904904
master for bit clock and frame clock.
905905

906906

907+
Name: hifiberry-dacplusdsp
908+
Info: Configures the HifiBerry DAC+DSP audio card
909+
Load: dtoverlay=hifiberry-dacplusdsp
910+
Params: <None>
911+
912+
907913
Name: hifiberry-digi
908914
Info: Configures the HifiBerry Digi and Digi+ audio card
909915
Load: dtoverlay=hifiberry-digi
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Definitions for hifiberry DAC+DSP soundcard overlay
2+
/dts-v1/;
3+
/plugin/;
4+
5+
/ {
6+
compatible = "brcm,bcm2835";
7+
8+
fragment@0 {
9+
target = <&i2s>;
10+
__overlay__ {
11+
status = "okay";
12+
};
13+
};
14+
15+
fragment@1 {
16+
target-path = "/";
17+
__overlay__ {
18+
dacplusdsp-codec {
19+
#sound-dai-cells = <0>;
20+
compatible = "hifiberry,dacplusdsp";
21+
status = "okay";
22+
};
23+
};
24+
};
25+
26+
fragment@2 {
27+
target = <&sound>;
28+
__overlay__ {
29+
compatible = "hifiberrydacplusdsp,hifiberrydacplusdsp-soundcard";
30+
i2s-controller = <&i2s>;
31+
status = "okay";
32+
};
33+
};
34+
};

arch/arm/configs/bcm2709_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
964964
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
965965
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC=m
966966
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO=m
967+
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP=m
967968
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
968969
CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
969970
CONFIG_SND_BCM2708_SOC_RPI_CIRRUS=m

arch/arm/configs/bcm2711_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
931931
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
932932
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC=m
933933
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO=m
934+
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP=m
934935
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
935936
CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
936937
CONFIG_SND_BCM2708_SOC_RPI_CIRRUS=m

arch/arm/configs/bcmrpi_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
956956
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
957957
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC=m
958958
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO=m
959+
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP=m
959960
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
960961
CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
961962
CONFIG_SND_BCM2708_SOC_RPI_CIRRUS=m

sound/soc/bcm/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ config SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO
5959
help
6060
Say Y or M if you want to add support for HifiBerry DAC+ADC PRO.
6161

62+
config SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP
63+
tristate "Support for HifiBerry DAC+DSP"
64+
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
65+
select SND_RPI_SIMPLE_SOUNDCARD
66+
help
67+
Say Y or M if you want to add support for HifiBerry DSP-DAC.
68+
6269
config SND_BCM2708_SOC_HIFIBERRY_DIGI
6370
tristate "Support for HifiBerry Digi"
6471
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S

sound/soc/bcm/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ snd-soc-googlevoicehat-codec-objs := googlevoicehat-codec.o
1616
snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
1717
snd-soc-hifiberry-dacplusadc-objs := hifiberry_dacplusadc.o
1818
snd-soc-hifiberry-dacplusadcpro-objs := hifiberry_dacplusadcpro.o
19+
snd-soc-hifiberry-dacplusdsp-objs := hifiberry_dacplusdsp.o
1920
snd-soc-justboom-dac-objs := justboom-dac.o
2021
snd-soc-rpi-cirrus-objs := rpi-cirrus.o
2122
snd-soc-rpi-proto-objs := rpi-proto.o
@@ -41,6 +42,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD) += snd-soc-googlevoiceha
4142
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
4243
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC) += snd-soc-hifiberry-dacplusadc.o
4344
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO) += snd-soc-hifiberry-dacplusadcpro.o
45+
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP) += snd-soc-hifiberry-dacplusdsp.o
4446
obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_DAC) += snd-soc-justboom-dac.o
4547
obj-$(CONFIG_SND_BCM2708_SOC_RPI_CIRRUS) += snd-soc-rpi-cirrus.o
4648
obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o

sound/soc/bcm/hifiberry_dacplusadcpro.c

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -445,29 +445,21 @@ static struct snd_soc_ops snd_rpi_hifiberry_dacplusadcpro_ops = {
445445
.shutdown = snd_rpi_hifiberry_dacplusadcpro_shutdown,
446446
};
447447

448-
static struct snd_soc_dai_link_component snd_rpi_hifiberry_dacplusadcpro_codecs[] = {
449-
{
450-
.name = "pcm512x.1-004d",
451-
.dai_name = "pcm512x-hifi",
452-
},
453-
{
454-
.name = "pcm186x.1-004a",
455-
.dai_name = "pcm1863-aif",
456-
},
457-
};
448+
SND_SOC_DAILINK_DEFS(hifi,
449+
DAILINK_COMP_ARRAY(COMP_CPU("bcm2708-i2s.0")),
450+
DAILINK_COMP_ARRAY(COMP_CODEC("pcm512x.1-004d", "pcm512x-hifi"),
451+
COMP_CODEC("pcm186x.1-004a", "pcm1863-aif")),
452+
DAILINK_COMP_ARRAY(COMP_PLATFORM("bcm2708-i2s.0")));
458453

459454
static struct snd_soc_dai_link snd_rpi_hifiberry_dacplusadcpro_dai[] = {
460455
{
461456
.name = "HiFiBerry DAC+ADC PRO",
462457
.stream_name = "HiFiBerry DAC+ADC PRO HiFi",
463-
.cpu_dai_name = "bcm2708-i2s.0",
464-
.platform_name = "bcm2708-i2s.0",
465-
.codecs = snd_rpi_hifiberry_dacplusadcpro_codecs,
466-
.num_codecs = 2,
467458
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
468459
SND_SOC_DAIFMT_CBS_CFS,
469460
.ops = &snd_rpi_hifiberry_dacplusadcpro_ops,
470461
.init = snd_rpi_hifiberry_dacplusadcpro_init,
462+
SND_SOC_DAILINK_REG(hifi),
471463
},
472464
};
473465

@@ -495,10 +487,10 @@ static int snd_rpi_hifiberry_dacplusadcpro_probe(struct platform_device *pdev)
495487
"i2s-controller", 0);
496488
if (i2s_node) {
497489
for (i = 0; i < card->num_links; i++) {
498-
dai->cpu_dai_name = NULL;
499-
dai->cpu_of_node = i2s_node;
500-
dai->platform_name = NULL;
501-
dai->platform_of_node = i2s_node;
490+
dai->cpus->dai_name = NULL;
491+
dai->cpus->of_node = i2s_node;
492+
dai->platforms->name = NULL;
493+
dai->platforms->of_node = i2s_node;
502494
}
503495
}
504496
}

sound/soc/bcm/hifiberry_dacplusdsp.c

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* ASoC Driver for HiFiBerry DAC + DSP
4+
*
5+
* Author: Joerg Schambacher <[email protected]>
6+
* Copyright 2018
7+
*
8+
* This program is free software; you can redistribute it and/or
9+
* modify it under the terms of the GNU General Public License
10+
* version 2 as published by the Free Software Foundation.
11+
*
12+
* This program is distributed in the hope that it will be useful, but
13+
* WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
* General Public License for more details.
16+
*/
17+
18+
#include <linux/init.h>
19+
#include <linux/module.h>
20+
#include <linux/of.h>
21+
#include <linux/platform_device.h>
22+
#include <sound/soc.h>
23+
24+
static struct snd_soc_component_driver dacplusdsp_component_driver;
25+
26+
static struct snd_soc_dai_driver dacplusdsp_dai = {
27+
.name = "dacplusdsp-hifi",
28+
.capture = {
29+
.stream_name = "DAC+DSP Capture",
30+
.channels_min = 2,
31+
.channels_max = 2,
32+
.rates = SNDRV_PCM_RATE_CONTINUOUS,
33+
.formats = SNDRV_PCM_FMTBIT_S16_LE |
34+
SNDRV_PCM_FMTBIT_S24_LE |
35+
SNDRV_PCM_FMTBIT_S32_LE,
36+
},
37+
.playback = {
38+
.stream_name = "DACP+DSP Playback",
39+
.channels_min = 2,
40+
.channels_max = 2,
41+
.rates = SNDRV_PCM_RATE_CONTINUOUS,
42+
.formats = SNDRV_PCM_FMTBIT_S16_LE |
43+
SNDRV_PCM_FMTBIT_S24_LE |
44+
SNDRV_PCM_FMTBIT_S32_LE,
45+
},
46+
.symmetric_rates = 1};
47+
48+
#ifdef CONFIG_OF
49+
static const struct of_device_id dacplusdsp_ids[] = {
50+
{
51+
.compatible = "hifiberry,dacplusdsp",
52+
},
53+
{} };
54+
MODULE_DEVICE_TABLE(of, dacplusdsp_ids);
55+
#endif
56+
57+
static int dacplusdsp_platform_probe(struct platform_device *pdev)
58+
{
59+
int ret;
60+
61+
ret = snd_soc_register_component(&pdev->dev,
62+
&dacplusdsp_component_driver, &dacplusdsp_dai, 1);
63+
if (ret) {
64+
pr_alert("snd_soc_register_component failed\n");
65+
return ret;
66+
}
67+
68+
return 0;
69+
}
70+
71+
static int dacplusdsp_platform_remove(struct platform_device *pdev)
72+
{
73+
snd_soc_unregister_component(&pdev->dev);
74+
return 0;
75+
}
76+
77+
static struct platform_driver dacplusdsp_driver = {
78+
.driver = {
79+
.name = "hifiberry-dacplusdsp-codec",
80+
.of_match_table = of_match_ptr(dacplusdsp_ids),
81+
},
82+
.probe = dacplusdsp_platform_probe,
83+
.remove = dacplusdsp_platform_remove,
84+
};
85+
86+
module_platform_driver(dacplusdsp_driver);
87+
88+
MODULE_AUTHOR("Joerg Schambacher <[email protected]>");
89+
MODULE_DESCRIPTION("ASoC Driver for HiFiBerry DAC+DSP");
90+
MODULE_LICENSE("GPL v2");

sound/soc/bcm/rpi-simple-soundcard.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,27 @@ static struct snd_rpi_simple_drvdata drvdata_googlevoicehat = {
144144
.dai = snd_googlevoicehat_soundcard_dai,
145145
};
146146

147+
SND_SOC_DAILINK_DEFS(hifiberry_dacplusdsp,
148+
DAILINK_COMP_ARRAY(COMP_EMPTY()),
149+
DAILINK_COMP_ARRAY(COMP_CODEC("dacplusdsp-codec", "dacplusdsp-hifi")),
150+
DAILINK_COMP_ARRAY(COMP_EMPTY()));
151+
152+
static struct snd_soc_dai_link snd_hifiberrydacplusdsp_soundcard_dai[] = {
153+
{
154+
.name = "Hifiberry DAC+DSP SoundCard",
155+
.stream_name = "Hifiberry DAC+DSP SoundCard HiFi",
156+
.dai_fmt = SND_SOC_DAIFMT_I2S |
157+
SND_SOC_DAIFMT_NB_NF |
158+
SND_SOC_DAIFMT_CBS_CFS,
159+
SND_SOC_DAILINK_REG(hifiberry_dacplusdsp),
160+
},
161+
};
162+
163+
static struct snd_rpi_simple_drvdata drvdata_hifiberrydacplusdsp = {
164+
.card_name = "snd_rpi_hifiberrydacplusdsp_soundcard",
165+
.dai = snd_hifiberrydacplusdsp_soundcard_dai,
166+
};
167+
147168
SND_SOC_DAILINK_DEFS(hifiberry_amp,
148169
DAILINK_COMP_ARRAY(COMP_EMPTY()),
149170
DAILINK_COMP_ARRAY(COMP_CODEC("tas5713.1-001b", "tas5713-hifi")),
@@ -213,6 +234,8 @@ static const struct of_device_id snd_rpi_simple_of_match[] = {
213234
.data = (void *) &drvdata_adau1977 },
214235
{ .compatible = "googlevoicehat,googlevoicehat-soundcard",
215236
.data = (void *) &drvdata_googlevoicehat },
237+
{ .compatible = "hifiberrydacplusdsp,hifiberrydacplusdsp-soundcard",
238+
.data = (void *) &drvdata_hifiberrydacplusdsp },
216239
{ .compatible = "hifiberry,hifiberry-amp",
217240
.data = (void *) &drvdata_hifiberry_amp },
218241
{ .compatible = "hifiberry,hifiberry-dac",

0 commit comments

Comments
 (0)