The patch titled

     pc speaker driver update

has been added to the -mm tree.  Its filename is

     pc-speaker-driver-update-3.patch

Patches currently in -mm which might be from [EMAIL PROTECTED] are

pc-speaker-driver-update-3.patch
pc-speaker-driver-update-2.patch
kgdb-ga.patch



From: Stas Sergeev <[EMAIL PROTECTED]>

Update the pc speaker driver with the following:

1.  Use i8253_lock to serialize the port 0x43 accesses, rather than a
   hand-made i8253_beep_lock.

2.  Added SND_SILENT event that allows to disable (and enable) the
   driver, either to grant the hardware access to some other driver, or to
   disable the annoying beeps.

3. i8253.h added to <asm-alpha>

Signed-off-by: Stas Sergeev <[EMAIL PROTECTED]>
Cc: Vojtech Pavlik <[EMAIL PROTECTED]>
Cc: Richard Henderson <[EMAIL PROTECTED]>
Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
---

 arch/alpha/kernel/time.c    |    4 ++
 drivers/input/misc/pcspkr.c |   66 ++++++++++++++++++++++++++++++--------------
 include/asm-alpha/i8253.h   |    6 ++++
 include/linux/input.h       |    1 
 4 files changed, 56 insertions(+), 21 deletions(-)

diff -puN arch/alpha/kernel/time.c~pc-speaker-driver-update-3 
arch/alpha/kernel/time.c
--- devel/arch/alpha/kernel/time.c~pc-speaker-driver-update-3   2005-08-30 
00:00:57.000000000 -0700
+++ devel-akpm/arch/alpha/kernel/time.c 2005-08-30 00:00:57.000000000 -0700
@@ -47,6 +47,7 @@
 #include <asm/io.h>
 #include <asm/hwrpb.h>
 #include <asm/8253pit.h>
+#include <asm/i8253.h>
 
 #include <linux/mc146818rtc.h>
 #include <linux/time.h>
@@ -65,6 +66,9 @@ static int set_rtc_mmss(unsigned long);
 
 DEFINE_SPINLOCK(rtc_lock);
 
+DEFINE_SPINLOCK(i8253_lock);
+EXPORT_SYMBOL(i8253_lock);
+
 #define TICK_SIZE (tick_nsec / 1000)
 
 /*
diff -puN drivers/input/misc/pcspkr.c~pc-speaker-driver-update-3 
drivers/input/misc/pcspkr.c
--- devel/drivers/input/misc/pcspkr.c~pc-speaker-driver-update-3        
2005-08-30 00:00:57.000000000 -0700
+++ devel-akpm/drivers/input/misc/pcspkr.c      2005-08-30 00:00:57.000000000 
-0700
@@ -17,6 +17,7 @@
 #include <linux/init.h>
 #include <linux/input.h>
 #include <asm/8253pit.h>
+#include <asm/i8253.h>
 #include <asm/io.h>
 
 MODULE_AUTHOR("Vojtech Pavlik <[EMAIL PROTECTED]>");
@@ -26,27 +27,13 @@ MODULE_LICENSE("GPL");
 static char pcspkr_name[] = "PC Speaker";
 static char pcspkr_phys[] = "isa0061/input0";
 static struct input_dev pcspkr_dev;
+enum { PCSPKR_NORMAL, PCSPKR_SUSPENDED };
 
-static DEFINE_SPINLOCK(i8253_beep_lock);
-
-static int pcspkr_event(struct input_dev *dev, unsigned int type, unsigned int 
code, int value)
+static void pcspkr_do_sound(unsigned int count)
 {
-       unsigned int count = 0;
        unsigned long flags;
 
-       if (type != EV_SND)
-               return -1;
-
-       switch (code) {
-               case SND_BELL: if (value) value = 1000;
-               case SND_TONE: break;
-               default: return -1;
-       }
-
-       if (value > 20 && value < 32767)
-               count = PIT_TICK_RATE / value;
-
-       spin_lock_irqsave(&i8253_beep_lock, flags);
+       spin_lock_irqsave(&i8253_lock, flags);
 
        if (count) {
                /* enable counter 2 */
@@ -61,7 +48,41 @@ static int pcspkr_event(struct input_dev
                outb(inb_p(0x61) & 0xFC, 0x61);
        }
 
-       spin_unlock_irqrestore(&i8253_beep_lock, flags);
+       spin_unlock_irqrestore(&i8253_lock, flags);
+}
+
+static int pcspkr_event(struct input_dev *dev, unsigned int type,
+               unsigned int code, int value)
+{
+       unsigned int count = 0;
+
+       switch (type) {
+       case EV_SND:
+               switch (code) {
+               case SND_BELL:
+                       if (value)
+                               value = 1000;
+               case SND_TONE:
+                       break;
+               case SND_SILENT:
+                       dev->state = value ? PCSPKR_SUSPENDED : PCSPKR_NORMAL;
+                       return 0;
+               default:
+                       return -1;
+               }
+               break;
+
+       default:
+               return -1;
+       }
+
+       if (dev->state == PCSPKR_SUSPENDED)
+               return 0;
+
+       if (value > 20 && value < 32767)
+               count = PIT_TICK_RATE / value;
+
+       pcspkr_do_sound(count);
 
        return 0;
 }
@@ -69,7 +90,7 @@ static int pcspkr_event(struct input_dev
 static int __init pcspkr_init(void)
 {
        pcspkr_dev.evbit[0] = BIT(EV_SND);
-       pcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
+       pcspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE) | BIT(SND_SILENT);
        pcspkr_dev.event = pcspkr_event;
 
        pcspkr_dev.name = pcspkr_name;
@@ -78,6 +99,7 @@ static int __init pcspkr_init(void)
        pcspkr_dev.id.vendor = 0x001f;
        pcspkr_dev.id.product = 0x0001;
        pcspkr_dev.id.version = 0x0100;
+       pcspkr_dev.state = PCSPKR_NORMAL;
 
        input_register_device(&pcspkr_dev);
 
@@ -88,9 +110,11 @@ static int __init pcspkr_init(void)
 
 static void __exit pcspkr_exit(void)
 {
+       if (pcspkr_dev.state == PCSPKR_NORMAL) {
+               /* turn off the speaker */
+               pcspkr_do_sound(0);
+       }
         input_unregister_device(&pcspkr_dev);
-       /* turn off the speaker */
-       pcspkr_event(NULL, EV_SND, SND_BELL, 0);
 }
 
 module_init(pcspkr_init);
diff -puN /dev/null include/asm-alpha/i8253.h
--- /dev/null   2003-09-15 06:40:47.000000000 -0700
+++ devel-akpm/include/asm-alpha/i8253.h        2005-08-30 00:00:57.000000000 
-0700
@@ -0,0 +1,6 @@
+#ifndef __ASM_I8253_H__
+#define __ASM_I8253_H__
+
+extern spinlock_t i8253_lock;
+
+#endif /* __ASM_I8253_H__ */
diff -puN include/linux/input.h~pc-speaker-driver-update-3 include/linux/input.h
--- devel/include/linux/input.h~pc-speaker-driver-update-3      2005-08-30 
00:00:57.000000000 -0700
+++ devel-akpm/include/linux/input.h    2005-08-30 00:00:57.000000000 -0700
@@ -601,6 +601,7 @@ struct input_absinfo {
 #define SND_CLICK              0x00
 #define SND_BELL               0x01
 #define SND_TONE               0x02
+#define SND_SILENT             0x06
 #define SND_MAX                        0x07
 
 /*
_
-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to