m68kspkr.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * m68k beeper driver for Linux
  3. *
  4. * Copyright (c) 2002 Richard Zidlicky
  5. * Copyright (c) 2002 Vojtech Pavlik
  6. * Copyright (c) 1992 Orest Zborowski
  7. *
  8. */
  9. /*
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License version 2 as published by
  12. * the Free Software Foundation
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/module.h>
  16. #include <linux/init.h>
  17. #include <linux/input.h>
  18. #include <asm/machdep.h>
  19. #include <asm/io.h>
  20. MODULE_AUTHOR("Richard Zidlicky <rz@linux-m68k.org>");
  21. MODULE_DESCRIPTION("m68k beeper driver");
  22. MODULE_LICENSE("GPL");
  23. static char m68kspkr_name[] = "m68k beeper";
  24. static char m68kspkr_phys[] = "m68k/generic";
  25. static struct input_dev m68kspkr_dev;
  26. static int m68kspkr_event(struct input_dev *dev, unsigned int type, unsigned int code, int value)
  27. {
  28. unsigned int count = 0;
  29. if (type != EV_SND)
  30. return -1;
  31. switch (code) {
  32. case SND_BELL: if (value) value = 1000;
  33. case SND_TONE: break;
  34. default: return -1;
  35. }
  36. if (value > 20 && value < 32767)
  37. count = 1193182 / value;
  38. mach_beep(count, -1);
  39. return 0;
  40. }
  41. static int __init m68kspkr_init(void)
  42. {
  43. if (!mach_beep){
  44. printk("%s: no lowlevel beep support\n", m68kspkr_name);
  45. return -1;
  46. }
  47. m68kspkr_dev.evbit[0] = BIT(EV_SND);
  48. m68kspkr_dev.sndbit[0] = BIT(SND_BELL) | BIT(SND_TONE);
  49. m68kspkr_dev.event = m68kspkr_event;
  50. m68kspkr_dev.name = m68kspkr_name;
  51. m68kspkr_dev.phys = m68kspkr_phys;
  52. m68kspkr_dev.id.bustype = BUS_HOST;
  53. m68kspkr_dev.id.vendor = 0x001f;
  54. m68kspkr_dev.id.product = 0x0001;
  55. m68kspkr_dev.id.version = 0x0100;
  56. input_register_device(&m68kspkr_dev);
  57. printk(KERN_INFO "input: %s\n", m68kspkr_name);
  58. return 0;
  59. }
  60. static void __exit m68kspkr_exit(void)
  61. {
  62. input_unregister_device(&m68kspkr_dev);
  63. }
  64. module_init(m68kspkr_init);
  65. module_exit(m68kspkr_exit);