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 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_DevSetSecurityLevel
     96  *
     97  * Description      Sets security level for HID device connections
     98  *
     99  * Returns          tHID_STATUS
    100  *
    101  ******************************************************************************/
    102 extern tHID_STATUS HID_DevSetSecurityLevel(uint8_t sec_lvl);
    103 
    104 /*******************************************************************************
    105  *
    106  * Function         HID_DevAddRecord
    107  *
    108  * Description      Creates SDP record for HID device
    109  *
    110  * Returns          tHID_STATUS
    111  *
    112  ******************************************************************************/
    113 extern tHID_STATUS HID_DevAddRecord(uint32_t handle, char* p_name,
    114                                     char* p_description, char* p_provider,
    115                                     uint16_t subclass, uint16_t desc_len,
    116                                     uint8_t* p_desc_data);
    117 
    118 /*******************************************************************************
    119  *
    120  * Function         HID_DevSendReport
    121  *
    122  * Description      Sends report
    123  *
    124  * Returns          tHID_STATUS
    125  *
    126  ******************************************************************************/
    127 extern tHID_STATUS HID_DevSendReport(uint8_t channel, uint8_t type, uint8_t id,
    128                                      uint16_t len, uint8_t* p_data);
    129 
    130 /*******************************************************************************
    131  *
    132  * Function         HID_DevVirtualCableUnplug
    133  *
    134  * Description      Sends Virtual Cable Unplug
    135  *
    136  * Returns          tHID_STATUS
    137  *
    138  ******************************************************************************/
    139 extern tHID_STATUS HID_DevVirtualCableUnplug(void);
    140 
    141 /*******************************************************************************
    142  *
    143  * Function         HID_DevPlugDevice
    144  *
    145  * Description      Establishes virtual cable to given host
    146  *
    147  * Returns          tHID_STATUS
    148  *
    149  ******************************************************************************/
    150 extern tHID_STATUS HID_DevPlugDevice(const RawAddress& addr);
    151 
    152 /*******************************************************************************
    153  *
    154  * Function         HID_DevUnplugDevice
    155  *
    156  * Description      Unplugs virtual cable from given host
    157  *
    158  * Returns          tHID_STATUS
    159  *
    160  ******************************************************************************/
    161 extern tHID_STATUS HID_DevUnplugDevice(const RawAddress& addr);
    162 
    163 /*******************************************************************************
    164  *
    165  * Function         HID_DevConnect
    166  *
    167  * Description      Connects to device
    168  *
    169  * Returns          tHID_STATUS
    170  *
    171  ******************************************************************************/
    172 extern tHID_STATUS HID_DevConnect(void);
    173 
    174 /*******************************************************************************
    175  *
    176  * Function         HID_DevDisconnect
    177  *
    178  * Description      Disconnects from device
    179  *
    180  * Returns          tHID_STATUS
    181  *
    182  ******************************************************************************/
    183 extern tHID_STATUS HID_DevDisconnect(void);
    184 
    185 /*******************************************************************************
    186  *
    187  * Function         HID_DevSetIncomingPolicy
    188  *
    189  * Description      Sets policy for incoming connections (allowed/disallowed)
    190  *
    191  * Returns          tHID_STATUS
    192  *
    193  ******************************************************************************/
    194 extern tHID_STATUS HID_DevSetIncomingPolicy(bool allow);
    195 
    196 /*******************************************************************************
    197  *
    198  * Function         HID_DevReportError
    199  *
    200  * Description      Reports error for Set Report via HANDSHAKE
    201  *
    202  * Returns          tHID_STATUS
    203  *
    204  ******************************************************************************/
    205 extern tHID_STATUS HID_DevReportError(uint8_t error);
    206 
    207 /*******************************************************************************
    208  *
    209  * Function         HID_DevGetDevice
    210  *
    211  * Description      Returns the BD Address of virtually cabled device
    212  *
    213  * Returns          tHID_STATUS
    214  *
    215  ******************************************************************************/
    216 extern tHID_STATUS HID_DevGetDevice(RawAddress* addr);
    217 
    218 /*******************************************************************************
    219  *
    220  * Function         HID_DevSetIncomingQos
    221  *
    222  * Description      Sets Incoming QoS values for Interrupt L2CAP Channel
    223  *
    224  * Returns          tHID_STATUS
    225  *
    226  ******************************************************************************/
    227 extern tHID_STATUS HID_DevSetIncomingQos(
    228     uint8_t service_type, uint32_t token_rate, uint32_t token_bucket_size,
    229     uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation);
    230 
    231 /*******************************************************************************
    232  *
    233  * Function         HID_DevSetOutgoingQos
    234  *
    235  * Description      Sets Outgoing QoS values for Interrupt L2CAP Channel
    236  *
    237  * Returns          tHID_STATUS
    238  *
    239  ******************************************************************************/
    240 extern tHID_STATUS HID_DevSetOutgoingQos(
    241     uint8_t service_type, uint32_t token_rate, uint32_t token_bucket_size,
    242     uint32_t peak_bandwidth, uint32_t latency, uint32_t delay_variation);
    243 
    244 /*******************************************************************************
    245  *
    246  * Function         HID_DevSetTraceLevel
    247  *
    248  * Description      This function sets the trace level for HID Dev. If called
    249  *                  with a value of 0xFF, it simply reads the current trace level.
    250  *
    251  * Returns          the new (current) trace level
    252  *
    253  ******************************************************************************/
    254 extern uint8_t HID_DevSetTraceLevel(uint8_t new_level);
    255 
    256 #ifdef __cplusplus
    257 }
    258 #endif
    259 
    260 #endif /* HIDD_API_H */
    261