Bug 213851 - Microphone LED is always on in the Thinkpad X220, T420 and W520
Summary: Microphone LED is always on in the Thinkpad X220, T420 and W520
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-07-25 16:55 UTC by Peter Weber
Modified: 2021-10-07 15:57 UTC (History)
2 users (show)

See Also:
Kernel Version: 5.13.x
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments
amixer -c0 contents (904 bytes, application/gzip)
2021-08-01 21:51 UTC, ValdikSS
Details
Sound LED debug patch (1.12 KB, patch)
2021-08-02 18:13 UTC, Jaroslav Kysela
Details | Diff
Sound LED debug patch v2 (1.51 KB, patch)
2021-08-03 12:10 UTC, Jaroslav Kysela
Details | Diff
Fix 'Capture Switch' change notifications (904 bytes, patch)
2021-08-11 12:57 UTC, Jaroslav Kysela
Details | Diff

Description Peter Weber 2021-07-25 16:55:12 UTC
Hello!

Since Linux >= 5.13 the microphone LED is always on, the microphone button itself works. The speaker LED is not affected and turns on/off like intended.

See also:
https://www.spinics.net/linux/fedora/fedora-users/msg508434.html

If I need to guess, I would look closely at one of these changes:
Hans de Goede (14):
HID: lenovo: Use brightness_set_blocking callback for setting LEDs brightness
HID: lenovo: Fix lenovo_led_set_tp10ubkbd() error handling
HID: lenovo: Check hid_get_drvdata() returns non NULL in lenovo_event()
HID: lenovo: Remove lenovo_led_brightness_get()
HID: lenovo: Set LEDs max_brightness value
HID: lenovo: Map mic-mute button to KEY_F20 instead of KEY_MICMUTE
HID: lenovo: Set default_triggers for the mute and micmute LEDs
HID: lenovo: Rework how the tp10ubkbd code decides which USB interface to use
HID: lenovo: Add support for Thinkpad X1 Tablet Thin keyboard

https://lore.kernel.org/lkml/nycvar.YFH.7.76.2104292151220.18270@cbobk.fhfr.pm/t/

