All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND] Amlogic DPCM audio card(s) speaker placement issue
@ 2021-12-26 11:43 ` Christian Hewitt
  0 siblings, 0 replies; 10+ messages in thread
From: Christian Hewitt @ 2021-12-26 11:43 UTC (permalink / raw)
  To: alsa-devel; +Cc: Matthias Reichl, Jerome Brunet, linux-amlogic

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

https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts#L136-L188

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

https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek-play2.dts#L51-L97

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
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RESEND] Amlogic DPCM audio card(s) speaker placement issue
@ 2021-12-26 11:43 ` Christian Hewitt
  0 siblings, 0 replies; 10+ messages in thread
From: Christian Hewitt @ 2021-12-26 11:43 UTC (permalink / raw)
  To: alsa-devel; +Cc: Matthias Reichl, linux-amlogic, Jerome Brunet

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

https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/amlogic/meson-gxl-s905x-libretech-cc.dts#L136-L188

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

https://github.com/torvalds/linux/blob/master/arch/arm64/boot/dts/amlogic/meson-gxbb-wetek-play2.dts#L51-L97

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


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RESEND] Amlogic DPCM audio card(s) speaker placement issue
  2021-12-26 11:43 ` Christian Hewitt
@ 2021-12-26 17:30   ` Jaroslav Kysela
  -1 siblings, 0 replies; 10+ messages in thread
From: Jaroslav Kysela @ 2021-12-26 17:30 UTC (permalink / raw)
  To: Christian Hewitt, alsa-devel
  Cc: Matthias Reichl, linux-amlogic, Jerome Brunet

On 26. 12. 21 12:43, Christian Hewitt wrote:

> **** List of PLAYBACK Hardware Devices ****
> card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
>   Subdevices: 1/1
>   Subdevice #0: subdevice #0

> 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-L188

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:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/hdmi-codec.c?h=v5.16-rc6#n805

						Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RESEND] Amlogic DPCM audio card(s) speaker placement issue
@ 2021-12-26 17:30   ` Jaroslav Kysela
  0 siblings, 0 replies; 10+ messages in thread
From: Jaroslav Kysela @ 2021-12-26 17:30 UTC (permalink / raw)
  To: Christian Hewitt, alsa-devel
  Cc: Matthias Reichl, Jerome Brunet, linux-amlogic

On 26. 12. 21 12:43, Christian Hewitt wrote:

> **** List of PLAYBACK Hardware Devices ****
> card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
>   Subdevices: 1/1
>   Subdevice #0: subdevice #0

> 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-L188

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:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/hdmi-codec.c?h=v5.16-rc6#n805

						Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RESEND] Amlogic DPCM audio card(s) speaker placement issue
  2021-12-26 17:30   ` Jaroslav Kysela
@ 2021-12-30  8:28     ` Christian Hewitt
  -1 siblings, 0 replies; 10+ messages in thread
From: Christian Hewitt @ 2021-12-30  8:28 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: alsa-devel, Matthias Reichl, linux-amlogic, Jerome Brunet


> On 26 Dec 2021, at 5:30 pm, Jaroslav Kysela <perex@perex.cz> wrote:
> 
> On 26. 12. 21 12:43, Christian Hewitt wrote:
> 
>> **** List of PLAYBACK Hardware Devices ****
>> card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
>>  Subdevices: 1/1
>>  Subdevice #0: subdevice #0
> 
>> 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-L188
> 
> 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.

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.

> 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:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/hdmi-codec.c?h=v5.16-rc6#n805


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
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RESEND] Amlogic DPCM audio card(s) speaker placement issue
@ 2021-12-30  8:28     ` Christian Hewitt
  0 siblings, 0 replies; 10+ messages in thread
From: Christian Hewitt @ 2021-12-30  8:28 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Matthias Reichl, alsa-devel, Jerome Brunet, linux-amlogic


> On 26 Dec 2021, at 5:30 pm, Jaroslav Kysela <perex@perex.cz> wrote:
> 
> On 26. 12. 21 12:43, Christian Hewitt wrote:
> 
>> **** List of PLAYBACK Hardware Devices ****
>> card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
>>  Subdevices: 1/1
>>  Subdevice #0: subdevice #0
> 
>> 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-L188
> 
> 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.

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.

> 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:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/hdmi-codec.c?h=v5.16-rc6#n805


That’s some way beyond my limited kernel skills, so I will need to
phone friends and ask the audience for assistance :)

