All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ASoC: simple-card: add support for aux devices
@ 2016-09-23  7:11 ` Nikita Yushchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Nikita Yushchenko @ 2016-09-23  7:11 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Mark Rutland,
	Jaroslav Kysela, Takashi Iwai, Otto Kekäläinen,
	Kuninori Morimoto, Mengdong Lin, Aaro Koskinen, Andrew Lunn,
	Peter Ujfalusi, alsa-devel, devicetree, linux-kernel
  Cc: Chris Healy, Nikita Yushchenko

This patch makes it possible to use simple-card in setups where separate
amplifier chip is connected to codec's output.

Changes from v1:
- moved example usage from commit message to Documentation/, as
  suggested by Kuninori Morimoto,
- fixed typo in example usage.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
 .../devicetree/bindings/sound/simple-card.txt      | 37 ++++++++++++++++++++++
 sound/soc/generic/simple-card.c                    | 34 ++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index 59d8628..c7a9393 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -22,6 +22,8 @@ Optional properties:
 					  headphones are attached.
 - simple-audio-card,mic-det-gpio	: Reference to GPIO that signals when
 					  a microphone is attached.
+- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
+					  as amplifiers, to be added to the sound card.
 
 Optional subnodes:
 
@@ -162,3 +164,38 @@ sound {
 		};
 	};
 };
+
+Example 3 - route audio from IMX6 SSI2 through TLV320DAC3100 codec
+through TPA6130A2 amplifier to headphones:
+
+&i2c0 {
+	codec: tlv320dac3100@18 {
+		compatible = "ti,tlv320dac3100";
+		...
+	}
+
+	amp: tpa6130a2@60 {
+		compatible = "ti,tpa6130a2";
+		...
+	}
+}
+
+sound {
+	compatible = "simple-audio-card";
+	...
+	simple-audio-card,widgets =
+		"Headphone", "Headphone Jack";
+	simple-audio-card,routing =
+		"Headphone Jack", "HPLEFT",
+		"Headphone Jack", "HPRIGHT",
+		"LEFTIN", "HPL",
+		"RIGHTIN", "HPR";
+	simple-audio-card,aux-devs = <&amp>;
+	simple-audio-card,cpu {
+		sound-dai = <&ssi2>;
+	};
+	simple-audio-card,codec {
+		sound-dai = <&codec>;
+		clocks = ...
+	};
+};
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 43295f0..f989f34 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -417,6 +417,36 @@ dai_link_of_err:
 	return ret;
 }
 
+static int asoc_simple_card_parse_aux_devs(struct device_node *node,
+					   struct simple_card_data *priv)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct device_node *aux_node;
+	int i, n, len;
+
+	if (!of_find_property(node, PREFIX "aux-devs", &len))
+		return 0;		/* Ok to have no aux-devs */
+
+	n = len / sizeof(__be32);
+	if (n <= 0)
+		return -EINVAL;
+
+	priv->snd_card.aux_dev = devm_kzalloc(dev,
+			n * sizeof(*priv->snd_card.aux_dev), GFP_KERNEL);
+	if (!priv->snd_card.aux_dev)
+		return -ENOMEM;
+
+	for (i = 0; i < n; i++) {
+		aux_node = of_parse_phandle(node, PREFIX "aux-devs", i);
+		if (!aux_node)
+			return -EINVAL;
+		priv->snd_card.aux_dev[i].codec_of_node = aux_node;
+	}
+
+	priv->snd_card.num_aux_devs = n;
+	return 0;
+}
+
 static int asoc_simple_card_parse_of(struct device_node *node,
 				     struct simple_card_data *priv)
 {
@@ -474,6 +504,10 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (ret)
 		return ret;
 
+	ret = asoc_simple_card_parse_aux_devs(node, priv);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.1.4

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

* [PATCH v2] ASoC: simple-card: add support for aux devices
@ 2016-09-23  7:11 ` Nikita Yushchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Nikita Yushchenko @ 2016-09-23  7:11 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Mark Rutland,
	Jaroslav Kysela, Takashi Iwai, Otto Kekäläinen,
	Kuninori Morimoto, Mengdong Lin, Aaro Koskinen, Andrew Lunn,
	Peter Ujfalusi, alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: Chris Healy, Nikita Yushchenko

This patch makes it possible to use simple-card in setups where separate
amplifier chip is connected to codec's output.

Changes from v1:
- moved example usage from commit message to Documentation/, as
  suggested by Kuninori Morimoto,
- fixed typo in example usage.

