• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 2016 The Android Open Source Project
4  *  Copyright 2002-2012 Broadcom Corporation
5  *
6  *  Licensed under the Apache License, Version 2.0 (the "License");
7  *  you may not use this file except in compliance with the License.
8  *  You may obtain a copy of the License at:
9  *
10  *  http://www.apache.org/licenses/LICENSE-2.0
11  *
12  *  Unless required by applicable law or agreed to in writing, software
13  *  distributed under the License is distributed on an "AS IS" BASIS,
14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  *  See the License for the specific language governing permissions and
16  *  limitations under the License.
17  *
18  ******************************************************************************/
19 #ifndef HIDD_API_H
20 #define HIDD_API_H
21 
22 #include <cstdint>
23 
24 #include "stack/include/bt_hdr.h"
25 #include "stack/include/hiddefs.h"
26 #include "stack/include/sdp_api.h"
27 #include "types/raw_address.h"
28 
29 /*****************************************************************************
30  *  Type Definitions
31  ****************************************************************************/
32 
33 enum { HID_CHANNEL_INTR, HID_CHANNEL_CTRL };
34 
35 /*
36     HID_DHOST_EVT_OPEN  - connected to host device (CTRL and INTR), data = n/a
37     HID_DHOST_EVT_CLOSE - disconnected from host device, data=reason
38     HID_DHOST_EVT_GET_REPORT - got GET_REPORT from host
39     HID_DHOST_EVT_SET_REPORT - got SET_REPORT from host
40     HID_DHOST_EVT_SET_PROTOCOL - got SET_PROTOCOL from host
41 */
42 
43 enum {
44   HID_DHOST_EVT_OPEN,
45   HID_DHOST_EVT_CLOSE,
46   HID_DHOST_EVT_GET_REPORT,
47   HID_DHOST_EVT_SET_REPORT,
48   HID_DHOST_EVT_SET_PROTOCOL,
49   HID_DHOST_EVT_INTR_DATA,
50   HID_DHOST_EVT_VC_UNPLUG,
51   HID_DHOST_EVT_SUSPEND,
52   HID_DHOST_EVT_EXIT_SUSPEND,
53 };
54 typedef void(tHID_DEV_HOST_CALLBACK)(const RawAddress& bd_addr, uint8_t event,
55                                      uint32_t data, BT_HDR* p_buf);
56 
57 /*****************************************************************************
58  *  External Function Declarations
59  ****************************************************************************/
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 /*******************************************************************************
65  *
66  * Function         HID_DevInit
67  *
68  * Description      Initializes control block
69  *
70  * Returns          void
71  *
72  ******************************************************************************/
73 extern void HID_DevInit(void);
74 
75 /*******************************************************************************
76  *
77  * Function         HID_DevRegister
78  *
79  * Description      Registers HID device with lower layers
80  *
81  * Returns          tHID_STATUS
82  *
83  ******************************************************************************/
84 extern tHID_STATUS HID_DevRegister(tHID_DEV_HOST_CALLBACK* host_cback);
85 
86 /*******************************************************************************
87  *
88  * Function         HID_DevDeregister
89  *
90  * Description      Deregisters HID device with lower layers
91  *
92  * Returns          tHID_STATUS
93  *
94  ******************************************************************************/
95 extern tHID_STATUS HID_DevDeregister(void);
96 
97 /*******************************************************************************
98  *
99  * Function         HID_DevAddRecord
100  *
101  * Description      Creates SDP record for HID device
102  *
103  * Returns          tHID_STATUS
104  *
105  ******************************************************************************/
106 extern tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name,
107                                     char* p_description, char* p_provider,
108                                     uint16_t subclass, uint16_t desc_len,
109                                     uint8_t* p_desc_data);
110 
111 /*******************************************************************************
112  *
113  * Function         HID_DevSendReport
114  *
115  * Description      Sends report
116  *
117  * Returns          tHID_STATUS
118  *
119  ******************************************************************************/
120 extern tHID_STATUS HID_DevSendReport(uint8_t channel, uint8_t type, uint8_t id,
121                                      uint16_t len, uint8_t* p_data);
122 
123 /*******************************************************************************
124  *
125  * Function         HID_DevVirtualCableUnplug
126  *
127  * Description      Sends Virtual Cable Unplug
128  *
129  * Returns          tHID_STATUS
130  *
131  ******************************************************************************/
132 extern tHID_STATUS HID_DevVirtualCableUnplug(void);
133 
134 /*******************************************************************************
135  *
136  * Function         HID_DevPlugDevice
137  *
138  * Description      Establishes virtual cable to given host
139  *
140  * Returns          tHID_STATUS
141  *
142  ******************************************************************************/
143 extern tHID_STATUS HID_DevPlugDevice(const RawAddress& addr);
144 
145 /*******************************************************************************
146  *
147  * Function         HID_DevUnplugDevice
148  *
149  * Description      Unplugs virtual cable from given host
150  *
151  * Returns          tHID_STATUS
152  *
153  ******************************************************************************/
154 extern tHID_STATUS HID_DevUnplugDevice(const RawAddress& addr);
155 
156 /*******************************************************************************
157  *
158  * Function         HID_DevConnect
159  *
160  * Description      Connects to device
161  *
162  * Returns          tHID_STATUS
163  *
164  ******************************************************************************/
165 extern tHID_STATUS HID_DevConnect(void);
166 
167 /*******************************************************************************
168  *
169  * Function         HID_DevDisconnect
170  *
171  * Description      Disconnects from device
172  *
173  * Returns          tHID_STATUS
174  *
175  ******************************************************************************/
176 extern tHID_STATUS HID_DevDisconnect(void);
177 
178 /*******************************************************************************
179  *
180  * Function         HID_DevSetIncomingPolicy
181  *
182  * Description      Sets policy for incoming connections (allowed/disallowed)
183  *
184  * Returns          tHID_STATUS
185  *
186  ******************************************************************************/
187 extern tHID_STATUS HID_DevSetIncomingPolicy(bool allow);
188 
189 /*******************************************************************************
190  *
191  * Function         HID_DevReportError
192  *
193  * Description      Reports error for Set Report via HANDSHAKE
194  *
195  * Returns          tHID_STATUS
196  *
197  ******************************************************************************/
198 extern tHID_STATUS HID_DevReportError(uint8_t error);
199 
200 /*******************************************************************************
201  *
202  * Function         HID_DevGetDevice
203  *
204  * Description      Returns the BD Address of virtually cabled device
205  *
206  * Returns          tHID_STATUS
207  *
208  ******************************************************************************/
209 extern tHID_STATUS HID_DevGetDevice(RawAddress* addr);
210 
211 /*******************************************************************************
212  *
213  * Function         HID_DevSetIncomingQos
214  *
215  * Description      Sets Incoming QoS values for Interrupt L2CAP Channel
216  *
217  * Returns          tHID_STATUS
218  *
219  ******************************************************************************/
220 extern tHID_STATUS HID_DevSetIncomingQos(
221     uint8_t service_type, uint32_t token_rate, uint32_t token_bucket_size,
222     uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation);
223 
224 /*******************************************************************************
225  *
226  * Function         HID_DevSetOutgoingQos
227  *
228  * Description      Sets Outgoing QoS values for Interrupt L2CAP Channel
229  *
230  * Returns          tHID_STATUS
231  *
232  ******************************************************************************/
233 extern tHID_STATUS HID_DevSetOutgoingQos(
234     uint8_t service_type, uint32_t token_rate, uint32_t token_bucket_size,
235     uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation);
236 
237 /*******************************************************************************
238  *
239  * Function         HID_DevSetTraceLevel
240  *
241  * Description      This function sets the trace level for HID Dev. If called
242  *                  with a value of 0xFF, it simply reads the current trace level.
243  *
244  * Returns          the new (current) trace level
245  *
246  ******************************************************************************/
247 extern uint8_t HID_DevSetTraceLevel(uint8_t new_level);
248 
249 #ifdef __cplusplus
250 }
251 #endif
252 
253 #endif /* HIDD_API_H */
254