From: David van Moolenbroek Date: Sun, 10 Feb 2013 00:17:47 +0000 (+0100) Subject: TTY: "nobeep" setting to disable beeps X-Git-Tag: v3.2.1^0 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=972156d595e8a959a5204e158fa8f16b99e443d4;p=minix.git TTY: "nobeep" setting to disable beeps Disable the speaker by passing in "nobeep=1" as a boot option. The option is preserved when updating the boot configuration. Currently i386 only. --- diff --git a/commands/update_bootcfg/update_bootcfg.sh b/commands/update_bootcfg/update_bootcfg.sh index 33abf6d30..c5c352939 100755 --- a/commands/update_bootcfg/update_bootcfg.sh +++ b/commands/update_bootcfg/update_bootcfg.sh @@ -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() { diff --git a/drivers/tty/arch/i386/console.c b/drivers/tty/arch/i386/console.c index cd383c46f..b18b853f4 100644 --- a/drivers/tty/arch/i386/console.c +++ b/drivers/tty/arch/i386/console.c @@ -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 */ @@ -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 * *===========================================================================*/ @@ -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); @@ -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)