Skip to content

Commit 41f5c50

Browse files
committed
Merge pull request #544 from iqaudio/rpi-3.10.y
Add IQaudIO Sound Card support for Raspberry Pi
2 parents 9cecb89 + 9f6cf35 commit 41f5c50

File tree

10 files changed

+980
-12
lines changed

10 files changed

+980
-12
lines changed

arch/arm/configs/bcmrpi_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ CONFIG_SND_BCM2708_SOC_I2S=m
744744
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
745745
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
746746
CONFIG_SND_BCM2708_SOC_RPI_DAC=m
747+
CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC=m
747748
CONFIG_SOUND_PRIME=m
748749
CONFIG_HIDRAW=y
749750
CONFIG_HID_A4TECH=m

arch/arm/mach-bcm2708/bcm2708.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,22 @@ static struct platform_device snd_pcm1794a_codec_device = {
685685
};
686686
#endif
687687

688+
689+
#if defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) || defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC_MODULE)
690+
static struct platform_device snd_rpi_iqaudio_dac_device = {
691+
.name = "snd-rpi-iqaudio-dac",
692+
.id = 0,
693+
.num_resources = 0,
694+
};
695+
696+
// Use the actual device name rather than generic driver name
697+
static struct i2c_board_info __initdata snd_pcm512x_i2c_devices[] = {
698+
{
699+
I2C_BOARD_INFO("pcm5122", 0x4c)
700+
},
701+
};
702+
#endif
703+
688704
int __init bcm_register_device(struct platform_device *pdev)
689705
{
690706
int ret;
@@ -831,6 +847,12 @@ void __init bcm2708_init(void)
831847
bcm_register_device(&snd_pcm1794a_codec_device);
832848
#endif
833849

850+
#if defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) || defined(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC_MODULE)
851+
bcm_register_device(&snd_rpi_iqaudio_dac_device);
852+
i2c_register_board_info(1, snd_pcm512x_i2c_devices, ARRAY_SIZE(snd_pcm512x_i2c_devices));
853+
#endif
854+
855+
834856
for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
835857
struct amba_device *d = amba_devs[i];
836858
amba_device_register(d, &iomem_resource);

sound/soc/bcm/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,10 @@ config SND_BCM2708_SOC_RPI_DAC
2929
select SND_SOC_PCM1794A
3030
help
3131
Say Y or M if you want to add support for RPi-DAC.
32+
33+
config SND_BCM2708_SOC_IQAUDIO_DAC
34+
tristate "Support for IQaudIO-DAC"
35+
depends on SND_BCM2708_SOC_I2S
36+
select SND_SOC_PCM512x
37+
help
38+
Say Y or M if you want to add support for IQaudIO-DAC.

sound/soc/bcm/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd-soc-bcm2708-i2s.o
77
snd-soc-hifiberry-dac-objs := hifiberry_dac.o
88
snd-soc-hifiberry-digi-objs := hifiberry_digi.o
99
snd-soc-rpi-dac-objs := rpi-dac.o
10+
snd-soc-iqaudio-dac-objs := iqaudio-dac.o
1011

1112
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
1213
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) += snd-soc-hifiberry-digi.o
1314
obj-$(CONFIG_SND_BCM2708_SOC_RPI_DAC) += snd-soc-rpi-dac.o
15+
obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
16+

