1 /******************************************************************************
2  *
3  *  Copyright 1999-2014 Broadcom Corporation
4  *
5  *  Licensed under the Apache License, Version 2.0 (the "License");
6  *  you may not use this file except in compliance with the License.
7  *  You may obtain a copy of the License at:
8  *
9  *  http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *  Unless required by applicable law or agreed to in writing, software
12  *  distributed under the License is distributed on an "AS IS" BASIS,
13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *  See the License for the specific language governing permissions and
15  *  limitations under the License.
16  *
17  ******************************************************************************/
18 
19 #ifndef HCIDEFS_H
20 #define HCIDEFS_H
21 
22 #define HCI_PROTO_VERSION 0x01     /* Version for BT spec 1.1          */
23 #define HCI_PROTO_VERSION_1_2 0x02 /* Version for BT spec 1.2          */
24 #define HCI_PROTO_VERSION_2_0 0x03 /* Version for BT spec 2.0          */
25 #define HCI_PROTO_VERSION_2_1 0x04 /* Version for BT spec 2.1 [Lisbon] */
26 #define HCI_PROTO_VERSION_3_0 0x05 /* Version for BT spec 3.0          */
27 #define HCI_PROTO_VERSION_4_0 0x06 /* Version for BT spec 4.0 [LE]     */
28 #define HCI_PROTO_VERSION_4_1 0x07 /* Version for BT spec 4.1          */
29 #define HCI_PROTO_VERSION_4_2 0x08 /* Version for BT spec 4.2          */
30 #define HCI_PROTO_VERSION_5_0 0x09 /* Version for BT spec 5.0          */
31 
32 /*
33  *  Definitions for HCI groups
34 */
35 #define HCI_GRP_LINK_CONTROL_CMDS (0x01 << 10)       /* 0x0400 */
36 #define HCI_GRP_LINK_POLICY_CMDS (0x02 << 10)        /* 0x0800 */
37 #define HCI_GRP_HOST_CONT_BASEBAND_CMDS (0x03 << 10) /* 0x0C00 */
38 #define HCI_GRP_INFORMATIONAL_PARAMS (0x04 << 10)    /* 0x1000 */
39 #define HCI_GRP_STATUS_PARAMS (0x05 << 10)           /* 0x1400 */
40 #define HCI_GRP_TESTING_CMDS (0x06 << 10)            /* 0x1800 */
41 #define HCI_GRP_BLE_CMDS (0x08 << 10)               /* 0x2000 (LE Commands) */
42 
43 #define HCI_GRP_VENDOR_SPECIFIC (0x3F << 10) /* 0xFC00 */
44 
45 /* Group occupies high 6 bits of the HCI command rest is opcode itself */
46 #define HCI_OGF(p) (uint8_t)((0xFC00 & (p)) >> 10)
47 #define HCI_OCF(p) (0x3FF & (p))
48 
49 /*
50  *  Definitions for Link Control Commands
51 */
52 /* Following opcode is used only in command complete event for flow control */
53 #define HCI_COMMAND_NONE 0x0000
54 
55 /* Commands of HCI_GRP_LINK_CONTROL_CMDS group */
56 #define HCI_INQUIRY (0x0001 | HCI_GRP_LINK_CONTROL_CMDS)
57 #define HCI_INQUIRY_CANCEL (0x0002 | HCI_GRP_LINK_CONTROL_CMDS)
58 #define HCI_PERIODIC_INQUIRY_MODE (0x0003 | HCI_GRP_LINK_CONTROL_CMDS)
59 #define HCI_EXIT_PERIODIC_INQUIRY_MODE (0x0004 | HCI_GRP_LINK_CONTROL_CMDS)
60 #define HCI_CREATE_CONNECTION (0x0005 | HCI_GRP_LINK_CONTROL_CMDS)
61 #define HCI_DISCONNECT (0x0006 | HCI_GRP_LINK_CONTROL_CMDS)
62 #define HCI_ADD_SCO_CONNECTION (0x0007 | HCI_GRP_LINK_CONTROL_CMDS)
63 #define HCI_CREATE_CONNECTION_CANCEL (0x0008 | HCI_GRP_LINK_CONTROL_CMDS)
64 #define HCI_ACCEPT_CONNECTION_REQUEST (0x0009 | HCI_GRP_LINK_CONTROL_CMDS)
65 #define HCI_REJECT_CONNECTION_REQUEST (0x000A | HCI_GRP_LINK_CONTROL_CMDS)
66 #define HCI_LINK_KEY_REQUEST_REPLY (0x000B | HCI_GRP_LINK_CONTROL_CMDS)
67 #define HCI_LINK_KEY_REQUEST_NEG_REPLY (0x000C | HCI_GRP_LINK_CONTROL_CMDS)
68 #define HCI_PIN_CODE_REQUEST_REPLY (0x000D | HCI_GRP_LINK_CONTROL_CMDS)
69 #define HCI_PIN_CODE_REQUEST_NEG_REPLY (0x000E | HCI_GRP_LINK_CONTROL_CMDS)
70 #define HCI_CHANGE_CONN_PACKET_TYPE (0x000F | HCI_GRP_LINK_CONTROL_CMDS)
71 #define HCI_AUTHENTICATION_REQUESTED (0x0011 | HCI_GRP_LINK_CONTROL_CMDS)
72 #define HCI_SET_CONN_ENCRYPTION (0x0013 | HCI_GRP_LINK_CONTROL_CMDS)
73 #define HCI_CHANGE_CONN_LINK_KEY (0x0015 | HCI_GRP_LINK_CONTROL_CMDS)
74 #define HCI_MASTER_LINK_KEY (0x0017 | HCI_GRP_LINK_CONTROL_CMDS)
75 #define HCI_RMT_NAME_REQUEST (0x0019 | HCI_GRP_LINK_CONTROL_CMDS)
76 #define HCI_RMT_NAME_REQUEST_CANCEL (0x001A | HCI_GRP_LINK_CONTROL_CMDS)
77 #define HCI_READ_RMT_FEATURES (0x001B | HCI_GRP_LINK_CONTROL_CMDS)
78 #define HCI_READ_RMT_EXT_FEATURES (0x001C | HCI_GRP_LINK_CONTROL_CMDS)
79 #define HCI_READ_RMT_VERSION_INFO (0x001D | HCI_GRP_LINK_CONTROL_CMDS)
80 #define HCI_READ_RMT_CLOCK_OFFSET (0x001F | HCI_GRP_LINK_CONTROL_CMDS)
81 #define HCI_READ_LMP_HANDLE (0x0020 | HCI_GRP_LINK_CONTROL_CMDS)
82 #define HCI_SETUP_ESCO_CONNECTION (0x0028 | HCI_GRP_LINK_CONTROL_CMDS)
83 #define HCI_ACCEPT_ESCO_CONNECTION (0x0029 | HCI_GRP_LINK_CONTROL_CMDS)
84 #define HCI_REJECT_ESCO_CONNECTION (0x002A | HCI_GRP_LINK_CONTROL_CMDS)
85 #define HCI_IO_CAPABILITY_REQUEST_REPLY (0x002B | HCI_GRP_LINK_CONTROL_CMDS)
86 #define HCI_USER_CONF_REQUEST_REPLY (0x002C | HCI_GRP_LINK_CONTROL_CMDS)
87 #define HCI_USER_CONF_VALUE_NEG_REPLY (0x002D | HCI_GRP_LINK_CONTROL_CMDS)
88 #define HCI_USER_PASSKEY_REQ_REPLY (0x002E | HCI_GRP_LINK_CONTROL_CMDS)
89 #define HCI_USER_PASSKEY_REQ_NEG_REPLY (0x002F | HCI_GRP_LINK_CONTROL_CMDS)
90 #define HCI_REM_OOB_DATA_REQ_REPLY (0x0030 | HCI_GRP_LINK_CONTROL_CMDS)
91 #define HCI_REM_OOB_DATA_REQ_NEG_REPLY (0x0033 | HCI_GRP_LINK_CONTROL_CMDS)
92 #define HCI_IO_CAP_REQ_NEG_REPLY (0x0034 | HCI_GRP_LINK_CONTROL_CMDS)
93 
94 /* AMP HCI */
95 #define HCI_CREATE_PHYSICAL_LINK (0x0035 | HCI_GRP_LINK_CONTROL_CMDS)
96 #define HCI_ACCEPT_PHYSICAL_LINK (0x0036 | HCI_GRP_LINK_CONTROL_CMDS)
97 #define HCI_DISCONNECT_PHYSICAL_LINK (0x0037 | HCI_GRP_LINK_CONTROL_CMDS)
98 #define HCI_CREATE_LOGICAL_LINK (0x0038 | HCI_GRP_LINK_CONTROL_CMDS)
99 #define HCI_ACCEPT_LOGICAL_LINK (0x0039 | HCI_GRP_LINK_CONTROL_CMDS)
100 #define HCI_DISCONNECT_LOGICAL_LINK (0x003A | HCI_GRP_LINK_CONTROL_CMDS)
101 #define HCI_LOGICAL_LINK_CANCEL (0x003B | HCI_GRP_LINK_CONTROL_CMDS)
102 #define HCI_FLOW_SPEC_MODIFY (0x003C | HCI_GRP_LINK_CONTROL_CMDS)
103 
104 #define HCI_ENH_SETUP_ESCO_CONNECTION (0x003D | HCI_GRP_LINK_CONTROL_CMDS)
105 #define HCI_ENH_ACCEPT_ESCO_CONNECTION (0x003E | HCI_GRP_LINK_CONTROL_CMDS)
106 
107 /* ConnectionLess Broadcast */
108 #define HCI_TRUNCATED_PAGE (0x003F | HCI_GRP_LINK_CONTROL_CMDS)
109 #define HCI_TRUNCATED_PAGE_CANCEL (0x0040 | HCI_GRP_LINK_CONTROL_CMDS)
110 #define HCI_SET_CLB (0x0041 | HCI_GRP_LINK_CONTROL_CMDS)
111 #define HCI_RECEIVE_CLB (0x0042 | HCI_GRP_LINK_CONTROL_CMDS)
112 #define HCI_START_SYNC_TRAIN (0x0043 | HCI_GRP_LINK_CONTROL_CMDS)
113 #define HCI_RECEIVE_SYNC_TRAIN (0x0044 | HCI_GRP_LINK_CONTROL_CMDS)
114 
115 #define HCI_LINK_CTRL_CMDS_FIRST HCI_INQUIRY
116 #define HCI_LINK_CTRL_CMDS_LAST HCI_RECEIVE_SYNC_TRAIN
117 
118 /* Commands of HCI_GRP_LINK_POLICY_CMDS */
119 #define HCI_HOLD_MODE (0x0001 | HCI_GRP_LINK_POLICY_CMDS)
120 #define HCI_SNIFF_MODE (0x0003 | HCI_GRP_LINK_POLICY_CMDS)
121 #define HCI_EXIT_SNIFF_MODE (0x0004 | HCI_GRP_LINK_POLICY_CMDS)
122 #define HCI_PARK_MODE (0x0005 | HCI_GRP_LINK_POLICY_CMDS)
123 #define HCI_EXIT_PARK_MODE (0x0006 | HCI_GRP_LINK_POLICY_CMDS)
124 #define HCI_QOS_SETUP (0x0007 | HCI_GRP_LINK_POLICY_CMDS)
125 #define HCI_ROLE_DISCOVERY (0x0009 | HCI_GRP_LINK_POLICY_CMDS)
126 #define HCI_SWITCH_ROLE (0x000B | HCI_GRP_LINK_POLICY_CMDS)
127 #define HCI_READ_POLICY_SETTINGS (0x000C | HCI_GRP_LINK_POLICY_CMDS)
128 #define HCI_WRITE_POLICY_SETTINGS (0x000D | HCI_GRP_LINK_POLICY_CMDS)
129 #define HCI_READ_DEF_POLICY_SETTINGS (0x000E | HCI_GRP_LINK_POLICY_CMDS)
130 #define HCI_WRITE_DEF_POLICY_SETTINGS (0x000F | HCI_GRP_LINK_POLICY_CMDS)
131 #define HCI_FLOW_SPECIFICATION (0x0010 | HCI_GRP_LINK_POLICY_CMDS)
132 #define HCI_SNIFF_SUB_RATE (0x0011 | HCI_GRP_LINK_POLICY_CMDS)
133 
134 #define HCI_LINK_POLICY_CMDS_FIRST HCI_HOLD_MODE
135 #define HCI_LINK_POLICY_CMDS_LAST HCI_SNIFF_SUB_RATE
136 
137 /* Commands of HCI_GRP_HOST_CONT_BASEBAND_CMDS */
138 #define HCI_SET_EVENT_MASK (0x0001 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
139 #define HCI_RESET (0x0003 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
140 #define HCI_SET_EVENT_FILTER (0x0005 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
141 #define HCI_FLUSH (0x0008 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
142 #define HCI_READ_PIN_TYPE (0x0009 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
143 #define HCI_WRITE_PIN_TYPE (0x000A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
144 #define HCI_CREATE_NEW_UNIT_KEY (0x000B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
145 #define HCI_GET_MWS_TRANS_LAYER_CFG (0x000C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
146 #define HCI_READ_STORED_LINK_KEY (0x000D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
147 #define HCI_WRITE_STORED_LINK_KEY (0x0011 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
148 #define HCI_DELETE_STORED_LINK_KEY (0x0012 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
149 #define HCI_CHANGE_LOCAL_NAME (0x0013 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
150 #define HCI_READ_LOCAL_NAME (0x0014 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
151 #define HCI_READ_CONN_ACCEPT_TOUT (0x0015 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
152 #define HCI_WRITE_CONN_ACCEPT_TOUT (0x0016 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
153 #define HCI_READ_PAGE_TOUT (0x0017 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
154 #define HCI_WRITE_PAGE_TOUT (0x0018 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
155 #define HCI_READ_SCAN_ENABLE (0x0019 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
156 #define HCI_WRITE_SCAN_ENABLE (0x001A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
157 #define HCI_READ_PAGESCAN_CFG (0x001B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
158 #define HCI_WRITE_PAGESCAN_CFG (0x001C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
159 #define HCI_READ_INQUIRYSCAN_CFG (0x001D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
160 #define HCI_WRITE_INQUIRYSCAN_CFG (0x001E | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
161 #define HCI_READ_AUTHENTICATION_ENABLE \
162   (0x001F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
163 #define HCI_WRITE_AUTHENTICATION_ENABLE \
164   (0x0020 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
165 #define HCI_READ_ENCRYPTION_MODE (0x0021 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
166 #define HCI_WRITE_ENCRYPTION_MODE (0x0022 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
167 #define HCI_READ_CLASS_OF_DEVICE (0x0023 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
168 #define HCI_WRITE_CLASS_OF_DEVICE (0x0024 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
169 #define HCI_READ_VOICE_SETTINGS (0x0025 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
170 #define HCI_WRITE_VOICE_SETTINGS (0x0026 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
171 #define HCI_READ_AUTOMATIC_FLUSH_TIMEOUT \
172   (0x0027 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
173 #define HCI_WRITE_AUTOMATIC_FLUSH_TIMEOUT \
174   (0x0028 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
175 #define HCI_READ_NUM_BCAST_REXMITS (0x0029 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
176 #define HCI_WRITE_NUM_BCAST_REXMITS (0x002A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
177 #define HCI_READ_HOLD_MODE_ACTIVITY (0x002B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
178 #define HCI_WRITE_HOLD_MODE_ACTIVITY (0x002C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
179 #define HCI_READ_TRANSMIT_POWER_LEVEL (0x002D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
180 #define HCI_READ_SCO_FLOW_CTRL_ENABLE (0x002E | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
181 #define HCI_WRITE_SCO_FLOW_CTRL_ENABLE \
182   (0x002F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
183 #define HCI_SET_HC_TO_HOST_FLOW_CTRL (0x0031 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
184 #define HCI_HOST_BUFFER_SIZE (0x0033 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
185 #define HCI_HOST_NUM_PACKETS_DONE (0x0035 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
186 #define HCI_READ_LINK_SUPER_TOUT (0x0036 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
187 #define HCI_WRITE_LINK_SUPER_TOUT (0x0037 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
188 #define HCI_READ_NUM_SUPPORTED_IAC (0x0038 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
189 #define HCI_READ_CURRENT_IAC_LAP (0x0039 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
190 #define HCI_WRITE_CURRENT_IAC_LAP (0x003A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
191 #define HCI_READ_PAGESCAN_PERIOD_MODE (0x003B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
192 #define HCI_WRITE_PAGESCAN_PERIOD_MODE \
193   (0x003C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
194 #define HCI_READ_PAGESCAN_MODE (0x003D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
195 #define HCI_WRITE_PAGESCAN_MODE (0x003E | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
196 #define HCI_SET_AFH_CHANNELS (0x003F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
197 
198 #define HCI_READ_INQSCAN_TYPE (0x0042 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
199 #define HCI_WRITE_INQSCAN_TYPE (0x0043 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
200 #define HCI_READ_INQUIRY_MODE (0x0044 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
201 #define HCI_WRITE_INQUIRY_MODE (0x0045 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
202 #define HCI_READ_PAGESCAN_TYPE (0x0046 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
203 #define HCI_WRITE_PAGESCAN_TYPE (0x0047 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
204 #define HCI_READ_AFH_ASSESSMENT_MODE (0x0048 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
205 #define HCI_WRITE_AFH_ASSESSMENT_MODE (0x0049 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
206 #define HCI_READ_EXT_INQ_RESPONSE (0x0051 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
207 #define HCI_WRITE_EXT_INQ_RESPONSE (0x0052 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
208 #define HCI_REFRESH_ENCRYPTION_KEY (0x0053 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
209 #define HCI_READ_SIMPLE_PAIRING_MODE (0x0055 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
210 #define HCI_WRITE_SIMPLE_PAIRING_MODE (0x0056 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
211 #define HCI_READ_LOCAL_OOB_DATA (0x0057 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
212 #define HCI_READ_INQ_TX_POWER_LEVEL (0x0058 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
213 #define HCI_WRITE_INQ_TX_POWER_LEVEL (0x0059 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
214 #define HCI_READ_ERRONEOUS_DATA_RPT (0x005A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
215 #define HCI_WRITE_ERRONEOUS_DATA_RPT (0x005B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
216 #define HCI_ENHANCED_FLUSH (0x005F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
217 #define HCI_SEND_KEYPRESS_NOTIF (0x0060 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
218 
219 /* AMP HCI */
220 #define HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT \
221   (0x0061 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
222 #define HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT \
223   (0x0062 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
224 #define HCI_SET_EVENT_MASK_PAGE_2 (0x0063 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
225 #define HCI_READ_LOCATION_DATA (0x0064 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
226 #define HCI_WRITE_LOCATION_DATA (0x0065 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
227 #define HCI_READ_FLOW_CONTROL_MODE (0x0066 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
228 #define HCI_WRITE_FLOW_CONTROL_MODE (0x0067 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
229 #define HCI_READ_BE_FLUSH_TOUT (0x0069 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
230 #define HCI_WRITE_BE_FLUSH_TOUT (0x006A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
231 /* 802.11 only */
232 #define HCI_SHORT_RANGE_MODE (0x006B | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
233 #define HCI_READ_LE_HOST_SUPPORT (0x006C | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
234 #define HCI_WRITE_LE_HOST_SUPPORT (0x006D | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
235 
236 /* MWS coexistence */
237 #define HCI_SET_MWS_CHANNEL_PARAMETERS \
238   (0x006E | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
239 #define HCI_SET_EXTERNAL_FRAME_CONFIGURATION \
240   (0x006F | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
241 #define HCI_SET_MWS_SIGNALING (0x0070 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
242 #define HCI_SET_MWS_TRANSPORT_LAYER (0x0071 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
243 #define HCI_SET_MWS_SCAN_FREQUENCY_TABLE \
244   (0x0072 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
245 #define HCI_SET_MWS_PATTERN_CONFIGURATION \
246   (0x0073 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
247 
248 /* Connectionless Broadcast */
249 #define HCI_SET_RESERVED_LT_ADDR (0x0074 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
250 #define HCI_DELETE_RESERVED_LT_ADDR (0x0075 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
251 #define HCI_WRITE_CLB_DATA (0x0076 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
252 #define HCI_READ_SYNC_TRAIN_PARAM (0x0077 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
253 #define HCI_WRITE_SYNC_TRAIN_PARAM (0x0078 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
254 
255 #define HCI_READ_SECURE_CONNS_SUPPORT (0x0079 | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
256 #define HCI_WRITE_SECURE_CONNS_SUPPORT \
257   (0x007A | HCI_GRP_HOST_CONT_BASEBAND_CMDS)
258 #define HCI_CONT_BASEBAND_CMDS_FIRST HCI_SET_EVENT_MASK
259 #define HCI_CONT_BASEBAND_CMDS_LAST HCI_READ_SYNC_TRAIN_PARAM
260 
261 /* Commands of HCI_GRP_INFORMATIONAL_PARAMS group */
262 #define HCI_READ_LOCAL_VERSION_INFO (0x0001 | HCI_GRP_INFORMATIONAL_PARAMS)
263 #define HCI_READ_LOCAL_SUPPORTED_CMDS (0x0002 | HCI_GRP_INFORMATIONAL_PARAMS)
264 #define HCI_READ_LOCAL_FEATURES (0x0003 | HCI_GRP_INFORMATIONAL_PARAMS)
265 #define HCI_READ_LOCAL_EXT_FEATURES (0x0004 | HCI_GRP_INFORMATIONAL_PARAMS)
266 #define HCI_READ_BUFFER_SIZE (0x0005 | HCI_GRP_INFORMATIONAL_PARAMS)
267 #define HCI_READ_COUNTRY_CODE (0x0007 | HCI_GRP_INFORMATIONAL_PARAMS)
268 #define HCI_READ_BD_ADDR (0x0009 | HCI_GRP_INFORMATIONAL_PARAMS)
269 #define HCI_READ_DATA_BLOCK_SIZE (0x000A | HCI_GRP_INFORMATIONAL_PARAMS)
270 #define HCI_READ_LOCAL_SUPPORTED_CODECS (0x000B | HCI_GRP_INFORMATIONAL_PARAMS)
271 
272 #define HCI_INFORMATIONAL_CMDS_FIRST HCI_READ_LOCAL_VERSION_INFO
273 #define HCI_INFORMATIONAL_CMDS_LAST HCI_READ_LOCAL_SUPPORTED_CODECS
274 
275 /* Commands of HCI_GRP_STATUS_PARAMS group */
276 #define HCI_READ_FAILED_CONTACT_COUNTER (0x0001 | HCI_GRP_STATUS_PARAMS)
277 #define HCI_RESET_FAILED_CONTACT_COUNTER (0x0002 | HCI_GRP_STATUS_PARAMS)
278 #define HCI_GET_LINK_QUALITY (0x0003 | HCI_GRP_STATUS_PARAMS)
279 #define HCI_READ_RSSI (0x0005 | HCI_GRP_STATUS_PARAMS)
280 #define HCI_READ_AFH_CH_MAP (0x0006 | HCI_GRP_STATUS_PARAMS)
281 #define HCI_READ_CLOCK (0x0007 | HCI_GRP_STATUS_PARAMS)
282 #define HCI_READ_ENCR_KEY_SIZE (0x0008 | HCI_GRP_STATUS_PARAMS)
283 
284 /* AMP HCI */
285 #define HCI_READ_LOCAL_AMP_INFO (0x0009 | HCI_GRP_STATUS_PARAMS)
286 #define HCI_READ_LOCAL_AMP_ASSOC (0x000A | HCI_GRP_STATUS_PARAMS)
287 #define HCI_WRITE_REMOTE_AMP_ASSOC (0x000B | HCI_GRP_STATUS_PARAMS)
288 
289 #define HCI_STATUS_PARAMS_CMDS_FIRST HCI_READ_FAILED_CONTACT_COUNTER
290 #define HCI_STATUS_PARAMS_CMDS_LAST HCI_WRITE_REMOTE_AMP_ASSOC
291 
292 /* Commands of HCI_GRP_TESTING_CMDS group */
293 #define HCI_READ_LOOPBACK_MODE (0x0001 | HCI_GRP_TESTING_CMDS)
294 #define HCI_WRITE_LOOPBACK_MODE (0x0002 | HCI_GRP_TESTING_CMDS)
295 #define HCI_ENABLE_DEV_UNDER_TEST_MODE (0x0003 | HCI_GRP_TESTING_CMDS)
296 #define HCI_WRITE_SIMP_PAIR_DEBUG_MODE (0x0004 | HCI_GRP_TESTING_CMDS)
297 
298 /* AMP HCI */
299 #define HCI_ENABLE_AMP_RCVR_REPORTS (0x0007 | HCI_GRP_TESTING_CMDS)
300 #define HCI_AMP_TEST_END (0x0008 | HCI_GRP_TESTING_CMDS)
301 #define HCI_AMP_TEST (0x0009 | HCI_GRP_TESTING_CMDS)
302 
303 #define HCI_TESTING_CMDS_FIRST HCI_READ_LOOPBACK_MODE
304 #define HCI_TESTING_CMDS_LAST HCI_AMP_TEST
305 
306 #define HCI_VENDOR_CMDS_FIRST 0x0001
307 #define HCI_VENDOR_CMDS_LAST 0xFFFF
308 #define HCI_VSC_MULTI_AV_HANDLE 0x0AAA
309 #define HCI_VSC_BURST_MODE_HANDLE 0x0BBB
310 
311 /* BLE HCI Group Commands */
312 /* Commands of BLE Controller setup and configuration */
313 #define HCI_BLE_SET_EVENT_MASK (0x0001 | HCI_GRP_BLE_CMDS)
314 #define HCI_BLE_READ_BUFFER_SIZE (0x0002 | HCI_GRP_BLE_CMDS)
315 #define HCI_BLE_READ_LOCAL_SPT_FEAT (0x0003 | HCI_GRP_BLE_CMDS)
316 #define HCI_BLE_WRITE_LOCAL_SPT_FEAT (0x0004 | HCI_GRP_BLE_CMDS)
317 #define HCI_BLE_WRITE_RANDOM_ADDR (0x0005 | HCI_GRP_BLE_CMDS)
318 #define HCI_BLE_WRITE_ADV_PARAMS (0x0006 | HCI_GRP_BLE_CMDS)
319 #define HCI_BLE_READ_ADV_CHNL_TX_POWER (0x0007 | HCI_GRP_BLE_CMDS)
320 #define HCI_BLE_WRITE_ADV_DATA (0x0008 | HCI_GRP_BLE_CMDS)
321 #define HCI_BLE_WRITE_SCAN_RSP_DATA (0x0009 | HCI_GRP_BLE_CMDS)
322 #define HCI_BLE_WRITE_ADV_ENABLE (0x000A | HCI_GRP_BLE_CMDS)
323 #define HCI_BLE_WRITE_SCAN_PARAMS (0x000B | HCI_GRP_BLE_CMDS)
324 #define HCI_BLE_WRITE_SCAN_ENABLE (0x000C | HCI_GRP_BLE_CMDS)
325 #define HCI_BLE_CREATE_LL_CONN (0x000D | HCI_GRP_BLE_CMDS)
326 #define HCI_BLE_CREATE_CONN_CANCEL (0x000E | HCI_GRP_BLE_CMDS)
327 #define HCI_BLE_READ_WHITE_LIST_SIZE (0x000F | HCI_GRP_BLE_CMDS)
328 #define HCI_BLE_CLEAR_WHITE_LIST (0x0010 | HCI_GRP_BLE_CMDS)
329 #define HCI_BLE_ADD_WHITE_LIST (0x0011 | HCI_GRP_BLE_CMDS)
330 #define HCI_BLE_REMOVE_WHITE_LIST (0x0012 | HCI_GRP_BLE_CMDS)
331 #define HCI_BLE_UPD_LL_CONN_PARAMS (0x0013 | HCI_GRP_BLE_CMDS)
332 #define HCI_BLE_SET_HOST_CHNL_CLASS (0x0014 | HCI_GRP_BLE_CMDS)
333 #define HCI_BLE_READ_CHNL_MAP (0x0015 | HCI_GRP_BLE_CMDS)
334 #define HCI_BLE_READ_REMOTE_FEAT (0x0016 | HCI_GRP_BLE_CMDS)
335 #define HCI_BLE_ENCRYPT (0x0017 | HCI_GRP_BLE_CMDS)
336 #define HCI_BLE_RAND (0x0018 | HCI_GRP_BLE_CMDS)
337 #define HCI_BLE_START_ENC (0x0019 | HCI_GRP_BLE_CMDS)
338 #define HCI_BLE_LTK_REQ_REPLY (0x001A | HCI_GRP_BLE_CMDS)
339 #define HCI_BLE_LTK_REQ_NEG_REPLY (0x001B | HCI_GRP_BLE_CMDS)
340 #define HCI_BLE_READ_SUPPORTED_STATES (0x001C | HCI_GRP_BLE_CMDS)
341 /* 0x001D, 0x001E and 0x001F are reserved */
342 #define HCI_BLE_RECEIVER_TEST (0x001D | HCI_GRP_BLE_CMDS)
343 #define HCI_BLE_TRANSMITTER_TEST (0x001E | HCI_GRP_BLE_CMDS)
344 /* BLE TEST COMMANDS */
345 #define HCI_BLE_TEST_END (0x001F | HCI_GRP_BLE_CMDS)
346 #define HCI_BLE_RC_PARAM_REQ_REPLY (0x0020 | HCI_GRP_BLE_CMDS)
347 #define HCI_BLE_RC_PARAM_REQ_NEG_REPLY (0x0021 | HCI_GRP_BLE_CMDS)
348 
349 #define HCI_BLE_SET_DATA_LENGTH (0x0022 | HCI_GRP_BLE_CMDS)
350 #define HCI_BLE_READ_DEFAULT_DATA_LENGTH (0x0023 | HCI_GRP_BLE_CMDS)
351 #define HCI_BLE_WRITE_DEFAULT_DATA_LENGTH (0x0024 | HCI_GRP_BLE_CMDS)
352 
353 #define HCI_BLE_ADD_DEV_RESOLVING_LIST (0x0027 | HCI_GRP_BLE_CMDS)
354 #define HCI_BLE_RM_DEV_RESOLVING_LIST (0x0028 | HCI_GRP_BLE_CMDS)
355 #define HCI_BLE_CLEAR_RESOLVING_LIST (0x0029 | HCI_GRP_BLE_CMDS)
356 #define HCI_BLE_READ_RESOLVING_LIST_SIZE (0x002A | HCI_GRP_BLE_CMDS)
357 #define HCI_BLE_READ_RESOLVABLE_ADDR_PEER (0x002B | HCI_GRP_BLE_CMDS)
358 #define HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL (0x002C | HCI_GRP_BLE_CMDS)
359 #define HCI_BLE_SET_ADDR_RESOLUTION_ENABLE (0x002D | HCI_GRP_BLE_CMDS)
360 #define HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT (0x002E | HCI_GRP_BLE_CMDS)
361 #define HCI_BLE_READ_MAXIMUM_DATA_LENGTH (0x002F | HCI_GRP_BLE_CMDS)
362 #define HCI_BLE_READ_PHY (0x0030 | HCI_GRP_BLE_CMDS)
363 #define HCI_BLE_SET_DEFAULT_PHY (0x0031 | HCI_GRP_BLE_CMDS)
364 #define HCI_BLE_SET_PHY (0x0032 | HCI_GRP_BLE_CMDS)
365 #define HCI_BLE_ENH_RECEIVER_TEST (0x0033 | HCI_GRP_BLE_CMDS)
366 #define HCI_BLE_ENH_TRANSMITTER_TEST (0x0034 | HCI_GRP_BLE_CMDS)
367 #define HCI_LE_SET_EXT_ADVERTISING_RANDOM_ADDRESS (0x35 | HCI_GRP_BLE_CMDS)
368 #define HCI_LE_SET_EXT_ADVERTISING_PARAM (0x36 | HCI_GRP_BLE_CMDS)
369 #define HCI_LE_SET_EXT_ADVERTISING_DATA (0x37 | HCI_GRP_BLE_CMDS)
370 #define HCI_LE_SET_EXT_ADVERTISING_SCAN_RESP (0x38 | HCI_GRP_BLE_CMDS)
371 #define HCI_LE_SET_EXT_ADVERTISING_ENABLE (0x39 | HCI_GRP_BLE_CMDS)
372 #define HCI_LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH (0x003A | HCI_GRP_BLE_CMDS)
373 #define HCI_LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS \
374   (0x003B | HCI_GRP_BLE_CMDS)
375 #define HCI_LE_REMOVE_ADVERTISING_SET (0x003C | HCI_GRP_BLE_CMDS)
376 #define HCI_LE_CLEAR_ADVERTISING_SETS (0x003D | HCI_GRP_BLE_CMDS)
377 #define HCI_LE_SET_PERIODIC_ADVERTISING_PARAM (0x003E | HCI_GRP_BLE_CMDS)
378 #define HCI_LE_SET_PERIODIC_ADVERTISING_DATA (0x003F | HCI_GRP_BLE_CMDS)
379 #define HCI_LE_SET_PERIODIC_ADVERTISING_ENABLE (0x0040 | HCI_GRP_BLE_CMDS)
380 #define HCI_LE_SET_EXTENDED_SCAN_PARAMETERS (0x0041 | HCI_GRP_BLE_CMDS)
381 #define HCI_LE_SET_EXTENDED_SCAN_ENABLE (0x0042 | HCI_GRP_BLE_CMDS)
382 #define HCI_LE_EXTENDED_CREATE_CONNECTION (0x0043 | HCI_GRP_BLE_CMDS)
383 #define HCI_BLE_PERIODIC_ADVERTISING_CREATE_SYNC (0x0044 | HCI_GRP_BLE_CMDS)
384 #define HCI_BLE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL \
385   (0x0045 | HCI_GRP_BLE_CMDS)
386 #define HCI_BLE_PERIODIC_ADVERTISING_TERMINATE_SYNC \
387   (0x0046 | HCI_GRP_BLE_CMDS)
388 #define HCI_BLE_ADD_DEVICE_TO_PERIODIC_ADVERTISING_LIST \
389   (0x0047 | HCI_GRP_BLE_CMDS)
390 #define HCI_BLE_RM_DEVICE_FROM_PERIODIC_ADVERTISING_LIST \
391   (0x0048 | HCI_GRP_BLE_CMDS)
392 #define HCI_BLE_CLEAR_PERIODIC_ADVERTISING_LIST (0x0049 | HCI_GRP_BLE_CMDS)
393 #define HCI_BLE_READ_PERIODIC_ADVERTISING_LIST_SIZE (0x004A | HCI_GRP_BLE_CMDS)
394 #define HCI_BLE_READ_TRANSMIT_POWER (0x004B | HCI_GRP_BLE_CMDS)
395 #define HCI_BLE_READ_RF_COMPENS_POWER (0x004C | HCI_GRP_BLE_CMDS)
396 #define HCI_BLE_WRITE_RF_COMPENS_POWER (0x004D | HCI_GRP_BLE_CMDS)
397 #define HCI_BLE_SET_PRIVACY_MODE (0x004E | HCI_GRP_BLE_CMDS)
398 
399 /* LE Get Vendor Capabilities Command opcode */
400 #define HCI_BLE_VENDOR_CAP (0x0153 | HCI_GRP_VENDOR_SPECIFIC)
401 
402 /* Multi adv opcode */
403 #define HCI_BLE_MULTI_ADV (0x0154 | HCI_GRP_VENDOR_SPECIFIC)
404 
405 /* Batch scan opcode */
406 #define HCI_BLE_BATCH_SCAN (0x0156 | HCI_GRP_VENDOR_SPECIFIC)
407 
408 /* ADV filter opcode */
409 #define HCI_BLE_ADV_FILTER (0x0157 | HCI_GRP_VENDOR_SPECIFIC)
410 
411 /* Tracking opcode */
412 #define HCI_BLE_TRACK_ADV (0x0158 | HCI_GRP_VENDOR_SPECIFIC)
413 
414 /* Energy info opcode */
415 #define HCI_BLE_ENERGY_INFO (0x0159 | HCI_GRP_VENDOR_SPECIFIC)
416 
417 /* Extended BLE Scan parameters opcode */
418 #define HCI_BLE_EXTENDED_SCAN_PARAMS (0x015A | HCI_GRP_VENDOR_SPECIFIC)
419 
420 /* Controller debug info opcode */
421 #define HCI_CONTROLLER_DEBUG_INFO (0x015B | HCI_GRP_VENDOR_SPECIFIC)
422 
423 /* A2DP offload opcode */
424 #define HCI_CONTROLLER_A2DP (0x015D | HCI_GRP_VENDOR_SPECIFIC)
425 
426 /* Bluetooth Quality Report opcode */
427 #define HCI_CONTROLLER_BQR (0x015E | HCI_GRP_VENDOR_SPECIFIC)
428 
429 /* subcode for multi adv feature */
430 #define BTM_BLE_MULTI_ADV_SET_PARAM 0x01
431 #define BTM_BLE_MULTI_ADV_WRITE_ADV_DATA 0x02
432 #define BTM_BLE_MULTI_ADV_WRITE_SCAN_RSP_DATA 0x03
433 #define BTM_BLE_MULTI_ADV_SET_RANDOM_ADDR 0x04
434 #define BTM_BLE_MULTI_ADV_ENB 0x05
435 
436 /* multi adv VSE subcode */
437 /* multi adv instance state change */
438 #define HCI_VSE_SUBCODE_BLE_MULTI_ADV_ST_CHG 0x55
439 
440 /* subcode for batch scan feature */
441 #define BTM_BLE_BATCH_SCAN_ENB_DISAB_CUST_FEATURE 0x01
442 #define BTM_BLE_BATCH_SCAN_SET_STORAGE_PARAM 0x02
443 #define BTM_BLE_BATCH_SCAN_SET_PARAMS 0x03
444 #define BTM_BLE_BATCH_SCAN_READ_RESULTS 0x04
445 
446 /* batch scan VSE subcode */
447 #define HCI_VSE_SUBCODE_BLE_THRESHOLD_SUB_EVT 0x54 /* Threshold event */
448 
449 /* tracking sub event */
450 #define HCI_VSE_SUBCODE_BLE_TRACKING_SUB_EVT 0x56 /* Tracking event */
451 
452 /* debug info sub event */
453 #define HCI_VSE_SUBCODE_DEBUG_INFO_SUB_EVT 0x57
454 
455 /* Bluetooth Quality Report sub event */
456 #define HCI_VSE_SUBCODE_BQR_SUB_EVT 0x58
457 
458 /* LE supported states definition */
459 #define HCI_LE_ADV_STATE 0x00000001
460 #define HCI_LE_SCAN_STATE 0x00000002
461 #define HCI_LE_INIT_STATE 0x00000004
462 #define HCI_LE_CONN_SL_STATE 0x00000008
463 #define HCI_LE_ADV_SCAN_STATE 0x00000010
464 #define HCI_LE_ADV_INIT_STATE 0x00000020
465 #define HCI_LE_ADV_MA_STATE 0x00000040
466 #define HCI_LE_ADV_SL_STATE 0x00000080
467 #define HCI_LE_SCAN_INIT_STATE 0x00000100
468 #define HCI_LE_SCAN_MA_STATE 0x00000200
469 #define HCI_LE_SCAN_SL_STATE 0x00000400
470 #define HCI_LE_INIT_MA_STATE 0x00000800
471 
472 /* LE Supported States */
473 constexpr uint8_t HCI_LE_STATES_NON_CONN_ADV_BIT = 0;
474 constexpr uint8_t HCI_LE_STATES_SCAN_ADV_BIT = 1;
475 constexpr uint8_t HCI_LE_STATES_CONN_ADV_BIT = 2;
476 constexpr uint8_t HCI_LE_STATES_HI_DUTY_DIR_ADV_BIT = 3;
477 constexpr uint8_t HCI_LE_STATES_PASS_SCAN_BIT = 4;
478 constexpr uint8_t HCI_LE_STATES_ACTIVE_SCAN_BIT = 5;
479 constexpr uint8_t HCI_LE_STATES_INIT_BIT = 6;
480 constexpr uint8_t HCI_LE_STATES_SLAVE_BIT = 7;
481 constexpr uint8_t HCI_LE_STATES_NON_CONN_ADV_PASS_SCAN_BIT = 8;
482 constexpr uint8_t HCI_LE_STATES_SCAN_ADV_PASS_SCAN_BIT = 9;
483 constexpr uint8_t HCI_LE_STATES_CONN_ADV_PASS_SCAN_BIT = 10;
484 constexpr uint8_t HCI_LE_STATES_HI_DUTY_DIR_ADV_PASS_SCAN_BIT = 11;
485 constexpr uint8_t HCI_LE_STATES_NON_CONN_ADV_ACTIVE_SCAN_BIT = 12;
486 constexpr uint8_t HCI_LE_STATES_SCAN_ADV_ACTIVE_SCAN_BIT = 13;
487 constexpr uint8_t HCI_LE_STATES_CONN_ADV_ACTIVE_SCAN_BIT = 14;
488 constexpr uint8_t HCI_LE_STATES_HI_DUTY_DIR_ADV_ACTIVE_SCAN_BIT = 15;
489 constexpr uint8_t HCI_LE_STATES_NON_CONN_INIT_BIT = 16;
490 constexpr uint8_t HCI_LE_STATES_SCAN_ADV_INIT_BIT = 17;
491 constexpr uint8_t HCI_LE_STATES_NON_CONN_ADV_MASTER_BIT = 18;
492 constexpr uint8_t HCI_LE_STATES_SCAN_ADV_MASTER_BIT = 19;
493 constexpr uint8_t HCI_LE_STATES_NON_CONN_ADV_SLAVE_BIT = 20;
494 constexpr uint8_t HCI_LE_STATES_SCAN_ADV_SLAVE_BIT = 21;
495 constexpr uint8_t HCI_LE_STATES_PASS_SCAN_INIT_BIT = 22;
496 constexpr uint8_t HCI_LE_STATES_ACTIVE_SCAN_INIT_BIT = 23;
497 constexpr uint8_t HCI_LE_STATES_PASS_SCAN_MASTER_BIT = 24;
498 constexpr uint8_t HCI_LE_STATES_ACTIVE_SCAN_MASTER_BIT = 25;
499 constexpr uint8_t HCI_LE_STATES_PASS_SCAN_SLAVE_BIT = 26;
500 constexpr uint8_t HCI_LE_STATES_ACTIVE_SCAN_SLAVE_BIT = 27;
501 constexpr uint8_t HCI_LE_STATES_INIT_MASTER_BIT = 28;
502 constexpr uint8_t HCI_LE_STATES_LOW_DUTY_DIR_ADV_BIT = 29;
503 constexpr uint8_t HCI_LE_STATES_LO_DUTY_DIR_ADV_PASS_SCAN_BIT = 30;
504 constexpr uint8_t HCI_LE_STATES_LO_DUTY_DIR_ADV_ACTIVE_SCAN_BIT = 31;
505 constexpr uint8_t HCI_LE_STATES_CONN_ADV_INIT_BIT = 32;
506 constexpr uint8_t HCI_LE_STATES_HI_DUTY_DIR_ADV_INIT_BIT = 33;
507 constexpr uint8_t HCI_LE_STATES_LO_DUTY_DIR_ADV_INIT_BIT = 34;
508 constexpr uint8_t HCI_LE_STATES_CONN_ADV_MASTER_BIT = 35;
509 constexpr uint8_t HCI_LE_STATES_HI_DUTY_DIR_ADV_MASTER_BIT = 36;
510 constexpr uint8_t HCI_LE_STATES_LO_DUTY_DIR_ADV_MASTER_BIT = 37;
511 constexpr uint8_t HCI_LE_STATES_CONN_ADV_SLAVE_BIT = 38;
512 constexpr uint8_t HCI_LE_STATES_HI_DUTY_DIR_ADV_SLAVE_BIT = 39;
513 constexpr uint8_t HCI_LE_STATES_LO_DUTY_DIR_ADV_SLAVE_BIT = 40;
514 constexpr uint8_t HCI_LE_STATES_INIT_MASTER_SLAVE_BIT = 41;
515 
516 /*
517  *  Definitions for HCI Events
518 */
519 #define HCI_INQUIRY_COMP_EVT 0x01
520 #define HCI_INQUIRY_RESULT_EVT 0x02
521 #define HCI_CONNECTION_COMP_EVT 0x03
522 #define HCI_CONNECTION_REQUEST_EVT 0x04
523 #define HCI_DISCONNECTION_COMP_EVT 0x05
524 #define HCI_AUTHENTICATION_COMP_EVT 0x06
525 #define HCI_RMT_NAME_REQUEST_COMP_EVT 0x07
526 #define HCI_ENCRYPTION_CHANGE_EVT 0x08
527 #define HCI_CHANGE_CONN_LINK_KEY_EVT 0x09
528 #define HCI_MASTER_LINK_KEY_COMP_EVT 0x0A
529 #define HCI_READ_RMT_FEATURES_COMP_EVT 0x0B
530 #define HCI_READ_RMT_VERSION_COMP_EVT 0x0C
531 #define HCI_QOS_SETUP_COMP_EVT 0x0D
532 #define HCI_COMMAND_COMPLETE_EVT 0x0E
533 #define HCI_COMMAND_STATUS_EVT 0x0F
534 #define HCI_HARDWARE_ERROR_EVT 0x10
535 #define HCI_FLUSH_OCCURED_EVT 0x11
536 #define HCI_ROLE_CHANGE_EVT 0x12
537 #define HCI_NUM_COMPL_DATA_PKTS_EVT 0x13
538 #define HCI_MODE_CHANGE_EVT 0x14
539 #define HCI_RETURN_LINK_KEYS_EVT 0x15
540 #define HCI_PIN_CODE_REQUEST_EVT 0x16
541 #define HCI_LINK_KEY_REQUEST_EVT 0x17
542 #define HCI_LINK_KEY_NOTIFICATION_EVT 0x18
543 #define HCI_LOOPBACK_COMMAND_EVT 0x19
544 #define HCI_DATA_BUF_OVERFLOW_EVT 0x1A
545 #define HCI_MAX_SLOTS_CHANGED_EVT 0x1B
546 #define HCI_READ_CLOCK_OFF_COMP_EVT 0x1C
547 #define HCI_CONN_PKT_TYPE_CHANGE_EVT 0x1D
548 #define HCI_QOS_VIOLATION_EVT 0x1E
549 #define HCI_PAGE_SCAN_MODE_CHANGE_EVT 0x1F
550 #define HCI_PAGE_SCAN_REP_MODE_CHNG_EVT 0x20
551 #define HCI_FLOW_SPECIFICATION_COMP_EVT 0x21
552 #define HCI_INQUIRY_RSSI_RESULT_EVT 0x22
553 #define HCI_READ_RMT_EXT_FEATURES_COMP_EVT 0x23
554 #define HCI_ESCO_CONNECTION_COMP_EVT 0x2C
555 #define HCI_ESCO_CONNECTION_CHANGED_EVT 0x2D
556 #define HCI_SNIFF_SUB_RATE_EVT 0x2E
557 #define HCI_EXTENDED_INQUIRY_RESULT_EVT 0x2F
558 #define HCI_ENCRYPTION_KEY_REFRESH_COMP_EVT 0x30
559 #define HCI_IO_CAPABILITY_REQUEST_EVT 0x31
560 #define HCI_IO_CAPABILITY_RESPONSE_EVT 0x32
561 #define HCI_USER_CONFIRMATION_REQUEST_EVT 0x33
562 #define HCI_USER_PASSKEY_REQUEST_EVT 0x34
563 #define HCI_REMOTE_OOB_DATA_REQUEST_EVT 0x35
564 #define HCI_SIMPLE_PAIRING_COMPLETE_EVT 0x36
565 #define HCI_LINK_SUPER_TOUT_CHANGED_EVT 0x38
566 #define HCI_ENHANCED_FLUSH_COMPLETE_EVT 0x39
567 #define HCI_USER_PASSKEY_NOTIFY_EVT 0x3B
568 #define HCI_KEYPRESS_NOTIFY_EVT 0x3C
569 #define HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT 0x3D
570 
571 /*#define HCI_GENERIC_AMP_LINK_KEY_NOTIF_EVT  0x3E Removed from spec */
572 #define HCI_PHYSICAL_LINK_COMP_EVT 0x40
573 #define HCI_CHANNEL_SELECTED_EVT 0x41
574 #define HCI_DISC_PHYSICAL_LINK_COMP_EVT 0x42
575 #define HCI_PHY_LINK_LOSS_EARLY_WARNING_EVT 0x43
576 #define HCI_PHY_LINK_RECOVERY_EVT 0x44
577 #define HCI_LOGICAL_LINK_COMP_EVT 0x45
578 #define HCI_DISC_LOGICAL_LINK_COMP_EVT 0x46
579 #define HCI_FLOW_SPEC_MODIFY_COMP_EVT 0x47
580 #define HCI_NUM_COMPL_DATA_BLOCKS_EVT 0x48
581 #define HCI_SHORT_RANGE_MODE_COMPLETE_EVT 0x4C
582 #define HCI_AMP_STATUS_CHANGE_EVT 0x4D
583 #define HCI_SET_TRIGGERED_CLOCK_CAPTURE_EVT 0x4E
584 
585 /* ULP HCI Event */
586 #define HCI_BLE_EVENT 0x3e
587 /* ULP Event sub code */
588 #define HCI_BLE_CONN_COMPLETE_EVT 0x01
589 #define HCI_BLE_ADV_PKT_RPT_EVT 0x02
590 #define HCI_BLE_LL_CONN_PARAM_UPD_EVT 0x03
591 #define HCI_BLE_READ_REMOTE_FEAT_CMPL_EVT 0x04
592 #define HCI_BLE_LTK_REQ_EVT 0x05
593 #define HCI_BLE_RC_PARAM_REQ_EVT 0x06
594 #define HCI_BLE_DATA_LENGTH_CHANGE_EVT 0x07
595 #define HCI_BLE_ENHANCED_CONN_COMPLETE_EVT 0x0a
596 #define HCI_BLE_DIRECT_ADV_EVT 0x0b
597 #define HCI_BLE_PHY_UPDATE_COMPLETE_EVT 0x0c
598 #define HCI_LE_EXTENDED_ADVERTISING_REPORT_EVT 0x0D
599 #define HCI_BLE_PERIODIC_ADV_SYNC_EST_EVT      0x0E
600 #define HCI_BLE_PERIODIC_ADV_REPORT_EVT        0x0F
601 #define HCI_BLE_PERIODIC_ADV_SYNC_LOST_EVT     0x10
602 #define HCI_BLE_SCAN_TIMEOUT_EVT               0x11
603 #define HCI_LE_ADVERTISING_SET_TERMINATED_EVT 0x12
604 #define HCI_BLE_SCAN_REQ_RX_EVT                0x13
605 
606 /* Definitions for LE Channel Map */
607 #define HCI_BLE_CHNL_MAP_SIZE 5
608 
609 #define HCI_VENDOR_SPECIFIC_EVT 0xFF /* Vendor specific events */
610 #define HCI_NAP_TRACE_EVT                       \
611   0xFF /* was define 0xFE, 0xFD, change to 0xFF \
612           because conflict w/ TCI_EVT and per   \
613           specification compliant */
614 
615 /*
616  *  Defentions for HCI Error Codes that are past in the events
617 */
618 #define HCI_SUCCESS 0x00
619 #define HCI_PENDING 0x00
620 #define HCI_ERR_ILLEGAL_COMMAND 0x01
621 #define HCI_ERR_NO_CONNECTION 0x02
622 #define HCI_ERR_HW_FAILURE 0x03
623 #define HCI_ERR_PAGE_TIMEOUT 0x04
624 #define HCI_ERR_AUTH_FAILURE 0x05
625 #define HCI_ERR_KEY_MISSING 0x06
626 #define HCI_ERR_MEMORY_FULL 0x07
627 #define HCI_ERR_CONNECTION_TOUT 0x08
628 #define HCI_ERR_MAX_NUM_OF_CONNECTIONS 0x09
629 #define HCI_ERR_MAX_NUM_OF_SCOS 0x0A
630 #define HCI_ERR_CONNECTION_EXISTS 0x0B
631 #define HCI_ERR_COMMAND_DISALLOWED 0x0C
632 #define HCI_ERR_HOST_REJECT_RESOURCES 0x0D
633 #define HCI_ERR_HOST_REJECT_SECURITY 0x0E
634 #define HCI_ERR_HOST_REJECT_DEVICE 0x0F
635 #define HCI_ERR_HOST_TIMEOUT 0x10
636 #define HCI_ERR_UNSUPPORTED_VALUE 0x11
637 #define HCI_ERR_ILLEGAL_PARAMETER_FMT 0x12
638 #define HCI_ERR_PEER_USER 0x13
639 #define HCI_ERR_PEER_LOW_RESOURCES 0x14
640 #define HCI_ERR_PEER_POWER_OFF 0x15
641 #define HCI_ERR_CONN_CAUSE_LOCAL_HOST 0x16
642 #define HCI_ERR_REPEATED_ATTEMPTS 0x17
643 #define HCI_ERR_PAIRING_NOT_ALLOWED 0x18
644 #define HCI_ERR_UNKNOWN_LMP_PDU 0x19
645 #define HCI_ERR_UNSUPPORTED_REM_FEATURE 0x1A
646 #define HCI_ERR_SCO_OFFSET_REJECTED 0x1B
647 #define HCI_ERR_SCO_INTERVAL_REJECTED 0x1C
648 #define HCI_ERR_SCO_AIR_MODE 0x1D
649 #define HCI_ERR_INVALID_LMP_PARAM 0x1E
650 #define HCI_ERR_UNSPECIFIED 0x1F
651 #define HCI_ERR_UNSUPPORTED_LMP_FEATURE 0x20
652 #define HCI_ERR_ROLE_CHANGE_NOT_ALLOWED 0x21
653 #define HCI_ERR_LMP_RESPONSE_TIMEOUT 0x22
654 #define HCI_ERR_LMP_ERR_TRANS_COLLISION 0x23
655 #define HCI_ERR_LMP_PDU_NOT_ALLOWED 0x24
656 #define HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE 0x25
657 #define HCI_ERR_UNIT_KEY_USED 0x26
658 #define HCI_ERR_QOS_NOT_SUPPORTED 0x27
659 #define HCI_ERR_INSTANT_PASSED 0x28
660 #define HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED 0x29
661 #define HCI_ERR_DIFF_TRANSACTION_COLLISION 0x2A
662 #define HCI_ERR_UNDEFINED_0x2B 0x2B
663 #define HCI_ERR_QOS_UNACCEPTABLE_PARAM 0x2C
664 #define HCI_ERR_QOS_REJECTED 0x2D
665 #define HCI_ERR_CHAN_CLASSIF_NOT_SUPPORTED 0x2E
666 #define HCI_ERR_INSUFFCIENT_SECURITY 0x2F
667 #define HCI_ERR_PARAM_OUT_OF_RANGE 0x30
668 #define HCI_ERR_UNDEFINED_0x31 0x31
669 #define HCI_ERR_ROLE_SWITCH_PENDING 0x32
670 #define HCI_ERR_UNDEFINED_0x33 0x33
671 #define HCI_ERR_RESERVED_SLOT_VIOLATION 0x34
672 #define HCI_ERR_ROLE_SWITCH_FAILED 0x35
673 #define HCI_ERR_INQ_RSP_DATA_TOO_LARGE 0x36
674 #define HCI_ERR_SIMPLE_PAIRING_NOT_SUPPORTED 0x37
675 #define HCI_ERR_HOST_BUSY_PAIRING 0x38
676 #define HCI_ERR_REJ_NO_SUITABLE_CHANNEL 0x39
677 #define HCI_ERR_CONTROLLER_BUSY 0x3A
678 #define HCI_ERR_UNACCEPT_CONN_INTERVAL 0x3B
679 #define HCI_ERR_ADVERTISING_TIMEOUT 0x3C
680 #define HCI_ERR_CONN_TOUT_DUE_TO_MIC_FAILURE 0x3D
681 #define HCI_ERR_CONN_FAILED_ESTABLISHMENT 0x3E
682 #define HCI_ERR_LIMIT_REACHED 0x43
683 #define HCI_ERR_MAC_CONNECTION_FAILED 0x3F
684 
685 /* ConnectionLess Broadcast errors */
686 #define HCI_ERR_LT_ADDR_ALREADY_IN_USE 0x40
687 #define HCI_ERR_LT_ADDR_NOT_ALLOCATED 0x41
688 #define HCI_ERR_CLB_NOT_ENABLED 0x42
689 #define HCI_ERR_CLB_DATA_TOO_BIG 0x43
690 
691 #define HCI_ERR_MAX_ERR 0x43
692 
693 #define HCI_HINT_TO_RECREATE_AMP_PHYS_LINK 0xFF
694 
695 /*
696  * Definitions for HCI enable event
697 */
698 #define HCI_INQUIRY_COMPLETE_EV(p) (*((uint32_t*)(p)) & 0x00000001)
699 #define HCI_INQUIRY_RESULT_EV(p) (*((uint32_t*)(p)) & 0x00000002)
700 #define HCI_CONNECTION_COMPLETE_EV(p) (*((uint32_t*)(p)) & 0x00000004)
701 #define HCI_CONNECTION_REQUEST_EV(p) (*((uint32_t*)(p)) & 0x00000008)
702 #define HCI_DISCONNECTION_COMPLETE_EV(p) (*((uint32_t*)(p)) & 0x00000010)
703 #define HCI_AUTHENTICATION_COMPLETE_EV(p) (*((uint32_t*)(p)) & 0x00000020)
704 #define HCI_RMT_NAME_REQUEST_COMPL_EV(p) (*((uint32_t*)(p)) & 0x00000040)
705 #define HCI_CHANGE_CONN_ENCRPT_ENABLE_EV(p) (*((uint32_t*)(p)) & 0x00000080)
706 #define HCI_CHANGE_CONN_LINK_KEY_EV(p) (*((uint32_t*)(p)) & 0x00000100)
707 #define HCI_MASTER_LINK_KEY_COMPLETE_EV(p) (*((uint32_t*)(p)) & 0x00000200)
708 #define HCI_READ_RMT_FEATURES_COMPL_EV(p) (*((uint32_t*)(p)) & 0x00000400)
709 #define HCI_READ_RMT_VERSION_COMPL_EV(p) (*((uint32_t*)(p)) & 0x00000800)
710 #define HCI_QOS_SETUP_COMPLETE_EV(p) (*((uint32_t*)(p)) & 0x00001000)
711 #define HCI_COMMAND_COMPLETE_EV(p) (*((uint32_t*)(p)) & 0x00002000)
712 #define HCI_COMMAND_STATUS_EV(p) (*((uint32_t*)(p)) & 0x00004000)
713 #define HCI_HARDWARE_ERROR_EV(p) (*((uint32_t*)(p)) & 0x00008000)
714 #define HCI_FLASH_OCCURED_EV(p) (*((uint32_t*)(p)) & 0x00010000)
715 #define HCI_ROLE_CHANGE_EV(p) (*((uint32_t*)(p)) & 0x00020000)
716 #define HCI_NUM_COMPLETED_PKTS_EV(p) (*((uint32_t*)(p)) & 0x00040000)
717 #define HCI_MODE_CHANGE_EV(p) (*((uint32_t*)(p)) & 0x00080000)
718 #define HCI_RETURN_LINK_KEYS_EV(p) (*((uint32_t*)(p)) & 0x00100000)
719 #define HCI_PIN_CODE_REQUEST_EV(p) (*((uint32_t*)(p)) & 0x00200000)
720 #define HCI_LINK_KEY_REQUEST_EV(p) (*((uint32_t*)(p)) & 0x00400000)
721 #define HCI_LINK_KEY_NOTIFICATION_EV(p) (*((uint32_t*)(p)) & 0x00800000)
722 #define HCI_LOOPBACK_COMMAND_EV(p) (*((uint32_t*)(p)) & 0x01000000)
723 #define HCI_DATA_BUF_OVERFLOW_EV(p) (*((uint32_t*)(p)) & 0x02000000)
724 #define HCI_MAX_SLOTS_CHANGE_EV(p) (*((uint32_t*)(p)) & 0x04000000)
725 #define HCI_READ_CLOCK_OFFSET_COMP_EV(p) (*((uint32_t*)(p)) & 0x08000000)
726 #define HCI_CONN_PKT_TYPE_CHANGED_EV(p) (*((uint32_t*)(p)) & 0x10000000)
727 #define HCI_QOS_VIOLATION_EV(p) (*((uint32_t*)(p)) & 0x20000000)
728 #define HCI_PAGE_SCAN_MODE_CHANGED_EV(p) (*((uint32_t*)(p)) & 0x40000000)
729 #define HCI_PAGE_SCAN_REP_MODE_CHNG_EV(p) (*((uint32_t*)(p)) & 0x80000000)
730 
731 /* the default event mask for 2.1+EDR (Lisbon) does not include Lisbon events */
732 #define HCI_DEFAULT_EVENT_MASK_0 0xFFFFFFFF
733 #define HCI_DEFAULT_EVENT_MASK_1 0x00001FFF
734 
735 /* the event mask for 2.0 + EDR and later (includes Lisbon events) */
736 #define HCI_LISBON_EVENT_MASK_0 0xFFFFFFFF
737 #define HCI_LISBON_EVENT_MASK_1 0x1DBFFFFF
738 #define HCI_LISBON_EVENT_MASK \
739   { 0x0D, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
740 #define HCI_LISBON_EVENT_MASK_EXT \
741   { 0x1D, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
742 #define HCI_DUMO_EVENT_MASK_EXT \
743   { 0x3D, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }
744 /*  0x00001FFF FFFFFFFF Default - no Lisbon events
745     0x00000800 00000000 Synchronous Connection Complete Event
746     0x00001000 00000000 Synchronous Connection Changed Event
747     0x00002000 00000000 Sniff Subrate Event
748     0x00004000 00000000 Extended Inquiry Result Event
749     0x00008000 00000000 Encryption Key Refresh Complete Event
750     0x00010000 00000000 IO Capability Request Event
751     0x00020000 00000000 IO Capability Response Event
752     0x00040000 00000000 User Confirmation Request Event
753     0x00080000 00000000 User Passkey Request Event
754     0x00100000 00000000 Remote OOB Data Request Event
755     0x00200000 00000000 Simple Pairing Complete Event
756     0x00400000 00000000 Generic AMP Link Key Notification Event
757     0x00800000 00000000 Link Supervision Timeout Changed Event
758     0x01000000 00000000 Enhanced Flush Complete Event
759     0x04000000 00000000 User Passkey Notification Event
760     0x08000000 00000000 Keypress Notification Event
761     0x10000000 00000000 Remote Host Supported Features Notification Event
762     0x20000000 00000000 LE Meta Event
763  */
764 
765 /* the event mask for AMP controllers */
766 #define HCI_AMP_EVENT_MASK_3_0 "\x00\x00\x00\x00\x00\x00\x3F\xFF"
767 
768 /*  0x0000000000000000 No events specified (default)
769     0x0000000000000001 Physical Link Complete Event
770     0x0000000000000002 Channel Selected Event
771     0x0000000000000004 Disconnection Physical Link Event
772     0x0000000000000008 Physical Link Loss Early Warning Event
773     0x0000000000000010 Physical Link Recovery Event
774     0x0000000000000020 Logical Link Complete Event
775     0x0000000000000040 Disconnection Logical Link Complete Event
776     0x0000000000000080 Flow Spec Modify Complete Event
777     0x0000000000000100 Number of Completed Data Blocks Event
778     0x0000000000000200 AMP Start Test Event
779     0x0000000000000400 AMP Test End Event
780     0x0000000000000800 AMP Receiver Report Event
781     0x0000000000001000 Short Range Mode Change Complete Event
782     0x0000000000002000 AMP Status Change Event
783 */
784 
785 /* the event mask page 2 (CLB + CSA4) for BR/EDR controller */
786 #define HCI_PAGE_2_EVENT_MASK "\x00\x00\x00\x00\x00\x7F\xC0\x00"
787 /*  0x0000000000004000 Triggered Clock Capture Event
788     0x0000000000008000 Sync Train Complete Event
789     0x0000000000010000 Sync Train Received Event
790     0x0000000000020000 Connectionless Broadcast Receive Event
791     0x0000000000040000 Connectionless Broadcast Timeout Event
792     0x0000000000080000 Truncated Page Complete Event
793     0x0000000000100000 Salve Page Response Timeout Event
794     0x0000000000200000 Connectionless Broadcast Channel Map Change Event
795     0x0000000000400000 Inquiry Response Notification Event
796 */
797 
798 /*
799  * Definitions for packet type masks (BT1.2 and BT2.0 definitions)
800 */
801 #define HCI_PKT_TYPES_MASK_NO_2_DH1 0x0002
802 #define HCI_PKT_TYPES_MASK_NO_3_DH1 0x0004
803 #define HCI_PKT_TYPES_MASK_DM1 0x0008
804 #define HCI_PKT_TYPES_MASK_DH1 0x0010
805 #define HCI_PKT_TYPES_MASK_HV1 0x0020
806 #define HCI_PKT_TYPES_MASK_HV2 0x0040
807 #define HCI_PKT_TYPES_MASK_HV3 0x0080
808 #define HCI_PKT_TYPES_MASK_NO_2_DH3 0x0100
809 #define HCI_PKT_TYPES_MASK_NO_3_DH3 0x0200
810 #define HCI_PKT_TYPES_MASK_DM3 0x0400
811 #define HCI_PKT_TYPES_MASK_DH3 0x0800
812 #define HCI_PKT_TYPES_MASK_NO_2_DH5 0x1000
813 #define HCI_PKT_TYPES_MASK_NO_3_DH5 0x2000
814 #define HCI_PKT_TYPES_MASK_DM5 0x4000
815 #define HCI_PKT_TYPES_MASK_DH5 0x8000
816 
817 /* Packet type should be one of valid but at least one should be specified */
818 #define HCI_VALID_SCO_PKT_TYPE(t)                         \
819   (((((t) &                                               \
820       ~(HCI_PKT_TYPES_MASK_HV1 | HCI_PKT_TYPES_MASK_HV2 | \
821         HCI_PKT_TYPES_MASK_HV3)) == 0)) &&                \
822    ((t) != 0))
823 
824 /* Packet type should not be invalid and at least one should be specified */
825 #define HCI_VALID_ACL_PKT_TYPE(t)                                             \
826   (((((t) &                                                                   \
827       ~(HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1 |                     \
828         HCI_PKT_TYPES_MASK_DM3 | HCI_PKT_TYPES_MASK_DH3 |                     \
829         HCI_PKT_TYPES_MASK_DM5 | HCI_PKT_TYPES_MASK_DH5 |                     \
830         HCI_PKT_TYPES_MASK_NO_2_DH1 | HCI_PKT_TYPES_MASK_NO_3_DH1 |           \
831         HCI_PKT_TYPES_MASK_NO_2_DH3 | HCI_PKT_TYPES_MASK_NO_3_DH3 |           \
832         HCI_PKT_TYPES_MASK_NO_2_DH5 | HCI_PKT_TYPES_MASK_NO_3_DH5)) == 0)) && \
833    (((t) & (HCI_PKT_TYPES_MASK_DM1 | HCI_PKT_TYPES_MASK_DH1 |                 \
834             HCI_PKT_TYPES_MASK_DM3 | HCI_PKT_TYPES_MASK_DH3 |                 \
835             HCI_PKT_TYPES_MASK_DM5 | HCI_PKT_TYPES_MASK_DH5)) != 0))
836 
837 /* Packet type should be one of valid but at least one should be specified for
838  * 1.2 */
839 #define HCI_VALID_ESCO_PKT_TYPE(t)                                           \
840   (((((t) &                                                                  \
841       ~(HCI_ESCO_PKT_TYPES_MASK_EV3 | HCI_ESCO_PKT_TYPES_MASK_EV4 |          \
842         HCI_ESCO_PKT_TYPES_MASK_EV5)) == 0)) &&                              \
843    ((t) != 0)) /* Packet type should be one of valid but at least one should \
844                   be specified */
845 
846 #define HCI_VALID_ESCO_SCOPKT_TYPE(t)                           \
847   (((((t) &                                                     \
848       ~(ESCO_PKT_TYPES_MASK_HV1 | HCI_ESCO_PKT_TYPES_MASK_HV2 | \
849         HCI_ESCO_PKT_TYPES_MASK_HV3)) == 0)) &&                 \
850    ((t) != 0))
851 
852 #define HCI_VALID_SCO_ALL_PKT_TYPE(t)                                         \
853   (((((t) &                                                                   \
854       ~(ESCO_PKT_TYPES_MASK_HV1 | HCI_ESCO_PKT_TYPES_MASK_HV2 |               \
855         HCI_ESCO_PKT_TYPES_MASK_HV3 | HCI_ESCO_PKT_TYPES_MASK_EV3 |           \
856         HCI_ESCO_PKT_TYPES_MASK_EV4 | HCI_ESCO_PKT_TYPES_MASK_EV5)) == 0)) && \
857    ((t) != 0))
858 
859 /*
860  * Define parameters to allow role switch during create connection
861 */
862 #define HCI_CR_CONN_NOT_ALLOW_SWITCH 0x00
863 #define HCI_CR_CONN_ALLOW_SWITCH 0x01
864 
865 /*
866  * Hold Mode command destination
867 */
868 #define HOLD_MODE_DEST_LOCAL_DEVICE 0x00
869 #define HOLD_MODE_DEST_RMT_DEVICE 0x01
870 
871 /*
872  *  Definitions for different HCI parameters
873 */
874 #define HCI_PER_INQ_MIN_MAX_PERIOD 0x0003
875 #define HCI_PER_INQ_MAX_MAX_PERIOD 0xFFFF
876 #define HCI_PER_INQ_MIN_MIN_PERIOD 0x0002
877 #define HCI_PER_INQ_MAX_MIN_PERIOD 0xFFFE
878 
879 #define HCI_MAX_INQUIRY_LENGTH 0x30
880 
881 #define HCI_MIN_INQ_LAP 0x9E8B00
882 #define HCI_MAX_INQ_LAP 0x9E8B3F
883 
884 /* HCI role defenitions */
885 #define HCI_ROLE_MASTER 0x00
886 #define HCI_ROLE_SLAVE 0x01
887 #define HCI_ROLE_UNKNOWN 0xff
888 
889 /* HCI mode defenitions */
890 #define HCI_MODE_ACTIVE 0x00
891 #define HCI_MODE_HOLD 0x01
892 #define HCI_MODE_SNIFF 0x02
893 #define HCI_MODE_PARK 0x03
894 
895 /* HCI Flow Control Mode defenitions */
896 #define HCI_PACKET_BASED_FC_MODE 0x00
897 #define HCI_BLOCK_BASED_FC_MODE 0x01
898 
899 /* Define Packet types as requested by the Host */
900 #define HCI_ACL_PKT_TYPE_NONE 0x0000
901 #define HCI_ACL_PKT_TYPE_DM1 0x0008
902 #define HCI_ACL_PKT_TYPE_DH1 0x0010
903 #define HCI_ACL_PKT_TYPE_AUX1 0x0200
904 #define HCI_ACL_PKT_TYPE_DM3 0x0400
905 #define HCI_ACL_PKT_TYPE_DH3 0x0800
906 #define HCI_ACL_PKT_TYPE_DM5 0x4000
907 #define HCI_ACL_PKT_TYPE_DH5 0x8000
908 
909 /* Define key type in the Master Link Key command */
910 #define HCI_USE_SEMI_PERMANENT_KEY 0x00
911 #define HCI_USE_TEMPORARY_KEY 0x01
912 
913 /* Page scan period modes */
914 #define HCI_PAGE_SCAN_REP_MODE_R0 0x00
915 #define HCI_PAGE_SCAN_REP_MODE_R1 0x01
916 #define HCI_PAGE_SCAN_REP_MODE_R2 0x02
917 
918 /* Define limits for page scan repetition modes */
919 #define HCI_PAGE_SCAN_R1_LIMIT 0x0800
920 #define HCI_PAGE_SCAN_R2_LIMIT 0x1000
921 
922 /* Page scan period modes */
923 #define HCI_PAGE_SCAN_PER_MODE_P0 0x00
924 #define HCI_PAGE_SCAN_PER_MODE_P1 0x01
925 #define HCI_PAGE_SCAN_PER_MODE_P2 0x02
926 
927 /* Page scan modes */
928 #define HCI_MANDATARY_PAGE_SCAN_MODE 0x00
929 #define HCI_OPTIONAL_PAGE_SCAN_MODE1 0x01
930 #define HCI_OPTIONAL_PAGE_SCAN_MODE2 0x02
931 #define HCI_OPTIONAL_PAGE_SCAN_MODE3 0x03
932 
933 /* Page and inquiry scan types */
934 #define HCI_SCAN_TYPE_STANDARD 0x00
935 #define HCI_SCAN_TYPE_INTERLACED 0x01 /* 1.2 devices or later */
936 #define HCI_DEF_SCAN_TYPE HCI_SCAN_TYPE_STANDARD
937 
938 /* Definitions for quality of service service types */
939 #define HCI_SERVICE_NO_TRAFFIC 0x00
940 #define HCI_SERVICE_BEST_EFFORT 0x01
941 #define HCI_SERVICE_GUARANTEED 0x02
942 
943 #define HCI_QOS_LATENCY_DO_NOT_CARE 0xFFFFFFFF
944 #define HCI_QOS_DELAY_DO_NOT_CARE 0xFFFFFFFF
945 
946 /* Definitions for Flow Specification */
947 #define HCI_FLOW_SPEC_LATENCY_DO_NOT_CARE 0xFFFFFFFF
948 
949 /* Definitions for AFH Channel Map */
950 #define HCI_AFH_CHANNEL_MAP_LEN 10
951 
952 /* Definitions for Extended Inquiry Response */
953 #define HCI_EXT_INQ_RESPONSE_LEN 240
954 #define HCI_EIR_FLAGS_TYPE BT_EIR_FLAGS_TYPE
955 #define HCI_EIR_MORE_16BITS_UUID_TYPE BT_EIR_MORE_16BITS_UUID_TYPE
956 #define HCI_EIR_COMPLETE_16BITS_UUID_TYPE BT_EIR_COMPLETE_16BITS_UUID_TYPE
957 #define HCI_EIR_MORE_32BITS_UUID_TYPE BT_EIR_MORE_32BITS_UUID_TYPE
958 #define HCI_EIR_COMPLETE_32BITS_UUID_TYPE BT_EIR_COMPLETE_32BITS_UUID_TYPE
959 #define HCI_EIR_MORE_128BITS_UUID_TYPE BT_EIR_MORE_128BITS_UUID_TYPE
960 #define HCI_EIR_COMPLETE_128BITS_UUID_TYPE BT_EIR_COMPLETE_128BITS_UUID_TYPE
961 #define HCI_EIR_SHORTENED_LOCAL_NAME_TYPE BT_EIR_SHORTENED_LOCAL_NAME_TYPE
962 #define HCI_EIR_COMPLETE_LOCAL_NAME_TYPE BT_EIR_COMPLETE_LOCAL_NAME_TYPE
963 #define HCI_EIR_TX_POWER_LEVEL_TYPE BT_EIR_TX_POWER_LEVEL_TYPE
964 #define HCI_EIR_MANUFACTURER_SPECIFIC_TYPE BT_EIR_MANUFACTURER_SPECIFIC_TYPE
965 #define HCI_EIR_SERVICE_DATA_TYPE BT_EIR_SERVICE_DATA_TYPE
966 #define HCI_EIR_SERVICE_DATA_16BITS_UUID_TYPE \
967   BT_EIR_SERVICE_DATA_16BITS_UUID_TYPE
968 #define HCI_EIR_SERVICE_DATA_32BITS_UUID_TYPE \
969   BT_EIR_SERVICE_DATA_32BITS_UUID_TYPE
970 #define HCI_EIR_SERVICE_DATA_128BITS_UUID_TYPE \
971   BT_EIR_SERVICE_DATA_128BITS_UUID_TYPE
972 #define HCI_EIR_OOB_BD_ADDR_TYPE BT_EIR_OOB_BD_ADDR_TYPE
973 #define HCI_EIR_OOB_COD_TYPE BT_EIR_OOB_COD_TYPE
974 #define HCI_EIR_OOB_SSP_HASH_C_TYPE BT_EIR_OOB_SSP_HASH_C_TYPE
975 #define HCI_EIR_OOB_SSP_RAND_R_TYPE BT_EIR_OOB_SSP_RAND_R_TYPE
976 
977 /* Definitions for Write Simple Pairing Mode */
978 #define HCI_SP_MODE_UNDEFINED 0x00
979 #define HCI_SP_MODE_ENABLED 0x01
980 
981 /* Definitions for Write Simple Pairing Debug Mode */
982 #define HCI_SPD_MODE_DISABLED 0x00
983 #define HCI_SPD_MODE_ENABLED 0x01
984 
985 /* Definitions for Write Secure Connections Host Support */
986 #define HCI_SC_MODE_DISABLED 0x00
987 #define HCI_SC_MODE_ENABLED 0x01
988 
989 /* Definitions for IO Capability Response/Command */
990 #define HCI_IO_CAP_DISPLAY_ONLY 0x00
991 #define HCI_IO_CAP_DISPLAY_YESNO 0x01
992 #define HCI_IO_CAP_KEYBOARD_ONLY 0x02
993 #define HCI_IO_CAP_NO_IO 0x03
994 
995 #define HCI_OOB_AUTH_DATA_NOT_PRESENT 0x00
996 #define HCI_OOB_REM_AUTH_DATA_PRESENT 0x01
997 
998 #define HCI_MITM_PROTECT_NOT_REQUIRED 0x00
999 #define HCI_MITM_PROTECT_REQUIRED 0x01
1000 
1001 /* Policy settings status */
1002 #define HCI_DISABLE_ALL_LM_MODES 0x0000
1003 #define HCI_ENABLE_MASTER_SLAVE_SWITCH 0x0001
1004 #define HCI_ENABLE_HOLD_MODE 0x0002
1005 #define HCI_ENABLE_SNIFF_MODE 0x0004
1006 #define HCI_ENABLE_PARK_MODE 0x0008
1007 
1008 /* By default allow switch, because host can not allow that */
1009 /* that until it created the connection */
1010 #define HCI_DEFAULT_POLICY_SETTINGS HCI_DISABLE_ALL_LM_MODES
1011 
1012 /* Filters that are sent in set filter command */
1013 #define HCI_FILTER_TYPE_CLEAR_ALL 0x00
1014 #define HCI_FILTER_INQUIRY_RESULT 0x01
1015 #define HCI_FILTER_CONNECTION_SETUP 0x02
1016 
1017 #define HCI_FILTER_COND_NEW_DEVICE 0x00
1018 #define HCI_FILTER_COND_DEVICE_CLASS 0x01
1019 #define HCI_FILTER_COND_BD_ADDR 0x02
1020 
1021 #define HCI_DO_NOT_AUTO_ACCEPT_CONNECT 1
1022 /* role switch disabled */
1023 #define HCI_DO_AUTO_ACCEPT_CONNECT 2
1024 /* role switch enabled (1.1 errata 1115) */
1025 #define HCI_DO_AUTO_ACCEPT_CONNECT_RS 3
1026 
1027 /* Auto accept flags */
1028 #define HCI_AUTO_ACCEPT_OFF 0x00
1029 #define HCI_AUTO_ACCEPT_ACL_CONNECTIONS 0x01
1030 #define HCI_AUTO_ACCEPT_SCO_CONNECTIONS 0x02
1031 
1032 /* PIN type */
1033 #define HCI_PIN_TYPE_VARIABLE 0
1034 #define HCI_PIN_TYPE_FIXED 1
1035 
1036 /* Loopback Modes */
1037 #define HCI_LOOPBACK_MODE_DISABLED 0
1038 #define HCI_LOOPBACK_MODE_LOCAL 1
1039 #define HCI_LOOPBACK_MODE_REMOTE 2
1040 
1041 #define SLOTS_PER_10MS 16 /* 0.625 ms slots in a 10 ms tick */
1042 
1043 /* Maximum connection accept timeout in 0.625msec */
1044 #define HCI_MAX_CONN_ACCEPT_TOUT 0xB540 /* 29 sec */
1045 #define HCI_DEF_CONN_ACCEPT_TOUT 0x1F40 /* 5 sec */
1046 
1047 /* Page timeout is used in LC only and LC is counting down slots not using OS */
1048 #define HCI_DEFAULT_PAGE_TOUT 0x2000 /* 5.12 sec (in slots) */
1049 
1050 /* Scan enable flags */
1051 #define HCI_NO_SCAN_ENABLED 0x00
1052 #define HCI_INQUIRY_SCAN_ENABLED 0x01
1053 #define HCI_PAGE_SCAN_ENABLED 0x02
1054 
1055 /* Pagescan timer definitions in 0.625 ms */
1056 #define HCI_MIN_PAGESCAN_INTERVAL 0x12   /* 11.25 ms */
1057 #define HCI_MAX_PAGESCAN_INTERVAL 0x1000 /* 2.56 sec */
1058 #define HCI_DEF_PAGESCAN_INTERVAL 0x0800 /* 1.28 sec */
1059 
1060 /* Parameter for pagescan window is passed to LC and is kept in slots */
1061 #define HCI_MIN_PAGESCAN_WINDOW 0x11   /* 10.625 ms */
1062 #define HCI_MAX_PAGESCAN_WINDOW 0x1000 /* 2.56  sec */
1063 #define HCI_DEF_PAGESCAN_WINDOW 0x12   /* 11.25 ms  */
1064 
1065 /* Inquiryscan timer definitions in 0.625 ms */
1066 #define HCI_MIN_INQUIRYSCAN_INTERVAL 0x12   /* 11.25 ms */
1067 #define HCI_MAX_INQUIRYSCAN_INTERVAL 0x1000 /* 2.56 sec */
1068 #define HCI_DEF_INQUIRYSCAN_INTERVAL 0x1000 /* 2.56 sec */
1069 
1070 /* Parameter for inquiryscan window is passed to LC and is kept in slots */
1071 #define HCI_MIN_INQUIRYSCAN_WINDOW 0x11   /* 10.625 ms */
1072 #define HCI_MAX_INQUIRYSCAN_WINDOW 0x1000 /* 2.56 sec */
1073 #define HCI_DEF_INQUIRYSCAN_WINDOW 0x12   /* 11.25 ms */
1074 
1075 /* Encryption modes */
1076 #define HCI_ENCRYPT_MODE_DISABLED 0x00
1077 #define HCI_ENCRYPT_MODE_POINT_TO_POINT 0x01
1078 #define HCI_ENCRYPT_MODE_ALL 0x02
1079 
1080 /* Voice settings */
1081 #define HCI_INP_CODING_LINEAR 0x0000 /* 0000000000 */
1082 #define HCI_INP_CODING_U_LAW 0x0100  /* 0100000000 */
1083 #define HCI_INP_CODING_A_LAW 0x0200  /* 1000000000 */
1084 #define HCI_INP_CODING_MASK 0x0300   /* 1100000000 */
1085 
1086 #define HCI_INP_DATA_FMT_1S_COMPLEMENT 0x0000  /* 0000000000 */
1087 #define HCI_INP_DATA_FMT_2S_COMPLEMENT 0x0040  /* 0001000000 */
1088 #define HCI_INP_DATA_FMT_SIGN_MAGNITUDE 0x0080 /* 0010000000 */
1089 #define HCI_INP_DATA_FMT_UNSIGNED 0x00c0       /* 0011000000 */
1090 #define HCI_INP_DATA_FMT_MASK 0x00c0           /* 0011000000 */
1091 
1092 #define HCI_INP_SAMPLE_SIZE_8BIT 0x0000  /* 0000000000 */
1093 #define HCI_INP_SAMPLE_SIZE_16BIT 0x0020 /* 0000100000 */
1094 #define HCI_INP_SAMPLE_SIZE_MASK 0x0020  /* 0000100000 */
1095 
1096 #define HCI_INP_LINEAR_PCM_BIT_POS_MASK 0x001c /* 0000011100 */
1097 #define HCI_INP_LINEAR_PCM_BIT_POS_OFFS 2
1098 
1099 #define HCI_AIR_CODING_FORMAT_CVSD 0x0000     /* 0000000000 */
1100 #define HCI_AIR_CODING_FORMAT_U_LAW 0x0001    /* 0000000001 */
1101 #define HCI_AIR_CODING_FORMAT_A_LAW 0x0002    /* 0000000010 */
1102 #define HCI_AIR_CODING_FORMAT_TRANSPNT 0x0003 /* 0000000011 */
1103 #define HCI_AIR_CODING_FORMAT_MASK 0x0003     /* 0000000011 */
1104 
1105 /* default                                        0001100000 */
1106 #define HCI_DEFAULT_VOICE_SETTINGS                          \
1107   (HCI_INP_CODING_LINEAR | HCI_INP_DATA_FMT_2S_COMPLEMENT | \
1108    HCI_INP_SAMPLE_SIZE_16BIT | HCI_AIR_CODING_FORMAT_CVSD)
1109 
1110 #define HCI_CVSD_SUPPORTED(x) \
1111   (((x)&HCI_AIR_CODING_FORMAT_MASK) == HCI_AIR_CODING_FORMAT_CVSD)
1112 #define HCI_U_LAW_SUPPORTED(x) \
1113   (((x)&HCI_AIR_CODING_FORMAT_MASK) == HCI_AIR_CODING_FORMAT_U_LAW)
1114 #define HCI_A_LAW_SUPPORTED(x) \
1115   (((x)&HCI_AIR_CODING_FORMAT_MASK) == HCI_AIR_CODING_FORMAT_A_LAW)
1116 #define HCI_TRANSPNT_SUPPORTED(x) \
1117   (((x)&HCI_AIR_CODING_FORMAT_MASK) == HCI_AIR_CODING_FORMAT_TRANSPNT)
1118 
1119 /* Retransmit timer definitions in 0.625 */
1120 #define HCI_MAX_AUTOMATIC_FLUSH_TIMEOUT 0x07FF
1121 #define HCI_DEFAULT_AUTOMATIC_FLUSH_TIMEOUT 0 /* No auto flush */
1122 
1123 /* Broadcast retransmitions */
1124 #define HCI_DEFAULT_NUM_BCAST_RETRAN 1
1125 
1126 /* Define broadcast data types as passed in the hci data packet */
1127 #define HCI_DATA_POINT_TO_POINT 0x00
1128 #define HCI_DATA_ACTIVE_BCAST 0x01
1129 #define HCI_DATA_PICONET_BCAST 0x02
1130 
1131 /* Hold mode activity */
1132 #define HCI_MAINTAIN_CUR_POWER_STATE 0x00
1133 #define HCI_SUSPEND_PAGE_SCAN 0x01
1134 #define HCI_SUSPEND_INQUIRY_SCAN 0x02
1135 #define HCI_SUSPEND_PERIODIC_INQUIRIES 0x04
1136 
1137 /* Default Link Supervision timeoout */
1138 #define HCI_DEFAULT_INACT_TOUT 0x7D00     /* BR/EDR (20 seconds) */
1139 #define HCI_DEFAULT_AMP_INACT_TOUT 0x3E80 /* AMP    (10 seconds) */
1140 
1141 /* Read transmit power level parameter */
1142 #define HCI_READ_CURRENT 0x00
1143 #define HCI_READ_MAXIMUM 0x01
1144 
1145 /* Link types for connection complete event */
1146 #define HCI_LINK_TYPE_SCO 0x00
1147 #define HCI_LINK_TYPE_ACL 0x01
1148 #define HCI_LINK_TYPE_ESCO 0x02
1149 
1150 /* Link Key Notification Event (Key Type) definitions */
1151 #define HCI_LKEY_TYPE_COMBINATION 0x00
1152 #define HCI_LKEY_TYPE_LOCAL_UNIT 0x01
1153 #define HCI_LKEY_TYPE_REMOTE_UNIT 0x02
1154 #define HCI_LKEY_TYPE_DEBUG_COMB 0x03
1155 #define HCI_LKEY_TYPE_UNAUTH_COMB 0x04
1156 #define HCI_LKEY_TYPE_AUTH_COMB 0x05
1157 #define HCI_LKEY_TYPE_CHANGED_COMB 0x06
1158 #define HCI_LKEY_TYPE_UNAUTH_COMB_P_256 0x07
1159 #define HCI_LKEY_TYPE_AUTH_COMB_P_256 0x08
1160 
1161 /* Internal definitions - not used over HCI */
1162 #define HCI_LKEY_TYPE_AMP_WIFI 0x80
1163 #define HCI_LKEY_TYPE_AMP_UWB 0x81
1164 #define HCI_LKEY_TYPE_UNKNOWN 0xff
1165 
1166 /* Read Local Version HCI Version return values (Command Complete Event) */
1167 #define HCI_VERSION_1_0B 0x00
1168 #define HCI_VERSION_1_1 0x01
1169 
1170 /* Define an invalid value for a handle */
1171 #define HCI_INVALID_HANDLE 0xFFFF
1172 
1173 /* Define max ammount of data in the HCI command */
1174 #define HCI_COMMAND_SIZE 255
1175 
1176 /* Define the preamble length for all HCI Commands.
1177  * This is 2-bytes for opcode and 1 byte for length
1178 */
1179 #define HCIC_PREAMBLE_SIZE 3
1180 
1181 /* Define the preamble length for all HCI Events
1182  * This is 1-byte for opcode and 1 byte for length
1183 */
1184 #define HCIE_PREAMBLE_SIZE 2
1185 #define HCI_SCO_PREAMBLE_SIZE 3
1186 #define HCI_DATA_PREAMBLE_SIZE 4
1187 
1188 /* local Bluetooth controller id for AMP HCI */
1189 #define LOCAL_BR_EDR_CONTROLLER_ID 0
1190 
1191 /* controller id types for AMP HCI */
1192 #define HCI_CONTROLLER_TYPE_BR_EDR 0
1193 #define HCI_CONTROLLER_TYPE_802_11 1
1194 #define HCI_CONTROLLER_TYPE_ECMA 2
1195 #define HCI_MAX_CONTROLLER_TYPES 3
1196 
1197 /*  ConnectionLess Broadcast */
1198 #define HCI_CLB_DISABLE 0x00
1199 #define HCI_CLB_ENABLE 0x01
1200 
1201 /* ConnectionLess Broadcast Data fragment */
1202 #define HCI_CLB_FRAGMENT_CONT 0x00
1203 #define HCI_CLB_FRAGMENT_START 0x01
1204 #define HCI_CLB_FRAGMENT_END 0x02
1205 #define HCI_CLB_FRAGMENT_SINGLE 0x03
1206 
1207 /* AMP Controller Status codes
1208 */
1209 #define HCI_AMP_CTRLR_PHYSICALLY_DOWN 0
1210 #define HCI_AMP_CTRLR_USABLE_BY_BT 1
1211 #define HCI_AMP_CTRLR_UNUSABLE_FOR_BT 2
1212 #define HCI_AMP_CTRLR_LOW_CAP_FOR_BT 3
1213 #define HCI_AMP_CTRLR_MED_CAP_FOR_BT 4
1214 #define HCI_AMP_CTRLR_HIGH_CAP_FOR_BT 5
1215 #define HCI_AMP_CTRLR_FULL_CAP_FOR_BT 6
1216 
1217 #define HCI_MAX_AMP_STATUS_TYPES 7
1218 
1219 /* Define the extended flow specification fields used by AMP */
1220 typedef struct {
1221   uint8_t id;
1222   uint8_t stype;
1223   uint16_t max_sdu_size;
1224   uint32_t sdu_inter_time;
1225   uint32_t access_latency;
1226   uint32_t flush_timeout;
1227 } tHCI_EXT_FLOW_SPEC;
1228 
1229 /* HCI message type definitions (for H4 messages) */
1230 #define HCIT_TYPE_COMMAND 1
1231 #define HCIT_TYPE_ACL_DATA 2
1232 #define HCIT_TYPE_SCO_DATA 3
1233 #define HCIT_TYPE_EVENT 4
1234 #define HCIT_TYPE_LM_DIAG 7
1235 #define HCIT_TYPE_NFC 16
1236 
1237 #define HCIT_LM_DIAG_LENGTH 63
1238 
1239 /* Parameter information for HCI_BRCM_SET_ACL_PRIORITY */
1240 #define HCI_BRCM_ACL_PRIORITY_PARAM_SIZE 3
1241 #define HCI_BRCM_ACL_PRIORITY_LOW 0x00
1242 #define HCI_BRCM_ACL_PRIORITY_HIGH 0xFF
1243 #define HCI_BRCM_SET_ACL_PRIORITY (0x0057 | HCI_GRP_VENDOR_SPECIFIC)
1244 
1245 /* Define values for LMP Test Control parameters
1246  * Test Scenario, Hopping Mode, Power Control Mode
1247 */
1248 #define LMP_TESTCTL_TESTSC_PAUSE 0
1249 #define LMP_TESTCTL_TESTSC_TXTEST_0 1
1250 #define LMP_TESTCTL_TESTSC_TXTEST_1 2
1251 #define LMP_TESTCTL_TESTSC_TXTEST_1010 3
1252 #define LMP_TESTCTL_TESTSC_PSRND_BITSEQ 4
1253 #define LMP_TESTCTL_TESTSC_CLOSEDLB_ACL 5
1254 #define LMP_TESTCTL_TESTSC_CLOSEDLB_SCO 6
1255 #define LMP_TESTCTL_TESTSC_ACL_NOWHIT 7
1256 #define LMP_TESTCTL_TESTSC_SCO_NOWHIT 8
1257 #define LMP_TESTCTL_TESTSC_TXTEST_11110000 9
1258 #define LMP_TESTCTL_TESTSC_EXITTESTMODE 255
1259 
1260 #define LMP_TESTCTL_HOPMOD_RXTX1FREQ 0
1261 #define LMP_TESTCTL_HOPMOD_HOP_EURUSA 1
1262 #define LMP_TESTCTL_HOPMOD_HOP_JAPAN 2
1263 #define LMP_TESTCTL_HOPMOD_HOP_FRANCE 3
1264 #define LMP_TESTCTL_HOPMOD_HOP_SPAIN 4
1265 #define LMP_TESTCTL_HOPMOD_REDUCED_HOP 5
1266 
1267 #define LMP_TESTCTL_POWCTL_FIXEDTX_OP 0
1268 #define LMP_TESTCTL_POWCTL_ADAPTIVE 1
1269 
1270 #define LMP_COMPID_GOOGLE 0xE0
1271 
1272 // TODO(zachoverflow): remove this once broadcom specific hacks are removed
1273 #define LMP_COMPID_BROADCOM 15
1274 
1275 /*
1276  * Define the packet types in the packet header, and a couple extra
1277 */
1278 #define PKT_TYPE_NULL 0x00
1279 #define PKT_TYPE_POLL 0x01
1280 #define PKT_TYPE_FHS 0x02
1281 #define PKT_TYPE_DM1 0x03
1282 
1283 #define PKT_TYPE_DH1 0x04
1284 #define PKT_TYPE_HV1 0x05
1285 #define PKT_TYPE_HV2 0x06
1286 #define PKT_TYPE_HV3 0x07
1287 #define PKT_TYPE_DV 0x08
1288 #define PKT_TYPE_AUX1 0x09
1289 
1290 #define PKT_TYPE_DM3 0x0a
1291 #define PKT_TYPE_DH3 0x0b
1292 
1293 #define PKT_TYPE_DM5 0x0e
1294 #define PKT_TYPE_DH5 0x0f
1295 
1296 #define PKT_TYPE_ID 0x10 /* Internally used packet types */
1297 #define PKT_TYPE_BAD 0x11
1298 #define PKT_TYPE_NONE 0x12
1299 
1300 /*
1301  * Define packet size
1302 */
1303 #define HCI_DM1_PACKET_SIZE 17
1304 #define HCI_DH1_PACKET_SIZE 27
1305 #define HCI_DM3_PACKET_SIZE 121
1306 #define HCI_DH3_PACKET_SIZE 183
1307 #define HCI_DM5_PACKET_SIZE 224
1308 #define HCI_DH5_PACKET_SIZE 339
1309 #define HCI_AUX1_PACKET_SIZE 29
1310 #define HCI_HV1_PACKET_SIZE 10
1311 #define HCI_HV2_PACKET_SIZE 20
1312 #define HCI_HV3_PACKET_SIZE 30
1313 #define HCI_DV_PACKET_SIZE 9
1314 #define HCI_EDR2_DH1_PACKET_SIZE 54
1315 #define HCI_EDR2_DH3_PACKET_SIZE 367
1316 #define HCI_EDR2_DH5_PACKET_SIZE 679
1317 #define HCI_EDR3_DH1_PACKET_SIZE 83
1318 #define HCI_EDR3_DH3_PACKET_SIZE 552
1319 #define HCI_EDR3_DH5_PACKET_SIZE 1021
1320 
1321 /* Feature Pages */
1322 #define HCI_EXT_FEATURES_PAGE_MAX 3  // Parse feature pages 0-3
1323 
1324 #define HCI_FEATURE_BYTES_PER_PAGE 8
1325 
1326 #define HCI_EXT_FEATURES_SUCCESS_EVT_LEN 13
1327 
1328 #define HCI_FEATURES_KNOWN(x) \
1329   (((x)[0] | (x)[1] | (x)[2] | (x)[3] | (x)[4] | (x)[5] | (x)[6] | (x)[7]) != 0)
1330 
1331 /* LMP features encoding - page 0 */
1332 #define HCI_3_SLOT_PACKETS_SUPPORTED(x) ((x)[0] & 0x01)
1333 #define HCI_5_SLOT_PACKETS_SUPPORTED(x) ((x)[0] & 0x02)
1334 #define HCI_ENCRYPTION_SUPPORTED(x) ((x)[0] & 0x04)
1335 #define HCI_SLOT_OFFSET_SUPPORTED(x) ((x)[0] & 0x08)
1336 #define HCI_TIMING_ACC_SUPPORTED(x) ((x)[0] & 0x10)
1337 #define HCI_SWITCH_SUPPORTED(x) ((x)[0] & 0x20)
1338 #define HCI_HOLD_MODE_SUPPORTED(x) ((x)[0] & 0x40)
1339 #define HCI_SNIFF_MODE_SUPPORTED(x) ((x)[0] & 0x80)
1340 
1341 #define HCI_PARK_MODE_SUPPORTED(x) ((x)[1] & 0x01)
1342 #define HCI_RSSI_SUPPORTED(x) ((x)[1] & 0x02)
1343 #define HCI_CQM_DATA_RATE_SUPPORTED(x) ((x)[1] & 0x04)
1344 #define HCI_SCO_LINK_SUPPORTED(x) ((x)[1] & 0x08)
1345 #define HCI_HV2_PACKETS_SUPPORTED(x) ((x)[1] & 0x10)
1346 #define HCI_HV3_PACKETS_SUPPORTED(x) ((x)[1] & 0x20)
1347 #define HCI_LMP_U_LAW_SUPPORTED(x) ((x)[1] & 0x40)
1348 #define HCI_LMP_A_LAW_SUPPORTED(x) ((x)[1] & 0x80)
1349 
1350 #define HCI_LMP_CVSD_SUPPORTED(x) ((x)[2] & 0x01)
1351 #define HCI_PAGING_SCHEME_SUPPORTED(x) ((x)[2] & 0x02)
1352 #define HCI_POWER_CTRL_SUPPORTED(x) ((x)[2] & 0x04)
1353 #define HCI_LMP_TRANSPNT_SUPPORTED(x) ((x)[2] & 0x08)
1354 #define HCI_FLOW_CTRL_LAG_VALUE(x) (((x)[2] & 0x70) >> 4)
1355 #define HCI_LMP_BCAST_ENC_SUPPORTED(x) ((x)[2] & 0x80)
1356 
1357 #define HCI_LMP_SCATTER_MODE_SUPPORTED(x) ((x)[3] & 0x01)
1358 #define HCI_EDR_ACL_2MPS_SUPPORTED(x) ((x)[3] & 0x02)
1359 #define HCI_EDR_ACL_3MPS_SUPPORTED(x) ((x)[3] & 0x04)
1360 #define HCI_ENHANCED_INQ_SUPPORTED(x) ((x)[3] & 0x08)
1361 #define HCI_LMP_INTERLACED_INQ_SCAN_SUPPORTED(x) ((x)[3] & 0x10)
1362 #define HCI_LMP_INTERLACED_PAGE_SCAN_SUPPORTED(x) ((x)[3] & 0x20)
1363 #define HCI_LMP_INQ_RSSI_SUPPORTED(x) ((x)[3] & 0x40)
1364 #define HCI_ESCO_EV3_SUPPORTED(x) ((x)[3] & 0x80)
1365 
1366 #define HCI_ESCO_EV4_SUPPORTED(x) ((x)[4] & 0x01)
1367 #define HCI_ESCO_EV5_SUPPORTED(x) ((x)[4] & 0x02)
1368 #define HCI_LMP_ABSENCE_MASKS_SUPPORTED(x) ((x)[4] & 0x04)
1369 #define HCI_LMP_AFH_CAP_SLAVE_SUPPORTED(x) ((x)[4] & 0x08)
1370 #define HCI_LMP_AFH_CLASS_SLAVE_SUPPORTED(x) ((x)[4] & 0x10)
1371 #define HCI_BREDR_NOT_SPT_SUPPORTED(x) ((x)[4] & 0x20)
1372 #define HCI_LE_SPT_SUPPORTED(x) ((x)[4] & 0x40)
1373 #define HCI_3_SLOT_EDR_ACL_SUPPORTED(x) ((x)[4] & 0x80)
1374 
1375 #define HCI_5_SLOT_EDR_ACL_SUPPORTED(x) ((x)[5] & 0x01)
1376 #define HCI_SNIFF_SUB_RATE_SUPPORTED(x) ((x)[5] & 0x02)
1377 #define HCI_ATOMIC_ENCRYPT_SUPPORTED(x) ((x)[5] & 0x04)
1378 #define HCI_LMP_AFH_CAP_MASTR_SUPPORTED(x) ((x)[5] & 0x08)
1379 #define HCI_LMP_AFH_CLASS_MASTR_SUPPORTED(x) ((x)[5] & 0x10)
1380 #define HCI_EDR_ESCO_2MPS_SUPPORTED(x) ((x)[5] & 0x20)
1381 #define HCI_EDR_ESCO_3MPS_SUPPORTED(x) ((x)[5] & 0x40)
1382 #define HCI_3_SLOT_EDR_ESCO_SUPPORTED(x) ((x)[5] & 0x80)
1383 
1384 #define HCI_EXT_INQ_RSP_SUPPORTED(x) ((x)[6] & 0x01)
1385 #define HCI_SIMUL_LE_BREDR_SUPPORTED(x) ((x)[6] & 0x02)
1386 #define HCI_ANUM_PIN_CAP_SUPPORTED(x) ((x)[6] & 0x04)
1387 #define HCI_SIMPLE_PAIRING_SUPPORTED(x) ((x)[6] & 0x08)
1388 #define HCI_ENCAP_PDU_SUPPORTED(x) ((x)[6] & 0x10)
1389 #define HCI_ERROR_DATA_SUPPORTED(x) ((x)[6] & 0x20)
1390 /* This feature is causing frequent link drops when doing call switch with
1391  * certain av/hfp headsets */
1392 // TODO: move the disabling somewhere else
1393 #define HCI_NON_FLUSHABLE_PB_SUPPORTED(x) (0)  //((x)[6] & 0x40)
1394 #define HCI_LINK_SUP_TO_EVT_SUPPORTED(x) ((x)[7] & 0x01)
1395 #define HCI_INQ_RESP_TX_SUPPORTED(x) ((x)[7] & 0x02)
1396 #define HCI_LMP_EXTENDED_SUPPORTED(x) ((x)[7] & 0x80)
1397 
1398 /* LMP features encoding - page 1 */
1399 #define HCI_SSP_HOST_SUPPORTED(x) ((x)[0] & 0x01)
1400 #define HCI_LE_HOST_SUPPORTED(x) ((x)[0] & 0x02)
1401 #define HCI_SIMUL_DUMO_HOST_SUPPORTED(x) ((x)[0] & 0x04)
1402 #define HCI_SC_HOST_SUPPORTED(x) ((x)[0] & 0x08)
1403 
1404 /* LMP features encoding - page 2 */
1405 #define HCI_CSB_MASTER_SUPPORTED(x) ((x)[0] & 0x01)
1406 #define HCI_CSB_SLAVE_SUPPORTED(x) ((x)[0] & 0x02)
1407 #define HCI_SYNC_TRAIN_MASTER_SUPPORTED(x) ((x)[0] & 0x04)
1408 #define HCI_SYNC_SCAN_SLAVE_SUPPORTED(x) ((x)[0] & 0x08)
1409 #define HCI_INQ_RESP_NOTIF_SUPPORTED(x) ((x)[0] & 0x10)
1410 
1411 #define HCI_SC_CTRLR_SUPPORTED(x) ((x)[1] & 0x01)
1412 #define HCI_PING_SUPPORTED(x) ((x)[1] & 0x02)
1413 
1414 /*  LE features encoding - page 0 (the only page for now) */
1415 #define HCI_LE_ENCRYPTION_SUPPORTED(x) ((x)[0] & 0x01)
1416 #define HCI_LE_CONN_PARAM_REQ_SUPPORTED(x) ((x)[0] & 0x02)
1417 #define HCI_LE_EXT_REJ_IND_SUPPORTED(x) ((x)[0] & 0x04)
1418 #define HCI_LE_SLAVE_INIT_FEAT_EXC_SUPPORTED(x) ((x)[0] & 0x08)
1419 #define HCI_LE_DATA_LEN_EXT_SUPPORTED(x) ((x)[0] & 0x20)
1420 #define HCI_LE_ENHANCED_PRIVACY_SUPPORTED(x) ((x)[0] & 0x40)
1421 #define HCI_LE_EXT_SCAN_FILTER_POLICY_SUPPORTED(x) ((x)[0] & 0x80)
1422 
1423 #define HCI_LE_2M_PHY_SUPPORTED(x) ((x)[1] & 0x01)
1424 #define HCI_LE_CODED_PHY_SUPPORTED(x) ((x)[1] & 0x08)
1425 #define HCI_LE_EXTENDED_ADVERTISING_SUPPORTED(x) ((x)[1] & 0x10)
1426 #define HCI_LE_PERIODIC_ADVERTISING_SUPPORTED(x) ((x)[1] & 0x20)
1427 
1428 /* Supported Commands*/
1429 #define HCI_NUM_SUPP_COMMANDS_BYTES 64
1430 
1431 #define HCI_INQUIRY_SUPPORTED(x) ((x)[0] & 0x01)
1432 #define HCI_INQUIRY_CANCEL_SUPPORTED(x) ((x)[0] & 0x02)
1433 #define HCI_PERIODIC_INQUIRY_SUPPORTED(x) ((x)[0] & 0x04)
1434 #define HCI_EXIT_PERIODIC_INQUIRY_SUPPORTED(x) ((x)[0] & 0x08)
1435 #define HCI_CREATE_CONN_SUPPORTED(x) ((x)[0] & 0x10)
1436 #define HCI_DISCONNECT_SUPPORTED(x) ((x)[0] & 0x20)
1437 #define HCI_ADD_SCO_CONN_SUPPORTED(x) ((x)[0] & 0x40)
1438 #define HCI_CANCEL_CREATE_CONN_SUPPORTED(x) ((x)[0] & 0x80)
1439 
1440 #define HCI_ACCEPT_CONN_REQUEST_SUPPORTED(x) ((x)[1] & 0x01)
1441 #define HCI_REJECT_CONN_REQUEST_SUPPORTED(x) ((x)[1] & 0x02)
1442 #define HCI_LINK_KEY_REQUEST_REPLY_SUPPORTED(x) ((x)[1] & 0x04)
1443 #define HCI_LINK_KEY_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[1] & 0x08)
1444 #define HCI_PIN_CODE_REQUEST_REPLY_SUPPORTED(x) ((x)[1] & 0x10)
1445 #define HCI_PIN_CODE_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[1] & 0x20)
1446 #define HCI_CHANGE_CONN_PKT_TYPE_SUPPORTED(x) ((x)[1] & 0x40)
1447 #define HCI_AUTH_REQUEST_SUPPORTED(x) ((x)[1] & 0x80)
1448 
1449 #define HCI_SET_CONN_ENCRYPTION_SUPPORTED(x) ((x)[2] & 0x01)
1450 #define HCI_CHANGE_CONN_LINK_KEY_SUPPORTED(x) ((x)[2] & 0x02)
1451 #define HCI_MASTER_LINK_KEY_SUPPORTED(x) ((x)[2] & 0x04)
1452 #define HCI_REMOTE_NAME_REQUEST_SUPPORTED(x) ((x)[2] & 0x08)
1453 #define HCI_CANCEL_REMOTE_NAME_REQUEST_SUPPORTED(x) ((x)[2] & 0x10)
1454 #define HCI_READ_REMOTE_SUPP_FEATURES_SUPPORTED(x) ((x)[2] & 0x20)
1455 #define HCI_READ_REMOTE_EXT_FEATURES_SUPPORTED(x) ((x)[2] & 0x40)
1456 #define HCI_READ_REMOTE_VER_INFO_SUPPORTED(x) ((x)[2] & 0x80)
1457 
1458 #define HCI_READ_CLOCK_OFFSET_SUPPORTED(x) ((x)[3] & 0x01)
1459 #define HCI_READ_LMP_HANDLE_SUPPORTED(x) ((x)[3] & 0x02)
1460 /* rest of bits in 3-rd byte are reserved */
1461 
1462 #define HCI_HOLD_MODE_CMD_SUPPORTED(x) ((x)[4] & 0x02)
1463 #define HCI_SNIFF_MODE_CMD_SUPPORTED(x) ((x)[4] & 0x04)
1464 #define HCI_EXIT_SNIFF_MODE_SUPPORTED(x) ((x)[4] & 0x08)
1465 #define HCI_PARK_STATE_SUPPORTED(x) ((x)[4] & 0x10)
1466 #define HCI_EXIT_PARK_STATE_SUPPORTED(x) ((x)[4] & 0x20)
1467 #define HCI_QOS_SETUP_SUPPORTED(x) ((x)[4] & 0x40)
1468 #define HCI_ROLE_DISCOVERY_SUPPORTED(x) ((x)[4] & 0x80)
1469 
1470 #define HCI_SWITCH_ROLE_SUPPORTED(x) ((x)[5] & 0x01)
1471 #define HCI_READ_LINK_POLICY_SET_SUPPORTED(x) ((x)[5] & 0x02)
1472 #define HCI_WRITE_LINK_POLICY_SET_SUPPORTED(x) ((x)[5] & 0x04)
1473 #define HCI_READ_DEF_LINK_POLICY_SET_SUPPORTED(x) ((x)[5] & 0x08)
1474 #define HCI_WRITE_DEF_LINK_POLICY_SET_SUPPORTED(x) ((x)[5] & 0x10)
1475 #define HCI_FLOW_SPECIFICATION_SUPPORTED(x) ((x)[5] & 0x20)
1476 #define HCI_SET_EVENT_MASK_SUPPORTED(x) ((x)[5] & 0x40)
1477 #define HCI_RESET_SUPPORTED(x) ((x)[5] & 0x80)
1478 
1479 #define HCI_SET_EVENT_FILTER_SUPPORTED(x) ((x)[6] & 0x01)
1480 #define HCI_FLUSH_SUPPORTED(x) ((x)[6] & 0x02)
1481 #define HCI_READ_PIN_TYPE_SUPPORTED(x) ((x)[6] & 0x04)
1482 #define HCI_WRITE_PIN_TYPE_SUPPORTED(x) ((x)[6] & 0x08)
1483 #define HCI_CREATE_NEW_UNIT_KEY_SUPPORTED(x) ((x)[6] & 0x10)
1484 #define HCI_READ_STORED_LINK_KEY_SUPPORTED(x) ((x)[6] & 0x20)
1485 #define HCI_WRITE_STORED_LINK_KEY_SUPPORTED(x) ((x)[6] & 0x40)
1486 #define HCI_DELETE_STORED_LINK_KEY_SUPPORTED(x) ((x)[6] & 0x80)
1487 
1488 #define HCI_WRITE_LOCAL_NAME_SUPPORTED(x) ((x)[7] & 0x01)
1489 #define HCI_READ_LOCAL_NAME_SUPPORTED(x) ((x)[7] & 0x02)
1490 #define HCI_READ_CONN_ACCEPT_TOUT_SUPPORTED(x) ((x)[7] & 0x04)
1491 #define HCI_WRITE_CONN_ACCEPT_TOUT_SUPPORTED(x) ((x)[7] & 0x08)
1492 #define HCI_READ_PAGE_TOUT_SUPPORTED(x) ((x)[7] & 0x10)
1493 #define HCI_WRITE_PAGE_TOUT_SUPPORTED(x) ((x)[7] & 0x20)
1494 #define HCI_READ_SCAN_ENABLE_SUPPORTED(x) ((x)[7] & 0x40)
1495 #define HCI_WRITE_SCAN_ENABLE_SUPPORTED(x) ((x)[7] & 0x80)
1496 
1497 #define HCI_READ_PAGE_SCAN_ACTIVITY_SUPPORTED(x) ((x)[8] & 0x01)
1498 #define HCI_WRITE_PAGE_SCAN_ACTIVITY_SUPPORTED(x) ((x)[8] & 0x02)
1499 #define HCI_READ_INQURIY_SCAN_ACTIVITY_SUPPORTED(x) ((x)[8] & 0x04)
1500 #define HCI_WRITE_INQURIY_SCAN_ACTIVITY_SUPPORTED(x) ((x)[8] & 0x08)
1501 #define HCI_READ_AUTH_ENABLE_SUPPORTED(x) ((x)[8] & 0x10)
1502 #define HCI_WRITE_AUTH_ENABLE_SUPPORTED(x) ((x)[8] & 0x20)
1503 #define HCI_READ_ENCRYPT_ENABLE_SUPPORTED(x) ((x)[8] & 0x40)
1504 #define HCI_WRITE_ENCRYPT_ENABLE_SUPPORTED(x) ((x)[8] & 0x80)
1505 
1506 #define HCI_READ_CLASS_DEVICE_SUPPORTED(x) ((x)[9] & 0x01)
1507 #define HCI_WRITE_CLASS_DEVICE_SUPPORTED(x) ((x)[9] & 0x02)
1508 #define HCI_READ_VOICE_SETTING_SUPPORTED(x) ((x)[9] & 0x04)
1509 #define HCI_WRITE_VOICE_SETTING_SUPPORTED(x) ((x)[9] & 0x08)
1510 #define HCI_READ_AUTOMATIC_FLUSH_TIMEOUT_SUPPORTED(x) ((x)[9] & 0x10)
1511 #define HCI_WRITE_AUTOMATIC_FLUSH_TIMEOUT_SUPPORTED(x) ((x)[9] & 0x20)
1512 #define HCI_READ_NUM_BROAD_RETRANS_SUPPORTED(x) ((x)[9] & 0x40)
1513 #define HCI_WRITE_NUM_BROAD_RETRANS_SUPPORTED(x) ((x)[9] & 0x80)
1514 
1515 #define HCI_READ_HOLD_MODE_ACTIVITY_SUPPORTED(x) ((x)[10] & 0x01)
1516 #define HCI_WRITE_HOLD_MODE_ACTIVITY_SUPPORTED(x) ((x)[10] & 0x02)
1517 #define HCI_READ_TRANS_PWR_LEVEL_SUPPORTED(x) ((x)[10] & 0x04)
1518 #define HCI_READ_SYNCH_FLOW_CTRL_ENABLE_SUPPORTED(x) ((x)[10] & 0x08)
1519 #define HCI_WRITE_SYNCH_FLOW_CTRL_ENABLE_SUPPORTED(x) ((x)[10] & 0x10)
1520 #define HCI_SET_HOST_CTRLR_TO_HOST_FC_SUPPORTED(x) ((x)[10] & 0x20)
1521 #define HCI_HOST_BUFFER_SIZE_SUPPORTED(x) ((x)[10] & 0x40)
1522 #define HCI_HOST_NUM_COMPLETED_PKTS_SUPPORTED(x) ((x)[10] & 0x80)
1523 
1524 #define HCI_READ_LINK_SUP_TOUT_SUPPORTED(x) ((x)[11] & 0x01)
1525 #define HCI_WRITE_LINK_SUP_TOUT_SUPPORTED(x) ((x)[11] & 0x02)
1526 #define HCI_READ_NUM_SUPP_IAC_SUPPORTED(x) ((x)[11] & 0x04)
1527 #define HCI_READ_CURRENT_IAC_LAP_SUPPORTED(x) ((x)[11] & 0x08)
1528 #define HCI_WRITE_CURRENT_IAC_LAP_SUPPORTED(x) ((x)[11] & 0x10)
1529 #define HCI_READ_PAGE_SCAN_PER_MODE_SUPPORTED(x) ((x)[11] & 0x20)
1530 #define HCI_WRITE_PAGE_SCAN_PER_MODE_SUPPORTED(x) ((x)[11] & 0x40)
1531 #define HCI_READ_PAGE_SCAN_MODE_SUPPORTED(x) ((x)[11] & 0x80)
1532 
1533 #define HCI_WRITE_PAGE_SCAN_MODE_SUPPORTED(x) ((x)[12] & 0x01)
1534 #define HCI_SET_AFH_CHNL_CLASS_SUPPORTED(x) ((x)[12] & 0x02)
1535 #define HCI_READ_INQUIRY_SCAN_TYPE_SUPPORTED(x) ((x)[12] & 0x10)
1536 #define HCI_WRITE_INQUIRY_SCAN_TYPE_SUPPORTED(x) ((x)[12] & 0x20)
1537 #define HCI_READ_INQUIRY_MODE_SUPPORTED(x) ((x)[12] & 0x40)
1538 #define HCI_WRITE_INQUIRY_MODE_SUPPORTED(x) ((x)[12] & 0x80)
1539 
1540 #define HCI_READ_PAGE_SCAN_TYPE_SUPPORTED(x) ((x)[13] & 0x01)
1541 #define HCI_WRITE_PAGE_SCAN_TYPE_SUPPORTED(x) ((x)[13] & 0x02)
1542 #define HCI_READ_AFH_CHNL_ASSESS_MODE_SUPPORTED(x) ((x)[13] & 0x04)
1543 #define HCI_WRITE_AFH_CHNL_ASSESS_MODE_SUPPORTED(x) ((x)[13] & 0x08)
1544 
1545 #define HCI_READ_LOCAL_VER_INFO_SUPPORTED(x) ((x)[14] & 0x08)
1546 #define HCI_READ_LOCAL_SUP_CMDS_SUPPORTED(x) ((x)[14] & 0x10)
1547 #define HCI_READ_LOCAL_SUPP_FEATURES_SUPPORTED(x) ((x)[14] & 0x20)
1548 #define HCI_READ_LOCAL_EXT_FEATURES_SUPPORTED(x) ((x)[14] & 0x40)
1549 #define HCI_READ_BUFFER_SIZE_SUPPORTED(x) ((x)[14] & 0x80)
1550 
1551 #define HCI_READ_COUNTRY_CODE_SUPPORTED(x) ((x)[15] & 0x01)
1552 #define HCI_READ_BD_ADDR_SUPPORTED(x) ((x)[15] & 0x02)
1553 #define HCI_READ_FAIL_CONTACT_CNTR_SUPPORTED(x) ((x)[15] & 0x04)
1554 #define HCI_RESET_FAIL_CONTACT_CNTR_SUPPORTED(x) ((x)[15] & 0x08)
1555 #define HCI_GET_LINK_QUALITY_SUPPORTED(x) ((x)[15] & 0x10)
1556 #define HCI_READ_RSSI_SUPPORTED(x) ((x)[15] & 0x20)
1557 #define HCI_READ_AFH_CH_MAP_SUPPORTED(x) ((x)[15] & 0x40)
1558 #define HCI_READ_BD_CLOCK_SUPPORTED(x) ((x)[15] & 0x80)
1559 
1560 #define HCI_READ_LOOPBACK_MODE_SUPPORTED(x) ((x)[16] & 0x01)
1561 #define HCI_WRITE_LOOPBACK_MODE_SUPPORTED(x) ((x)[16] & 0x02)
1562 #define HCI_ENABLE_DEV_UNDER_TEST_SUPPORTED(x) ((x)[16] & 0x04)
1563 #define HCI_SETUP_SYNCH_CONN_SUPPORTED(x) ((x)[16] & 0x08)
1564 #define HCI_ACCEPT_SYNCH_CONN_SUPPORTED(x) ((x)[16] & 0x10)
1565 #define HCI_REJECT_SYNCH_CONN_SUPPORTED(x) ((x)[16] & 0x20)
1566 
1567 #define HCI_READ_EXT_INQUIRY_RESP_SUPPORTED(x) ((x)[17] & 0x01)
1568 #define HCI_WRITE_EXT_INQUIRY_RESP_SUPPORTED(x) ((x)[17] & 0x02)
1569 #define HCI_REFRESH_ENCRYPTION_KEY_SUPPORTED(x) ((x)[17] & 0x04)
1570 #define HCI_SNIFF_SUB_RATE_CMD_SUPPORTED(x) ((x)[17] & 0x10)
1571 #define HCI_READ_SIMPLE_PAIRING_MODE_SUPPORTED(x) ((x)[17] & 0x20)
1572 #define HCI_WRITE_SIMPLE_PAIRING_MODE_SUPPORTED(x) ((x)[17] & 0x40)
1573 #define HCI_READ_LOCAL_OOB_DATA_SUPPORTED(x) ((x)[17] & 0x80)
1574 
1575 #define HCI_READ_INQUIRY_RESPONSE_TX_POWER_SUPPORTED(x) ((x)[18] & 0x01)
1576 #define HCI_WRITE_INQUIRY_RESPONSE_TX_POWER_SUPPORTED(x) ((x)[18] & 0x02)
1577 #define HCI_READ_DEFAULT_ERRONEOUS_DATA_REPORTING_SUPPORTED(x) ((x)[18] & 0x04)
1578 #define HCI_WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING_SUPPORTED(x) ((x)[18] & 0x08)
1579 #define HCI_IO_CAPABILITY_REQUEST_REPLY_SUPPORTED(x) ((x)[18] & 0x80)
1580 
1581 #define HCI_USER_CONFIRMATION_REQUEST_REPLY_SUPPORTED(x) ((x)[19] & 0x01)
1582 #define HCI_USER_CONFIRMATION_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[19] & 0x02)
1583 #define HCI_USER_PASSKEY_REQUEST_REPLY_SUPPORTED(x) ((x)[19] & 0x04)
1584 #define HCI_USER_PASSKEY_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[19] & 0x08)
1585 #define HCI_REMOTE_OOB_DATA_REQUEST_REPLY_SUPPORTED(x) ((x)[19] & 0x10)
1586 #define HCI_WRITE_SIMPLE_PAIRING_DBG_MODE_SUPPORTED(x) ((x)[19] & 0x20)
1587 #define HCI_ENHANCED_FLUSH_SUPPORTED(x) ((x)[19] & 0x40)
1588 #define HCI_REMOTE_OOB_DATA_REQUEST_NEG_REPLY_SUPPORTED(x) ((x)[19] & 0x80)
1589 
1590 #define HCI_SEND_NOTIF_SUPPORTED(x) ((x)[20] & 0x04)
1591 #define HCI_IO_CAP_REQ_NEG_REPLY_SUPPORTED(x) ((x)[20] & 0x08)
1592 #define HCI_READ_ENCR_KEY_SIZE_SUPPORTED(x) ((x)[20] & 0x10)
1593 
1594 #define HCI_CREATE_PHYSICAL_LINK_SUPPORTED(x) ((x)[21] & 0x01)
1595 #define HCI_ACCEPT_PHYSICAL_LINK_SUPPORTED(x) ((x)[21] & 0x02)
1596 #define HCI_DISCONNECT_PHYSICAL_LINK_SUPPORTED(x) ((x)[21] & 0x04)
1597 #define HCI_CREATE_LOGICAL_LINK_SUPPORTED(x) ((x)[21] & 0x08)
1598 #define HCI_ACCEPT_LOGICAL_LINK_SUPPORTED(x) ((x)[21] & 0x10)
1599 #define HCI_DISCONNECT_LOGICAL_LINK_SUPPORTED(x) ((x)[21] & 0x20)
1600 #define HCI_LOGICAL_LINK_CANCEL_SUPPORTED(x) ((x)[21] & 0x40)
1601 #define HCI_FLOW_SPEC_MODIFY_SUPPORTED(x) ((x)[21] & 0x80)
1602 
1603 #define HCI_READ_LOGICAL_LINK_ACCEPT_TIMEOUT_SUPPORTED(x) ((x)[22] & 0x01)
1604 #define HCI_WRITE_LOGICAL_LINK_ACCEPT_TIMEOUT_SUPPORTED(x) ((x)[22] & 0x02)
1605 #define HCI_SET_EVENT_MASK_PAGE_2_SUPPORTED(x) ((x)[22] & 0x04)
1606 #define HCI_READ_LOCATION_DATA_SUPPORTED(x) ((x)[22] & 0x08)
1607 #define HCI_WRITE_LOCATION_DATA_SUPPORTED(x) ((x)[22] & 0x10)
1608 #define HCI_READ_LOCAL_AMP_INFO_SUPPORTED(x) ((x)[22] & 0x20)
1609 #define HCI_READ_LOCAL_AMP_ASSOC_SUPPORTED(x) ((x)[22] & 0x40)
1610 #define HCI_WRITE_REMOTE_AMP_ASSOC_SUPPORTED(x) ((x)[22] & 0x80)
1611 
1612 #define HCI_READ_FLOW_CONTROL_MODE_SUPPORTED(x) ((x)[23] & 0x01)
1613 #define HCI_WRITE_FLOW_CONTROL_MODE_SUPPORTED(x) ((x)[23] & 0x02)
1614 #define HCI_READ_DATA_BLOCK_SIZE_SUPPORTED(x) ((x)[23] & 0x04)
1615 #define HCI_ENABLE_AMP_RCVR_REPORTS_SUPPORTED(x) ((x)[23] & 0x20)
1616 #define HCI_AMP_TEST_END_SUPPORTED(x) ((x)[23] & 0x40)
1617 #define HCI_AMP_TEST_SUPPORTED(x) ((x)[23] & 0x80)
1618 
1619 #define HCI_READ_TRANSMIT_POWER_LEVEL_SUPPORTED(x) ((x)[24] & 0x01)
1620 #define HCI_READ_BE_FLUSH_TOUT_SUPPORTED(x) ((x)[24] & 0x04)
1621 #define HCI_WRITE_BE_FLUSH_TOUT_SUPPORTED(x) ((x)[24] & 0x08)
1622 #define HCI_SHORT_RANGE_MODE_SUPPORTED(x) ((x)[24] & 0x10)
1623 
1624 #define HCI_ENH_SETUP_SYNCH_CONN_SUPPORTED(x) ((x)[29] & 0x08)
1625 #define HCI_ENH_ACCEPT_SYNCH_CONN_SUPPORTED(x) ((x)[29] & 0x10)
1626 #define HCI_READ_LOCAL_CODECS_SUPPORTED(x) ((x)[29] & 0x20)
1627 #define HCI_SET_MWS_CHANNEL_PARAMETERS_SUPPORTED(x) ((x)[29] & 0x40)
1628 #define HCI_SET_EXTERNAL_FRAME_CONFIGURATION_SUPPORTED(x) ((x)[29] & 0x80)
1629 
1630 #define HCI_SET_MWS_SIGNALING_SUPPORTED(x) ((x)[30] & 0x01)
1631 #define HCI_SET_MWS_TRANSPORT_LAYER_SUPPORTED(x) ((x)[30] & 0x02)
1632 #define HCI_SET_MWS_SCAN_FREQUENCY_TABLE_SUPPORTED(x) ((x)[30] & 0x04)
1633 #define HCI_GET_MWS_TRANS_LAYER_CFG_SUPPORTED(x) ((x)[30] & 0x08)
1634 #define HCI_SET_MWS_PATTERN_CONFIGURATION_SUPPORTED(x) ((x)[30] & 0x10)
1635 #define HCI_SET_TRIG_CLK_CAP_SUPPORTED(x) ((x)[30] & 0x20)
1636 #define HCI_TRUNCATED_PAGE_SUPPORTED(x) ((x)[30] & 0x40)
1637 #define HCI_TRUNCATED_PAGE_CANCEL_SUPPORTED(x) ((x)[30] & 0x80)
1638 
1639 #define HCI_SET_CONLESS_SLAVE_BRCST_SUPPORTED(x) ((x)[31] & 0x01)
1640 #define HCI_SET_CONLESS_SLAVE_BRCST_RECEIVE_SUPPORTED(x) ((x)[31] & 0x02)
1641 #define HCI_START_SYNC_TRAIN_SUPPORTED(x) ((x)[31] & 0x04)
1642 #define HCI_RECEIVE_SYNC_TRAIN_SUPPORTED(x) ((x)[31] & 0x08)
1643 #define HCI_SET_RESERVED_LT_ADDR_SUPPORTED(x) ((x)[31] & 0x10)
1644 #define HCI_DELETE_RESERVED_LT_ADDR_SUPPORTED(x) ((x)[31] & 0x20)
1645 #define HCI_SET_CONLESS_SLAVE_BRCST_DATA_SUPPORTED(x) ((x)[31] & 0x40)
1646 #define HCI_READ_SYNC_TRAIN_PARAM_SUPPORTED(x) ((x)[31] & 0x80)
1647 
1648 #define HCI_WRITE_SYNC_TRAIN_PARAM_SUPPORTED(x) ((x)[32] & 0x01)
1649 #define HCI_REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY_SUPPORTED(x) ((x)[32] & 0x02)
1650 #define HCI_READ_SECURE_CONNS_SUPPORT_SUPPORTED(x) ((x)[32] & 0x04)
1651 #define HCI_WRITE_SECURE_CONNS_SUPPORT_SUPPORTED(x) ((x)[32] & 0x08)
1652 #define HCI_READ_AUTHENT_PAYLOAD_TOUT_SUPPORTED(x) ((x)[32] & 0x10)
1653 #define HCI_WRITE_AUTHENT_PAYLOAD_TOUT_SUPPORTED(x) ((x)[32] & 0x20)
1654 #define HCI_READ_LOCAL_OOB_EXTENDED_DATA_SUPPORTED(x) ((x)[32] & 0x40)
1655 #define HCI_WRITE_SECURE_CONNECTIONS_TEST_MODE_SUPPORTED(x) ((x)[32] & 0x80)
1656 
1657 #define HCI_LE_RC_CONN_PARAM_UPD_RPY_SUPPORTED(x) ((x)[33] & 0x10)
1658 #define HCI_LE_RC_CONN_PARAM_UPD_NEG_RPY_SUPPORTED(x) ((x)[33] & 0x20)
1659 
1660 #define HCI_LE_READ_PHY_SUPPORTED(x) ((x)[35] & 0x10)
1661 #define HCI_LE_SET_DEFAULT_PHY_SUPPORTED(x) ((x)[35] & 0x20)
1662 #define HCI_LE_SET_PHY_SUPPORTED(x) ((x)[35] & 0x40)
1663 #define HCI_LE_ENH_RX_TEST_SUPPORTED(x) ((x)[35] & 0x80)
1664 
1665 #define HCI_LE_ENH_TX_TEST_SUPPORTED(x) ((x)[36] & 0x01)
1666 
1667 #define HCI_LE_SET_PRIVACY_MODE_SUPPORTED(x) ((x)[39] & 0x04)
1668 
1669 #endif
1670