Skip to content

add Hifiberry DAC+DSP soundcard driver #3224

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 12, 2019
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/boot/dts/overlays/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ dtbo-$(CONFIG_ARCH_BCM2835) += \
hifiberry-dacplus.dtbo \
hifiberry-dacplusadc.dtbo \
hifiberry-dacplusadcpro.dtbo \
hifiberry-dacplusdsp.dtbo \
hifiberry-digi.dtbo \
hifiberry-digi-pro.dtbo \
hy28a.dtbo \
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/boot/dts/overlays/README
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,12 @@ Params: 24db_digital_gain Allow gain to be applied via the PCM512x codec
master for bit clock and frame clock.


Name: hifiberry-dacplusdsp
Info: Configures the HifiBerry DAC+DSP audio card
Load: dtoverlay=hifiberry-dacplusdsp
Params: <None>


Name: hifiberry-digi
Info: Configures the HifiBerry Digi and Digi+ audio card
Load: dtoverlay=hifiberry-digi
Expand Down
34 changes: 34 additions & 0 deletions arch/arm/boot/dts/overlays/hifiberry-dacplusdsp-overlay.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Definitions for hifiberry DAC+DSP soundcard overlay
/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2835";

fragment@0 {
target = <&i2s>;
__overlay__ {
status = "okay";
};
};

fragment@1 {
target-path = "/";
__overlay__ {
dacplusdsp-codec {
#sound-dai-cells = <0>;
compatible = "hifiberry,dacplusdsp";
status = "okay";
};
};
};

fragment@2 {
target = <&sound>;
__overlay__ {
compatible = "hifiberrydacplusdsp,hifiberrydacplusdsp-soundcard";
i2s-controller = <&i2s>;
status = "okay";
};
};
};
1 change: 1 addition & 0 deletions arch/arm/configs/bcm2709_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
CONFIG_SND_BCM2708_SOC_RPI_CIRRUS=m
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/bcm2711_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
CONFIG_SND_BCM2708_SOC_RPI_CIRRUS=m
Expand Down
1 change: 1 addition & 0 deletions arch/arm/configs/bcmrpi_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -962,6 +962,7 @@ CONFIG_SND_BCM2708_SOC_HIFIBERRY_DAC=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_DIGI=m
CONFIG_SND_BCM2708_SOC_HIFIBERRY_AMP=m
CONFIG_SND_BCM2708_SOC_RPI_CIRRUS=m
Expand Down
7 changes: 7 additions & 0 deletions sound/soc/bcm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ config SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO
help
Say Y or M if you want to add support for HifiBerry DAC+ADC PRO.

config SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP
tristate "Support for HifiBerry DAC+DSP"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_SOC_I2S
select SND_RPI_SIMPLE_SOUNDCARD
help
Say Y or M if you want to add support for HifiBerry DSP-DAC.

