source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/aob/7552/baob_status.c

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 18.5 KB
Line 
1/******************************************************************************
2 *    (c)2011-2012 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 * Except as expressly set forth in the Authorized License,
15 * 
16 * 1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17 * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18 * and to use this information only in connection with your use of Broadcom integrated circuit products.
19 * 
20 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21 * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23 * THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25 * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26 * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27 * USE OR PERFORMANCE OF THE SOFTWARE.
28 *
29 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30 * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31 * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32 * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34 * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35 * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36 * ANY LIMITED REMEDY.
37 *
38 * $brcm_Workfile: baob_status.c $
39 * $brcm_Revision: 24 $
40 * $brcm_Date: 3/13/12 5:05p $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /AP/ctfe/core/aob/baob_status.c $
47 *
48 * 24   3/13/12 5:05p farshidf
49 * SW3128-1: merge to inetg
50 *
51 * Fw_Integration_Devel/10   3/13/12 5:04p farshidf
52 * SW3128-1: merge to inetg
53 *
54 * Fw_Integration_Devel/AP_V4_0_AOB_DEV/4   3/13/12 5:00p farshidf
55 * SW3128-1: reset status clean up
56 *
57 * Fw_Integration_Devel/AP_V4_0_AOB_DEV/3   3/1/12 10:25a farshidf
58 * SW3128-1: fix compile issue for 7552
59 *
60 * Fw_Integration_Devel/AP_V4_0_AOB_DEV/2   2/16/12 9:46a farshidf
61 * SW3128-1: remove printf
62 *
63 * Fw_Integration_Devel/AP_V4_0_AOB_DEV/1   2/15/12 5:15p dorothyl
64 * SW3128-1: fix BERSRC status
65 *
66 * Fw_Integration_Devel/6   2/9/12 12:56p farshidf
67 * SW3128-1: remove warning
68 *
69 * Fw_Integration_Devel/AP_V3_0_AOB_DEV/8   2/9/12 12:55p farshidf
70 * SW3128-1: remove extra warning
71 *
72 * Fw_Integration_Devel/AP_V3_0_AOB_DEV/7   2/8/12 4:10p dorothyl
73 * SW3128-1 : bug in status
74 *
75 * Fw_Integration_Devel/AP_V3_0_AOB_DEV/6   2/8/12 2:15p dorothyl
76 * SW3128-1 : OOB BERT
77 *
78 * Fw_Integration_Devel/AP_V3_0_AOB_DEV/4   2/6/12 10:34a dorothyl
79 * SW3128-1 : fix a comment
80 *
81 * Fw_Integration_Devel/AP_V3_0_AOB_DEV/3   2/3/12 1:56p dorothyl
82 * SW3128-1: oob channel power
83 *
84 * Fw_Integration_Devel/AP_V3_0_AOB_DEV/2   1/4/12 2:55p dorothyl
85 * SW3128-1 : needed to read IRQST twice to get correct value
86 *
87 * Fw_Integration_Devel/AP_V3_0_AOB_DEV/1   12/13/11 12:29p mpovich
88 * SW3128-69: Add lock/unlock IRQs and status for Out of Band.
89 *
90 * Fw_Integration_Devel/AP_V3_0_AOB_DEV/SW3128-69/1   12/12/11 9:38p mpovich
91 * SW3128-69: Support for lock/unlock Host IRQs for Out of Band.
92 *
93 * 15   11/16/11 10:37a farshidf
94 * SW3461-91: merge to main
95 *
96 * Fw_Integration_Devel/2   11/9/11 4:42p farshidf
97 * SW7552-139: merge to dev/integ
98 *
99 * 14   11/9/11 4:38p farshidf
100 * SW7552-139: adapt the code for magnum support
101 *
102 * Fw_Integration_Devel/1   11/3/11 12:55p farshidf
103 * SW3128-60: merge to integ
104 *
105 * Fw_Integration_Devel/AP_V2_0_AOB_DEV/1   10/24/11 11:07a dorothyl
106 * SW3128-1 : update bert sync
107 *
108 * 10   4/18/11 5:32p farshidf
109 * SW3128-1: update to make it work with host chip
110 *
111 * 9   4/12/11 11:47a farshidf
112 * SW3128-1: fix warning
113 *
114 * 8   4/7/11 11:24a farshidf
115 * SW3128-1: add lock status
116 *
117 * 7   4/5/11 3:23p farshidf
118 * SW3461-1: merge  main
119 *
120 * AOB_3128_1/13   4/5/11 10:54a dorothyl
121 * SW3128-1: OOB UPDATE
122 *
123 * AOB_3128_1/12   3/31/11 11:32a dorothyl
124 * SW3128-1: oob status fix
125 *
126 * AOB_3128_1/11   3/29/11 10:39a dorothyl
127 * SW3128-1: oob fix
128 *
129 * AOB_3128_1/10   3/28/11 2:33p dorothyl
130 * SW3128-1: OOB FIX
131 *
132 * AOB_3128_1/9   3/25/11 11:36a dorothyl
133 * SW3128-1: fixed fec/rec lock
134 *
135 * AOB_3128_1/8   3/25/11 11:28a dorothyl
136 * SW3128-1: fix OOB
137 *
138 * 2   3/22/11 5:04p mpovich
139 * SW3128-1: Add latest AOB driver changes.
140 *
141 * AOB_3128_1/5   3/21/11 6:25p farshidf
142 * SW3461-1: update naming
143 *
144 * AOB_3128_1/4   3/18/11 4:58p cbrooks
145 * sw3128-1:BERT Sync Modification
146 *
147 * AOB_3128_1/3   3/18/11 4:37p cbrooks
148 * sw3128-1:Added Status for OOB
149 *
150 * AOB_3128_1/2   3/17/11 8:39p cbrooks
151 * sw3128-1:Worked on AOB status
152 *
153 * AOB_3128_1/1   3/17/11 6:16p cbrooks
154 * sw3128-1:Added OOB code
155 *
156 * 1   3/11/11 3:41p farshidf
157 * SW3128-1: add status file
158 *
159 *****************************************************************************/
160
161
162#include "bstd.h"
163#include "bkni.h"
164#include "bkni_multi.h"
165#include "btmr.h"
166#include "bmth.h"
167#ifdef LEAP_BASED_CODE
168#include "baob_api.h"
169#include "bwfe_global_clk.h"
170#else
171#include "baob.h"
172BDBG_MODULE(baob_status);
173#endif
174#include "baob_struct.h"
175#include "baob_acquire.h"
176#include "baob_status.h"
177#include "baob_utils.h"
178#include "baob_priv.h"
179#include "bchp_oob.h"
180
181#define LOG10_OB_PREADC 0
182
183
184/************************************************************************************************
185BCM3128A0 : CTRL3 and CTRL6 have a bug --- need to read/write all 32 bits.
186 ************************************************************************************************/
187
188/************************************************************************************************
189 * BAOB_P_Reset_Status()         This routine resets the status parameters
190 ************************************************************************************************/
191BERR_Code BAOB_P_Reset_Status(BAOB_3x7x_Handle h)
192{
193        uint32_t ReadReg;
194
195        BERR_Code retCode = BERR_SUCCESS;
196        BDBG_MSG(("BAOB_P_Reset_Status() "));
197
198        h->pStatus->Auto = BAOB_Status_eDisable;
199        h->pStatus->AI = BAOB_Status_eDisable;
200        h->pStatus->BYP = BAOB_Status_eDisable;
201        h->pStatus->BPS = BAOB_Status_BPS_eDVS_178;
202        h->pStatus->AA = BAOB_Status_BPS_eDVS178;
203        h->pStatus->PLBW = BAOB_Status_PLBW_eLow; 
204   /*   h->pStatus->BERSRC = BAOB_Status_BERT_Source_eI; */
205        h->pStatus->SI = BAOB_Status_eNotInverted;
206        h->pStatus->BERSYN = BAOB_Status_eUnlock;
207        h->pStatus->Reack_Count = 0;
208        h->pStatus->SNR = 0;
209        h->pStatus->Sample_Rate = 0; 
210        h->pStatus->Symbol_Rate = 0; 
211        h->pStatus->Frequency_Error = 0;
212        h->pStatus->Symbol_Error = 0;                     
213        h->pStatus->BERT = 0;             
214        h->pStatus->FEC_Corr_RS_Blocks = 0; 
215        h->pStatus->FEC_UCorr_RS_Blocks = 0; 
216        h->pStatus->ATM_Total_Count = 0;     
217        h->pStatus->ATM_Loss_Count = 0;       
218
219        /*clear RS correction counter--*/
220        BREG_Write32(h->hRegister, BCHP_OOB_STRSB, 0x00000000);
221
222        /*Clear BERT PRBS counter by reading it*/
223        ReadReg = BREG_Read32(h->hRegister, BCHP_OOB_LDBERTC); 
224        ReadReg = BREG_Read32(h->hRegister, BCHP_OOB_LDATMC);
225        ReadReg = BREG_Read32(h->hRegister, BCHP_OOB_LDATML);
226        ReadReg = BREG_Read32(h->hRegister, BCHP_OOB_LDHEC);
227
228
229return retCode;
230}
231
232
233/************************************************************************************************
234 * BAOB_P_GetLock_Status()       This routine return the lock status
235 ************************************************************************************************/
236BERR_Code BAOB_P_GetLock_Status(BAOB_3x7x_Handle h)
237{
238        uint32_t ReadReg;
239
240        /*Receiver Lock*/
241        ReadReg = BREG_ReadField(h->hRegister, OOB_IRQST,       SNR_IS);
242        ReadReg = BREG_ReadField(h->hRegister, OOB_IRQST,       SNR_IS);
243        if (ReadReg == 1)
244        {
245                h->pStatus->RLK = BAOB_Status_eLock;
246        }
247        else
248        {
249                h->pStatus->RLK = BAOB_Status_eUnlock;
250        }
251       
252        /*FEC Lock*/
253        ReadReg = BREG_ReadField(h->hRegister, OOB_IRQST,       FEC_IS);
254        ReadReg = BREG_ReadField(h->hRegister, OOB_IRQST,       FEC_IS);
255        if (ReadReg == 1)
256        {
257                h->pStatus->FLK = BAOB_Status_eLock;
258        }
259        else
260        {
261                h->pStatus->FLK = BAOB_Status_eUnlock;
262        }
263
264        return BERR_SUCCESS;
265}
266/************************************************************************************************
267 * BAOB_P_Get_Status()   This routine gets the status parameters
268 ************************************************************************************************/
269BERR_Code BAOB_P_Get_Status(BAOB_3x7x_Handle h)
270{
271        BERR_Code retCode = BERR_SUCCESS;
272
273        uint32_t ReadReg;
274#ifdef LEAP_BASED_CODE
275        BAOB_P_AobCallbackData_t CallbackFrontend;
276#endif
277        /*BDBG_MSG(("BAOB_P_Get_Status() "));*/
278
279        /*Auto Acquire: Get from BAOB_Acquire_Params_t structure since this is a software flag*/
280        if (h->pAcqParam->BAOB_Acquire_Params.Auto == BAOB_Acquire_Params_eEnable)
281        {
282                h->pStatus->Auto = BAOB_Status_eEnable;
283        }
284        else
285        {
286                h->pStatus->Auto = BAOB_Status_eDisable;
287        }
288
289        /*Auto Invert Spectrum: Get from BAOB_Acquire_Params_t structure since this is a software flag*/
290        if (h->pAcqParam->BAOB_Acquire_Params.AI == BAOB_Acquire_Params_eEnable)
291        {
292                h->pStatus->AI = BAOB_Status_eEnable;
293        }
294        else
295        {
296                h->pStatus->AI = BAOB_Status_eDisable;
297        }
298
299        /*FEC Bypass*/
300        ReadReg = BREG_ReadField(h->hRegister, OOB_CTRL5, FECBYP);
301        if (ReadReg == 1)
302        {
303                h->pStatus->BYP = BAOB_Status_eEnable;
304        }
305        else
306        {
307                h->pStatus->BYP = BAOB_Status_eDisable;
308        }
309
310        /*BPS: Get from BAOB_Acquire_Params_t structure since this is a software flag*/
311        switch (h->pAcqParam->BAOB_Acquire_Params.BPS)
312        {
313                case BAOB_Acquire_Params_BPS_eDVS_178:
314                        h->pStatus->BPS = BAOB_Status_BPS_eDVS_178;
315                        break;
316                case BAOB_Acquire_Params_BPS_eDVS_167_GradeA:
317                        h->pStatus->BPS = BAOB_Status_BPS_eDVS_167_GradeA;     
318                        break;
319                case BAOB_Acquire_Params_BPS_eDVS_167_GradeB:
320                        h->pStatus->BPS = BAOB_Status_BPS_eDVS_167_GradeB;
321                        break;
322                case BAOB_Acquire_Params_BPS_eBERT_TEST_MODE:
323                        h->pStatus->BPS = BAOB_Status_BPS_eBERT_TEST_MODE;
324                        break;
325                default:
326                        h->pStatus->BPS = BAOB_Status_BPS_eDVS_178;
327                        BDBG_ERR(("UNKNOWN BAOB_Acquire_Params.BPS in BAOB_P_Get_Status()"));
328        }
329                /*FEC Bypass*/
330        ReadReg = BREG_ReadField(h->hRegister, OOB_LDFECH, OOB_LDFECH_0);
331        if ((ReadReg & 0x4) == 0)
332        {
333                h->pStatus->AA = BAOB_Status_BPS_eDVS167;
334        }
335        else
336        {
337                h->pStatus->AA = BAOB_Status_BPS_eDVS178;
338        }
339
340        /*PLBW: Get from BAOB_Acquire_Params_t structure since this is a software flag*/
341        switch (h->pAcqParam->BAOB_Acquire_Params.PLBW)
342        {
343                case BAOB_Acquire_Params_PLBW_eLow:
344                        h->pStatus->PLBW = BAOB_Status_PLBW_eLow;
345                        break;
346                case BAOB_Acquire_Params_PLBW_eMed:
347                        h->pStatus->PLBW = BAOB_Status_PLBW_eMed; 
348                        break;
349                case BAOB_Acquire_Params_PLBW_eHigh:
350                        h->pStatus->PLBW = BAOB_Status_PLBW_eHigh; 
351                        break;
352                default:
353                        h->pStatus->PLBW = BAOB_Status_PLBW_eLow;
354                        BDBG_ERR(("UNKNOWN BAOB_Acquire_Params.BPS in BAOB_P_Get_Status()"));
355        }
356
357        /*Get BERT Source*/
358        /*Need to add a shadow  hack since this register can not be read back*/
359        /*BDBG_MSG(( "STATUS: CTRL3 %x, BERSRC bits = %x", h->pAcqParam->BAOB_Local_Params.CTRL3,(h->pAcqParam->BAOB_Local_Params.CTRL3>>28) & 0x3));*/
360        ReadReg = BREG_ReadField(h->hRegister, OOB_CTRL3,BERSRC);
361        switch (ReadReg & 0x3)
362        {
363        case 0x0:
364                h->pStatus->BERSRC = BAOB_Status_BERT_Source_eI;
365                break;
366        case 0x1:
367                h->pStatus->BERSRC = BAOB_Status_BERT_Source_eQ; 
368                break;
369        case 0x2:
370                h->pStatus->BERSRC = BAOB_Status_BERT_Source_eIQ; 
371                break;
372        case 0x3:
373                h->pStatus->BERSRC = BAOB_Status_BERT_Source_eFEC; 
374                break;
375        default :
376                h->pStatus->BERSRC = BAOB_Status_BERT_Source_eI;
377                BDBG_ERR(("UNKNOWN BERT_Source in BAOB_P_Get_Status()"));
378        }
379
380        /*Receiver Lock*/
381        ReadReg = BREG_ReadField(h->hRegister, OOB_IRQST,       SNR_IS);
382        ReadReg = BREG_ReadField(h->hRegister, OOB_IRQST,       SNR_IS);
383        if (ReadReg == 1)
384        {
385                h->pStatus->RLK = BAOB_Status_eLock;
386        }
387        else
388        {
389                h->pStatus->RLK = BAOB_Status_eUnlock;
390        }
391       
392        /*FEC Lock*/
393        ReadReg = BREG_ReadField(h->hRegister, OOB_IRQST,       FEC_IS);
394        ReadReg = BREG_ReadField(h->hRegister, OOB_IRQST,       FEC_IS);
395        if (ReadReg == 1)
396        {
397                h->pStatus->FLK = BAOB_Status_eLock;
398        }
399        else
400        {
401                h->pStatus->FLK = BAOB_Status_eUnlock;
402        }
403
404        /*Spectral Inversion Lock*/
405        ReadReg = BREG_ReadField(h->hRegister, OOB_CTRL2, OFMT);
406        if (h->pAcqParam->BAOB_Acquire_Params.IS == BAOB_Acquire_Params_eDisable) /*OFMT = 0 initially*/
407        {
408                h->pStatus->SI = (ReadReg == 0) ? BAOB_Status_eNotInverted : BAOB_Status_eInverted; 
409        }
410        else                                                                       /*OFMT = 1 initially*/
411        {
412                h->pStatus->SI = (ReadReg == 1) ? BAOB_Status_eNotInverted : BAOB_Status_eInverted; 
413        }
414
415        /*BERT Sync*/
416        /*Bug in A0 chip prevents reading so set to unlock at all times*/
417        ReadReg = BREG_ReadField(h->hRegister, OOB_CTRL3,       BERSYN);
418        /*ReadReg = h->pAcqParam->BAOB_Local_Params.CTRL3 & 0x00080000;*/
419        if (ReadReg == 1)
420        {
421                h->pStatus->BERSYN = BAOB_Status_eLock;
422        }
423        else
424        {
425                h->pStatus->BERSYN = BAOB_Status_eUnlock;
426        }
427 
428        /*set in the baob_acquire()*/
429        /*h->pStatus->Reack_Count = 0;  */
430
431        /***************************************/
432        /*Determine SNR                        */
433        /*BBS will divide by 256 to get dB     */
434        /***************************************/
435        /*SNR in dB is different for each QAM Mode*/
436  /*QPSK  124.4714 dB - 20*log(ERRVAL) or if scaled by 256: 31865-5120*log(ERRVAL)*/
437        ReadReg = BREG_Read32(h->hRegister, BCHP_OOB_LDSNRE);
438        ReadReg = ReadReg/256; 
439        h->pStatus->SNR = 31865 - (BMTH_2560log10(ReadReg)<<1);
440       
441        /*Sample Rate*/
442
443        h->pStatus->Sample_Rate = F_HS;                                                 
444   
445        /*Symbol Rate*/
446        h->pStatus->Symbol_Rate = BAOB_P_Get_SymbolRate(h);
447   
448        /*Frequency Error*/
449        h->pStatus->Frequency_Error = BAOB_P_Get_CFL_FrequencyError(h); 
450
451        /*Timing Error*/
452        h->pStatus->Symbol_Error = BAOB_P_Get_TL_FrequencyError(h)-h->pStatus->Symbol_Rate;
453        /*BDBG_MSG(("symbol err=%d",h->pStatus->Symbol_Error ));*/
454
455        /*BERT Count*/
456        ReadReg=BREG_Read32(h->hRegister, BCHP_OOB_LDBERTC);
457        h->pStatus->BERT = h->pStatus->BERT + ReadReg;
458       
459        /*RS Corrected Bits Count*/
460        ReadReg = BREG_Read32(h->hRegister, BCHP_OOB_LDRSB); 
461        ReadReg = ReadReg/65536;
462        h->pStatus->FEC_Corr_RS_Blocks = h->pStatus->FEC_Corr_RS_Blocks+ReadReg;   
463
464        /*RS Uncorrected Blocks Count*/
465        h->pStatus->FEC_UCorr_RS_Blocks = h->pStatus->FEC_UCorr_RS_Blocks+BREG_Read32(h->hRegister, BCHP_OOB_LDUERC);   
466
467        /*ATM Total Cell Count*/
468        h->pStatus->ATM_Total_Count = h->pStatus->ATM_Total_Count+BREG_Read32(h->hRegister, BCHP_OOB_LDATMC);   
469
470        /*ATM Cell Loss Count*/
471        ReadReg = BREG_Read32(h->hRegister, BCHP_OOB_LDATML); 
472        ReadReg = ReadReg/65536;
473        h->pStatus->ATM_Loss_Count = h->pStatus->ATM_Loss_Count+ReadReg;
474#ifdef LEAP_BASED_CODE
475        /*Channel Power*/
476        /*Get front end status*/
477       
478        CallbackFrontend.hTunerChn = (h->pCallbackParam[BAOB_Callback_eTuner]);
479        CallbackFrontend.Mode = BAOB_CallbackMode_eRequestMode;
480        BKNI_EnterCriticalSection();
481        (h->pCallback[BAOB_Callback_eTuner])(&CallbackFrontend);       
482        BKNI_LeaveCriticalSection();
483
484        ReadReg=0;
485
486#if OB_MODE == OB_AD   
487        h->pStatus->FrontEndGain_db = (int32_t)(CallbackFrontend.PostADC_Gain_x256db);
488#else
489        /*Gain before the WB A/D*/
490        ReadReg=CallbackFrontend.PreADC_Gain_x256db;
491        /*AGCF in WFE Gain*/
492        if ((CallbackFrontend.PreADC_Gain_x256db == -32768) || (CallbackFrontend.PostADC_Gain_x256db == -32768))   
493        {
494                h->pStatus->FrontEndGain_db = -32768;
495        }
496        else
497        {
498                h->pStatus->FrontEndGain_db = (int32_t)( ReadReg + CallbackFrontend.PostADC_Gain_x256db);
499        } 
500#endif
501
502        /*AGCF*/
503   /*   BDBG_MSG(("OOB FrontendGain(dB) = %d",(int32_t)( ReadReg + CallbackFrontend.PostADC_Gain_x256db)));       */
504
505        /*DAGC Gain*/
506        /*DAGC_LPINT.INTGTR is 32-bit 8.24 unsigned number*/
507        /*Reset value is 0x00000000*/
508        /*  db = 20*log10(DAGC_LPINT/2^24)*/
509        /*  256*db = 5120*log10(AGCBVAL/2^16)-5120*log10(2^8)*/ 
510        ReadReg = BREG_ReadField(h->hRegister,OOB_DAGC_LPINT, INTGTR);
511        ReadReg = 2*BMTH_2560log10(ReadReg/POWER2_16) - LOG10_POWER2_8_X5120;
512        h->pStatus->DAGC_Gain_db = (int32_t)ReadReg;  /*BBS will divide by 256 to get dB*/
513        /*BDBG_MSG(("OOB DAGC(dB) = %d",h->pStatus->DAGC_Gain_db));*/
514
515        /*EQ Gain (real part of the main tap)*/
516        /*LDF1.LDF1_0 and LDF1_1 together is a 12-bit 4.8 signed number*/
517        /*LDF1_0 are bits [31:24], LDF1_1 are bits [19:16]*/
518        /*EQ_Gain db = 20*log10( (LDF1_0/2^20)+((LDF1_1/2^16) && 0x000f))/2^12)*/
519        /*EQ 256*db = 5120*log10((LDF1_0/2^20)+((LDF1_1/2^16) && 0x000f))-5120*log10(2^12)*/
520 
521        ReadReg = BREG_ReadField(h->hRegister, OOB_LDF1, OOB_LDF1_0);
522        ReadReg = 2*BMTH_2560log10(BREG_ReadField(h->hRegister, OOB_LDF1, OOB_LDF1_1)+ReadReg*POWER2_4);
523        ReadReg = (ReadReg) - LOG10_POWER2_8_X5120;
524        h->pStatus->EQ_Gain_db = (int32_t)ReadReg;  /*BBS will divide by 256 to get dB*/
525        /*BDBG_MSG(("OOB EQ(dB) = %d",h->pStatus->EQ_Gain_db));*/
526
527        /*check for unknown power level sent from front end, -32768*/
528        if (CallbackFrontend.External_Gain_x256db == -32768)
529        {
530                h->pStatus->EstChannelPower_dbm = -32768;
531        }
532        else
533        {
534
535        switch (h->pAcqParam->BAOB_Acquire_Params.Nyq)
536        {
537                case BAOB_Acquire_Params_Nyq_ehalf_raised:
538                         ReadReg = 0;
539                        break;
540                case BAOB_Acquire_Params_Nyq_ehalf_rtraised:
541                        ReadReg = 3*256;       
542                        break;
543                case    BAOB_Acquire_Params_Nyq_ethird_rtraised:
544                        ReadReg = 3*256;
545                        break;
546                default:
547                        ReadReg = 0;
548                        BDBG_ERR(("UNKNOWN BAOB_Acquire_Params.Nyq in BAOB_P_Get_Status()"));
549        }
550
551#if OB_MODE==OB_AD     
552                h->pStatus->EstChannelPower_dbm = OB_GAIN_OFFSET + ReadReg - h->pStatus->EQ_Gain_db - h->pStatus->FrontEndGain_db - h->pStatus->DAGC_Gain_db - (int32_t)CallbackFrontend.External_Gain_x256db;
553            /*BDBG_MSG(("OB_AD : OOB EstChannelPwr(dB) = %d %d",h->pStatus->EstChannelPower_dbm, OB_GAIN_OFFSET));*/
554#else
555                h->pStatus->EstChannelPower_dbm = OB_GAIN_OFFSET_WB + ReadReg - h->pStatus->EQ_Gain_db - h->pStatus->FrontEndGain_db - h->pStatus->DAGC_Gain_db - (int32_t)CallbackFrontend.External_Gain_x256db;
556                /*BDBG_MSG(("WB_AD : OOB EstChannelPwr(dB) = %d %d",h->pStatus->EstChannelPower_dbm, OB_GAIN_OFFSET_WB));*/
557#endif
558                ReadReg = (h->pStatus->EQ_Gain_db + h->pStatus->FrontEndGain_db + h->pStatus->DAGC_Gain_db + (int32_t)CallbackFrontend.External_Gain_x256db);
559        }
560#endif
561
562        return retCode;
563}
Note: See TracBrowser for help on using the repository browser.