Skip to content
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

ASoC: Add support and bcm2708 drivers for PCM5102A #24

Merged
merged 3 commits into from
Sep 24, 2013
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
19 changes: 19 additions & 0 deletions arch/arm/mach-bcm2708/bcm2708.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,20 @@ static struct platform_device snd_rpi_ess9018_codec_device = {
};
#endif

#ifdef CONFIG_SND_BCM2708_SOC_RPI_CODEC_PCM5102A_MODULE
static struct platform_device snd_rpi_pcm5102a_device = {
.name = "snd-rpi-pcm5102a",
.id = 0,
.num_resources = 0,
};

static struct platform_device snd_rpi_pcm5102a_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 @@ -854,6 +868,11 @@ void __init bcm2708_init(void)
bcm_register_device(&snd_rpi_ess9018_codec_device);
#endif

#ifdef CONFIG_SND_BCM2708_SOC_RPI_CODEC_PCM5102A_MODULE
bcm_register_device(&snd_rpi_pcm5102a_device);
bcm_register_device(&snd_rpi_pcm5102a_codec_device);
#endif

for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
struct amba_device *d = amba_devs[i];
amba_device_register(d, &iomem_resource);
Expand Down
9 changes: 9 additions & 0 deletions sound/soc/bcm2708/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,12 @@ config SND_BCM2708_SOC_RPI_CODEC_ESS9018
help
Say Y if you want to add support for ESS9018

config SND_BCM2708_SOC_RPI_CODEC_PCM5102A
tristate "Support for PCM5102A"
depends on SND_BCM2708_SOC
select SND_BCM2708_SOC_I2S
select SND_SOC_PCM5102A
help
Say Y if you want to add support for PCM5102A


2 changes: 2 additions & 0 deletions sound/soc/bcm2708/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ snd-soc-rpi-mbed-objs := rpi-mbed.o
snd-soc-rpi-tda1541a-objs := rpi-tda1541a.o
snd-soc-rpi-proto-objs := rpi-proto.o
snd-soc-rpi-ess9018-objs := rpi-ess9018.o
snd-soc-rpi-pcm5102a-objs := rpi-pcm5102a.o

obj-$(CONFIG_SND_BCM2708_SOC) += snd-soc-bcm2708.o
obj-$(CONFIG_SND_BCM2708_SOC_I2S) += snd-soc-bcm2708-i2s.o
Expand All @@ -14,4 +15,5 @@ obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_MBED) += snd-soc-rpi-mbed.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_TDA1541A) += snd-soc-rpi-tda1541a.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_PROTO) += snd-soc-rpi-proto.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_ESS9018) += snd-soc-rpi-ess9018.o
obj-$(CONFIG_SND_BCM2708_SOC_RPI_CODEC_PCM5102A) += snd-soc-rpi-pcm5102a.o

93 changes: 93 additions & 0 deletions sound/soc/bcm2708/rpi-pcm5102a.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* ASoC driver for PCM5102A codec
* connected to a Raspberry Pi
*
* Author: Francesco Valla, <[email protected]>
* Based on rpi-ess9018.c by: Florian Meier, <[email protected]>
* Copyright 2013
*
* 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.
*/

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

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

static int snd_rpi_pcm5102a_init(struct snd_soc_pcm_runtime *rtd)
{
return 0;
}

static int snd_rpi_pcm5102a_hw_params(struct snd_pcm_substream *substream,
struct snd_pcm_hw_params *params)
{
return 0;
}

/* machine stream operations */
static struct snd_soc_ops snd_rpi_pcm5102a_ops = {
.hw_params = snd_rpi_pcm5102a_hw_params,
};

static struct snd_soc_dai_link snd_rpi_pcm5102a_dai[] = {
{
.name = "PCM5102A",
.stream_name = "PCM5102A HiFi",
.cpu_dai_name = "bcm2708-i2s.0",
.codec_dai_name = "pcm5102a-hifi",
.platform_name = "bcm2708-pcm-audio.0",
.codec_name = "pcm5102a-codec",
.dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF |
SND_SOC_DAIFMT_CBS_CFS,
.ops = &snd_rpi_pcm5102a_ops,
.init = snd_rpi_pcm5102a_init,
},
};

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

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

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

