[SOLVED] How to turn ON/OFF beep_mode in oss_hdaudio ?

OSS specific Linux discussion (x86/amd64)

Moderators: hannu, dev, cesium

igorzwx
Known Member
Posts: 1261
Joined: Sun Jun 28, 2009 9:31 pm

[SOLVED] How to turn ON/OFF beep_mode in oss_hdaudio ?

Postby igorzwx » Tue Apr 30, 2013 5:04 am

It turns out that Intel HD audio chipsets are capable of producing "loud as hell beep".

ALSA supports this very useful feature of Intel HDA codecs, and it seems that OSS4 also supports it viewtopic.php?f=3&t=5222

The users of Debian, Linux Mint and Arch Linux reported that Gnome3 and/or systemd can trigger "very loud beep which never stops" with Intel HDA chipsets:
http://forums.debian.net/viewtopic.php? ... 27#p416250
http://forums.linuxmint.com/viewtopic.php?f=191&t=94514
https://bbs.archlinux.org/viewtopic.php?pid=1148026

Therefore, it might reasonable to learn how to turn ON/OFF beep_mode in oss_hdaudio.

With ALSA, it can be done in this way:

Re: Disable gdm3 startup beep
by enok » 2012-01-22 14:10

I had the same issue with the system beep when the gdm3 login screen loaded and when I rebooted. It turns out it was the sound card module (snd_hda_intel) that was causing it. The snd_hda_intel has an option, "beep_mode", that grabs the system beep when it loads, overriding pcspkr. And, of course, "beep_mode" is enabled by default. That's why you still get the beep even when you remove and blacklist pcspkr.

Code: Select all

# modinfo snd_hda_intel | grep beep
parm:           beep_mode:Select HDA Beep registration mode (0=off, 1=on, 2=mute switch on/off) (default=1). (array of int)


To disable the system beep:

Code: Select all

# echo "options snd_hda_intel beep_mode=0" >> /etc/modprobe.d/alsa-base.conf
# echo "blacklist pcspkr" >> /etc/modprobe.d/blacklist.conf


That should get rid of the annoying beep you get when gdm3 loads and in the console. The Intel HD audio chipset is common in laptops now, so if you have a laptop that won't stop beeping, snd_hda_intel is likely the culprit. I haven't tried the "beep_mode=2" mute switch option, so I'm not sure what it does.
http://forums.debian.net/viewtopic.php? ... 27#p416250


ALSA driver for Intel HDA codecs, snd_hda_intel, does have beep_mode:

Code: Select all

