Re: freebsd hdmi audio

From: Steven Friedrich <freebsdlouisville_at_gmail.com>
Date: Mon, 08 Jul 2024 11:19:35 UTC
On 7/8/24 05:42, Tomek CEDRO wrote:
> Does that produce noise on the HDMI audio?
>
> cat /dev/random > /dev/dsp2

Nope.  But I wrote a shell script using beep:

cat testSound
#!/bin/sh
echo "Begin `uname -s` `basename -s .sh $0` on `uname -n`"
echo "************************************************************"
cat /dev/sndstat
default_unit=`sysctl hw.snd.default_unit|awk '{print $2}'`
echo -e "\nDefault Sound device=$default_unit\n"
echo /dev/dsp$default_unit
mixer -f /dev/mixer0 vol=100 rec=0
mixer -f /dev/mixer1 vol=100 mic=0 rec=0
mixer -f /dev/mixer2 vol=100
# beep -g 100 -D 2000 -d /dev/dsp$default_unit
# beep -g 100 -D 2000 -d /dev/dsp0
# beep -g 100 -D 2000 -d /dev/dsp1
# beep -g 100 -D 2000 -d /dev/dsp2
for dsp in /dev/dsp*
do
#echo -n "$dsp  "
cat /dev/sndstat|grep -m 1 pcm`echo -n $dsp|cut -c 9-`; beep -g 100 -D 
2000 -d $dsp
done
echo "End   `uname -s` `basename -s .sh $0` on `uname -n`"
echo "************************************************************"

I can plug headphones into the rear or front audio jacks and hear the 
beep.  But no beep emits from speakers connected to hdmi.  I have 
speakers plugged into my monitor.  I don't have this problem with Mint, 
KDE Neon, or debian12.  Some FreeBSD users are claiming their system 
does produce sound out of HDMI.  I believe FreeBSD is missing some Linux 
"magic".


>
> What are vales for
>
> mixer -f /dev/mixer2
./testSound
Begin FreeBSD testSound on Slim
************************************************************
FreeBSD Audio Driver
Installed devices:
pcm0: <Realtek ALC671 (Rear Analog)> on hdaa0 (1p:1v/1r:1v)
         snddev flags=0x2e2<AUTOVCHAN,BUSY,MPSAFE,REGISTERED,VPC>
         [pcm0:play:dsp0.p0]: spd 48000, fmt 0x00200010, flags 
0x00002100, 0x00000004
         interrupts 0, underruns 0, feed 0, ready 0 
[b:2048/1024/2|bs:2048/1024/2]
         channel flags=0x2100<BUSY,HAS_VCHAN>
         {userland} -> feeder_mixer(0x00200010) -> {hardware}
         pcm0:play:dsp0.p0[pcm0:virtual_play:dsp0.vp0]: spd 8000, fmt 
0x00100008, flags 0x10000000, 0x00000000
         interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:0/0/0]
         channel flags=0x10000000<VIRTUAL>
         {userland} -> feeder_root(0x00000000) -> {hardware}
         [pcm0:record:dsp0.r0]: spd 48000, fmt 0x00200010, flags 
0x00002100, 0x00000005
         interrupts 0, overruns 0, feed 0, hfree 512, sfree 512 
[b:512/256/2|bs:512/256/2]
         channel flags=0x2100<BUSY,HAS_VCHAN>
         {hardware} -> feeder_root(0x00200010) -> 
feeder_mixer(0x00200010) -> {userland}
         pcm0:record:dsp0.r0[pcm0:virtual_record:dsp0.vr0]: spd 8000, 
fmt 0x00100008, flags 0x10000000, 0x00000000
         interrupts 0, overruns 0, feed 0, hfree 0, sfree 0 
[b:0/0/0|bs:0/0/0]
         channel flags=0x10000000<VIRTUAL>
         {hardware} -> feeder_root(0x00000000) -> {userland}
pcm1: <Realtek ALC671 (Analog)> on hdaa0 (1p:1v/1r:1v)
         snddev flags=0x2e2<AUTOVCHAN,BUSY,MPSAFE,REGISTERED,VPC>
         [pcm1:play:dsp1.p0]: spd 48000, fmt 0x00200010, flags 
0x00002100, 0x00000004
         interrupts 0, underruns 0, feed 0, ready 0 
[b:2048/1024/2|bs:2048/1024/2]
         channel flags=0x2100<BUSY,HAS_VCHAN>
         {userland} -> feeder_mixer(0x00200010) -> {hardware}
         pcm1:play:dsp1.p0[pcm1:virtual_play:dsp1.vp0]: spd 8000, fmt 
