lkml.org 
[lkml]   [1998]   [Feb]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: PROPOSAL: PC Speaker toggle

On Wed, 25 Feb 1998, David Woodhouse wrote:

:Date: Wed, 25 Feb 1998 18:23:53 +0000
:From: David Woodhouse <Dave@imladris.demon.co.uk>
:To: Rik van Riel <H.H.vanRiel@fys.ruu.nl>
:Cc: "Sean M. Kelly" <smkelly@zombie.org>, linux-kernel@vger.rutgers.edu
:Subject: Re: PROPOSAL: PC Speaker toggle
:
:
:H.H.vanRiel@fys.ruu.nl said:
:> OK, I've read the patch and it's so trivial that it just can't be
:> wrong.
:
:Famous last words....
:
:--- v2.1.88/drivers/char/vt.c Mon Feb 23 20:05:01 1998
:+++ linux/drivers/char/vt.c Tue Feb 24 16:42:00 1998
:@@ -33,6 +33,7 @@
:
: char vt_dont_switch = 0;
: extern struct tty_driver console_driver;
:+int spekaer_sound = 1;
: ^^^^^^^
:
[snip]:

Hmm... and that is why we shouldn't try to rewrite code to make it nicer
looking :) I also found another mistake, a missing ',' in sysctl.c.

This new attached patch has all the corrections *AND* I have successfully
compiled and tested it this time.

Thanks for pointing that out

-- Sean

-----
Sean M. Kelly
smkelly@zombie.org
diff -u --recursive --new-file v2.1.88/drivers/char/vt.c linux/drivers/char/vt.c
--- v2.1.88/drivers/char/vt.c Mon Feb 23 20:05:01 1998
+++ linux/drivers/char/vt.c Tue Feb 24 16:42:00 1998
@@ -33,6 +33,7 @@

char vt_dont_switch = 0;
extern struct tty_driver console_driver;
+int speaker_sound = 1;

#define VT_IS_IN_USE(i) (console_driver.table[i] && console_driver.table[i]->count)
#define VT_BUSY(i) (VT_IS_IN_USE(i) || i == fg_console || i == sel_cons)
@@ -168,28 +169,34 @@

unsigned int count = 0;

- if (hz > 20 && hz < 32767)
- count = 1193180 / hz;
+ /* PC Speaker toggle via proc */
+ /* Originally by Aaron Tiensivu (tiensivu@pilot.msu.edu) */
+ /* Revised for 2.1.88 by Sean Kelly <smkelly@zombie.org> */
+
+ 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);

- 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;
+ if (ticks) {
+ sound_timer.expires = jiffies+ticks;
+ add_timer(&sound_timer);
+ }
+ } else
+ kd_nosound(0);
+ sti();
+ }
+ return;
}

void (*kd_mksound)(unsigned int hz, unsigned int ticks) = _kd_mksound;
diff -u --recursive --new-file v2.1.88/include/linux/sysctl.h linux/include/linux/sysctl.h
--- v2.1.88/include/linux/sysctl.h Mon Feb 23 20:05:35 1998
+++ linux/include/linux/sysctl.h Tue Feb 24 16:43:14 1998
@@ -70,7 +70,8 @@
KERN_PRINTK, /* sturct: control printk logging parameters */
KERN_NAMETRANS, /* Name translation */
KERN_STATINODE,
- KERN_DENTRY /* dentry statistics */
+ KERN_DENTRY, /* dentry statistics */
+ KERN_PCSPEAKER /* PC Speaker */
};


diff -u --recursive --new-file v2.1.88/kernel/sysctl.c linux/kernel/sysctl.c
--- v2.1.88/kernel/sysctl.c Mon Feb 23 20:06:26 1998
+++ linux/kernel/sysctl.c Tue Feb 24 16:45:28 1998
@@ -41,6 +41,7 @@
extern int bdf_prm[], bdflush_min[], bdflush_max[];
extern char binfmt_java_interpreter[], binfmt_java_appletviewer[];
extern int sysctl_overcommit_memory;
+extern int speaker_sound;

#ifdef __sparc__
extern char reboot_command [];
@@ -155,6 +156,8 @@
{KERN_SECURELVL, "securelevel", &securelevel, sizeof(int),
0444, NULL, &proc_dointvec, (ctl_handler *)&do_securelevel_strategy},
{KERN_PANIC, "panic", &panic_timeout, sizeof(int),
+ 0644, NULL, &proc_dointvec},
+ {KERN_PCSPEAKER, "speaker", &speaker_sound, sizeof(int),
0644, NULL, &proc_dointvec},
#ifdef CONFIG_BLK_DEV_INITRD
{KERN_REALROOTDEV, "real-root-dev", &real_root_dev, sizeof(int),
\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.036 / U:0.996 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site