I’m trying to create a device tree overlay that creates an external sound card using simple-audio-card ASoC driver to interface with a WM8731 development board. Here’s my attempt at the overlay:
/dts-v1/;
/plugin/;
/ {
compatible = "rockchip,rockpi","rockchip,rk3399";
fragment@0 {
target = <&i2s1>;
__overlay__ {
status = "okay";
};
};
fragment@1 {
target = <&i2c7>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
wm8731: wm8731@1a {
#sound-dai-cells = <0>;
compatible = "wlf,wm8731";
reg = <0x1a>;
status = "okay";
};
};
};
fragment@2 {
target-path = "/sound-ext-card";
__overlay__ {
status = "okay";
compatible = "simple-audio-card";
simple-audio-card,format = "i2s";
simple-audio-card,name = "rockchip,wm8731-codec";
simple-audio-card,widgets =
"Microphone", "Mic Jack",
"Headphone", "Headphone Jack";
simple-audio-card,routing =
"Mic Jack", "MICIN",
"Headphone Jack", "LHPOUT",
"Headphone Jack", "RHPOUT";
simple-audio-card,bitclock-master = <&sac_cpu>;
simple-audio-card,frame-master = <&sac_cpu>;
sac_cpu: simple-audio-card,cpu {
sound-dai = <&i2s1>;
};
sac_codec: simple-audio-card,codec {
sound-dai = <&wm8731>;
};
};
};
};
This almost works - I get a new card/device (card 2: rockchipwm8731c [rockchip,wm8731-codec], device 0) showing up in aplay -l
, but when I try to play a .wav file through it, i hear nothing. actually i hear almost nothing, except for some very faint noise/glitches. When I scope the I2S lines, I see this:
The SCLK frequency is 46.88 kHz, and there are 64 SCLK cycles per LRCK cycle. What I would expect to see, is SCLK running at 48 kHz * 2 * 16 = 1.536 MHz, and then 32 SCLK cycles per LRCK cycle. So
something is obviously wrong here: the clock is running way too slow, and ratio of SCLK to LRCK is
off by a factor of 2.
When I look at the way the ES8316 (on-board codec) is configured in the device tree, I notice a few things different. First, there is the simple-audio-card,mclk-fs
property, which is set to 256 for the ES8316. If I try to set that to anything in my overlay, I get a device which responds with “unable to install hw params” while trying aplay.
The other thing I noticed in this .dsti is that the ES8316 sub-node of the i2c1 device node makes reference to some clock parameters:
es8316: es8316@11 {
#sound-dai-cells = <0>;
compatible = "everest,es8316";
reg = <0x11>;
clocks = <&cru SCLK_I2S_8CH_OUT>;
clock-names = "mclk";
pinctrl-names = "default";
pinctrl-0 = <&i2s_8ch_mclk>;
};
What is the meaning of this “&cru SCLK_I2S_8CH_OUT”? Should I put something similar (perhaps 2CH_OUT?) in my overlay? What are my options?
In summary, how should I configure the clocks for this I2S1 overlay?