/* beep speaker */ #include <linux/module.h> #include <linux/kernel.h> #include <linux/delay.h> #include <asm/string.h> #include <asm/io.h> #define SPEAKER_PORT 0x61 #define PORT 0xFC #define HZ_MN1 0xff #define HZ_MN2 0x42 #define __bad_udelay() "wrong" static void kd_nosound(unsigned long ignored) { /* acesssando port space */ /* outb - saida em 8-bit */ /* inb_p - entrada em 8-bit */ outb(inb_p(SPEAKER_PORT) & PORT, SPEAKER_PORT); return; } static void kd_mksound(unsigned int hz, unsigned int ticks) { static struct timer_list sound_timer = { function: kd_nosound }; unsigned int count = 0; unsigned long flags; if (hz > 20 && hz < 32767) count = 1193180 / hz; save_flags(flags); cli(); del_timer(&sound_timer); if (count) { outb_p(inb_p(SPEAKER_PORT) | 3, SPEAKER_PORT); outb_p(0xB6, 0x43); /* selecionar HZ desejado */ outb_p(count & HZ_MN1, HZ_MN2); outb((count >> 8) & HZ_MN1, HZ_MN2); if (ticks) { sound_timer.expires = jiffies+ticks; add_timer(&sound_timer); } } else kd_nosound(0); restore_flags(flags); return; } void cleanup_module(void) { printk(KERN_INFO "Até! \n"); } int init_module(void) { kd_mksound(494,120); mdelay(200); kd_mksound(1,140); mdelay(100); kd_mksound(330,120); mdelay(200); kd_mksound(1,120); mdelay(100); kd_mksound(415,120); mdelay(200); kd_mksound(1,120); mdelay(100); kd_mksound(494,120); mdelay(200); kd_mksound(1,120); mdelay(100); kd_mksound(0,0); return 0; } MODULE_AUTHOR("Guilherme Polo"); MODULE_LICENSE("GPL"); EXPORT_NO_SYMBOLS;