Bug 196669

Summary: C-Media USB soundcard reports incorrect minimum volume
Product: Drivers Reporter: Star Brilliant (coder)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: RESOLVED CODE_FIX    
Severity: normal CC: bugzilla.kernel.org, coder, tiwai
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.11.8 Subsystem:
Regression: No Bisected commit-id:
Attachments: lsusb.txt
Test patch
Revised fix patch

Description Star Brilliant 2017-08-15 13:03:28 UTC
Created attachment 257923 [details]
lsusb.txt

Affected soundcard model:

  Bus 004 Device 018: ID 0d8c:0014 C-Media Electronics, Inc.

  USB Mixer: usb_id=0x0d8c0014, ctrlif=0, ctlerr=0
  Card: C-Media Electronics Inc. USB Audio Device at usb-0000:00:1d.0-1.2, full speed
    Unit: 9
      Control: name="Speaker Playback Volume", index=0
      Info: id=9, control=2, cmask=0x3, channels=2, type="S16"
      Volume: min=-9472, max=0, dBmin=-3700, dBmax=0

Problem:

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

  This misleading data further prevented the software mixing feature of PulseAudio from working at volume lower than -37 dB (24%), resulting no sound at all.

  It might be a common hardware problem for all C-Media USB soundcards, although the value "-37" might differ.

Suggested workaround:

  Ignore the reported lowest volume for all 0d8c devices, and set the lowest volume to -Infinity.
Comment 1 Takashi Iwai 2017-08-15 16:15:43 UTC
Ignoring the lowest value is no correct solution.  We have MINMAX_MUTE type and for the corresponding devices, this type should be used instead.

I'm not sure whether it's safe to apply the rule for all C-Media devices.  There are tons of C-Media ones, so I'd rather take conservative approach, apply the quirk only to known devices at first.

Below is a totally untested patch.  Could you check whether it does anything?
Comment 2 Takashi Iwai 2017-08-15 16:16:00 UTC
Created attachment 257927 [details]
Test patch
Comment 3 Star Brilliant 2017-08-16 09:59:09 UTC
This patch worked. Thanks.
Comment 4 Takashi Iwai 2017-08-16 10:51:51 UTC
OK, thanks.

To be sure, could you give the alsa-info.sh output after the patch?
My concern is that whether the quirk is applied to the wrong volumes, not only to the output volumes.

Also, do you know other USB device IDs showing the same problem?
Comment 5 Star Brilliant 2017-08-16 11:37:52 UTC
alsa-info.sh:

  http://www.alsa-project.org/db/?f=c3b18b819ac85401449bde31f5d734a53ffb66d8

Other volumes:

  There are 4 volumes in total:
    - Playback: Speaker
    - Playback: Mic (which is loopback)
    - Capture: Mic
    - Auto Gain Control (boolean, affects both Capture & Playback Mic)
  For "Playback: Speaker" and "Playback: Mic", the lowest volume acts as muted.
  For "Capture: Mic", the lowest volume does not act as muted.

A quick Google finds me 0d8c:000c also have the same problem:
  https://unix.stackexchange.com/questions/204782/pulseaudio-with-external-sound-adapter-work-around-broken-sound
Comment 6 Star Brilliant 2017-08-16 11:58:14 UTC
Related bug report on 0d8c:000c:
  https://bugzilla.redhat.com/show_bug.cgi?id=1248649
Comment 7 Star Brilliant 2017-08-16 12:12:21 UTC
That alsa-info.sh above was captured with the patched kernel.

This alsa-info.sh below is captured with the unpatched kernel:
  http://www.alsa-project.org/db/?f=b807809e8ade21fa3d49e0e890ec778492384070
Comment 8 Takashi Iwai 2017-08-16 12:24:46 UTC
Thanks.  Could you try the revised patch below?
If it works, I'm going to submit this and queue for the upstream inclusion.
Comment 9 Takashi Iwai 2017-08-16 12:25:10 UTC
Created attachment 257953 [details]
Revised fix patch
Comment 10 Star Brilliant 2017-08-17 14:10:31 UTC
The patch works as intended. Thanks!

It's ready to queue for the upstream.
Comment 11 Stéphane Gourichon 2018-12-17 09:41:29 UTC
Hello. Bug still observed on Ubuntu 18.04 (kernel 4.15.0-39-generic #42-Ubuntu SMP Tue Oct 23 15:48:01 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux).

At -27.36dB attenuation, sound is still output (and still very strong).
At -27.80dB and below, sound is muted.

Device is 0d8c:000c C-Media Electronics, Inc. Audio Adapter.

I can post more information if useful (e.g. alsa-info or whatever you ask).

Thank you for your attention.
Comment 12 Takashi Iwai 2018-12-17 10:44:54 UTC
A different device, a different problem.  Please create another bug report and mention this one there.  Thanks.

Meanwhile, this particular bug was fixed long time ago in the upstream commit 0f174b3525a43bd51f9397394763925e0ebe7bc7.  So let's close.