cdc-acm.h 3.6 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 32
  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 accomodate 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. struct list_head list;
  61. int size;
  62. unsigned char *base;
  63. dma_addr_t dma;
  64. };
  65. struct acm_ru {
  66. struct list_head list;
  67. struct acm_rb *buffer;
  68. struct urb *urb;
  69. struct acm *instance;
  70. };
  71. struct acm {
  72. struct usb_device *dev; /* the corresponding usb device */
  73. struct usb_interface *control; /* control interface */
  74. struct usb_interface *data; /* data interface */
  75. struct tty_port port; /* our tty port data */
  76. struct urb *ctrlurb; /* urbs */
  77. u8 *ctrl_buffer; /* buffers of urbs */
  78. dma_addr_t ctrl_dma; /* dma handles of buffers */
  79. u8 *country_codes; /* country codes from device */
  80. unsigned int country_code_size; /* size of this buffer */
  81. unsigned int country_rel_date; /* release date of version */
  82. struct acm_wb wb[ACM_NW];
  83. struct acm_ru ru[ACM_NR];
  84. struct acm_rb rb[ACM_NR];
  85. int rx_buflimit;
  86. int rx_endpoint;
  87. spinlock_t read_lock;
  88. struct list_head spare_read_urbs;
  89. struct list_head spare_read_bufs;
  90. struct list_head filled_read_bufs;
  91. int write_used; /* number of non-empty write buffers */
  92. int processing;
  93. int transmitting;
  94. spinlock_t write_lock;
  95. struct mutex mutex;
  96. struct usb_cdc_line_coding line; /* bits, stop, parity */
  97. struct work_struct work; /* work queue entry for line discipline waking up */
  98. struct work_struct waker;
  99. wait_queue_head_t drain_wait; /* close processing */
  100. struct tasklet_struct urb_task; /* rx processing */
  101. spinlock_t throttle_lock; /* synchronize throtteling and read callback */
  102. unsigned int ctrlin; /* input control lines (DCD, DSR, RI, break, overruns) */
  103. unsigned int ctrlout; /* output control lines (DTR, RTS) */
  104. unsigned int writesize; /* max packet size for the output bulk endpoint */
  105. unsigned int readsize,ctrlsize; /* buffer sizes for freeing */
  106. unsigned int minor; /* acm minor number */
  107. unsigned char throttle; /* throttled by tty layer */
  108. unsigned char clocal; /* termios CLOCAL */
  109. unsigned int ctrl_caps; /* control capabilities from the class specific header */
  110. unsigned int susp_count; /* number of suspended interfaces */
  111. int combined_interfaces:1; /* control and data collapsed */
  112. struct acm_wb *delayed_wb; /* write queued for a device about to be woken */
  113. };
  114. #define CDC_DATA_INTERFACE_TYPE 0x0a
  115. /* constants describing various quirks and errors */
  116. #define NO_UNION_NORMAL 1
  117. #define SINGLE_RX_URB 2
  118. #define NO_CAP_LINE 4