usbhid.h 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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/timer.h>
  28. #include <linux/wait.h>
  29. #include <linux/workqueue.h>
  30. #include <linux/input.h>
  31. /* API provided by hid-core.c for USB HID drivers */
  32. int usbhid_wait_io(struct hid_device* hid);
  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. void usbhid_submit_report(struct hid_device *hid, struct hid_report *report, unsigned char dir);
  37. /*
  38. * USB-specific HID struct, to be pointed to
  39. * from struct hid_device->driver_data
  40. */
  41. struct usbhid_device {
  42. struct hid_device *hid; /* pointer to corresponding HID dev */
  43. struct usb_interface *intf; /* USB interface */
  44. int ifnum; /* USB interface number */
  45. unsigned int bufsize; /* URB buffer size */
  46. struct urb *urbin; /* Input URB */
  47. char *inbuf; /* Input buffer */
  48. dma_addr_t inbuf_dma; /* Input buffer dma */
  49. spinlock_t inlock; /* Input fifo spinlock */
  50. struct urb *urbctrl; /* Control URB */
  51. struct usb_ctrlrequest *cr; /* Control request struct */
  52. dma_addr_t cr_dma; /* Control request struct dma */
  53. struct hid_control_fifo ctrl[HID_CONTROL_FIFO_SIZE]; /* Control fifo */
  54. unsigned char ctrlhead, ctrltail; /* Control fifo head & tail */
  55. char *ctrlbuf; /* Control buffer */
  56. dma_addr_t ctrlbuf_dma; /* Control buffer dma */
  57. spinlock_t ctrllock; /* Control fifo spinlock */
  58. struct urb *urbout; /* Output URB */
  59. struct hid_report *out[HID_CONTROL_FIFO_SIZE]; /* Output pipe fifo */
  60. unsigned char outhead, outtail; /* Output pipe fifo head & tail */
  61. char *outbuf; /* Output buffer */
  62. dma_addr_t outbuf_dma; /* Output buffer dma */
  63. spinlock_t outlock; /* Output fifo spinlock */
  64. unsigned long iofl; /* I/O flags (CTRL_RUNNING, OUT_RUNNING) */
  65. struct timer_list io_retry; /* Retry timer */
  66. unsigned long stop_retry; /* Time to give up, in jiffies */
  67. unsigned int retry_delay; /* Delay length in ms */
  68. struct work_struct reset_work; /* Task context for resets */
  69. wait_queue_head_t wait; /* For sleeping */
  70. };
  71. #define hid_to_usb_dev(hid_dev) \
  72. container_of(hid_dev->dev->parent, struct usb_device, dev)
  73. #endif