Jetson Xavier NX sound card tegrahdaxnx volume control

Hi!I recently ran into a problem and desperate for help,In our test pipeline we choose HDMI audio output,and we use the sound card tegrahdaxnx as alsasink,as follows:

gst-launch-1.0 alsasrc device=plughw:2,0 ! alsasink device=plughw:0,7

We found that when the pipeline is up, we use PulseAudio to adjust the sink volume is invalid,

pactl set-sink-volume alsa_output.platform-3510000.hda.hdmi-stereo-extra1 0

so we test whether we can control the sink volume through Alsa,query the control interface of the sound card through amixer as follows. It can be found that there is no volume-related control interface.

user@linux:~$ amixer -c tegrahdaxnx controls
numid=1,iface=CARD,name=‘HDMI/DP,pcm=3 Jack’
numid=12,iface=CARD,name=‘HDMI/DP,pcm=7 Jack’
numid=23,iface=CARD,name=‘HDMI/DP,pcm=8 Jack’
numid=34,iface=CARD,name=‘HDMI/DP,pcm=9 Jack’
numid=2,iface=MIXER,name=‘IEC958 Playback Con Mask’
numid=13,iface=MIXER,name=‘IEC958 Playback Con Mask’,index=1
numid=24,iface=MIXER,name=‘IEC958 Playback Con Mask’,index=2
numid=35,iface=MIXER,name=‘IEC958 Playback Con Mask’,index=3
numid=3,iface=MIXER,name=‘IEC958 Playback Pro Mask’
numid=14,iface=MIXER,name=‘IEC958 Playback Pro Mask’,index=1
numid=25,iface=MIXER,name=‘IEC958 Playback Pro Mask’,index=2
numid=36,iface=MIXER,name=‘IEC958 Playback Pro Mask’,index=3
numid=4,iface=MIXER,name=‘IEC958 Playback Default’
numid=15,iface=MIXER,name=‘IEC958 Playback Default’,index=1
numid=26,iface=MIXER,name=‘IEC958 Playback Default’,index=2
numid=37,iface=MIXER,name=‘IEC958 Playback Default’,index=3
numid=5,iface=MIXER,name=‘IEC958 Playback Switch’
numid=16,iface=MIXER,name=‘IEC958 Playback Switch’,index=1
numid=27,iface=MIXER,name=‘IEC958 Playback Switch’,index=2
numid=38,iface=MIXER,name=‘IEC958 Playback Switch’,index=3
numid=8,iface=MIXER,name=‘HDA Comfort Noise’
numid=19,iface=MIXER,name=‘HDA Comfort Noise’,index=1
numid=30,iface=MIXER,name=‘HDA Comfort Noise’,index=2
numid=41,iface=MIXER,name=‘HDA Comfort Noise’,index=3
numid=6,iface=MIXER,name=‘HDA Decode Capability’
numid=17,iface=MIXER,name=‘HDA Decode Capability’,index=1
numid=28,iface=MIXER,name=‘HDA Decode Capability’,index=2
numid=39,iface=MIXER,name=‘HDA Decode Capability’,index=3
numid=7,iface=MIXER,name=‘HDA Maximum PCM Channels’
numid=18,iface=MIXER,name=‘HDA Maximum PCM Channels’,index=1
numid=29,iface=MIXER,name=‘HDA Maximum PCM Channels’,index=2
numid=40,iface=MIXER,name=‘HDA Maximum PCM Channels’,index=3
numid=10,iface=MIXER,name=‘HDA Custom ELD’,device=3
numid=21,iface=MIXER,name=‘HDA Custom ELD’,device=7
numid=32,iface=MIXER,name=‘HDA Custom ELD’,device=8
numid=43,iface=MIXER,name=‘HDA Custom ELD’,device=9
numid=9,iface=PCM,name=‘ELD’,device=3
numid=11,iface=PCM,name=‘Playback Channel Map’,device=3
numid=20,iface=PCM,name=‘ELD’,device=7
numid=22,iface=PCM,name=‘Playback Channel Map’,device=7
numid=31,iface=PCM,name=‘ELD’,device=8
numid=33,iface=PCM,name=‘Playback Channel Map’,device=8
numid=42,iface=PCM,name=‘ELD’,device=9
numid=44,iface=PCM,name=‘Playback Channel Map’,device=9

Then I have two doubts:

  1. Why does PulseAudio fail to set volume?
  2. If we don’t want to adjust the volume through related plugins in the pipeline,and we also don’t want to use pulsesink instead of alsasink,Is there any way we can modify the sink volume of the sound card tegrahdaxnx at the bottom layer? Whether the bottom layer can achieve this purpose by modifying the relevant alsa configuration files

Looking forward to your reply, thank you!

Hi,
Unfortunately, the HDA driver doesn’t expose any mixer control for Volume control directly from HW. so we need to use some kind of SW solution like audio player or alsa softvol support to control volume.

Below is a example to use ALSA bases softvol controls. Please give a try and let us know if it helps.

Edit alsa conf file “# sudo vim /etc/asound.conf” to add below entries and reboot the device

pcm.hdmi_hw {
type hw
card 0 # <— card number
device 7 # <— device number
}
pcm.hdmi_softvol {
type softvol
slave.pcm hdmi_hw
control.name hdmi_volume
control.card 0
}
pcm.!default hdmi_softvol

For first time use " aplay -D “hdmi_softvol” wavefile "

After the above command you would see below control for softvol

amixer -c 0 cget name=“hdmi_volume”
numid=45,iface=MIXER,name=‘hdmi_volume’
; type=INTEGER,access=rw—RW-,values=2,min=0,max=255,step=0
: values=255,255
| dBscale-min=-51.00dB,step=0.20dB,mute=0

Now you can try changing the above control value for volume level.

Hi, mkumard, thank you very much for your advice!
I tried following your steps,and it works in my gstreamer pipeline.

But now I have another problem, In our application, for device sharing, we have the dmix plugin configured on the device “hw:0,7”,as follows:

pcm.hdmi_out
{
type dmix
ipc_key 1042
ipc_key_add_uid true
slave{
pcm “hw:0,7”
period_time 20000
rate 48000
format S16_LE
channels 2
}
}

And we use it by:

gst-launch-1.0 alsasrc device=plughw:2,0 ! alsasink device=plug:hdmi_out
gst-launch-1.0 alsasrc device=plughw:3,0 ! alsasink device=plug:hdmi_out

According to your suggestion, we need define a new virtual pcm device "hdmi_softvol ", so I modified the configuration file,

pcm.hdmi_softvol {
type softvol
slave{
pcm “hw:0,7”
}
control.name hdmi_volume
control.card 0
}
pcm.hdmi_out
{
type dmix
ipc_key 1042
ipc_key_add_uid true
slave.pcm hdmi_softvol
}

Then I started the pipeline again and found an error,

Playback open error on device ‘plug:hdmi_out’: invalid parameter

so can the dmix plugin work with the softvol plugin and if so how should I modify the config file?

Looking forward to your reply, thanks!

Hi fanjiaheng,
Yes, ideally it is possible to use softvol and dmix plugin.

pcm.!default {
type plug
slave.pcm “hdmi_softvol” make use of softvol
}
pcm.hdmi_softvol {
type softvol
slave {
pcm “dmix:0,7” #redirect the output to dmix
}
control.name hdmi_volume
control.card 0
}

One reference found was @ Gentoo Forums :: View topic - Forcing alsa dmix to 24 bit 96 kHz with softvol [SOLVED]

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.