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 = <®_vcc>; Vdd-supply = <®_vcc>; #sound-dai-cells = <0>; };
wm8782_2: stereo-adc { compatible = "wlf,wm8782"; Vdda-supply = <®_vcc>; Vdd-supply = <®_vcc>; #sound-dai-cells = <0>; };
wm8782_3: stereo-adc { compatible = "wlf,wm8782"; Vdda-supply = <®_vcc>; Vdd-supply = <®_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.