Cosmetic cleanups.
[dragonfly.git] / sys / bus / usb / usbcdc.h
1 /*
2  * $NetBSD: usbcdc.h,v 1.6 2000/04/27 15:26:50 augustss Exp $
3  * $FreeBSD: src/sys/dev/usb/usbcdc.h,v 1.10 2003/01/09 04:24:28 imp Exp $
4  * $DragonFly: src/sys/bus/usb/usbcdc.h,v 1.3 2003/12/30 01:01:44 dillon Exp $
5  */
6
7 /*
8  * Copyright (c) 1998 The NetBSD Foundation, Inc.
9  * All rights reserved.
10  *
11  * This code is derived from software contributed to The NetBSD Foundation
12  * by Lennart Augustsson (lennart@augustsson.net) at
13  * Carlstedt Research & Technology.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  *    notice, this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must reproduce the above copyright
21  *    notice, this list of conditions and the following disclaimer in the
22  *    documentation and/or other materials provided with the distribution.
23  * 3. All advertising materials mentioning features or use of this software
24  *    must display the following acknowledgement:
25  *        This product includes software developed by the NetBSD
26  *        Foundation, Inc. and its contributors.
27  * 4. Neither the name of The NetBSD Foundation nor the names of its
28  *    contributors may be used to endorse or promote products derived
29  *    from this software without specific prior written permission.
30  *
31  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
32  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
33  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
34  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
35  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
36  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
37  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
38  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
39  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGE.
42  */
43
44 #ifndef _USBCDC_H_
45 #define _USBCDC_H_
46
47 #define UDESCSUB_CDC_HEADER     0
48 #define UDESCSUB_CDC_CM         1 /* Call Management */
49 #define UDESCSUB_CDC_ACM        2 /* Abstract Control Model */
50 #define UDESCSUB_CDC_DLM        3 /* Direct Line Management */
51 #define UDESCSUB_CDC_TRF        4 /* Telephone Ringer */
52 #define UDESCSUB_CDC_TCLSR      5 /* Telephone Call ... */
53 #define UDESCSUB_CDC_UNION      6
54 #define UDESCSUB_CDC_CS         7 /* Country Selection */
55 #define UDESCSUB_CDC_TOM        8 /* Telephone Operational Modes */
56 #define UDESCSUB_CDC_USBT       9 /* USB Terminal */
57
58 typedef struct {
59         uByte           bLength;
60         uByte           bDescriptorType;
61         uByte           bDescriptorSubtype;
62         uWord           bcdCDC;
63 } usb_cdc_header_descriptor_t;
64
65 typedef struct {
66         uByte           bLength;
67         uByte           bDescriptorType;
68         uByte           bDescriptorSubtype;
69         uByte           bmCapabilities;
70 #define USB_CDC_CM_DOES_CM              0x01
71 #define USB_CDC_CM_OVER_DATA            0x02
72         uByte           bDataInterface;
73 } usb_cdc_cm_descriptor_t;
74
75 typedef struct {
76         uByte           bLength;
77         uByte           bDescriptorType;
78         uByte           bDescriptorSubtype;
79         uByte           bmCapabilities;
80 #define USB_CDC_ACM_HAS_FEATURE         0x01
81 #define USB_CDC_ACM_HAS_LINE            0x02
82 #define USB_CDC_ACM_HAS_BREAK           0x04
83 #define USB_CDC_ACM_HAS_NETWORK_CONN    0x08
84 } usb_cdc_acm_descriptor_t;
85
86 typedef struct {
87         uByte           bLength;
88         uByte           bDescriptorType;
89         uByte           bDescriptorSubtype;
90         uByte           bMasterInterface;
91         uByte           bSlaveInterface[1];
92 } usb_cdc_union_descriptor_t;
93
94 #define UCDC_SEND_ENCAPSULATED_COMMAND  0x00
95 #define UCDC_GET_ENCAPSULATED_RESPONSE  0x01
96 #define UCDC_SET_COMM_FEATURE           0x02
97 #define UCDC_GET_COMM_FEATURE           0x03
98 #define  UCDC_ABSTRACT_STATE            0x01
99 #define  UCDC_COUNTRY_SETTING           0x02
100 #define UCDC_CLEAR_COMM_FEATURE         0x04
101 #define UCDC_SET_LINE_CODING            0x20
102 #define UCDC_GET_LINE_CODING            0x21
103 #define UCDC_SET_CONTROL_LINE_STATE     0x22
104 #define  UCDC_LINE_DTR                  0x0001
105 #define  UCDC_LINE_RTS                  0x0002
106 #define UCDC_SEND_BREAK                 0x23
107 #define  UCDC_BREAK_ON                  0xffff
108 #define  UCDC_BREAK_OFF                 0x0000
109
110 typedef struct {
111         uWord   wState;
112 #define UCDC_IDLE_SETTING               0x0001
113 #define UCDC_DATA_MULTIPLEXED           0x0002
114 } usb_cdc_abstract_state_t;
115 #define UCDC_ABSTRACT_STATE_LENGTH 2
116
117 typedef struct {
118         uDWord  dwDTERate;
119         uByte   bCharFormat;
120 #define UCDC_STOP_BIT_1                 0
121 #define UCDC_STOP_BIT_1_5               1
122 #define UCDC_STOP_BIT_2                 2
123         uByte   bParityType;
124 #define UCDC_PARITY_NONE                0
125 #define UCDC_PARITY_ODD                 1
126 #define UCDC_PARITY_EVEN                2
127 #define UCDC_PARITY_MARK                3
128 #define UCDC_PARITY_SPACE               4
129         uByte   bDataBits;
130 } usb_cdc_line_state_t;
131 #define UCDC_LINE_STATE_LENGTH 7
132
133 typedef struct {
134         uByte   bmRequestType;
135 #define UCDC_NOTIFICATION               0xa1
136         uByte   bNotification;
137 #define UCDC_N_NETWORK_CONNECTION       0x00
138 #define UCDC_N_RESPONSE_AVAILABLE       0x01
139 #define UCDC_N_AUX_JACK_HOOK_STATE      0x08
140 #define UCDC_N_RING_DETECT              0x09
141 #define UCDC_N_SERIAL_STATE             0x20
142 #define UCDC_N_CALL_STATE_CHANGED       0x28
143 #define UCDC_N_LINE_STATE_CHANGED       0x29
144 #define UCDC_N_CONNECTION_SPEED_CHANGE  0x2a
145         uWord   wValue;
146         uWord   wIndex;
147         uWord   wLength;
148         uByte   data[16];
149 } usb_cdc_notification_t;
150 #define UCDC_NOTIFICATION_LENGTH 8
151
152 /*
153  * Bits set in the SERIAL STATE notifcation (first byte of data)
154  */
155
156 #define UCDC_N_SERIAL_OVERRUN           0x40
157 #define UCDC_N_SERIAL_PARITY            0x20
158 #define UCDC_N_SERIAL_FRAMING           0x10
159 #define UCDC_N_SERIAL_RI                0x08
160 #define UCDC_N_SERIAL_BREAK             0x04
161 #define UCDC_N_SERIAL_DSR               0x02
162 #define UCDC_N_SERIAL_DCD               0x01
163
164 /* Serial state bit masks */
165 #define UCDC_MDM_RXCARRIER      0x01
166 #define UCDC_MDM_TXCARRIER      0x02
167 #define UCDC_MDM_BREAK          0x04
168 #define UCDC_MDM_RING           0x08
169 #define UCDC_MDM_FRAMING_ERR    0x10
170 #define UCDC_MDM_PARITY_ERR     0x20
171 #define UCDC_MDM_OVERRUN_ERR    0x40
172
173 #endif /* _USBCDC_H_ */