!!Module: snd_hda_intel
   bdl_pos_adj : 32,32,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
   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
   enable : 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,Y
   enable_msi : -1
   id : (null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
   index : -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
   model : (null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
   patch : (null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null),(null)
   position_fix : 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
   power_save : 0
   power_save_controller : Y
   probe_mask : -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1
   probe_only : 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
   single_cmd : N

http://permalink.gmane.org/gmane.linux.alsa.user/35879


1. There is a small chip, called "Intel HDA codec". It is integrated into motherboard.
2. There is also a little thing affixed directly to motherboard, called "pc speaker", or "motherboard speaker".

Video: 4-Pin Motherboard Speaker Unboxing http://www.youtube.com/watch?v=vIYsgFZKX98

This "motherboard speaker" is supposed to be controlled by pcspkr driver.
However, snd_hda_intel driver can override pcspkr and privatize the "motherboard speaker".
ALSA simply grabs the system beep and plays "loud as hell beep" through the "motherboard speaker".

systemd can also grab the system beep and send it to "motherboard speaker".

See: Computer POST and beep codes http://www.computerhope.com/beep.htm

OSS4 driver for Intel HDA codecs, oss_hdaudio, should also have a kind of "beep_mode" to override pcspkr, grab the system beep, and produce "loud as hell beep" through the help of the "motherboard speaker".

It seems that oss_hdaudio also overrides pcspkr, because pcspkr does not produce any beep:

Code: Select all

$ sudo modprobe pcspkr
$ lsmod | grep pcspkr
pcspkr                 12631  0
$ echo -e "\007"


Moreover, pcspkr does not produce any beep, even if OSS4 is unloaded:

Code: Select all

$ sudo soundoff
$ sudo soundoff
OSS not loaded.
$ sudo modprobe pcspkr
$ lsmod | grep pcspkr
pcspkr                 12631  0
$ echo -e "\007"
Last edited by igorzwx on Wed May 01, 2013 11:23 pm, edited 5 times in total.

igorzwx
Known Member
Posts: 1261
Joined: Sun Jun 28, 2009 9:31 pm

Re: [SOLVED] How to turn ON/OFF beep_mode in oss_hdaudio ?

Postby igorzwx » Tue Apr 30, 2013 7:49 pm

SOLUTION:

If you want to produce beep with oss_hdaudio, or oss_ich, you can simply
(1) load pcspkr module

Code: Select all

$ sudo modprobe pcspkr
$ lsmod | grep pcspkr

(2) switch to a virtual console: Strl+Alt+F1 (that is, /dev/tty1 )
(3) execute command:

Code: Select all

$ echo -e "\007"


You do not need to unload OSS4 to produce beep with pcspkr,
because OSS4 drivers do not override pcspkr.

1. OSS4 does not grab the system beep, it does not override pcspkr.
2. If pcspkr is unloaded, the JB code "\007" does not produce any beep.

It was tested with Linux Mint 14 Mate (oss_hdaudio) and Arch Linux XFCE (oss_ich).

If you want to hear beep on boot, you can load pcspkr on boot:

Code: Select all

$ cat /etc/modules | grep pcspkr
pcspkr
$ cat /etc/modprobe.d/blacklist.conf | grep pcspkr
# blacklist pcspkr


In this case, you will also hear other beep notifications: reboot, shutdown, etc., if pcspkr is loaded.

It was tested with Linux Mint 14 Mate (oss_hdaudio).

The traditional method of producing a beep in a shell script is to write an ASCII BEL (\007) character to standard output, by means of a shell command such as ‘echo -ne '\007'’. This only works if the calling shell's standard output is currently directed to a terminal device of some sort; if not, the beep will produce no sound and might even cause unwanted corruption in whatever file the output is directed to.

There are other ways to cause a beeping noise. A slightly more reliable method is to open /dev/tty and send your BEL character there. This is robust against I/O redirection, but still fails in the case where the shell script wishing to generate a beep does not have a controlling terminal, for example because it is run from an X window manager.

A third approach is to connect to your X display and send it a bell command. This does not depend on a Unix terminal device, but does (of course) require an X display.
http://unix.stackexchange.com/questions ... eaker-beep


There should be a "Beep generator" switch in OSS4 Mixer. You may not find it in the mixer, but it is available in the source code of oss_hdaudio driver for Intel HDA codecs:

http://manuals.opensound.com/sources/hd ... dec.c.html
Codec handling for Intel High Definition Audio (HDA/Azalia).
This file is part of Open Sound System.

Code: Select all

#include "oss_hdaudio_cfg.h"
#include "hdaudio.h"
#include "hdaudio_codec.h"
#include "hdaudio_codecids.h"

extern int hdaudio_snoopy;
extern int hdaudio_jacksense;
extern int hdaudio_noskip;

...

attach_node (hdaudio_mixer_t * mixer, int cad, int wid, int parent)
{
  static const char *widget_types[16] = {
    "Audio output",
    "Audio input",
    "Audio mixer",
    "Audio selector",
    "Pin complex",
    "Power widget",
    "Volume knob",
    "Beep generator",
    "Reserved8",
    "Reserved9",
    "ReservedA",
    "ReservedB",
    "ReservedC",
    "ReservedD",
    "ReservedE",
    "Vendor defined audio"
  };

  static const char *widget_id[16] = {
    "pcm",
    "rec",
    "mix",
    "select",
    "jack",
    "power",
    "vol",
    "beep",
    "unkn",
    "unkn",
    "unkn",
    "unkn",
    "unkn",
    "unkn",
    "unkn",
    "vendor"
  };


http://manuals.opensound.com/developer/ ... let.c.html
[OSS4] mixer_applet.c
1) How to find the default mixer device that controls the primary sound card/device in the system. This device is connected to the primary (desktop) speakers and the default system sounds/beep are directed to it. Normally this device is the audio chip installed on the motherboard of the computer.


ALSA also supports the so-called "Beep Generator Widget" of Intel HDA codec:

https://bugs.launchpad.net/ubuntu/+sour ... +bug/33719

Code: Select all

Node 0x16 [Beep Generator Widget] wcaps 0x70000c: Mono Amp-Out
  Amp-Out caps: ofs=0x03, nsteps=0x03, stepsize=0x17, mute=0
  Amp-Out vals: [0x00]
Node 0x17 [Volume Knob Widget] wcaps 0x600000: Mono
Node 0x18 [Audio Output] wcaps 0x40201: Stereo Digital


http://www.alsa-project.org/main/index. ... ric_driver
[ALSA] HDA generic driver
Regenerated hda_beep.patch
Revert hda_intel.patch
regenerate pci/hda/hda_beep.patch
ALSA: hda - Add extra volume offset to standard volume amp macros
ALSA: hda - Check HDMI jack types in the auto configuration
ALSA: hda - No widget selection for volume knob widgets in proc output
ALSA: hda: Add digital beep generator support for Realtek codecs.


http://www.alsa-project.org/main/index. ... c_driver_2
[ALSA] HDA generic driver
- Regenerated hda_beep.patch
Signed-off-by: Takashi Iwai <tiwai@suse.de>
- Revert hda_intel.patch
The changes regarding the suspend of hda_intel.c was reverted, so
we need to revert the corresponding build-patch, too.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
- regenerate pci/hda/hda_beep.patch
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>


The problem is that the OSS4 driver for Intel HDA codecs, oss_hdaudio, is a generic driver http://manuals.opensound.com/usersguide ... audio.html
It cannot be perfect, and it is buggy, of course. All those "patches" for oss_hdaudio are simply "dirty hacks". They fix problems and create new ones. Therefore, the "Beep generator" switch might be missing in your OSS mixer, or it might be misidentified as "volume control", or "input-mix-mute", or else. It is unclear whether the "Beep generator" works or not. If it does not work, you can use pcspkr.

NOTE: If you think that is not a "solution", you are mistaken. OSS4 is said to be "open source". This usually means that there is a "secret documentation" called Ultimate Documentation. The trick is that the Ultimate Documentation is both "secret" and "open for public" at the same time. This does not contradict Marxist dialectics:
There's always a bit of Dialectic to help out. I have naturally expressed my statements so that I am also right if the opposite thing happens (Karl Marx).
http://en.wikipedia.org/wiki/Dialectic# ... dialectics

The Ultimate Documentation is, of course, the "source code". If you want to unlock the secret, you should study the code. In short, it is not just a "solution". It is a "secret solution", or, perhaps, more precisely, a "secret open-source solution".


Return to “Linux”

Who is online

Users browsing this forum: No registered users and 8 guests