alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone
@ 2010-05-27  9:13 Seungwhan Youn
  2010-05-27 13:54 ` Liam Girdwood
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Seungwhan Youn @ 2010-05-27  9:13 UTC (permalink / raw)
  To: alsa-devel; +Cc: Seungwhan Youn, broonie, schen, lrg

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;
 }
 
-- 
1.6.2.5

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone
  2010-05-27  9:13 [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone Seungwhan Youn
@ 2010-05-27 13:54 ` Liam Girdwood
  2010-05-31 11:23 ` Mark Brown
  2010-05-31 12:42 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Liam Girdwood @ 2010-05-27 13:54 UTC (permalink / raw)
  To: Seungwhan Youn; +Cc: alsa-devel, broonie, schen

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone
  2010-05-27  9:13 [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone Seungwhan Youn
  2010-05-27 13:54 ` Liam Girdwood
@ 2010-05-31 11:23 ` Mark Brown
  2010-05-31 12:42 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2010-05-31 11:23 UTC (permalink / raw)
  To: Seungwhan Youn; +Cc: alsa-devel, schen, lrg

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone
  2010-05-27  9:13 [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone Seungwhan Youn
  2010-05-27 13:54 ` Liam Girdwood
  2010-05-31 11:23 ` Mark Brown
@ 2010-05-31 12:42 ` Mark Brown
  2010-05-31 19:27   ` Seungwhan Youn
  2 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2010-05-31 12:42 UTC (permalink / raw)
  To: Seungwhan Youn; +Cc: alsa-devel, schen, lrg

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=unknown-8bit, Size: 1131 bytes --]

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.

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone
  2010-05-31 12:42 ` Mark Brown
@ 2010-05-31 19:27   ` Seungwhan Youn
  0 siblings, 0 replies; 5+ messages in thread
From: Seungwhan Youn @ 2010-05-31 19:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: alsa-devel, lrg, schen, Seungwhan Youn

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-05-31 19:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-27  9:13 [PATCH] ASoC: spdif: Add codec driver to use spdif stand-alone Seungwhan Youn
2010-05-27 13:54 ` Liam Girdwood
2010-05-31 11:23 ` Mark Brown
2010-05-31 12:42 ` Mark Brown
2010-05-31 19:27   ` Seungwhan Youn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).