Skip to contentSkip to conversation

asoc: add dummy codec

PATCH In review Stas Sergeev 3 participants 15 messages Apr 11, 2013 – Apr 12, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 asoc: add dummy codec

Hi.

The attached patch adds a dummy codec for the asoc subsystem.
I use it with the driver that programs the soc to drive I2S from an internal PLLs, and the audio then goes to HDMI, so no external codec is used.
I've found spdif_transciever.c, which exactly is such a dummy driver, but it is bound to the particular plat device, so I made the device name a config option, and if not set, the plat device is created with the default name.

It may be possible to avoid the usage of the codec driver at all, but I haven't succeeded with this, and the existance of spdif_transciever.c suggests there is no such way. Thoughts?

From de73a7b38e4972af64c5e3e10798bdfca0277a10 Mon Sep 17 00:00:00 2001
From: Stas Sergeev <[email protected]>
Date: Thu, 11 Apr 2013 13:56:34 +0400
Subject: [PATCH] asoc: add dummy codec

---
 sound/soc/codecs/Kconfig  | 10 +++++
 sound/soc/codecs/Makefile |  2 +
 sound/soc/codecs/dummy.c  | 94 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 106 insertions(+)
 create mode 100644 sound/soc/codecs/dummy.c
sound/soc/codecs/Kconfig +10 -0
index 45b7256..1f5a704 100644
@@ -10,6 +10,7 @@ config SND_SOC_I2C_AND_SPI
 
 config SND_SOC_ALL_CODECS
 	tristate "Build all ASoC CODEC drivers"
+	select SND_SOC_DUMMY
 	select SND_SOC_88PM860X if MFD_88PM860X
 	select SND_SOC_L3
 	select SND_SOC_AB8500_CODEC if ABX500_CORE
@@ -134,6 +135,15 @@ config SND_SOC_ALL_CODECS
 
           If unsure select "N".
 
+config SND_SOC_DUMMY
+	tristate
+
+config SND_SOC_DUMMY_NAME
+	string "Name of the dummy codec"
+	depends on SND_SOC_DUMMY
+	help
+	  Specify platform device name, if any, or leave blank
+
 config SND_SOC_88PM860X
 	tristate
 
sound/soc/codecs/Makefile +2 -0
index 6a3b3c3..7514d5e 100644
@@ -1,3 +1,4 @@
+snd-soc-dummy-objs := dummy.o
 snd-soc-88pm860x-objs := 88pm860x-codec.o
 snd-soc-ab8500-codec-objs := ab8500-codec.o
 snd-soc-ac97-objs := ac97.o
@@ -121,6 +122,7 @@ snd-soc-wm-hubs-objs := wm_hubs.o
 snd-soc-max9877-objs := max9877.o
 snd-soc-tpa6130a2-objs := tpa6130a2.o
 
+obj-$(CONFIG_SND_SOC_DUMMY)	+= snd-soc-dummy.o
 obj-$(CONFIG_SND_SOC_88PM860X)	+= snd-soc-88pm860x.o
 obj-$(CONFIG_SND_SOC_AB8500_CODEC)	+= snd-soc-ab8500-codec.o
 obj-$(CONFIG_SND_SOC_AC97_CODEC)	+= snd-soc-ac97.o
sound/soc/codecs/dummy.c new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#1 lore raw
Quoted 13 lines · Stas Sergeev

Hi.

The attached patch adds a dummy codec for the asoc subsystem.
I use it with the driver that programs the soc to drive I2S from an internal PLLs, and the audio then goes to HDMI, so no external codec is used.
I've found spdif_transciever.c, which exactly is such a dummy driver, but it is bound to the particular plat device, so I made the device name a config option, and if not set, the plat device is created with the default name.

Quoted 7 lines

It may be possible to avoid the usage of the codec driver at all, but I haven't succeeded with this, and the existance of spdif_transciever.c suggests there is no such way. Thoughts?

Hi,

There is already a dummy codec driver.

Please take a look at sound/soc/soc-utils.c

- Lars

#2 lore raw

11.04.2013 14:41, Lars-Peter Clausen пишет:

Quoted 19 lines · Stas Sergeev
Quoted 18 lines

Hi.

The attached patch adds a dummy codec for the asoc subsystem.
I use it with the driver that programs the soc to drive I2S from an internal PLLs, and the audio then goes to HDMI, so no external codec is used.
I've found spdif_transciever.c, which exactly is such a dummy driver, but it is bound to the particular plat device, so I made the device name a config option, and if not set, the plat device is created with the default name.

It may be possible to avoid the usage of the codec driver at all, but I haven't succeeded with this, and the existance of spdif_transciever.c suggests there is no such way. Thoughts?

Quoted 7 lines
Quoted 2 lines

