Bug 210559 - VIA VT2021 wrong minimal dB value
Summary: VIA VT2021 wrong minimal dB value
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-08 16:14 UTC by William
Modified: 2021-01-15 20:41 UTC (History)
1 user (show)

See Also:
Kernel Version: 5.9.11
Subsystem:
Regression: No
Bisected commit-id:


Attachments
alsa-info.sh output (63.11 KB, text/plain)
2020-12-08 16:14 UTC, William
Details
Test fix patch for VIA codecs (516 bytes, patch)
2021-01-08 14:31 UTC, Takashi Iwai
Details | Diff
DS_VIA_VT2021 (870.83 KB, application/pdf)
2021-01-15 14:10 UTC, William
Details
pulseaudio debug (572.00 KB, text/plain)
2021-01-15 14:58 UTC, William
Details
amixer-contents (7.65 KB, text/plain)
2021-01-15 15:04 UTC, William
Details

Description William 2020-12-08 16:14:03 UTC
Created attachment 294039 [details]
alsa-info.sh output

Affected Soundcard:

00:1b.0 Audio device [0403]: Intel Corporation 7 Series/C216 Chipset Family High Definition Audio Controller [8086:1e20] (rev 04)
	Subsystem: Gigabyte Technology Co., Ltd Device [1458:a014]

Motherboard is an old gigabyte Z77X-Ud3h - with VIA VT2021 audio 

Problem:

  The soundcard reports -63 dB as the lowest volume to ALSA, but setting the volume to -63 dB mutes the device.

  This also results in PulseAudio muting the device at 9% (-63db), resulting in no sound at all.


This my first bug report here i am new to Linux and hope this is the right place to report it. as you can see in the alsa-info the aplay -l output shows the device as VT2020 but it is definitly actually a VT2021 (i checkt on the motherboard) im told this is not an issue with pulseaudio it happens with ignore_dB=1 aswell as with the cli tool alsamixer.
Comment 1 Takashi Iwai 2021-01-08 14:31:14 UTC
The patch below should make the driver showing the minimal volume as mute.
Could you give it a try?
Comment 2 Takashi Iwai 2021-01-08 14:31:42 UTC
Created attachment 294567 [details]
Test fix patch for VIA codecs
Comment 3 William 2021-01-14 17:38:42 UTC
first of all thank you for looking into this.

I was able to compile kernel 5.9.16 with that patch but the result was still the same pulse mutes the device below 9%. i could confirm that the master volume slider in alsamixer showed a different value than before so i guess the patch was applied correctly but my assumption that it was the root cause was wrong mb...

using pulseaudio control the mixer values for Master PCM  and Front all are controlled and when reaching 8% the overall -dB is at -63db (master) -1.2dB (PCM) and -1.5dB (Front) but since master is at -63 there is already no sound.
at 9% master is at -61.5dB with PCM at -1.2dB and Front is maxed at -0.00 for overall -62.7dB and a very low sound.

What can cause this and is it normal that master control only has 0-42 volume steps? + why would pulseaudio put Master to 0 at 8%?
Comment 4 Takashi Iwai 2021-01-15 08:06:05 UTC
It's the hardware feature that mutes in the lowest volume, and we can't change it; that said, there is no way to allow the latest non-mute volume at all.

The difference with the patch is that the driver now tells that the lowest volume is the mute.  Then PA (or any other) can know that it's being muted in the lowest volume and can show the status more properly.

The Master volume is a virtual volume that is basically the additional attenuation applied on top of the Front volume.  This doesn't give more resolution; if the Front is already attenuated, Master can have the resolution (max - Front) value.  So, determining the real resolution, you need to set Front and PCM to 0dB, then adjust Master volume accordingly.
Comment 5 William 2021-01-15 14:08:54 UTC
ok. my understanding comes from this:
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/PulseAudioStoleMyVolumes/

basically saying that pulse 0%-100% slider works in dB adjusting outer to inner mixers...

But for some reason pulse is trying to go way below -63dB overall and archwiki said its a bug in the driver reporting wrong values and therefor a wontfix in pulseaudio. (a dirty workaround is that ignore_dB=1 but then i am left with only 43 volume steps and no change inbetween) (PCM and Front stay at 0dB always then) 

as i said the patch did not fix this as pulse still wanted to go below -63dB.
Here is a DataSheet about the audiochip (mb it helps). i can find the 0 to -63dB in 43 steps in it but dont know where the 0 to -51dB PCM mixer (34 steps) would come from.
Comment 6 William 2021-01-15 14:10:10 UTC
Created attachment 294647 [details]
DS_VIA_VT2021

Data Sheet VIA-VT-2021
Comment 7 Jaroslav Kysela 2021-01-15 14:21:23 UTC
William, could you show the debug output from PA? There are visible dB calculations. It may help to determine what's wrong. Also, if 'amixer contents' reports correct dB ranges, then this problem should be discussed in PA: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues .
Comment 8 William 2021-01-15 14:56:34 UTC
Thx for your help aswell

here is pulseaudio debug log for a short run and changing some volumes: interesting part is when switching below 9%...

D: [pulseaudio] alsa-sink.c: Requested volume: front-left: 5243 /   8% / -65,81 dB,   front-right: 5243 /   8% / -65,81 dB
D: [pulseaudio] alsa-sink.c: Got hardware volume: front-left: 5266 /   8% / -65,70 dB,   front-right: 5266 /   8% / -65,70 dB
D: [pulseaudio] alsa-sink.c: Calculated software volume: front-left: 65250 / 100% / -0,11 dB,   front-right: 65250 / 100% / -0,11 dB (accurate-enough=yes)

is there anything else needed to make sure its really not a driver bug??
mb the mixer order or smthing is assumed wrong or smthing..
Comment 9 William 2021-01-15 14:58:52 UTC
Created attachment 294649 [details]
pulseaudio debug
Comment 10 William 2021-01-15 15:04:52 UTC
Created attachment 294651 [details]
amixer-contents
Comment 11 Takashi Iwai 2021-01-15 16:41:42 UTC
It's because the volume is calculated as multiplication from both Master and Front (or Headphone) volumes; e.g. if both points to -60dB, it'll be -120dB although the hardware is up to -63dB or such.  It's a side-effect of the virtual master volume, unfortunately, and we have no way to inform the total limit of dB range, so far.
Comment 12 William 2021-01-15 17:59:25 UTC
so it is a missing feature? is there a way to hide the master/ front mixer so pulse would only see one and assume the -63dB minimum?

also why is PCM only down to -51dB? otherwise i could tell pulse to only use that mixer ... (i cant cuz i lose 12dB and can't mute)

is that feature even planned or is it too much of an edge case with these via onboard audio chips?
Comment 13 Jaroslav Kysela 2021-01-15 18:27:19 UTC
PCM control is defined in alsa-lib for this hardware, so you may change the range, there. But it's software defined volume control. It's better to keep this control to max (0dB gain) to avoid the stream modification.
Comment 14 William 2021-01-15 20:41:43 UTC
so what is the best solution here then. i just want a smooth audio control for a single line out why is it so hard to map 0>100 % to -63>0 dB? where do i go from here?

Note You need to log in before you can comment on or make changes to this bug.