All of lore.kernel.org
 help / color / mirror / Atom feed
From: Caleb Crome <caleb@crome.org>
To: Mark Brown <broonie@kernel.org>
Cc: Pavel Machek <pavel@ucw.cz>,
	Charles Keepax <ckeepax@opensource.wolfsonmicro.com>,
	"alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>,
	tiwai@suse.de, linux-kernel@vger.kernel.org,
	patches@opensource.wolfsonmicro.com,
	Liam Girdwood <lgirdwood@gmail.com>
Subject: Re: [alsa-devel] System with multiple arizona (wm5102) codecs
Date: Tue, 15 Sep 2015 08:26:36 -0700	[thread overview]
Message-ID: <CAG5mAdzKC1FuF-DXosj2RBwyo6jA_qvnjSjuCKfHgMWvQ59kag@mail.gmail.com> (raw)
In-Reply-To: <20150915140919.GE11268@sirena.org.uk>

>
> Like Charles said earlier the Bells machine in mainline has multiple
> CODECs hooked up.  Speyside too.  To hook up multiple CODECs to a single
> DAI link see 88bd870f02dff5c94 (ASoC: core: Add initial support for DAI
> multicodec), sadly I don't think Benoit ever got round to submitting a
> machine.

Thanks Mark.

I've been staring at that diff for a a day or two, and I still can't
quite figure out how to use it.

I think I'm getting close:  all codecs are registered, the DAPM stuff
seems to be connected (all with prefixed names), but the card won't
open more than a 2 channel interface.

For example, when I do aplay -l, I get this:
**** List of PLAYBACK Hardware Devices ****
card 0: PUPPYAUDIO [PUPPY-AUDIO], device 0: AIC3X tlv320aic3x-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PUPPYAUDIO [PUPPY-AUDIO], device 1: AIC3X tlv320aic3x-hifi-1 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PUPPYAUDIO [PUPPY-AUDIO], device 2: AIC3X tlv320aic3x-hifi-2 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PUPPYAUDIO [PUPPY-AUDIO], device 3: AIC3X tlv320aic3x-hifi-3 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Each device is a 2 channel codec, so I thought I should get 8
channels. but when I try to run jackd with 8 channels, I get the
following:
# jackd  -d alsa -D -i 8 -o 8 -S -r16000
...
ALSA: cannot set channel count to 8 for capture
ALSA: cannot configure capture channel
...


So, here are the relevent bits of my patch.  Any chance you could
point out the error in my ways?

Basically, what I did was add a snd_soc_dai_link and a
snd_soc_codec_conf for each codec, and set num_links and num_configs
to the number of codecs.

Thanks

-Caleb

diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c
index 731fb0d..d2e7049 100644
--- a/sound/soc/davinci/davinci-evm.c
+++ b/sound/soc/davinci/davinci-evm.c
@@ -23,10 +23,11 @@

 #include <asm/dma.h>
 #include <asm/mach-types.h>
-
 struct snd_soc_card_drvdata_davinci {
     struct clk *mclk;
     unsigned sysclk;
+        int controls_added_already;
 };

