• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * SoftGemini.c
3  *
4  * Copyright(c) 1998 - 2009 Texas Instruments. All rights reserved.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  *  * Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  *  * Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  *  * Neither the name Texas Instruments nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /** \file softGemini.c
35  *  \brief BlueTooth-Wlan coexistence module interface
36  *
37  *  \see softGemini.h
38  */
39 
40 /****************************************************************************************************
41 *																									*
42 *		MODULE:		softGemini.c																	*
43 *		PURPOSE:	BlueTooth-Wlan coexistence module interface.							*
44 *					This module handles all data base (and Fw setting accordingly)					*
45 *					for Bluetooth-Wlan coexistence implementation.									*
46 *																						 			*
47 ****************************************************************************************************/
48 
49 #define __FILE_ID__  FILE_ID_5
50 #include "report.h"
51 #include "osApi.h"
52 #include "SoftGemini.h"
53 #include "DataCtrl_Api.h"
54 #include "scrApi.h"
55 #include "PowerMgr_API.h"
56 #include "ScanCncn.h"
57 #include "currBss.h"
58 #include "CmdDispatcher.h"
59 #include "TWDriver.h"
60 #include "DrvMainModules.h"
61 #include "bssTypes.h"
62 #include "sme.h"
63 
64 
65 #define SENSE_MODE_ENABLE		0x01
66 #define SENSE_MODE_DISABLE		0x00
67 #define PROTECTIVE_MODE_ON		0x01
68 #define PROTECTIVE_MODE_OFF		0x00
69 
70 /********************************************************************************/
71 /*						Internal functions prototypes.							*/
72 /********************************************************************************/
73 
74 static TI_STATUS SoftGemini_setEnableParam(TI_HANDLE hSoftGemini, ESoftGeminiEnableModes SoftGeminiEnable, TI_BOOL recovery);
75 static TI_STATUS SoftGemini_setParamsToFW(TI_HANDLE hSoftGemini, TSoftGeminiParams *SoftGeminiParam);
76 static TI_STATUS SoftGemini_EnableDriver(TI_HANDLE hSoftGemini);
77 static TI_STATUS SoftGemini_DisableDriver(TI_HANDLE hSoftGemini);
78 static TI_STATUS SoftGemini_SetPS(SoftGemini_t	 *pSoftGemini);
79 static TI_STATUS SoftGemini_unSetPS(SoftGemini_t *pSoftGemini);
80 static void SoftGemini_RemoveProtectiveModeParameters(TI_HANDLE hSoftGemini);
81 static void SoftGemini_setConfigParam(TI_HANDLE hSoftGemini, TI_UINT32 *param);
82 static void SoftGemini_EnableProtectiveMode(TI_HANDLE hSoftGemini);
83 static void SoftGemini_DisableProtectiveMode(TI_HANDLE hSoftGemini);
84 #ifdef REPORT_LOG
85 static char* SoftGemini_ConvertModeToString(ESoftGeminiEnableModes SoftGeminiEnable);
86 #endif
87 
88 /********************************************************************************/
89 /*						Interface functions Implementation.						*/
90 /********************************************************************************/
91 /************************************************************************
92  *                        SoftGemini_SetPSmode									*
93  ************************************************************************
94 DESCRIPTION: SoftGemini module, called by the conn_Infra on connection
95 				performs the following:
96 				-	Enables SG if needed
97                                 -       Enables the SG power mode
98 INPUT:      hSoftGemini -		Handle to SoftGemini
99 
100 OUTPUT:
101 
102 RETURN:
103 
104 ************************************************************************/
SoftGemini_SetPSmode(TI_HANDLE hSoftGemini)105 void SoftGemini_SetPSmode(TI_HANDLE hSoftGemini)
106 {
107 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
108 
109 	if (pSoftGemini)
110 	{
111 		if (pSoftGemini->bDriverEnabled)
112 		{
113 			/* Check if coexAutoPsMode is enabled to enter/exit P.S */
114 			if ( pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_PS_MODE])
115 			{
116 				SoftGemini_SetPS(pSoftGemini);
117 			}
118 		}
119 		if (pSoftGemini->bProtectiveMode)
120 		{
121 			SoftGemini_EnableProtectiveMode(hSoftGemini);
122 		}
123 	}
124 	else
125         {
126           TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_ERROR, "  SoftGemini_SetPSmode() - Error hSoftGemini= NULL \n");
127         }
128 }
129 
130 /************************************************************************
131  *                        SoftGemini_unSetPSmode									*
132  ************************************************************************
133 DESCRIPTION: SoftGemini module, called by the conn_Infra after disconnecting
134 				performs the following:
135 				-	Disables the SG
136                                 -       Disables the SG power mode
137 INPUT:      hSoftGemini -		Handle to SoftGemini
138 
139 OUTPUT:
140 
141 RETURN:
142 
143 ************************************************************************/
SoftGemini_unSetPSmode(TI_HANDLE hSoftGemini)144 void SoftGemini_unSetPSmode(TI_HANDLE hSoftGemini)
145 {
146 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
147 
148     if (pSoftGemini)
149 	{
150 		if (pSoftGemini->bDriverEnabled)
151 		{
152 			/* Check if coexAutoPsMode is enabled to enter/exit P.S */
153 			if ( pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_PS_MODE])
154 			{
155 				SoftGemini_unSetPS(pSoftGemini);
156 			}
157 		}
158 		if (pSoftGemini->bProtectiveMode)
159 		{
160 			SoftGemini_RemoveProtectiveModeParameters(hSoftGemini);
161 		}
162 	}
163     else
164     {
165 		TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_ERROR, " SoftGemini_unSetPSmode() - Error hSoftGemini= NULL \n");
166     }
167 }
168 
169 /************************************************************************
170  *                        SoftGemini_create									*
171  ************************************************************************
172 DESCRIPTION: SoftGemini module creation function, called by the config mgr in creation phase
173 				performs the following:
174 				-	Allocate the SoftGemini handle
175 
176 INPUT:      hOs -			Handle to OS
177 
178 
179 OUTPUT:
180 
181 RETURN:     Handle to the SoftGemini module on success, NULL otherwise
182 
183 ************************************************************************/
SoftGemini_create(TI_HANDLE hOs)184 TI_HANDLE SoftGemini_create(TI_HANDLE hOs)
185 {
186 	SoftGemini_t			*pSoftGemini = NULL;
187 
188 	/* allocating the SoftGemini object */
189 	pSoftGemini = os_memoryAlloc(hOs,sizeof(SoftGemini_t));
190 
191 	if (pSoftGemini == NULL)
192 		return NULL;
193 
194 	pSoftGemini->hOs = hOs;
195 
196 	return pSoftGemini;
197 }
198 
199 /************************************************************************
200  *                        SoftGemini_config						*
201  ************************************************************************
202 DESCRIPTION: SoftGemini module init function, called by the rvMain in init phase
203 				performs the following:
204 				-	Init local variables
205 				-	Init the handles to be used by the module
206 
207 INPUT:       pStadHandles  - The driver modules handles
208 
209 OUTPUT:
210 
211 RETURN:      void
212 ************************************************************************/
SoftGemini_init(TStadHandlesList * pStadHandles)213 void SoftGemini_init (TStadHandlesList *pStadHandles)
214 {
215 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)(pStadHandles->hSoftGemini);
216 
217 	pSoftGemini->hCtrlData    = pStadHandles->hCtrlData;
218 	pSoftGemini->hTWD	      = pStadHandles->hTWD;
219 	pSoftGemini->hReport	  = pStadHandles->hReport;
220 	pSoftGemini->hSCR         = pStadHandles->hSCR;
221 	pSoftGemini->hPowerMgr    = pStadHandles->hPowerMgr;
222 	pSoftGemini->hCmdDispatch = pStadHandles->hCmdDispatch;
223 	pSoftGemini->hScanCncn    = pStadHandles->hScanCncn;
224 	pSoftGemini->hCurrBss	  = pStadHandles->hCurrBss;
225     pSoftGemini->hSme         = pStadHandles->hSme;
226 }
227 
228 
SoftGemini_SetDefaults(TI_HANDLE hSoftGemini,SoftGeminiInitParams_t * pSoftGeminiInitParams)229 TI_STATUS SoftGemini_SetDefaults (TI_HANDLE hSoftGemini, SoftGeminiInitParams_t *pSoftGeminiInitParams)
230 {
231 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
232 	TI_UINT8 i =0;
233 	TI_STATUS status;
234 	/*************************************/
235 	/* Getting SoftGemini init Params */
236 	/***********************************/
237 
238 	pSoftGemini->SoftGeminiEnable = pSoftGeminiInitParams->SoftGeminiEnable;
239 
240 	for (i =0; i< SOFT_GEMINI_PARAMS_MAX ; i++)
241 	{
242 		pSoftGemini->SoftGeminiParam.coexParams[i] = pSoftGeminiInitParams->coexParams[i];
243 	}
244 
245 	pSoftGemini->SoftGeminiParam.paramIdx = 0xFF; /* signals to FW to config all the paramters */
246 
247 
248     /* Send the configuration to the FW */
249 	status = SoftGemini_setParamsToFW(hSoftGemini, &pSoftGemini->SoftGeminiParam);
250 
251 	/*******************************/
252     /* register Indication interrupts  */
253 	/*****************************/
254 
255     TWD_RegisterEvent (pSoftGemini->hTWD,
256                        TWD_OWN_EVENT_SOFT_GEMINI_SENSE,
257                        (void *)SoftGemini_SenseIndicationCB,
258                        hSoftGemini);
259 	TWD_RegisterEvent (pSoftGemini->hTWD,
260                        TWD_OWN_EVENT_SOFT_GEMINI_PREDIC,
261                        (void *)SoftGemini_ProtectiveIndicationCB,
262                        hSoftGemini);
263 
264     TWD_EnableEvent (pSoftGemini->hTWD, TWD_OWN_EVENT_SOFT_GEMINI_SENSE);
265 	TWD_EnableEvent (pSoftGemini->hTWD, TWD_OWN_EVENT_SOFT_GEMINI_PREDIC);
266 
267 	/* On system initialization SG is disabled but later calls to SoftGemini_setEnableParam() */
268 	pSoftGemini->bProtectiveMode = TI_FALSE;
269 	pSoftGemini->SoftGeminiEnable = SG_DISABLE;
270 	pSoftGemini->bDriverEnabled = TI_FALSE;
271         pSoftGemini->bPsPollFailureActive = TI_FALSE;
272 
273 	if ((TI_OK == status) && (pSoftGeminiInitParams->SoftGeminiEnable != SG_DISABLE))
274 	{	/* called only if different than SG_DISABLE */
275 		status = SoftGemini_setEnableParam(hSoftGemini, pSoftGeminiInitParams->SoftGeminiEnable, TI_FALSE);
276 	}
277 
278 	if (status == TI_OK)
279 	{
280 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INIT, "  SoftGemini_config() - configured successfully\n");
281 	}
282 	else
283 	{
284 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_ERROR, "  SoftGemini_config() - Error configuring module \n");
285 	}
286 
287 	return status;
288 }
289 
290 /************************************************************************
291  *                        SoftGemini_destroy							*
292  ************************************************************************
293 DESCRIPTION: SoftGemini module destroy function, called by the config mgr in the destroy phase
294 				performs the following:
295 				-	Free all memory aloocated by the module
296 
297 INPUT:      hSoftGemini	-	SoftGemini handle.
298 
299 
300 OUTPUT:
301 
302 RETURN:     TI_OK on success, TI_NOK otherwise
303 
304 ************************************************************************/
SoftGemini_destroy(TI_HANDLE hSoftGemini)305 TI_STATUS SoftGemini_destroy(TI_HANDLE hSoftGemini)
306 {
307 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
308 
309 	if (pSoftGemini != NULL)
310 	{
311 		os_memoryFree( pSoftGemini->hOs, (TI_HANDLE)pSoftGemini , sizeof(SoftGemini_t));
312 	}
313 
314 	return TI_OK;
315 }
316 
317 
318 /***********************************************************************
319  *                        SoftGemini_setParam
320  ***********************************************************************
321 DESCRIPTION: SoftGemini set param function, called by the following:
322 			-	config mgr in order to set a parameter receiving from the OS abstraction layer.
323 			-	From inside the driver
324 
325 INPUT:      hSoftGemini	-	SoftGemini handle.
326 			pParam	-	Pointer to the parameter
327 
328 OUTPUT:
329 
330 RETURN:     TI_OK on success, TI_NOK otherwise
331 
332 ************************************************************************/
SoftGemini_setParam(TI_HANDLE hSoftGemini,paramInfo_t * pParam)333 TI_STATUS SoftGemini_setParam(TI_HANDLE	hSoftGemini,
334 											paramInfo_t	*pParam)
335 {
336 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
337 	TI_STATUS return_value = TI_OK;
338 
339 TRACE1(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "  SoftGemini_setParam() (0x%x)\n", pParam->paramType);
340 
341 	switch(pParam->paramType)
342 	{
343 
344 	case SOFT_GEMINI_SET_ENABLE:
345 
346 		return_value = SoftGemini_setEnableParam(hSoftGemini,pParam->content.SoftGeminiEnable, TI_FALSE);
347 		break;
348 
349 	case SOFT_GEMINI_SET_CONFIG:
350 
351 		/* copy new params to SoftGemini module */
352 		SoftGemini_setConfigParam(hSoftGemini,pParam->content.SoftGeminiParamArray);
353 
354 		/* set new params to FW */
355 		return_value = SoftGemini_setParamsToFW(hSoftGemini, &(pSoftGemini->SoftGeminiParam));
356 
357 		if (pSoftGemini->bProtectiveMode == TI_TRUE)
358 		{
359 			/* set new configurations of scan to scancncn */
360 			scanCncn_SGconfigureScanParams(pSoftGemini->hScanCncn,TI_TRUE,
361 										   (TI_UINT8)pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_SCAN_PROBE_REQ],
362 										   pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_SCAN_COMPENSATION_MAX_TIME],
363 										   pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_SCAN_WINDOW]);
364 		}
365 		break;
366 
367 	default:
368 TRACE1(pSoftGemini->hReport, REPORT_SEVERITY_ERROR, "  SoftGemini_setParam(), Params is not supported, %d\n\n", pParam->paramType);
369 		return PARAM_NOT_SUPPORTED;
370 	}
371 
372 	return return_value;
373 }
374 
375 /***********************************************************************
376  *			      SoftGemini_getParam
377  ***********************************************************************
378 DESCRIPTION: SoftGemini get param function, called by the following:
379 			-	config mgr in order to get a parameter from the OS abstraction layer.
380 			-	From inside the dirver
381 
382 INPUT:      hSoftGemini	-	SoftGemini handle.
383 
384 
385 OUTPUT:		pParam	-	Pointer to the parameter
386 
387 RETURN:     TI_OK on success, TI_NOK otherwise
388 
389 ************************************************************************/
SoftGemini_getParam(TI_HANDLE hSoftGemini,paramInfo_t * pParam)390 TI_STATUS SoftGemini_getParam(TI_HANDLE		hSoftGemini,
391 											paramInfo_t	*pParam)
392 {
393 		switch (pParam->paramType)
394 		{
395 			case SOFT_GEMINI_GET_CONFIG:
396 				SoftGemini_printParams(hSoftGemini);
397 				break;
398 		}
399 
400 	return TI_OK;
401 }
402 
403 
404 
405 /***************************************************************************
406 *					SoftGemini_setEnableParam					    	       *
407 ****************************************************************************
408 * DESCRIPTION:	The function sets the  appropriate Enable value,
409 *				configures SCR , POWER MGR , DATA CTRL , FW.
410 *
411 * INPUTS:		pSoftGemini - the object
412 ***************************************************************************/
SoftGemini_setEnableParam(TI_HANDLE hSoftGemini,ESoftGeminiEnableModes SoftGeminiEnable,TI_BOOL recovery)413 static TI_STATUS SoftGemini_setEnableParam(TI_HANDLE hSoftGemini, ESoftGeminiEnableModes SoftGeminiEnable, TI_BOOL recovery)
414 {
415 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
416 	TTwdParamInfo	param;
417 	TI_STATUS return_value = TI_OK;
418 
419 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "  setSoftGeminiEnableParam() - Old value = , New value = \n");
420 
421 
422     /*
423      * PsPoll work around is active. Just save the value and configure it later
424      */
425     if ( pSoftGemini->bPsPollFailureActive )
426     {
427         TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "  setSoftGeminiEnableParam() - while PsPollFailure is active\n");
428 
429         pSoftGemini->PsPollFailureLastEnableValue = SoftGeminiEnable;
430         return TI_OK;
431     }
432 
433 	/**********************************/
434 	/* Sanity check on enable values */
435 	/********************************/
436 
437 	/*				Old Value						New Value		    */
438 	/*					|							    |			    */
439 	/*			  	   \|/							   \|/			    */
440 
441 	if ((pSoftGemini->SoftGeminiEnable == SoftGeminiEnable) && !recovery)
442 	{
443 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_ERROR, "   - setting same value \n");
444 		return TI_NOK;
445 	}
446 
447 	/*******************************/
448 	/* Make the necessary actions */
449 	/*****************************/
450 
451 	switch (SoftGeminiEnable)
452 	{
453 	case SG_PROTECTIVE:
454 	case SG_OPPORTUNISTIC:
455 
456 		/* set FW with SG_ENABLE */
457 		param.paramType = TWD_SG_ENABLE_PARAM_ID;
458 		param.content.SoftGeminiEnable = SoftGeminiEnable;
459 		return_value = TWD_SetParam (pSoftGemini->hTWD, &param);
460 
461 		break;
462 
463 	case SG_DISABLE:
464 
465 		/* set FW with SG_DISABLE */
466 		param.paramType = TWD_SG_ENABLE_PARAM_ID;
467 		param.content.SoftGeminiEnable = SG_DISABLE;
468 		return_value = TWD_SetParam (pSoftGemini->hTWD, &param);
469 
470 		if (pSoftGemini->bDriverEnabled)
471 		{
472 			SoftGemini_DisableDriver(hSoftGemini);
473 		}
474 
475 		break;
476 
477 	default:
478 TRACE1(pSoftGemini->hReport, REPORT_SEVERITY_ERROR, " defualt :%d\n",SoftGeminiEnable);
479 		return TI_NOK;
480 	}
481 
482 	/* Pass to the new enable state */
483 	pSoftGemini->SoftGeminiEnable = SoftGeminiEnable;
484 
485 	if (TI_OK != return_value)
486 	{
487 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_ERROR, " can't configure enable param to FW :\n");
488 	}
489 
490 	return return_value;
491 }
492 
493 /***************************************************************************
494 *					SoftGemini_setConfigParam				    	       *
495 ****************************************************************************
496 * DESCRIPTION:	The function sets params
497 *
498 * INPUTS:		pSoftGemini - the object
499 *				param       - params to be configured
500 ***************************************************************************/
SoftGemini_setConfigParam(TI_HANDLE hSoftGemini,TI_UINT32 * param)501 static void SoftGemini_setConfigParam(TI_HANDLE hSoftGemini, TI_UINT32 *param)
502 {
503 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
504 
505 	/* param[0] - SG parameter index, param[1] - SG parameter value */
506 	pSoftGemini->SoftGeminiParam.coexParams[(TI_UINT8)param[0]] = (TI_UINT32)param[1];
507 	pSoftGemini->SoftGeminiParam.paramIdx = (TI_UINT8)param[0];
508 }
509 
510 /***************************************************************************
511 *					SoftGemini_printParams					    	       *
512 ****************************************************************************
513 * DESCRIPTION:	Print SG Parameters.
514 *
515 * INPUTS:		pSoftGemini - the object
516 ***************************************************************************/
SoftGemini_printParams(TI_HANDLE hSoftGemini)517 void SoftGemini_printParams(TI_HANDLE hSoftGemini)
518 {
519 #ifdef REPORT_LOG
520 
521 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
522 	TSoftGeminiParams *SoftGeminiParam = &pSoftGemini->SoftGeminiParam;
523 
524 	WLAN_OS_REPORT(("[0]:  coexBtPerThreshold = %d\n", SoftGeminiParam->coexParams[SOFT_GEMINI_BT_PER_THRESHOLD]));
525 	WLAN_OS_REPORT(("[1]:  coexAutoScanCompensationMaxTime = %d (usec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_AUTO_SCAN_COMPENSATION_MAX_TIME]));
526 	WLAN_OS_REPORT(("[2]:  coexBtNfsSampleInterval = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_BT_NFS_SAMPLE_INTERVAL]));
527 	WLAN_OS_REPORT(("[3]:  coexBtLoadRatio = %d (%)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_BT_LOAD_RATIO]));
528 	WLAN_OS_REPORT(("[4]:  coexAutoPsMode = %s \n", (SoftGeminiParam->coexParams[SOFT_GEMINI_AUTO_PS_MODE]?"Enabled":"Disabled")));
529 	WLAN_OS_REPORT(("[5]:  coexAutoScanEnlargedNumOfProbeReqPercent = %d (%)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_AUTO_SCAN_PROBE_REQ]));
530 	WLAN_OS_REPORT(("[6]:  coexAutoScanEnlargedScanWindowPercent = %d (%)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_AUTO_SCAN_WINDOW]));
531 	WLAN_OS_REPORT(("[7]:  coexAntennaConfiguration = %s (0 = Single, 1 = Dual) \n", (SoftGeminiParam->coexParams[SOFT_GEMINI_ANTENNA_CONFIGURATION]?"Dual":"Single")));
532 	WLAN_OS_REPORT(("[8]:  coexMaxConsecutiveBeaconMissPrecent = %d (%)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_BEACON_MISS_PERCENT]));
533 	WLAN_OS_REPORT(("[9]:  coexAPRateAdapationThr = %d\n", SoftGeminiParam->coexParams[SOFT_GEMINI_RATE_ADAPT_THRESH]));
534 	WLAN_OS_REPORT(("[10]: coexAPRateAdapationSnr = %d\n", SoftGeminiParam->coexParams[SOFT_GEMINI_RATE_ADAPT_SNR]));
535 	WLAN_OS_REPORT(("[11]: coexWlanPsBtAclMasterMinBR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_MASTER_MIN_BR]));
536 	WLAN_OS_REPORT(("[12]: coexWlanPsBtAclMasterMaxBR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_MASTER_MAX_BR]));
537 	WLAN_OS_REPORT(("[13]: coexWlanPsMaxBtAclMasterBR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_MAX_BT_ACL_MASTER_BR]));
538     WLAN_OS_REPORT(("[14]: coexWlanPsBtAclSlaveMinBR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_SLAVE_MIN_BR]));
539     WLAN_OS_REPORT(("[15]: coexWlanPsBtAclSlaveMaxBR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_SLAVE_MAX_BR]));
540     WLAN_OS_REPORT(("[16]: coexWlanPsMaxBtAclSlaveBR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_MAX_BT_ACL_SLAVE_BR]));
541     WLAN_OS_REPORT(("[17]: coexWlanPsBtAclMasterMinEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_MASTER_MIN_EDR]));
542     WLAN_OS_REPORT(("[18]: coexWlanPsBtAclMasterMaxEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_MASTER_MAX_EDR]));
543     WLAN_OS_REPORT(("[19]: coexWlanPsMaxBtAclMasterEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_MAX_BT_ACL_MASTER_EDR]));
544     WLAN_OS_REPORT(("[20]: coexWlanPsBtAclSlaveMinEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_SLAVE_MIN_EDR]));
545     WLAN_OS_REPORT(("[21]: coexWlanPsBtAclSlaveMaxEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_BT_ACL_SLAVE_MAX_EDR]));
546     WLAN_OS_REPORT(("[22]: coexWlanPsMaxBtAclSlaveEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_PS_MAX_BT_ACL_SLAVE_EDR]));
547 	WLAN_OS_REPORT(("[23]: coexRxt = %d (usec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_RXT]));
548 	WLAN_OS_REPORT(("[24]: coexTxt = %d (usec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_TXT]));
549 	WLAN_OS_REPORT(("[25]: coexAdaptiveRxtTxt = %s \n", (SoftGeminiParam->coexParams[SOFT_GEMINI_ADAPTIVE_RXT_TXT]?"Enabled":"Disabled")));
550 	WLAN_OS_REPORT(("[26]: coexPsPollTimeout = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_PS_POLL_TIMEOUT]));
551 	WLAN_OS_REPORT(("[27]: coexUpsdTimeout = %d (msec) \n", SoftGeminiParam->coexParams[SOFT_GEMINI_UPSD_TIMEOUT]));
552 	WLAN_OS_REPORT(("[28]: coexWlanActiveBtAclMasterMinEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_MASTER_MIN_EDR]));
553 	WLAN_OS_REPORT(("[29]: coexWlanActiveBtAclMasterMaxEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_MASTER_MAX_EDR]));
554 	WLAN_OS_REPORT(("[30]: coexWlanActiveMaxBtAclMasterEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_ACTIVE_MAX_BT_ACL_MASTER_EDR]));
555     WLAN_OS_REPORT(("[31]: coexWlanActiveBtAclSlaveMinEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_SLAVE_MIN_EDR]));
556 	WLAN_OS_REPORT(("[32]: coexWlanActiveBtAclSlaveMaxEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_SLAVE_MAX_EDR]));
557     WLAN_OS_REPORT(("[33]: coexWlanActiveMaxBtAclSlaveEDR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_ACTIVE_MAX_BT_ACL_SLAVE_EDR]));
558     WLAN_OS_REPORT(("[34]: coexWlanActiveBtAclMinBR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_SLAVE_MIN_BR]));
559     WLAN_OS_REPORT(("[35]: coexWlanActiveBtAclMaxBR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_ACTIVE_BT_ACL_SLAVE_MAX_BR]));
560     WLAN_OS_REPORT(("[36]: coexWlanActiveMaxBtAclBR = %d (msec)\n", SoftGeminiParam->coexParams[SOFT_GEMINI_WLAN_ACTIVE_MAX_BT_ACL_SLAVE_BR]));
561     WLAN_OS_REPORT(("[37]: coexTempParam1 = %d \n", SoftGeminiParam->coexParams[SOFT_GEMINI_TEMP_PARAM_1]));
562     WLAN_OS_REPORT(("[38]: coexTempParam2 = %d \n", SoftGeminiParam->coexParams[SOFT_GEMINI_TEMP_PARAM_2]));
563     WLAN_OS_REPORT(("[39]: coexTempParam3 = %d \n", SoftGeminiParam->coexParams[SOFT_GEMINI_TEMP_PARAM_3]));
564     WLAN_OS_REPORT(("[40]: coexTempParam4 = %d \n", SoftGeminiParam->coexParams[SOFT_GEMINI_TEMP_PARAM_4]));
565     WLAN_OS_REPORT(("[41]: coexTempParam5 = %d \n", SoftGeminiParam->coexParams[SOFT_GEMINI_TEMP_PARAM_5]));
566 	WLAN_OS_REPORT(("Enable mode : %s\n", SoftGemini_ConvertModeToString(pSoftGemini->SoftGeminiEnable)));
567 	WLAN_OS_REPORT(("Driver Enabled : %s\n",(pSoftGemini->bDriverEnabled ? "YES" : "NO")));
568 	WLAN_OS_REPORT(("Protective mode : %s\n", (pSoftGemini->bProtectiveMode ? "ON" : "OFF")));
569     WLAN_OS_REPORT(("PsPoll failure active : %s\n", (pSoftGemini->bPsPollFailureActive ? "YES" : "NO")));
570 
571 #endif
572 }
573 
574 /***************************************************************************
575 *					SoftGemini_setParamsToFW					    	       *
576 ****************************************************************************
577 * DESCRIPTION:	The function sets the FW with the appropriate parameters set.
578 *
579 * INPUTS:		pSoftGemini - the object
580 *
581 *
582 * OUTPUT:
583 *
584 * RETURNS:
585 ***************************************************************************/
SoftGemini_setParamsToFW(TI_HANDLE hSoftGemini,TSoftGeminiParams * softGeminiParams)586 static TI_STATUS SoftGemini_setParamsToFW(TI_HANDLE hSoftGemini, TSoftGeminiParams *softGeminiParams)
587 {
588 	SoftGemini_t *pSoftGemini = (SoftGemini_t *)hSoftGemini;
589 	TTwdParamInfo param;
590 
591 	os_memoryCopy(pSoftGemini->hOs,&param.content.SoftGeminiParam, softGeminiParams, sizeof(TSoftGeminiParams));
592 	param.paramType = TWD_SG_CONFIG_PARAM_ID;
593 	return TWD_SetParam (pSoftGemini->hTWD, &param);
594 }
595 
596 
597 /***************************************************************************
598 *					SoftGemini_EnableDriver  		    	       *
599 ****************************************************************************
600 * DESCRIPTION:	Activated when SG is enabled (after CLI or FW command)
601 *
602 * INPUTS:		pSoftGemini - the object
603 *
604 ***************************************************************************/
SoftGemini_EnableDriver(TI_HANDLE hSoftGemini)605 static TI_STATUS SoftGemini_EnableDriver(TI_HANDLE hSoftGemini)
606 {
607 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
608 	TI_STATUS return_value = TI_OK;
609 
610 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "\n");
611 
612 	pSoftGemini->bDriverEnabled = TI_TRUE;
613 
614 	/* Check if coexAutoPsMode - Co-ex is enabled to enter/exit P.S */
615 	if ( pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_PS_MODE])
616 	{
617 		SoftGemini_SetPS(pSoftGemini);
618 	}
619 
620 	scr_setMode(pSoftGemini->hSCR, SCR_MID_SG);
621 
622 	return return_value;
623 }
624 
625 /***************************************************************************
626 *					SoftGemini_DisableDriver  		    	       *
627 ****************************************************************************
628 * DESCRIPTION:	Activated when SG is disabled (after CLI or FW command)
629 *
630 * INPUTS:		pSoftGemini - the object
631 *
632 ***************************************************************************/
SoftGemini_DisableDriver(TI_HANDLE hSoftGemini)633 static TI_STATUS SoftGemini_DisableDriver(TI_HANDLE hSoftGemini)
634 {
635 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
636 	TI_STATUS return_value = TI_OK;
637 
638 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "\n");
639 
640 	pSoftGemini->bDriverEnabled = TI_FALSE;
641 
642 	scr_setMode(pSoftGemini->hSCR, SCR_MID_NORMAL);
643 
644 
645 	/* Check if coexAutoPsMode - Co-ex is enabled to enter/exit P.S */
646 	if ( pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_PS_MODE])
647 	{
648 		SoftGemini_unSetPS(pSoftGemini);
649 	}
650 
651 	/* Undo the changes that were made when Protective mode was on */
652 	if (pSoftGemini->bProtectiveMode)
653 	{
654 		SoftGemini_DisableProtectiveMode(hSoftGemini);
655 	}
656 
657 	return return_value;
658 }
659 
660 /***************************************************************************
661 *					SoftGemini_SetPS  		    						   *
662 ****************************************************************************
663 * DESCRIPTION:	Set Always PS to PowerMgr
664 *
665 * INPUTS:		pSoftGemini - the object
666 *
667 ***************************************************************************/
SoftGemini_SetPS(SoftGemini_t * pSoftGemini)668 static TI_STATUS SoftGemini_SetPS(SoftGemini_t	*pSoftGemini)
669 {
670 	paramInfo_t param;
671 	bssEntry_t *pBssInfo=NULL;
672 
673     if (pSoftGemini->hCurrBss)
674 	{
675 		pBssInfo = currBSS_getBssInfo(pSoftGemini->hCurrBss);
676 	}
677     else
678     {
679 		TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_ERROR, "SoftGemini_SetPS: hCurrBss = NULL!!!\n");
680     }
681 
682     TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "\n");
683 
684 	if (pBssInfo)
685 	{
686 		if ((pBssInfo->band == RADIO_BAND_2_4_GHZ))
687 		{
688             TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, " SG-setPS: band == RADIO_BAND_2_4_GHZ");
689 
690 	        /* Set Params to Power Mgr for SG priority */
691 	        param.paramType = POWER_MGR_POWER_MODE;
692 	        param.content.powerMngPowerMode.PowerMode = POWER_MODE_PS_ONLY;
693 	        param.content.powerMngPowerMode.PowerMngPriority = POWER_MANAGER_SG_PRIORITY;
694 	        powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
695 
696 	        /* enable SG priority for Power Mgr */
697 	        param.paramType = POWER_MGR_ENABLE_PRIORITY;
698 	        param.content.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
699 	        return powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
700         }
701         else
702         {
703             TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, " SG-setPS: band == RADIO_BAND_5_GHZ");
704         }
705 	}
706 	return TI_OK;
707 }
708 
709 /***************************************************************************
710 *					SoftGemini_unSetPS  		    						   *
711 ****************************************************************************
712 * DESCRIPTION:	unSet Always PS to PowerMgr
713 *
714 * INPUTS:		pSoftGemini - the object
715 *
716 ***************************************************************************/
SoftGemini_unSetPS(SoftGemini_t * pSoftGemini)717 static TI_STATUS SoftGemini_unSetPS(SoftGemini_t	*pSoftGemini)
718 {
719 	paramInfo_t param;
720 
721 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, ", SG-unSetPS \n");
722 
723 	/* disable SG priority for Power Mgr*/
724 	param.paramType = POWER_MGR_DISABLE_PRIORITY;
725 	param.content.powerMngPriority = POWER_MANAGER_SG_PRIORITY;
726 	return powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
727 
728 }
729 
730 /***************************************************************************
731 *					SoftGemini_EnableProtectiveMode  		    	       *
732 ****************************************************************************
733 * DESCRIPTION:	Activated when FW inform us that protective mode is ON
734 *
735 *
736 * INPUTS:		pSoftGemini - the object
737 *
738 ***************************************************************************/
SoftGemini_EnableProtectiveMode(TI_HANDLE hSoftGemini)739 void SoftGemini_EnableProtectiveMode(TI_HANDLE hSoftGemini)
740 {
741 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
742 	paramInfo_t 	param;
743 
744 	pSoftGemini->bProtectiveMode = TI_TRUE;
745 
746 	/* set new configurations of SG roaming parameters */
747 
748 	/* This code should be removed on SG stage 2 integration
749 	 currBSS_SGconfigureBSSLoss(pSoftGemini->hCurrBss,pSoftGemini->BSSLossCompensationPercent,TI_TRUE); */
750 
751 	/* set new configurations of scan to scancncn */
752     scanCncn_SGconfigureScanParams(pSoftGemini->hScanCncn,TI_TRUE,
753 								   (TI_UINT8)pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_SCAN_PROBE_REQ],
754 								   pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_SCAN_COMPENSATION_MAX_TIME],
755 								   pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_SCAN_WINDOW]);
756 
757     /* Call the power manager to enter short doze */
758 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, " SoftGemini_EnableProtectiveMode set SD");
759 
760 	/* Set Params to Power Mgr for SG priority */
761 	param.paramType = POWER_MGR_POWER_MODE;
762 	param.content.powerMngPowerMode.PowerMode = POWER_MODE_SHORT_DOZE;
763 	param.content.powerMngPowerMode.PowerMngPriority = POWER_MANAGER_SG_PRIORITY;
764 	powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
765 }
766 
767 /***************************************************************************
768 *					SoftGemini_DisableProtectiveMode  		    	       *
769 ****************************************************************************
770 * DESCRIPTION:	Activated when FW inform us that protective mode is OFF or SG is disabled
771 *
772 * INPUTS:		pSoftGemini - the object
773 *
774 ***************************************************************************/
SoftGemini_DisableProtectiveMode(TI_HANDLE hSoftGemini)775 void SoftGemini_DisableProtectiveMode(TI_HANDLE hSoftGemini)
776 {
777 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
778 
779 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "\n");
780 
781 	pSoftGemini->bProtectiveMode = TI_FALSE;
782 
783 	SoftGemini_RemoveProtectiveModeParameters(hSoftGemini);
784 }
785 
786 /***************************************************************************
787 *					SoftGemini_DisableProtectiveMode  		    	       *
788 ****************************************************************************
789 * DESCRIPTION:	Called from SoftGemini_DisableProtectiveMode() when FW inform
790 *				us that protective mode is OFF or SG is disabled, or from
791 *				SoftGemini_unSetPSmode() when driver disconnects from AP.
792 *
793 * INPUTS:		pSoftGemini - the object
794 *
795 ***************************************************************************/
796 
SoftGemini_RemoveProtectiveModeParameters(TI_HANDLE hSoftGemini)797 void SoftGemini_RemoveProtectiveModeParameters(TI_HANDLE hSoftGemini)
798 {
799 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
800 	paramInfo_t  	param;
801 
802 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "\n");
803 
804 	/* don't use the SG roaming parameters */
805 	currBSS_SGconfigureBSSLoss(pSoftGemini->hCurrBss,0,TI_FALSE);
806 
807 	/* don't use the SG scan parameters */
808     scanCncn_SGconfigureScanParams(pSoftGemini->hScanCncn,TI_FALSE,0,0,0);
809 
810     /* Call the power manager to exit short doze */
811 	/* Set Params to Power Mgr for SG priority */
812 	param.paramType = POWER_MGR_POWER_MODE;
813 	param.content.powerMngPowerMode.PowerMode = POWER_MODE_PS_ONLY;
814 	param.content.powerMngPowerMode.PowerMngPriority = POWER_MANAGER_SG_PRIORITY;
815 	powerMgr_setParam(pSoftGemini->hPowerMgr,&param);
816 }
817 
818 /***************************************************************************
819 *					SoftGemini_SenseIndicationCB  		    	       *
820 ****************************************************************************
821 * DESCRIPTION:	This is the the function which is called for sense mode indication from FW
822 *				(i.e. we are in SENSE mode and FW detects BT activity )
823 *				SENSE_MODE_ENABLE - Indicates that FW detected BT activity
824 *				SENSE_MODE_DISABLE - Indicates that FW doesn't detect BT activity for a period of time
825 *
826 * INPUTS:		pSoftGemini - the object
827 * NOTE			This function is located in the API for debug purposes
828 ***************************************************************************/
829 
SoftGemini_SenseIndicationCB(TI_HANDLE hSoftGemini,char * str,TI_UINT32 strLen)830 void SoftGemini_SenseIndicationCB( TI_HANDLE hSoftGemini, char* str, TI_UINT32 strLen )
831 {
832 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
833 
834 	if (pSoftGemini->SoftGeminiEnable == SG_DISABLE) {
835 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_WARNING, ": SG is disabled, existing");
836 		return;
837 	}
838 
839 	if ( (SENSE_MODE_ENABLE == *str) && (!pSoftGemini->bDriverEnabled) )
840 	{
841 			SoftGemini_EnableDriver(hSoftGemini);
842 	}
843 	else if ( (SENSE_MODE_DISABLE == *str) && (pSoftGemini->bDriverEnabled) )
844 	{
845 			SoftGemini_DisableDriver(hSoftGemini);
846 	}
847 }
848 
849 /***************************************************************************
850 *					SoftGemini_ProtectiveIndicationCB  		    	       *
851 ****************************************************************************
852 * DESCRIPTION:	This is the the function which is called when FW starts Protective mode (i.e BT voice)
853 *
854 *				PROTECTIVE_MODE_ON - FW is activated on protective mode (BT voice is running)
855 *				PROTECTIVE_MODE_OFF - FW is not activated on protective mode
856 *
857 * INPUTS:		pSoftGemini - the object
858 * NOTE			This function is located in the API for debug purposes
859 ***************************************************************************/
860 
SoftGemini_ProtectiveIndicationCB(TI_HANDLE hSoftGemini,char * str,TI_UINT32 strLen)861 void SoftGemini_ProtectiveIndicationCB( TI_HANDLE hSoftGemini, char* str, TI_UINT32 strLen )
862 {
863 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
864 
865 TRACE1(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, " with 0x%x\n",*str);
866 
867 	if (SG_DISABLE != pSoftGemini->SoftGeminiEnable)
868 	{
869 		if ((!pSoftGemini->bProtectiveMode) && (PROTECTIVE_MODE_ON == *str))
870 		{
871 			SoftGemini_EnableProtectiveMode(hSoftGemini);
872 		}
873 		else if ((pSoftGemini->bProtectiveMode) && (PROTECTIVE_MODE_OFF == *str))
874 		{
875 			SoftGemini_DisableProtectiveMode(hSoftGemini);
876 		}
877 		else
878 		{
879 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, " : Protective mode  called when Protective mode is  \n");
880 		}
881 	}
882 	else
883 	{
884 TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_WARNING, " : Protective mode  called when SG mode is  ? \n");
885 	}
886 }
887 
888 /***************************************************************************
889 *					SoftGemini_ConvertModeToString  		    	       *
890 ****************************************************************************/
891 #ifdef REPORT_LOG
892 
SoftGemini_ConvertModeToString(ESoftGeminiEnableModes SoftGeminiEnable)893 char* SoftGemini_ConvertModeToString(ESoftGeminiEnableModes SoftGeminiEnable)
894 {
895 	switch(SoftGeminiEnable)
896 	{
897 	case SG_PROTECTIVE:				return "SG_PROTECTIVE";
898 	case SG_DISABLE:			    return "SG_DISABLE";
899 	case SG_OPPORTUNISTIC:     return "SG_OPPORTUNISTIC";
900 	default:
901 		return "ERROR";
902 	}
903 }
904 
905 #endif
906 
907 /***************************************************************************
908 *					SoftGemini_getSGMode						  		    	       *
909 ****************************************************************************/
SoftGemini_getSGMode(TI_HANDLE hSoftGemini)910 ESoftGeminiEnableModes SoftGemini_getSGMode(TI_HANDLE hSoftGemini)
911 {
912 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
913 	return pSoftGemini->SoftGeminiEnable;
914 }
915 
916 /***************************************************************************
917 *					SoftGemini_handleRecovery					    	       *
918 ****************************************************************************
919 * DESCRIPTION:	The function reconfigures WHAL with the SG parameters.
920 *
921 * INPUTS:		pSoftGemini - the object
922 ***************************************************************************/
SoftGemini_handleRecovery(TI_HANDLE hSoftGemini)923 TI_STATUS SoftGemini_handleRecovery(TI_HANDLE hSoftGemini)
924 {
925 	SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
926 	ESoftGeminiEnableModes       realSoftGeminiEnableMode;
927 
928 	realSoftGeminiEnableMode = pSoftGemini->SoftGeminiEnable;
929     /* Disable the SG */
930     SoftGemini_setEnableParam(hSoftGemini, SG_DISABLE, TI_TRUE);
931     TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "Disable SG \n");
932 
933 	pSoftGemini->SoftGeminiEnable = realSoftGeminiEnableMode;
934 	/* Set enable param */
935 
936 	SoftGemini_setEnableParam(hSoftGemini, pSoftGemini->SoftGeminiEnable, TI_TRUE);
937     TRACE1(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "Set SG to-%d\n", pSoftGemini->SoftGeminiEnable);
938 
939 	/* Config the params to FW */
940 
941 	SoftGemini_setParamsToFW(hSoftGemini, &pSoftGemini->SoftGeminiParam);
942 	/*SoftGemini_printParams(hSoftGemini);*/
943 	return TI_OK;
944 }
945 /***************************************************************************
946 *					SoftGemini_startPsPollFailure					       *
947 ****************************************************************************
948 * DESCRIPTION:	After Ps-Poll failure we disable the SG
949 *
950 * INPUTS:		pSoftGemini - the object
951 ***************************************************************************/
SoftGemini_startPsPollFailure(TI_HANDLE hSoftGemini)952 void SoftGemini_startPsPollFailure(TI_HANDLE hSoftGemini)
953 	{
954     SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
955 
956     TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "\n");
957 
958     if ( (!pSoftGemini->bPsPollFailureActive) && (pSoftGemini->SoftGeminiParam.coexParams[SOFT_GEMINI_AUTO_PS_MODE] == TI_TRUE) )
959     {
960         pSoftGemini->PsPollFailureLastEnableValue = pSoftGemini->SoftGeminiEnable;
961 
962         /* Disable SG if needed */
963         if ( pSoftGemini->SoftGeminiEnable != SG_DISABLE )
964         {
965             SoftGemini_setEnableParam(hSoftGemini, SG_DISABLE, TI_FALSE);
966 	}
967 
968         pSoftGemini->bPsPollFailureActive = TI_TRUE;
969     }
970     else /* Calling SoftGemini_startPsPollFailure twice ? */
971 	{
972         TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_WARNING, "Calling  SoftGemini_startPsPollFailure while bPsPollFailureActive is TRUE\n");
973     }
974 	}
975 
976 /***************************************************************************
977 *					SoftGemini_endPsPollFailure					    	   *
978 ****************************************************************************
979 * DESCRIPTION:	Return to normal behavior after the PsPoll failure
980 *
981 * INPUTS:		pSoftGemini - the object
982 ***************************************************************************/
SoftGemini_endPsPollFailure(TI_HANDLE hSoftGemini)983 void SoftGemini_endPsPollFailure(TI_HANDLE hSoftGemini)
984 {
985     SoftGemini_t	*pSoftGemini = (SoftGemini_t *)hSoftGemini;
986 
987     TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_INFORMATION, "\n");
988 
989     if ( pSoftGemini->bPsPollFailureActive )
990     {
991         pSoftGemini->bPsPollFailureActive = TI_FALSE;
992 
993         /* return to previous value */
994         if ( pSoftGemini->PsPollFailureLastEnableValue != SG_DISABLE )
995         {
996 			SoftGemini_setEnableParam(hSoftGemini, pSoftGemini->PsPollFailureLastEnableValue, TI_FALSE);
997         }
998     }
999     else /* Calling SoftGemini_endPsPollFailure twice ? */
1000     {
1001         TRACE0(pSoftGemini->hReport, REPORT_SEVERITY_WARNING, "Calling  SoftGemini_endPsPollFailure while bPsPollFailureActive is FALSE\n");
1002     }
1003 }
1004 
1005 
1006