Christian


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RESEND] Amlogic DPCM audio card(s) speaker placement issue
  2021-12-26 17:30   ` Jaroslav Kysela
@ 2022-01-03  9:57     ` Jerome Brunet
  -1 siblings, 0 replies; 10+ messages in thread
From: Jerome Brunet @ 2022-01-03  9:57 UTC (permalink / raw)
  To: Jaroslav Kysela, Christian Hewitt, alsa-devel
  Cc: Matthias Reichl, linux-amlogic


On Sun 26 Dec 2021 at 18:30, Jaroslav Kysela <perex@perex.cz> wrote:

> On 26. 12. 21 12:43, Christian Hewitt wrote:
>
>> **** List of PLAYBACK Hardware Devices ****
>> card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
>>   Subdevices: 1/1
>>   Subdevice #0: subdevice #0
>
>> 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-L188
>
> 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:
>

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.

> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/hdmi-codec.c?h=v5.16-rc6#n805
>
> 						Jaroslav


_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RESEND] Amlogic DPCM audio card(s) speaker placement issue
@ 2022-01-03  9:57     ` Jerome Brunet
  0 siblings, 0 replies; 10+ messages in thread
From: Jerome Brunet @ 2022-01-03  9:57 UTC (permalink / raw)
  To: Jaroslav Kysela, Christian Hewitt, alsa-devel
  Cc: Matthias Reichl, linux-amlogic


On Sun 26 Dec 2021 at 18:30, Jaroslav Kysela <perex@perex.cz> wrote:

> On 26. 12. 21 12:43, Christian Hewitt wrote:
>
>> **** List of PLAYBACK Hardware Devices ****
>> card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
>>   Subdevices: 1/1
>>   Subdevice #0: subdevice #0
>
>> 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-L188
>
> 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:
>

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.

> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/sound/soc/codecs/hdmi-codec.c?h=v5.16-rc6#n805
>
> 						Jaroslav


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RESEND] Amlogic DPCM audio card(s) speaker placement issue
  2022-01-03  9:57     ` Jerome Brunet
@ 2022-01-03 11:04       ` Jaroslav Kysela
  -1 siblings, 0 replies; 10+ messages in thread
From: Jaroslav Kysela @ 2022-01-03 11:04 UTC (permalink / raw)
  To: Jerome Brunet, Christian Hewitt, alsa-devel
  Cc: Matthias Reichl, linux-amlogic

On 03. 01. 22 10:57, Jerome Brunet wrote:
> 
> On Sun 26 Dec 2021 at 18:30, Jaroslav Kysela <perex@perex.cz> wrote:
> 
>> On 26. 12. 21 12:43, Christian Hewitt wrote:
>>
>>> **** List of PLAYBACK Hardware Devices ****
>>> card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
>>>    Subdevices: 1/1
>>>    Subdevice #0: subdevice #0
>>
>>> 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-L188
>>
>> 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:
>>
> 
> 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 ?

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

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RESEND] Amlogic DPCM audio card(s) speaker placement issue
@ 2022-01-03 11:04       ` Jaroslav Kysela
  0 siblings, 0 replies; 10+ messages in thread
From: Jaroslav Kysela @ 2022-01-03 11:04 UTC (permalink / raw)
  To: Jerome Brunet, Christian Hewitt, alsa-devel
  Cc: Matthias Reichl, linux-amlogic

On 03. 01. 22 10:57, Jerome Brunet wrote:
> 
> On Sun 26 Dec 2021 at 18:30, Jaroslav Kysela <perex@perex.cz> wrote:
> 
>> On 26. 12. 21 12:43, Christian Hewitt wrote:
>>
>>> **** List of PLAYBACK Hardware Devices ****
>>> card 0: LIBRETECHCC [LIBRETECH-CC], device 0: fe.dai-link-0 (*) []
>>>    Subdevices: 1/1
>>>    Subdevice #0: subdevice #0
>>
>>> 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-L188
>>
>> 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:
>>
> 
> 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 ?

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

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-01-03 14:24 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-26 11:43 [RESEND] Amlogic DPCM audio card(s) speaker placement issue Christian Hewitt
2021-12-26 11:43 ` Christian Hewitt
2021-12-26 17:30 ` Jaroslav Kysela
2021-12-26 17:30   ` Jaroslav Kysela
2021-12-30  8:28   ` Christian Hewitt
2021-12-30  8:28     ` Christian Hewitt
2022-01-03  9:57   ` Jerome Brunet
2022-01-03  9:57     ` Jerome Brunet
2022-01-03 11:04     ` Jaroslav Kysela
2022-01-03 11:04       ` Jaroslav Kysela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.