[alsa-devel] [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone
This patch adds spdif dummy codec driver for using spdif-dit as a stand-alone. Until this, spdif-dit can be used only with other codecs like tlv320aci3x in davinci platform.
Signed-off-by: Seungwhan Youn sw.youn@samsung.com --- sound/soc/codecs/spdif_transciever.c | 93 +++++++++++++++++++++++++++++++++- 1 files changed, 92 insertions(+), 1 deletions(-)
diff --git a/sound/soc/codecs/spdif_transciever.c b/sound/soc/codecs/spdif_transciever.c index a631911..f0945ab 100644 --- a/sound/soc/codecs/spdif_transciever.c +++ b/sound/soc/codecs/spdif_transciever.c @@ -18,6 +18,7 @@ #include <linux/moduleparam.h> #include <sound/soc.h> #include <sound/pcm.h> +#include <sound/initval.h>
#include "spdif_transciever.h"
@@ -26,6 +27,48 @@ MODULE_LICENSE("GPL"); #define STUB_RATES SNDRV_PCM_RATE_8000_96000 #define STUB_FORMATS SNDRV_PCM_FMTBIT_S16_LE
+static struct snd_soc_codec *spdif_dit_codec; + +static int spdif_dit_codec_probe(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + struct snd_soc_codec *codec; + int ret; + + if (spdif_dit_codec == NULL) { + dev_err(&pdev->dev, "Codec device not registered\n"); + return -ENODEV; + } + + socdev->card->codec = spdif_dit_codec; + codec = spdif_dit_codec; + + ret = snd_soc_new_pcms(socdev, SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1); + if (ret < 0) { + dev_err(codec->dev, "failed to create pcms: %d\n", ret); + goto err_create_pcms; + } + + return 0; + +err_create_pcms: + return ret; +} + +static int spdif_dit_codec_remove(struct platform_device *pdev) +{ + struct snd_soc_device *socdev = platform_get_drvdata(pdev); + + snd_soc_free_pcms(socdev); + + return 0; +} + +struct snd_soc_codec_device soc_codec_dev_spdif_dit = { + .probe = spdif_dit_codec_probe, + .remove = spdif_dit_codec_remove, +}; EXPORT_SYMBOL_GPL(soc_codec_dev_spdif_dit); + struct snd_soc_dai dit_stub_dai = { .name = "DIT", .playback = { @@ -40,13 +83,61 @@ EXPORT_SYMBOL_GPL(dit_stub_dai);
static int spdif_dit_probe(struct platform_device *pdev) { + struct snd_soc_codec *codec; + int ret; + + if (spdif_dit_codec) { + dev_err(&pdev->dev, "Another Codec is registered\n"); + ret = -EINVAL; + goto err_reg_codec; + } + + codec = kzalloc(sizeof(struct snd_soc_codec), GFP_KERNEL); + if (codec == NULL) + return -ENOMEM; + + codec->dev = &pdev->dev; + + mutex_init(&codec->mutex); + + INIT_LIST_HEAD(&codec->dapm_widgets); + INIT_LIST_HEAD(&codec->dapm_paths); + + codec->name = "spdif-dit"; + codec->owner = THIS_MODULE; + codec->dai = &dit_stub_dai; + codec->num_dai = 1; + + spdif_dit_codec = codec; + + ret = snd_soc_register_codec(codec); + if (ret < 0) { + dev_err(codec->dev, "Failed to register codec: %d\n", ret); + goto err_reg_codec; + } + dit_stub_dai.dev = &pdev->dev; - return snd_soc_register_dai(&dit_stub_dai); + ret = snd_soc_register_dai(&dit_stub_dai); + if (ret < 0) { + dev_err(codec->dev, "Failed to register dai: %d\n", ret); + goto err_reg_dai; + } + + return 0; + +err_reg_dai: + snd_soc_unregister_codec(codec); +err_reg_codec: + kfree(spdif_dit_codec); + return ret; }
static int spdif_dit_remove(struct platform_device *pdev) { snd_soc_unregister_dai(&dit_stub_dai); + snd_soc_unregister_codec(spdif_dit_codec); + kfree(spdif_dit_codec); + spdif_dit_codec = NULL; return 0; }
On Thu, 2010-05-27 at 18:13 +0900, Seungwhan Youn wrote:
This patch adds spdif dummy codec driver for using spdif-dit as a stand-alone. Until this, spdif-dit can be used only with other codecs like tlv320aci3x in davinci platform.
Signed-off-by: Seungwhan Youn sw.youn@samsung.com
sound/soc/codecs/spdif_transciever.c | 93 +++++++++++++++++++++++++++++++++- 1 files changed, 92 insertions(+), 1 deletions(-)
- spdif_dit_codec = NULL;
This isn't really necessary as the module is being removed at this point.
Acked-by: Liam Girdwood lrg@slimlogic.co.uk
On Thu, May 27, 2010 at 06:13:48PM +0900, Seungwhan Youn wrote:
This patch adds spdif dummy codec driver for using spdif-dit as a stand-alone. Until this, spdif-dit can be used only with other codecs like tlv320aci3x in davinci platform.
Signed-off-by: Seungwhan Youn sw.youn@samsung.com
Applied, thanks.
On Thu, May 27, 2010 at 06:13:48PM +0900, Seungwhan Youn wrote:
This patch adds spdif dummy codec driver for using spdif-dit as a stand-alone. Until this, spdif-dit can be used only with other codecs like tlv320aci3x in davinci platform.
Signed-off-by: Seungwhan Youn sw.youn@samsung.com
*sigh*
sound/soc/codecs/spdif_transciever.c:67:29: warning: symbol 'soc_codec_dev_spdif_dit' was not declared. Should it be static? sound/soc/codecs/spdif_transciever.c:95:17: error: undefined identifier 'kzalloc' sound/soc/codecs/spdif_transciever.c:131:9: error: undefined identifier 'kfree' sound/soc/codecs/spdif_transciever.c:139:9: error: undefined identifier 'kfree' CC [M] sound/soc/codecs/spdif_transciever.o sound/soc/codecs/spdif_transciever.c: In function ‘spdif_dit_probe’: sound/soc/codecs/spdif_transciever.c:95: error: implicit declaration of function ‘kzalloc’ sound/soc/codecs/spdif_transciever.c:95: warning: assignment makes pointer from integer without a cast sound/soc/codecs/spdif_transciever.c:131: error: implicit declaration of function ‘kfree’
I've fixed these up.
Hi, Mark,
2010/5/31 Mark Brown broonie@opensource.wolfsonmicro.com
On Thu, May 27, 2010 at 06:13:48PM +0900, Seungwhan Youn wrote:
This patch adds spdif dummy codec driver for using spdif-dit as a stand-alone. Until this, spdif-dit can be used only with other codecs like tlv320aci3x in davinci platform.
Signed-off-by: Seungwhan Youn sw.youn@samsung.com
*sigh*
sound/soc/codecs/spdif_transciever.c:67:29: warning: symbol 'soc_codec_dev_spdif_dit' was not declared. Should it be static? sound/soc/codecs/spdif_transciever.c:95:17: error: undefined identifier 'kzalloc' sound/soc/codecs/spdif_transciever.c:131:9: error: undefined identifier 'kfree' sound/soc/codecs/spdif_transciever.c:139:9: error: undefined identifier 'kfree' CC [M] sound/soc/codecs/spdif_transciever.o sound/soc/codecs/spdif_transciever.c: In function ‘spdif_dit_probe’: sound/soc/codecs/spdif_transciever.c:95: error: implicit declaration of function ‘kzalloc’ sound/soc/codecs/spdif_transciever.c:95: warning: assignment makes pointer from integer without a cast sound/soc/codecs/spdif_transciever.c:131: error: implicit declaration of function ‘kfree’
I've fixed these up.
I'm sorry for missing these. :( Thank you.
Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
BestRegards, claude
participants (4)
-
Liam Girdwood
-
Mark Brown
-
Seungwhan Youn
-
Seungwhan Youn