Bug 212873 - [HP ENVY All-in-One 32-a12xxx] - Need to toggle GPIO pin to enable sound
Summary: [HP ENVY All-in-One 32-a12xxx] - Need to toggle GPIO pin to enable sound
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Sound(ALSA) (show other bugs)
Hardware: Intel Linux
: P1 normal
Assignee: Jaroslav Kysela
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-28 14:31 UTC by Paul Koster
Modified: 2021-05-04 09:18 UTC (History)
1 user (show)

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


Attachments
ALSA info (47.06 KB, text/plain)
2021-04-28 14:31 UTC, Paul Koster
Details
ALSA info with option: alc256-asus-aio (44.28 KB, text/plain)
2021-05-03 10:55 UTC, Paul Koster
Details
ALSA info, cold boot, with option: alc256-asus-aio (47.28 KB, text/plain)
2021-05-03 12:11 UTC, Paul Koster
Details
Test fix patch (2.28 KB, patch)
2021-05-03 15:43 UTC, Takashi Iwai
Details | Diff
Revised test patch (2.34 KB, patch)
2021-05-04 08:03 UTC, Takashi Iwai
Details | Diff

Description Paul Koster 2021-04-28 14:31:27 UTC
Created attachment 296525 [details]
ALSA info

No sound at all whereas all controls and settings seem to work without hiccups. Turns out a GPIO pin needs to be set. Found this out using hda-analyzer python script. Now I execute this script on start-up to make it work:

/usr/bin/hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_MASK 0x04
/usr/bin/hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DIRECTION 0x04
/usr/bin/hda-verb /dev/snd/hwC0D0 0x01 SET_GPIO_DATA 0x04

The strange thing is, when I close applications using sound, the system goes mute within a minute or so and I have to run hda-analyzer to toggle the 'enable' settings of this GPIO pin.

For now I run the gnome settings widget at startup, displaying the sound settings and running the hda-verb commands above. This seems enough to leave the sound on.
Comment 1 Takashi Iwai 2021-05-03 08:42:59 UTC
Try to pass model=alc256-asus-aio option to snd-hda-intel module.
Either boot with snd_hda_intel.model=alc256-asus-aio boot option or
create a file (e.g. /etc/modprobe.d/hda.conf) containing

options snd-hda-intel model=alc256-asus-aio

If this works, we can put a static quirk entry for your device, too.
Comment 2 Paul Koster 2021-05-03 09:23:32 UTC
(In reply to Takashi Iwai from comment #1)
> Try to pass model=alc256-asus-aio option to snd-hda-intel module.
> Either boot with snd_hda_intel.model=alc256-asus-aio boot option or
> create a file (e.g. /etc/modprobe.d/hda.conf) containing
> 
> options snd-hda-intel model=alc256-asus-aio
> 
> If this works, we can put a static quirk entry for your device, too.

Unfortunately this doesn't work
Comment 3 Takashi Iwai 2021-05-03 09:31:03 UTC
Strange.  Give alsa-info.sh output again after applying the option.
Comment 4 Paul Koster 2021-05-03 10:55:17 UTC
Created attachment 296593 [details]
ALSA info with  option: alc256-asus-aio
Comment 5 Paul Koster 2021-05-03 10:57:12 UTC
Behaviour is still the same: I have to manually toggle the GPIO switch and keep a sound stream open, like gnome sound settings. Otherwise sound is gone after I close the settings and open it again.
Comment 6 Takashi Iwai 2021-05-03 11:05:46 UTC
The proc content in comment 4 shows the GPIO[2] is set, which corresponds to 0x04.  Do you mean that this wasn't set automatically?  Then please give alsa-info.sh output before your manual tweaks.
Comment 7 Paul Koster 2021-05-03 12:11:19 UTC
Created attachment 296599 [details]
ALSA info, cold boot, with option: alc256-asus-aio

Added the alsa_info.txt after a cold boot, with no tweaks, but the model parameter.
Comment 8 Paul Koster 2021-05-03 12:13:58 UTC
Seems that the GPIO pin is properly set with this model, but appearenly it is muted already before the system is started and I'm able to start a sound stream.
Comment 9 Takashi Iwai 2021-05-03 12:47:00 UTC
I don't understand the comment 8.

What is muted, what didn't work, and what is this GPIO supposed to do for?
Comment 10 Paul Koster 2021-05-03 15:16:20 UTC
Ok, let me elaborate a bit more then ;-)

This GPIO pin is needed to drive the speakers (both built-in as well as headphones). Probably it switches on an amplifier?

When the GPIO is set, the currently played audio will be audible, but when there is no sound stream being played, system will go silent shortly therafter, even when enabled is set active. When a new stream is started, I have to toggle the GPIO to disabled and then back to enabled again to hear sound again.

With the model=alc256-asus-aio set the GPIO is set correctly, but as there was no sound to be played when the pin was set, the setup went silent already, before I could start a sound stream.

Let me know if this is more clear? I can also create a video if that helps....
Comment 11 Takashi Iwai 2021-05-03 15:31:02 UTC
OK, thanks.  This sounds like a unique behavior, the amp has some automatic shut down, as it seems.  The current setup is either always-on statically, or bound with Master switch, so it's essentially always on.  This needs a completely different way of control of GPIO unlike others.
Comment 12 Takashi Iwai 2021-05-03 15:42:40 UTC
A PoC fix patch is below.  Could you give it a try?
Comment 13 Takashi Iwai 2021-05-03 15:43:08 UTC
Created attachment 296609 [details]
Test fix patch
Comment 14 Paul Koster 2021-05-03 20:16:02 UTC
Hi Takashi, this PoC works! Toggling 'data' pin has the same effect as toggling the 'enable' pin appearently.

Only thing is now that pins 'out-dir' and 'enable' are off by default. If I start hda-analyzer and set these two pins, your solution works flawless. Playing multiple streams simultaneously, closing one and the other, restarting a stream etc.

Furthermore, with model=alc256-asus-aio in modprobe it doesn't work anymore.
Comment 15 Takashi Iwai 2021-05-04 08:02:46 UTC
Oh indeed, I forgot to set up the GPIO mask and dir.
The revised v2 patch is below.  Let me know if this works as is.

And, yes, you need to pass no model option with the patch.
Comment 16 Takashi Iwai 2021-05-04 08:03:12 UTC
Created attachment 296627 [details]
Revised test patch
Comment 17 Paul Koster 2021-05-04 08:57:48 UTC
Hi Takashi, thanx for your great job, it works perfect now! The sounds is audible from cold boot, after a restart and after suspend / standby.
Comment 18 Takashi Iwai 2021-05-04 09:18:51 UTC
Good to hear!

The fix patch was now submitted to the upstream.  It'll be merged to sound.git tree and will be propagated to 5.13-rc1 kernel likely in the next week.

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