Re: How do I set up multiple codecs on one I2S - without TDM?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I return days later with an answer, so I shall try and answer my own email.

On Wed, Jul 26, 2023 at 08:48:18AM +1000, John Watts wrote:
> 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?

After reading the following links:

https://lore.kernel.org/all/87fsw124wn.wl-kuninori.morimoto.gx@xxxxxxxxxxx/
https://lore.kernel.org/r/87ilbx1kh3.wl-kuninori.morimoto.gx@xxxxxxxxxxx

I found that this is a case of 1:N cpus to codecs, and this can be
solved using audio-graph-card2.

So I set up a device tree like this:

	wm8782_1: stereo-adc-1 {
		compatible = "wlf,wm8782";
		Vdda-supply = <&reg_vcc>;
		Vdd-supply = <&reg_vcc>;
		#sound-dai-cells = <0>;
		port {
			wm8782_1_ep: endpoint {
				remote-endpoint = <&card_ep_1>;
			};
		};
	};

	wm8782_2: stereo-adc-2 {
		compatible = "wlf,wm8782";
		Vdda-supply = <&reg_vcc>;
		Vdd-supply = <&reg_vcc>;
		#sound-dai-cells = <0>;
		port {
			wm8782_2_ep: endpoint {
				remote-endpoint = <&card_ep_2>;
			};
		};
	};

	wm8782_3: stereo-adc-3 {
		compatible = "wlf,wm8782";
		Vdda-supply = <&reg_vcc>;
		Vdd-supply = <&reg_vcc>;
		#sound-dai-cells = <0>;
		port {
			wm8782_3_ep: endpoint {
				remote-endpoint = <&card_ep_3>;
			};
		};
	};

	sound {
		compatible = "audio-graph-card2";
		links = <&i2s2_port>;
		multi {
			ports {
				#address-cells = <1>;
				#size-cells = <0>;
				port@0 {
					card_ep_0: endpoint {
						remote-endpoint = <&i2s2_ep>;
					};
				};
				port@1 {
					card_ep_1: endpoint {
						remote-endpoint = <&wm8782_1_ep>;
					};
				};
				port@2 {
					card_ep_2: endpoint {
						remote-endpoint = <&wm8782_2_ep>;
					};
				};
				port@3 {
					card_ep_3: endpoint {
						remote-endpoint = <&wm8782_3_ep>;
					};
				};
			};
		};
	};

	&i2s2 {
		pinctrl-0 = <&i2s2_pins>, <&i2s2_din_pins>;
		pinctrl-names = "default";
		status = "okay";
		i2s2_port: port {
			format = "i2s";
			mclk-fs = <128>;
			bitclock-master;
			frame-master;
			i2s2_ep: endpoint {
				remote-endpoint = <&card_ep_0>;
			};
		};
	};

Immediately I was able to record from the needed channels!
After tinkering with the driver registers I was even able to get it to
read the channels properly :)

I hope this helps somebody else in my situation.
John.



[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux