Amlogic DPCM audio card(s) speaker placement issue
PATCH RESEND 1/1 Amlogic DPCM audio card(s) speaker placement issue
Hello alsa-dev people,
I’d like to describe a problem with speaker placement seen with the Amlogic (meson) AIU and AXG drivers when playing multi-channel media. The problem was traced to a failure to get the channel map via snd_pcm_get_chmap() and further analysis showed this failed because the PCM controls are exposed on a different device than the PCM stream.
e.g. on LibreTech LePotato with DPCM routing configured for HDMI output, the hw PCM is on the single frontend device 0 but the PCM controls are on device 2:
LePotato:~ # aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
LePotato:~ # amixer controls numid=19,iface=MIXER,name='PCM Playback Volume' numid=18,iface=MIXER,name='ACODEC Left DAC Sel' numid=7,iface=MIXER,name='ACODEC Mute Ramp Switch' numid=2,iface=MIXER,name='ACODEC Playback Channel Mode' numid=3,iface=MIXER,name='ACODEC Playback Switch' numid=4,iface=MIXER,name='ACODEC Playback Volume' numid=5,iface=MIXER,name='ACODEC Ramp Rate' numid=17,iface=MIXER,name='ACODEC Right DAC Sel' numid=8,iface=MIXER,name='ACODEC Unmute Ramp Switch' numid=6,iface=MIXER,name='ACODEC Volume Ramp Switch' numid=1,iface=MIXER,name='AIU ACODEC I2S Lane Select' numid=16,iface=MIXER,name='AIU ACODEC OUT EN Switch' numid=15,iface=MIXER,name='AIU ACODEC SRC' numid=14,iface=MIXER,name='AIU HDMI CTRL SRC' numid=13,iface=MIXER,name='AIU SPDIF SRC SEL' numid=12,iface=PCM,name='ELD',device=2 numid=11,iface=PCM,name='IEC958 Playback Default',device=2 numid=10,iface=PCM,name='IEC958 Playback Mask',device=2 numid=9,iface=PCM,name='Playback Channel Map',device=2
or on a Wetek Play 2:
WP2:~ # aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: WETEKPLAY2 [WETEK-PLAY2], device 0: fe.dai-link-0 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: WETEKPLAY2 [WETEK-PLAY2], device 1: fe.dai-link-1 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
WP2:~ # amixer controls numid=7,iface=MIXER,name='PCM Playback Volume' numid=6,iface=MIXER,name='AIU HDMI CTRL SRC' numid=5,iface=MIXER,name='AIU SPDIF SRC SEL' numid=4,iface=PCM,name='ELD',device=4 numid=3,iface=PCM,name='IEC958 Playback Default',device=4 numid=2,iface=PCM,name='IEC958 Playback Mask',device=4 numid=1,iface=PCM,name='Playback Channel Map',device=4
It looks like the PCM controls of the backend hdmi-codec are not routed through the DPCM driver the same way as PCM streams. We discussed that issue with Jerome, the driver author, but it’s not clear which bits we are missing. i.e. if it's something ASoC DPCM should be handling or if some further plumbing in the card driver or userspace is needed?
Any hints into the right direction would be highly appreciated!
Christian
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Quoted 11 lines · Christian Hewitt
**** List of PLAYBACK Hardware Devices ****
card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0numid=12,iface=PCM,name='ELD',device=2 numid=11,iface=PCM,name='IEC958 Playback Default',device=2 numid=10,iface=PCM,name='IEC958 Playback Mask',device=2 numid=9,iface=PCM,name='Playback Channel Map',device=2
Have you tried to reorder the dai-link-# sections in DT? It appears to me that sound/soc/codecs/hdmi-codec.c / hdmi_codec_pcm_new() gets the internal PCM device rather than the exported PCM device for the user space.
If the DAI routing cannot be changed, then the hdmi-codec.c should be modified to export the correct device number for the user space:
Jaroslav
Signature · 7 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc. _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
Quoted 10 lines · Jaroslav Kysela
Quoted 4 lines · Christian Hewitt
**** List of PLAYBACK Hardware Devices ****
card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0
Quoted 8 lines
Quoted 5 lines
numid=12,iface=PCM,name='ELD',device=2 numid=11,iface=PCM,name='IEC958 Playback Default',device=2 numid=10,iface=PCM,name='IEC958 Playback Mask',device=2 numid=9,iface=PCM,name='Playback Channel Map',device=2
https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts#L136-L188Have you tried to reorder the dai-link-# sections in DT? It appears to me that
sound/soc/codecs/hdmi-codec.c/hdmi_codec_pcm_new()gets the internal PCM device rather than the exported PCM device for the user space.
I did a test reordering the nodes on the WP2 box like this:
dai-link-0 {
sound-dai = <&aiu AIU_HDMI CTRL_OUT>;
codec-0 {
sound-dai = <&hdmi_tx>;
};
};
dai-link-1 {
sound-dai = <&aiu AIU_CPU CPU_I2S_FIFO>;
};
dai-link-2 {
sound-dai = <&aiu AIU_CPU CPU_SPDIF_FIFO>;
};
dai-link-3 {
sound-dai = <&aiu AIU_CPU CPU_I2S_ENCODER>;
dai-format = "i2s";
mclk-fs = <256>;
codec-0 {
sound-dai = <&aiu AIU_HDMI CTRL_I2S>;
};
};
dai-link-4 {
sound-dai = <&aiu AIU_CPU CPU_SPDIF_ENCODER>;
codec-0 {
sound-dai = <&spdif_dit>;
};
};This gives output like:
WP2:~ # amixer controls
numid=5,iface=MIXER,name='AIU HDMI CTRL SRC'
numid=6,iface=MIXER,name='AIU SPDIF SRC SEL'
numid=4,iface=PCM,name='ELD'
numid=3,iface=PCM,name='IEC958 Playback Default'
numid=2,iface=PCM,name='IEC958 Playback Mask'
numid=1,iface=PCM,name='Playback Channel Map’
The “device=4” is gone, but also gone is the default PCM device:
WP2:~ # aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
iec958:CARD=WETEKPLAY2,DEV=0
WETEK-PLAY2,
IEC958 (S/PDIF) Digital Audio Output
Assuming I did the changes above correctly? it looks like DAI order matters and cannot be changed.
Quoted 3 lines
If the DAI routing cannot be changed, then the
hdmi-codec.cshould be modified to export the correct device number for the user space:
That’s some way beyond my limited kernel skills, so I will need to phone friends and ask the audience for assistance :)
Christian
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Jerome Brunet
reviewerQuoted 13 lines · Jaroslav Kysela
Quoted 10 lines · Christian Hewitt
**** List of PLAYBACK Hardware Devices ****
card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0numid=12,iface=PCM,name='ELD',device=2 numid=11,iface=PCM,name='IEC958 Playback Default',device=2 numid=10,iface=PCM,name='IEC958 Playback Mask',device=2 numid=9,iface=PCM,name='Playback Channel Map',device=2
https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts#L136-L188
Quoted 5 lines
Have you tried to reorder the dai-link-# sections in DT? It appears to me that
sound/soc/codecs/hdmi-codec.c/hdmi_codec_pcm_new()gets the internal PCM device rather than the exported PCM device for the user space.If the DAI routing cannot be changed, then the
hdmi-codec.cshould be modified to export the correct device number for the user space:
The DAI routing is dynamic, especially on the AXG series. There is actually two routing stages:
1) Between the user interfaces (DMA) and the i2s/TDM encoders/decoders:
-> This is using DPCM
2) Between the i2s/TDM encoders and the HDMI controller:
-> This is using Codec-to-Codec links
The problem exposed here is
- How to get the get the "Playback Channel Map" related to the pcm device of a given playback ?
I don't really know how to answer this.
As you noted above, given the routing is dynamic, I don't think the problem can be solved with a specific link ordering
However, on these platforms, there will only be one such control AFAIK. The one you get is the one you are looking for. It's not ideal but it's a start.
Quoted 3 lines
Jaroslav
_______________________________________________
linux-amlogic mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-amlogic
Quoted 26 lines · Jerome Brunet
Quoted 13 lines · Jaroslav Kysela
Quoted 10 lines · Christian Hewitt
**** List of PLAYBACK Hardware Devices ****
card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
Subdevices: 1/1
Subdevice #0: subdevice #0numid=12,iface=PCM,name='ELD',device=2 numid=11,iface=PCM,name='IEC958 Playback Default',device=2 numid=10,iface=PCM,name='IEC958 Playback Mask',device=2 numid=9,iface=PCM,name='Playback Channel Map',device=2
https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts#L136-L188Quoted 5 lines
Have you tried to reorder the dai-link-# sections in DT? It appears to me that
sound/soc/codecs/hdmi-codec.c/hdmi_codec_pcm_new()gets the internal PCM device rather than the exported PCM device for the user space.If the DAI routing cannot be changed, then the
hdmi-codec.cshould be modified to export the correct device number for the user space:The DAI routing is dynamic, especially on the AXG series. There is actually two routing stages:
1) Between the user interfaces (DMA) and the i2s/TDM encoders/decoders:
Quoted 8 lines
-> This is using DPCM2) Between the i2s/TDM encoders and the HDMI controller:
-> This is using Codec-to-Codec linksThe problem exposed here is
- How to get the get the "Playback Channel Map" related to the pcm device of a given playback ?
The PCM device exported to the user space should be able to export this information correctly. The kcontrols in hdmi-codec.c refers to an unknown (internal) PCM codec2codec device (from the user space view) which is created in the SoC layer.
It seems that kcontrols in hdmi-codec.c should not be created for the internal SoC PCMs. A new layer which translate the kcontrol handling between the exported (user space) PCM device and internal (SoC) PCM device is required.
Problematic code in hdmi_codec_pcm_new() / hdmi-codec.c:
- snd_pcm_add_chmap_ctls()
- kctl->id.device = rtd->pcm->device
Jaroslav
Signature · 7 lines
Jaroslav Kysela <[email protected]> Linux Sound Maintainer; ALSA Project; Red Hat, Inc. _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic