source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/thd/bthd.c @ 54

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

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 20.2 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2005-2012, 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: bthd.c $
11 * $brcm_Revision: Hydra_Software_Devel/21 $
12 * $brcm_Date: 2/2/12 6:23p $
13 *
14 * [File Description:]
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/thd/bthd.c $
19 *
20 * Hydra_Software_Devel/21   2/2/12 6:23p atanugul
21 * SW3461-141: Implement new apis for SetAcquireParams, GetAcquireParams
22 * and PowerUp
23 *
24 * Hydra_Software_Devel/20   11/16/11 12:06p atanugul
25 * SW3461-79: Add No Signal to GetThdLockStatus()
26 *
27 * Hydra_Software_Devel/19   6/1/11 3:39p atanugul
28 * SW3461-5: Add THD support to 3461
29 *
30 * Hydra_Software_Devel/18   4/27/11 12:14p farshidf
31 * SWDTV-6190: add the Nexus BBS interface
32 *
33 * Hydra_Software_Devel/17   5/18/10 3:51p farshidf
34 * SW7550-440: add GetThdLockStatus
35 *
36 * Hydra_Software_Devel/SW7550-399/1   5/6/10 6:15p farshidf
37 * SW7550-399: add the mini tune while we are lock
38 *
39 * Hydra_Software_Devel/16   11/6/09 5:53p farshidf
40 * SW7550-38: match Nexus changes
41 *
42 * Hydra_Software_Devel/15   11/5/09 3:32p farshidf
43 * SW7550-38: compile issue
44 *
45 * Hydra_Software_Devel/14   11/5/09 2:09p farshidf
46 * SW7550-38: add the API changes for 7550
47 * PR41450: move down the timer settings
48 * PR41450: remove Dynamic settings
49 * PR41450: add the update Aquire param settings
50 * PR57150: Implement THD under Nexus without the AP
51 *
52 * Hydra_Software_Devel/PR57150/5   11/5/09 2:06p farshidf
53 * SW7550-38: add the API changes for 7550
54 *
55 * Hydra_Software_Devel/PR57150/4   11/1/09 2:13p farshidf
56 * PR41450: move down the timer settings
57 *
58 * Hydra_Software_Devel/PR57150/3   10/8/09 6:13p farshidf
59 * PR41450: remove Dynamic settings
60 *
61 * Hydra_Software_Devel/PR57150/2   9/30/09 3:30p farshidf
62 * PR41450: add the update Aquire param settings
63 *
64 * Hydra_Software_Devel/PR57150/1   7/28/09 2:14p farshidf
65 * PR57150: Implement THD under Nexus without the AP
66 *
67 * Hydra_Software_Devel/13   9/29/08 9:52a dliu
68 * PR46539: Add dynamic power management
69 *
70 * Hydra_Software_Devel/12   8/13/08 5:04p dliu
71 * PR38944: Change SetIfdAudioSettings to pass in const pointer
72 *
73 * Hydra_Software_Devel/11   8/8/08 2:54p dliu
74 * PR38944: Change SetIfdAudioSettings function to use pointers
75 *
76 * Hydra_Software_Devel/10   8/6/08 4:54p dliu
77 * PR38944: Add extran functions and parameters for AASD
78 *
79 * Hydra_Software_Devel/9   7/30/08 2:31p dliu
80 * PR45192: Change function name
81 *
82 * Hydra_Software_Devel/8   7/28/08 4:01p dliu
83 * PR45192: Add GetDefault function to api list
84 *
85 * Hydra_Software_Devel/7   6/24/08 3:25p dliu
86 * PR38944: Change parameters for GetSoftDecisionBuf to signed values
87 *
88 * Hydra_Software_Devel/6   5/31/08 12:23p dliu
89 * PR38934: Change argument of GetSoftDecisionBuffer to uint_16
90 *
91 * Hydra_Software_Devel/5   5/15/08 12:34p dliu
92 * PR38934: Add IFD Status function and GetSoftDecisionBuf function
93 *
94 * Hydra_Software_Devel/4   2/27/08 10:10a dliu
95 * PR36603: Add function to get lockchange event handle
96 *
97 * Hydra_Software_Devel/3   11/6/07 5:36p dliu
98 * PR36603: Add GetVersion function
99 *
100 * Hydra_Software_Devel/2   11/5/07 3:43p dliu
101 * PR36603: Change file header
102 *
103 * Hydra_Software_Devel/1   11/5/07 3:40p dliu
104 * PR36603: Initial version
105 *
106 ***************************************************************************/
107#include "bstd.h"
108#include "bthd.h"
109#include "bthd_priv.h"
110
111BDBG_MODULE(bTHD);
112
113/******************************************************************************
114 BTHD_Open()
115******************************************************************************/
116BERR_Code BTHD_Open(
117   BTHD_Handle *h,         /* [out] BTHD handle */
118   BCHP_Handle hChip,      /* [in] chip handle */
119   void        *pReg,      /* [in] pointer to register or i2c handle */
120   BINT_Handle hInterrupt, /* [in] Interrupt handle */   
121   const BTHD_Settings *pDefSettings /* [in] default settings */
122)
123{ 
124   BDBG_ASSERT(h);
125   BDBG_ASSERT(pReg);
126   BDBG_ASSERT(pDefSettings);
127   
128   return (pDefSettings->api.Open(h, hChip, pReg, hInterrupt, pDefSettings));
129}
130
131
132/******************************************************************************
133 BTHD_Close()
134******************************************************************************/
135BERR_Code BTHD_Close(
136   BTHD_Handle h   /* [in] BTHD handle */
137)
138{
139   BDBG_ASSERT(h);
140   return (h->settings.api.Close(h));
141}
142
143                                                                                   
144/******************************************************************************
145 BTHD_Init()
146******************************************************************************/
147BERR_Code BTHD_Init(
148   BTHD_Handle h,         /* [in] BTHD handle */
149   const uint8_t *pImage, /* [in] pointer to the microcode image. Set to NULL to use default image */
150   uint32_t imageLength   /* [in] length of microcode image. Set to 0 when using default image */
151)
152{
153   BDBG_ASSERT(h);
154   return (h->settings.api.Init(h, pImage, imageLength));
155}
156
157/******************************************************************************
158 BTHD_ReadRegister()
159******************************************************************************/
160BERR_Code BTHD_ReadRegister(
161   BTHD_Handle h,    /* [in] BTHD handle */
162   uint32_t    reg,  /* [in] address of register to read */
163   uint32_t    *val  /* [in] contains data that was read */
164)
165{
166   BDBG_ASSERT(h);
167   return (h->settings.api.ReadRegister(h, reg, val));
168}
169
170
171/******************************************************************************
172 BTHD_WriteRegister()
173******************************************************************************/
174BERR_Code BTHD_WriteRegister(
175   BTHD_Handle h,    /* [in] BTHD handle */
176   uint32_t    reg,  /* [in] address of register to read */
177   uint32_t    *val  /* [in] contains data that was read */
178)
179{
180   BDBG_ASSERT(h);
181   return (h->settings.api.WriteRegister(h, reg, val));
182}
183
184
185/******************************************************************************
186 BTHD_Mi2cWrite()
187******************************************************************************/ 
188BERR_Code BTHD_Mi2cWrite(
189   BTHD_Handle h,      /* [in] BTHD handle */
190   uint8_t slave_addr, /* [in] address of the i2c slave device */
191   uint8_t *buf,       /* [in] specifies the data to transmit */
192   uint8_t n           /* [in] number of bytes to transmit after the i2c slave address */
193)
194{
195   BDBG_ASSERT(h);
196   if (h->settings.api.Mi2cWrite)
197      return (h->settings.api.Mi2cWrite(h, slave_addr, buf, n));
198   else
199      return BERR_NOT_SUPPORTED;
200}
201
202
203/******************************************************************************
204 BTHD_Mi2cRead()
205******************************************************************************/ 
206BERR_Code BTHD_Mi2cRead(
207   BTHD_Handle h,      /* [in] BTHD handle */
208   uint8_t slave_addr, /* [in] address of the i2c slave device */
209   uint8_t *out_buf,   /* [in] specifies the data to transmit before the i2c restart condition */
210   uint8_t out_n,      /* [in] number of bytes to transmit before the i2c restart condition not including the i2c slave address */
211   uint8_t *in_buf,    /* [out] holds the data read */
212   uint8_t in_n        /* [in] number of bytes to read after the i2c restart condition not including the i2c slave address */
213)
214{
215   BDBG_ASSERT(h);
216   if (h->settings.api.Mi2cRead)
217      return (h->settings.api.Mi2cRead(h, slave_addr, out_buf, out_n, in_buf, in_n));
218   else
219      return BERR_NOT_SUPPORTED; 
220}
221
222/******************************************************************************
223 BTHD_AcquireIfd()
224******************************************************************************/
225BERR_Code BTHD_AcquireIfd(
226        BTHD_Handle h,                                  /* [in] BTHD handle */
227        const BTHD_IfdParams *pParams   /* [in] IFD acqusition parameters */
228        )
229{
230        BDBG_ASSERT(h);
231        return (h->settings.api.AcquireIfd(h, pParams));
232}
233
234/******************************************************************************
235 BTHD_GetIfdStatus()
236******************************************************************************/
237BERR_Code BTHD_GetIfdStatus(
238        BTHD_Handle h,                  /* [in] BTHD handle */
239        BTHD_IfdStatus *pIfdStatus              /* [out] IFD Status structure */
240        )
241{
242        BDBG_ASSERT(h);
243        return (h->settings.api.GetIfdStatus(h, pIfdStatus));
244}
245
246/******************************************************************************
247 BTHD_SetAcquireParams()
248******************************************************************************/
249BERR_Code BTHD_SetAcquireParams(
250   BTHD_Handle h,      /* [in] BTHD handle */
251   const BTHD_InbandParams *pParams  /* [in] inband acquisition parameters */
252)
253{   
254   BDBG_ASSERT(h);
255   return (h->settings.api.SetAcquireParams(h, pParams));
256}
257
258/******************************************************************************
259 BTHD_GetAcquireParams()
260******************************************************************************/
261BERR_Code BTHD_GetAcquireParams(
262   BTHD_Handle h,      /* [in] BTHD handle */
263   BTHD_InbandParams *pParams  /* [out] inband acquisition parameters */ 
264)
265{   
266   BDBG_ASSERT(h);
267   return (h->settings.api.GetAcquireParams(h, pParams));
268}
269
270/******************************************************************************
271 BTHD_TuneAcquire()
272******************************************************************************/
273BERR_Code BTHD_TuneAcquire(
274   BTHD_Handle h,                    /* [in] BTHD handle */
275   const BTHD_InbandParams *pParams  /* [in] inband acquisition parameters */
276)
277{   
278   BDBG_ASSERT(h);
279   return (h->settings.api.TuneAcquire(h, pParams));
280}
281
282/******************************************************************************
283 BTHD_RequestThdAsyncStatus()
284******************************************************************************/
285BERR_Code BTHD_RequestThdAsyncStatus(
286   BTHD_Handle h /* [in] BTHD handle */
287)
288{
289   BDBG_ASSERT(h);
290   return (h->settings.api.RequestThdAsyncStatus(h));
291}
292
293/******************************************************************************
294 BTHD_GetThdAsyncStatus()
295******************************************************************************/
296BERR_Code BTHD_GetThdAsyncStatus(
297   BTHD_Handle h,           /* [in] BTHD handle */
298   BTHD_THDStatus *pStatus  /* [out] THD status */
299)
300{
301   BDBG_ASSERT(h);
302   return (h->settings.api.GetThdAsyncStatus(h, pStatus));
303}
304
305/******************************************************************************
306 BTHD_GetThdStatus()
307******************************************************************************/
308BERR_Code BTHD_GetThdStatus(
309   BTHD_Handle h,           /* [in] BTHD handle */
310   BTHD_THDStatus *pStatus  /* [out] THD status */
311)
312{
313   BDBG_ASSERT(h);
314   return (h->settings.api.GetThdStatus(h, pStatus));
315}
316
317/******************************************************************************
318 BTHD_ResetInbandStatus()
319******************************************************************************/
320BERR_Code BTHD_ResetInbandStatus(
321   BTHD_Handle h /* [in] BTHD handle */
322)
323{
324   BDBG_ASSERT(h);
325   return (h->settings.api.ResetInbandStatus(h));
326}
327
328/******************************************************************************
329 BTHD_GetInterruptEventHandle()
330******************************************************************************/
331BERR_Code BTHD_GetInterruptEventHandle(
332   BTHD_Handle h,            /* [in] BTHD handle */
333   BKNI_EventHandle *hEvent  /* [out] interrupt event handle */
334)
335{
336   BDBG_ASSERT(h);
337   if (h->settings.api.GetInterruptEventHandle)
338      return (h->settings.api.GetInterruptEventHandle(h, hEvent));
339   else
340      return BERR_NOT_SUPPORTED;           
341}
342
343
344/******************************************************************************
345 BTHD_GetInterruptEventHandle()
346******************************************************************************/
347BERR_Code BTHD_GetBBSInterruptEventHandle(
348   BTHD_Handle h,            /* [in] BTHD handle */
349   BKNI_EventHandle *hEvent  /* [out] interrupt event handle */
350)
351{
352   BDBG_ASSERT(h);
353   if (h->settings.api.GetBBSInterruptEventHandle)
354      return (h->settings.api.GetBBSInterruptEventHandle(h, hEvent));
355   else
356      return BERR_NOT_SUPPORTED;           
357}
358
359/******************************************************************************
360 BTHD_HandleInterrupt_isr()
361******************************************************************************/
362BERR_Code BTHD_HandleInterrupt_isr(
363   BTHD_Handle h /* [in] BTHD handle */
364)
365{
366   BDBG_ASSERT(h);
367   return (h->settings.api.HandleInterrupt_isr(h));
368}
369
370/******************************************************************************
371 BTHD_ProcessInterruptEvent()
372******************************************************************************/
373BERR_Code BTHD_ProcessInterruptEvent(
374   BTHD_Handle h  /* [in] BTHD handle */
375)
376{
377   BDBG_ASSERT(h);
378   return (h->settings.api.ProcessInterruptEvent(h));
379}
380
381
382/******************************************************************************
383 BTHD_ProcessInterruptEvent()
384******************************************************************************/
385BERR_Code BTHD_ProcessBBSInterruptEvent(
386   BTHD_Handle h  /* [in] BTHD handle */
387)
388{
389   BDBG_ASSERT(h);
390   return (h->settings.api.ProcessBBSInterruptEvent(h));
391}
392
393
394/******************************************************************************
395 BTHD_GetSettings()
396******************************************************************************/
397BERR_Code BTHD_GetSettings(
398   BTHD_Handle h,           /* [in] BTHD handle */
399   BTHD_Settings *pSettings /* [out] current BTHD settings */
400)
401{
402   BDBG_ASSERT(pSettings);
403   BKNI_Memcpy((void*)pSettings, (void*)&(h->settings), sizeof(BTHD_Settings));
404   return BERR_SUCCESS;
405}
406
407
408/******************************************************************************
409   BTHD_SetSettings()
410******************************************************************************/
411BERR_Code BTHD_SetSettings(
412   BTHD_Handle h,           /* [in] BTHD handle */
413   BTHD_Settings *pSettings /* [in] new BTHD settings */
414)
415{
416   BDBG_ASSERT(pSettings);
417   BKNI_Memcpy((void*)&(h->settings), (void*)pSettings, sizeof(BTHD_Settings));
418   return BERR_SUCCESS;
419}
420
421/******************************************************************************
422 BTHD_GetChipRevision
423******************************************************************************/
424BERR_Code BTHD_GetChipRevision(
425   BTHD_Handle h,           /* [in] BTHD handle */
426   uint8_t *revision        /* [out] chip revision*/
427)
428{
429   BDBG_ASSERT(h);
430   return (h->settings.api.GetChipRevision(h, revision));
431}
432
433/******************************************************************************
434 BTHD_GetVersion
435******************************************************************************/
436BERR_Code BTHD_GetVersion(
437   BTHD_Handle h,           /* [in] BTHD handle */
438   uint32_t *revision,      /* [out] firmware revision */
439   uint32_t *checksum       /* [out] firmware checksum */
440)
441{
442   BDBG_ASSERT(h);
443   return (h->settings.api.GetVersion(h, revision, checksum));
444}
445
446/******************************************************************************
447 BTHD_GetLockStateChangeEventHandle()
448******************************************************************************/
449BERR_Code BTHD_GetLockStateChangeEventHandle(
450   BTHD_Handle h,            /* [in] BTHD handle */
451   BKNI_EventHandle *hEvent  /* [out] lock event handle */
452)
453{
454   BDBG_ASSERT(h);
455   return (h->settings.api.GetLockStateChangeEventHandle(h, hEvent));
456}
457/******************************************************************************
458 BTHD_GetSoftDecisionBuf()
459******************************************************************************/
460BERR_Code BTHD_GetSoftDecisionBuf(
461   BTHD_Handle h,  /* [in] BTHD handle */
462   int16_t *pI,    /* [out] 30 I-values */
463   int16_t *pQ     /* [out] 30 Q-values */
464)
465{
466        BDBG_ASSERT(h);
467        return (h->settings.api.GetSoftDecisionBuf(h, pI, pQ));
468}
469
470/******************************************************************************
471 BTHD_GetDefaultInbandParam()
472******************************************************************************/
473BERR_Code BTHD_GetDefaultInbandParams(
474    BTHD_Handle h,            /* [in] BTHD handle */         
475    BTHD_InbandParams* pDefInbandParam /* [out] default param */
476)
477{
478    return (h->settings.api.GetDefaultInbandParams(pDefInbandParam));
479}
480
481/******************************************************************************
482 BTHD_GetDefaultIfdParam()
483******************************************************************************/
484BERR_Code BTHD_GetDefaultIfdParams(
485    BTHD_Handle h,            /* [in] BTHD handle */         
486    BTHD_IfdParams* pDefIfdParam /* [out] default param */
487)
488{
489    return (h->settings.api.GetDefaultIfdParams(pDefIfdParam));
490}
491
492/******************************************************************************
493 BTHD_ResetInbandStatus()
494******************************************************************************/
495BERR_Code BTHD_ResetIfdStatus(
496   BTHD_Handle h /* [in] BTHD handle */
497)
498{
499   BDBG_ASSERT(h);
500   return (h->settings.api.ResetIfdStatus(h));
501}
502
503/******************************************************************************
504 BTHD_GetIfdAudioSettings()
505******************************************************************************/
506BERR_Code BTHD_GetIfdAudioSettings(
507    BTHD_Handle h,                          /* [in] BTHD handle */
508    BTHD_IfdAudioSettings* audioSettings    /* [out] Audio settings structure */
509)
510{
511    BDBG_ASSERT(h);
512    return (h->settings.api.GetIfdAudioSettings(h, audioSettings));
513}
514
515/******************************************************************************
516 BTHD_GetIfdAudioSettings()
517******************************************************************************/
518BERR_Code BTHD_SetIfdAudioSettings(
519    BTHD_Handle h,                         /* [in] BTHD handle */
520    const BTHD_IfdAudioSettings* audioSettings    /* [in] Audio settings structure */
521)
522{
523    BDBG_ASSERT(h);
524    return (h->settings.api.SetIfdAudioSettings(h, audioSettings));
525}
526
527/******************************************************************************
528 BTHD_PowerEnable()
529******************************************************************************/
530BERR_Code BTHD_PowerUp(
531    BTHD_Handle h                         /* [in] BTHD handle */
532)
533{
534    BDBG_ASSERT(h);
535    return (h->settings.api.PowerUp(h));
536}
537
538/******************************************************************************
539 BTHD_PowerDisable()
540******************************************************************************/
541BERR_Code BTHD_PowerDown(
542    BTHD_Handle h                         /* [in] BTHD handle */
543)
544{
545    BDBG_ASSERT(h);
546    return (h->settings.api.PowerDown(h));
547}
548
549/******************************************************************************
550 BTHD_GetEWSEventHandle()
551******************************************************************************/
552BERR_Code BTHD_GetEWSEventHandle(
553   BTHD_Handle h,            /* [in] BTHD handle */
554   BKNI_EventHandle *hEvent  /* [out] lock event handle */
555)
556{
557   BDBG_ASSERT(h);
558   return (h->settings.api.GetEWSEventHandle(h, hEvent));
559}
560
561/******************************************************************************
562 BTHD_GetThdLockStatus()
563******************************************************************************/
564BERR_Code BTHD_GetThdLockStatus(
565   BTHD_Handle h,            /* [in] BTHD handle */
566   BTHD_LockStatus *pLockStatus  /* [out] THD status */
567)
568{
569   BDBG_ASSERT(h);
570   return (h->settings.api.GetThdLockStatus(h, pLockStatus));
571}
572
573/******************************************************************************
574 BTHD_InstallCallback()
575******************************************************************************/
576BERR_Code BTHD_InstallCallback(
577    BTHD_Handle h,                      /* [in] Device channel handle */
578    BTHD_Callback callbackType,         /* [in] Type of callback */
579    BTHD_CallbackFunc pCallback,        /* [in] Function Ptr to callback */
580    void *pParam                        /* [in] Generic parameter send on callback */
581    )
582{
583    BERR_Code retCode = BERR_SUCCESS;
584
585
586    BDBG_ENTER(BTHD_InstallCallback);
587    BDBG_ASSERT( h );
588   
589    if( h->settings.api.InstallCallback != NULL )
590    {
591        retCode = h->settings.api.InstallCallback( h, callbackType, pCallback, pParam );
592    }
593    else
594    {
595        BDBG_WRN(("BTHD_InstallCallback: Funtion Ptr is NULL"));
596    }
597
598    BDBG_LEAVE(BTHD_InstallCallback);
599    return( retCode );
600}
Note: See TracBrowser for help on using the repository browser.