| 1 | /************************************************************************* |
|---|
| 2 | * (c)2005-2011 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * $brcm_Workfile: btnr_3x7x_priv.c $ |
|---|
| 15 | * $brcm_Revision: Hydra_Software_Devel/10 $ |
|---|
| 16 | * $brcm_Date: 3/5/12 4:59p $ |
|---|
| 17 | * |
|---|
| 18 | * [File Description:] |
|---|
| 19 | * |
|---|
| 20 | * Revision History: |
|---|
| 21 | * |
|---|
| 22 | * $brcm_Log: /magnum/portinginterface/tnr/7552/btnr_3x7x_priv.c $ |
|---|
| 23 | * |
|---|
| 24 | * Hydra_Software_Devel/10 3/5/12 4:59p farshidf |
|---|
| 25 | * SW7552-223: TNR power up/down |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/9 2/13/12 2:37p farshidf |
|---|
| 28 | * SW3461-140: update the tuner status field for next tune comparason |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/8 11/10/11 4:21p farshidf |
|---|
| 31 | * SW7552-144: fix the loopthr.daisy,dpm |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/7 11/9/11 6:17p farshidf |
|---|
| 34 | * SW7552-144: update the enum |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/6 10/24/11 3:36p farshidf |
|---|
| 37 | * SW7552-134: write to UFE reg after power up |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/5 8/30/11 5:57p farshidf |
|---|
| 40 | * SW7552-112: add the suuport for BBS to switch to different power mode |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/4 8/26/11 5:04p farshidf |
|---|
| 43 | * SW7552-102: fix the tuner issue to lock the first time |
|---|
| 44 | * |
|---|
| 45 | * Hydra_Software_Devel/3 7/28/11 3:54p farshidf |
|---|
| 46 | * SW3461-1: reset the LAN usage register |
|---|
| 47 | * |
|---|
| 48 | * Hydra_Software_Devel/2 6/12/11 1:18p farshidf |
|---|
| 49 | * SW7552-36: clean up |
|---|
| 50 | * |
|---|
| 51 | * Hydra_Software_Devel/1 6/12/11 12:30p farshidf |
|---|
| 52 | * SW7552-36: code clean up |
|---|
| 53 | * |
|---|
| 54 | ***************************************************************************/ |
|---|
| 55 | #include "bstd.h" |
|---|
| 56 | #include "bkni.h" |
|---|
| 57 | #include "btnr.h" |
|---|
| 58 | #include "bdbg.h" |
|---|
| 59 | #include "btnr_priv.h" |
|---|
| 60 | #include "btmr.h" |
|---|
| 61 | #include "btnr_struct.h" |
|---|
| 62 | #include "btnr_3x7x_priv.h" |
|---|
| 63 | #include "btnr_init.h" |
|---|
| 64 | #include "btnr_tune.h" |
|---|
| 65 | #include "bchp_ufe_misc2.h" |
|---|
| 66 | #include "bchp_ufe.h" |
|---|
| 67 | #include "bchp_ufe_afe.h" |
|---|
| 68 | #include "bchp_sdadc.h" |
|---|
| 69 | BDBG_MODULE(btnr_3x7x_priv); |
|---|
| 70 | |
|---|
| 71 | #define DEV_MAGIC_ID ((BERR_TNR_ID<<16) | 0xFACE) |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | /****************************************************************************** |
|---|
| 75 | * BTNR_3x7x_Close |
|---|
| 76 | ******************************************************************************/ |
|---|
| 77 | BERR_Code BTNR_3x7x_Close( |
|---|
| 78 | BTNR_Handle hDev /* [in] Device handle */ |
|---|
| 79 | ) |
|---|
| 80 | { |
|---|
| 81 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 82 | BTNR_3x7x_Handle btnr_3x7x_handle; |
|---|
| 83 | BTNR_P_3x7x_Handle *p3x7x; |
|---|
| 84 | |
|---|
| 85 | BDBG_ENTER(BTNR_3x7x_Close); |
|---|
| 86 | BDBG_ASSERT( hDev ); |
|---|
| 87 | BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID ); |
|---|
| 88 | |
|---|
| 89 | /* verify the handle is good before using it */ |
|---|
| 90 | btnr_3x7x_handle = (BTNR_3x7x_Handle) hDev->hDevImpl; |
|---|
| 91 | p3x7x = (BTNR_P_3x7x_Handle *)(hDev->hDevImpl); |
|---|
| 92 | |
|---|
| 93 | hDev->magicId = 0x00; /* clear it to catch inproper use */ |
|---|
| 94 | BTMR_DestroyTimer(p3x7x->hTimer); |
|---|
| 95 | BKNI_DestroyEvent(p3x7x->hInterruptEvent); |
|---|
| 96 | BMEM_Free( p3x7x->hHeap, p3x7x->pTunerParams ); |
|---|
| 97 | BMEM_Free( p3x7x->hHeap, p3x7x->pTunerStatus ); |
|---|
| 98 | BKNI_Free( (void *) hDev->hDevImpl ); |
|---|
| 99 | BKNI_Free( (void *) hDev ); |
|---|
| 100 | |
|---|
| 101 | BDBG_LEAVE(BTNR_3x7x_Close); |
|---|
| 102 | return( retCode ); |
|---|
| 103 | } |
|---|
| 104 | /*************************************************************************** |
|---|
| 105 | Summary: |
|---|
| 106 | BTNR_3x7x_SetTuneSettings |
|---|
| 107 | ****************************************************************************/ |
|---|
| 108 | BERR_Code BTNR_3x7x_SetSettings( |
|---|
| 109 | BTNR_3x7x_Handle hDev, /* [in] Device handle */ |
|---|
| 110 | BTNR_Settings *settings /* [in] TNR settings. */ |
|---|
| 111 | ) |
|---|
| 112 | { |
|---|
| 113 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 114 | BTNR_TunerApplicationMode_t TunerApplication=0; |
|---|
| 115 | BDBG_ENTER(BTNR_3x7x_SetSettings); |
|---|
| 116 | BDBG_ASSERT( hDev ); |
|---|
| 117 | BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID ); |
|---|
| 118 | |
|---|
| 119 | if (hDev->pTunerStatus->PowerStatus != BTNR_ePower_On) |
|---|
| 120 | { |
|---|
| 121 | BDBG_ERR(("BTNR_3x7x_SetRfFreq: power is still off ")); |
|---|
| 122 | return BERR_NOT_INITIALIZED; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | if ((BTNR_ePower_On == hDev->pTunerStatus->PowerStatus) || (settings->rfInputMode != (BTNR_RfInputMode)hDev->pTunerParams->BTNR_Local_Params.RfInputMode)) |
|---|
| 126 | { |
|---|
| 127 | hDev->pTunerParams->BTNR_RF_Input_Mode = settings->rfInputMode; |
|---|
| 128 | BTNR_3x7x_PowerUp(hDev); |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | switch (settings->tnrApplication) |
|---|
| 132 | { |
|---|
| 133 | case BTNR_TunerApplication_eCable: |
|---|
| 134 | TunerApplication = BTNR_TunerApplicationMode_eCable; |
|---|
| 135 | break; |
|---|
| 136 | case BTNR_TunerApplication_eTerrestrial: |
|---|
| 137 | TunerApplication = BTNR_TunerApplicationMode_eTerrestrial; |
|---|
| 138 | break; |
|---|
| 139 | case BTNR_TunerApplication_eLast: |
|---|
| 140 | TunerApplication = BTNR_TunerApplicationMode_eTerrestrial; |
|---|
| 141 | break; |
|---|
| 142 | } |
|---|
| 143 | |
|---|
| 144 | hDev->pTunerParams->BTNR_Acquire_Params.Application = TunerApplication; |
|---|
| 145 | switch (settings->bandwidth) |
|---|
| 146 | { |
|---|
| 147 | case 8000000: |
|---|
| 148 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Bandwidth = BTNR_LPF_Bandwidth_e8MHz; |
|---|
| 149 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Variable_Bandwidth = 0; |
|---|
| 150 | break; |
|---|
| 151 | case 7000000: |
|---|
| 152 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Bandwidth = BTNR_LPF_Bandwidth_e7MHz; |
|---|
| 153 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Variable_Bandwidth = 0; |
|---|
| 154 | break; |
|---|
| 155 | case 6000000: |
|---|
| 156 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Bandwidth = BTNR_LPF_Bandwidth_e6MHz; |
|---|
| 157 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Variable_Bandwidth = 0; |
|---|
| 158 | break; |
|---|
| 159 | case 5000000: |
|---|
| 160 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Bandwidth = BTNR_LPF_Bandwidth_e5MHz; |
|---|
| 161 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Variable_Bandwidth = 0; |
|---|
| 162 | break; |
|---|
| 163 | case 1700000: |
|---|
| 164 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Bandwidth = BTNR_LPF_Bandwidth_e1_7MHz; |
|---|
| 165 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Variable_Bandwidth = 0; |
|---|
| 166 | break; |
|---|
| 167 | default: |
|---|
| 168 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Bandwidth = BTNR_LPF_Bandwidth_eVariable; |
|---|
| 169 | hDev->pTunerParams->BTNR_Acquire_Params.LPF_Variable_Bandwidth = settings->bandwidth; |
|---|
| 170 | break; |
|---|
| 171 | } |
|---|
| 172 | |
|---|
| 173 | switch (settings->std) |
|---|
| 174 | { |
|---|
| 175 | case BTNR_Standard_eDvbt: |
|---|
| 176 | hDev->pTunerParams->BTNR_Acquire_Params.Standard= BTNR_Standard_eDVBT; |
|---|
| 177 | break; |
|---|
| 178 | case BTNR_Standard_eIsdbt: |
|---|
| 179 | hDev->pTunerParams->BTNR_Acquire_Params.Standard= BTNR_Standard_eISDBT; |
|---|
| 180 | break; |
|---|
| 181 | case BTNR_Standard_eQam: |
|---|
| 182 | hDev->pTunerParams->BTNR_Acquire_Params.Standard= BTNR_Standard_eQAM; |
|---|
| 183 | break; |
|---|
| 184 | case BTNR_Standard_eDvbt2: |
|---|
| 185 | hDev->pTunerParams->BTNR_Acquire_Params.Standard= BTNR_Standard_eT2; |
|---|
| 186 | break; |
|---|
| 187 | default: |
|---|
| 188 | hDev->pTunerParams->BTNR_Acquire_Params.Standard= BTNR_Standard_eQAM; |
|---|
| 189 | break; |
|---|
| 190 | } |
|---|
| 191 | |
|---|
| 192 | hDev->pTunerParams->BTNR_RF_Input_Mode = settings->rfInputMode; |
|---|
| 193 | |
|---|
| 194 | if (TunerApplication != hDev->pTunerParams->BTNR_Local_Params.TunerApplication) |
|---|
| 195 | hDev->pTunerParams->BTNR_TuneType.TuneType = BTNR_TuneType_eInitTune; |
|---|
| 196 | else |
|---|
| 197 | hDev->pTunerParams->BTNR_TuneType.TuneType = BTNR_TuneType_eTune; |
|---|
| 198 | |
|---|
| 199 | hDev->pTunerParams->BTNR_Local_Params.TunerApplication = TunerApplication; |
|---|
| 200 | hDev->pTunerParams->BTNR_Local_Params.RfInputMode = settings->rfInputMode; |
|---|
| 201 | |
|---|
| 202 | BDBG_LEAVE(BTNR_3x7x_SetSettings); |
|---|
| 203 | return retCode; |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | /*************************************************************************** |
|---|
| 207 | Summary: |
|---|
| 208 | BTNR_3x7x_GetSettings |
|---|
| 209 | ****************************************************************************/ |
|---|
| 210 | BERR_Code BTNR_3x7x_GetSettings( |
|---|
| 211 | BTNR_3x7x_Handle hDev, /* [in] Device handle */ |
|---|
| 212 | BTNR_Settings *settings /* [out] TNR settings. */ |
|---|
| 213 | ) |
|---|
| 214 | { |
|---|
| 215 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 216 | BTNR_TunerApplication TunerApplication=0; |
|---|
| 217 | |
|---|
| 218 | BDBG_ENTER(BTNR_3x7x_GetSettings); |
|---|
| 219 | BDBG_ASSERT( hDev ); |
|---|
| 220 | BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID ); |
|---|
| 221 | |
|---|
| 222 | switch (hDev->pTunerParams->BTNR_Acquire_Params.Standard) |
|---|
| 223 | { |
|---|
| 224 | case BTNR_Standard_eDVBT: |
|---|
| 225 | settings->std = BTNR_Standard_eDvbt; |
|---|
| 226 | break; |
|---|
| 227 | case BTNR_Standard_eISDBT: |
|---|
| 228 | settings->std = BTNR_Standard_eIsdbt; |
|---|
| 229 | break; |
|---|
| 230 | case BTNR_Standard_eQAM: |
|---|
| 231 | settings->std = BTNR_Standard_eQam; |
|---|
| 232 | break; |
|---|
| 233 | case BTNR_Standard_eT2: |
|---|
| 234 | settings->std = BTNR_Standard_eDvbt2; |
|---|
| 235 | break; |
|---|
| 236 | default: |
|---|
| 237 | settings->std = BTNR_Standard_eQam; |
|---|
| 238 | break; |
|---|
| 239 | } |
|---|
| 240 | switch (hDev->pTunerParams->BTNR_Acquire_Params.LPF_Bandwidth) |
|---|
| 241 | { |
|---|
| 242 | case 1: |
|---|
| 243 | settings->bandwidth = 8000000; |
|---|
| 244 | break; |
|---|
| 245 | case 2: |
|---|
| 246 | settings->bandwidth = 7000000; |
|---|
| 247 | break; |
|---|
| 248 | case 3: |
|---|
| 249 | settings->bandwidth = 6000000; |
|---|
| 250 | break; |
|---|
| 251 | case 4: |
|---|
| 252 | settings->bandwidth = 5000000; |
|---|
| 253 | break; |
|---|
| 254 | case 5: |
|---|
| 255 | settings->bandwidth = 1700000; |
|---|
| 256 | break; |
|---|
| 257 | case 6: |
|---|
| 258 | settings->bandwidth = hDev->pTunerParams->BTNR_Acquire_Params.LPF_Variable_Bandwidth; |
|---|
| 259 | break; |
|---|
| 260 | } |
|---|
| 261 | switch (hDev->pTunerParams->BTNR_Acquire_Params.Application) |
|---|
| 262 | { |
|---|
| 263 | case BTNR_TunerApplicationMode_eCable: |
|---|
| 264 | TunerApplication = BTNR_TunerApplication_eCable; |
|---|
| 265 | break; |
|---|
| 266 | case BTNR_TunerApplicationMode_eTerrestrial: |
|---|
| 267 | TunerApplication = BTNR_TunerApplication_eTerrestrial; |
|---|
| 268 | break; |
|---|
| 269 | } |
|---|
| 270 | |
|---|
| 271 | settings->tnrApplication = TunerApplication; |
|---|
| 272 | settings->rfInputMode = hDev->pTunerParams->BTNR_RF_Input_Mode; |
|---|
| 273 | |
|---|
| 274 | BDBG_LEAVE(BTNR_3x7x_GetSettings); |
|---|
| 275 | return retCode; |
|---|
| 276 | } |
|---|
| 277 | |
|---|
| 278 | /*************************************************************************** |
|---|
| 279 | Summary: |
|---|
| 280 | BTNR_3x7x_SetRfFreq |
|---|
| 281 | ****************************************************************************/ |
|---|
| 282 | BERR_Code BTNR_3x7x_SetRfFreq( |
|---|
| 283 | BTNR_3x7x_Handle hDev, /* [in] Device handle */ |
|---|
| 284 | uint32_t rfFreq, /* [in] Requested tuner freq., in Hertz */ |
|---|
| 285 | BTNR_TunerMode tunerMode /* [in] Requested tuner mode */ |
|---|
| 286 | ) |
|---|
| 287 | { |
|---|
| 288 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 289 | BSTD_UNUSED(tunerMode); |
|---|
| 290 | BDBG_ENTER(BTNR_3x7x_SetRfFreq); |
|---|
| 291 | BDBG_ASSERT( hDev ); |
|---|
| 292 | BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID ); |
|---|
| 293 | |
|---|
| 294 | |
|---|
| 295 | if (hDev->pTunerStatus->PowerStatus != BTNR_ePower_On) |
|---|
| 296 | { |
|---|
| 297 | BDBG_ERR(("BTNR_3x7x_SetRfFreq: power is still off ")); |
|---|
| 298 | return BERR_NOT_INITIALIZED; |
|---|
| 299 | } |
|---|
| 300 | BDBG_MSG(("BTNR_3x7x_Tune: TUNE TIME START")); |
|---|
| 301 | hDev->pTunerParams->BTNR_Internal_Params.LNA_Enable = BTNR_Internal_Params_eEnable; |
|---|
| 302 | |
|---|
| 303 | hDev->pTunerParams->BTNR_Acquire_Params.RF_Freq = rfFreq; |
|---|
| 304 | |
|---|
| 305 | if (hDev->pTunerParams->BTNR_TuneType.TuneType == BTNR_TuneType_eInitTune) |
|---|
| 306 | { |
|---|
| 307 | /* Important: Init Tuner before TNR */ |
|---|
| 308 | BDBG_MSG(("BTNR_3x7x_Tune: BTNR_TuneType_eInitTune %0x %0x %0x %0x %0x", hDev->pTunerParams->BTNR_Acquire_Params.Application, hDev->pTunerParams->BTNR_Acquire_Params.Standard, hDev->pTunerParams->BTNR_Acquire_Params.LPF_Bandwidth, hDev->pTunerParams->BTNR_Acquire_Params.LPF_Variable_Bandwidth, hDev->pTunerParams->BTNR_Acquire_Params.RF_Freq )); |
|---|
| 309 | BTNR_P_TunerInit(hDev); |
|---|
| 310 | BTNR_P_TunerTune(hDev); |
|---|
| 311 | BTNR_P_TnrInit(hDev); |
|---|
| 312 | BREG_Write32(hDev->hRegister, BCHP_UFE_SPARE, hDev->pTunerParams->BTNR_Local_Params.TunerBBSaddress); |
|---|
| 313 | } |
|---|
| 314 | else if (hDev->pTunerParams->BTNR_TuneType.TuneType == BTNR_TuneType_eTune) |
|---|
| 315 | { |
|---|
| 316 | BDBG_MSG(("BTNR_3x7x_Tune: BTNR_TuneType_eTune")); |
|---|
| 317 | BTNR_P_TunerTune(hDev); |
|---|
| 318 | BTNR_P_TnrInit(hDev); |
|---|
| 319 | |
|---|
| 320 | } |
|---|
| 321 | else if (hDev->pTunerParams->BTNR_TuneType.TuneType == BTNR_TuneType_eMiniTune) |
|---|
| 322 | { |
|---|
| 323 | BDBG_MSG(("BTNR_3x7x_Tune: BTNR_TuneType_eMiniTune")); |
|---|
| 324 | BTNR_P_TnrMiniInit(hDev); /* just reset the data path */ |
|---|
| 325 | BTNR_P_TunerTune(hDev); |
|---|
| 326 | } |
|---|
| 327 | /* make sure the status fileds are up to date since Dave is using staus field to know if new Tune will be required SW3461-140*/ |
|---|
| 328 | BTNR_P_TunerStatus(hDev); |
|---|
| 329 | BDBG_MSG(("BTNR_3x7x_Tune: TUNE TIME COMPLETE")); |
|---|
| 330 | |
|---|
| 331 | BTMR_StopTimer(hDev->hTimer); |
|---|
| 332 | BTMR_StartTimer(hDev->hTimer, 500000); |
|---|
| 333 | BDBG_LEAVE(BTNR_3x7x_SetRfFreq); |
|---|
| 334 | return retCode; |
|---|
| 335 | } |
|---|
| 336 | |
|---|
| 337 | /*************************************************************************** |
|---|
| 338 | Summary: |
|---|
| 339 | BTNR_3x7x_GetRfFreq |
|---|
| 340 | ****************************************************************************/ |
|---|
| 341 | BERR_Code BTNR_3x7x_GetRfFreq( |
|---|
| 342 | BTNR_3x7x_Handle hDev, /* [in] Device handle */ |
|---|
| 343 | uint32_t *rfFreq, /* [output] Returns tuner freq., in Hertz */ |
|---|
| 344 | BTNR_TunerMode *tunerMode /* [output] Returns tuner mode */ |
|---|
| 345 | ) |
|---|
| 346 | { |
|---|
| 347 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 348 | |
|---|
| 349 | |
|---|
| 350 | BDBG_ENTER(BTNR_3x7x_GetRfFreq); |
|---|
| 351 | BDBG_ASSERT( hDev ); |
|---|
| 352 | BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID ); |
|---|
| 353 | |
|---|
| 354 | |
|---|
| 355 | *rfFreq = hDev->pTunerParams->BTNR_Acquire_Params.RF_Freq; |
|---|
| 356 | *tunerMode = BTNR_TunerMode_eDigital; |
|---|
| 357 | |
|---|
| 358 | BDBG_LEAVE(BTNR_3x7x_GetRfFreq); |
|---|
| 359 | return retCode; |
|---|
| 360 | } |
|---|
| 361 | /*************************************************************************** |
|---|
| 362 | Summary: |
|---|
| 363 | BTNR_3x7x_GetInfo |
|---|
| 364 | ****************************************************************************/ |
|---|
| 365 | |
|---|
| 366 | BERR_Code BTNR_3x7x_GetInfo( |
|---|
| 367 | BTNR_3x7x_Handle hDev, /* [in] Device handle */ |
|---|
| 368 | BTNR_TunerInfo *tnrInfo /* [out] Tuner information */ |
|---|
| 369 | ) |
|---|
| 370 | { |
|---|
| 371 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 372 | |
|---|
| 373 | BDBG_ENTER(BTNR_3x7x_GetInfo); |
|---|
| 374 | BDBG_ASSERT( hDev ); |
|---|
| 375 | BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID ); |
|---|
| 376 | |
|---|
| 377 | tnrInfo->tunerMaker = 1; |
|---|
| 378 | tnrInfo->tunerId = 0x7552; |
|---|
| 379 | tnrInfo->tunerMajorVer = 0; |
|---|
| 380 | tnrInfo->tunerMinorVer = 0; |
|---|
| 381 | |
|---|
| 382 | BDBG_LEAVE(BTNR_3x7x_GetInfo); |
|---|
| 383 | return retCode; |
|---|
| 384 | } |
|---|
| 385 | |
|---|
| 386 | |
|---|
| 387 | /*************************************************************************** |
|---|
| 388 | * BTNR_3x7x_PowerUp() |
|---|
| 389 | ***************************************************************************/ |
|---|
| 390 | BERR_Code BTNR_3x7x_PowerUp (BTNR_3x7x_Handle hTnr) |
|---|
| 391 | { |
|---|
| 392 | BERR_Code eResult = BERR_SUCCESS; |
|---|
| 393 | |
|---|
| 394 | |
|---|
| 395 | BREG_WriteField(hTnr->hRegister, UFE_MISC2_CLK_RESET, CLK_SDADC_RESET, 0x0); /* This must be AFTER UFE reset*/ |
|---|
| 396 | |
|---|
| 397 | hTnr->pTunerParams->BTNR_Internal_Params.LNA_Enable = BTNR_Internal_Params_eEnable; |
|---|
| 398 | |
|---|
| 399 | BDBG_MSG(("BTNR_3x7x_PowerUp: %d ",hTnr->pTunerParams->BTNR_RF_Input_Mode)); |
|---|
| 400 | |
|---|
| 401 | /* Tuner Power Mode set indirectly by RF Input Mode function/command */ |
|---|
| 402 | switch ( hTnr->pTunerParams->BTNR_RF_Input_Mode ) |
|---|
| 403 | { |
|---|
| 404 | case BTNR_3x7x_TunerRfInputMode_eExternalLna : |
|---|
| 405 | hTnr->pTunerParams->BTNR_TunePowerMode.Tuner_Power_Mode = BTNR_Tuner_Power_Mode_eUHF_Power; |
|---|
| 406 | break; |
|---|
| 407 | |
|---|
| 408 | /* In case RF Input mode is "off", change to StandardIf */ |
|---|
| 409 | case BTNR_3x7x_TunerRfInputMode_eOff : |
|---|
| 410 | hTnr->pTunerParams->BTNR_RF_Input_Mode = BTNR_3x7x_TunerRfInputMode_eStandardIf; |
|---|
| 411 | /* NO break (fall through to handle BTNR_TunerRfInputMode_eStandardIf) */ |
|---|
| 412 | case BTNR_3x7x_TunerRfInputMode_eInternalLna : |
|---|
| 413 | case BTNR_3x7x_TunerRfInputMode_eStandardIf : |
|---|
| 414 | hTnr->pTunerParams->BTNR_TunePowerMode.Tuner_Power_Mode = BTNR_Tuner_Power_Mode_eVHF_Power; |
|---|
| 415 | break; |
|---|
| 416 | |
|---|
| 417 | case BTNR_3x7x_TunerRfInputMode_eLowIf : |
|---|
| 418 | case BTNR_3x7x_TunerRfInputMode_eBaseband : |
|---|
| 419 | hTnr->pTunerParams->BTNR_TunePowerMode.Tuner_Power_Mode = BTNR_Tuner_Power_Mode_eMini_Power; |
|---|
| 420 | break; |
|---|
| 421 | |
|---|
| 422 | /* In case invalid RF Input mode set, return an error */ |
|---|
| 423 | default: |
|---|
| 424 | eResult = BERR_INVALID_PARAMETER; |
|---|
| 425 | } |
|---|
| 426 | if ( eResult == BERR_SUCCESS ) |
|---|
| 427 | { |
|---|
| 428 | hTnr->pTunerParams->BTNR_Internal_Params.LNA_Enable = BTNR_Internal_Params_eEnable; |
|---|
| 429 | BTNR_P_Tuner_Power_Control(hTnr); |
|---|
| 430 | hTnr->pTunerStatus->PowerStatus = BTNR_ePower_On; |
|---|
| 431 | } |
|---|
| 432 | |
|---|
| 433 | BREG_Write32(hTnr->hRegister, BCHP_UFE_LFSR_SEED , 0); |
|---|
| 434 | return ( eResult ); |
|---|
| 435 | } |
|---|
| 436 | |
|---|
| 437 | /*************************************************************************** |
|---|
| 438 | * BTNR_3x7x_PowerDown() |
|---|
| 439 | ***************************************************************************/ |
|---|
| 440 | BERR_Code BTNR_3x7x_PowerDown(BTNR_3x7x_Handle hTnr) |
|---|
| 441 | { |
|---|
| 442 | |
|---|
| 443 | BDBG_MSG(("BTNR_3x7x_PowerDown")); |
|---|
| 444 | BREG_Write32(hTnr->hRegister, BCHP_UFE_AFE_TNR_PWRUP_01, 0x0); |
|---|
| 445 | BREG_Write32(hTnr->hRegister, BCHP_UFE_AFE_TNR0_PWRUP_01, 0x0); |
|---|
| 446 | BREG_Write32(hTnr->hRegister, BCHP_UFE_AFE_TNR0_PWRUP_02, 0x0); |
|---|
| 447 | BREG_Write32(hTnr->hRegister, BCHP_UFE_AFE_TNR0_RESET_01, 0xFFFFFFFF); |
|---|
| 448 | BREG_Write32(hTnr->hRegister, BCHP_UFE_AFE_TNR0_RESETB_01, 0x0); |
|---|
| 449 | BREG_Write32(hTnr->hRegister, BCHP_UFE_AFE_TNR_RESET_01, 0xFFFFFFFF); |
|---|
| 450 | BREG_Write32(hTnr->hRegister, BCHP_UFE_AFE_TNR_RESETB_01, 0x0); |
|---|
| 451 | BREG_Write32(hTnr->hRegister, BCHP_UFE_MISC2_CLK_RESET, 0x7); |
|---|
| 452 | BREG_Write32(hTnr->hRegister, BCHP_SDADC_CTRL_PWRUP, 0x0); |
|---|
| 453 | |
|---|
| 454 | BKNI_Memset( hTnr->pTunerParams, 0x00, sizeof( BTNR_3x7x_TuneParams_t ) ); |
|---|
| 455 | hTnr->pTunerStatus->PowerStatus = BTNR_ePower_Off; |
|---|
| 456 | return BERR_SUCCESS; |
|---|
| 457 | } |
|---|
| 458 | |
|---|
| 459 | |
|---|
| 460 | /*************************************************************************** |
|---|
| 461 | Summary: |
|---|
| 462 | BTNR_3x7x_SetPowerSaver |
|---|
| 463 | ****************************************************************************/ |
|---|
| 464 | BERR_Code BTNR_3x7x_SetPowerSaver( |
|---|
| 465 | BTNR_3x7x_Handle hDev, /* [in] Device handle */ |
|---|
| 466 | BTNR_PowerSaverSettings *pwrSettings /* [in] Power saver settings. */ |
|---|
| 467 | ) |
|---|
| 468 | { |
|---|
| 469 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 470 | |
|---|
| 471 | BDBG_ENTER(BTNR_3x7x_SetPowerSaver); |
|---|
| 472 | |
|---|
| 473 | if(!pwrSettings->enable) |
|---|
| 474 | BTNR_3x7x_PowerUp(hDev); |
|---|
| 475 | else |
|---|
| 476 | BTNR_3x7x_PowerDown(hDev); |
|---|
| 477 | |
|---|
| 478 | BDBG_LEAVE(BTNR_3x7x_SetPowerSaver); |
|---|
| 479 | return retCode; |
|---|
| 480 | } |
|---|
| 481 | /*************************************************************************** |
|---|
| 482 | * BTNR_3x7x_GetPowerSaver() |
|---|
| 483 | ***************************************************************************/ |
|---|
| 484 | BERR_Code BTNR_3x7x_GetPowerSaver( |
|---|
| 485 | BTNR_3x7x_Handle hDev, /* [in] Device handle */ |
|---|
| 486 | BTNR_PowerSaverSettings *pwrSettings /* [in] Power saver settings. */ |
|---|
| 487 | ) |
|---|
| 488 | { |
|---|
| 489 | BERR_Code retCode = BERR_SUCCESS; |
|---|
| 490 | BDBG_ENTER(BTNR_3x7x_GetPowerSaver); |
|---|
| 491 | |
|---|
| 492 | pwrSettings->enable = hDev->pTunerStatus->PowerStatus; |
|---|
| 493 | |
|---|
| 494 | BDBG_LEAVE(BTNR_3x7x_GetPowerSaver); |
|---|
| 495 | return retCode; |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | |
|---|
| 499 | |
|---|