Bug 110311

Summary: bad volume control on Logitech S-150
Product: Drivers Reporter: Pierre Ossman (pierre-bugzilla)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: NEW ---    
Severity: normal CC: jim, superquad.vortex2, tiwai
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 4.2.8-300.fc23.x86_64 Subsystem:
Regression: No Bisected commit-id:
Attachments: volume step patch

Description Pierre Ossman 2016-01-03 15:33:47 UTC
I have a pair of cheap USB powered speakers from Logitech, model S-150. They work reasonably well, except for the volume control which is way off. Only the initial few steps actually do anything and anything above that is full blast.

Here's what I can see in dmesg:

[    3.017511] usb 1-1: new full-speed USB device number 2 using xhci_hcd
[    3.181389] usb 1-1: New USB device found, idVendor=1130, idProduct=1620
[    3.181397] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[    3.181402] usb 1-1: Product: USB  AUDIO  
[    3.181647] usb 1-1: ep 0x82 - rounding interval to 64 microframes, ep desc says 80 microframes
[    3.195480] input: USB  AUDIO   as /devices/pci0000:00/0000:00:10.0/usb1/1-1/1-1:1.2/0003:1130:1620.0001/input/input2
[    6.598245] usb 1-1: Warning! Unlikely big volume range (=17152), cval->res is probably wrong.
[    6.598254] usb 1-1: [2] FU [PCM Playback Volume] ch = 2, val = 0/17152/1
Comment 1 Raymond 2016-01-05 02:09:40 UTC
The number of steps 17152 is too large,  this mean dB per step is less than 1/256,  you need to increase cval->res so that dB range is correct
Comment 3 Raymond 2016-01-07 01:27:32 UTC
17152 = 67 * 256

this mean cval->res = 256

you have to recompile the alsa driver to set cval->res to 256 to get (0 to 67 steps )
Comment 5 Pierre Ossman 2016-01-09 14:13:33 UTC
(In reply to Raymond from comment #3)
> 17152 = 67 * 256
> 
> this mean cval->res = 256
> 
> you have to recompile the alsa driver to set cval->res to 256 to get (0 to
> 67 steps )

This gets a range that seems reasonable. The steps are however very unlinear so I'm wondering if the dB information is wonky as well. Any pointers on how to adjust that? I tried fiddling with cval->min/max but that just make things to nuts.
Comment 6 Pierre Ossman 2016-01-09 14:14:49 UTC
Created attachment 199081 [details]
volume step patch
Comment 7 Raymond 2016-01-09 16:08:06 UTC
https://git.kernel.org/cgit/linux/kernel/git/tiwai/sound.git/patch/sound/usb?id=42e3121d90f42e57f6dbd6083dff2f57b3ec7daa

You can use DECLARE_TLV_DB_RANGE to define a set of dB ranges
Comment 8 Takashi Iwai 2016-01-20 11:27:46 UTC
Could you cook up a proper patch?  Then I'm willing to merge to the upstream.
Comment 9 Pierre Ossman 2019-10-09 05:18:08 UTC
Sorry about dropping the ball on this. I got rid of these speakers so I didn't pursue a fix further. Feel free to close this issue if you want.
Comment 10 Jim Paris 2020-02-22 04:56:26 UTC
Hi,
This seems to the same as bug 72511.

I just bought the Logitech S-150 and also have volume control problems.  In Pulseaudio mixer, the volume is basically:
  0-9%: silent
  10-20%: rapidly increasing
  20-100%: nearly full volume

My cval ranges are different than the original report (same VID, PID):

[1044202.587605] usb 5-1.1.3: new full-speed USB device number 10 using xhci_hcd
[1044202.821372] usb 5-1.1.3: New USB device found, idVendor=1130, idProduct=1620, bcdDevice= 1.87
[1044202.821375] usb 5-1.1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[1044202.821376] usb 5-1.1.3: Product: USB  AUDIO  
[1044202.927882] usb 5-1.1.3: [2] FU [PCM Playback Switch] ch = 1, val = 0/1/1
[1044202.929123] usb 5-1.1.3: [2] FU [PCM Playback Volume] ch = 2, val = -16224/-16/48

which looks bogus (338.33 steps?)

The chip is the TP6902 and the manufacturer's website claims it has 64 levels of volume control.
https://www.tenx.com.tw/product_detail.aspx?ProductID=128
Comment 11 Jim Paris 2020-02-23 04:13:49 UTC
For what it's worth, my workaround is to just configure pulseaudio to use software mixing (and leave the volume set to 100% at the ALSA layer)

  # cat /etc/udev/rules.d/90-jim-usbaudio.rules
  SUBSYSTEM=="sound", ACTION=="change", KERNEL=="card*", SUBSYSTEMS=="usb", \
          ATTRS{idVendor}=="1130", ATTRS{idProduct}=="1620", \
          ENV{PULSE_PROFILE_SET}="/etc/pulse/profile-swmix.conf"

  # cat /etc/pulse/profile-swmix.conf
  [General]
  auto-profiles = yes
  
  [Mapping swmix-stereo]
  description = Stereo (software volume control)
  device-strings = hw:%f
  channel-map = left,right
  paths-output = /etc/pulse/path-swmix-output

  # cat /etc/pulse/path-swmix-output.conf
  [General]
  description = Stereo
  
  [Element PCM]
  switch = mute
  volume = ignore