blob: 4d89a0ecd925ad9ee8738015c0cb1d3bf84854e1 (
plain)
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
|
/******************************************************************************
*
* Copyright 2016 The Android Open Source Project
* Copyright 2002-2012 Broadcom Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
#ifndef BTA_HD_API_H
#define BTA_HD_API_H
#include <cstdint>
#include "bta/include/bta_api.h"
#include "stack/include/hiddefs.h"
#include "types/raw_address.h"
/*****************************************************************************
* Constants and Type Definitions
****************************************************************************/
#ifndef BTA_HD_DEBUG
#define BTA_HD_DEBUG FALSE
#endif
/* BTA HID Device callback events */
#define BTA_HD_ENABLE_EVT 0 /* BT-HD enabled */
#define BTA_HD_DISABLE_EVT 1 /* BT-HD disabled */
#define BTA_HD_REGISTER_APP_EVT 2 /* application registered */
#define BTA_HD_UNREGISTER_APP_EVT 3 /* application unregistered */
#define BTA_HD_OPEN_EVT 4 /* connection to host opened */
#define BTA_HD_CLOSE_EVT 5 /* connection to host closed */
#define BTA_HD_GET_REPORT_EVT 6 /* GET_REPORT request from host */
#define BTA_HD_SET_REPORT_EVT 7 /* SET_REPORT request from host */
#define BTA_HD_SET_PROTOCOL_EVT 8 /* SET_PROTOCOL request from host */
#define BTA_HD_INTR_DATA_EVT 9 /* DATA received from host on intr */
#define BTA_HD_VC_UNPLUG_EVT 10 /* Virtual Cable Unplug */
#define BTA_HD_CONN_STATE_EVT 11 /* Report connection state change */
#define BTA_HD_API_ERR_EVT 99 /* BT-HD API error */
typedef uint16_t tBTA_HD_EVT;
enum { BTA_HD_OK, BTA_HD_ERROR };
typedef uint8_t tBTA_HD_STATUS;
typedef tHID_DEV_DSCP_INFO tBTA_HD_DEV_DESCR;
typedef struct {
char* p_name;
char* p_description;
char* p_provider;
uint8_t subclass;
tBTA_HD_DEV_DESCR descriptor;
} tBTA_HD_APP_INFO;
typedef struct {
uint8_t service_type;
uint32_t token_rate;
uint32_t token_bucket_size;
uint32_t peak_bandwidth;
uint32_t access_latency;
uint32_t delay_variation;
} tBTA_HD_QOS_INFO;
typedef struct {
bool use_intr;
uint8_t type;
uint8_t id;
uint16_t len;
uint8_t* p_data;
} tBTA_HD_REPORT;
typedef struct {
tBTA_HD_STATUS status;
bool in_use;
RawAddress bda;
} tBTA_HD_REG_STATUS;
typedef struct {
RawAddress bda;
tBTA_HD_STATUS status;
} tBTA_HD_CONN;
typedef struct {
uint8_t report_type;
uint8_t report_id;
uint16_t buffer_size;
} tBTA_HD_GET_REPORT;
typedef struct {
uint8_t report_type;
uint8_t report_id;
uint16_t len;
uint8_t* p_data;
} tBTA_HD_SET_REPORT;
typedef uint8_t tBTA_HD_SET_PROTOCOL;
typedef struct {
uint8_t report_id;
uint16_t len;
uint8_t* p_data;
} tBTA_HD_INTR_DATA;
/* union of data associated with HD callback */
typedef union {
tBTA_HD_STATUS status; /* BTA_HD_ENABLE_EVT
BTA_HD_DISABLE_EVT
BTA_HD_UNREGISTER_APP_EVT */
tBTA_HD_REG_STATUS reg_status; /* BTA_HD_REGISTER_APP_EVT */
tBTA_HD_CONN conn; /* BTA_HD_OPEN_EVT
BTA_HD_CLOSE_EVT
BTA_HD_VC_UNPLUG_EVT
BTA_HD_OWN_VC_UNPLUG_EVT */
tBTA_HD_GET_REPORT get_report; /* BTA_HD_GET_REPORT */
tBTA_HD_SET_REPORT set_report; /* BTA_HD_SET_REPORT */
tBTA_HD_SET_PROTOCOL set_protocol; /* BTA_HD_SETPROTOCOL */
tBTA_HD_INTR_DATA intr_data; /* BTA_HD_INTR_DATA_EVT */
} tBTA_HD;
/* BTA HD callback function */
typedef void(tBTA_HD_CBACK)(tBTA_HD_EVT event, tBTA_HD* p_data);
/*****************************************************************************
* External Function Declarations
****************************************************************************/
#ifdef __cplusplus
extern "C" {
#endif
/*******************************************************************************
*
* Function BTA_HhRegister
*
* Description This function enable HID host and registers HID-Host with
* lower layers.
*
* Returns void
*
******************************************************************************/
extern void BTA_HdEnable(tBTA_HD_CBACK* p_cback);
/*******************************************************************************
*
* Function BTA_HhDeregister
*
* Description This function is called when the host is about power down.
*
* Returns void
*
******************************************************************************/
extern void BTA_HdDisable(void);
/*******************************************************************************
*
* Function BTA_HdRegisterApp
*
* Description This function is called when application should be
*registered
*
* Returns void
*
******************************************************************************/
extern void BTA_HdRegisterApp(tBTA_HD_APP_INFO* p_app_info,
tBTA_HD_QOS_INFO* p_in_qos,
tBTA_HD_QOS_INFO* p_out_qos);
/*******************************************************************************
*
* Function BTA_HdUnregisterApp
*
* Description This function is called when application should be
*unregistered
*
* Returns void
*
******************************************************************************/
extern void BTA_HdUnregisterApp(void);
/*******************************************************************************
*
* Function BTA_HdSendReport
*
* Description This function is called when report is to be sent
*
* Returns void
*
******************************************************************************/
extern void BTA_HdSendReport(tBTA_HD_REPORT* p_report);
/*******************************************************************************
*
* Function BTA_HdVirtualCableUnplug
*
* Description This function is called when VCU shall be sent
*
* Returns void
*
******************************************************************************/
extern void BTA_HdVirtualCableUnplug(void);
/*******************************************************************************
*
* Function BTA_HdConnect
*
* Description This function is called when connection to host shall be
* made
*
* Returns void
*
******************************************************************************/
extern void BTA_HdConnect(const RawAddress& addr);
/*******************************************************************************
*
* Function BTA_HdDisconnect
*
* Description This function is called when host shall be disconnected
*
* Returns void
*
******************************************************************************/
extern void BTA_HdDisconnect(void);
/*******************************************************************************
*
* Function BTA_HdAddDevice
*
* Description This function is called when a device is virtually cabled
*
* Returns void
*
******************************************************************************/
extern void BTA_HdAddDevice(const RawAddress& addr);
/*******************************************************************************
*
* Function BTA_HdRemoveDevice
*
* Description This function is called when a device is virtually uncabled
*
* Returns void
*
******************************************************************************/
extern void BTA_HdRemoveDevice(const RawAddress& addr);
/*******************************************************************************
*
* Function BTA_HdReportError
*
* Description This function is called when reporting error for set report
*
* Returns void
*
******************************************************************************/
extern void BTA_HdReportError(uint8_t error);
#ifdef __cplusplus
}
#endif
#endif /* BTA_HD_API_H */
|