sound/soc/bcm/iqaudio-dac.c

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
* ASoC Driver for IQaudIO DAC
3+
*
4+
* Author: Florian Meier <[email protected]>
5+
* Copyright 2013
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_iqaudio_dac_init(struct snd_soc_pcm_runtime *rtd)
27+
{
28+
// NOT USED struct snd_soc_codec *codec = rtd->codec;
29+
30+
return 0;
31+
}
32+
33+
static int snd_rpi_iqaudio_dac_hw_params(struct snd_pcm_substream *substream,
34+
struct snd_pcm_hw_params *params)
35+
{
36+
struct snd_soc_pcm_runtime *rtd = substream->private_data;
37+
// NOT USED struct snd_soc_dai *codec_dai = rtd->codec_dai;
38+
// NOT USED struct snd_soc_codec *codec = rtd->codec;
39+
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;
40+
41+
unsigned int sample_bits =
42+
snd_pcm_format_physical_width(params_format(params));
43+
44+
return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
45+
}
46+
47+
/* machine stream operations */
48+
static struct snd_soc_ops snd_rpi_iqaudio_dac_ops = {
49+
.hw_params = snd_rpi_iqaudio_dac_hw_params,
50+
};
51+
52+
static struct snd_soc_dai_link snd_rpi_iqaudio_dac_dai[] = {
53+
{
54+
.name = "IQaudIO DAC",
55+
.stream_name = "IQaudIO DAC HiFi",
56+
.cpu_dai_name = "bcm2708-i2s.0",
57+
.codec_dai_name = "pcm512x-hifi",
58+
.platform_name = "bcm2708-i2s.0",
59+
.codec_name = "pcm512x.1-004c",
60+
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
61+
SND_SOC_DAIFMT_CBS_CFS,
62+
.ops = &snd_rpi_iqaudio_dac_ops,
63+
.init = snd_rpi_iqaudio_dac_init,
64+
},
65+
};
66+
67+
/* audio machine driver */
68+
static struct snd_soc_card snd_rpi_iqaudio_dac = {
69+
.name = "snd_rpi_iqaudio_dac",
70+
.dai_link = snd_rpi_iqaudio_dac_dai,
71+
.num_links = ARRAY_SIZE(snd_rpi_iqaudio_dac_dai),
72+
};
73+
74+
static int snd_rpi_iqaudio_dac_probe(struct platform_device *pdev)
75+
{
76+
int ret = 0;
77+
78+
snd_rpi_iqaudio_dac.dev = &pdev->dev;
79+
ret = snd_soc_register_card(&snd_rpi_iqaudio_dac);
80+
if (ret)
81+
dev_err(&pdev->dev,
82+
"snd_soc_register_card() failed: %d\n", ret);
83+
84+
return ret;
85+
}
86+
87+
static int snd_rpi_iqaudio_dac_remove(struct platform_device *pdev)
88+
{
89+
return snd_soc_unregister_card(&snd_rpi_iqaudio_dac);
90+
}
91+
92+
static const struct of_device_id iqaudio_of_match[] = {
93+
{ .compatible = "iqaudio,iqaudio-dac", },
94+
{},
95+
};
96+
97+
static struct platform_driver snd_rpi_iqaudio_dac_driver = {
98+
.driver = {
99+
.name = "snd-rpi-iqaudio-dac",
100+
.owner = THIS_MODULE,
101+
.of_match_table = iqaudio_of_match,
102+
},
103+
.probe = snd_rpi_iqaudio_dac_probe,
104+
.remove = snd_rpi_iqaudio_dac_remove,
105+
};
106+
107+
module_platform_driver(snd_rpi_iqaudio_dac_driver);
108+
109+
MODULE_AUTHOR("Florian Meier <[email protected]>");
110+
MODULE_DESCRIPTION("ASoC Driver for IQAudio DAC");
111+
MODULE_LICENSE("GPL v2");

sound/soc/codecs/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ config SND_SOC_ALL_CODECS
5757
select SND_SOC_PCM3008
5858
select SND_SOC_PCM1794A
5959
select SND_SOC_PCM5102A
60+
select SND_SOC_PCM512x if SND_SOC_I2C_AND_SPI
6061
select SND_SOC_RT5631 if I2C
6162
select SND_SOC_SGTL5000 if I2C
6263
select SND_SOC_SI476X if MFD_SI476X_CORE
@@ -301,6 +302,9 @@ config SND_SOC_PCM1794A
301302
config SND_SOC_PCM5102A
302303
tristate
303304

305+
config SND_SOC_PCM512x
306+
tristate
307+
304308
config SND_SOC_RT5631
305309
tristate
306310

sound/soc/codecs/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ snd-soc-omap-hdmi-codec-objs := omap-hdmi.o
4545
snd-soc-pcm3008-objs := pcm3008.o
4646
snd-soc-pcm1794a-objs := pcm1794a.o
4747
snd-soc-pcm5102a-objs := pcm5102a.o
48+
snd-soc-pcm512x-objs := pcm512x.o
4849
snd-soc-rt5631-objs := rt5631.o
4950
snd-soc-sgtl5000-objs := sgtl5000.o
5051
snd-soc-alc5623-objs := alc5623.o
@@ -174,6 +175,7 @@ obj-$(CONFIG_SND_SOC_OMAP_HDMI_CODEC) += snd-soc-omap-hdmi-codec.o
174175
obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o
175176
obj-$(CONFIG_SND_SOC_PCM1794A) += snd-soc-pcm1794a.o
176177
obj-$(CONFIG_SND_SOC_PCM5102A) += snd-soc-pcm5102a.o
178+
obj-$(CONFIG_SND_SOC_PCM512x) += snd-soc-pcm512x.o
177179
obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o
178180
obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o
179181
obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o

0 commit comments

Comments
 (0)