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 "hiddefs.h" 23 #include "sdp_api.h" 24 25 /***************************************************************************** 26 * Type Definitions 27 ****************************************************************************/ 28 29 enum { HID_CHANNEL_INTR, HID_CHANNEL_CTRL }; 30 31 /* 32 HID_DHOST_EVT_OPEN - connected to host device (CTRL and INTR), data = n/a 33 HID_DHOST_EVT_CLOSE - disconnected from host device, data=reason 34 HID_DHOST_EVT_GET_REPORT - got GET_REPORT from host 35 HID_DHOST_EVT_SET_REPORT - got SET_REPORT from host 36 HID_DHOST_EVT_SET_PROTOCOL - got SET_PROTOCOL from host 37 */ 38 39 enum { 40 HID_DHOST_EVT_OPEN, 41 HID_DHOST_EVT_CLOSE, 42 HID_DHOST_EVT_GET_REPORT, 43 HID_DHOST_EVT_SET_REPORT, 44 HID_DHOST_EVT_SET_PROTOCOL, 45 HID_DHOST_EVT_INTR_DATA, 46 HID_DHOST_EVT_VC_UNPLUG, 47 HID_DHOST_EVT_SUSPEND, 48 HID_DHOST_EVT_EXIT_SUSPEND, 49 }; 50 typedef void(tHID_DEV_HOST_CALLBACK)(const RawAddress& bd_addr, uint8_t event, 51 uint32_t data, BT_HDR* p_buf); 52 53 /***************************************************************************** 54 * External Function Declarations 55 ****************************************************************************/ 56 #ifdef __cplusplus 57 extern "C" { 58 #endif 59 60 /******************************************************************************* 61 * 62 * Function HID_DevInit 63 * 64 * Description Initializes control block 65 * 66 * Returns void 67 * 68 ******************************************************************************/ 69 extern void HID_DevInit(void); 70 71 /******************************************************************************* 72 * 73 * Function HID_DevRegister 74 * 75 * Description Registers HID device with lower layers 76 * 77 * Returns tHID_STATUS 78 * 79 ******************************************************************************/ 80 extern tHID_STATUS HID_DevRegister(tHID_DEV_HOST_CALLBACK* host_cback); 81 82 /******************************************************************************* 83 * 84 * Function HID_DevDeregister 85 * 86 * Description Deregisters HID device with lower layers 87 * 88 * Returns tHID_STATUS 89 * 90 ******************************************************************************/ 91 extern tHID_STATUS HID_DevDeregister(void); 92 93 /******************************************************************************* 94 * 95 * Function HID_DevAddRecord 96 * 97 * Description Creates SDP record for HID device 98 * 99 * Returns tHID_STATUS 100 * 101 ******************************************************************************/ 102 extern tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name, 103 char* p_description, char* p_provider, 104 uint16_t subclass, uint16_t desc_len, 105 uint8_t* p_desc_data); 106 107 /******************************************************************************* 108 * 109 * Function HID_DevSendReport 110 * 111 * Description Sends report 112 * 113 * Returns tHID_STATUS 114 * 115 ******************************************************************************/ 116 extern tHID_STATUS HID_DevSendReport(uint8_t channel, uint8_t type, uint8_t id, 117 uint16_t len, uint8_t* p_data); 118 119 /******************************************************************************* 120 * 121 * Function HID_DevVirtualCableUnplug 122 * 123 * Description Sends Virtual Cable Unplug 124 * 125 * Returns tHID_STATUS 126 * 127 ******************************************************************************/ 128 extern tHID_STATUS HID_DevVirtualCableUnplug(void); 129 130 /******************************************************************************* 131 * 132 * Function HID_DevPlugDevice 133 * 134 * Description Establishes virtual cable to given host 135 * 136 * Returns tHID_STATUS 137 * 138 ******************************************************************************/ 139 extern tHID_STATUS HID_DevPlugDevice(const RawAddress& addr); 140 141 /******************************************************************************* 142 * 143 * Function HID_DevUnplugDevice 144 * 145 * Description Unplugs virtual cable from given host 146 * 147 * Returns tHID_STATUS 148 * 149 ******************************************************************************/ 150 extern tHID_STATUS HID_DevUnplugDevice(const RawAddress& addr); 151 152 /******************************************************************************* 153 * 154 * Function HID_DevConnect 155 * 156 * Description Connects to device 157 * 158 * Returns tHID_STATUS 159 * 160 ******************************************************************************/ 161 extern tHID_STATUS HID_DevConnect(void); 162 163 /******************************************************************************* 164 * 165 * Function HID_DevDisconnect 166 * 167 * Description Disconnects from device 168 * 169 * Returns tHID_STATUS 170 * 171 ******************************************************************************/ 172 extern tHID_STATUS HID_DevDisconnect(void); 173 174 /******************************************************************************* 175 * 176 * Function HID_DevSetIncomingPolicy 177 * 178 * Description Sets policy for incoming connections (allowed/disallowed) 179 * 180 * Returns tHID_STATUS 181 * 182 ******************************************************************************/ 183 extern tHID_STATUS HID_DevSetIncomingPolicy(bool allow); 184 185 /******************************************************************************* 186 * 187 * Function HID_DevReportError 188 * 189 * Description Reports error for Set Report via HANDSHAKE 190 * 191 * Returns tHID_STATUS 192 * 193 ******************************************************************************/ 194 extern tHID_STATUS HID_DevReportError(uint8_t error); 195 196 /******************************************************************************* 197 * 198 * Function HID_DevGetDevice 199 * 200 * Description Returns the BD Address of virtually cabled device 201 * 202 * Returns tHID_STATUS 203 * 204 ******************************************************************************/ 205 extern tHID_STATUS HID_DevGetDevice(RawAddress* addr); 206 207 /******************************************************************************* 208 * 209 * Function HID_DevSetIncomingQos 210 * 211 * Description Sets Incoming QoS values for Interrupt L2CAP Channel 212 * 213 * Returns tHID_STATUS 214 * 215 ******************************************************************************/ 216 extern tHID_STATUS HID_DevSetIncomingQos( 217 uint8_t service_type, uint32_t token_rate, uint32_t token_bucket_size, 218 uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation); 219 220 /******************************************************************************* 221 * 222 * Function HID_DevSetOutgoingQos 223 * 224 * Description Sets Outgoing QoS values for Interrupt L2CAP Channel 225 * 226 * Returns tHID_STATUS 227 * 228 ******************************************************************************/ 229 extern tHID_STATUS HID_DevSetOutgoingQos( 230 uint8_t service_type, uint32_t token_rate, uint32_t token_bucket_size, 231 uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation); 232 233 /******************************************************************************* 234 * 235 * Function HID_DevSetTraceLevel 236 * 237 * Description This function sets the trace level for HID Dev. If called 238 * with a value of 0xFF, it simply reads the current trace level. 239 * 240 * Returns the new (current) trace level 241 * 242 ******************************************************************************/ 243 extern uint8_t HID_DevSetTraceLevel(uint8_t new_level); 244 245 #ifdef __cplusplus 246 } 247 #endif 248 249 #endif /* HIDD_API_H */ 250