/proc tunable speaker

Aaron Tiensivu (root@lucretia)
Thu, 9 Jan 1997 20:23:09 -0500


Real simple and to the point.. enable/disable speaker output
Against 2.1.15 but should work in 2.1.20 too.

echo 0 >/proc/sys/kernel/speaker

Turns off speaker.

Anything above 0 turns it on.

--- linux/drivers/char/vt.c.orig Thu Jan 9 19:50:50 1997
+++ linux/drivers/char/vt.c Thu Jan 9 20:06:16 1997
@@ -32,6 +32,8 @@
extern char vt_dont_switch;
extern struct tty_driver console_driver;

+int speaker_sound = 1;
+
#define VT_IS_IN_USE(i) (console_driver.table[i] && console_driver.table[i]->co
unt)
#define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || i == sel_cons)

@@ -163,27 +165,32 @@

unsigned int count = 0;

- if (hz > 20 && hz < 32767)
- count = 1193180 / hz;
+ /* proc tunable speaker sound - on or off */
+ /* Aaron Tiensivu (tiensivu@pilot.msu.edu) */
+
+ if (speaker_sound) {
+ if (hz > 20 && hz < 32767)
+ count = 1193180 / hz;

- cli();
- del_timer(&sound_timer);
- if (count) {
- /* enable counter 2 */
- outb_p(inb_p(0x61)|3, 0x61);
- /* set command for counter 2, 2 byte write */
- outb_p(0xB6, 0x43);
- /* select desired HZ */
- outb_p(count & 0xff, 0x42);
- outb((count >> 8) & 0xff, 0x42);
-
- if (ticks) {
- sound_timer.expires = jiffies+ticks;
- add_timer(&sound_timer);
- }
- } else
- kd_nosound(0);
- sti();
+ cli();
+ del_timer(&sound_timer);
+ if (count) {
+ /* enable counter 2 */
+ outb_p(inb_p(0x61)|3, 0x61);
+ /* set command for counter 2, 2 byte write */
+ outb_p(0xB6, 0x43);
+ /* select desired HZ */
+ outb_p(count & 0xff, 0x42);
+ outb((count >> 8) & 0xff, 0x42);
+
+ if (ticks) {
+ sound_timer.expires = jiffies+ticks;
+ add_timer(&sound_timer);
+ }
+ } else
+ kd_nosound(0);
+ sti();
+ }
return;
}

--- linux/include/linux/sysctl.h.orig Thu Jan 9 19:14:06 1997
+++ linux/include/linux/sysctl.h Thu Jan 9 20:04:58 1997
@@ -61,6 +61,7 @@
#define KERN_NFSRADDRS 18 /* NFS root addresses */
#define KERN_JAVA_INTERPRETER 19 /* path to Java(tm) interpreter */
#define KERN_JAVA_APPLETVIEWER 20 /* path to Java(tm) appletviewer */
+#define KERN_SPEAKER 21 /* Speaker sound - on or off */

/* CTL_VM names: */
#define VM_SWAPCTL 1 /* struct: Set vm swapping control */
--- linux/kernel/sysctl.c.orig Thu Jan 9 19:04:54 1997
+++ linux/kernel/sysctl.c Thu Jan 9 19:57:57 1997
@@ -26,7 +26,7 @@

/* External variables not in a header file. */
extern int panic_timeout;
-
+extern int speaker_sound;

#ifdef CONFIG_ROOT_NFS
#include <linux/nfs_fs.h>
@@ -133,6 +133,9 @@
0444, NULL, &proc_dointvec, (ctl_handler *)&do_securelevel_strategy},
{KERN_PANIC, "panic", &panic_timeout, sizeof(int),
0644, NULL, &proc_dointvec},
+ {KERN_SPEAKER, "speaker", &speaker_sound, sizeof(int),
+ 0644, NULL, &proc_dointvec},
+
#ifdef CONFIG_BLK_DEV_INITRD
{KERN_REALROOTDEV, "real-root-dev", &real_root_dev, sizeof(int),
0644, NULL, &proc_dointvec},

--
Which is worse: ignorance or apathy?  Who knows?  Who cares?
Life is sexually transmitted.
Yank my doodle, it's a dandy.
You can lead a horse to prune juice, but you wouldn't want him to drink it.