0x00100008, flags 0x10000000, 0x00000000
         interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:0/0/0]
         channel flags=0x10000000<VIRTUAL>
         {userland} -> feeder_root(0x00000000) -> {hardware}
         [pcm1:record:dsp1.r0]: spd 48000, fmt 0x00200010, flags 
0x00002100, 0x00000005
         interrupts 0, overruns 0, feed 0, hfree 512, sfree 512 
[b:512/256/2|bs:512/256/2]
         channel flags=0x2100<BUSY,HAS_VCHAN>
         {hardware} -> feeder_root(0x00200010) -> 
feeder_mixer(0x00200010) -> {userland}
         pcm1:record:dsp1.r0[pcm1:virtual_record:dsp1.vr0]: spd 8000, 
fmt 0x00100008, flags 0x10000000, 0x00000000
         interrupts 0, overruns 0, feed 0, hfree 0, sfree 0 
[b:0/0/0|bs:0/0/0]
         channel flags=0x10000000<VIRTUAL>
         {hardware} -> feeder_root(0x00000000) -> {userland}
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> on hdaa1 (1p:1v/0r:0v) default
         snddev 
flags=0x200002e7<SIMPLEX,AUTOVCHAN,SOFTPCMVOL,BUSY,MPSAFE,REGISTERED,VPC,PRIO_WR>
         [pcm2:play:dsp2.p0]: spd 48000, fmt 0x00200010, flags 
0x00006100, 0x00000004
         interrupts 2213, underruns 0, feed 2213, ready 0 
[b:2048/1024/2|bs:2048/1024/2]
         channel flags=0x6100<BUSY,HAS_VCHAN,VCHAN_PASSTHROUGH>
         {userland} -> feeder_mixer(0x00200010) -> {hardware}
         pcm2:play:dsp2.p0[pcm2:virtual_play:dsp2.vp0]: spd 8000/48000, 
fmt 0x00100008/0x00200010, flags 0x10000000, 0x0000006b
         interrupts 0, underruns 0, feed 0, ready 0 [b:0/0/0|bs:512/64/8]
         channel flags=0x10000000<VIRTUAL>
         {userland} -> feeder_root(0x00100008) -> 
feeder_format(0x00100008 -> 0x00100010) -> feeder_rate(0x00100010 q:1 
8000 -> 48000) -> feeder_matrix(1.0 -> 2.0) -> feeder_volume(0x00200010) 
-> {hardware}
No devices installed from userspace.

Default Sound device=2

/dev/dsp2
vol.volume: 1.00:1.00 -> 1.00:1.00
rec.volume: 0.00:0.00 -> 0.00:0.00
pcm0:mixer: <Realtek ALC671 (Rear Analog)> on hdaa0 (play/rec)
     vol       = 1.00:1.00     pbk
     pcm       = 1.00:1.00     pbk
     speaker   = 0.58:0.58     rec
     line      = 0.01:0.01     rec src
     mix       = 0.74:0.74     rec
     rec       = 0.00:0.00     pbk
     igain     = 0.00:0.00     pbk
     ogain     = 1.00:1.00     pbk
vol.volume: 1.00:1.00 -> 1.00:1.00
mic.volume: 0.00:0.00 -> 0.00:0.00
rec.volume: 0.00:0.00 -> 0.00:0.00
pcm1:mixer: <Realtek ALC671 (Analog)> on hdaa0 (play/rec)
     vol       = 1.00:1.00     pbk
     pcm       = 1.00:1.00     pbk
     mic       = 0.00:0.00     rec src
     rec       = 0.00:0.00     pbk
     igain     = 0.00:0.00     pbk
     ogain     = 1.00:1.00     pbk
vol.volume: 1.00:1.00 -> 1.00:1.00
pcm2:mixer: <Intel Kaby Lake (HDMI/DP 8ch)> on hdaa1 (play) (default)
     vol       = 1.00:1.00     pbk
     pcm       = 1.00:1.00     pbk
pcm0: <Realtek ALC671 (Rear Analog)> on hdaa0 (1p:1v/1r:1v)
pcm1: <Realtek ALC671 (Analog)> on hdaa0 (1p:1v/1r:1v)
pcm2: <Intel Kaby Lake (HDMI/DP 8ch)> on hdaa1 (1p:1v/0r:0v) default
End   FreeBSD testSound on Slim
************************************************************
I don't know what 0r:0v means.
>
> If you want to switch audio sources (i.e. per application) and outputs 
> on the fly consider using PulseAudio :-)
>
> --
> CeDeROM, SQ7MHZ, http://www.tomek.cedro.info