bta_hd_api.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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 BTA_HD_API_H
  20. #define BTA_HD_API_H
  21. #include "bta_api.h"
  22. #include "hidd_api.h"
  23. /*****************************************************************************
  24. * Constants and Type Definitions
  25. ****************************************************************************/
  26. #ifndef BTA_HD_DEBUG
  27. #define BTA_HD_DEBUG FALSE
  28. #endif
  29. /* BTA HID Device callback events */
  30. #define BTA_HD_ENABLE_EVT 0 /* BT-HD enabled */
  31. #define BTA_HD_DISABLE_EVT 1 /* BT-HD disabled */
  32. #define BTA_HD_REGISTER_APP_EVT 2 /* application registered */
  33. #define BTA_HD_UNREGISTER_APP_EVT 3 /* application unregistered */
  34. #define BTA_HD_OPEN_EVT 4 /* connection to host opened */
  35. #define BTA_HD_CLOSE_EVT 5 /* connection to host closed */
  36. #define BTA_HD_GET_REPORT_EVT 6 /* GET_REPORT request from host */
  37. #define BTA_HD_SET_REPORT_EVT 7 /* SET_REPORT request from host */
  38. #define BTA_HD_SET_PROTOCOL_EVT 8 /* SET_PROTOCOL request from host */
  39. #define BTA_HD_INTR_DATA_EVT 9 /* DATA received from host on intr */
  40. #define BTA_HD_VC_UNPLUG_EVT 10 /* Virtual Cable Unplug */
  41. #define BTA_HD_CONN_STATE_EVT 11 /* Report connection state change */
  42. #define BTA_HD_API_ERR_EVT 99 /* BT-HD API error */
  43. typedef uint16_t tBTA_HD_EVT;
  44. enum { BTA_HD_OK, BTA_HD_ERROR };
  45. typedef uint8_t tBTA_HD_STATUS;
  46. typedef tHID_DEV_DSCP_INFO tBTA_HD_DEV_DESCR;
  47. typedef struct {
  48. char* p_name;
  49. char* p_description;
  50. char* p_provider;
  51. uint8_t subclass;
  52. tBTA_HD_DEV_DESCR descriptor;
  53. } tBTA_HD_APP_INFO;
  54. typedef struct {
  55. uint8_t service_type;
  56. uint32_t token_rate;
  57. uint32_t token_bucket_size;
  58. uint32_t peak_bandwidth;
  59. uint32_t access_latency;
  60. uint32_t delay_variation;
  61. } tBTA_HD_QOS_INFO;
  62. typedef struct {
  63. bool use_intr;
  64. uint8_t type;
  65. uint8_t id;
  66. uint16_t len;
  67. uint8_t* p_data;
  68. } tBTA_HD_REPORT;
  69. typedef struct {
  70. tBTA_HD_STATUS status;
  71. bool in_use;
  72. RawAddress bda;
  73. } tBTA_HD_REG_STATUS;
  74. typedef struct {
  75. RawAddress bda;
  76. tBTA_HD_STATUS status;
  77. } tBTA_HD_CONN;
  78. typedef struct {
  79. uint8_t report_type;
  80. uint8_t report_id;
  81. uint16_t buffer_size;
  82. } tBTA_HD_GET_REPORT;
  83. typedef struct {
  84. uint8_t report_type;
  85. uint8_t report_id;
  86. uint16_t len;
  87. uint8_t* p_data;
  88. } tBTA_HD_SET_REPORT;
  89. typedef uint8_t tBTA_HD_SET_PROTOCOL;
  90. typedef struct {
  91. uint8_t report_id;
  92. uint16_t len;
  93. uint8_t* p_data;
  94. } tBTA_HD_INTR_DATA;
  95. /* union of data associated with HD callback */
  96. typedef union {
  97. tBTA_HD_STATUS status; /* BTA_HD_ENABLE_EVT
  98. BTA_HD_DISABLE_EVT
  99. BTA_HD_UNREGISTER_APP_EVT */
  100. tBTA_HD_REG_STATUS reg_status; /* BTA_HD_REGISTER_APP_EVT */
  101. tBTA_HD_CONN conn; /* BTA_HD_OPEN_EVT
  102. BTA_HD_CLOSE_EVT
  103. BTA_HD_VC_UNPLUG_EVT
  104. BTA_HD_OWN_VC_UNPLUG_EVT */
  105. tBTA_HD_GET_REPORT get_report; /* BTA_HD_GET_REPORT */
  106. tBTA_HD_SET_REPORT set_report; /* BTA_HD_SET_REPORT */
  107. tBTA_HD_SET_PROTOCOL set_protocol; /* BTA_HD_SETPROTOCOL */
  108. tBTA_HD_INTR_DATA intr_data; /* BTA_HD_INTR_DATA_EVT */
  109. } tBTA_HD;
  110. /* BTA HD callback function */
  111. typedef void(tBTA_HD_CBACK)(tBTA_HD_EVT event, tBTA_HD* p_data);
  112. /*****************************************************************************
  113. * External Function Declarations
  114. ****************************************************************************/
  115. #ifdef __cplusplus
  116. extern "C" {
  117. #endif
  118. /*******************************************************************************
  119. *
  120. * Function BTA_HhRegister
  121. *
  122. * Description This function enable HID host and registers HID-Host with
  123. * lower layers.
  124. *
  125. * Returns void
  126. *
  127. ******************************************************************************/
  128. extern void BTA_HdEnable(tBTA_HD_CBACK* p_cback);
  129. /*******************************************************************************
  130. *
  131. * Function BTA_HhDeregister
  132. *
  133. * Description This function is called when the host is about power down.
  134. *
  135. * Returns void
  136. *
  137. ******************************************************************************/
  138. extern void BTA_HdDisable(void);
  139. /*******************************************************************************
  140. *
  141. * Function BTA_HdRegisterApp
  142. *
  143. * Description This function is called when application should be
  144. *registered
  145. *
  146. * Returns void
  147. *
  148. ******************************************************************************/
  149. extern void BTA_HdRegisterApp(tBTA_HD_APP_INFO* p_app_info,
  150. tBTA_HD_QOS_INFO* p_in_qos,
  151. tBTA_HD_QOS_INFO* p_out_qos);
  152. /*******************************************************************************
  153. *
  154. * Function BTA_HdUnregisterApp
  155. *
  156. * Description This function is called when application should be
  157. *unregistered
  158. *
  159. * Returns void
  160. *
  161. ******************************************************************************/
  162. extern void BTA_HdUnregisterApp(void);
  163. /*******************************************************************************
  164. *
  165. * Function BTA_HdSendReport
  166. *
  167. * Description This function is called when report is to be sent
  168. *
  169. * Returns void
  170. *
  171. ******************************************************************************/
  172. extern void BTA_HdSendReport(tBTA_HD_REPORT* p_report);
  173. /*******************************************************************************
  174. *
  175. * Function BTA_HdVirtualCableUnplug
  176. *
  177. * Description This function is called when VCU shall be sent
  178. *
  179. * Returns void
  180. *
  181. ******************************************************************************/
  182. extern void BTA_HdVirtualCableUnplug(void);
  183. /*******************************************************************************
  184. *
  185. * Function BTA_HdConnect
  186. *
  187. * Description This function is called when connection to host shall be
  188. * made
  189. *
  190. * Returns void
  191. *
  192. ******************************************************************************/
  193. extern void BTA_HdConnect(const RawAddress& addr);
  194. /*******************************************************************************
  195. *
  196. * Function BTA_HdDisconnect
  197. *
  198. * Description This function is called when host shall be disconnected
  199. *
  200. * Returns void
  201. *
  202. ******************************************************************************/
  203. extern void BTA_HdDisconnect(void);
  204. /*******************************************************************************
  205. *
  206. * Function BTA_HdAddDevice
  207. *
  208. * Description This function is called when a device is virtually cabled
  209. *
  210. * Returns void
  211. *
  212. ******************************************************************************/
  213. extern void BTA_HdAddDevice(const RawAddress& addr);
  214. /*******************************************************************************
  215. *
  216. * Function BTA_HdRemoveDevice
  217. *
  218. * Description This function is called when a device is virtually uncabled
  219. *
  220. * Returns void
  221. *
  222. ******************************************************************************/
  223. extern void BTA_HdRemoveDevice(const RawAddress& addr);
  224. /*******************************************************************************
  225. *
  226. * Function BTA_HdReportError
  227. *
  228. * Description This function is called when reporting error for set report
  229. *
  230. * Returns void
  231. *
  232. ******************************************************************************/
  233. extern void BTA_HdReportError(uint8_t error);
  234. #ifdef __cplusplus
  235. }
  236. #endif
  237. #endif /* BTA_HD_API_H */