Skip to content

Commit 9f49dc3

Browse files
Daniel Matuschekpopcornmix
Daniel Matuschek
authored andcommitted
Added driver for HiFiBerry Amp amplifier add-on board
The driver contains a low-level hardware driver for the TAS5713 and the drivers for the Raspberry Pi I2S subsystem. TAS5713: return error if initialisation fails Existing TAS5713 driver logs errors during initialisation, but does not return an error code. Therefore even if initialisation fails, the driver will still be loaded, but won't work. This patch fixes this. I2C communication error will now reported correctly by a non-zero return code. HiFiBerry Amp: fix device-tree problems Some code to load the driver based on device-tree-overlays was missing. This is added by this patch. hifiberry-amp: Adjust for ALSA object refactoring See: #1775
1 parent d124a5e commit 9f49dc3

File tree

7 files changed

+725
-0
lines changed

7 files changed

+725
-0
lines changed

sound/soc/bcm/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ config SND_BCM2708_SOC_HIFIBERRY_DIGI
3838
help
3939
Say Y or M if you want to add support for HifiBerry Digi S/PDIF output board.
4040

41+
config SND_BCM2708_SOC_HIFIBERRY_AMP
42+
tristate "Support for the HifiBerry Amp"
43+
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
44+
select SND_SOC_TAS5713
45+
help
46+
Say Y or M if you want to add support for the HifiBerry Amp amplifier board.
47+
4148
config SND_BCM2708_SOC_RPI_DAC
4249
tristate "Support for RPi-DAC"
4350
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
@@ -9,12 +9,14 @@ snd-soc-cygnus-objs := cygnus-pcm.o cygnus-ssp.o
99
obj-$(CONFIG_SND_SOC_CYGNUS) += snd-soc-cygnus.o
1010

1111
# BCM2708 Machine Support
12+
snd-soc-hifiberry-amp-objs := hifiberry_amp.o
1213
snd-soc-hifiberry-dac-objs := hifiberry_dac.o
1314
snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
1415
snd-soc-hifiberry-digi-objs := hifiberry_digi.o
1516
snd-soc-rpi-dac-objs := rpi-dac.o
1617
snd-soc-iqaudio-dac-objs := iqaudio-dac.o
1718

19+
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP) += snd-soc-hifiberry-amp.o
1820
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
1921
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
2022
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) += snd-soc-hifiberry-digi.o

