hid-sunplus.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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) 2008 Jiri Slaby
  9. */
  10. /*
  11. * This program is free software; you can redistribute it and/or modify it
  12. * under the terms of the GNU General Public License as published by the Free
  13. * Software Foundation; either version 2 of the License, or (at your option)
  14. * any later version.
  15. */
  16. #include <linux/device.h>
  17. #include <linux/hid.h>
  18. #include <linux/module.h>
  19. #include "hid-ids.h"
  20. static __u8 *sp_report_fixup(struct hid_device *hdev, __u8 *rdesc,
  21. unsigned int *rsize)
  22. {
  23. if (*rsize >= 112 && rdesc[104] == 0x26 && rdesc[105] == 0x80 &&
  24. rdesc[106] == 0x03) {
  25. hid_info(hdev, "fixing up Sunplus Wireless Desktop report descriptor\n");
  26. rdesc[105] = rdesc[110] = 0x03;
  27. rdesc[106] = rdesc[111] = 0x21;
  28. }
  29. return rdesc;
  30. }
  31. #define sp_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
  32. EV_KEY, (c))
  33. static int sp_input_mapping(struct hid_device *hdev, struct hid_input *hi,
  34. struct hid_field *field, struct hid_usage *usage,
  35. unsigned long **bit, int *max)
  36. {
  37. if ((usage->hid & HID_USAGE_PAGE) != HID_UP_CONSUMER)
  38. return 0;
  39. switch (usage->hid & HID_USAGE) {
  40. case 0x2003: sp_map_key_clear(KEY_ZOOMIN); break;
  41. case 0x2103: sp_map_key_clear(KEY_ZOOMOUT); break;
  42. default:
  43. return 0;
  44. }
  45. return 1;
  46. }
  47. static const struct hid_device_id sp_devices[] = {
  48. { HID_USB_DEVICE(USB_VENDOR_ID_SUNPLUS, USB_DEVICE_ID_SUNPLUS_WDESKTOP) },
  49. { }
  50. };
  51. MODULE_DEVICE_TABLE(hid, sp_devices);
  52. static struct hid_driver sp_driver = {
  53. .name = "sunplus",
  54. .id_table = sp_devices,
  55. .report_fixup = sp_report_fixup,
  56. .input_mapping = sp_input_mapping,
  57. };
  58. module_hid_driver(sp_driver);
  59. MODULE_LICENSE("GPL");