usbhid.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #ifndef __USBHID_H
  2. #define __USBHID_H
  3. /*
  4. * Copyright (c) 1999 Andreas Gal
  5. * Copyright (c) 2000-2001 Vojtech Pavlik
  6. * Copyright (c) 2006 Jiri Kosina
  7. */
  8. /*
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  22. *
  23. */
  24. #include <linux/types.h>
  25. #include <linux/slab.h>
  26. #include <linux/list.h>
  27. #include <linux/mutex.h>
  28. #include <linux/timer.h>
  29. #include <linux/wait.h>
  30. #include <linux/workqueue.h>
  31. #include <linux/input.h>
  32. /* API provided by hid-core.c for USB HID drivers */
  33. void usbhid_close(struct hid_device *hid);
  34. int usbhid_open(struct hid_device *hid);
  35. void usbhid_init_reports(struct hid_device *hid);
  36. int usbhid_get_power(struct hid_device *hid);
  37. void usbhid_put_power(struct hid_device *hid);
  38. struct usb_interface *usbhid_find_interface(int minor);
  39. /* iofl flags */
  40. #define HID_CTRL_RUNNING 1
  41. #define HID_OUT_RUNNING 2
  42. #define HID_IN_RUNNING 3
  43. #define HID_RESET_PENDING 4
  44. #define HID_SUSPENDED 5
  45. #define HID_CLEAR_HALT 6
  46. #define HID_DISCONNECTED 7
  47. #define HID_STARTED 8
  48. #define HID_KEYS_PRESSED 10
  49. #define HID_NO_BANDWIDTH 11
  50. #define HID_RESUME_RUNNING 12
  51. /*
  52. * USB-specific HID struct, to be pointed to
  53. * from struct hid_device->driver_data
  54. */
  55. struct usbhid_device {
  56. struct hid_device *hid; /* pointer to corresponding HID dev */
  57. struct usb_interface *intf; /* USB interface */
  58. int ifnum; /* USB interface number */
  59. unsigned int bufsize; /* URB buffer size */
  60. struct urb *urbin; /* Input URB */
  61. char *inbuf; /* Input buffer */
  62. dma_addr_t inbuf_dma; /* Input buffer dma */
  63. struct urb *urbctrl; /* Control URB */
  64. struct usb_ctrlrequest *cr; /* Control request struct */
  65. struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */
  66. unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
  67. char *ctrlbuf; /* Control buffer */
  68. dma_addr_t ctrlbuf_dma; /* Control buffer dma */
  69. unsigned long last_ctrl; /* record of last output for timeouts */
  70. struct urb *urbout; /* Output URB */
  71. struct hid_output_fifo out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
  72. unsigned char outhead, outtail; /* Output pipe fifo head & tail */
  73. char *outbuf; /* Output buffer */
  74. dma_addr_t outbuf_dma; /* Output buffer dma */
  75. unsigned long last_out; /* record of last output for timeouts */
  76. spinlock_t lock; /* fifo spinlock */
  77. unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
  78. struct timer_list io_retry; /* Retry timer */
  79. unsigned long stop_retry; /* Time to give up, in jiffies */
  80. unsigned int retry_delay; /* Delay length in ms */
  81. struct work_struct reset_work; /* Task context for resets */
  82. wait_queue_head_t wait; /* For sleeping */
  83. };
  84. #define hid_to_usb_dev(hid_dev) \
  85. to_usb_device(hid_dev->dev.parent->parent)
  86. #endif