blob: 3c879a58203ef51d6add392566d6665a29eb1769 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42/******************************************************************************
43*
44* Name: btcApi.h
45*
46* Description: BTC Events Layer API definitions.
47*
48* Copyright 2008 (c) Qualcomm, Incorporated. All Rights Reserved.
49* Qualcomm Confidential and Proprietary.
50*
51******************************************************************************/
52
53#ifndef __BTC_API_H__
54#define __BTC_API_H__
55
56#include "vos_types.h"
57#include "vos_timer.h"
58
59#define BT_INVALID_CONN_HANDLE (0xFFFF) /**< Invalid connection handle */
60
61/* ACL and Sync connection attempt results */
62#define BT_CONN_STATUS_FAIL (0) /**< Connection failed */
63#define BT_CONN_STATUS_SUCCESS (1) /**< Connection successful */
64#define BT_CONN_STATUS_MAX (2) /**< This and beyond are invalid values */
65
66/** ACL and Sync link types
67 These must match the Bluetooth Spec!
68*/
69#define BT_SCO (0) /**< SCO Link */
70#define BT_ACL (1) /**< ACL Link */
71#define BT_eSCO (2) /**< eSCO Link */
72#define BT_LINK_TYPE_MAX (3) /**< This value and higher are invalid */
73
74/** ACL link modes
75 These must match the Bluetooth Spec!
76*/
77#define BT_ACL_ACTIVE (0) /**< Active mode */
78#define BT_ACL_HOLD (1) /**< Hold mode */
79#define BT_ACL_SNIFF (2) /**< Sniff mode */
80#define BT_ACL_PARK (3) /**< Park mode */
81#define BT_ACL_MODE_MAX (4) /**< This value and higher are invalid */
82
83/**
84 * A2DP BTC max no of BT sub intervals
85 *
86 * **/
87#define BTC_MAX_NUM_ACL_BT_SUB_INTS (7)
88
89/** BTC Executions Modes allowed to be set by user
90*/
91#define BTC_SMART_COEXISTENCE (0) /** BTC Mapping Layer decides whats best */
92#define BTC_WLAN_ONLY (1) /** WLAN takes all mode */
93#define BTC_PTA_ONLY (2) /** Allow only 3 wire protocol in H/W */
94#define BTC_SMART_MAX_WLAN (3) /** BTC Mapping Layer decides whats best, WLAN weighted */
95#define BTC_SMART_MAX_BT (4) /** BTC Mapping Layer decides whats best, BT weighted */
96#define BTC_SMART_BT_A2DP (5) /** BTC Mapping Layer decides whats best, balanced + BT A2DP weight */
97#define BT_EXEC_MODE_MAX (6) /** This and beyond are invalid values */
98
99/** Enumeration of different kinds actions that BTC Mapping Layer
100 can do if PM indication (to AP) fails.
101*/
102#define BTC_RESTART_CURRENT (0) /** Restart the interval we just failed to leave */
103#define BTC_START_NEXT (1) /** Start the next interval even though the PM transition at the AP was unsuccessful */
104#define BTC_ACTION_TYPE_MAX (2) /** This and beyond are invalid values */
105
106#define BTC_BT_INTERVAL_MODE1_DEFAULT (120) /** BT Interval in Mode 1 */
107#define BTC_WLAN_INTERVAL_MODE1_DEFAULT (30) /** WLAN Interval in Mode 1 */
108
109/** Bitmaps used for maintaining various BT events that requires
110 enough time to complete such that it might require disbling of
111 heartbeat monitoring to avoid WLAN link loss with the AP
112*/
113#define BT_INQUIRY_STARTED (1<<0)
114#define BT_PAGE_STARTED (1<<1)
115#define BT_CREATE_ACL_CONNECTION_STARTED (1<<2)
116#define BT_CREATE_SYNC_CONNECTION_STARTED (1<<3)
117
118/** Maximum time duration in milliseconds between a specific BT start event and its
119 respective stop event, before it can be declared timed out on receiving the stop event.
120*/
121#define BT_MAX_EVENT_DONE_TIMEOUT 45000
122
123
124/*
125 To suppurt multiple SCO connections for BT+UAPSD work
126*/
127#define BT_MAX_SCO_SUPPORT 3
128#define BT_MAX_ACL_SUPPORT 3
129#define BT_MAX_DISCONN_SUPPORT (BT_MAX_SCO_SUPPORT+BT_MAX_ACL_SUPPORT)
130#define BT_MAX_NUM_EVENT_ACL_DEFERRED 4 //We may need to defer these many BT events for ACL
131#define BT_MAX_NUM_EVENT_SCO_DEFERRED 4 //We may need to defer these many BT events for SYNC
132
Jeff Johnson32d95a32012-09-10 13:15:23 -0700133/** Default values for the BTC tunables parameters
134*/
135#define BTC_STATIC_BT_LEN_INQ_DEF (120000) // 120 msec
136#define BTC_STATIC_BT_LEN_PAGE_DEF (10000) // 10 msec (don't care)
137#define BTC_STATIC_BT_LEN_CONN_DEF (10000) // 10 msec (don't care)
138#define BTC_STATIC_BT_LEN_LE_DEF (10000) // 10 msec (don't care)
139#define BTC_STATIC_WLAN_LEN_INQ_DEF (30000) // 30 msec
140#define BTC_STATIC_WLAN_LEN_PAGE_DEF (0) // 0 msec (BT takes all)
141#define BTC_STATIC_WLAN_LEN_CONN_DEF (0) // 0 msec (BT takes all)
142#define BTC_STATIC_WLAN_LEN_LE_DEF (0) // 0 msec (BT takes all)
143#define BTC_DYNAMIC_BT_LEN_MAX_DEF (250000) // 250 msec
144#define BTC_DYNAMIC_WLAN_LEN_MAX_DEF (45000) // 45 msec
145#define BTC_SCO_BLOCK_PERC_DEF (1) // 1 percent
146#define BTC_DHCP_ON_A2DP_DEF (1) // ON
147#define BTC_DHCP_ON_SCO_DEF (0) // OFF
Jeff Johnson295189b2012-06-20 16:38:30 -0700148
Wilson Tsaof8b37942013-09-06 10:49:00 -0700149/*
150 * Number of victim tables and mws coex configurations
151 */
152#define MWS_COEX_MAX_VICTIM_TABLE 10
153#define MWS_COEX_MAX_CONFIG 6
154
Jeff Johnson295189b2012-06-20 16:38:30 -0700155/** Enumeration of all the different kinds of BT events
156*/
157typedef enum eSmeBtEventType
158{
159 BT_EVENT_DEVICE_SWITCHED_ON,
160 BT_EVENT_DEVICE_SWITCHED_OFF,
161 BT_EVENT_INQUIRY_STARTED,
162 BT_EVENT_INQUIRY_STOPPED,
163 BT_EVENT_INQUIRY_SCAN_STARTED,
164 BT_EVENT_INQUIRY_SCAN_STOPPED,
165 BT_EVENT_PAGE_STARTED,
166 BT_EVENT_PAGE_STOPPED,
167 BT_EVENT_PAGE_SCAN_STARTED,
168 BT_EVENT_PAGE_SCAN_STOPPED,
169 BT_EVENT_CREATE_ACL_CONNECTION,
170 BT_EVENT_ACL_CONNECTION_COMPLETE,
171 BT_EVENT_CREATE_SYNC_CONNECTION,
172 BT_EVENT_SYNC_CONNECTION_COMPLETE,
173 BT_EVENT_SYNC_CONNECTION_UPDATED,
174 BT_EVENT_DISCONNECTION_COMPLETE,
175 BT_EVENT_MODE_CHANGED,
176 BT_EVENT_A2DP_STREAM_START,
177 BT_EVENT_A2DP_STREAM_STOP,
178 BT_EVENT_TYPE_MAX, //This and beyond are invalid values
179} tSmeBtEventType;
180
181/** BT-AMP events type
182*/
183typedef enum eSmeBtAmpEventType
184{
185 BTAMP_EVENT_CONNECTION_START,
186 BTAMP_EVENT_CONNECTION_STOP,
187 BTAMP_EVENT_CONNECTION_TERMINATED,
188 BTAMP_EVENT_TYPE_MAX, //This and beyond are invalid values
189} tSmeBtAmpEventType;
190
191
192/**Data structure that specifies the needed event parameters for
193 BT_EVENT_CREATE_ACL_CONNECTION and BT_EVENT_ACL_CONNECTION_COMPLETE
194*/
195typedef struct sSmeBtAclConnectionParam
196{
197 v_U8_t bdAddr[6];
198 v_U16_t connectionHandle;
199 v_U8_t status;
200} tSmeBtAclConnectionParam, *tpSmeBtAclConnectionParam;
201
202/** Data structure that specifies the needed event parameters for
203 BT_EVENT_CREATE_SYNC_CONNECTION, BT_EVENT_SYNC_CONNECTION_COMPLETE
204 and BT_EVENT_SYNC_CONNECTION_UPDATED
205*/
206typedef struct sSmeBtSyncConnectionParam
207{
208 v_U8_t bdAddr[6];
209 v_U16_t connectionHandle;
210 v_U8_t status;
211 v_U8_t linkType;
212 v_U8_t scoInterval; //units in number of 625us slots
213 v_U8_t scoWindow; //units in number of 625us slots
214 v_U8_t retransmisisonWindow; //units in number of 625us slots
215} tSmeBtSyncConnectionParam, *tpSmeBtSyncConnectionParam;
216
217typedef struct sSmeBtSyncUpdateHist
218{
219 tSmeBtSyncConnectionParam btSyncConnection;
220 v_BOOL_t fValid;
221} tSmeBtSyncUpdateHist, *tpSmeBtSyncUpdateHist;
222
223/**Data structure that specifies the needed event parameters for
224 BT_EVENT_MODE_CHANGED
225*/
226typedef struct sSmeBtAclModeChangeParam
227{
228 v_U16_t connectionHandle;
229 v_U8_t mode;
230} tSmeBtAclModeChangeParam, *tpSmeBtAclModeChangeParam;
231
232/*Data structure that specifies the needed event parameters for
233 BT_EVENT_DISCONNECTION_COMPLETE
234*/
235typedef struct sSmeBtDisconnectParam
236{
237 v_U16_t connectionHandle;
238} tSmeBtDisconnectParam, *tpSmeBtDisconnectParam;
239
240/*Data structure that specifies the needed event parameters for
241 BT_EVENT_A2DP_STREAM_START
242 BT_EVENT_A2DP_STREAM_STOP
243*/
244typedef struct sSmeBtA2DPParam
245{
246 v_U8_t bdAddr[6];
247} tSmeBtA2DPParam, *tpSmeBtA2DPParam;
248
249
250/** Generic Bluetooth Event structure for BTC
251*/
252typedef struct sSmeBtcBtEvent
253{
254 tSmeBtEventType btEventType;
255 union
256 {
257 v_U8_t bdAddr[6]; /**< For events with only a BT Addr in event_data */
258 tSmeBtAclConnectionParam btAclConnection;
259 tSmeBtSyncConnectionParam btSyncConnection;
260 tSmeBtDisconnectParam btDisconnect;
261 tSmeBtAclModeChangeParam btAclModeChange;
262 }uEventParam;
263} tSmeBtEvent, *tpSmeBtEvent;
264
265
266/**
267 BT-AMP Event Structure
268*/
269typedef struct sSmeBtAmpEvent
270{
271 tSmeBtAmpEventType btAmpEventType;
272
273} tSmeBtAmpEvent, *tpSmeBtAmpEvent;
274
275
276/** Data structure that specifies the BTC Configuration parameters
277*/
278typedef struct sSmeBtcConfig
279{
280 v_U8_t btcExecutionMode;
281 v_U8_t btcConsBtSlotsToBlockDuringDhcp;
282 v_U8_t btcA2DPBtSubIntervalsDuringDhcp;
283 v_U8_t btcActionOnPmFail;
284 v_U8_t btcBtIntervalMode1;
285 v_U8_t btcWlanIntervalMode1;
286
Jeff Johnson32d95a32012-09-10 13:15:23 -0700287 v_U32_t btcStaticLenInqBt;
288 v_U32_t btcStaticLenPageBt;
289 v_U32_t btcStaticLenConnBt;
290 v_U32_t btcStaticLenLeBt;
291 v_U32_t btcStaticLenInqWlan;
292 v_U32_t btcStaticLenPageWlan;
293 v_U32_t btcStaticLenConnWlan;
294 v_U32_t btcStaticLenLeWlan;
295 v_U32_t btcDynMaxLenBt;
296 v_U32_t btcDynMaxLenWlan;
297 v_U32_t btcMaxScoBlockPerc;
298 v_U32_t btcDhcpProtOnA2dp;
299 v_U32_t btcDhcpProtOnSco;
Wilson Tsaof8b37942013-09-06 10:49:00 -0700300
301 v_U32_t mwsCoexVictimWANFreq[MWS_COEX_MAX_VICTIM_TABLE];
302 v_U32_t mwsCoexVictimWLANFreq[MWS_COEX_MAX_VICTIM_TABLE];
303 v_U32_t mwsCoexVictimConfig[MWS_COEX_MAX_VICTIM_TABLE];
304 v_U32_t mwsCoexVictimConfig2[MWS_COEX_MAX_VICTIM_TABLE];
305 v_U32_t mwsCoexModemBackoff;
306 v_U32_t mwsCoexConfig[MWS_COEX_MAX_CONFIG];
307 v_U32_t SARPowerBackoff;
Jeff Johnson295189b2012-06-20 16:38:30 -0700308} tSmeBtcConfig, *tpSmeBtcConfig;
309
310
311typedef struct sSmeBtAclModeChangeEventHist
312{
313 tSmeBtAclModeChangeParam btAclModeChange;
314 v_BOOL_t fValid;
315} tSmeBtAclModeChangeEventHist, *tpSmeBtAclModeChangeEventHist;
316
317typedef struct sSmeBtAclEventHist
318{
319 //At most, cached events are COMPLETION, DISCONNECT, CREATION, COMPLETION
320 tSmeBtEventType btEventType[BT_MAX_NUM_EVENT_ACL_DEFERRED];
321 tSmeBtAclConnectionParam btAclConnection[BT_MAX_NUM_EVENT_ACL_DEFERRED];
322 //bNextEventIdx == 0 meaning no event cached here
323 tANI_U8 bNextEventIdx;
324} tSmeBtAclEventHist, *tpSmeBtAclEventHist;
325
326typedef struct sSmeBtSyncEventHist
327{
328 //At most, cached events are COMPLETION, DISCONNECT, CREATION, COMPLETION
329 tSmeBtEventType btEventType[BT_MAX_NUM_EVENT_SCO_DEFERRED];
330 tSmeBtSyncConnectionParam btSyncConnection[BT_MAX_NUM_EVENT_SCO_DEFERRED];
331 //bNextEventIdx == 0 meaning no event cached here
332 tANI_U8 bNextEventIdx;
333} tSmeBtSyncEventHist, *tpSmeBtSyncEventHist;
334
335typedef struct sSmeBtDisconnectEventHist
336{
337 tSmeBtDisconnectParam btDisconnect;
338 v_BOOL_t fValid;
339} tSmeBtDisconnectEventHist, *tpSmeBtDisconnectEventHist;
340
341
342/*
343 Data structure for the history of BT events
344*/
345typedef struct sSmeBtcEventHist
346{
347 tSmeBtSyncEventHist btSyncConnectionEvent[BT_MAX_SCO_SUPPORT];
348 tSmeBtAclEventHist btAclConnectionEvent[BT_MAX_ACL_SUPPORT];
349 tSmeBtAclModeChangeEventHist btAclModeChangeEvent[BT_MAX_ACL_SUPPORT];
350 tSmeBtDisconnectEventHist btDisconnectEvent[BT_MAX_DISCONN_SUPPORT];
351 tSmeBtSyncUpdateHist btSyncUpdateEvent[BT_MAX_SCO_SUPPORT];
352 int nInquiryEvent; //>0 for # of outstanding inquiriy starts
353 //<0 for # of outstanding inquiry stops
354 //0 == no inquiry event
355 int nPageEvent; //>0 for # of outstanding page starts
356 //<0 for # of outstanding page stops
357 //0 == no page event
358 v_BOOL_t fA2DPStarted;
359 v_BOOL_t fA2DPStopped;
360} tSmeBtcEventHist, *tpSmeBtcEventHist;
361
362typedef struct sSmeBtcEventReplay
363{
364 tSmeBtcEventHist btcEventHist;
365 v_BOOL_t fBTSwitchOn;
366 v_BOOL_t fBTSwitchOff;
367 //This is not directly tied to BT event so leave it alone when processing BT events
368 v_BOOL_t fRestoreHBMonitor;
369} tSmeBtcEventReplay, *tpSmeBtcEventReplay;
370
371typedef struct sSmeBtcInfo
372{
373 tSmeBtcConfig btcConfig;
374 v_BOOL_t btcReady;
375 v_U8_t btcEventState;
376 v_U8_t btcHBActive; /* Is HB currently active */
377 v_U8_t btcHBCount; /* default HB count */
378 vos_timer_t restoreHBTimer; /* Timer to restore heart beat */
379 tSmeBtcEventReplay btcEventReplay;
380 v_BOOL_t fReplayBTEvents;
381 v_BOOL_t btcUapsdOk; /* Indicate whether BTC is ok with UAPSD */
382 v_BOOL_t fA2DPTrafStop;/*flag to check A2DP_STOP event has come before MODE_CHANGED*/
383 v_U16_t btcScoHandles[BT_MAX_SCO_SUPPORT]; /* Handles for SCO, if any*/
384 v_BOOL_t fA2DPUp; /*remember whether A2DP is in session*/
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -0800385 v_BOOL_t btcScanCompromise;
Jeff Johnson295189b2012-06-20 16:38:30 -0700386} tSmeBtcInfo, *tpSmeBtcInfo;
387
388
389/** Routine definitions
390*/
391
392#ifndef WLAN_MDM_CODE_REDUCTION_OPT
393VOS_STATUS btcOpen (tHalHandle hHal);
394VOS_STATUS btcClose (tHalHandle hHal);
395VOS_STATUS btcReady (tHalHandle hHal);
396VOS_STATUS btcSendCfgMsg(tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig);
397VOS_STATUS btcSignalBTEvent (tHalHandle hHal, tpSmeBtEvent pBtEvent);
398VOS_STATUS btcSetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig);
399VOS_STATUS btcGetConfig (tHalHandle hHal, tpSmeBtcConfig pSmeBtcConfig);
400/*
401 Caller can check whether BTC's current event allows UAPSD. This doesn't affect
402 BMPS.
403 return: VOS_TRUE -- BTC is ready for UAPSD
404 VOS_FALSE -- certain BT event is active, cannot enter UAPSD
405*/
406v_BOOL_t btcIsReadyForUapsd( tHalHandle hHal );
407eHalStatus btcHandleCoexInd(tHalHandle hHal, void* pMsg);
408#endif /* End of WLAN_MDM_CODE_REDUCTION_OPT */
409
410#endif