linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: snd-soc-dummy: add Device Tree support
@ 2021-06-21  7:41 Judy Hsiao
  2021-06-21 11:45 ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Judy Hsiao @ 2021-06-21  7:41 UTC (permalink / raw)
  To: broonie
  Cc: Taniya Das, Rohit kumar, Banajit Goswami, Patrick Lai,
	Andy Gross, Bjorn Andersson, Liam Girdwood, Rob Herring,
	Jaroslav Kysela, Takashi Iwai, Srini Kandagatla, Stephan Gerhold,
	dianders, dgreid, cychiang, judyhsiao, tzungbi, swboyd,
	linux-arm-kernel, linux-arm-msm, devicetree, alsa-devel,
	Judy Hsiao

Support for loading the snd-soc-dummy via DeviceTree.
This is useful to create dummy codec devices where we need to have some
DAI links without a real Codec.

Signed-off-by: Judy Hsiao <judyhsiao@chromium.org>
---
 .../devicetree/bindings/sound/snd-soc-dummy.txt  | 16 ++++++++++++++++
 sound/soc/soc-utils.c                            | 11 +++++++++++
 2 files changed, 27 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/sound/snd-soc-dummy.txt

diff --git a/Documentation/devicetree/bindings/sound/snd-soc-dummy.txt b/Documentation/devicetree/bindings/sound/snd-soc-dummy.txt
new file mode 100644
index 000000000000..7fa8c5751e62
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/snd-soc-dummy.txt
@@ -0,0 +1,16 @@
+* snd-soc-dummy
+
+This node models the snd-soc-dummy.
+This is useful to create dummy codec devices where we need to have
+some DAI links without a real Codec.
+
+Required properties:
+- compatible   : "asoc,snd-soc-dummy"
+
+
+Example:
+
+dummy_codec {
+	compatible = "asoc,snd-soc-dummy";
+	#sound-dai-cells = <0>;
+};
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c
index 299b5d6ebfd1..def2cc687415 100644
--- a/sound/soc/soc-utils.c
+++ b/sound/soc/soc-utils.c
@@ -7,6 +7,8 @@
 // Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
 //         Liam Girdwood <lrg@slimlogic.co.uk>
 
+#include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/export.h>
 #include <sound/core.h>
@@ -181,9 +183,18 @@ static int snd_soc_dummy_probe(struct platform_device *pdev)
 	return ret;
 }
 
+#ifdef CONFIG_OF
+static const struct of_device_id soc_dummy_device_id[] = {
+	{ .compatible = "asoc,snd-soc-dummy" },
+	{}
+};
+MODULE_DEVICE_TABLE(of, soc_dummy_device_id);
+#endif
+
 static struct platform_driver soc_dummy_driver = {
 	.driver = {
 		.name = "snd-soc-dummy",
+		.of_match_table = of_match_ptr(soc_dummy_device_id),
 	},
 	.probe = snd_soc_dummy_probe,
 };
-- 
2.31.0


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

* Re: [PATCH] ASoC: snd-soc-dummy: add Device Tree support
  2021-06-21  7:41 [PATCH] ASoC: snd-soc-dummy: add Device Tree support Judy Hsiao
@ 2021-06-21 11:45 ` Mark Brown
  2021-06-22 16:10   ` Judy Hsiao
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2021-06-21 11:45 UTC (permalink / raw)
  To: Judy Hsiao
  Cc: Taniya Das, Rohit kumar, Banajit Goswami, Patrick Lai,
	Andy Gross, Bjorn Andersson, Liam Girdwood, Rob Herring,
	Jaroslav Kysela, Takashi Iwai, Srini Kandagatla, Stephan Gerhold,
	dianders, dgreid, cychiang, judyhsiao, tzungbi, swboyd,
	linux-arm-kernel, linux-arm-msm, devicetree, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 656 bytes --]

On Mon, Jun 21, 2021 at 03:41:52PM +0800, Judy Hsiao wrote:

> Support for loading the snd-soc-dummy via DeviceTree.
> This is useful to create dummy codec devices where we need to have some
> DAI links without a real Codec.

Why would it be useful to create DAI links to a dummy device that has
no properties?  If you've got a device with no software control it's
still going to have some limits on things like what formats and sample
rates it can accept so you should describe that in DT.

Please try to keep the CC lists for patches you are submitting relevant
to the patch, people get a lot of mail and reviews for irrelevant
patches add to the noise.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] ASoC: snd-soc-dummy: add Device Tree support
  2021-06-21 11:45 ` Mark Brown
@ 2021-06-22 16:10   ` Judy Hsiao
  2021-06-22 16:23     ` Mark Brown
  0 siblings, 1 reply; 5+ messages in thread
From: Judy Hsiao @ 2021-06-22 16:10 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, Rob Herring, Jaroslav Kysela, Takashi Iwai,
	Douglas Anderson, Dylan Reid, Jimmy Cheng-Yi Chiang, Judy Hsiao,
	Tzung-Bi Shih, Stephen Boyd, linux-arm-kernel, linux-arm-msm,
	devicetree, alsa-devel

On Mon, Jun 21, 2021 at 7:46 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Mon, Jun 21, 2021 at 03:41:52PM +0800, Judy Hsiao wrote:
>
> > Support for loading the snd-soc-dummy via DeviceTree.
> > This is useful to create dummy codec devices where we need to have some
> > DAI links without a real Codec.
>
> Why would it be useful to create DAI links to a dummy device that has
> no properties?  If you've got a device with no software control it's
> still going to have some limits on things like what formats and sample
> rates it can accept so you should describe that in DT.

Thanks for your review comment.
This patch is used to support multi-channel where we want one codec to
control the only GPIO shared by 4 amps.
(Please refer to
:https://patchwork.kernel.org/project/alsa-devel/patch/20210526154704.114957-1-judyhsiao@chromium.org/)

In snd_soc_runtime_calc_hw(), by creating dummy codecs that share a
DAI link with a real codec:
  1. The min/ max channel of  CPU DAI will be directly adopted.
  2. The formats and sample rates of the DAI link will be determined
by the real codec unless the real codec supports the rate
      and format that do not intersect with the rate and format of
snd-soc-dummy.
That is the reason why we don’t specify the format and sample rates of
the dummy codec with the real codec determining the properties .

Does reposting a new patch with  a more clear commit message to
describe the use case sound good to you?
>
> Please try to keep the CC lists for patches you are submitting relevant
> to the patch, people get a lot of mail and reviews for irrelevant
> patches add to the noise.
Sorry about that. I have adjusted the CC lists.

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

* Re: [PATCH] ASoC: snd-soc-dummy: add Device Tree support
  2021-06-22 16:10   ` Judy Hsiao
