Skip to content

Added driver for HiFiBerry Amp amplifier add-on board #659

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arch/arm/configs/bcmrpi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ CONFIG_SND_BCM2708_SOC_I2S=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
CONFIG_SND_BCM2708_SOC_RPI_DAC=m
CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC=m
CONFIG_SOUND_PRIME=m
Expand Down
20 changes: 20 additions & 0 deletions arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,20 @@ static struct i2c_board_info __initdata snd_wm8804_i2c_devices[] = {

#endif

#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP_MODULE)
static struct platform_device snd_hifiberry_amp_device = {
.name = "snd-hifiberry-amp",
.id = 0,
.num_resources = 0,
};

static struct i2c_board_info __initdata snd_tas5713_i2c_devices[] = {
{
I2C_BOARD_INFO("tas5713", 0x1b)
},
};
#endif

#if defined(CONFIG_SND_BCM2708_SOC_RPI_DAC) || defined(CONFIG_SND_BCM2708_SOC_RPI_DAC_MODULE)
static struct platform_device snd_rpi_dac_device = {
.name = "snd-rpi-dac",
Expand Down Expand Up @@ -852,6 +866,12 @@ void __init bcm2708_init(void)
i2c_register_board_info(1, snd_wm8804_i2c_devices, ARRAY_SIZE(snd_wm8804_i2c_devices));
#endif

#if defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP) || defined(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP_MODULE)
bcm_register_device(&snd_hifiberry_amp_device);
i2c_register_board_info(1, snd_tas5713_i2c_devices, ARRAY_SIZE(snd_tas5713_i2c_devices));
#endif


#if defined(CONFIG_SND_BCM2708_SOC_RPI_DAC) || defined(CONFIG_SND_BCM2708_SOC_RPI_DAC_MODULE)
bcm_register_device(&snd_rpi_dac_device);
bcm_register_device(&snd_pcm1794a_codec_device);
Expand Down
7 changes: 7 additions & 0 deletions sound/soc/bcm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ config SND_BCM2708_SOC_HIFIBERRY_DIGI
help
Say Y or M if you want to add support for HifiBerry Digi S/PDIF output board.

config SND_BCM2708_SOC_HIFIBERRY_AMP
tristate "Support for the HifiBerry Amp"
depends on SND_BCM2708_SOC_I2S
select SND_SOC_TAS5713
help
Say Y or M if you want to add support for the HifiBerry Amp amplifier board.

config SND_BCM2708_SOC_RPI_DAC
tristate "Support for RPi-DAC"
depends on SND_BCM2708_SOC_I2S
Expand Down
2 changes: 2 additions & 0 deletions sound/soc/bcm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd-soc-bcm2708-i2s.o
snd-soc-hifiberry-dac-objs := hifiberry_dac.o
snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
snd-soc-hifiberry-digi-objs := hifiberry_digi.o
snd-soc-hifiberry-amp-objs := hifiberry_amp.o
snd-soc-rpi-dac-objs := rpi-dac.o
snd-soc-iqaudio-dac-objs := iqaudio-dac.o

obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC) += snd-soc-hifiberry-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI) += snd-soc-hifiberry-digi.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP) += snd-soc-hifiberry-amp.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_DAC) += snd-soc-rpi-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_IQAUDIO_DAC) += snd-soc-iqaudio-dac.o
106 changes: 106 additions & 0 deletions sound/soc/bcm/hifiberry_amp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* ASoC Driver for HifiBerry AMP
*
* Author: Sebastian Eickhoff <[email protected]>
* Copyright 2014
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*/

#include <linux/module.h>
#include <linux/platform_device.h>

#include <sound/core.h>
#include <sound/pcm.h>
#include <sound/pcm_params.h>
#include <sound/soc.h>
#include <sound/jack.h>

static int snd_rpi_hifiberry_amp_init(struct snd_soc_pcm_runtime *rtd)
{
// ToDo: init of the dsp-registers.
return 0;
}

