2 * PC-9800 Speaker beeper driver for Linux
4 * Copyright (c) 2002 Osamu Tomita
5 * Copyright (c) 2002 Vojtech Pavlik
6 * Copyright (c) 1992 Orest Zborowski
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License version 2 as published by
13 * the Free Software Foundation
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/init.h>
19 #include <linux/input.h>
22 MODULE_AUTHOR("Osamu Tomita <tomita@cinet.co.jp>");
23 MODULE_DESCRIPTION("PC-9800 Speaker beeper driver");
24 MODULE_LICENSE("GPL");
26 static char spkr98_name[] = "PC-9801 Speaker";
27 static char spkr98_phys[] = "isa3fdb/input0";
28 static struct input_dev spkr98_dev;
30 spinlock_t i8253_beep_lock = SPIN_LOCK_UNLOCKED;
32 static int spkr98_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
34 unsigned int count = 0;
41 case SND_BELL: if (value) value = 1000;
46 if (value > 20 && value < 32767)
47 count = CLOCK_TICK_RATE / value;
49 spin_lock_irqsave(&i8253_beep_lock, flags);
54 outb(count & 0xff, 0x3fdb);
56 outb((count >> 8) & 0xff, 0x3fdb);
64 spin_unlock_irqrestore(&i8253_beep_lock, flags);
69 static int __init spkr98_init(void)
71 spkr98_dev.evbit[0] = BIT(EV_SND);
72 spkr98_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
73 spkr98_dev.event = spkr98_event;
75 spkr98_dev.name = spkr98_name;
76 spkr98_dev.phys = spkr98_phys;
77 spkr98_dev.id.bustype = BUS_ISA;
78 spkr98_dev.id.vendor = 0x001f;
79 spkr98_dev.id.product = 0x0001;
80 spkr98_dev.id.version = 0x0100;
82 input_register_device(&spkr98_dev);
84 printk(KERN_INFO "input: %s\n", spkr98_name);
89 static void __exit spkr98_exit(void)
91 input_unregister_device(&spkr98_dev);
94 module_init(spkr98_init);
95 module_exit(spkr98_exit);