@@ -118,11 +122,18 @@ static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd)
 {
     struct snd_soc_card *card = rtd->card;
     struct device_node *np = card->dev->of_node;
+
+    struct snd_soc_card_drvdata_davinci *drvdata =
+        snd_soc_card_get_drvdata(card);
     int ret;

     /* Add davinci-evm specific widgets */
-    snd_soc_dapm_new_controls(&card->dapm, aic3x_dapm_widgets,
-                  ARRAY_SIZE(aic3x_dapm_widgets));
+    if (!drvdata->controls_added_already) {
+        snd_soc_dapm_new_controls(&card->dapm, aic3x_dapm_widgets,
+                      ARRAY_SIZE(aic3x_dapm_widgets));
+        drvdata->controls_added_already = 1;
+    }

     if (np) {
         ret = snd_soc_of_parse_audio_routing(card, "ti,audio-routing");
@@ -330,14 +342,71 @@ static struct snd_soc_card da850_snd_soc_card = {
  * The struct is used as place holder. It will be completely
  * filled with data from dt node.
  */
-static struct snd_soc_dai_link evm_dai_tlv320aic3x = {
-    .name        = "TLV320AIC3X",
+static struct snd_soc_dai_link evm_dai_tlv320aic3x[] = {
+    {
+    .name        = "TLV320AIC3X a",
     .stream_name    = "AIC3X",
     .codec_dai_name    = "tlv320aic3x-hifi",
     .ops            = &evm_ops,
     .init           = evm_aic3x_init,
-    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
-           SND_SOC_DAIFMT_IB_NF,
+    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
SND_SOC_DAIFMT_IB_NF,
+    },
+    {
+    .name        = "TLV320AIC3X b",
+    .stream_name    = "AIC3X",
+    .codec_dai_name    = "tlv320aic3x-hifi",
+    .ops            = &evm_ops,
+    .init           = evm_aic3x_init,
+    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
SND_SOC_DAIFMT_IB_NF,
+    },
+    {
+    .name        = "TLV320AIC3X c",
+    .stream_name    = "AIC3X",
+    .codec_dai_name    = "tlv320aic3x-hifi",
+    .ops            = &evm_ops,
+    .init           = evm_aic3x_init,
+    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
SND_SOC_DAIFMT_IB_NF,
+    },
+    {
+    .name        = "TLV320AIC3X d",
+    .stream_name    = "AIC3X",
+    .codec_dai_name    = "tlv320aic3x-hifi",
+    .ops            = &evm_ops,
+    .init           = evm_aic3x_init,
+    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
SND_SOC_DAIFMT_IB_NF,
+    },
+    {
+    .name        = "TLV320AIC3X e",
+    .stream_name    = "AIC3X",
+    .codec_dai_name    = "tlv320aic3x-hifi",
+    .ops            = &evm_ops,
+    .init           = evm_aic3x_init,
+    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
SND_SOC_DAIFMT_IB_NF,
+    },
+    {
+    .name        = "TLV320AIC3X f",
+    .stream_name    = "AIC3X",
+    .codec_dai_name    = "tlv320aic3x-hifi",
+    .ops            = &evm_ops,
+    .init           = evm_aic3x_init,
+    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
SND_SOC_DAIFMT_IB_NF,
+    },
+    {
+    .name        = "TLV320AIC3X g",
+    .stream_name    = "AIC3X",
+    .codec_dai_name    = "tlv320aic3x-hifi",
+    .ops            = &evm_ops,
+    .init           = evm_aic3x_init,
+    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
SND_SOC_DAIFMT_IB_NF,
+    },
+    {
+    .name        = "TLV320AIC3X h",
+    .stream_name    = "AIC3X",
+    .codec_dai_name    = "tlv320aic3x-hifi",
+    .ops            = &evm_ops,
+    .init           = evm_aic3x_init,
+    .dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_CBM_CFM |
SND_SOC_DAIFMT_IB_NF,
+    },
 };

 static const struct of_device_id davinci_evm_dt_ids[] = {
@@ -355,6 +424,8 @@ static struct snd_soc_card evm_soc_card = {
     .num_links = 1,
 };

+static struct snd_soc_codec_conf evm_codec_confs[16];
+
 static int davinci_evm_probe(struct platform_device *pdev)
 {
     struct device_node *np = pdev->dev.of_node;
@@ -364,18 +435,36 @@ static int davinci_evm_probe(struct platform_device *pdev)
     struct snd_soc_card_drvdata_davinci *drvdata = NULL;
     struct clk *mclk;
     int ret = 0;
+    int i;

     evm_soc_card.dai_link = dai;
-
-    dai->codec_of_node = of_parse_phandle(np, "ti,audio-codec", 0);
-    if (!dai->codec_of_node)
+
+    evm_soc_card.codec_conf = evm_codec_confs;
+
+    for (i = 0;
+         (of_parse_phandle(np, "ti,audio-codec", i) != NULL) &&
+         (i < ARRAY_SIZE(evm_dai_tlv320aic3x)-1);
+         i++) {
+        char *name_prefix = kzalloc(4, GFP_KERNEL);
+
+        dai[i].codec_of_node = of_parse_phandle(np, "ti,audio-codec", i);
+
+        if (!dai[i].codec_of_node)
         return -EINVAL;

-    dai->cpu_of_node = of_parse_phandle(np, "ti,mcasp-controller", 0);
-    if (!dai->cpu_of_node)
+        evm_codec_confs[i].of_node = dai[i].codec_of_node;
+        snprintf(name_prefix, 4, "%c", 'a'+i);
+        evm_codec_confs[i].name_prefix = name_prefix;
+
+        dai[i].cpu_of_node = of_parse_phandle(np, "ti,mcasp-controller", 0);
+        if (!dai[i].cpu_of_node)
         return -EINVAL;

-    dai->platform_of_node = dai->cpu_of_node;
+        dai[i].platform_of_node = dai[i].cpu_of_node;
+    }
+    evm_soc_card.num_configs=i;
+    evm_soc_card.num_links  =i;
+

     evm_soc_card.dev = &pdev->dev;
     ret = snd_soc_of_parse_card_name(&evm_soc_card, "ti,model");
diff --git a/arch/arm/boot/dts/am335x-boneblack.dts
b/arch/arm/boot/dts/am335x-boneblack.dts
index 6335072..19af41f 100644
--- a/arch/arm/boot/dts/am335x-boneblack.dts
+++ b/arch/arm/boot/dts/am335x-boneblack.dts
+&i2c1 {
+    clock-frequency = <100000>;
+    status = "okay";
+    pinctrl-names = "default";
+    pinctrl-0 = <&i2c1_pins_default>;
+    status="okay";
+
+    tlv320aic3x_a: tlv320aic3x@18 {
+        compatible = "ti,tlv320aic3x";
+        reg = <0x18>;
+        tdm-offset = <0>;
+        status = "okay";
+    };
+
+    tlv320aic3x_b: tlv320aic3x@19 {
+        compatible = "ti,tlv320aic3x";
+        reg = <0x19>;
+        tdm-offset = <32>;
+        status = "okay";
+    };
+
+    tlv320aic3x_c: tlv320aic3x@1a {
+        compatible = "ti,tlv320aic3x";
+        reg = <0x1a>;
+        tdm-offset = <64>;
+        status = "okay";
+    };
+
+    tlv320aic3x_d: tlv320aic3x@1b {
+        compatible = "ti,tlv320aic3x";
+        reg = <0x1b>;
+        tdm-offset = <96>;
+        status = "okay";
+    };
+
+};
+
+&mcasp0 {
+    pinctrl-names = "default";
+    pinctrl-0 = <&mcasp_0_pins_default>;
+    status = "okay";
+
+    op-mode = <0>;          /* MCASP_IIS_MODE */
+    tdm-slots = <16>;
+    num-serializer = <16>;
+    serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
+        0 0 1 2
+        0 0 0 0
+        0 0 0 0
+        0 0 0 0
+    >;
+    tx-num-evt = <1>;
+    rx-num-evt = <1>;
 };

+
 / {
+    sound {
+        compatible = "ti,da830-evm-audio";
+        ti,model = "PUPPY-AUDIO";
+        ti,audio-codec = <
+                   &tlv320aic3x_a
+                   &tlv320aic3x_b
+                   &tlv320aic3x_c
+                   &tlv320aic3x_d
+                   >;
+        ti,mcasp-controller = <&mcasp0>;
+        ti,codec-clock-rate = <12288000>;
+        ti,audio-routing =
+            "Headphone Jack",       "a HPLOUT",
+            "Headphone Jack",       "a HPROUT",
+            "a LINE1L",               "Line In",
+            "a LINE1R",               "Line In";
+        status="okay";
+    };
 };

 &rtc {

  reply	other threads:[~2015-09-15 15:27 UTC|newest]

Thread overview: 65+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-14 11:54 System with multiple arizona (wm5102) codecs Pavel Machek
2015-09-14 11:52 ` Charles Keepax
2015-09-14 11:52   ` Charles Keepax
2015-09-14 13:31   ` Charles Keepax
2015-09-14 13:31     ` Charles Keepax
2015-09-14 20:11   ` Pavel Machek
2015-09-15  6:18   ` Pavel Machek
2015-09-15  8:06     ` Charles Keepax
2015-09-15  8:06       ` Charles Keepax
2015-09-15  8:35       ` Pavel Machek
2015-09-15 13:56         ` [alsa-devel] " Caleb Crome
2015-09-15 13:56           ` Caleb Crome
2015-09-15 14:09           ` [alsa-devel] " Mark Brown
2015-09-15 14:09             ` Mark Brown
2015-09-15 15:26             ` Caleb Crome [this message]
2015-09-19 18:21               ` [alsa-devel] " Mark Brown
2015-09-21 12:36           ` Pavel Machek
2015-10-12  9:00   ` multi-codec support for arizona-ldo1 was " Pavel Machek
2015-10-12 11:37     ` Charles Keepax
2015-10-12 11:37       ` Charles Keepax
2015-11-30 11:33       ` multi-card support for davinci-evm Pavel Machek
2015-11-30 11:37       ` multi-card support for arizona-core Pavel Machek
2015-11-30 11:37         ` Pavel Machek
2015-11-30 11:54         ` Mark Brown
2015-10-12 15:47     ` multi-codec support for arizona-ldo1 was Re: System with multiple arizona (wm5102) codecs Mark Brown
2015-10-12 20:11       ` Pavel Machek
2015-10-13 11:53         ` Mark Brown
2015-10-13 11:53           ` Mark Brown
2015-11-13 21:58           ` Pavel Machek
2015-11-13 22:53             ` Mark Brown
2015-11-14  7:44               ` Pavel Machek
2015-11-14  7:44                 ` Pavel Machek
2015-11-14 12:39                 ` Mark Brown
2015-11-14 17:59                   ` Pavel Machek
2015-11-14 17:59                     ` Pavel Machek
2015-11-14 18:49                     ` Mark Brown
2015-11-14 21:16                       ` Pavel Machek
2015-11-14 21:16                         ` Pavel Machek
2015-11-15  0:14                         ` Mark Brown
2015-11-15  0:14                           ` Mark Brown
2015-11-16  7:45                           ` Pavel Machek
2015-11-16 10:50                             ` Mark Brown
2015-11-16 12:29                               ` Pavel Machek
2015-11-16 12:29                                 ` Pavel Machek
2015-11-16 13:57                                 ` Charles Keepax
2015-11-16 13:57                                   ` Charles Keepax
2015-11-16 14:28                                 ` Charles Keepax
2015-11-16 14:28                                   ` Charles Keepax
2015-11-16 17:33                                 ` Mark Brown
2015-11-16 14:11                         ` Charles Keepax
2015-11-16 14:11                           ` Charles Keepax
2015-11-22  6:51                           ` Pavel Machek
2015-11-22  6:51                             ` Pavel Machek
2015-11-23  8:18                             ` Lee Jones
2015-11-23  8:18                               ` Lee Jones
2015-11-23 10:11                               ` Pavel Machek
2015-11-23 10:25                                 ` Richard Fitzgerald
2015-11-23 10:25                                   ` Richard Fitzgerald
2015-11-23 11:30                                   ` Mark Brown
2015-11-23 11:46                                     ` Charles Keepax
2015-11-23 11:46                                       ` Charles Keepax
2015-11-23 14:31                                       ` Lee Jones
2015-11-23 15:00                                       ` Pavel Machek
2015-11-16 14:05                     ` Charles Keepax
2015-11-16 14:05                       ` Charles Keepax

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAG5mAdzKC1FuF-DXosj2RBwyo6jA_qvnjSjuCKfHgMWvQ59kag@mail.gmail.com \
    --to=caleb@crome.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.wolfsonmicro.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=pavel@ucw.cz \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.