Signed-off-by: Nikita Yushchenko <nikita.yoush-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
---
 .../devicetree/bindings/sound/simple-card.txt      | 37 ++++++++++++++++++++++
 sound/soc/generic/simple-card.c                    | 34 ++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index 59d8628..c7a9393 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -22,6 +22,8 @@ Optional properties:
 					  headphones are attached.
 - simple-audio-card,mic-det-gpio	: Reference to GPIO that signals when
 					  a microphone is attached.
+- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
+					  as amplifiers, to be added to the sound card.
 
 Optional subnodes:
 
@@ -162,3 +164,38 @@ sound {
 		};
 	};
 };
+
+Example 3 - route audio from IMX6 SSI2 through TLV320DAC3100 codec
+through TPA6130A2 amplifier to headphones:
+
+&i2c0 {
+	codec: tlv320dac3100@18 {
+		compatible = "ti,tlv320dac3100";
+		...
+	}
+
+	amp: tpa6130a2@60 {
+		compatible = "ti,tpa6130a2";
+		...
+	}
+}
+
+sound {
+	compatible = "simple-audio-card";
+	...
+	simple-audio-card,widgets =
+		"Headphone", "Headphone Jack";
+	simple-audio-card,routing =
+		"Headphone Jack", "HPLEFT",
+		"Headphone Jack", "HPRIGHT",
+		"LEFTIN", "HPL",
+		"RIGHTIN", "HPR";
+	simple-audio-card,aux-devs = <&amp>;
+	simple-audio-card,cpu {
+		sound-dai = <&ssi2>;
+	};
+	simple-audio-card,codec {
+		sound-dai = <&codec>;
+		clocks = ...
+	};
+};
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index 43295f0..f989f34 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -417,6 +417,36 @@ dai_link_of_err:
 	return ret;
 }
 
+static int asoc_simple_card_parse_aux_devs(struct device_node *node,
+					   struct simple_card_data *priv)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct device_node *aux_node;
+	int i, n, len;
+
+	if (!of_find_property(node, PREFIX "aux-devs", &len))
+		return 0;		/* Ok to have no aux-devs */
+
+	n = len / sizeof(__be32);
+	if (n <= 0)
+		return -EINVAL;
+
+	priv->snd_card.aux_dev = devm_kzalloc(dev,
+			n * sizeof(*priv->snd_card.aux_dev), GFP_KERNEL);
+	if (!priv->snd_card.aux_dev)
+		return -ENOMEM;
+
+	for (i = 0; i < n; i++) {
+		aux_node = of_parse_phandle(node, PREFIX "aux-devs", i);
+		if (!aux_node)
+			return -EINVAL;
+		priv->snd_card.aux_dev[i].codec_of_node = aux_node;
+	}
+
+	priv->snd_card.num_aux_devs = n;
+	return 0;
+}
+
 static int asoc_simple_card_parse_of(struct device_node *node,
 				     struct simple_card_data *priv)
 {
@@ -474,6 +504,10 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	if (ret)
 		return ret;
 
+	ret = asoc_simple_card_parse_aux_devs(node, priv);
+	if (ret)
+		return ret;
+
 	return 0;
 }
 
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] ASoC: simple-card: add support for aux devices
  2016-09-23  7:11 ` Nikita Yushchenko
  (?)
@ 2016-09-23 22:25 ` Rob Herring
  2016-09-24  6:04     ` Nikita Yushchenko
                     ` (2 more replies)
  -1 siblings, 3 replies; 14+ messages in thread
From: Rob Herring @ 2016-09-23 22:25 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Liam Girdwood, Mark Brown, Mark Rutland, Jaroslav Kysela,
	Takashi Iwai, Otto Kekäläinen, Kuninori Morimoto,
	Mengdong Lin, Aaro Koskinen, Andrew Lunn, Peter Ujfalusi,
	alsa-devel, devicetree, linux-kernel, Chris Healy

On Fri, Sep 23, 2016 at 10:11:12AM +0300, Nikita Yushchenko wrote:
> This patch makes it possible to use simple-card in setups where separate
> amplifier chip is connected to codec's output.
> 
> Changes from v1:
> - moved example usage from commit message to Documentation/, as
>   suggested by Kuninori Morimoto,
> - fixed typo in example usage.

Ah, one more property to the "simple" card. At what point in adding 
properties is it not simple?

> 
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
> ---
>  .../devicetree/bindings/sound/simple-card.txt      | 37 ++++++++++++++++++++++
>  sound/soc/generic/simple-card.c                    | 34 ++++++++++++++++++++
>  2 files changed, 71 insertions(+)