static int snd_rpi_hifiberry_amp_hw_params( struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params )
{
struct snd_soc_pcm_runtime *rtd = substream->private_data;
struct snd_soc_dai *cpu_dai = rtd->cpu_dai;

return snd_soc_dai_set_bclk_ratio(cpu_dai, 64);
}

static struct snd_soc_ops snd_rpi_hifiberry_amp_ops = {
.hw_params = snd_rpi_hifiberry_amp_hw_params,
};

static struct snd_soc_dai_link snd_rpi_hifiberry_amp_dai[] = {
{
.name = "HifiBerry AMP",
.stream_name = "HifiBerry AMP HiFi",
.cpu_dai_name = "bcm2708-i2s.0",
.codec_dai_name = "tas5713-hifi",
.platform_name = "bcm2708-i2s.0",
.codec_name = "tas5713.1-001b",
.dai_fmt = SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS,
.ops = &snd_rpi_hifiberry_amp_ops,
.init = snd_rpi_hifiberry_amp_init,
},
};


static struct snd_soc_card snd_rpi_hifiberry_amp = {
.name = "snd_rpi_hifiberry_amp",
.dai_link = snd_rpi_hifiberry_amp_dai,
.num_links = ARRAY_SIZE(snd_rpi_hifiberry_amp_dai),
};


static int snd_rpi_hifiberry_amp_probe(struct platform_device *pdev)
{
int ret = 0;

snd_rpi_hifiberry_amp.dev = &pdev->dev;

ret = snd_soc_register_card(&snd_rpi_hifiberry_amp);

if (ret != 0) {
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);
}

return ret;
}


static int snd_rpi_hifiberry_amp_remove(struct platform_device *pdev)
{
return snd_soc_unregister_card(&snd_rpi_hifiberry_amp);
}


static struct platform_driver snd_rpi_hifiberry_amp_driver = {
.driver = {
.name = "snd-hifiberry-amp",
.owner = THIS_MODULE,
},
.probe = snd_rpi_hifiberry_amp_probe,
.remove = snd_rpi_hifiberry_amp_remove,
};


module_platform_driver(snd_rpi_hifiberry_amp_driver);


MODULE_AUTHOR("Sebastian Eickhoff <[email protected]>");
MODULE_DESCRIPTION("ASoC driver for HiFiBerry-AMP");
MODULE_LICENSE("GPL v2");
4 changes: 4 additions & 0 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_STA529 if I2C
select SND_SOC_STAC9766 if SND_SOC_AC97_BUS
select SND_SOC_TAS5086 if I2C
select SND_SOC_TAS5713 if I2C
select SND_SOC_TLV320AIC23 if I2C
select SND_SOC_TLV320AIC26 if SPI_MASTER
select SND_SOC_TLV320AIC32X4 if I2C
Expand Down Expand Up @@ -364,6 +365,9 @@ config SND_SOC_STAC9766
config SND_SOC_TAS5086
tristate

config SND_SOC_TAS5713
tristate

config SND_SOC_TLV320AIC23
tristate

Expand Down
2 changes: 2 additions & 0 deletions sound/soc/codecs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ snd-soc-sta32x-objs := sta32x.o
snd-soc-sta529-objs := sta529.o
snd-soc-stac9766-objs := stac9766.o
snd-soc-tas5086-objs := tas5086.o
snd-soc-tas5713-objs := tas5713.o
snd-soc-tlv320aic23-objs := tlv320aic23.o
snd-soc-tlv320aic26-objs := tlv320aic26.o
snd-soc-tlv320aic3x-objs := tlv320aic3x.o
Expand Down Expand Up @@ -198,6 +199,7 @@ obj-$(CONFIG_SND_SOC_STA32X) += snd-soc-sta32x.o
obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o
obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o
obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o
obj-$(CONFIG_SND_SOC_TAS5713) += snd-soc-tas5713.o
obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o
obj-$(CONFIG_SND_SOC_TLV320AIC26) += snd-soc-tlv320aic26.o
obj-$(CONFIG_SND_SOC_TLV320AIC3X) += snd-soc-tlv320aic3x.o
Expand Down
Loading