@ 2021-06-22 16:23     ` Mark Brown
  2021-06-23 14:29       ` Judy Hsiao
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Brown @ 2021-06-22 16:23 UTC (permalink / raw)
  To: Judy Hsiao
  Cc: Liam Girdwood, Rob Herring, Jaroslav Kysela, Takashi Iwai,
	Douglas Anderson, Dylan Reid, Jimmy Cheng-Yi Chiang, Judy Hsiao,
	Tzung-Bi Shih, Stephen Boyd, linux-arm-kernel, linux-arm-msm,
	devicetree, alsa-devel

[-- Attachment #1: Type: text/plain, Size: 1199 bytes --]

On Wed, Jun 23, 2021 at 12:10:53AM +0800, Judy Hsiao wrote:

> Thanks for your review comment.
> This patch is used to support multi-channel where we want one codec to
> control the only GPIO shared by 4 amps.

So you've got 4 instances of the same CODEC?  Then I'd expect to see
those all individually represented in DT.  Or if there's a single
physical CODEC then I'm not sure what the dummies are for?

> In snd_soc_runtime_calc_hw(), by creating dummy codecs that share a
> DAI link with a real codec:
>   1. The min/ max channel of  CPU DAI will be directly adopted.
>   2. The formats and sample rates of the DAI link will be determined
> by the real codec unless the real codec supports the rate
>       and format that do not intersect with the rate and format of
> snd-soc-dummy.
> That is the reason why we don’t specify the format and sample rates of
> the dummy codec with the real codec determining the properties .

It's not clear to me why you'd not just describe the actual CODECs here
rather than using a dummy CODEC, the fact that the dummy CODEC is doing
what you want is just an accident of the implementation rather than a
description of the hardware.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] ASoC: snd-soc-dummy: add Device Tree support
  2021-06-22 16:23     ` Mark Brown
@ 2021-06-23 14:29       ` Judy Hsiao
  0 siblings, 0 replies; 5+ messages in thread
From: Judy Hsiao @ 2021-06-23 14:29 UTC (permalink / raw)
  To: Mark Brown
  Cc: Liam Girdwood, Rob Herring, Jaroslav Kysela, Takashi Iwai,
	Douglas Anderson, Dylan Reid, Jimmy Cheng-Yi Chiang, Judy Hsiao,
	Tzung-Bi Shih, Stephen Boyd, linux-arm-kernel, linux-arm-msm,
	devicetree, alsa-devel

On Wed, Jun 23, 2021 at 12:23 AM Mark Brown <broonie@kernel.org> wrote:
>
> On Wed, Jun 23, 2021 at 12:10:53AM +0800, Judy Hsiao wrote:
>
> > Thanks for your review comment.
> > This patch is used to support multi-channel where we want one codec to
> > control the only GPIO shared by 4 amps.
>
> So you've got 4 instances of the same CODEC?  Then I'd expect to see
> those all individually represented in DT.  Or if there's a single
> physical CODEC then I'm not sure what the dummies are for?
>
> > In snd_soc_runtime_calc_hw(), by creating dummy codecs that share a
> > DAI link with a real codec:
> >   1. The min/ max channel of  CPU DAI will be directly adopted.
> >   2. The formats and sample rates of the DAI link will be determined
> > by the real codec unless the real codec supports the rate
> >       and format that do not intersect with the rate and format of
> > snd-soc-dummy.
> > That is the reason why we don’t specify the format and sample rates of
> > the dummy codec with the real codec determining the properties .
>
> It's not clear to me why you'd not just describe the actual CODECs here
> rather than using a dummy CODEC, the fact that the dummy CODEC is doing
> what you want is just an accident of the implementation rather than a
> description of the hardware.

Thanks for your inputs. Specifying four codes for the multi-channel works fine.
We have not thought of specifying four codes before as we want to avoid loading
the codec driver multiple times, but actually loading the
snd-soc-dummy just has the
similar cost. By specifying four codes, the dtsi file describes the
real hardware schematic.
I will specify four codec in the dtsi file to support the four channel
use case and this
snd-soc-dummy patch is not needed. Thanks for the discussion!

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

end of thread, other threads:[~2021-06-23 14:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21  7:41 [PATCH] ASoC: snd-soc-dummy: add Device Tree support Judy Hsiao
2021-06-21 11:45 ` Mark Brown
2021-06-22 16:10   ` Judy Hsiao
2021-06-22 16:23     ` Mark Brown
2021-06-23 14:29       ` Judy Hsiao

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).