Bug 73851 - CM109 driver has little range, either inaudible or too loud
Summary: CM109 driver has little range, either inaudible or too loud
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: 2014-04-11 16:58 UTC by S.
Modified: 2015-07-29 19:58 UTC (History)
4 users (show)

See Also:
Kernel Version: 3.10, 3.12, 3.14
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description S. 2014-04-11 16:58:33 UTC
Hi, I use a CM109 headset. The device has very little volume range under Linux. When I reduce the volume below about 35%, it suddenly become inadudible. I confirmed that it has good range when used with Windows.

Additionally, there is a line in dmesg:
"cm109 1-1:1.3: cm109_toggle_buzzer_sync: usb_control_msg() failed -19"
Not sure if this is related or not.

Thanks for looking into this.
Comment 1 Raymond 2014-04-12 05:13:35 UTC
USB Mixer: usb_id=0x0d8c000e, ctrlif=0, ctlerr=0
Card: Generic USB Audio Device at usb-0000:00:1d.7-3.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=-7264, max=-16, dBmin=-2837, dBmax=-6


https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/637066

do the patch fix the problem ?
Comment 2 S. 2014-04-12 12:56:36 UTC
I'm sorry I don't compile my own kernels, so I couldn't try the patch. My apologies.
Comment 3 Raymond 2014-04-13 15:14:01 UTC
are you using pulseaudio volume control ?

if your USB audio is card 0

try using 

alsamixer -c 0

you can also set pulseaudio ignore dB scale and let pulseaudio use software volume

https://cgit.freedesktop.org/pulseaudio/pulseaudio/commit/?id=d6f598ab3e1cdb71dc3b408592d06bba23f53a71
Comment 4 S. 2014-04-13 21:04:42 UTC
Thanks again for the reply.

I tried "alsamixer -c 1" (my headphones are plugged in later, so card 1) but it reacts the same. The volume is either loud or completely silent.

As for making pulseaudio ignore the dB scale, is this what you are referring to?
http://tombuntu.com/index.php/2010/05/09/fix-volume-range-issue-in-pulseaudio/
This does seem to work well for me. It would just be nice if users didn't have to muck around with the pulseaudio config files. Could this be set on a per-driver basis, and by default for CM109?

Thanks again!
Comment 5 Raymond 2014-04-14 11:45:18 UTC
can you post the output of alsa-info,sh and lsusb -vvvv ?


http://www.freedesktop.org/wiki/Software/PulseAudio/Backends/ALSA/Decibel/

http://git.alsa-project.org/?p=alsa-utils.git;a=commit;h=34bb514b5fd1d6f91ba9a7b3a70b0ea0c6014250

alsamixer seem use linear scale when dB range is less than 24dB


dBmin=-2837, dBmax=-6

22.37
Comment 6 S. 2014-04-14 13:10:08 UTC
Sure, here are the logs:

http://pastebin.mozilla.org/4798566
http://pastebin.mozilla.org/4798564

The "Planet UP-100, Genius G-Talk" device is the one in question. I also tried this on an Asus 4810T laptop running the 3.10 kernel, and it behaved the same way.
Comment 7 Raymond 2014-04-15 03:37:14 UTC
 idVendor           0x0d8c C-Media Electronics, Inc.
  idProduct          0x000e Audio Adapter (Planet UP-100, Genius G-Talk)
  bcdDevice            1.00
  iManufacturer           0 
  iProduct                1 Generic USB Audio Device   


https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/?id=c04148f915e5ba7947752e6348e0da4cdab1329e


the playback volume control with steps from 0 to 151 and -48.87dB to -0.06dB


at which step do the sound volume change ?

try increase the volume one step at a time where x from 0 to 151


