All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Watts <contact@jookia.org>
To: alsa-devel@alsa-project.org
Subject: How do I set up multiple codecs on one I2S - without TDM?
Date: Wed, 26 Jul 2023 08:48:18 +1000	[thread overview]
Message-ID: <ZMBRMnv0GQF4wyfQ@titan> (raw)

Hello there!

I have an interesting problem that I'm trying to solve. It will require
writing adding driver support but right now I'm struggling to understand
how I should go about it all.

As a background, this is with the Allwinner D1 or T113. It has a 16
channel I2S controller and each channel can be configured to use a
specific pin and TDM time slice. Even channels are low LRCLK, odd are
high LRCLK.

So for my situation I want to have six channels:

- Channel 0: Timeslot 0, Pin 0, LRCLK 0 -> ADC 1
- Channel 1: Timeslot 0, Pin 0, LRCLK 1 -> ADC 1
- Channel 2: Timeslot 0, Pin 1, LRCLK 0 -> ADC 2
- Channel 3: Timeslot 0, Pin 1, LRCLK 1 -> ADC 2
- Channel 4: Timeslot 0, Pin 2, LRCLK 0 -> ADC 3
- Channel 5: Timeslot 0, Pin 2, LRCLK 1 -> ADC 3

These ADCs are WM8782s, completely TDM unaware. If they were TDM aware
then I could run even more ADCs by having multiple separate TDMs going
on each pin.

I have tried to look online for I2S controllers that do the same thing
but haven't had much luck. The current driver for this controller only
supports TDM. So I will have to add support for this.

So my questions are: 
- How do I express this in terms of ALSA and sound card concepts?
- How do I express this in the device tree?

My immediate thought is that this is a situation where I have a card
with 3 dai-links between the I2S controller and each separate codec.
I have written this tree as a test:

    wm8782_1: stereo-adc {
    	compatible = "wlf,wm8782";
    	Vdda-supply = <&reg_vcc>;
    	Vdd-supply = <&reg_vcc>;
    	#sound-dai-cells = <0>;
    };
    
    wm8782_2: stereo-adc {
    	compatible = "wlf,wm8782";
    	Vdda-supply = <&reg_vcc>;
    	Vdd-supply = <&reg_vcc>;
    	#sound-dai-cells = <0>;
    };
    
    wm8782_3: stereo-adc {
    	compatible = "wlf,wm8782";
    	Vdda-supply = <&reg_vcc>;
    	Vdd-supply = <&reg_vcc>;
    	#sound-dai-cells = <0>;
    };
    
    sound {
    	compatible = "simple-audio-card";
    	simple-audio-card,name = "Testcard In";
    	simple-audio-card,format = "i2s";
    	simple-audio-card,bitclock-master = <&sound_cpu>;
    	simple-audio-card,frame-master = <&sound_cpu>;
    	simple-audio-card,mclk-fs = <128>;
    	#address-cells = <1>;
    	#size-cells = <0>;
    	simple-audio-card,dai-link@0 {
    		reg = <0>;
    		sound_cpu: cpu {
    			sound-dai = <&i2s2>;
    		};
    		codec {
    			sound-dai = <&wm8782_1>;
    		};
    	};
    	simple-audio-card,dai-link@1 {
    		reg = <1>;
    		cpu {
    			sound-dai = <&i2s2>;
    		};
    		codec {
    			sound-dai = <&wm8782_2>;
    		};
    	};
    	simple-audio-card,dai-link@2 {
    		reg = <2>;
    		cpu {
    			sound-dai = <&i2s2>;
    		};
    		codec {
    			sound-dai = <&wm8782_3>;
    		};
    	};
    };

But I get this kernel error:

    kobject_add_internal failed for 2034000.i2s-wm8782 with -EEXIST, don't try to register things with the same name
    asoc-simple-card: probe of sound failed with error -12

The WM8782 doesn't support TDM or multiplexing so I'm not exactly sure
if this is correct behaviour or my mistake configuring.

I tried adding TDM nodes which didn't help.

I also tried having a single link with multiple codecs on sound-dai
which did create a sound card but it was unclear to me if this was
ignoring the other codecs I had listed or not.

I also can't test this at this point as the sunxi codec driver assumes
that the number of channels is equal to TDM slots, which isn't true any
more.

Any pointers in the right direction would be a huge help.
Surely someone else has had this problem.

Thanks,
John.

             reply	other threads:[~2023-07-27  7:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-25 22:48 John Watts [this message]
2023-07-27  9:45 ` How do I set up multiple codecs on one I2S - without TDM? Pierre-Louis Bossart
2023-07-27  9:50   ` John Watts
2023-08-01 17:55 ` John Watts

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=ZMBRMnv0GQF4wyfQ@titan \
    --to=contact@jookia.org \
    --cc=alsa-devel@alsa-project.org \
    /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.