xref: /haiku/headers/os/drivers/usb/USB_cdc.h (revision 2f470aec1c92ce6917b8a903e343795dc77af41f)
1 #ifndef USB_CDC_H
2 #define USB_CDC_H
3 
4 // (Partial) USB Class Definitions for Communication Devices (CDC), version 1.1
5 // Reference: http://www.usb.org/developers/devclass_docs/usbcdc11.pdf
6 
7 #define USB_COMMUNICATION_DEVICE_CLASS 			0x02
8 
9 #define USB_CDC_COMMUNICATION_INTERFACE_CLASS	0x02
10 #define USB_CDC_CLASS_VERSION					0x0101
11 
12 enum { // Communication Interface Subclasses
13 	USB_CDC_COMMUNICATION_INTERFACE_DLCM_SUBCLASS =	0x01,	// Direct Line Control Model
14 	USB_CDC_COMMUNICATION_INTERFACE_ACM_SUBCLASS,			// Abstract Control Model
15 	USB_CDC_COMMUNICATION_INTERFACE_TCM_SUBCLASS,			// Telephone Control Model
16 	USB_CDC_COMMUNICATION_INTERFACE_MCCM_SUBCLASS,			// Multi-Channel Control Model
17 	USB_CDC_COMMUNICATION_INTERFACE_CAPICM_SUBCLASS,    	// CAPI Control Model
18 	USB_CDC_COMMUNICATION_INTERFACE_ENCM_SUBCLASS,			// Ethernet Networking Control Model
19 	USB_CDC_COMMUNICATION_INTERFACE_ATMNCM_SUBCLASS			// ATM Networking Control Model
20 };
21 
22 enum { // Communication Interface Class Control Protocols
23 	USB_CDC_COMMUNICATION_INTERFACE_NONE_PROTOCOL = 0x00,		// No class specific protocol required
24 	USB_CDC_COMMUNICATION_INTERFACE_V25TER_PROTOCOL = 0x01,		// Common AT commands (also knowns as "Hayes compatible")
25 	USB_CDC_COMMUNICATION_INTERFACE_SPECIFIC_PROTOCOL = 0xff	// Vendor-specific protocol
26 };
27 
28 #define USB_CDC_DATA_INTERFACE_CLASS			0x0a
29 
30 enum { // Management Element Requests (p62)
31 	USB_CDC_SEND_ENCAPSULATED_COMMAND		= 0x00,
32 	USB_CDC_GET_ENCAPSULATED_RESPONSE,
33 	USB_CDC_SET_COMM_FEATURE,
34 	USB_CDC_GET_COMM_FEATURE,
35 	USB_CDC_CLEAR_COMM_FEATURE,
36 	// 0x05 -> 0x0F: reserved for future use
37 	USB_CDC_SET_AUX_LINE_STATE				= 0x10,
38 	USB_CDC_SET_HOOK_STATE,
39 	USB_CDC_PULSE_SETUP,
40 	USB_CDC_SEND_PULSE,
41 	USB_CDC_SET_PULSE_TIME,
42 	USB_CDC_RING_AUX_JACK,
43 	// 0x16 -> 0x1F: reserved for future use
44 	USB_CDC_SET_LINE_CODING					= 0x20,
45 	USB_CDC_GET_LINE_CODING,
46 	USB_CDC_SET_CONTROL_LINE_STATE,
47 	USB_CDC_SEND_BREAK,
48 	// 0x24 -> 0x2F: reserved for future use
49 	USB_CDC_SET_RINGER_PARMS				= 0x30,
50 	USB_CDC_GET_RINGER_PARMS,
51 	USB_CDC_SET_OPERATION_PARMS,
52 	USB_CDC_GET_OPERATION_PARMS,
53 	USB_CDC_SET_LINE_PARMS,
54 	USB_CDC_GET_LINE_PARMS,
55 	USB_CDC_DIAL_DIGITS,
56 	USB_CDC_SET_UNIT_PARAMETER,
57 	USB_CDC_GET_UNIT_PARAMETER,
58 	USB_CDC_CLEAR_UNIT_PARAMETER,
59 	USB_CDC_GET_PROFILE,
60 	// 0x3B -> 0x3F: reserved for future use
61 	USB_CDC_SET_ETHERNET_MULTICAST_FILTERS	= 0x40,
62 	USB_CDC_SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER,
63 	USB_CDC_GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER,
64 	USB_CDC_SET_ETHERNET_PACKET_FILTER,
65 	USB_CDC_GET_ETHERNET_STATISTIC,
66 	// 0x45 -> 0x4F: reserved for future use
67 	USB_CDC_SET_ATM_DATA_FORMAT				= 0x50,
68 	USB_CDC_GET_ATM_DEVICE_STATISTICS,
69 	USB_CDC_SET_ATM_DEFAULT_VC,
70 	USB_CDC_GET_ATM_VC_STATISTICS
71 	// 0x54 -> 0xFF: reserved for future use
72 };
73 
74 enum { // Feature Selector (for USB_CDC_SET/GET/CLEAR_COMM_FEATURE (p65-66))
75 	USB_CDC_ABSTRACT_STATE	= 0x01,
76 	USB_CDC_COUNTRY_SETTING	= 0x02
77 };
78 
79 enum { // ABSTRACT_STATE bitmap (for USB_CDC_ABSTRAT_STATE Feature Selector (p66))
80 	USB_CDC_ABSTRACT_STATE_IDLE				= 0x01,
81 	USB_CDC_ABSTRACT_STATE_DATA_MULTIPLEXED = 0x02
82 };
83 
84 typedef struct {	// Line Coding Structure (for USB_CDC_SET/GET_LINE_CODING (p69))
85 	uint32 	speed;
86 	uint8 	stopbits;
87 	uint8 	parity;
88 	uint8 	databits;
89 } _PACKED usb_cdc_line_coding;
90 
91 enum { // CDC stopbits values (for Line Coding Structure stopbits field)
92 	USB_CDC_1_STOPBIT	= 0,
93 	USB_CDC_1_5_STOPBITS,
94 	USB_CDC_2_STOPBITS
95 };
96 
97 enum { // CDC parity values (for Line Coding Structure parity field)
98 	USB_CDC_NO_PARITY	= 0,
99 	USB_CDC_ODD_PARITY,
100 	USB_CDC_EVEN_PARITY,
101 	USB_CDC_MARK_PARITY,
102 	USB_CDC_SPACE_PARITY
103 };
104 
105 enum { // CDC Control Signal bitmap (for CDC_SET_CONTROL_LINE_STATE request)
106 	USB_CDC_CONTROL_SIGNAL_STATE_DTR		= 0x01,
107 	USB_CDC_CONTROL_SIGNAL_STATE_RTS		= 0x02
108 };
109 
110 enum {	// Notification Elements notifications (p84)
111 	USB_CDC_NETWORK_CONNECTION					= 0x00,
112 	USB_CDC_RESPONSE_AVAILABLE,
113 	// 0x02 -> 0x07: reserved for future use
114 	USB_CDC_AUX_JACK_HOOK_STATE					= 0x08,
115 	USB_CDC_RING_DETECT,
116 	// 0x0a -> 0x1f: reserved for future use
117 	USB_CDC_SERIAL_STATE						= 0x20,
118 	// 0x21 -> 0x27: reserved for future use
119 	USB_CDC_CALL_STATE_CHANGE					= 0x28,
120 	USB_CDC_LINE_STATE_CHANGE,
121 	USB_CDC_CONNECTION_SPEED_CHANGE
122 	// 0x2b -> 0xff: reserved for future use
123 };
124 
125 enum { // CDC UART State bitmap (for USB_CDC_SERIAL_STATE notification)
126 	USB_CDC_UART_STATE_DCD				= 0x01,
127 	USB_CDC_UART_STATE_DSR				= 0x02,
128 	USB_CDC_UART_STATE_BREAK			= 0x04,
129 	USB_CDC_UART_STATE_RING				= 0x08,
130 	USB_CDC_UART_STATE_FRAMING_ERROR	= 0x10,
131 	USB_CDC_UART_STATE_PARITY_ERROR		= 0x20,
132 	USB_CDC_UART_STATE_OVERRUN_ERROR	= 0x40
133 };
134 
135 #endif	// USB_CDC_H
136 
137