realtek bt bringup
[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 #define DOWN_FW_CFG _IOW('H', 201, int)
82 #define SET_ISO_CFG _IOW('H', 202, int)
83 #define GET_USB_INFO _IOW('H', 203, int)
84 #define RESET_CONTROLLER _IOW('H', 204, int)
85
86 /* Device port name where Bluetooth controller attached */
87 #ifndef BLUETOOTH_UART_DEVICE_PORT
88 #define BLUETOOTH_UART_DEVICE_PORT "/dev/ttyS1" /* maguro */
89 #endif
90
91 /* Location of firmware patch files */
92 #ifndef FW_PATCHFILE_LOCATION
93 #define FW_PATCHFILE_LOCATION "/vendor/etc/firmware/" /* maguro */
94 #endif
95
96 #ifndef UART_TARGET_BAUD_RATE
97 #define UART_TARGET_BAUD_RATE 3000000
98 #endif
99
100
101
102 /* The Bluetooth Device Aaddress source switch:
103 *
104 * -FALSE- (default value)
105 * Get the factory BDADDR from device's file system. Normally the BDADDR is
106 * stored in the location pointed by the PROPERTY_BT_BDADDR_PATH (defined in
107 * btif_common.h file) property.
108 *
109 * -TRUE-
110 * If the Bluetooth Controller has equipped with a non-volatile memory (such
111 * as BCM4330's OTP memory), the factory BDADDR can be stored in there and
112 * retrieved by the stack while enabling BT.
113 * !!! WARNING !!! Make sure that the OTP feature has been enabled in the
114 * firmware patchram (.hcd) file.
115 */
116 #ifndef USE_CONTROLLER_BDADDR
117 #define USE_CONTROLLER_BDADDR TRUE //FALSE
118 #endif
119
120 /* sleep mode
121
122 0: disable
123 1: UART with Host wake/BT wake out of band signals
124 */
125 #ifndef LPM_SLEEP_MODE
126 #define LPM_SLEEP_MODE 1
127 #endif
128
129 /* Host Stack Idle Threshold in 300ms or 25ms
130
131 In sleep mode 1, this is the number of firmware loops executed with no
132 activity before the Host wake line is deasserted. Activity includes HCI
133 traffic excluding certain sleep mode commands and the presence of SCO
134 connections if the "Allow Host Sleep During SCO" flag is not set to 1.
135 Each count of this parameter is roughly equivalent to 300ms or 25ms.
136 */
137 #ifndef LPM_IDLE_THRESHOLD
138 #define LPM_IDLE_THRESHOLD 1
139 #endif
140
141 /* Host Controller Idle Threshold in 300ms or 25ms
142
143 This is the number of firmware loops executed with no activity before the
144 HC is considered idle. Depending on the mode, HC may then attempt to sleep.
145 Activity includes HCI traffic excluding certain sleep mode commands and
146 the presence of ACL/SCO connections.
147 */
148 #ifndef LPM_HC_IDLE_THRESHOLD
149 #define LPM_HC_IDLE_THRESHOLD 1
150 #endif
151
152 /* BT_WAKE Polarity - 0=Active Low, 1= Active High */
153 #ifndef LPM_BT_WAKE_POLARITY
154 #define LPM_BT_WAKE_POLARITY 1 /* maguro */
155 #endif
156
157 /* HOST_WAKE Polarity - 0=Active Low, 1= Active High */
158 #ifndef LPM_HOST_WAKE_POLARITY
159 #define LPM_HOST_WAKE_POLARITY 1 /* maguro */
160 #endif
161
162 /* LPM_ALLOW_HOST_SLEEP_DURING_SCO
163
164 When this flag is set to 0, the host is not allowed to sleep while
165 an SCO is active. In sleep mode 1, the device will keep the host
166 wake line asserted while an SCO is active.
167 When this flag is set to 1, the host can sleep while an SCO is active.
168 This flag should only be set to 1 if SCO traffic is directed to the PCM
169 interface.
170 */
171 #ifndef LPM_ALLOW_HOST_SLEEP_DURING_SCO
172 #define LPM_ALLOW_HOST_SLEEP_DURING_SCO 1
173 #endif
174
175 /* LPM_COMBINE_SLEEP_MODE_AND_LPM
176
177 In Mode 0, always set byte 7 to 0. In sleep mode 1, device always
178 requires permission to sleep between scans / periodic inquiries regardless
179 of the setting of this byte. In sleep mode 1, if byte is set, device must
180 have "permission" to sleep during the low power modes of sniff, hold, and
181 park. If byte is not set, device can sleep without permission during these
182 modes. Permission to sleep in Mode 1 is obtained if the BT_WAKE signal is
183 not asserted.
184 */
185 #ifndef LPM_COMBINE_SLEEP_MODE_AND_LPM
186 #define LPM_COMBINE_SLEEP_MODE_AND_LPM 1
187 #endif
188
189 /* LPM_ENABLE_UART_TXD_TRI_STATE
190
191 When set to 0, the device will not tristate its UART TX line before going
192 to sleep.
193 When set to 1, the device will tristate its UART TX line before going to
194 sleep.
195 */
196 #ifndef LPM_ENABLE_UART_TXD_TRI_STATE
197 #define LPM_ENABLE_UART_TXD_TRI_STATE 0
198 #endif
199
200 /* LPM_PULSED_HOST_WAKE
201 */
202 #ifndef LPM_PULSED_HOST_WAKE
203 #define LPM_PULSED_HOST_WAKE 0
204 #endif
205
206 /* LPM_IDLE_TIMEOUT_MULTIPLE
207
208 The multiple factor of host stack idle threshold in 300ms/25ms
209 */
210 #ifndef LPM_IDLE_TIMEOUT_MULTIPLE
211 #define LPM_IDLE_TIMEOUT_MULTIPLE 10
212 #endif
213
214 /* BT_WAKE_VIA_USERIAL_IOCTL
215
216 Use userial ioctl function to control BT_WAKE signal
217 */
218 #ifndef BT_WAKE_VIA_USERIAL_IOCTL
219 #define BT_WAKE_VIA_USERIAL_IOCTL FALSE
220 #endif
221
222 /* BT_WAKE_VIA_PROC
223
224 LPM & BT_WAKE control through PROC nodes
225 */
226 #ifndef BT_WAKE_VIA_PROC
227 #define BT_WAKE_VIA_PROC FALSE
228 #endif
229
230 /* HW_END_WITH_HCI_RESET
231
232 Sample code implementation of sending a HCI_RESET command during the epilog
233 process. It calls back to the callers after command complete of HCI_RESET
234 is received.
235 */
236 #ifndef HW_END_WITH_HCI_RESET
237 #define HW_END_WITH_HCI_RESET FALSE
238 #endif
239
240 /******************************************************************************
241 ** Extern variables and functions
242 ******************************************************************************/
243
244 extern bt_vendor_callbacks_t *bt_vendor_cbacks;
245
246 #endif /* BT_VENDOR_RTK_H */