-
Notifications
You must be signed in to change notification settings - Fork 12
/
usb_cdc_proto.h
219 lines (195 loc) · 7.18 KB
/
usb_cdc_proto.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
/*
* usb_cdc_proto.h
*
* See USB Class Definitions for Communication Devices, Revision 1.1
*
* Copyright (C) 2019-2021 Sylvain Munaut <tnt@246tNt.com>
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#pragma once
#include <no2usb/usb_proto.h>
enum usb_cdc_subclass {
USB_CDC_SCLS_DLCM = 0x01, /* Direct Line Control Model */
USB_CDC_SCLS_ACM = 0x02, /* Abstract Control Model */
USB_CDC_SCLS_TCM = 0x03, /* Telephone Control Model */
USB_CDC_SCLS_MCCM = 0x04, /* Multi-Channel Control Model */
USB_CDC_SCLS_CCM = 0x05, /* CAPI Control Model */
USB_CDC_SCLS_ENCM = 0x06, /* Ethernet Networking Control Model */
USB_CDC_SCLS_ANCM = 0x07, /* ATM Networking Control Model */
};
enum usb_cdc_desc_subtype {
USB_CDC_DST_HEADER = 0x00,
USB_CDC_DST_CALL_MGMT = 0x01,
USB_CDC_DST_ACM = 0x02,
USB_CDC_DST_DLM = 0x03,
USB_CDC_DST_TEL_R = 0x04,
USB_CDC_DST_TEL_CAP = 0x05,
USB_CDC_DST_UNION = 0x06,
USB_CDC_DST_COUNTRY_SEL = 0x07,
USB_CDC_DST_TEL_OM = 0x08,
USB_CDC_DST_USB_TERM = 0x09,
USB_CDC_DST_NCT = 0x0A,
USB_CDC_DST_PU = 0x0B,
USB_CDC_DST_EU = 0x0C,
USB_CDC_DST_MCM = 0x0D,
USB_CDC_DST_CAPI = 0x0E,
USB_CDC_DST_ETH = 0x0F,
USB_CDC_DST_ATM = 0x10,
USB_CDC_DST_WHCM = 0x11,
USB_CDC_DST_MDLM = 0x12,
USB_CDC_DST_MDLM_DET = 0x13,
USB_CDC_DST_DMM = 0x14,
USB_CDC_DST_OBEX = 0x15,
USB_CDC_DST_CS = 0x16,
USB_CDC_DST_CS_DET = 0x17,
USB_CDC_DST_TEL_CM = 0x18,
USB_CDC_DST_OBEX_SI = 0x19,
USB_CDC_DST_NCM = 0x1A
};
struct usb_cdc_hdr_desc {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorsubtype;
uint16_t bcdCDC;
} __attribute__((packed));
struct usb_cdc_call_mgmt_desc {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorsubtype;
uint8_t bmCapabilities;
uint8_t bDataInterface;
} __attribute__((packed));
struct usb_cdc_acm_desc {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorsubtype;
uint8_t bmCapabilities;
} __attribute__((packed));
struct usb_cdc_dlm_desc {
uint8_t bLength;
uint8_t bDescriptorType;
uint8_t bDescriptorsubtype;
uint8_t bmCapabilities;
} __attribute__((packed));
#define usb_cdc_union_desc_def(n) \
struct usb_cdc_union_desc__ ## n { \
uint8_t bLength; \
uint8_t bDescriptorType; \
uint8_t bDescriptorsubtype; \
uint8_t bMasterInterface; \
uint8_t bSlaveInterface[n]; \
} __attribute__((packed))
usb_cdc_union_desc_def(0);
#define usb_cdc_union_desc usb_cdc_union_desc__0
#define usb_cdc_coutry_sel_desc_def(n) \
struct usb_cdc_country_sel_desc__ ## n { \
uint8_t bLength; \
uint8_t bDescriptorType; \
uint8_t bDescriptorsubtype; \
uint8_t iCountryCodeRelDate; \
uint16_t wCountryCode[n]; \
} __attribute__((packed))
/* Control requests */
#define USB_REQ_CDC_SEND_ENCAPSULATED_COMMAND 0x00
#define USB_REQ_CDC_GET_ENCAPSULATED_RESPONSE 0x01
#define USB_REQ_CDC_SET_COMM_FEATURE 0x02
#define USB_REQ_CDC_GET_COMM_FEATURE 0x03
#define USB_REQ_CDC_CLEAR_COMM_FEATURE 0x04
#define USB_REQ_CDC_SET_AUX_LINE_STATE 0x10
#define USB_REQ_CDC_SET_HOOK_STATE 0x11
#define USB_REQ_CDC_PULSE_SETUP 0x12
#define USB_REQ_CDC_SEND_PULSE 0x13
#define USB_REQ_CDC_SET_PULSE_TIME 0x14
#define USB_REQ_CDC_RING_AUX_JACK 0x15
#define USB_REQ_CDC_SET_LINE_CODING 0x20
#define USB_REQ_CDC_GET_LINE_CODING 0x21
#define USB_REQ_CDC_SET_CONTROL_LINE_STATE 0x22
#define USB_REQ_CDC_SEND_BREAK 0x23
#define USB_REQ_CDC_SET_RINGER_PARMS 0x30
#define USB_REQ_CDC_GET_RINGER_PARMS 0x31
#define USB_REQ_CDC_SET_OPERATION_PARMS 0x32
#define USB_REQ_CDC_GET_OPERATION_PARMS 0x33
#define USB_REQ_CDC_SET_LINE_PARMS 0x34
#define USB_REQ_CDC_GET_LINE_PARMS 0x35
#define USB_REQ_CDC_DIAL_DIGITS 0x36
#define USB_REQ_CDC_SET_UNIT_PARAMETER 0x37
#define USB_REQ_CDC_GET_UNIT_PARAMETER 0x38
#define USB_REQ_CDC_CLEAR_UNIT_PARAMETER 0x39
#define USB_REQ_CDC_GET_PROFILE 0x3A
#define USB_REQ_CDC_SET_ETH_MULTICAST_FILTERS 0x40
#define USB_REQ_CDC_SET_ETH_PWR_MGMT_PTRN_FLT 0x41
#define USB_REQ_CDC_GET_ETH_PWR_MGMT_PTRN_FLT 0x42
#define USB_REQ_CDC_SET_ETH_PACKET_FILTER 0x43
#define USB_REQ_CDC_GET_ETH_STATISTIC 0x44
#define USB_REQ_CDC_SET_ATM_DATA_FORMAT 0x50
#define USB_REQ_CDC_GET_ATM_DEVICE_STATISTICS 0x51
#define USB_REQ_CDC_SET_ATM_DEFAULT_VC 0x52
#define USB_REQ_CDC_GET_ATM_VC_STATISTICS 0x53
#define USB_RT_CDC_SEND_ENCAPSULATED_COMMAND ((0x00 << 8) | 0x21)
#define USB_RT_CDC_GET_ENCAPSULATED_RESPONSE ((0x01 << 8) | 0xa1)
#define USB_RT_CDC_SET_COMM_FEATURE ((0x02 << 8) | 0x21)
#define USB_RT_CDC_GET_COMM_FEATURE ((0x03 << 8) | 0xa1)
#define USB_RT_CDC_CLEAR_COMM_FEATURE ((0x04 << 8) | 0x21)
#define USB_RT_CDC_SET_AUX_LINE_STATE ((0x10 << 8) | 0x21)
#define USB_RT_CDC_SET_HOOK_STATE ((0x11 << 8) | 0x21)
#define USB_RT_CDC_PULSE_SETUP ((0x12 << 8) | 0x21)
#define USB_RT_CDC_SEND_PULSE ((0x13 << 8) | 0x21)
#define USB_RT_CDC_SET_PULSE_TIME ((0x14 << 8) | 0x21)
#define USB_RT_CDC_RING_AUX_JACK ((0x15 << 8) | 0x21)
#define USB_RT_CDC_SET_LINE_CODING ((0x20 << 8) | 0x21)
#define USB_RT_CDC_GET_LINE_CODING ((0x21 << 8) | 0xa1)
#define USB_RT_CDC_SET_CONTROL_LINE_STATE ((0x22 << 8) | 0x21)
#define USB_RT_CDC_SEND_BREAK ((0x23 << 8) | 0x21)
#define USB_RT_CDC_SET_RINGER_PARMS ((0x30 << 8) | 0x21)
#define USB_RT_CDC_GET_RINGER_PARMS ((0x31 << 8) | 0xa1)
#define USB_RT_CDC_SET_OPERATION_PARMS ((0x32 << 8) | 0x21)
#define USB_RT_CDC_GET_OPERATION_PARMS ((0x33 << 8) | 0xa1)
#define USB_RT_CDC_SET_LINE_PARMS ((0x34 << 8) | 0x21)
#define USB_RT_CDC_GET_LINE_PARMS ((0x35 << 8) | 0xa1)
#define USB_RT_CDC_DIAL_DIGITS ((0x36 << 8) | 0x21)
#define USB_RT_CDC_SET_UNIT_PARAMETER ((0x37 << 8) | 0x21)
#define USB_RT_CDC_GET_UNIT_PARAMETER ((0x38 << 8) | 0xa1)
#define USB_RT_CDC_CLEAR_UNIT_PARAMETER ((0x39 << 8) | 0x21)
#define USB_RT_CDC_GET_PROFILE ((0x3A << 8) | 0xa1)
#define USB_RT_CDC_SET_ETH_MULTICAST_FILTERS ((0x40 << 8) | 0x21)
#define USB_RT_CDC_SET_ETH_PWR_MGMT_PTRN_FLT ((0x41 << 8) | 0x21)
#define USB_RT_CDC_GET_ETH_PWR_MGMT_PTRN_FLT ((0x42 << 8) | 0xa1)
#define USB_RT_CDC_SET_ETH_PACKET_FILTER ((0x43 << 8) | 0x21)
#define USB_RT_CDC_GET_ETH_STATISTIC ((0x44 << 8) | 0xa1)
#define USB_RT_CDC_SET_ATM_DATA_FORMAT ((0x50 << 8) | 0x21)
#define USB_RT_CDC_GET_ATM_DEVICE_STATISTICS ((0x51 << 8) | 0xa1)
#define USB_RT_CDC_SET_ATM_DEFAULT_VC ((0x52 << 8) | 0x21)
#define USB_RT_CDC_GET_ATM_VC_STATISTICS ((0x53 << 8) | 0xa1)
/* Notifications */
#define USB_NOTIF_CDC_NETWORK_CONNECTION 0x00
#define USB_NOTIF_CDC_RESPONSE_AVAILABLE 0x01
#define USB_NOTIF_CDC_AUX_JACK_HOOK_STATE 0x08
#define USB_NOTIF_CDC_RING_DETECT 0x09
#define USB_NOTIF_CDC_SERIAL_STATE 0x20
#define USB_NOTIF_CDC_CALL_STATE_CHANGE 0x28
#define USB_NOTIF_CDC_LINE_STATE_CHANGE 0x29
#define USB_NOTIF_CDC_CONNECTION_SPEED_CHANGE 0x2A
/* Basically the same as usb_ctrl_req but without alignement requirements */
struct usb_cdc_notif_header {
union {
struct {
uint8_t bmRequestType;
uint8_t bRequest;
};
uint16_t wRequestAndType;
};
uint16_t wValue;
uint16_t wIndex;
uint16_t wLength;
} __attribute__((packed));
struct usb_cdc_notif_serial_state {
struct usb_cdc_notif_header hdr;
uint16_t bits;
} __attribute__((packed));
/* Argument Structures */
struct usb_cdc_line_coding {
uint32_t dwDTERate;
uint8_t bCharFormat;
uint8_t bParityType;
uint8_t bDataBits;
} __attribute__((packed));