Skip to content

This will add durio sound driver to rpi 3.18.y #867

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

Closed
wants to merge 1 commit into from
Closed
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
34 changes: 34 additions & 0 deletions arch/arm/boot/dts/duriosound-dac-overlay.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Definitions for DURIOSOUND DAC
/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2708";

fragment@0 {
target = <&sound>;
__overlay__ {
compatible = "duriosound,duriosound-dac";
i2s-controller = <&i2s>;
status = "okay";
};
};

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

fragment@2 {
target-path = "/";
__overlay__ {
pcm5102a-codec {
#sound-dai-cells = <0>;
compatible = "ti,pcm5102a";
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 @@ -798,6 +798,7 @@ 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_SND_BCM2708_SOC_DURIOSOUND_DAC=m
CONFIG_SND_SIMPLE_CARD=m
CONFIG_SOUND_PRIME=m
CONFIG_HIDRAW=y
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 @@ -792,6 +792,7 @@ 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_SND_BCM2708_SOC_DURIOSOUND_DAC=m
CONFIG_SND_SIMPLE_CARD=m
CONFIG_SOUND_PRIME=m
CONFIG_HIDRAW=y
Expand Down
19 changes: 19 additions & 0 deletions arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,20 @@ static struct i2c_board_info __initdata snd_pcm512x_i2c_devices[] = {
};
#endif

#if defined(CONFIG_SND_BCM2708_SOC_DURIOSOUND_DAC) || defined(CONFIG_SND_BCM2708_SOC_DURIOSOUND_DAC_MODULE)
static struct platform_device snd_duriosound_dac_device = {
.name = "snd-hifiberry-dac",
.id = 0,
.num_resources = 0,
};

static struct platform_device snd_pcm5102a_durio_codec_device = {
.name = "pcm5102a-codec",
.id = -1,
.num_resources = 0,
};
#endif

int __init bcm_register_device(struct platform_device *pdev)
{
int ret;
Expand Down Expand Up @@ -932,6 +946,11 @@ void __init bcm2708_init(void)
i2c_register_board_info_dt(1, snd_pcm512x_i2c_devices, ARRAY_SIZE(snd_pcm512x_i2c_devices));
#endif

#if defined(CONFIG_SND_BCM2708_SOC_DURIOSOUND_DAC) || defined(CONFIG_SND_BCM2708_SOC_DURIOSOUND_DAC_MODULE)
bcm_register_device_dt(&snd_duriosound_dac_device);
bcm_register_device_dt(&snd_pcm5102a_durio_codec_device);
#endif


for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
struct amba_device *d = amba_devs[i];
Expand Down
19 changes: 19 additions & 0 deletions arch/arm/mach-bcm2709/bcm2709.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,20 @@ static struct i2c_board_info __initdata snd_pcm512x_i2c_devices[] = {
};
#endif

#if defined(CONFIG_SND_BCM2708_SOC_DURIOSOUND_DAC) || defined(CONFIG_SND_BCM2708_SOC_DURIOSOUND_DAC_MODULE)
static struct platform_device snd_duriosound_dac_device = {
.name = "snd-hifiberry-dac",
.id = 0,
.num_resources = 0,
};

static struct platform_device snd_pcm5102a_durio_codec_device = {
.name = "pcm5102a-codec",
.id = -1,
.num_resources = 0,
};
#endif

int __init bcm_register_device(struct platform_device *pdev)
{
int ret;
Expand Down Expand Up @@ -954,6 +968,11 @@ void __init bcm2709_init(void)
i2c_register_board_info_dt(1, snd_pcm512x_i2c_devices, ARRAY_SIZE(snd_pcm512x_i2c_devices));
#endif

#if defined(CONFIG_SND_BCM2708_SOC_DURIOSOUND_DAC) || defined(CONFIG_SND_BCM2708_SOC_DURIOSOUND_DAC_MODULE)
bcm_register_device_dt(&snd_duriosound_dac_device);
bcm_register_device_dt(&snd_pcm5102a_durio_codec_device);
#endif


for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
struct amba_device *d = amba_devs[i];
Expand Down
8 changes: 8 additions & 0 deletions sound/soc/bcm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ config SND_BCM2708_SOC_IQAUDIO_DAC
select SND_SOC_PCM512x_I2C
help
Say Y or M if you want to add support for IQaudIO-DAC.

config SND_BCM2708_SOC_DURIOSOUND_DAC
tristate "Support for DurioSound DAC"
depends on SND_BCM2708_SOC_I2S
select SND_SOC_PCM5102A
help
Say Y or M if you want to add support for DurioSound DAC.

2 changes: 2 additions & 0 deletions sound/soc/bcm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ 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
snd-soc-duriosound-dac-objs := duriosound-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
obj-$(CONFIG_SND_BCM2708_SOC_DURIOSOUND_DAC) += snd-soc-duriosound-dac.o
106 changes: 106 additions & 0 deletions sound/soc/bcm/duriosound-dac.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* ASoC Driver for DurioSound-DAC.
*
* Author : Pitichai Pitimaneeyakul <[email protected]>
* Copyright 2014
*
* based on code by Florian Meier <[email protected]>
*
* This Module is rewritten from rpi-dac.c and it is modified to
* use pcm5102a as codec to support DurioSound DAC.
*
* 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/moduleparam.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_duriosound_dac_init(struct snd_soc_pcm_runtime *rtd)
{
return 0;
}

static int snd_rpi_duriosound_dac_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;

unsigned int sample_bits =
snd_pcm_format_physical_width(params_format(params));

return snd_soc_dai_set_bclk_ratio(cpu_dai, sample_bits * 2);
}

/* machine stream operations */
static struct snd_soc_ops snd_rpi_duriosound_dac_ops = {
.hw_params = snd_rpi_duriosound_dac_hw_params,
};

static struct snd_soc_dai_link snd_rpi_duriosound_dac_dai[] = {
{
.name = "DurioSound-DAC",
.stream_name = "DurioSound-DAC HiFi",
.cpu_dai_name = "bcm2708-i2s.0",
.codec_dai_name = "pcm5102a-hifi",
.platform_name = "bcm2708-i2s.0",
.codec_name = "pcm5102a-codec",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS,
.ops = &snd_rpi_duriosound_dac_ops,
.init = snd_rpi_duriosound_dac_init,
},
};

/* audio machine driver */
static struct snd_soc_card snd_rpi_duriosound_dac = {
.name = "snd_rpi_duriosound_dac",
.dai_link = snd_rpi_duriosound_dac_dai,
.num_links = ARRAY_SIZE(snd_rpi_duriosound_dac_dai),
};

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

snd_rpi_duriosound_dac.dev = &pdev->dev;
ret = snd_soc_register_card(&snd_rpi_duriosound_dac);
if (ret)
dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", ret);

return ret;
}

static int snd_rpi_duriosound_dac_remove(struct platform_device *pdev)
{
return snd_soc_unregister_card(&snd_rpi_duriosound_dac);
}

static struct platform_driver snd_rpi_duriosound_dac_driver = {
.driver = {
.name = "snd-duriosound-dac",
.owner = THIS_MODULE,
},
.probe = snd_rpi_duriosound_dac_probe,
.remove = snd_rpi_duriosound_dac_remove,
};

module_platform_driver(snd_rpi_duriosound_dac_driver);

MODULE_AUTHOR("Pitichai Pitimaneeyakul <[email protected]>");
MODULE_DESCRIPTION("ASoC Driver for DurioSound-DAC");
MODULE_LICENSE("GPL v2");