Benoit Cousson | 21 Mar 16:27 2014

[RFT v2 0/6] ASoC: core: Add support for DAI multicodec

Hi Mark and Liam,

Here is the second version of the multicodec series. I mostly rebased the code
to asoc-next, added smaller patches to introduce helpers before the main patch
and thus reduce the overal size of that patch and modified the TDM slot fixup.

Please note that I have a very simple setup based on BBB to check if the series
is working, so it will be good to test the series on various setup to ensure
this is not generating any regression.
Hence the RFT for this version.

The series is based on asoc-v3.15-2-245-g876dea8.

Test and comments are welcome.

Thanks,
Benoit

v1: http://comments.gmane.org/gmane.linux.alsa.devel/120532

v2:
- Split the first version in several patches.
- Remove the TDM fixup 

---
Misael Lopez Cruz (6):
  ASoC: core: Add helpers for codec and codec_dai search
  ASoC: core: Add helpers for codec DAI probe & remove
  ASoC: core: Add helper for DAI widgets linking
  ASoC: core: Add function for ac97 codec registration
(Continue reading)

Benoit Cousson | 21 Mar 16:27 2014

[RFT v2 1/6] ASoC: core: Add helpers for codec and codec_dai search

From: Misael Lopez Cruz <misael.lopez <at> ti.com>

Add dedicated helpers for codec and codec_dai search in preparation
for DAI-multicodec. It will help reducing the extra indentation
that will be introduced by the iteration over multiple codecs.

Previous implementation unnecessarily kept searching for a matching
codec in the remaining register codecs even if it was already found.

Fix that by returning in case of matching.

Signed-off-by: Misael Lopez Cruz <misael.lopez <at> ti.com>
[fparent <at> baylibre.com: Adapt to 3.14+]
Signed-off-by: Fabien Parent <fparent <at> baylibre.com>
Signed-off-by: Benoit Cousson <bcousson <at> baylibre.com>
---
 sound/soc/soc-core.c | 79 +++++++++++++++++++++++++++++++---------------------
 1 file changed, 47 insertions(+), 32 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index b322cf2..ab65137 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
 <at>  <at>  -854,14 +854,47  <at>  <at>  EXPORT_SYMBOL_GPL(snd_soc_resume);
 static const struct snd_soc_dai_ops null_dai_ops = {
 };

+static struct snd_soc_codec *soc_find_codec(const struct device_node *codec_of_node,
+					    const char *codec_name)
+{
(Continue reading)

Benoit Cousson | 21 Mar 16:27 2014

[RFT v2 2/6] ASoC: core: Add helpers for codec DAI probe & remove

From: Misael Lopez Cruz <misael.lopez <at> ti.com>

Add helper functions for codec DAI probe and remove in
preparation for DAI-multicodec support.

No functional change.

Signed-off-by: Misael Lopez Cruz <misael.lopez <at> ti.com>
[fparent <at> baylibre.com: Adapt to 3.14+]
Signed-off-by: Fabien Parent <fparent <at> baylibre.com>
Signed-off-by: Benoit Cousson <bcousson <at> baylibre.com>
---
 sound/soc/soc-core.c | 74 +++++++++++++++++++++++++++++++++-------------------
 1 file changed, 47 insertions(+), 27 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index ab65137..1bcc446 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
 <at>  <at>  -1010,21 +1010,10  <at>  <at>  static void soc_remove_codec(struct snd_soc_codec *codec)
 	module_put(codec->dev->driver->owner);
 }

-static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order)
+static void soc_remove_codec_dai(struct snd_soc_dai *codec_dai, int order)
 {
-	struct snd_soc_pcm_runtime *rtd = &card->rtd[num];
-	struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai;
 	int err;

(Continue reading)

Benoit Cousson | 21 Mar 16:27 2014

[RFT v2 3/6] ASoC: core: Add helper for DAI widgets linking

From: Misael Lopez Cruz <misael.lopez <at> ti.com>

Add a helper for DAI widgets linking in preparation for
DAI-multicodec support.

No functional change.

Signed-off-by: Misael Lopez Cruz <misael.lopez <at> ti.com>
[fparent <at> baylibre.com: Adapt to 3.14+]
Signed-off-by: Fabien Parent <fparent <at> baylibre.com>
Signed-off-by: Benoit Cousson <bcousson <at> baylibre.com>
---
 sound/soc/soc-core.c | 64 ++++++++++++++++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 24 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1bcc446..1debe3d 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
 <at>  <at>  -1418,6 +1418,42  <at>  <at>  static int soc_probe_codec_dai(struct snd_soc_card *card,
 	return 0;
 }

+static int soc_link_dai_widgets(struct snd_soc_card *card,
+				struct snd_soc_dai_link *dai_link,
+				struct snd_soc_dai *cpu_dai,
+				struct snd_soc_dai *codec_dai)
+{
+	struct snd_soc_dapm_widget *play_w, *capture_w;
+	int ret;
(Continue reading)

Benoit Cousson | 21 Mar 16:27 2014

[RFT v2 4/6] ASoC: core: Add function for ac97 codec registration

From: Misael Lopez Cruz <misael.lopez <at> ti.com>

Add codec registration specific function in preparation
for DAI-multicodec support.

No functional change.

Signed-off-by: Misael Lopez Cruz <misael.lopez <at> ti.com>
[fparent <at> baylibre.com: Adapt to 3.14+]
Signed-off-by: Fabien Parent <fparent <at> baylibre.com>
Signed-off-by: Benoit Cousson <bcousson <at> baylibre.com>
---
 sound/soc/soc-core.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 1debe3d..76fdf43 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
 <at>  <at>  -1557,14 +1557,15  <at>  <at>  static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order)
 }

 #ifdef CONFIG_SND_SOC_AC97_BUS