> 
> diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
> index 59d8628..c7a9393 100644
> --- a/Documentation/devicetree/bindings/sound/simple-card.txt
> +++ b/Documentation/devicetree/bindings/sound/simple-card.txt
> @@ -22,6 +22,8 @@ Optional properties:
>  					  headphones are attached.
>  - simple-audio-card,mic-det-gpio	: Reference to GPIO that signals when
>  					  a microphone is attached.
> +- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
> +					  as amplifiers, to be added to the sound card.

I think the property should be specific as to the type of device. What 
if you have 2 amps? Maybe simple-card can't have 2 outputs. What if you 
have a chain of devices and need to know the order of them?

Rob

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

* Re: [PATCH v2] ASoC: simple-card: add support for aux devices
  2016-09-23 22:25 ` Rob Herring
@ 2016-09-24  6:04     ` Nikita Yushchenko
  2016-09-24 17:58     ` Mark Brown
  2016-09-24 18:00     ` Mark Brown
  2 siblings, 0 replies; 14+ messages in thread
From: Nikita Yushchenko @ 2016-09-24  6:04 UTC (permalink / raw)
  To: Rob Herring
  Cc: Liam Girdwood, Mark Brown, Mark Rutland, Jaroslav Kysela,
	Takashi Iwai, Otto Kekäläinen, Kuninori Morimoto,
	Mengdong Lin, Aaro Koskinen, Andrew Lunn, Peter Ujfalusi,
	alsa-devel, devicetree, linux-kernel, Chris Healy

>> Changes from v1:
>> - moved example usage from commit message to Documentation/, as
>>   suggested by Kuninori Morimoto,
>> - fixed typo in example usage.
> 
> Ah, one more property to the "simple" card. At what point in adding 
> properties is it not simple?

AFAIU, idea is to have a pure-device-tree-controlled audio device (i.e.
without dedicated machine driver).

Perhaps it should be just renamed at some point.

>> +- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
>> +					  as amplifiers, to be added to the sound card.
> 
> I think the property should be specific as to the type of device. What 
> if you have 2 amps? Maybe simple-card can't have 2 outputs. What if you 
> have a chain of devices and need to know the order of them?

snd_soc_card has unordered list of aux devices. Things you mention are
controlled are configured via routing.

Nikita

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

* Re: [PATCH v2] ASoC: simple-card: add support for aux devices
@ 2016-09-24  6:04     ` Nikita Yushchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Nikita Yushchenko @ 2016-09-24  6:04 UTC (permalink / raw)
  To: Rob Herring
  Cc: Liam Girdwood, Mark Brown, Mark Rutland, Jaroslav Kysela,
	Takashi Iwai, Otto Kekäläinen, Kuninori Morimoto,
	Mengdong Lin, Aaro Koskinen, Andrew Lunn, Peter Ujfalusi,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Chris Healy

>> Changes from v1:
>> - moved example usage from commit message to Documentation/, as
>>   suggested by Kuninori Morimoto,
>> - fixed typo in example usage.
> 
> Ah, one more property to the "simple" card. At what point in adding 
> properties is it not simple?

AFAIU, idea is to have a pure-device-tree-controlled audio device (i.e.
without dedicated machine driver).

Perhaps it should be just renamed at some point.

>> +- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
>> +					  as amplifiers, to be added to the sound card.
> 
> I think the property should be specific as to the type of device. What 
> if you have 2 amps? Maybe simple-card can't have 2 outputs. What if you 
> have a chain of devices and need to know the order of them?

snd_soc_card has unordered list of aux devices. Things you mention are
controlled are configured via routing.

Nikita
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [PATCH v2] ASoC: simple-card: add support for aux devices
  2016-09-23 22:25 ` Rob Herring
