Skip to content

Commit

Permalink
TTY: "nobeep" setting to disable beeps
Browse files Browse the repository at this point in the history
Disable the speaker by passing in "nobeep=1" as a boot option.
The option is preserved when updating the boot configuration.
Currently i386 only.
  • Loading branch information
dcvmoole committed Feb 15, 2013
1 parent 09b729b commit 972156d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion commands/update_bootcfg/update_bootcfg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DEFAULTCFG=/etc/boot.cfg.default
LOCALCFG=/etc/boot.cfg.local
TMP=/boot.cfg.temp
DIRSBASE=/boot/minix
INHERIT="ahci acpi no_apic"
INHERIT="ahci acpi no_apic nobeep"

filter_entries()
{
Expand Down
23 changes: 23 additions & 0 deletions drivers/tty/arch/i386/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static int vid_port; /* I/O port for accessing 6845 */
static int wrap; /* hardware can wrap? */
static int softscroll; /* 1 = software scrolling, 0 = hardware */
static int beeping; /* speaker is beeping? */
static long disable_beep = -1; /* do not use speaker if set to 1 */
static unsigned font_lines; /* font lines per character */
static unsigned scr_width; /* # characters on a line */
static unsigned scr_lines; /* # lines on the screen */
Expand Down Expand Up @@ -761,6 +762,24 @@ unsigned *val; /* 16-bit value to set it to */
}
#endif

/*===========================================================================*
* beep_disabled *
*===========================================================================*/
static long beep_disabled(void)
{
/* Return whether the user requested that beeps not be performed.
*/

/* Perform first-time initialization if necessary. */
if (disable_beep < 0) {
disable_beep = 0; /* the default is on */

(void) env_parse("nobeep", "d", 0, &disable_beep, 0, 1);
}

return disable_beep;
}

/*===========================================================================*
* beep *
*===========================================================================*/
Expand All @@ -774,6 +793,8 @@ static void beep()
pvb_pair_t char_out[3];
u32_t port_b_val;

if (beep_disabled()) return;

/* Set timer in advance to prevent beeping delay. */
set_timer(&tmr_stop_beep, B_TIME, stop_beep, 0);

Expand Down Expand Up @@ -880,6 +901,8 @@ clock_t dur;
static timer_t tmr_stop_beep;
pvb_pair_t char_out[3];
u32_t port_b_val;

if (beep_disabled()) return;

unsigned long ival= TIMER_FREQ / freq;
if (ival == 0 || ival > 0xffff)
Expand Down

0 comments on commit 972156d

Please sign in to comment.