-static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd)
+static int soc_register_ac97_codec(struct snd_soc_codec *codec,
+				   struct snd_soc_dai *codec_dai)
 {
 	int ret;

 	/* Only instantiate AC97 if not already done by the adaptor
(Continue reading)

Benoit Cousson | 21 Mar 16:27 2014

[RFT v2 5/6] ASoC: core: Add helpers for dai link and aux dev init

From: Misael Lopez Cruz <misael.lopez <at> ti.com>

Separate DAI link and aux dev initialization in preparation for
DAI multicodec support.
Since aux dev will remain using single codecs but DAI links
will be able to support multiple codecs.

No functional change.

Signed-off-by: Misael Lopez Cruz <misael.lopez <at> ti.com>
[fparent <at> baylibre.com: Adapt to 3.14+]
Signed-off-by: Fabien Parent <fparent <at> baylibre.com>
Signed-off-by: Benoit Cousson <bcousson <at> baylibre.com>
---
 sound/soc/soc-core.c | 74 ++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 60 insertions(+), 14 deletions(-)

diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index 76fdf43..cfa481e 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
 <at>  <at>  -1268,6 +1268,63  <at>  <at>  static void rtd_release(struct device *dev)
 	kfree(dev);
 }

+static int soc_aux_dev_init(struct snd_soc_card *card,
+			    struct snd_soc_codec *codec,
+			    int num)
+{
+	struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num];
(Continue reading)

Mark Brown | 14 Apr 21:39 2014

Re: [RFT v2 5/6] ASoC: core: Add helpers for dai link and aux dev init

On Fri, Mar 21, 2014 at 04:27:29PM +0100, Benoit Cousson wrote:
> From: Misael Lopez Cruz <misael.lopez <at> ti.com>
> 
> Separate DAI link and aux dev initialization in preparation for
> DAI multicodec support.
> Since aux dev will remain using single codecs but DAI links
> will be able to support multiple codecs.

I applied everything up to here.  This one didn't apply, probably due to
context changes but I didn't make any real effort to understand the
issue.
On Fri, Mar 21, 2014 at 04:27:29PM +0100, Benoit Cousson wrote:
> From: Misael Lopez Cruz <misael.lopez <at> ti.com>
> 
> Separate DAI link and aux dev initialization in preparation for
> DAI multicodec support.
> Since aux dev will remain using single codecs but DAI links
> will be able to support multiple codecs.

I applied everything up to here.  This one didn't apply, probably due to
context changes but I didn't make any real effort to understand the
issue.
Benoit Cousson | 14 Apr 22:12 2014

Re: [RFT v2 5/6] ASoC: core: Add helpers for dai link and aux dev init

Hi Mark,

On 14/04/2014 21:39, Mark Brown wrote:
> On Fri, Mar 21, 2014 at 04:27:29PM +0100, Benoit Cousson wrote:
>> From: Misael Lopez Cruz <misael.lopez <at> ti.com>
>>
>> Separate DAI link and aux dev initialization in preparation for
>> DAI multicodec support.
>> Since aux dev will remain using single codecs but DAI links
>> will be able to support multiple codecs.
>
> I applied everything up to here.  This one didn't apply, probably due to
> context changes but I didn't make any real effort to understand the
> issue.

Yep, I've just seen that. It is indeed a small move in the previous 
context code.

I'm still in the process of updating the series based on Lars comments, 
but was somehow too busy the last 2 weeks to complete the changes.
I should be able to post the update this week.

Sorry for the delay.

Thanks,
Benoit

--

-- 
BenoƮt Cousson
BayLibre
(Continue reading)

Benoit Cousson | 21 Mar 16:27 2014

[RFT v2 6/6] ASoC: core: Add support for DAI multicodec

From: Misael Lopez Cruz <misael.lopez <at> ti.com>

DAI link assumes a one to one mapping between CPU DAI and CODEC. In
some cases, the same CPU DAI can be connected to several codecs.
This is the case for example, if you connect two mono codecs to the
same I2S link in order to have a stereo card.
The current ASoC implementation does not allow such setup.

Add support for DAI links composed of a single CPU DAI and multiple
CODECs. Sound cards have to pass the CODECs array in the corresponding
DAI link through a new 'snd_soc_dai_link_codec' struct. Each CODEC in
this array is described in the same manner single CODEC DAIs are
(either DT/OF node or codec_name).

CPU DAI in a multicodec DAI link can have more channels than what each
CODEC has. The number of channels each CODEC is responsible for is
machine specific, hence it's fixed up in machine drivers in a similar
way to what DPCM does.

Fix a trailing space in the header as well.

Signed-off-by: Misael Lopez Cruz <misael.lopez <at> ti.com>
[fparent <at> baylibre.com: Adapt to 3.14+]
Signed-off-by: Fabien Parent <fparent <at> baylibre.com>
[bcousson <at> baylibre.com: Change tdm mask fixup, add missing iteration
over codecs array]
Signed-off-by: Benoit Cousson <bcousson <at> baylibre.com>
---
 include/sound/soc-dai.h |   5 +
 include/sound/soc.h     |  16 ++
(Continue reading)

Lars-Peter Clausen | 22 Mar 09:33 2014
Picon

Re: [RFT v2 6/6] ASoC: core: Add support for DAI multicodec

On 03/21/2014 04:27 PM, Benoit Cousson wrote:
> From: Misael Lopez Cruz <misael.lopez <at> ti.com>
>
> DAI link assumes a one to one mapping between CPU DAI and CODEC. In
> some cases, the same CPU DAI can be connected to several codecs.
> This is the case for example, if you connect two mono codecs to the
> same I2S link in order to have a stereo card.
> The current ASoC implementation does not allow such setup.
>
> Add support for DAI links composed of a single CPU DAI and multiple
> CODECs. Sound cards have to pass the CODECs array in the corresponding
> DAI link through a new 'snd_soc_dai_link_codec' struct. Each CODEC in
> this array is described in the same manner single CODEC DAIs are
> (either DT/OF node or codec_name).
>
> CPU DAI in a multicodec DAI link can have more channels than what each
> CODEC has. The number of channels each CODEC is responsible for is
> machine specific, hence it's fixed up in machine drivers in a similar
> way to what DPCM does.
>
> Fix a trailing space in the header as well.

This has been a feature that has been missing for quite a while, thanks for 
taking care of this. There are a few things that need to be fixed, but 
nothing that's not fixable.

I'd expect that after this patch has been applied there are no more usages 
of rtd->codec_dai. There are some though.

soc_pcm_params_symmetry() and soc_pcm_has_symmetry(), this should be trivial 
(Continue reading)

Benoit Cousson | 25 Mar 14:10 2014

Re: [RFT v2 6/6] ASoC: core: Add support for DAI multicodec

Hi Lars,

On 22/03/2014 09:33, Lars-Peter Clausen wrote:
> On 03/21/2014 04:27 PM, Benoit Cousson wrote:
>> From: Misael Lopez Cruz <misael.lopez <at> ti.com>
>>
>> DAI link assumes a one to one mapping between CPU DAI and CODEC. In
>> some cases, the same CPU DAI can be connected to several codecs.
>> This is the case for example, if you connect two mono codecs to the
>> same I2S link in order to have a stereo card.
>> The current ASoC implementation does not allow such setup.
>>
>> Add support for DAI links composed of a single CPU DAI and multiple
>> CODECs. Sound cards have to pass the CODECs array in the corresponding
>> DAI link through a new 'snd_soc_dai_link_codec' struct. Each CODEC in
>> this array is described in the same manner single CODEC DAIs are
>> (either DT/OF node or codec_name).
>>
>> CPU DAI in a multicodec DAI link can have more channels than what each
>> CODEC has. The number of channels each CODEC is responsible for is
>> machine specific, hence it's fixed up in machine drivers in a similar
>> way to what DPCM does.
>>
>> Fix a trailing space in the header as well.
>
> This has been a feature that has been missing for quite a while, thanks
> for taking care of this. There are a few things that need to be fixed,
> but nothing that's not fixable.

Cool, great :-)
(Continue reading)

Lars-Peter Clausen | 25 Mar 18:01 2014
Picon

Re: [RFT v2 6/6] ASoC: core: Add support for DAI multicodec

On 03/25/2014 02:10 PM, Benoit Cousson wrote:
[...]
>>> +struct snd_soc_dai_link_codec {
>>
>> For the sake of symmetry maybe name this snd_soc_dai_link_component and
>> drop the 'codec_' prefix in front of the struct fields. There is no
>> reason why this couldn't be used for CPU dais as well at some point.
>
> OK, good point.
>
>>> +    const char *codec_name;
>>> +    const struct device_node *codec_of_node;
>>> +    const char *codec_dai_name;
>>
>> I'd like to see this split up into the descriptive part that holds the
>> name, of_node etc, and the runtime data that holds the pointer to the
>> DAIs. The descriptive part goes in the dai_link struct the. The pointers
>> to the DAIs go into the snd_soc_pcm_runtime struct. This is how it is
>> used the only place where you need both is in soc_bind_dai_link.
>
> OK, let me try to clarify that. You suggest to create that struct:
>
> +struct snd_soc_dai_link_component {
> +    const char *name;
> +    const struct device_node *of_node;
> +    const char *dai_name;
> +}
>
> to be inside the snd_soc_dai_link.
>
(Continue reading)


Gmane