@ 2016-09-24 17:58     ` Mark Brown
  2016-09-24 17:58     ` Mark Brown
  2016-09-24 18:00     ` Mark Brown
  2 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2016-09-24 17:58 UTC (permalink / raw)
  To: Rob Herring
  Cc: Nikita Yushchenko, Liam Girdwood, Mark Rutland, Jaroslav Kysela,
	Takashi Iwai, Otto Kekäläinen, Kuninori Morimoto,
	Mengdong Lin, Aaro Koskinen, Andrew Lunn, Peter Ujfalusi,
	alsa-devel, devicetree, linux-kernel, Chris Healy

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

On Fri, Sep 23, 2016 at 05:25:41PM -0500, Rob Herring wrote:

> Ah, one more property to the "simple" card. At what point in adding 
> properties is it not simple?

There are a *lot* of tunables for audio subsystems and a lot of ways
they can be designed, this is why complaining at the less realistic DT
advocates who object to having a card at all.  Probably most cards won't
use anything like all the properties but simple-card does cover a large
proportion of common place cards and keeps those DT advocates who object
to having a card object at all happier.

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

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

* Re: [PATCH v2] ASoC: simple-card: add support for aux devices
@ 2016-09-24 17:58     ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2016-09-24 17:58 UTC (permalink / raw)
  To: Rob Herring
  Cc: Nikita Yushchenko, Liam Girdwood, Mark Rutland, Jaroslav Kysela,
	Takashi Iwai, Otto Kekäläinen, Kuninori Morimoto,
	Mengdong Lin, Aaro Koskinen, Andrew Lunn, Peter Ujfalusi,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Chris Healy

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

On Fri, Sep 23, 2016 at 05:25:41PM -0500, Rob Herring wrote:

> Ah, one more property to the "simple" card. At what point in adding 
> properties is it not simple?

There are a *lot* of tunables for audio subsystems and a lot of ways
they can be designed, this is why complaining at the less realistic DT
advocates who object to having a card at all.  Probably most cards won't
use anything like all the properties but simple-card does cover a large
proportion of common place cards and keeps those DT advocates who object
to having a card object at all happier.

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

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

* Re: [PATCH v2] ASoC: simple-card: add support for aux devices
  2016-09-23 22:25 ` Rob Herring
@ 2016-09-24 18:00     ` Mark Brown
  2016-09-24 17:58     ` Mark Brown
  2016-09-24 18:00     ` Mark Brown
  2 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2016-09-24 18:00 UTC (permalink / raw)
  To: Rob Herring
  Cc: Nikita Yushchenko, Liam Girdwood, Mark Rutland, Jaroslav Kysela,
	Takashi Iwai, Otto Kekäläinen, Kuninori Morimoto,
	Mengdong Lin, Aaro Koskinen, Andrew Lunn, Peter Ujfalusi,
	alsa-devel, devicetree, linux-kernel, Chris Healy

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

On Fri, Sep 23, 2016 at 05:25:41PM -0500, Rob Herring wrote:
> On Fri, Sep 23, 2016 at 10:11:12AM +0300, Nikita Yushchenko wrote:

> > +- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
> > +					  as amplifiers, to be added to the sound card.

> I think the property should be specific as to the type of device. What 
> if you have 2 amps? Maybe simple-card can't have 2 outputs. What if you 
> have a chain of devices and need to know the order of them?

Sorry, missed this bit...  We already have the audio routing properties
which define how things are interconnected, this exists to get pure
analogue components into the set of things that can be routed to.  The
abstraction we're using hides what the device is well enough.

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

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

* Re: [PATCH v2] ASoC: simple-card: add support for aux devices
@ 2016-09-24 18:00     ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2016-09-24 18:00 UTC (permalink / raw)
  To: Rob Herring
  Cc: Nikita Yushchenko, Liam Girdwood, Mark Rutland, Jaroslav Kysela,
	Takashi Iwai, Otto Kekäläinen, Kuninori Morimoto,
	Mengdong Lin, Aaro Koskinen, Andrew Lunn, Peter Ujfalusi,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, Chris Healy

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

On Fri, Sep 23, 2016 at 05:25:41PM -0500, Rob Herring wrote:
> On Fri, Sep 23, 2016 at 10:11:12AM +0300, Nikita Yushchenko wrote:

> > +- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
> > +					  as amplifiers, to be added to the sound card.

> I think the property should be specific as to the type of device. What 
> if you have 2 amps? Maybe simple-card can't have 2 outputs. What if you 
> have a chain of devices and need to know the order of them?

Sorry, missed this bit...  We already have the audio routing properties
which define how things are interconnected, this exists to get pure
analogue components into the set of things that can be routed to.  The
abstraction we're using hides what the device is well enough.

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

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

* Re: [PATCH v2] ASoC: simple-card: add support for aux devices
  2016-09-23  7:11 ` Nikita Yushchenko
  (?)
  (?)
@ 2016-09-24 18:03 ` Mark Brown
  2016-09-26  9:56     ` Nikita Yushchenko
  -1 siblings, 1 reply; 14+ messages in thread
From: Mark Brown @ 2016-09-24 18:03 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Liam Girdwood, Rob Herring, Mark Rutland, Jaroslav Kysela,
	Takashi Iwai, Otto Kekäläinen, Kuninori Morimoto,
	Mengdong Lin, Aaro Koskinen, Andrew Lunn, Peter Ujfalusi,
	alsa-devel, devicetree, linux-kernel, Chris Healy

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

