hid-sunplus.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * HID driver for some sunplus "special" devices
  3. *
  4. * Copyright (c) 1999 Andreas Gal
  5. * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
  6. * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
  7. * Copyright (c) 2006-2007 Jiri Kosina
  8. * Copyright (c) 2007 Paul Walmsley
  9. * Copyright (c) 2008 Jiri Slaby
  10. */
  11. /*
  12. * This program is free software; you can redistribute it and/or modify it
  13. * under the terms of the GNU General Public License as published by the Free
  14. * Software Foundation; either version 2 of the License, or (at your option)
  15. * any later version.
  16. */
  17. #include <linux/device.h>
  18. #include <linux/hid.h>
  19. #include <linux/module.h>
  20. #include "hid-ids.h"
  21. static __u8 *sp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  22. unsigned int *rsize)
  23. {
  24. if (*rsize >= 107 && rdesc[104] == 0x26 && rdesc[105] == 0x80 &&
  25. rdesc[106] == 0x03) {
  26. hid_info(hdev, "fixing up Sunplus Wireless Desktop report descriptor\n");
  27. rdesc[105] = rdesc[110] = 0x03;
  28. rdesc[106] = rdesc[111] = 0x21;
  29. }
  30. return rdesc;
  31. }
  32. #define sp_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
  33. EV_KEY, (c))
  34. static int sp_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  35. struct hid_field *field, struct hid_usage *usage,
  36. unsigned long **bit, int *max)
  37. {
  38. if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
  39. return 0;
  40. switch (usage->hid & HID_USAGE) {
  41. case 0x2003: sp_map_key_clear(KEY_ZOOMIN); break;
  42. case 0x2103: sp_map_key_clear(KEY_ZOOMOUT); break;
  43. default:
  44. return 0;
  45. }
  46. return 1;
  47. }
  48. static const struct hid_device_id sp_devices[] = {
  49. { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
  50. { }
  51. };
  52. MODULE_DEVICE_TABLE(hid, sp_devices);
  53. static struct hid_driver sp_driver = {
  54. .name = "sunplus",
  55. .id_table = sp_devices,
  56. .report_fixup = sp_report_fixup,
  57. .input_mapping = sp_input_mapping,
  58. };
  59. static int __init sp_init(void)
  60. {
  61. return hid_register_driver(&sp_driver);
  62. }
  63. static void __exit sp_exit(void)
  64. {
  65. hid_unregister_driver(&sp_driver);
  66. }
  67. module_init(sp_init);
  68. module_exit(sp_exit);
  69. MODULE_LICENSE("GPL");