cdc-acm.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. *
  3. * Includes for cdc-acm.c
  4. *
  5. * Mainly take from usbnet's cdc-ether part
  6. *
  7. */
  8. /*
  9. * CMSPAR, some architectures can't have space and mark parity.
  10. */
  11. #ifndef CMSPAR
  12. #define CMSPAR 0
  13. #endif
  14. /*
  15. * Major and minor numbers.
  16. */
  17. #define ACM_TTY_MAJOR 166
  18. #define ACM_TTY_MINORS 256
  19. /*
  20. * Requests.
  21. */
  22. #define USB_RT_ACM (USB_TYPE_CLASS | USB_RECIP_INTERFACE)
  23. /*
  24. * Output control lines.
  25. */
  26. #define ACM_CTRL_DTR 0x01
  27. #define ACM_CTRL_RTS 0x02
  28. /*
  29. * Input control lines and line errors.
  30. */
  31. #define ACM_CTRL_DCD 0x01
  32. #define ACM_CTRL_DSR 0x02
  33. #define ACM_CTRL_BRK 0x04
  34. #define ACM_CTRL_RI 0x08
  35. #define ACM_CTRL_FRAMING 0x10
  36. #define ACM_CTRL_PARITY 0x20
  37. #define ACM_CTRL_OVERRUN 0x40
  38. /*
  39. * Internal driver structures.
  40. */
  41. /*
  42. * The only reason to have several buffers is to accommodate assumptions
  43. * in line disciplines. They ask for empty space amount, receive our URB size,
  44. * and proceed to issue several 1-character writes, assuming they will fit.
  45. * The very first write takes a complete URB. Fortunately, this only happens
  46. * when processing onlcr, so we only need 2 buffers. These values must be
  47. * powers of 2.
  48. */
  49. #define ACM_NW 16
  50. #define ACM_NR 16
  51. struct acm_wb {
  52. unsigned char *buf;
  53. dma_addr_t dmah;
  54. int len;
  55. int use;
  56. struct urb *urb;
  57. struct acm *instance;
  58. };
  59. struct acm_rb {
  60. int size;
  61. unsigned char *base;
  62. dma_addr_t dma;
  63. int index;
  64. struct acm *instance;
  65. };
  66. struct acm {
  67. struct usb_device *dev; /* the corresponding usb device */
  68. struct usb_interface *control; /* control interface */
  69. struct usb_interface *data; /* data interface */
  70. struct tty_port port; /* our tty port data */
  71. struct urb *ctrlurb; /* urbs */
  72. u8 *ctrl_buffer; /* buffers of urbs */
  73. dma_addr_t ctrl_dma; /* dma handles of buffers */
  74. u8 *country_codes; /* country codes from device */
  75. unsigned int country_code_size; /* size of this buffer */
  76. unsigned int country_rel_date; /* release date of version */
  77. struct acm_wb wb[ACM_NW];
  78. unsigned long read_urbs_free;
  79. struct urb *read_urbs[ACM_NR];
  80. struct acm_rb read_buffers[ACM_NR];
  81. int rx_buflimit;
  82. spinlock_t read_lock;
  83. int write_used; /* number of non-empty write buffers */
  84. int transmitting;
  85. spinlock_t write_lock;
  86. struct mutex mutex;
  87. bool disconnected;
  88. struct usb_cdc_line_coding line; /* bits, stop, parity */
  89. struct work_struct work; /* work queue entry for line discipline waking up */
  90. unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
  91. unsigned int ctrlout; /* output control lines (DTR, RTS) */
  92. struct async_icount iocount; /* counters for control line changes */
  93. struct async_icount oldcount; /* for comparison of counter */
  94. wait_queue_head_t wioctl; /* for ioctl */
  95. unsigned int writesize; /* max packet size for the output bulk endpoint */
  96. unsigned int readsize,ctrlsize; /* buffer sizes for freeing */
  97. unsigned int minor; /* acm minor number */
  98. unsigned char clocal; /* termios CLOCAL */
  99. unsigned int ctrl_caps; /* control capabilities from the class specific header */
  100. unsigned int susp_count; /* number of suspended interfaces */
  101. unsigned int combined_interfaces:1; /* control and data collapsed */
  102. unsigned int is_int_ep:1; /* interrupt endpoints contrary to spec used */
  103. unsigned int throttled:1; /* actually throttled */
  104. unsigned int throttle_req:1; /* throttle requested */
  105. u8 bInterval;
  106. struct usb_anchor delayed; /* writes queued for a device about to be woken */
  107. unsigned long quirks;
  108. };
  109. #define CDC_DATA_INTERFACE_TYPE 0x0a
  110. /* constants describing various quirks and errors */
  111. #define NO_UNION_NORMAL BIT(0)
  112. #define SINGLE_RX_URB BIT(1)
  113. #define NO_CAP_LINE BIT(2)
  114. #define NO_DATA_INTERFACE BIT(4)
  115. #define IGNORE_DEVICE BIT(5)
  116. #define QUIRK_CONTROL_LINE_STATE BIT(6)
  117. #define CLEAR_HALT_CONDITIONS BIT(7)
  118. #define SEND_ZERO_PACKET BIT(8)
  119. #define DISABLE_ECHO BIT(9)