On Fri, Sep 23, 2016 at 10:11:12AM +0300, Nikita Yushchenko wrote:
> This patch makes it possible to use simple-card in setups where separate
> amplifier chip is connected to codec's output.

This doesn't apply to current code, please check and resend.

> Changes from v1:

Please put any process noise like inter version changelogs that isn't
part of the changelog itself after the --- as covered in
SubmittingPatches.

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

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

* [PATCH] ASoC: simple-card: add support for aux devices
@ 2016-09-26  9:56     ` Nikita Yushchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Nikita Yushchenko @ 2016-09-26  9:56 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Mark Rutland,
	Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, alsa-devel,
	devicetree, linux-kernel
  Cc: Chris Healy, Nikita Yushchenko

Add device tree property to define auxiliary devices to be added to
simle-audio-card.

Together with proper audio routing definition, this allows to use
simple-card in setups where separate amplifier chip is connected to
codec's output.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
Rebased against commit b0133d9c4d76 ("ASoC: simple-card: use kzalloc()
for dai_props / dai_link") in branch 'topic/simple' of
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

Updated patch description to mention audio routing.

 .../devicetree/bindings/sound/simple-card.txt      | 37 ++++++++++++++++++++++
 sound/soc/generic/simple-card.c                    | 34 ++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index cf3979eb3578..5ecdde6d9f63 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -22,6 +22,8 @@ Optional properties:
 					  headphones are attached.
 - simple-audio-card,mic-det-gpio	: Reference to GPIO that signals when
 					  a microphone is attached.
+- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
+					  as amplifiers, to be added to the sound card.
 
 Optional subnodes:
 
@@ -162,3 +164,38 @@ sound {
 		};
 	};
 };
+
+Example 3 - route audio from IMX6 SSI2 through TLV320DAC3100 codec
+through TPA6130A2 amplifier to headphones:
+
+&i2c0 {
+	codec: tlv320dac3100@18 {
+		compatible = "ti,tlv320dac3100";
+		...
+	}
+
+	amp: tpa6130a2@60 {
+		compatible = "ti,tpa6130a2";
+		...
+	}
+}
+
+sound {
+	compatible = "simple-audio-card";
+	...
+	simple-audio-card,widgets =
+		"Headphone", "Headphone Jack";
+	simple-audio-card,routing =
+		"Headphone Jack", "HPLEFT",
+		"Headphone Jack", "HPRIGHT",
+		"LEFTIN", "HPL",
+		"RIGHTIN", "HPR";
+	simple-audio-card,aux-devs = <&amp>;
+	simple-audio-card,cpu {
+		sound-dai = <&ssi2>;
+	};
+	simple-audio-card,codec {
+		sound-dai = <&codec>;
+		clocks = ...
+	};
+};
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index fe0bc5c469e2..f608f8d23f3d 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -318,6 +318,36 @@ dai_link_of_err:
 	return ret;
 }
 
+static int asoc_simple_card_parse_aux_devs(struct device_node *node,
+					   struct simple_card_data *priv)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct device_node *aux_node;
+	int i, n, len;
+
+	if (!of_find_property(node, PREFIX "aux-devs", &len))
+		return 0;		/* Ok to have no aux-devs */
+
+	n = len / sizeof(__be32);
+	if (n <= 0)
+		return -EINVAL;
+
+	priv->snd_card.aux_dev = devm_kzalloc(dev,
+			n * sizeof(*priv->snd_card.aux_dev), GFP_KERNEL);
+	if (!priv->snd_card.aux_dev)
+		return -ENOMEM;
+
+	for (i = 0; i < n; i++) {
+		aux_node = of_parse_phandle(node, PREFIX "aux-devs", i);
+		if (!aux_node)
+			return -EINVAL;
+		priv->snd_card.aux_dev[i].codec_of_node = aux_node;
+	}
+
+	priv->snd_card.num_aux_devs = n;
+	return 0;
+}
+
 static int asoc_simple_card_parse_of(struct device_node *node,
 				     struct simple_card_data *priv)
 {
@@ -372,6 +402,10 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	}
 
 	ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
+	if (ret < 0)
+		goto card_parse_end;
+
+	ret = asoc_simple_card_parse_aux_devs(node, priv);
 
 card_parse_end:
 	of_node_put(dai_link);
-- 
2.1.4

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

* [PATCH] ASoC: simple-card: add support for aux devices
@ 2016-09-26  9:56     ` Nikita Yushchenko
  0 siblings, 0 replies; 14+ messages in thread
From: Nikita Yushchenko @ 2016-09-26  9:56 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Rob Herring, Mark Rutland,
	Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto,
	alsa-devel-K7yf7f+aM1XWsZ/bQMPhNw,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
  Cc: Chris Healy, Nikita Yushchenko

Add device tree property to define auxiliary devices to be added to
simle-audio-card.

Together with proper audio routing definition, this allows to use
simple-card in setups where separate amplifier chip is connected to
codec's output.

Signed-off-by: Nikita Yushchenko <nikita.yoush-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
---
Rebased against commit b0133d9c4d76 ("ASoC: simple-card: use kzalloc()
for dai_props / dai_link") in branch 'topic/simple' of
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git

Updated patch description to mention audio routing.

 .../devicetree/bindings/sound/simple-card.txt      | 37 ++++++++++++++++++++++
 sound/soc/generic/simple-card.c                    | 34 ++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index cf3979eb3578..5ecdde6d9f63 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -22,6 +22,8 @@ Optional properties:
 					  headphones are attached.
 - simple-audio-card,mic-det-gpio	: Reference to GPIO that signals when
 					  a microphone is attached.
+- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
+					  as amplifiers, to be added to the sound card.
 
 Optional subnodes:
 
@@ -162,3 +164,38 @@ sound {
 		};
 	};
 };
+
+Example 3 - route audio from IMX6 SSI2 through TLV320DAC3100 codec
+through TPA6130A2 amplifier to headphones:
+
+&i2c0 {
+	codec: tlv320dac3100@18 {
+		compatible = "ti,tlv320dac3100";
+		...
+	}
+
+	amp: tpa6130a2@60 {
+		compatible = "ti,tpa6130a2";
+		...
+	}
+}
+
+sound {
+	compatible = "simple-audio-card";
+	...
+	simple-audio-card,widgets =
+		"Headphone", "Headphone Jack";
+	simple-audio-card,routing =
+		"Headphone Jack", "HPLEFT",
+		"Headphone Jack", "HPRIGHT",
+		"LEFTIN", "HPL",
+		"RIGHTIN", "HPR";
+	simple-audio-card,aux-devs = <&amp>;
+	simple-audio-card,cpu {
+		sound-dai = <&ssi2>;
+	};
+	simple-audio-card,codec {
+		sound-dai = <&codec>;
+		clocks = ...
+	};
+};
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index fe0bc5c469e2..f608f8d23f3d 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -318,6 +318,36 @@ dai_link_of_err:
 	return ret;
 }
 
+static int asoc_simple_card_parse_aux_devs(struct device_node *node,
+					   struct simple_card_data *priv)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct device_node *aux_node;
+	int i, n, len;
+
+	if (!of_find_property(node, PREFIX "aux-devs", &len))
+		return 0;		/* Ok to have no aux-devs */
+
+	n = len / sizeof(__be32);
+	if (n <= 0)
+		return -EINVAL;
+
+	priv->snd_card.aux_dev = devm_kzalloc(dev,
+			n * sizeof(*priv->snd_card.aux_dev), GFP_KERNEL);
+	if (!priv->snd_card.aux_dev)
+		return -ENOMEM;
+
+	for (i = 0; i < n; i++) {
+		aux_node = of_parse_phandle(node, PREFIX "aux-devs", i);
+		if (!aux_node)
+			return -EINVAL;
+		priv->snd_card.aux_dev[i].codec_of_node = aux_node;
+	}
+
+	priv->snd_card.num_aux_devs = n;
+	return 0;
+}
+
 static int asoc_simple_card_parse_of(struct device_node *node,
 				     struct simple_card_data *priv)
 {
@@ -372,6 +402,10 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	}
 
 	ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
+	if (ret < 0)
+		goto card_parse_end;
+
+	ret = asoc_simple_card_parse_aux_devs(node, priv);
 
 card_parse_end:
 	of_node_put(dai_link);
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Applied "ASoC: simple-card: add support for aux devices" to the asoc tree
@ 2016-09-26 16:15       ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2016-09-26 16:15 UTC (permalink / raw)
  To: Nikita Yushchenko
  Cc: Mark Brown, Liam Girdwood, Mark Brown, Rob Herring, Mark Rutland,
	Jaroslav Kysela, Takashi Iwai, Kuninori Morimoto, alsa-devel,
	devicetree, linux-kernel, Chris Healy, alsa-devel

The patch

   ASoC: simple-card: add support for aux devices

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 899a247cf6d5bbb9eb799261791441d7d5ea2099 Mon Sep 17 00:00:00 2001
From: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Date: Mon, 26 Sep 2016 12:56:51 +0300
Subject: [PATCH] ASoC: simple-card: add support for aux devices

Add device tree property to define auxiliary devices to be added to
simle-audio-card.