Hi,

There is already a dummy codec driver.

Please take a look at sound/soc/soc-utils.c

Hi, I've seen that, but how can I get use of it? It doesn't do snd_soc_register_codec(), and in debugfs I can do 'cat asoc/codecs' and it shows only 'dummy-codec', which is installed by my driver.
So could you please clarify?
_______________________________________________
Alsa-devel mailing list [email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#3 lore raw
Quoted 22 lines · Stas Sergeev

11.04.2013 14:41, Lars-Peter Clausen пишет:

Quoted 21 lines · Stas Sergeev
Quoted 20 lines

Hi.

The attached patch adds a dummy codec for the asoc subsystem.
I use it with the driver that programs the soc to drive I2S from an internal PLLs, and the audio then goes to HDMI, so no external codec is used.
I've found spdif_transciever.c, which exactly is such a dummy driver, but it is bound to the particular plat device, so I made the device name a config option, and if not set, the plat device is created with the default name.

It may be possible to avoid the usage of the codec driver at all, but I haven't succeeded with this, and the existance of spdif_transciever.c suggests there is no such way. Thoughts?

Quoted 7 lines
Quoted 5 lines

Hi,

There is already a dummy codec driver.

Please take a look at sound/soc/soc-utils.c

Hi, I've seen that, but how can I get use of it? It doesn't do snd_soc_register_codec(), and in debugfs

It does:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/sound/soc/soc-utils.c#n101

- Lars

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#4 lore raw

11.04.2013 18:21, Lars-Peter Clausen пишет:

Quoted 25 lines · Stas Sergeev
Quoted 24 lines

11.04.2013 14:41, Lars-Peter Clausen пишет:

Quoted 23 lines · Stas Sergeev
Quoted 13 lines

Hi.

The attached patch adds a dummy codec for the asoc subsystem.
I use it with the driver that programs the soc to drive I2S from an internal PLLs, and the audio then goes to HDMI, so no external codec is used.
I've found spdif_transciever.c, which exactly is such a dummy driver, but it is bound to the particular plat device, so I made the device name a config option, and if not set, the plat device is created with the default name.

Quoted 7 lines

It may be possible to avoid the usage of the codec driver at all, but I haven't succeeded with this, and the existance of spdif_transciever.c suggests there is no such way. Thoughts?

Hi,

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

There is already a dummy codec driver.

Please take a look at sound/soc/soc-utils.c

Hi, I've seen that, but how can I get use of it? It doesn't do snd_soc_register_codec(), and in debugfs

It does:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/sound/soc/soc-utils.c#n101

Arr, that's it, thank you!
It doesn't do so on an android kernel I have here (based on linux-3.0), but it indeed does so in a git kernel...
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw
In reply to Lars-Peter Clausen

11.04.2013 14:41, Lars-Peter Clausen пишет:

Quoted 21 lines · Stas Sergeev
Quoted 13 lines

Hi.

The attached patch adds a dummy codec for the asoc subsystem.
I use it with the driver that programs the soc to drive I2S from an internal PLLs, and the audio then goes to HDMI, so no external codec is used.
I've found spdif_transciever.c, which exactly is such a dummy driver, but it is bound to the particular plat device, so I made the device name a config option, and if not set, the plat device is created with the default name.

Quoted 7 lines

It may be possible to avoid the usage of the codec driver at all, but I haven't succeeded with this, and the existance of spdif_transciever.c suggests there is no such way. Thoughts?

Quoted 7 lines

Hi,

There is already a dummy codec driver.

Please take a look at sound/soc/soc-utils.c

- Lars

Lars, indeed, this codec is present in a git kernel and it wasn't in mine android kernel.
But, that driver is too dummy to even work at all.

The attached patch adds a playback stream for the dummy codec. Would it be possible to apply this?

From 9723ec37ed86b156502fc7972a1bded35c4e55c3 Mon Sep 17 00:00:00 2001
From: Stas Sergeev <[email protected]>
Date: Thu, 11 Apr 2013 19:07:20 +0400
Subject: [PATCH] asoc: define playback stream in dummy codec

---
 sound/soc/soc-utils.c | 7 +++++++
 1 file changed, 7 insertions(+)
sound/soc/soc-utils.c +7 -0
index fe4541d..53e3c89 100644
@@ -92,6 +92,13 @@ static struct snd_soc_platform_driver dummy_platform = {
 static struct snd_soc_codec_driver dummy_codec;
 static struct snd_soc_dai_driver dummy_dai = {
 	.name = "snd-soc-dummy-dai",
+	.playback 	= {
+		.stream_name	= "Playback",
+		.channels_min	= 1,
+		.channels_max	= 384,
+		.rates		= SNDRV_PCM_RATE_8000_96000,
+		.formats	= SNDRV_PCM_FMTBIT_S16_LE,
+	},
 };
 
 static int snd_soc_dummy_probe(struct platform_device *pdev)
Signature · 1 line
1.7.11.7
#6 lore raw
Quoted 11 lines · Stas Sergeev
Quoted 5 lines

There is already a dummy codec driver.

Please take a look at sound/soc/soc-utils.c

- Lars

Lars, indeed, this codec is present in a git kernel and it wasn't in mine android kernel.
But, that driver is too dummy to even work at all.

The attached patch adds a playback stream for the dummy codec. Would it be possible to apply this?

No... not like that.

Instead, wouldn't it be better to extend it by defining some platform data? Maybe something like:

sound/soc/soc-utils.c +6 -1
index fe4541d..9d22718 100644
@@ -96,9 +96,14 @@ static struct snd_soc_dai_driver dummy_dai = {
 
 static int snd_soc_dummy_probe(struct platform_device *pdev)
 {
+       struct snd_soc_dummy_dai_pdata *pdata = dev_get_platdata(&pdev->dev);
        int ret;
 
-       ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1);
+       if (pdata->n_dai > 0)
+               ret = snd_soc_register_codec(&pdev->dev, &dummy_codec,
+                                            &pdata->dai, &pdata->n_dai);
+       else
+               ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1);
        if (ret < 0)
                return ret;
 

...then you can define whatever kind of DAI you want in the machine driver.

-gabriel

#7 lore raw

11.04.2013 19:48, Gabriel M. Beddingfield пишет:

Quoted 37 lines · Stas Sergeev
Quoted 11 lines
Quoted 5 lines

There is already a dummy codec driver.

Please take a look at sound/soc/soc-utils.c

- Lars

Lars, indeed, this codec is present in a git kernel and it wasn't in mine android kernel.
But, that driver is too dummy to even work at all.

The attached patch adds a playback stream for the dummy codec. Would it be possible to apply this?

No... not like that.

Instead, wouldn't it be better to extend it by defining some platform data? Maybe something like:

sound/soc/soc-utils.c +6 -1
index fe4541d..9d22718 100644
@@ -96,9 +96,14 @@ static struct snd_soc_dai_driver dummy_dai = {
 
 static int snd_soc_dummy_probe(struct platform_device *pdev)
 {
+       struct snd_soc_dummy_dai_pdata *pdata = dev_get_platdata(&pdev->dev);
        int ret;
 
-       ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1);
+       if (pdata->n_dai > 0)
+               ret = snd_soc_register_codec(&pdev->dev, &dummy_codec,
+                                            &pdata->dai, &pdata->n_dai);
+       else
+               ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1);
        if (ret < 0)
                return ret;
 
Quoted 1 line

...then you can define whatever kind of DAI you want in the machine driver.

But that's a _dummy_ codec, it simply does this:
---
soc_dummy_dev = platform_device_alloc("snd-soc-dummy", -1); if (!soc_dummy_dev)
return -ENOMEM;
ret = platform_device_add(soc_dummy_dev);
---
in the very same source file.
What is the reason of adding platform data for a dummy driver? The code snippet I propose, is copied from the spdif_receiver.c, so its not something I invented myself. :)
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#8 lore raw
Quoted 1 line · Stas Sergeev

What is the reason of adding platform data for a dummy driver?

Because some audio "codecs" have a static configuration or are configured by magic. (E.g. a modem in a phone.) I think that being able to declare a board-specific set of "dummy DAI's" in the board file is helpful.

-gabriel

#9 lore raw

11.04.2013 20:13, Gabriel M. Beddingfield пишет:

Quoted 7 lines · Stas Sergeev
Quoted 1 line

What is the reason of adding platform data for a dummy driver?

Because some audio "codecs" have a static configuration or are configured by magic. (E.g. a modem in a phone.) I think that being able to declare a board-specific set of "dummy DAI's" in the board file is helpful.

I don't understand your suggestion yet.
Currently this driver creates the platform device on its own. Do you propose to remove this first, and rely on the boards to define "snd-soc-dummy" device with plat data?
Could you please also give a practical example where the current "snd-soc-dummy-dai" is not enough? My driver defines 2 DAIs, but I linked them both to "snd-soc-dummy-dai", and that seem to work. But I am not familiar with this subsystem, so maybe I did something wrong.
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#14 lore raw
In reply to Stas Sergeev
Quoted 28 lines · Stas Sergeev

11.04.2013 14:41, Lars-Peter Clausen пишет:

Quoted 27 lines · Stas Sergeev
Quoted 13 lines

Hi.

The attached patch adds a dummy codec for the asoc subsystem.
I use it with the driver that programs the soc to drive I2S from an internal PLLs, and the audio then goes to HDMI, so no external codec is used.
I've found spdif_transciever.c, which exactly is such a dummy driver, but it is bound to the particular plat device, so I made the device name a config option, and if not set, the plat device is created with the default name.

Quoted 7 lines

It may be possible to avoid the usage of the codec driver at all, but I haven't succeeded with this, and the existance of spdif_transciever.c suggests there is no such way. Thoughts?

Hi,

There is already a dummy codec driver.

Please take a look at sound/soc/soc-utils.c

Quoted 7 lines
Quoted 1 line

- Lars

Lars, indeed, this codec is present in a git kernel and it wasn't in mine android kernel.
But, that driver is too dummy to even work at all.

The attached patch adds a playback stream for the dummy codec. Would it be possible to apply this?

Looks fine to me, although it might make sense to also add a dummy capture stream. But you need to send the patch to Mark and Liam who are the ASoC maintainers. Also use the proper subsystem prefix, which is "ASoC" not "asoc", add a patch description, sign off on the patch itself and try to send it inline instead of an attachment.

- Lars
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#10 lore raw
In reply to Gabriel M. Beddingfield
Quoted 10 lines · Gabriel M. Beddingfield
Quoted 9 lines · Stas Sergeev
Quoted 5 lines

There is already a dummy codec driver.

Please take a look at sound/soc/soc-utils.c

- Lars

Lars, indeed, this codec is present in a git kernel and it wasn't in mine android kernel.
But, that driver is too dummy to even work at all.

Quoted 6 lines
Quoted 2 lines

The attached patch adds a playback stream for the dummy codec. Would it be possible to apply this?

No... not like that.

Instead, wouldn't it be better to extend it by defining some platform data? Maybe something like:

Either you want a dummy or you want one with specific requirements. For the former case use the dummy codec, for the later case add a proper driver. Putting these kinds of things in your board file is in my opinion a bad habit.

- Lars

Quoted 26 lines
sound/soc/soc-utils.c +6 -1
index fe4541d..9d22718 100644
@@ -96,9 +96,14 @@ static struct snd_soc_dai_driver dummy_dai = {
 
 static int snd_soc_dummy_probe(struct platform_device *pdev)
 {
+       struct snd_soc_dummy_dai_pdata *pdata = dev_get_platdata(&pdev->dev);
        int ret;
 
-       ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1);
+       if (pdata->n_dai > 0)
+               ret = snd_soc_register_codec(&pdev->dev, &dummy_codec,
+                                            &pdata->dai, &pdata->n_dai);
+       else
+               ret = snd_soc_register_codec(&pdev->dev, &dummy_codec, &dummy_dai, 1);
        if (ret < 0)
                return ret;
 

...then you can define whatever kind of DAI you want in the machine driver.

-gabriel

#12 lore raw
In reply to Gabriel M. Beddingfield
Quoted 4 lines · Gabriel M. Beddingfield
Quoted 2 lines

The attached patch adds a playback stream for the dummy codec. Would it be possible to apply this?

No... not like that.

I was wrong. Sorry.

That patch is on the right track. As Lars said, it needs a Capture DAI, too. Might also consider adding more audio formats.

Quoted 2 lines

Instead, wouldn't it be better to extend it by defining some platform data? Maybe something like:

I still think that making this extensible is a good idea (platform data), but fall back on a very permissive default DAI (like in your patch).

-gabriel

#11 lore raw
In reply to Lars-Peter Clausen
Quoted 5 lines · Lars-Peter Clausen
Quoted 1 line

Instead, wouldn't it be better to extend it by defining some platform data? Maybe something like:

Either you want a dummy or you want one with specific requirements. For the former case use the dummy codec, for the later case add a proper driver. Putting these kinds of things in your board file is in my opinion a bad habit.

Well, I've seen a couple cases where a dummy codec /is/ the proper driver and all that's needed is to restrict the formats that the DAI supports (sample rate, etc).

Yes, we can always write a board-specific dummy codec with the restricted formats -- but since there's already one in ASoC, why not make it extensible?

-gabriel

#13 lore raw
In reply to Gabriel M. Beddingfield

12.04.2013 06:50, Gabriel M. Beddingfield пишет:

Quoted 3 lines

I still think that making this extensible is a good idea (platform data), but fall back on a very permissive default DAI (like in your patch).

OK, I see your point, and I think it would be nice
to have some quick way to add the format restrictions to the DAI without writing a new dummy codec every time. Maybe even the runtime-adjustable restrictions would be nice in some cases (when you plug and unplug different devices to the HDMI transmitter, which is my use-case now). But I am afraid this will require much more considerations than just a quick hack on a currently existing dummy codec. This is out of the scope for my patch. I'll go the short route. :)
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel