hci_usb.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. HCI USB driver for Linux Bluetooth protocol stack (BlueZ)
  3. Copyright (C) 2000-2001 Qualcomm Incorporated
  4. Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
  5. Copyright (C) 2003 Maxim Krasnyansky <maxk@qualcomm.com>
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License version 2 as
  8. published by the Free Software Foundation;
  9. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  10. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  11. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
  12. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
  13. CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
  14. WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
  18. COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
  19. SOFTWARE IS DISCLAIMED.
  20. */
  21. /* Class, SubClass, and Protocol codes that describe a Bluetooth device */
  22. #define HCI_DEV_CLASS 0xe0 /* Wireless class */
  23. #define HCI_DEV_SUBCLASS 0x01 /* RF subclass */
  24. #define HCI_DEV_PROTOCOL 0x01 /* Bluetooth programming protocol */
  25. #define HCI_IGNORE 0x01
  26. #define HCI_RESET 0x02
  27. #define HCI_DIGIANSWER 0x04
  28. #define HCI_CSR 0x08
  29. #define HCI_SNIFFER 0x10
  30. #define HCI_BCM92035 0x20
  31. #define HCI_BROKEN_ISOC 0x40
  32. #define HCI_WRONG_SCO_MTU 0x80
  33. #define HCI_MAX_IFACE_NUM 3
  34. #define HCI_MAX_BULK_TX 4
  35. #define HCI_MAX_BULK_RX 1
  36. #define HCI_MAX_ISOC_RX 2
  37. #define HCI_MAX_ISOC_TX 2
  38. #define HCI_MAX_ISOC_FRAMES 10
  39. struct _urb_queue {
  40. struct list_head head;
  41. spinlock_t lock;
  42. };
  43. struct _urb {
  44. struct list_head list;
  45. struct _urb_queue *queue;
  46. int type;
  47. void *priv;
  48. struct urb urb;
  49. };
  50. static inline void _urb_free(struct _urb *_urb)
  51. {
  52. kfree(_urb);
  53. }
  54. static inline void _urb_queue_init(struct _urb_queue *q)
  55. {
  56. INIT_LIST_HEAD(&q->head);
  57. spin_lock_init(&q->lock);
  58. }
  59. static inline void _urb_queue_head(struct _urb_queue *q, struct _urb *_urb)
  60. {
  61. unsigned long flags;
  62. spin_lock_irqsave(&q->lock, flags);
  63. list_add(&_urb->list, &q->head); _urb->queue = q;
  64. spin_unlock_irqrestore(&q->lock, flags);
  65. }
  66. static inline void _urb_queue_tail(struct _urb_queue *q, struct _urb *_urb)
  67. {
  68. unsigned long flags;
  69. spin_lock_irqsave(&q->lock, flags);
  70. list_add_tail(&_urb->list, &q->head); _urb->queue = q;
  71. spin_unlock_irqrestore(&q->lock, flags);
  72. }
  73. static inline void _urb_unlink(struct _urb *_urb)
  74. {
  75. struct _urb_queue *q = _urb->queue;
  76. unsigned long flags;
  77. if (q) {
  78. spin_lock_irqsave(&q->lock, flags);
  79. list_del(&_urb->list); _urb->queue = NULL;
  80. spin_unlock_irqrestore(&q->lock, flags);
  81. }
  82. }
  83. struct hci_usb {
  84. struct hci_dev *hdev;
  85. unsigned long state;
  86. struct usb_device *udev;
  87. struct usb_host_endpoint *bulk_in_ep;
  88. struct usb_host_endpoint *bulk_out_ep;
  89. struct usb_host_endpoint *intr_in_ep;
  90. struct usb_interface *isoc_iface;
  91. struct usb_host_endpoint *isoc_out_ep;
  92. struct usb_host_endpoint *isoc_in_ep;
  93. __u8 ctrl_req;
  94. struct sk_buff_head transmit_q[4];
  95. struct sk_buff *reassembly[4]; /* Reassembly buffers */
  96. rwlock_t completion_lock;
  97. atomic_t pending_tx[4]; /* Number of pending requests */
  98. struct _urb_queue pending_q[4]; /* Pending requests */
  99. struct _urb_queue completed_q[4]; /* Completed requests */
  100. };
  101. /* States */
  102. #define HCI_USB_TX_PROCESS 1
  103. #define HCI_USB_TX_WAKEUP 2