Together with proper audio routing definition, this allows to use
simple-card in setups where separate amplifier chip is connected to
codec's output.

Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 .../devicetree/bindings/sound/simple-card.txt      | 37 ++++++++++++++++++++++
 sound/soc/generic/simple-card.c                    | 34 ++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index cf3979eb3578..5ecdde6d9f63 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -22,6 +22,8 @@ Optional properties:
 					  headphones are attached.
 - simple-audio-card,mic-det-gpio	: Reference to GPIO that signals when
 					  a microphone is attached.
+- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
+					  as amplifiers, to be added to the sound card.
 
 Optional subnodes:
 
@@ -162,3 +164,38 @@ sound {
 		};
 	};
 };
+
+Example 3 - route audio from IMX6 SSI2 through TLV320DAC3100 codec
+through TPA6130A2 amplifier to headphones:
+
+&i2c0 {
+	codec: tlv320dac3100@18 {
+		compatible = "ti,tlv320dac3100";
+		...
+	}
+
+	amp: tpa6130a2@60 {
+		compatible = "ti,tpa6130a2";
+		...
+	}
+}
+
+sound {
+	compatible = "simple-audio-card";
+	...
+	simple-audio-card,widgets =
+		"Headphone", "Headphone Jack";
+	simple-audio-card,routing =
+		"Headphone Jack", "HPLEFT",
+		"Headphone Jack", "HPRIGHT",
+		"LEFTIN", "HPL",
+		"RIGHTIN", "HPR";
+	simple-audio-card,aux-devs = <&amp>;
+	simple-audio-card,cpu {
+		sound-dai = <&ssi2>;
+	};
+	simple-audio-card,codec {
+		sound-dai = <&codec>;
+		clocks = ...
+	};
+};
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index fe0bc5c469e2..f608f8d23f3d 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -318,6 +318,36 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
 	return ret;
 }
 
+static int asoc_simple_card_parse_aux_devs(struct device_node *node,
+					   struct simple_card_data *priv)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct device_node *aux_node;
+	int i, n, len;
+
+	if (!of_find_property(node, PREFIX "aux-devs", &len))
+		return 0;		/* Ok to have no aux-devs */
+
+	n = len / sizeof(__be32);
+	if (n <= 0)
+		return -EINVAL;
+
+	priv->snd_card.aux_dev = devm_kzalloc(dev,
+			n * sizeof(*priv->snd_card.aux_dev), GFP_KERNEL);
+	if (!priv->snd_card.aux_dev)
+		return -ENOMEM;
+
+	for (i = 0; i < n; i++) {
+		aux_node = of_parse_phandle(node, PREFIX "aux-devs", i);
+		if (!aux_node)
+			return -EINVAL;
+		priv->snd_card.aux_dev[i].codec_of_node = aux_node;
+	}
+
+	priv->snd_card.num_aux_devs = n;
+	return 0;
+}
+
 static int asoc_simple_card_parse_of(struct device_node *node,
 				     struct simple_card_data *priv)
 {
@@ -372,6 +402,10 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	}
 
 	ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
+	if (ret < 0)
+		goto card_parse_end;
+
+	ret = asoc_simple_card_parse_aux_devs(node, priv);
 
 card_parse_end:
 	of_node_put(dai_link);
-- 
2.9.3

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

