7146c7ad9cc677bc888f96c4bb01946fe9cbb7b4
[GitHub/LineageOS/G12/android_hardware_realtek.git] / rtkbt / code / libbt-vendor / include / bt_vendor_rtk.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2009-2012 Realtek Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 ******************************************************************************/
18
19 /******************************************************************************
20 *
21 * Filename: bt_vendor_rtk.h
22 *
23 * Description: A wrapper header file of bt_vendor_lib.h
24 *
25 * Contains definitions specific for interfacing with Realtek
26 * Bluetooth chipsets
27 *
28 ******************************************************************************/
29
30 #ifndef BT_VENDOR_RTK_H
31 #define BT_VENDOR_RTK_H
32
33 #include "bt_vendor_lib.h"
34 #include "vnd_buildcfg.h"
35 #include "rtk_btsnoop_net.h"
36 #include <string.h>
37 #include <fcntl.h>
38 #include <errno.h>
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <dirent.h>
42 #include <sys/stat.h>
43 #include <unistd.h>
44 #include <sys/types.h>
45 #include <sys/socket.h>
46 #include <sys/ioctl.h>
47 #include <sys/epoll.h>
48 #include <sys/eventfd.h>
49 #include <unistd.h>
50 #include <ctype.h>
51 #include <cutils/properties.h>
52
53
54 /******************************************************************************
55 ** Constants & Macros
56 ******************************************************************************/
57 #define RTKBT_TRANS_H4 0x20
58 #define RTKBT_TRANS_H5 0x10
59 #define RTKBT_TRANS_UART 0x01
60 #define RTKBT_TRANS_USB 0x20
61
62
63 #ifndef FALSE
64 #define FALSE 0
65 #endif
66
67 #ifndef TRUE
68 #define TRUE (!FALSE)
69 #endif
70
71 #ifndef BTVND_DBG
72 #define BTVND_DBG TRUE
73 #endif
74
75 #if (BTVND_DBG == TRUE)
76 #define BTVNDDBG(param, ...) {ALOGD(param, ## __VA_ARGS__);}
77 #else
78 #define BTVNDDBG(param, ...) {}
79 #endif
80
81
82 /* Device port name where Bluetooth controller attached */
83 #ifndef BLUETOOTH_UART_DEVICE_PORT
84 #define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyO1" /* maguro */
85 #endif
86
87 /* Location of firmware patch files */
88 #ifndef FW_PATCHFILE_LOCATION
89 #define FW_PATCHFILE_LOCATION "/vendor/etc/firmware/" /* maguro */
90 #endif
91
92 #ifndef UART_TARGET_BAUD_RATE
93 #define UART_TARGET_BAUD_RATE 3000000
94 #endif
95
96
97
98 /* The Bluetooth Device Aaddress source switch:
99 *
100 * -FALSE- (default value)
101 * Get the factory BDADDR from device's file system. Normally the BDADDR is
102 * stored in the location pointed by the PROPERTY_BT_BDADDR_PATH (defined in
103 * btif_common.h file) property.
104 *
105 * -TRUE-
106 * If the Bluetooth Controller has equipped with a non-volatile memory (such
107 * as BCM4330's OTP memory), the factory BDADDR can be stored in there and
108 * retrieved by the stack while enabling BT.
109 * !!! WARNING !!! Make sure that the OTP feature has been enabled in the
110 * firmware patchram (.hcd) file.
111 */
112 #ifndef USE_CONTROLLER_BDADDR
113 #define USE_CONTROLLER_BDADDR FALSE
114 #endif
115
116 /* sleep mode
117
118 0: disable
119 1: UART with Host wake/BT wake out of band signals
120 */
121 #ifndef LPM_SLEEP_MODE
122 #define LPM_SLEEP_MODE 1
123 #endif
124
125 /* Host Stack Idle Threshold in 300ms or 25ms
126
127 In sleep mode 1, this is the number of firmware loops executed with no
128 activity before the Host wake line is deasserted. Activity includes HCI
129 traffic excluding certain sleep mode commands and the presence of SCO
130 connections if the "Allow Host Sleep During SCO" flag is not set to 1.
131 Each count of this parameter is roughly equivalent to 300ms or 25ms.
132 */
133 #ifndef LPM_IDLE_THRESHOLD
134 #define LPM_IDLE_THRESHOLD 1
135 #endif
136
137 /* Host Controller Idle Threshold in 300ms or 25ms
138
139 This is the number of firmware loops executed with no activity before the
140 HC is considered idle. Depending on the mode, HC may then attempt to sleep.
141 Activity includes HCI traffic excluding certain sleep mode commands and
142 the presence of ACL/SCO connections.
143 */
144 #ifndef LPM_HC_IDLE_THRESHOLD
145 #define LPM_HC_IDLE_THRESHOLD 1
146 #endif
147
148 /* BT_WAKE Polarity - 0=Active Low, 1= Active High */
149 #ifndef LPM_BT_WAKE_POLARITY
150 #define LPM_BT_WAKE_POLARITY 1 /* maguro */
151 #endif
152
153 /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
154 #ifndef LPM_HOST_WAKE_POLARITY
155 #define LPM_HOST_WAKE_POLARITY 1 /* maguro */
156 #endif
157
158 /* LPM_ALLOW_HOST_SLEEP_DURING_SCO
159
160 When this flag is set to 0, the host is not allowed to sleep while
161 an SCO is active. In sleep mode 1, the device will keep the host
162 wake line asserted while an SCO is active.
163 When this flag is set to 1, the host can sleep while an SCO is active.
164 This flag should only be set to 1 if SCO traffic is directed to the PCM
165 interface.
166 */
167 #ifndef LPM_ALLOW_HOST_SLEEP_DURING_SCO
168 #define LPM_ALLOW_HOST_SLEEP_DURING_SCO 1
169 #endif
170
171 /* LPM_COMBINE_SLEEP_MODE_AND_LPM
172
173 In Mode 0, always set byte 7 to 0. In sleep mode 1, device always
174 requires permission to sleep between scans / periodic inquiries regardless
175 of the setting of this byte. In sleep mode 1, if byte is set, device must
176 have "permission" to sleep during the low power modes of sniff, hold, and
177 park. If byte is not set, device can sleep without permission during these
178 modes. Permission to sleep in Mode 1 is obtained if the BT_WAKE signal is
179 not asserted.
180 */
181 #ifndef LPM_COMBINE_SLEEP_MODE_AND_LPM
182 #define LPM_COMBINE_SLEEP_MODE_AND_LPM 1
183 #endif
184
185 /* LPM_ENABLE_UART_TXD_TRI_STATE
186
187 When set to 0, the device will not tristate its UART TX line before going
188 to sleep.
189 When set to 1, the device will tristate its UART TX line before going to
190 sleep.
191 */
192 #ifndef LPM_ENABLE_UART_TXD_TRI_STATE
193 #define LPM_ENABLE_UART_TXD_TRI_STATE 0
194 #endif
195
196 /* LPM_PULSED_HOST_WAKE
197 */
198 #ifndef LPM_PULSED_HOST_WAKE
199 #define LPM_PULSED_HOST_WAKE 0
200 #endif
201
202 /* LPM_IDLE_TIMEOUT_MULTIPLE
203
204 The multiple factor of host stack idle threshold in 300ms/25ms
205 */
206 #ifndef LPM_IDLE_TIMEOUT_MULTIPLE
207 #define LPM_IDLE_TIMEOUT_MULTIPLE 10
208 #endif
209
210 /* BT_WAKE_VIA_USERIAL_IOCTL
211
212 Use userial ioctl function to control BT_WAKE signal
213 */
214 #ifndef BT_WAKE_VIA_USERIAL_IOCTL
215 #define BT_WAKE_VIA_USERIAL_IOCTL FALSE
216 #endif
217
218 /* BT_WAKE_VIA_PROC
219
220 LPM & BT_WAKE control through PROC nodes
221 */
222 #ifndef BT_WAKE_VIA_PROC
223 #define BT_WAKE_VIA_PROC FALSE
224 #endif
225
226 /* HW_END_WITH_HCI_RESET
227
228 Sample code implementation of sending a HCI_RESET command during the epilog
229 process. It calls back to the callers after command complete of HCI_RESET
230 is received.
231 */
232 #ifndef HW_END_WITH_HCI_RESET
233 #define HW_END_WITH_HCI_RESET FALSE
234 #endif
235
236 /******************************************************************************
237 ** Extern variables and functions
238 ******************************************************************************/
239
240 extern bt_vendor_callbacks_t *bt_vendor_cbacks;
241
242 #endif /* BT_VENDOR_RTK_H */