Bug 204635

Summary: No HDA Digital PCBeep on Lenovo ThinkCentre with Realtek ALC3239
Product: Drivers Reporter: bughunter
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: RESOLVED CODE_FIX    
Severity: normal CC: tiwai
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: all Subsystem:
Regression: No Bisected commit-id:
Attachments: No HDA Digital PCBeep on Lenovo ThinkCentre with Realtek ALC3239
After Enabling Loopback Mixing
Lenovo ThinkCentre M73

Description bughunter 2019-08-20 00:07:53 UTC
Created attachment 284521 [details]
No HDA Digital PCBeep on Lenovo ThinkCentre with Realtek ALC3239

Lenovo M93p and M73 are old computers (from 2013). Everything looks OK. There is a beep slider in alsamixer. Everything works perfectly except a digital beep. After blacklisting snd_hda_intel Digital PCBeep works (can be heard) as dummy output in PulseAudio (but there is no HDA Intel HDMI and HDA Intel PCH cards). Alsa-info.txt attached.
Comment 1 Takashi Iwai 2019-08-20 06:56:30 UTC
You're turning off Loopback Mixing switch, so the analog-analog loopback is disabled.  Try to turn it on.

Note that this loopback might be a cause of some other noises, hence it's disabled as default on many codec chips.
Comment 2 bughunter 2019-08-20 08:26:05 UTC
Created attachment 284527 [details]
After Enabling Loopback Mixing
Comment 3 bughunter 2019-08-20 08:26:53 UTC
Turning on (enabling) Loopback Mixing doesn't help. New Alsa-info.txt attached.

I've seen a few alsa-info files generated on the machines with ALC3239. Some of them shows that this chip has two components: analog and digital.

aplay -l

[ deleted section about card 0: HDMI [HDA Intel HDMI ]

card 1: PCH [HDA Intel PCH], device 0: ALC3239 Analog [ALC3239 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: PCH [HDA Intel PCH], device 1: ALC3239 Digital [ALC3239 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Comment 4 Takashi Iwai 2019-08-20 08:58:43 UTC
Then I have no idea.  The beep stuff is pretty much depending on the hardware implementation, and so you'd need to ask Lenovo.
Comment 5 bughunter 2019-08-20 13:57:45 UTC
Thanks for help.

Might be helpful for others.

Steps to repeat problem/check your own machine.

HDA Digital PCBeep works on Lenovo ThinkPad X200 and Lenovo ThinkPad T500.
Doesn't work on Lenovo ThinkCentre M93p Tiny and Lenovo ThinkCentre M73.

1. Download linuxmint-19.2-cinnamon-64bit.iso and create bootable USB.
2. Start LinuxMint in live mode.
3. As root enable pcspkr by commenting or removing line:
blacklist pcspkr
in /etc/modprobe/blacklist.conf
4. As root load pcspkr module:
modprobe pcspkr

After that HDA Digital PCBeep works in real console. If you wish you may enable hda beep in X in terminal emulator:

Preferences > Sound > Terminal Bell

That's all :-)
//
Comment 6 bughunter 2019-08-20 14:32:32 UTC
Forgot

5. Unmute PC Beep in alsamixer
//
Comment 7 Takashi Iwai 2019-08-20 17:07:56 UTC
OK, could you try to pass beep_mode=0 option to snd-hda-intel module and see whether pcspkr keeps still working after loading the sound module?
Comment 8 bughunter 2019-08-20 18:18:00 UTC
I did as you suggested.

Start Linux with blacklisted snd-hda-intel
With working pcspkr I modprobed snd-hda-intel with
options snd-hda-intel beep_mode=0

and pcspkr stopped working.

I looked into alsa-info and saw on both cards:

beep_mode : N,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y,Y

Then I repeated the procedure, but this time with:

options snd-hda-intel beep_mode=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

And IT WORKS!!

Thank you very much :-)

For the record:

In alsa-info on both cards:
beep_mode : N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N,N

In alsamixer loopback mixing must be enabled.

//
Comment 9 Takashi Iwai 2019-08-20 18:57:49 UTC
Actually it's possible to put a blacklist to suppress the beep control creation in HD-audio side if it really doesn't work as expected.

I can cook a patch if you can give alsa-info.sh outputs on such machines.
Comment 10 bughunter 2019-08-21 09:05:51 UTC
Created attachment 284553 [details]
Lenovo ThinkCentre M73

Alsa-info from the other machine
Comment 11 Takashi Iwai 2019-08-22 08:02:34 UTC
Thanks.  Now I submitted the workaround patch to disable the beep creation for these machines.

I'm not going to merge this for 5.3 but maybe only for 5.4.  Please keep the beep_mode option you've used.
Comment 12 bughunter 2019-08-23 12:10:10 UTC
Thank you for your information.

I've put the beep_mode option in /etc/modprobe/alsa.conf and every hour on 59th minute (crontab) I have the proof that it still works.

sleep 53
amixer -c "PCH" sset Beep 50%
beep -f 1000 -l 100 -r 5 -d 900 && sleep 0.9 && beep -f 1000 -l 500
amixer -c "PCH" sset Beep 35%

It's Greenwich Time Signal :-)
https://en.wikipedia.org/wiki/Greenwich_Time_Signal

Thanks and good luck!
//