Wow, this actually works, sort of. There are some issues, which I do not fully understand. However the sound quality seems perfect.
1) I would think the correct bit clock for 88200 Hz 16 bit samples would be 2*16*88200 = 28222400, but I actually see 11289600, which is 4x too big. Attached is a oscope shot with 200 ns/division.
2) With 32 bit samples at 88200 Hz, it still works, but I get occasional xruns. These go away mostly if I renice aplay to highest possible priority. (What I really want is a real-time 3.15.4 kernel or at least low latency one)
3) Something is fishy with P9-41. The audio signal for axr1 is there, but noisy, and I get sputtering along with the correct music sound.
output from aplay -v -r 88200 -f S16_LE -c 8 -
Playing raw data 'stdin' : Signed 16 bit Little Endian, Rate 88200 Hz, Channels 8
Hardware PCM card 0 'TI PCM5102A' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 8
rate : 88200
exact rate : 88200 (88200/1)
msbits : 16
buffer_size : 8192
period_size : 512
period_time : 5804
tstamp_mode : NONE
period_step : 1
avail_min : 512
period_event : 0
start_threshold : 8192
stop_threshold : 8192
silence_threshold: 0
silence_size : 0
boundary : 1073741824
appl_ptr : 0
hw_ptr : 0
Debug output from kernel module pcm5102a:
[ 553.856720] PCM5102a hw params
[ 553.856841] sysclk=22579200
[ 553.856860] rate=88200
[ 553.856874] width=16
[ 553.856887] channels=8
[ 553.856900] bclk=11289600
[ 553.856916] set cpu clk to IN
I used
in am335x-boneblack.dts:
&mcasp0 {
pinctrl-names = "default";
pinctrl-0 = <&mcasp0_pins>;
status = "okay";
op-mode = <0>; /* MCASP_IIS_MODE */
tdm-slots = <2>;
/* 16 serializers */
serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */
1 1 1 1
>;
tx-num-evt = <8> /* was <32>*/;
rx-num-evt = <8> /* was <32>*/;
};
/ {
pcm5102a: pcm5102a {
compatible = "ti,pcm5102a";
};
sound {
compatible = "ti,pcm5102a-evm-audio";
ti,model = "TI PCM5102A";
ti,audio-codec = <&pcm5102a>;
ti,mcasp-controller = <&mcasp0>;
ti,codec-clock-rate = <22579200>;
};
&am33xx_pinmux {
mcasp0_pins: mcasp0_pins {
pinctrl-single,pins = <
0x190 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* P9-31 mcasp0_aclkx */
0x194 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* P9-29 mcasp0_fsx*/
0x198 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* P9-30 mcasp0_axr0 */
/* 0x1A8 (PIN_OUTPUT_PULLDOWN | MUX_MODE0) /* P9-41 mcasp0_axr1 something wrong*/
0x0D8 (PIN_OUTPUT_PULLDOWN | MUX_MODE3) /* P8-31 mcasp0_axr1 */
0x19C (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* P8-28 mcasp0_axr2 */
0x1A4 (PIN_OUTPUT_PULLDOWN | MUX_MODE2) /* P8-27 mcasp0_axr3 */
//0x19C (PIN_INPUT_PULLUP | MUX_MODE0) /* P9-28 mcasp0_achlkr */
0x1AC (PIN_INPUT_PULLUP | MUX_MODE0) /* P9-25 mcasp0_achlkx */
>;
};
};
};
in pcm5102a:
static struct snd_soc_dai_driver pcm5102a_dai = {
.name = "pcm5102a-hifi",
.playback = {
.stream_name = "Playback",
.channels_min = 2,
.channels_max = 8,
.rates = RATES,
.formats = FORMATS,
},
};