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