• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2 **+-----------------------------------------------------------------------+**
3 **|                                                                       |**
4 **| Copyright(c) 1998 - 2008 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 ****************************************************************************/
35 
36 /****************************************************************************
37  *
38  *   MODULE:  whalRadio.c
39  *   PURPOSE: Handle all radio aspects in the Hal
40  *
41  *  RSSI
42  *		Set RSSI params to the firmware
43  *		Conversion function From/To RxLevel/RSSI
44  *	TxPowerLevel
45  *		Overide the default radioTxLevel table
46  *
47  ****************************************************************************/
48 #include "whalCommon.h"
49 #include "whalCtrl_api.h"
50 #include "whalCtrl.h"
51 #include "whalSecurity.h"
52 #include "commonTypes.h"
53 #include "eventMbox_api.h"
54 #include "whalBus_Api.h"
55 
56 /* Conversion Factors */
57 #define RADIA_BG_FACTOR         93
58 #define RADIA_ABG_FACTOR        93
59 #define RADIA_BG_CRT_FACTOR     98
60 
61 /*
62  * ----------------------------------------------------------------------------
63  * Function : whalCtrl_SetRadioBand
64  *
65  * Input    :
66  * Output   :
67  * Process  :
68  * Note(s)  : Done
69  * -----------------------------------------------------------------------------
70  */
71 
whalCtrl_SetRadioBand(TI_HANDLE hWhalCtrl,radioBand_e RadioBand)72 int whalCtrl_SetRadioBand (TI_HANDLE hWhalCtrl, radioBand_e RadioBand)
73 {
74     WHAL_CTRL *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
75 
76 	pWhalCtrl->pWhalParams->WlanParams.RadioBand = RadioBand;
77 
78 	return OK;
79 }
80 
81 /*
82  * ----------------------------------------------------------------------------
83  * Function : whalCtrl_convertRSSIToRxLevel
84  *
85  * Input    :
86  * Output   :
87  * Process  :
88  * Note(s)  :  Done
89  * -----------------------------------------------------------------------------
90  */
whalCtrl_convertRSSIToRxLevel(TI_HANDLE hWhalCtrl,INT32 rssiVal)91 INT8 whalCtrl_convertRSSIToRxLevel(TI_HANDLE hWhalCtrl, INT32 rssiVal)
92 {
93     WHAL_CTRL   *pWhalCtrl = (WHAL_CTRL *)hWhalCtrl;
94     INT8       rxLevel;
95 
96     switch(pWhalCtrl->pWhalParams->WlanParams.radioType)
97     {
98     case RADIO_MAXIM2820_ID:  /* Not Supported at the moment */
99         rxLevel = 0;
100         break;
101     case RADIO_RFMD_ID:       /* Not Supported at the moment */
102         rxLevel = 0;
103         break;
104     case RADIO_RADIA_BG_ID:
105         rxLevel = (INT8)(rssiVal + RADIA_BG_FACTOR);
106         break;
107     case RADIO_RADIA_ABG_ID:
108         rxLevel = (INT8)(rssiVal + RADIA_ABG_FACTOR);
109         break;
110     case RADIO_RADIA_BG_CRT_ID:
111         rxLevel = (INT8)(rssiVal + RADIA_BG_CRT_FACTOR);
112         break;
113     case RADIO_RADIA_WBR_ID:
114         rxLevel = (UINT8)(rssiVal + RADIA_BG_CRT_FACTOR);
115         break;
116     case RADIO_RADIA_DCR_ID:
117 	case RADIO_RADIA_DCR_1251_ID:
118         rxLevel = (UINT8)(rssiVal + RADIA_BG_CRT_FACTOR);
119         break;
120     default:
121         rxLevel = 0;
122         WLAN_REPORT_ERROR(pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
123             ("whalCtrl_convertRSSIToRxLevel: Error - Unknown radio type!\n"));
124         break;
125     }
126 
127 	return rxLevel;
128 }
129 
130 /*
131  * ----------------------------------------------------------------------------
132  * Function : whalCtrl_getRadioNumber
133  *
134  * Input    :
135  * Output   :
136  * Process  :
137  * Note(s)  :  Done
138  * -----------------------------------------------------------------------------
139  */
whalCtrl_getRadioNumber(TI_HANDLE hWhalCtrl,UINT32 * outRadioType,UINT32 * outRadioNumber)140 TI_STATUS whalCtrl_getRadioNumber(TI_HANDLE hWhalCtrl, UINT32 *outRadioType, UINT32 *outRadioNumber)
141 {
142     WHAL_CTRL *pWhalCtrl = (WHAL_CTRL*)hWhalCtrl;
143 	WlanParams_T *pWlanParams = whal_ParamsGetWlanParams(pWhalCtrl->pWhalParams);
144 	UINT32 RadioType;
145 
146 	*outRadioNumber = pWlanParams->radioType;
147 
148 	switch (pWlanParams->radioType)
149 	{
150 		case RADIO_RADIA_BG_ID:
151 			RadioType = RADIA_BG;
152 			WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
153 									 ("Radio Type is : RADIA BG\n"));
154 			break;
155 
156 		case RADIO_RADIA_ABG_ID:
157 			RadioType = RADIA_ABG;
158 			WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
159 									 ("Radio Type is : RADIA ABG\n"));
160 			break;
161 
162 		case RADIO_RADIA_BG_CRT_ID:
163 			RadioType = RADIA_BG;
164 			WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
165 									 ("Radio Type is : RADIA BG (crt)\n"));
166 			break;
167 
168         case RADIO_RADIA_WBR_ID:
169             RadioType = RADIA_ABG;
170             WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
171                                  ("Radio Type is : RADIO ABG (wbr)\n"));
172             break;
173 
174         case RADIO_RADIA_DCR_ID:
175 		case RADIO_RADIA_DCR_1251_ID:
176             RadioType = RADIA_ABG;
177             WLAN_REPORT_INFORMATION (pWhalCtrl->hReport, HAL_CTRL_MODULE_LOG,
178                                  ("Radio Type is : RADIO ABG (dcr)\n"));
179             break;
180 
181 		default:
182 			RadioType = UNKNOWN_RADIO_TYPE;
183 			WLAN_OS_REPORT (("FATAL ERR: Radio Type is : 0x%x - UNKNOWN\n", pWlanParams->radioType));
184 			break;
185 	}
186 
187 	*outRadioType = RadioType;
188 	return OK;
189 }
190 
191