* Applied "ASoC: simple-card: add support for aux devices" to the asoc tree
@ 2016-09-26 16:15       ` Mark Brown
  0 siblings, 0 replies; 14+ messages in thread
From: Mark Brown @ 2016-09-26 16:15 UTC (permalink / raw)
  To: Nikita Yushchenko; +Cc: Mark Brown, Liam Girdwood

The patch

   ASoC: simple-card: add support for aux devices

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 899a247cf6d5bbb9eb799261791441d7d5ea2099 Mon Sep 17 00:00:00 2001
From: Nikita Yushchenko <nikita.yoush-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
Date: Mon, 26 Sep 2016 12:56:51 +0300
Subject: [PATCH] ASoC: simple-card: add support for aux devices

Add device tree property to define auxiliary devices to be added to
simle-audio-card.

Together with proper audio routing definition, this allows to use
simple-card in setups where separate amplifier chip is connected to
codec's output.

Signed-off-by: Nikita Yushchenko <nikita.yoush-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
Signed-off-by: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>
---
 .../devicetree/bindings/sound/simple-card.txt      | 37 ++++++++++++++++++++++
 sound/soc/generic/simple-card.c                    | 34 ++++++++++++++++++++
 2 files changed, 71 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/simple-card.txt b/Documentation/devicetree/bindings/sound/simple-card.txt
index cf3979eb3578..5ecdde6d9f63 100644
--- a/Documentation/devicetree/bindings/sound/simple-card.txt
+++ b/Documentation/devicetree/bindings/sound/simple-card.txt
@@ -22,6 +22,8 @@ Optional properties:
 					  headphones are attached.
 - simple-audio-card,mic-det-gpio	: Reference to GPIO that signals when
 					  a microphone is attached.
+- simple-audio-card,aux-devs		: List of phandles pointing to auxiliary devices, such
+					  as amplifiers, to be added to the sound card.
 
 Optional subnodes:
 
@@ -162,3 +164,38 @@ sound {
 		};
 	};
 };
+
+Example 3 - route audio from IMX6 SSI2 through TLV320DAC3100 codec
+through TPA6130A2 amplifier to headphones:
+
+&i2c0 {
+	codec: tlv320dac3100@18 {
+		compatible = "ti,tlv320dac3100";
+		...
+	}
+
+	amp: tpa6130a2@60 {
+		compatible = "ti,tpa6130a2";
+		...
+	}
+}
+
+sound {
+	compatible = "simple-audio-card";
+	...
+	simple-audio-card,widgets =
+		"Headphone", "Headphone Jack";
+	simple-audio-card,routing =
+		"Headphone Jack", "HPLEFT",
+		"Headphone Jack", "HPRIGHT",
+		"LEFTIN", "HPL",
+		"RIGHTIN", "HPR";
+	simple-audio-card,aux-devs = <&amp>;
+	simple-audio-card,cpu {
+		sound-dai = <&ssi2>;
+	};
+	simple-audio-card,codec {
+		sound-dai = <&codec>;
+		clocks = ...
+	};
+};
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c
index fe0bc5c469e2..f608f8d23f3d 100644
--- a/sound/soc/generic/simple-card.c
+++ b/sound/soc/generic/simple-card.c
@@ -318,6 +318,36 @@ static int asoc_simple_card_dai_link_of(struct device_node *node,
 	return ret;
 }
 
+static int asoc_simple_card_parse_aux_devs(struct device_node *node,
+					   struct simple_card_data *priv)
+{
+	struct device *dev = simple_priv_to_dev(priv);
+	struct device_node *aux_node;
+	int i, n, len;
+
+	if (!of_find_property(node, PREFIX "aux-devs", &len))
+		return 0;		/* Ok to have no aux-devs */
+
+	n = len / sizeof(__be32);
+	if (n <= 0)
+		return -EINVAL;
+
+	priv->snd_card.aux_dev = devm_kzalloc(dev,
+			n * sizeof(*priv->snd_card.aux_dev), GFP_KERNEL);
+	if (!priv->snd_card.aux_dev)
+		return -ENOMEM;
+
+	for (i = 0; i < n; i++) {
+		aux_node = of_parse_phandle(node, PREFIX "aux-devs", i);
+		if (!aux_node)
+			return -EINVAL;
+		priv->snd_card.aux_dev[i].codec_of_node = aux_node;
+	}
+
+	priv->snd_card.num_aux_devs = n;
+	return 0;
+}
+
 static int asoc_simple_card_parse_of(struct device_node *node,
 				     struct simple_card_data *priv)
 {
@@ -372,6 +402,10 @@ static int asoc_simple_card_parse_of(struct device_node *node,
 	}
 
 	ret = asoc_simple_card_parse_card_name(&priv->snd_card, PREFIX);
+	if (ret < 0)
+		goto card_parse_end;
+
+	ret = asoc_simple_card_parse_aux_devs(node, priv);
 
 card_parse_end:
 	of_node_put(dai_link);
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2016-09-26 16:16 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-23  7:11 [PATCH v2] ASoC: simple-card: add support for aux devices Nikita Yushchenko
2016-09-23  7:11 ` Nikita Yushchenko
2016-09-23 22:25 ` Rob Herring
2016-09-24  6:04   ` Nikita Yushchenko
2016-09-24  6:04     ` Nikita Yushchenko
2016-09-24 17:58   ` Mark Brown
2016-09-24 17:58     ` Mark Brown
2016-09-24 18:00   ` Mark Brown
2016-09-24 18:00     ` Mark Brown
2016-09-24 18:03 ` Mark Brown
2016-09-26  9:56   ` [PATCH] " Nikita Yushchenko
2016-09-26  9:56     ` Nikita Yushchenko
2016-09-26 16:15     ` Applied "ASoC: simple-card: add support for aux devices" to the asoc tree Mark Brown
2016-09-26 16:15       ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.