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 
20 /******************************************************************************
21  *
22  *  This file contains HID DEVICE internal definitions
23  *
24  ******************************************************************************/
25 
26 #ifndef HIDD_INT_H
27 #define HIDD_INT_H
28 
29 #include <cstdint>
30 
31 #include "stack/hid/hid_conn.h"
32 #include "stack/include/bt_hdr.h"
33 #include "stack/include/hidd_api.h"
34 #include "stack/include/l2c_api.h"  // tL2CAP_CFG_INFO && FLOW_SPEC
35 #include "types/raw_address.h"
36 
37 enum { HIDD_DEV_NO_CONN, HIDD_DEV_CONNECTED };
38 
39 typedef struct device_ctb {
40   bool in_use;
41   RawAddress addr;
42 
43   uint8_t state;
44 
45   tHID_CONN conn;
46 
47   bool boot_mode;
48 
49   uint8_t idle_time;
50 } tHID_DEV_DEV_CTB;
51 
52 typedef struct dev_ctb {
53   tHID_DEV_DEV_CTB device;
54 
55   tHID_DEV_HOST_CALLBACK* callback;
56   tL2CAP_CFG_INFO l2cap_cfg;
57   tL2CAP_CFG_INFO l2cap_intr_cfg;
58 
59   bool use_in_qos;
60   FLOW_SPEC in_qos;
61 
62   bool reg_flag;
63 
64   bool allow_incoming;
65 
66   BT_HDR* pending_data;
67 
68   bool pending_vc_unplug;
69 } tHID_DEV_CTB;
70 
71 tHID_STATUS hidd_conn_reg(void);
72 void hidd_conn_dereg(void);
73 tHID_STATUS hidd_conn_initiate(void);
74 tHID_STATUS hidd_conn_disconnect(void);
75 tHID_STATUS hidd_conn_send_data(uint8_t channel, uint8_t msg_type,
76                                 uint8_t param, uint8_t data, uint16_t len,
77                                 uint8_t* p_data);
78 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
83 /******************************************************************************
84  * Main Control Block
85  ******************************************************************************/
86 extern tHID_DEV_CTB hd_cb;
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif
93