lkml.org 
[lkml]   [1998]   [Feb]   [24]   [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 Tue, 24 Feb 1998, Rik van Riel wrote:

:Date: Tue, 24 Feb 1998 10:46:26 +0100 (MET)
:From: Rik van Riel <H.H.vanRiel@fys.ruu.nl>
:To: "Sean M. Kelly" <smkelly@zombie.org>
:Cc: linux-kernel@vger.rutgers.edu
:Subject: Re: PROPOSAL: PC Speaker toggle
:
:On Mon, 23 Feb 1998, Sean M. Kelly wrote:
:
:> Let's face it, that nasty PC speaker is annoying as hell. *BEEEP BEEEP*
:>
:> I have a patch here that was originally made for 2.1.21 [I think] by Aaron
:> Tiensivu (tiensivu@pilot.msu.edu), and have updated it to work on 2.1.88.
:> If anybody would like me to send them the patch let me know.
:
:If it works and is trivial enough, please send it
:to Linus for inclusion in 2.1.89...
:
:Rik.
:+-----------------------------+------------------------------+
:| For Linux mm-patches, go to | "I'm busy managing memory.." |
:| my homepage (via LinuxHQ). | H.H.vanRiel@fys.ruu.nl |
:| ...submissions welcome... | http://www.fys.ruu.nl/~riel/ |
:+-----------------------------+------------------------------+

As many of you have pointed out to me, there is an option to 'setterm' to
do this. Unfortunately, I have not gotten the termainl settings to get
stored so that a termianl reset (i.e. the 'reset' command, or mingetty
reinitilizing the terminal) would preserve the beepless state. I did try
'setterm -bfreq 0 -store' and many other combinations.

I beileve that this patch is small enough that it doesn't really cause a
potential problem in the kernel. Also, there's the added advantage of
security. For example, let's say you admin the computers in a library, you
wouldn't want all the troublemakers that know Linux turning the beeping
back on :) The proc interface is a way for the administrator to set a
global state for the PC speaker which will stay under any circumstance
(except for sound directly sent to the driver).

I have included the patch in this message for those who are interrested
and also for those who wonder what 'exactly' I'm talking about.

As before, I appreciate any feedback

-- 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 spekaer_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.605 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site