return ret;
}


static int snd_rpi_pcm5102a_remove(struct platform_device *pdev)
{
return snd_soc_unregister_card(&snd_rpi_pcm5102a);
}

static struct platform_driver snd_rpi_pcm5102a_driver = {
.driver = {
.name = "snd-rpi-pcm5102a",
.owner = THIS_MODULE,
},
.probe = snd_rpi_pcm5102a_probe,
.remove = snd_rpi_pcm5102a_remove,
};

module_platform_driver(snd_rpi_pcm5102a_driver);

MODULE_AUTHOR("Francesco Valla");
MODULE_DESCRIPTION("ASoC Driver for Raspberry Pi connected to a PCM5102A");
MODULE_LICENSE("GPL");
4 changes: 4 additions & 0 deletions sound/soc/codecs/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ config SND_SOC_ALL_CODECS
select SND_SOC_ML26124 if I2C
select SND_SOC_OMAP_HDMI_CODEC if OMAP4_DSS_HDMI
select SND_SOC_PCM3008
select SND_SOC_PCM5102A
select SND_SOC_RT5631 if I2C
select SND_SOC_SGTL5000 if I2C
select SND_SOC_SI476X if MFD_SI476X_CORE
Expand Down Expand Up @@ -288,6 +289,9 @@ config SND_SOC_OMAP_HDMI_CODEC
config SND_SOC_PCM3008
tristate

config SND_SOC_PCM5102A
tristate

config SND_SOC_RT5631
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 @@ -42,6 +42,7 @@ snd-soc-mc13783-objs := mc13783.o
snd-soc-ml26124-objs := ml26124.o
snd-soc-omap-hdmi-codec-objs := omap-hdmi.o
snd-soc-pcm3008-objs := pcm3008.o
snd-soc-pcm5102a-objs := pcm5102a.o
snd-soc-rt5631-objs := rt5631.o
snd-soc-sgtl5000-objs := sgtl5000.o
snd-soc-alc5623-objs := alc5623.o
Expand Down Expand Up @@ -168,6 +169,7 @@ obj-$(CONFIG_SND_SOC_MC13783) += snd-soc-mc13783.o
obj-$(CONFIG_SND_SOC_ML26124) += snd-soc-ml26124.o
obj-$(CONFIG_SND_SOC_OMAP_HDMI_CODEC) += snd-soc-omap-hdmi-codec.o
obj-$(CONFIG_SND_SOC_PCM3008) += snd-soc-pcm3008.o
obj-$(CONFIG_SND_SOC_PCM5102A) += snd-soc-pcm5102a.o
obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o
obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o
obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o
Expand Down
61 changes: 61 additions & 0 deletions sound/soc/codecs/pcm5102a.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* Driver for the PCM5102A codec
* It is a dummy driver without any controls.
*
* Copyright 2013
* Author: Francesco Valla <[email protected]>
* Based on ess9018.c by Florian Meier <[email protected]>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/

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

#include <sound/soc.h>

static struct snd_soc_dai_driver pcm5102a_dai = {
.name = "pcm5102a-hifi",
.playback = {
.channels_min = 1,
.channels_max = 2,
.rates = SNDRV_PCM_RATE_8000_192000,
.formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE
},
};

static struct snd_soc_codec_driver soc_codec_dev_pcm5102a;

static int pcm5102a_probe(struct platform_device *pdev)
{
return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_pcm5102a,
&pcm5102a_dai, 1);
}

static int pcm5102a_remove(struct platform_device *pdev)
{
snd_soc_unregister_codec(&pdev->dev);

return 0;
}

static struct platform_driver pcm5102a_codec_driver = {
.probe = pcm5102a_probe,
.remove = pcm5102a_remove,
.driver = {
.name = "pcm5102a-codec",
.owner = THIS_MODULE,
},
};

module_platform_driver(pcm5102a_codec_driver);

MODULE_AUTHOR("Francesco Valla <[email protected]>");
MODULE_DESCRIPTION("ASoC PCM5102A codec driver");
MODULE_LICENSE("GPL");