sound/soc/bcm/hifiberry_amp.c

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* ASoC Driver for HifiBerry AMP
3+
*
4+
* Author: Sebastian Eickhoff <[email protected]>
5+
* Copyright 2014
6+
*
7+
* This program is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU General Public License
9+
* version 2 as published by the Free Software Foundation.
10+
*
11+
* This program is distributed in the hope that it will be useful, but
12+
* WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* General Public License for more details.
15+
*/
16+
17+
#include <linux/module.h>
18+
#include <linux/platform_device.h>
19+
20+
#include <sound/core.h>
21+
#include <sound/pcm.h>
22+
#include <sound/pcm_params.h>
23+
#include <sound/soc.h>
24+
#include <sound/jack.h>
25+
26+
static int snd_rpi_hifiberry_amp_init(struct snd_soc_pcm_runtime *rtd)
27+
{
28+
// ToDo: init of the dsp-registers.
29+
return 0;
30+
}
31+
32+
static int snd_rpi_hifiberry_amp_hw_params( struct snd_pcm_substream *substream,
33+
struct snd_pcm_hw_params *params )
34+
{
35+
struct snd_soc_pcm_runtime *rtd = substream->private_data;
36+
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
37+
38+
return snd_soc_dai_set_bclk_ratio(cpu_dai, 64);
39+
}
40+
41+
static struct snd_soc_ops snd_rpi_hifiberry_amp_ops = {
42+
.hw_params = snd_rpi_hifiberry_amp_hw_params,
43+
};
44+
45+
static struct snd_soc_dai_link snd_rpi_hifiberry_amp_dai[] = {
46+
{
47+
.name = "HifiBerry AMP",
48+
.stream_name = "HifiBerry AMP HiFi",
49+
.cpu_dai_name = "bcm2708-i2s.0",
50+
.codec_dai_name = "tas5713-hifi",
51+
.platform_name = "bcm2708-i2s.0",
52+
.codec_name = "tas5713.1-001b",
53+
.dai_fmt = SND_SOC_DAIFMT_I2S |
54+
SND_SOC_DAIFMT_NB_NF |
55+
SND_SOC_DAIFMT_CBS_CFS,
56+
.ops = &snd_rpi_hifiberry_amp_ops,
57+
.init = snd_rpi_hifiberry_amp_init,
58+
},
59+
};
60+
61+
62+
static struct snd_soc_card snd_rpi_hifiberry_amp = {
63+
.name = "snd_rpi_hifiberry_amp",
64+
.driver_name = "HifiberryAmp",
65+
.owner = THIS_MODULE,
66+
.dai_link = snd_rpi_hifiberry_amp_dai,
67+
.num_links = ARRAY_SIZE(snd_rpi_hifiberry_amp_dai),
68+
};
69+
70+
static const struct of_device_id snd_rpi_hifiberry_amp_of_match[] = {
71+
{ .compatible = "hifiberry,hifiberry-amp", },
72+
{},
73+
};
74+
MODULE_DEVICE_TABLE(of, snd_rpi_hifiberry_amp_of_match);
75+
76+
77+
static int snd_rpi_hifiberry_amp_probe(struct platform_device *pdev)
78+
{
79+
int ret = 0;
80+
81+
snd_rpi_hifiberry_amp.dev = &pdev->dev;
82+
83+
if (pdev->dev.of_node) {
84+
struct device_node *i2s_node;
85+
struct snd_soc_dai_link *dai = &snd_rpi_hifiberry_amp_dai[0];
86+
i2s_node = of_parse_phandle(pdev->dev.of_node,
87+
"i2s-controller", 0);
88+
89+
if (i2s_node) {
90+
dai->cpu_dai_name = NULL;
91+
dai->cpu_of_node = i2s_node;
92+
dai->platform_name = NULL;
93+
dai->platform_of_node = i2s_node;
94+
}
95+
}
96+
97+
ret = snd_soc_register_card(&snd_rpi_hifiberry_amp);
98+
99+
if (ret != 0) {
100+
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
101+
}
102+
103+
return ret;
104+
}
105+
106+
107+
static int snd_rpi_hifiberry_amp_remove(struct platform_device *pdev)
108+
{
109+
return snd_soc_unregister_card(&snd_rpi_hifiberry_amp);
110+
}
111+
112+
113+
static struct platform_driver snd_rpi_hifiberry_amp_driver = {
114+
.driver = {
115+
.name = "snd-hifiberry-amp",
116+
.owner = THIS_MODULE,
117+
.of_match_table = snd_rpi_hifiberry_amp_of_match,
118+
},
119+
.probe = snd_rpi_hifiberry_amp_probe,
120+
.remove = snd_rpi_hifiberry_amp_remove,
121+
};
122+
123+
124+
module_platform_driver(snd_rpi_hifiberry_amp_driver);
125+
126+
127+
MODULE_AUTHOR("Sebastian Eickhoff <[email protected]>");
128+
MODULE_DESCRIPTION("ASoC driver for HiFiBerry-AMP");
129+
MODULE_LICENSE("GPL v2");

sound/soc/codecs/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ config SND_SOC_ALL_CODECS
139139
select SND_SOC_TFA9879 if I2C
140140
select SND_SOC_TLV320AIC23_I2C if I2C
141141
select SND_SOC_TLV320AIC23_SPI if SPI_MASTER
142+
select SND_SOC_TAS5713 if I2C
142143
select SND_SOC_TLV320AIC26 if SPI_MASTER
143144
select SND_SOC_TLV320AIC31XX if I2C
144145
select SND_SOC_TLV320AIC32X4_I2C if I2C
@@ -821,6 +822,9 @@ config SND_SOC_TFA9879
821822
tristate "NXP Semiconductors TFA9879 amplifier"
822823
depends on I2C
823824

825+
config SND_SOC_TAS5713
826+
tristate
827+
824828
config SND_SOC_TLV320AIC23
825829
tristate
826830

sound/soc/codecs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ snd-soc-tas5086-objs := tas5086.o
144144
snd-soc-tas571x-objs := tas571x.o
145145
snd-soc-tas5720-objs := tas5720.o
146146
snd-soc-tfa9879-objs := tfa9879.o
147+
snd-soc-tas5713-objs := tas5713.o
147148
snd-soc-tlv320aic23-objs := tlv320aic23.o
148149
snd-soc-tlv320aic23-i2c-objs := tlv320aic23-i2c.o
149150
snd-soc-tlv320aic23-spi-objs := tlv320aic23-spi.o
@@ -366,6 +367,7 @@ obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o
366367
obj-$(CONFIG_SND_SOC_TAS571X) += snd-soc-tas571x.o
367368
obj-$(CONFIG_SND_SOC_TAS5720) += snd-soc-tas5720.o
368369
obj-$(CONFIG_SND_SOC_TFA9879) += snd-soc-tfa9879.o
370+
obj-$(CONFIG_SND_SOC_TAS5713) += snd-soc-tas5713.o
369371
obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o
370372
obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o
371373
obj-$(CONFIG_SND_SOC_TLV320AIC23_SPI) += snd-soc-tlv320aic23-spi.o

0 commit comments

Comments
 (0)