Thanks for your work :)
Peter
Comment 1 Peter Weber 2021-07-29 12:12:38 UTC
When the ThinkPad is docked into a docking-station (with USB-Microphone attached to it) the LED remains always off. Vice versa.
Comment 2 ValdikSS 2021-08-01 20:35:45 UTC
This is a regression introduced by new alsa LED control.
Please edit the bug, set component: sound(alsa) and assignee perex@perex.cz (I'm not sure if you have privilege to assign)
Comment 3 Jaroslav Kysela 2021-08-01 20:57:49 UTC
Which controls are bound to the Mic LED ?

   cat /sys/devices/virtual/sound/ctl-led/mic/card0/list

and 'amixer -c 0 controls'

Replace 0 with the HDA card number, if different.
Comment 4 ValdikSS 2021-08-01 21:05:03 UTC
On 5.13.1

$ cat /sys/devices/virtual/sound/ctl-led/mic/card0/list
7

$ amixer -c 0 controls
numid=18,iface=CARD,name='Dock Headphone Jack'
numid=16,iface=CARD,name='Dock Mic Jack'
numid=22,iface=CARD,name='HDMI/DP,pcm=3 Jack'
numid=28,iface=CARD,name='HDMI/DP,pcm=7 Jack'
numid=34,iface=CARD,name='HDMI/DP,pcm=8 Jack'
numid=19,iface=CARD,name='Headphone Jack'
numid=14,iface=CARD,name='Internal Mic Phantom Jack'
numid=15,iface=CARD,name='Mic Jack'
numid=17,iface=CARD,name='Speaker Phantom Jack'
numid=13,iface=MIXER,name='Master Playback Switch'
numid=12,iface=MIXER,name='Master Playback Volume'
numid=4,iface=MIXER,name='Headphone Playback Switch'
numid=3,iface=MIXER,name='Headphone Playback Volume'
numid=43,iface=MIXER,name='PCM Playback Volume'
numid=9,iface=MIXER,name='Mic Boost Volume'
numid=7,iface=MIXER,name='Capture Switch'
numid=6,iface=MIXER,name='Capture Volume'
numid=23,iface=MIXER,name='IEC958 Playback Con Mask'
numid=29,iface=MIXER,name='IEC958 Playback Con Mask',index=1
numid=35,iface=MIXER,name='IEC958 Playback Con Mask',index=2
numid=24,iface=MIXER,name='IEC958 Playback Pro Mask'
numid=30,iface=MIXER,name='IEC958 Playback Pro Mask',index=1
numid=36,iface=MIXER,name='IEC958 Playback Pro Mask',index=2
numid=25,iface=MIXER,name='IEC958 Playback Default'
numid=31,iface=MIXER,name='IEC958 Playback Default',index=1
numid=37,iface=MIXER,name='IEC958 Playback Default',index=2
numid=26,iface=MIXER,name='IEC958 Playback Switch'
numid=32,iface=MIXER,name='IEC958 Playback Switch',index=1
numid=38,iface=MIXER,name='IEC958 Playback Switch',index=2
numid=5,iface=MIXER,name='Auto-Mute Mode'
numid=11,iface=MIXER,name='Beep Playback Switch'
numid=10,iface=MIXER,name='Beep Playback Volume'
numid=44,iface=MIXER,name='Digital Capture Volume'
numid=8,iface=MIXER,name='Internal Mic Boost Volume'
numid=2,iface=MIXER,name='Speaker Playback Switch'
numid=1,iface=MIXER,name='Speaker Playback Volume'
numid=21,iface=PCM,name='Capture Channel Map'
numid=20,iface=PCM,name='Playback Channel Map'
numid=27,iface=PCM,name='ELD',device=3
numid=40,iface=PCM,name='Playback Channel Map',device=3
numid=33,iface=PCM,name='ELD',device=7
numid=41,iface=PCM,name='Playback Channel Map',device=7
numid=39,iface=PCM,name='ELD',device=8
numid=42,iface=PCM,name='Playback Channel Map',device=8



On 5.12

$ amixer -c 0 controls
numid=20,iface=CARD,name='Dock Headphone Jack'
numid=18,iface=CARD,name='Dock Mic Jack'
numid=24,iface=CARD,name='HDMI/DP,pcm=3 Jack'
numid=30,iface=CARD,name='HDMI/DP,pcm=7 Jack'
numid=36,iface=CARD,name='HDMI/DP,pcm=8 Jack'
numid=21,iface=CARD,name='Headphone Jack'
numid=16,iface=CARD,name='Internal Mic Phantom Jack'
numid=17,iface=CARD,name='Mic Jack'
numid=19,iface=CARD,name='Speaker Phantom Jack'
numid=14,iface=MIXER,name='Master Playback Switch'
numid=13,iface=MIXER,name='Master Playback Volume'
numid=4,iface=MIXER,name='Headphone Playback Switch'
numid=3,iface=MIXER,name='Headphone Playback Volume'
numid=45,iface=MIXER,name='PCM Playback Volume'
numid=9,iface=MIXER,name='Mic Boost Volume'
numid=12,iface=MIXER,name='Mic Mute-LED Mode'
numid=7,iface=MIXER,name='Capture Switch'
numid=6,iface=MIXER,name='Capture Volume'
numid=25,iface=MIXER,name='IEC958 Playback Con Mask'
numid=31,iface=MIXER,name='IEC958 Playback Con Mask',index=1
numid=37,iface=MIXER,name='IEC958 Playback Con Mask',index=2
numid=26,iface=MIXER,name='IEC958 Playback Pro Mask'
numid=32,iface=MIXER,name='IEC958 Playback Pro Mask',index=1
numid=38,iface=MIXER,name='IEC958 Playback Pro Mask',index=2
numid=27,iface=MIXER,name='IEC958 Playback Default'
numid=33,iface=MIXER,name='IEC958 Playback Default',index=1
numid=39,iface=MIXER,name='IEC958 Playback Default',index=2
numid=28,iface=MIXER,name='IEC958 Playback Switch'
numid=34,iface=MIXER,name='IEC958 Playback Switch',index=1
numid=40,iface=MIXER,name='IEC958 Playback Switch',index=2
numid=5,iface=MIXER,name='Auto-Mute Mode'
numid=11,iface=MIXER,name='Beep Playback Switch'
numid=10,iface=MIXER,name='Beep Playback Volume'
numid=46,iface=MIXER,name='Digital Capture Volume'
numid=8,iface=MIXER,name='Internal Mic Boost Volume'
numid=15,iface=MIXER,name='Mute-LED Mode'
numid=2,iface=MIXER,name='Speaker Playback Switch'
numid=1,iface=MIXER,name='Speaker Playback Volume'
numid=23,iface=PCM,name='Capture Channel Map'
numid=22,iface=PCM,name='Playback Channel Map'
numid=29,iface=PCM,name='ELD',device=3
numid=42,iface=PCM,name='Playback Channel Map',device=3
numid=35,iface=PCM,name='ELD',device=7
numid=43,iface=PCM,name='Playback Channel Map',device=7
numid=41,iface=PCM,name='ELD',device=8
numid=44,iface=PCM,name='Playback Channel Map',device=8

Note that on 5.13 there's no 'Mute-LED Mode' and 'Mic Mute-LED Mode'
Comment 5 Jaroslav Kysela 2021-08-01 21:10:34 UTC
The ALSA mixer controls for the LED mode were removed, only the sysfs interface is available to set the LED mode now.

   numid=7,iface=MIXER,name='Capture Switch'

The Mic LED mute should follow this switch. Could you try to control this mixer element using 'alsamixer' or 'amixer' ?
Comment 6 ValdikSS 2021-08-01 21:12:02 UTC
This element is not visible in alsamixer. When I press mute button physically, the state changes correctly. Checked with
amixer -c0 cget numid=7,iface=MIXER,name='Capture Switch'
Comment 7 ValdikSS 2021-08-01 21:14:16 UTC
$ amixer -c0 cget numid=7,iface=MIXER,name='Capture Switch'
numid=7,iface=MIXER,name='Capture Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on

$ amixer cset numid=7,iface=MIXER,name='Capture Switch' on,on
numid=2,iface=MIXER,name='Capture Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on


Note that the numid's are different (2 vs 7) and only a single value. Is this the issue?
Comment 8 ValdikSS 2021-08-01 21:15:16 UTC
Sorry, nevermind, forget to add "-c0".

$ amixer -c0 cset numid=7,iface=MIXER,name='Capture Switch' on
numid=7,iface=MIXER,name='Capture Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on

on/off does not make led change, it always on.
Comment 9 Jaroslav Kysela 2021-08-01 21:37:27 UTC
In alsamixer, you need to switch to the capture view (F4).

I don't see a problem in the control_led.c code (the ledtrig_audio_set() call seems straight and should follow the attached element). You may attach also a different element for the check.

If you set the Mic LED mute mode to 'off', the function is correct?
Comment 10 ValdikSS 2021-08-01 21:46:39 UTC
(In reply to Jaroslav Kysela from comment #9)
> In alsamixer, you need to switch to the capture view (F4).

I know, but there's no such switch.
https://files.catbox.moe/o8if48.png
Capture bar doesn't have mute capability either.

> I don't see a problem in the control_led.c code (the ledtrig_audio_set()
> call seems straight and should follow the attached element). You may attach
> also a different element for the check.

When I attach 13 (speaker mute) to mic led, it works. This element has only one value (on or off), while element 7 (mic mute) has two values: on,on or off,off.
Could this be the cause of ths issue?

> 
> If you set the Mic LED mute mode to 'off', the function is correct?

When I set Mic LED mute mode to 'off' on 5.12, it works correctly.
Comment 11 ValdikSS 2021-08-01 21:51:14 UTC
Created attachment 298145 [details]
amixer -c0 contents

The microphone is stereo by the way.
Comment 12 Peter Weber 2021-08-02 15:55:23 UTC
I've set it to Sound(ALSA). Jaroslav (perex) is already here :)
Comment 13 Jaroslav Kysela 2021-08-02 18:13:13 UTC
(In reply to ValdikSS from comment #10)
> (In reply to Jaroslav Kysela from comment #9)
> > In alsamixer, you need to switch to the capture view (F4).
> 
> I know, but there's no such switch.
> https://files.catbox.moe/o8if48.png
> Capture bar doesn't have mute capability either.

The red 'CAPTURE' state means that the capture path is active (unmuted). The space key controls this in the F4 view.

> > I don't see a problem in the control_led.c code (the ledtrig_audio_set()
> > call seems straight and should follow the attached element). You may attach
> > also a different element for the check.
> 
> When I attach 13 (speaker mute) to mic led, it works. This element has only
> one value (on or off), while element 7 (mic mute) has two values: on,on or
> off,off.
> Could this be the cause of ths issue?

The Mic LED should be active when both values for 'Capture Switch' are off. The new code evaluates all values.

Could you apply the attached patch (led-debug) and show me the 'CTL LED' lines from dmesg when you toggle the 'Capture Switch' on and off ?
Comment 14 Jaroslav Kysela 2021-08-02 18:13:56 UTC
Created attachment 298169 [details]
Sound LED debug patch
Comment 15 ValdikSS 2021-08-03 06:33:31 UTC
0x4000000 is mic led, 0x2000000 is speaker led.
Mic led lights up on boot and does not switch after switching capture or pressing the physical button. No new records are printed on switching. Pressing speaker mute button adds prints.

[   19.665980] CTL LED GET: access=0x4000000 value[0]=0
[   19.665983] CTL LED GET: access=0x4000000 value[1]=0
[   19.665984] CTL LED STATE: access=0x4000000 route=0
[   19.665988] CTL LED GET: access=0x2000000 value[0]=0
[   19.665989] CTL LED STATE: access=0x2000000 route=0
[   19.665992] CTL LED GET: access=0x2000000 value[0]=0
[   19.665994] CTL LED STATE: access=0x2000000 route=0
[   19.665996] CTL LED GET: access=0x4000000 value[0]=0
[   19.665997] CTL LED GET: access=0x4000000 value[1]=0
[   19.665998] CTL LED STATE: access=0x4000000 route=0
[   46.178143] CTL LED GET: access=0x2000000 value[0]=1
[   46.178149] CTL LED STATE: access=0x2000000 route=1
[  245.647248] CTL LED GET: access=0x2000000 value[0]=0
[  245.647254] CTL LED STATE: access=0x2000000 route=0
[  246.467618] CTL LED GET: access=0x2000000 value[0]=1
[  246.467624] CTL LED STATE: access=0x2000000 route=1
[  247.087296] CTL LED GET: access=0x2000000 value[0]=0
[  247.087320] CTL LED STATE: access=0x2000000 route=0
[  247.876807] CTL LED GET: access=0x2000000 value[0]=1
[  247.876813] CTL LED STATE: access=0x2000000 route=1
Comment 16 Jaroslav Kysela 2021-08-03 12:10:25 UTC
Created attachment 298179 [details]
Sound LED debug patch v2
Comment 17 Jaroslav Kysela 2021-08-03 12:11:20 UTC
Please, provide new output from the updated debug patch.
Comment 18 ValdikSS 2021-08-03 12:49:46 UTC
[авг 3 15:48] CTL LED ADD/VALUE: access=0x4000003/0x4000000
[  +0,000008] CTL LED GET: access=0x4000000 value[0]=1
[  +0,000002] CTL LED STATE: access=0x4000000 route=1
[  +0,000013] CTL LED GET: access=0x2000000 value[0]=1
[  +0,000001] CTL LED STATE: access=0x2000000 route=1
[  +0,000007] CTL LED GET: access=0x2000000 value[0]=1
[  +0,000001] CTL LED STATE: access=0x2000000 route=1
[  +0,000004] CTL LED GET: access=0x4000000 value[0]=1
[  +0,000001] CTL LED STATE: access=0x4000000 route=1

No new records upon switching.
Comment 19 Jaroslav Kysela 2021-08-03 12:58:07 UTC
Do you see element change events using the 'amixer -c 0 events' for the 'Capture Switch'? Replace zero with your HDA card number.
Comment 20 ValdikSS 2021-08-03 13:33:39 UTC
No, there's no events for CAPTURE switch. There are for speaker though.

...
Ready to listen...
Poll ok: 1
event value: numid=2,iface=MIXER,name='Speaker Playback Switch'
event value: numid=2,iface=MIXER,name='Speaker Playback Switch'
event value: numid=13,iface=MIXER,name='Master Playback Switch'
event value: numid=2,iface=MIXER,name='Speaker Playback Switch'
event value: numid=13,iface=MIXER,name='Master Playback Switch'
event value: numid=13,iface=MIXER,name='Master Playback Switch'
Comment 21 Jaroslav Kysela 2021-08-03 14:05:28 UTC
So the problem does not seem to be related to the LED code.

Takashi, do you have any idea why 'Capture Switch' does not generate change notifications?
Comment 22 ValdikSS 2021-08-08 21:48:04 UTC
'Capture Switch' does not generate change notifications on older kernels as well (tested with 5.10.56).
Comment 23 Jaroslav Kysela 2021-08-11 12:57:01 UTC
Created attachment 298287 [details]
Fix 'Capture Switch' change notifications

Please, test this patch.
Comment 24 ValdikSS 2021-08-11 15:46:37 UTC
(In reply to Jaroslav Kysela from comment #23)
> Created attachment 298287 [details]
> Fix 'Capture Switch' change notifications
> 
> Please, test this patch.

It works. LED works correctly with the patch, `amixer -c0 events` shows the event.
Comment 25 Jaroslav Kysela 2021-08-11 16:16:54 UTC
Upstream patch: https://lore.kernel.org/alsa-devel/20210811161441.1325250-1-perex@perex.cz/
Comment 26 Jaroslav Kysela 2021-08-12 12:42:55 UTC
Queued to upstream. Thank you for your co-operation with the debugging and testing.
Comment 27 ValdikSS 2021-08-30 07:33:34 UTC
Should be fixed in 5.14.
Comment 28 ValdikSS 2021-09-10 08:49:41 UTC
As well as 5.13.13.

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