source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/tnr/btnr.c @ 31

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

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 10.3 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2011, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: btnr.c $
11 * $brcm_Revision: Hydra_Software_Devel/20 $
12 * $brcm_Date: 5/4/11 4:20p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/tnr/btnr.c $
19 *
20 * Hydra_Software_Devel/20   5/4/11 4:20p atanugul
21 * SW7231-32: Reverting back to version 18
22 *
23 * Hydra_Software_Devel/19   5/3/11 3:19p vishk
24 * SW7231-32: Implement the Nexus code to support the 3461 frontend chip.
25 * Undo the changes done since version 16.
26 *
27 * Hydra_Software_Devel/18   4/19/11 10:07a atanugul
28 * SW3461-3: Fix Compile Warning
29 *
30 * Hydra_Software_Devel/17   4/11/11 5:15p atanugul
31 * SW3128-2: Add Get_Settings and SetSettings support to 3128 TNR PI
32 *
33 * Hydra_Software_Devel/16   6/22/10 6:13p vishk
34 * SW7420-839: Add support to program AGC gain to 31xx TNR PI
35 *
36 * Hydra_Software_Devel/15   11/17/09 7:59p farshidf
37 * SW7550-38: update the code to the latest nexus call
38 *
39 * Hydra_Software_Devel/14   11/10/09 7:11p farshidf
40 * 7550-38: add the tuner code
41 *
42 * Hydra_Software_Devel/13   8/24/09 6:05p vishk
43 * SW7405-2841: Bcm31xx: Add Power Management support for TNR
44 *
45 * Hydra_Software_Devel/12   8/21/09 6:19p vishk
46 * PR 57484: Bcm31xx: Add Power Management support for TNR
47 *
48 * Hydra_Software_Devel/11   6/7/05 8:35a dlwin
49 * PR 14682: Added additional functions for Docsis and general use.  New
50 * function 'BTNR_GetInfo()' returns additional informtion for the tuner.
51 *
52 * Hydra_Software_Devel/10   4/1/05 5:25p dlwin
53 * PR 14682: Added semi-private functions for QamCm to use to AGC
54 * readings.  This required for Docsis integration.
55 *
56 * Hydra_Software_Devel/9   10/21/03 6:19p dlwin
57 * Removed all BDBG_ENTER(__FUNCTION__) and BDBG_LEAVE(__FUNCTION__) with
58 * macro usage of function, instead of __FUNCTION__.
59 *
60 * Hydra_Software_Devel/8   10/7/03 8:52a dlwin
61 * Removed the need to call a create generic tuner  handle.
62 *
63 * Hydra_Software_Devel/7   9/9/03 8:44a dlwin
64 * Updated API function parameter comment for DocJet.
65 *
66 * Hydra_Software_Devel/6   8/29/03 7:31a dlwin
67 * - Removed reference to 'BFEH'
68 * - Renamed 'BTNR_Set/GetTunerFreq()' to 'BTNR_Set/GetTunerRfFreq()'.
69 *
70 * Hydra_Software_Devel/5   8/26/03 2:23p dlwin
71 * Updated to used newer API, which is model like BREG_I2C and BREG
72 *
73 * Hydra_Software_Devel/4   7/10/03 10:44a dlwin
74 * Fixed a problem Open fails.
75 *
76 * Hydra_Software_Devel/3   7/2/03 3:11p dlwin
77 * Fixed with OpenChannel().
78 *
79 * Hydra_Software_Devel/2   6/26/03 11:11a dlwin
80 * Removed reference to 'bchp_7120.h' and 'bchp_3250.h'.
81 *
82 * Hydra_Software_Devel/1   6/25/03 4:55p dlwin
83 * Initial version
84 *
85 ***************************************************************************/
86#include "bstd.h"
87#include "bkni.h"
88#include "btnr.h"
89#include "btnr_priv.h"
90
91BDBG_MODULE(btnr);
92
93
94#define DEV_MAGIC_ID            ((BERR_TNR_ID<<16) | 0xFACE)
95
96#define CHK_RETCODE( rc, func )     \
97do {                                        \
98    if( (rc = BERR_TRACE(func)) != BERR_SUCCESS ) \
99    {                                       \
100        goto done;                          \
101    }                                       \
102} while(0)
103
104
105/*******************************************************************************
106*
107*   Private Module Handles
108*
109*******************************************************************************/
110
111
112
113/*******************************************************************************
114*
115*   Default Module Settings
116*
117*******************************************************************************/
118
119
120
121/*******************************************************************************
122*
123*   Private Module Data
124*
125*******************************************************************************/
126
127
128
129/*******************************************************************************
130*
131*   Private Module Functions
132*
133*******************************************************************************/
134
135
136
137/*******************************************************************************
138*
139*   Public Module Functions
140*
141*******************************************************************************/
142BERR_Code BTNR_SetTunerRfFreq(
143    BTNR_Handle hDev,                   /* [in] Device handle */
144    uint32_t freq,                      /* [in] Requested tuner freq., in Hertz */
145    BTNR_TunerMode tunerMode            /* [in] Requested tuner mode */
146    )
147{
148    BERR_Code retCode = BERR_SUCCESS;
149
150
151    BDBG_ENTER(BTNR_SetTunerRfFreq);
152    BDBG_ASSERT( hDev );
153    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
154   
155    if( hDev->pSetRfFreq != NULL )
156    {
157        CHK_RETCODE( retCode, hDev->pSetRfFreq( hDev->hDevImpl, freq, tunerMode ) );
158    }
159
160done:
161    BDBG_LEAVE(BTNR_SetTunerRfFreq);
162    return( retCode );
163}
164
165BERR_Code BTNR_GetTunerRfFreq(
166    BTNR_Handle hDev,                   /* [in] Device handle */
167    uint32_t *freq,                     /* [output] Returns tuner freq., in Hertz */
168    BTNR_TunerMode *tunerMode           /* [output] Returns tuner mode */
169    )
170{
171    BERR_Code retCode = BERR_SUCCESS;
172
173
174    BDBG_ENTER(BTNR_GetTunerRfFreq);
175    BDBG_ASSERT( hDev );
176    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
177
178    if( hDev->pGetRfFreq != NULL )
179    {
180        CHK_RETCODE( retCode, hDev->pGetRfFreq( hDev->hDevImpl, freq, tunerMode ) );
181    }
182    else
183    {
184        *freq = 0;
185        *tunerMode = BTNR_TunerMode_eDigital;
186    }
187
188done:
189    BDBG_LEAVE(BTNR_GetTunerRfFreq);
190    return( retCode );
191}
192
193BERR_Code BTNR_GetInfo(
194    BTNR_Handle hDev,                   /* [in] Device handle */
195    BTNR_TunerInfo *tnrInfo             /* [out] Tuner information */
196    )
197{
198    BERR_Code retCode = BERR_SUCCESS;
199
200
201    BDBG_ENTER(BTNR_GetInfo);
202    BDBG_ASSERT( hDev );
203    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
204
205    BKNI_Memset( tnrInfo, 0x00, sizeof( BTNR_TunerInfo ) );
206    if( hDev->pGetInfo != NULL )
207    {
208        CHK_RETCODE( retCode, hDev->pGetInfo( hDev->hDevImpl, tnrInfo ) );
209    }
210
211done:
212    BDBG_LEAVE(BTNR_GetInfo);
213    return( retCode );
214}
215
216BERR_Code BTNR_Close(
217    BTNR_Handle hDev                    /* [in] Device handle */
218    )
219{
220    BERR_Code retCode = BERR_SUCCESS;
221
222
223    BDBG_ENTER(BTNR_Close);
224    BDBG_ASSERT( hDev );
225    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
226
227    if( hDev->pClose != NULL )
228    {
229        CHK_RETCODE( retCode, hDev->pClose( hDev ) );
230    }
231
232done:
233    BDBG_LEAVE(BTNR_Close);
234    return( retCode );
235}
236
237BERR_Code BTNR_P_GetTunerAgcRegVal(
238    BTNR_Handle hDev,                   /* [in] Device handle */
239    uint32_t regOffset,                 /* [in] AGC register offset */
240    uint32_t *agcVal                    /* [out] output value */
241    )
242{
243    BERR_Code retCode = BERR_SUCCESS;
244
245
246    BDBG_ENTER(BTNR_P_GetTunerAgcRegVal);
247    BDBG_ASSERT( hDev );
248    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
249
250    if( hDev->pGetAgcRegVal != NULL )
251    {
252        CHK_RETCODE( retCode, hDev->pGetAgcRegVal( hDev->hDevImpl, regOffset, agcVal ) );
253    }
254    else
255    {
256        *agcVal = 0;
257        retCode = BERR_NOT_SUPPORTED;
258    }
259
260done:
261    BDBG_LEAVE(BTNR_P_GetTunerAgcRegVal);
262    return( retCode );
263}
264
265BERR_Code BTNR_SetTunerAgcRegVal(
266    BTNR_Handle hDev,                   /* [in] Device handle */
267    uint32_t regOffset,                 /* [in] AGC register offset */
268    uint32_t *agcVal                    /* [in] input value */
269    )
270{
271    BERR_Code retCode = BERR_SUCCESS;
272
273
274    BDBG_ENTER(BTNR_SetTunerAgcRegVal);
275    BDBG_ASSERT( hDev );
276    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
277
278    if( hDev->pSetAgcRegVal != NULL )
279    {
280        CHK_RETCODE( retCode, hDev->pSetAgcRegVal( hDev->hDevImpl, regOffset, agcVal ) );
281    }
282    else
283    {
284        retCode = BERR_NOT_SUPPORTED;
285    }
286
287done:
288    BDBG_LEAVE(BTNR_P_GetTunerAgcRegVal);
289    return( retCode );
290}
291
292BERR_Code BTNR_GetPowerSaver(
293    BTNR_Handle hDev,                   /* [in] Device handle */
294    BTNR_PowerSaverSettings *pwrSettings /* [out] Power saver settings. */
295    )
296{
297    BERR_Code retCode = BERR_SUCCESS;
298
299    BDBG_ENTER(BTNR_GetPowerSaver);
300    BDBG_ASSERT( hDev );
301    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
302   
303    if( hDev->pGetPowerSaver != NULL )
304    {
305        CHK_RETCODE( retCode, hDev->pGetPowerSaver( hDev->hDevImpl, pwrSettings ) );
306    }
307    else {
308        retCode = BERR_INVALID_PARAMETER;
309    }
310
311done:
312    BDBG_LEAVE(BTNR_GetPowerSaver);
313    return( retCode );
314}
315
316BERR_Code BTNR_SetPowerSaver(
317    BTNR_Handle hDev,                   /* [in] Device handle */
318    BTNR_PowerSaverSettings *pwrSettings /* [in] Power saver settings. */
319    )
320{
321    BERR_Code retCode = BERR_SUCCESS;
322
323    BDBG_ENTER(BTNR_SetPowerSaver);
324    BDBG_ASSERT( hDev );
325    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
326   
327    if( hDev->pSetPowerSaver != NULL )
328    {
329        CHK_RETCODE( retCode, hDev->pSetPowerSaver( hDev->hDevImpl, pwrSettings ) );
330    }
331    else {
332        retCode = BERR_NOT_SUPPORTED;
333    }
334
335done:
336    BDBG_LEAVE(BTNR_SetPowerSaver);
337    return( retCode );
338}
339
340BERR_Code BTNR_GetSettings(
341    BTNR_Handle hDev,           /* [in] Device handle */
342    BTNR_Settings *settings     /* [out] TNR settings. */
343    )
344{
345    BERR_Code retCode = BERR_SUCCESS;
346
347    BDBG_ENTER(BTNR_GetSettings);
348    BDBG_ASSERT( hDev );
349    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
350   
351    if( hDev->pGetSettings != NULL )
352    {
353        CHK_RETCODE( retCode, hDev->pGetSettings( hDev->hDevImpl, settings ) );
354    }
355    else {
356        retCode = BERR_INVALID_PARAMETER;
357    }
358
359done:
360    BDBG_LEAVE(BTNR_GetSettings);
361    return( retCode );
362}
363
364BERR_Code BTNR_SetSettings(
365    BTNR_Handle hDev,           /* [in] Device handle */
366    BTNR_Settings *settings     /* [in] TNR settings. */
367    )
368{
369    BERR_Code retCode = BERR_SUCCESS;
370
371    BDBG_ENTER(BTNR_SetSettings);
372    BDBG_ASSERT( hDev );
373    BDBG_ASSERT( hDev->magicId == DEV_MAGIC_ID );
374   
375    if( hDev->pSetSettings != NULL )
376    {
377        CHK_RETCODE( retCode, hDev->pSetSettings( hDev->hDevImpl, settings ) );
378    }
379    else {
380        retCode = BERR_NOT_SUPPORTED;
381    }
382
383done:
384    BDBG_LEAVE(BTNR_SetSettings);
385    return( retCode );
386}
Note: See TracBrowser for help on using the repository browser.