PageRenderTime 29ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/hal/hl_ctrl/whalRadio.c

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