amixer -c1 set "PCM Playback Volume"  x



   control.3 {

                iface MIXER
                name 'PCM Playback Switch'
                value true
                comment {
                        access 'read write'
                        type BOOLEAN
                        count 1
                }

        }

        control.4 {

                iface MIXER
                name 'PCM Playback Volume'
                value.0 55
                value.1 55
                comment {
                        access 'read write'
                        type INTEGER
                        count 2
                        range '0 - 151'
                        dbmin -2837
                        dbmax -6
                        dbvalue.0 -1806
                        dbvalue.1 -1806
                }
        }

        control.5 {
                iface MIXER
                name 'Mic Capture Switch'
                value true
                comment {
                        access 'read write'
                        type BOOLEAN
                        count 1
                }

        }

        control.6 {
                iface MIXER
                name 'Mic Capture Volume'
                value 6
                comment {
                        access 'read write'
                        type INTEGER
                        count 1
                        range '0 - 16'
                        dbmin 0
                        dbmax 2381
                        dbvalue.0 892

                }
Comment 8 S. 2014-04-16 15:36:04 UTC
3 is silent.
4 is audible.

$ amixer -c1 set "PCM" 4
Simple mixer control 'PCM',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 151
  Mono:
  Front Left: Playback 4 [3%] [-27.63dB] [on]
  Front Right: Playback 4 [3%] [-27.63dB] [on]
Comment 9 Raymond 2014-04-17 05:16:39 UTC
do you mean the volume is maximum for the ranges 4 to 151 ?
Comment 10 S. 2014-04-17 12:06:53 UTC
(In reply to Raymond from comment #9)
> do you mean the volume is maximum for the ranges 4 to 151 ?

Sorry I wasn't clear. No, there is an abrupt cut-off from audible at 4 to silent at 3. I tested from 4 to 10, and there is gradual volume increase from 4 to 10. Also, I should have mentioned that for this test I removed the "ignore_dB=1" tweak from the config file.
Comment 11 Raymond 2014-04-18 01:48:04 UTC
you have to test the volume by application which can use hw:1,0 (e.g. allay/ speaker-test) instead of pulseaudio 


did pulseaudio find the correct dB range of your USB audio since both min dB and max dB are negative ?

http://freedesktop.org/software/pulseaudio/doxygen/volume_8h_source.html

your USB audio dB range does not contain PA_VOLUME_NORM 0dB
Comment 12 V字龍(Vdragon) 2014-07-05 09:32:20 UTC
Hi, I can confirm the similar issue on ID 0d8c:000c C-Media Electronics, Inc. Audio Adapter (kernel: 3.13.0-29-lowlatency from Ubuntu 14.04)
The sound became audible during the pulseaudio volume step 30% to 35%
Comment 13 matera.ttp 2014-12-10 08:43:06 UTC
Have the same issue on ubuntu 14.04 with usb sound card.
Comment 14 Simon 2014-12-28 08:56:03 UTC
I hope I'd get it right.  

Tested:
speaker-test -D hw:2,0 -c8

While I played with 
amixer -c2 set "Speaker" x

x = Number 0,1,2,...

For each Number except 0 i get Sound.
Comment 15 Simon 2014-12-28 09:09:03 UTC
Sorry for the double post.  I have forgotten:

1 is quite hearable and there are no jumps, just smooth increasing
Comment 16 Raymond 2014-12-28 15:17:19 UTC
you need to calibrate the dB range


http://wiki.linuxaudio.org/apps/all/japa


http://wiki.linuxaudio.org/apps/all/jaaa
Comment 17 Simon 2014-12-28 16:23:25 UTC
Both tools test the input (volume).  I don't understand, what should i do with them to get the range.
Comment 18 Simon 2014-12-30 16:19:24 UTC
I'm sorry, the window of Jaaa was too small, so I oversaw the output section.  Now I set the speaker volume in alsa to 100 (via alsamixer) then tested the dB-range with sinus.

For the lower end I get
-90.3dB NOT hearable
-90.2dB hearable

For the upper end I thought to test for distortion.  Well the headset was lying on my desk and maybe my ears are distorted. I assume the following
-2.3dB NOT distorted
-2.2dB distorted

Is that what you meant?
By the way, where are the output options in Japa?
Comment 19 Simon 2015-01-19 12:07:18 UTC
Looking at the datasheet page 33, announced in 
https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1200925
the dynamic range is 90dB.  So for that the upper end may be -0.2dB.  As I said I'm certain with the lower end.  There was a really small jump from no sound to sound. The next +0.1dB steps were smoother.  Should I test smaller step-sizes?
Comment 20 Simon 2015-03-23 07:57:19 UTC
Any news?  Or anything we/I could test to get the process along?
Comment 21 Raymond 2015-03-24 05:18:21 UTC
you need to change the formula if you want to shift dBmax to 0dB  by adding new variable shift_base and set it to -6



cval->dBmin = (convert_signed_value(cval, cval->min - shift_base) * 100) / 256;
cval->dBmax = (convert_signed_value(cval, cval->max - shift_base) * 100) / 256;
Comment 22 Simon 2015-03-31 08:08:20 UTC
Put these

cval->dBmin = (convert_signed_value(cval, cval->min) * 100) / 256;
cval->dBmax = (convert_signed_value(cval, cval->max) * 100) / 256;
//My edits starts here
switch (cval->mixer->chip->usb_id) {
case USB_ID(0x0d8c, 0x6):
  if (!strcmp(kctl->id.name, "Speaker Playback Volume")) {
    int shift_base = -6;
    cval->dBmin = (convert_signed_value(cval, cval->min - shift_base) * 100) / 256;
    cval->dBmax = (convert_signed_value(cval, cval->max - shift_base) * 100) / 256;
  }
  break;
}
//up to here
if (cval->dBmin > cval->dBmax) {

into kernel/sound/usb/mixer.c and compiled the kernel (Ubuntu-kernel 3.13.11).  (After reboot into this kernel) the problem is still present and there is no difference whether I plug&play nor starting Linux with headset power turned on.
Comment 23 Raymond 2015-03-31 16:32:02 UTC
if the volume control does not has fixed dB per step , you need to use DECLARE_TLV_DB_RANGE with severval ranges


https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/tree/include/sound/tlv.h


https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/commit/sound?id=093eef416642c84265cced12335ff125f0db7313
Comment 24 S. 2015-07-29 19:58:28 UTC
Confirmed that this bug still exists on Ubuntu 15.04 + mainline kernel:

uname -a
Linux T530 4.1.3-040103-generic #201507220129 SMP Wed Jul 22 01:31:38 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

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