config SND_BCM2708_SOC_HIFIBERRY_DIGI
tristate "Support for HifiBerry Digi"
depends on SND_BCM2708_SOC_I2S || SND_BCM2835_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 @@ -15,6 +15,7 @@ snd-soc-googlevoicehat-codec-objs := googlevoicehat-codec.o
snd-soc-hifiberry-dacplus-objs := hifiberry_dacplus.o
snd-soc-hifiberry-dacplusadc-objs := hifiberry_dacplusadc.o
snd-soc-hifiberry-dacplusadcpro-objs := hifiberry_dacplusadcpro.o
snd-soc-hifiberry-dacplusdsp-objs := hifiberry_dacplusdsp.o
snd-soc-justboom-dac-objs := justboom-dac.o
snd-soc-rpi-cirrus-objs := rpi-cirrus.o
snd-soc-rpi-proto-objs := rpi-proto.o
Expand All @@ -40,6 +41,7 @@ obj-$(CONFIG_SND_BCM2708_SOC_GOOGLEVOICEHAT_SOUNDCARD) += snd-soc-googlevoiceha
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUS) += snd-soc-hifiberry-dacplus.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADC) += snd-soc-hifiberry-dacplusadc.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSADCPRO) += snd-soc-hifiberry-dacplusadcpro.o
obj-$(CONFIG_SND_BCM2708_SOC_HIFIBERRY_DACPLUSDSP) += snd-soc-hifiberry-dacplusdsp.o
obj-$(CONFIG_SND_BCM2708_SOC_JUSTBOOM_DAC) += snd-soc-justboom-dac.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_CIRRUS) += snd-soc-rpi-cirrus.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_PROTO) += snd-soc-rpi-proto.o
Expand Down
90 changes: 90 additions & 0 deletions sound/soc/bcm/hifiberry_dacplusdsp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// SPDX-License-Identifier: GPL-2.0
/*
* ASoC Driver for HiFiBerry DAC + DSP
*
* Author: Joerg Schambacher <[email protected]>
* Copyright 2018
*
* 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/init.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <sound/soc.h>

static struct snd_soc_component_driver dacplusdsp_component_driver;

static struct snd_soc_dai_driver dacplusdsp_dai = {
.name = "dacplusdsp-hifi",
.capture = {
.stream_name = "DAC+DSP Capture",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.formats = SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S32_LE,
},
.playback = {
.stream_name = "DACP+DSP Playback",
.channels_min = 2,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_CONTINUOUS,
.formats = SNDRV_PCM_FMTBIT_S16_LE |
SNDRV_PCM_FMTBIT_S24_LE |
SNDRV_PCM_FMTBIT_S32_LE,
},
.symmetric_rates = 1};

#ifdef CONFIG_OF
static const struct of_device_id dacplusdsp_ids[] = {
{
.compatible = "hifiberry,dacplusdsp",
},
{} };
MODULE_DEVICE_TABLE(of, dacplusdsp_ids);
#endif

static int dacplusdsp_platform_probe(struct platform_device *pdev)
{
int ret;

ret = snd_soc_register_component(&pdev->dev,
&dacplusdsp_component_driver, &dacplusdsp_dai, 1);
if (ret) {
pr_alert("snd_soc_register_component failed\n");
return ret;
}

return 0;
}

static int dacplusdsp_platform_remove(struct platform_device *pdev)
{
snd_soc_unregister_component(&pdev->dev);
return 0;
}

static struct platform_driver dacplusdsp_driver = {
.driver = {
.name = "hifiberry-dacplusdsp-codec",
.of_match_table = of_match_ptr(dacplusdsp_ids),
},
.probe = dacplusdsp_platform_probe,
.remove = dacplusdsp_platform_remove,
};

module_platform_driver(dacplusdsp_driver);

MODULE_AUTHOR("Joerg Schambacher <[email protected]>");
MODULE_DESCRIPTION("ASoC Driver for HiFiBerry DAC+DSP");
MODULE_LICENSE("GPL v2");
19 changes: 19 additions & 0 deletions sound/soc/bcm/rpi-simple-soundcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,23 @@ static struct snd_rpi_simple_drvdata drvdata_googlevoicehat = {
.dai = snd_googlevoicehat_soundcard_dai,
};

static struct snd_soc_dai_link snd_hifiberrydacplusdsp_soundcard_dai[] = {
{
.name = "Hifiberry DAC+DSP SoundCard",
.stream_name = "Hifiberry DAC+DSP SoundCard HiFi",
.codec_dai_name = "dacplusdsp-hifi",
.codec_name = "dacplusdsp-codec",
.dai_fmt = SND_SOC_DAIFMT_I2S |
SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS,
},
};

static struct snd_rpi_simple_drvdata drvdata_hifiberrydacplusdsp = {
.card_name = "snd_rpi_hifiberrydacplusdsp_soundcard",
.dai = snd_hifiberrydacplusdsp_soundcard_dai,
};

static struct snd_soc_dai_link snd_hifiberry_amp_dai[] = {
{
.name = "HifiBerry AMP",
Expand Down Expand Up @@ -193,6 +210,8 @@ static const struct of_device_id snd_rpi_simple_of_match[] = {
.data = (void *) &drvdata_adau1977 },
{ .compatible = "googlevoicehat,googlevoicehat-soundcard",
.data = (void *) &drvdata_googlevoicehat },
{ .compatible = "hifiberrydacplusdsp,hifiberrydacplusdsp-soundcard",
.data = (void *) &drvdata_hifiberrydacplusdsp },
{ .compatible = "hifiberry,hifiberry-amp",
.data = (void *) &drvdata_hifiberry_amp },
{ .compatible = "hifiberry,hifiberry-dac",
Expand Down