Bug 211893 - Mute and mute mic leds on Zbook Studio
Summary: Mute and mute mic leds on Zbook Studio
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-02-22 11:15 UTC by marietta
Modified: 2021-03-06 16:58 UTC (History)
2 users (show)

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


Attachments
Test patch (4.21 KB, patch)
2021-03-04 17:06 UTC, Takashi Iwai
Details | Diff

Description marietta 2021-02-22 11:15:48 UTC
Hello, I would like to make the mute and mute mic leds work on my laptop.
I own a HP Zbook Studio G5.

Mute is Fn+F5 and mute mic is Fn+F8.

The following
options snd-hda-intel model=hp-dock
gives more controls in alsamixer. I can switch between Line, Mic and Internal Mic. I also get controls for Mic Mute-LED Mode and Mute-LED Mode, but they don't turn the leds on or off.

The 
options snd-hda-intel model=mute-led-gpio
also gives me the controls for the leds, none of them turn the leds on or off.


I tried poking at the GPIOs.
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK 0x1{0..f}
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DIR 0x1{0..f}
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0x1{0..f}
turns the mute led on.

hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0x0{0..f}
turns it off.

Changing any of the GPIOs turns the mute mic led on and also mutes the microphone, but none of them turns it off and the microphone stays muted until reboot.

Please help me sort this out.
Thank you.
Comment 1 marietta 2021-02-22 11:37:40 UTC
grep "IO\[" /proc/asound/card0/codec\#0
when both leds are off:
  IO[0]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
  IO[1]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
  IO[2]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
  IO[3]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
  IO[4]: enable=1, dir=1, wake=0, sticky=0, data=0, unsol=0
  IO[5]: enable=1, dir=1, wake=0, sticky=0, data=0, unsol=0
  IO[6]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0
  IO[7]: enable=0, dir=0, wake=0, sticky=0, data=0, unsol=0


If I leave out the 'options' from modprobe, initially both leds are off.
Changing any of the GPIOs will turn the mic mute led on and mutes the microphone until reboot.

With one of the 'options' above, the mute mic led will be turned on right after boot and the microphone stays muted.


I ran alsa-info.sh, it is uploaded to http://alsa-project.org/db/?f=2fa38e8759f387ec7a66d3ef05badac8ae03ffe7
Comment 2 Takashi Iwai 2021-03-03 14:31:46 UTC
Hm, from the bug description, it's not clear whether GPIO actually turns on/off the LED or not...   Let's test it more carefully at first.

First of all, try to disable the runtime PM.  This can be done by

  echo 0 > /sys/module/snd_hda_intel/parameters/power_save

There are 8 GPIO pins, and each of them can be toggled via

  hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK $BIT
  hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DIR $BIT
  hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA $BIT

where $BIT is 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80.
When you set SET_GPIO_DATA 0, it'll turn off the GPIO pin.

And any of those 8 pins change the mute and mic-mute LED states?
Comment 3 marietta 2021-03-03 15:25:53 UTC
Thank you for the response.

If I change anything, even if I issue the
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK 0
command, the mic-mute led comes on and stays on. I can't turn it off afterwards.

If $BIT = 0x10
the mute led comes on.
When the led is on, SET_GPIO_DATA 0 turns it off.
Also 0x01 0x02 0x04 0x08 0x20 0x40 0x80 will turn it off.
Comment 4 Takashi Iwai 2021-03-03 15:31:52 UTC
(In reply to marietta from comment #3)
> Thank you for the response.
> 
> If I change anything, even if I issue the
> hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK 0
> command, the mic-mute led comes on and stays on. I can't turn it off
> afterwards.

Hmm.  In the above test, you'd need to run

  hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK $BIT
  hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DIR $BIT
  hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA $BIT

then
  hda-verb dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0

for each $BIT value.  It's possible that the mute LED is triggered inversely.
i.e. clear bit = LED on, set bit = off.
Comment 5 marietta 2021-03-03 18:46:14 UTC
It didn't change.. but you gave me an idea.. so I tried the following:


hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK 0x20
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DIR 0x20
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0
-> the led turned off!

hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0x20
-> the led turned on! 

Thank you :)
Comment 6 Takashi Iwai 2021-03-04 13:21:22 UTC
OK, that's the playback mute LED, right?  What about the mic mute LED?
Comment 7 marietta 2021-03-04 16:07:18 UTC
The playback mute led worked like this:

hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK 0x10
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DIR 0x10
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0x10
-> led turns on
hda-verb dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0
-> led turns off


The mic mute led:

-> led is on
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK 0x20
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DIR 0x20
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0
-> the led turns off
hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0x20
-> the led turns on
Comment 8 Takashi Iwai 2021-03-04 17:05:56 UTC
OK, thanks.
Below is a test patch that adds the mute / mic-mute LED controls.
Could you give it a try?  It's for 5.12-rc1 kernel, but likely applicable to older kernels, too.
Comment 9 Takashi Iwai 2021-03-04 17:06:24 UTC
Created attachment 295647 [details]
Test patch
Comment 10 marietta 2021-03-05 18:23:25 UTC
I applied the patch.
Two more controls have appeared in alsamixer: mic mute-led mode and mute-led mode.
The mic mute-led mode turns the mic mute led on, off, or follows capture/mute.
The mute-led mode turns the mute led on, off, or follows master.

Thank you!
Comment 11 Takashi Iwai 2021-03-06 16:58:53 UTC
OK, now I submitted and merged the fix patch.  It'll be likely included in 5.12-rc3.

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