source: svn/newcon3bcm2_21bu/nexus/modules/frontend/common/src/nexus_frontend_card.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 10.2 KB
Line 
1/***************************************************************************
2*     (c)2004-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*  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: nexus_frontend_card.c $
39* $brcm_Revision: 6 $
40* $brcm_Date: 3/4/11 3:04p $
41*
42* API Description:
43*   API name: Frontend Card
44*    APIs to detect, open, and close removable frontend cards.
45*
46* Revision History:
47*
48* $brcm_Log: /nexus/modules/frontend/common/src/nexus_frontend_card.c $
49*
50* 6   3/4/11 3:04p jgarrett
51* SW7422-171: Adding support for 3128 daughtercard
52*
53* 5   4/11/08 9:53a erickson
54* PR41246: convert BDBG_OBJECT_UNSET to BDBG_OBJECT_DESTROY if freeing
55*  memory
56*
57* 4   4/10/08 6:08p jgarrett
58* PR 41191: Fixing uninitialized structure
59*
60* 3   3/31/08 1:13p erickson
61* PR41075: add BDBG_OBJECT
62*
63* 2   2/28/08 4:34p jgarrett
64* PR 39999: Fixing assertion for card channels
65*
66* 1   2/8/08 6:37p jgarrett
67* PR 39408: Adding daughtercard support
68*
69***************************************************************************/
70#include "nexus_frontend_module.h"
71
72BDBG_MODULE(nexus_frontend_card);
73
74BDBG_OBJECT_ID(NEXUS_FrontendCard);
75
76/***************************************************************************
77Summary:
78    Get the default settings for a frontend card
79 ***************************************************************************/
80void NEXUS_FrontendCard_GetDefaultSettings(
81    NEXUS_FrontendCardSettings *pSettings   /* [out] */
82    )
83{
84    BDBG_ASSERT(NULL != pSettings);
85    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
86    pSettings->numChannels = 1;
87}
88
89/***************************************************************************
90Summary:
91    Open a frontend card.
92
93Description:
94    This routine will probe a frontend card slot for all known card types.
95    If a recognized card is found, a valid handle will be returned.
96    Otherwise, NULL handle will be returned.
97
98See Also:
99    NEXUS_FrontendCard_Close
100 ***************************************************************************/
101NEXUS_FrontendCardHandle NEXUS_FrontendCard_Open(   /* attr{destructor=NEXUS_FrontendCard_Close} */
102    const NEXUS_FrontendCardSettings *pSettings
103    )
104{
105    NEXUS_FrontendCard *pCard;
106    bool foundCard;
107
108    BDBG_ASSERT(NULL != pSettings);
109    BDBG_ASSERT(NULL != pSettings->i2cDevice);
110    BDBG_ASSERT(pSettings->numChannels >= 1);
111
112    pCard = BKNI_Malloc(sizeof(NEXUS_FrontendCard));
113    if ( NULL == pCard )
114    {
115        BDBG_ERR(("Out of memory"));
116        return NULL;
117    }
118    BKNI_Memset(pCard, 0, sizeof(*pCard));
119    BDBG_OBJECT_SET(pCard, NEXUS_FrontendCard);
120
121    foundCard = NEXUS_Frontend_P_ProbeCard(pCard, pSettings);
122    if ( !foundCard )
123    {
124        BKNI_Free(pCard);
125        return NULL;
126    }
127
128    return pCard;
129}
130
131/***************************************************************************
132Summary:
133    Close a frontend card.
134 ***************************************************************************/
135void NEXUS_FrontendCard_Close(
136    NEXUS_FrontendCardHandle handle
137    )
138{
139    int i;
140    BDBG_OBJECT_ASSERT(handle, NEXUS_FrontendCard);
141
142    for ( i = NEXUS_MAX_FRONTEND_CHANNELS-1; i >= 0; i-- )
143    {
144        if ( handle->frontends[i] )
145        {
146            NEXUS_Frontend_Close(handle->frontends[i]);
147        }
148        if ( handle->ifds[i] )
149        {
150            NEXUS_Ifd_Close(handle->ifds[i]);
151        }
152        if ( handle->tuners[i] )
153        {
154            NEXUS_Tuner_Close(handle->tuners[i]);
155        }
156        if ( handle->amplifiers[i] )
157        {
158            NEXUS_Amplifier_Close(handle->amplifiers[i]);
159        }
160    }
161    BDBG_OBJECT_DESTROY(handle, NEXUS_FrontendCard);
162    BKNI_Free(handle);
163}
164
165/***************************************************************************
166Summary:
167    Get the number of channels present on this frontend card
168
169Description:
170    Frontend cards may have multiple channels.  This API allows the caller
171    to determine the number of channels available.
172
173See Also:
174    NEXUS_FrontendCard_GetChannel
175 ***************************************************************************/
176NEXUS_Error NEXUS_FrontendCard_GetNumChannels(
177    NEXUS_FrontendCardHandle handle,
178    unsigned *pNumChannels
179    )
180{
181    BDBG_OBJECT_ASSERT(handle, NEXUS_FrontendCard);
182    BDBG_ASSERT(NULL != pNumChannels);
183    *pNumChannels = handle->numChannels;
184    return BERR_SUCCESS;
185}
186
187/***************************************************************************
188Summary:
189    Get a frontend channel handle for this card
190
191Description:
192    Frontend cards may have multiple channels.  This API allows the caller
193    to retrieve each channel using an index.
194
195See Also:
196    NEXUS_FrontendCard_GetNumChannels
197 ***************************************************************************/
198NEXUS_FrontendHandle NEXUS_FrontendCard_GetChannel(
199    NEXUS_FrontendCardHandle handle,
200    unsigned index
201    )
202{
203    BDBG_OBJECT_ASSERT(handle, NEXUS_FrontendCard);
204
205    if ( index >= NEXUS_MAX_FRONTEND_CHANNELS )
206    {
207        BDBG_ERR(("Index out of range"));
208        return NULL;
209    }
210
211    return handle->frontends[index];
212}
213/***************************************************************************
214Summary:
215    Get the number of out of band channels present on this frontend card
216
217Description:
218    Frontend cards may have multiple out of band channels.  This API allows the caller
219    to determine the number of out of band channels available.
220
221See Also:
222    NEXUS_FrontendCard_GetChannel
223 ***************************************************************************/
224NEXUS_Error NEXUS_FrontendCard_GetNumOutOfBandChannels(
225    NEXUS_FrontendCardHandle handle,
226    unsigned *pNumOutOfBandChannels
227    )
228{
229    BDBG_OBJECT_ASSERT(handle, NEXUS_FrontendCard);
230    BDBG_ASSERT(NULL != pNumOutOfBandChannels);
231    *pNumOutOfBandChannels = handle->numOutOfBandChannels;
232    return BERR_SUCCESS;
233}
234
235/***************************************************************************
236Summary:
237    Get a frontend out of band channel handle for this card
238
239Description:
240    Frontend cards may have multiple  out of band channels.  This API allows the caller
241    to retrieve each out of band  channel using an index.
242
243See Also:
244    NEXUS_FrontendCard_GetNumChannels
245 ***************************************************************************/
246NEXUS_FrontendHandle NEXUS_FrontendCard_GetOutOfBandChannel(
247    NEXUS_FrontendCardHandle handle,
248    unsigned index
249    )
250{
251    BDBG_OBJECT_ASSERT(handle, NEXUS_FrontendCard);
252
253    if ( index >= NEXUS_MAX_FRONTEND_OOB_CHANNELS )
254    {
255        BDBG_ERR(("Index out of range"));
256        return NULL;
257    }
258
259    return handle->outOfBandFrontends[index];
260}
261
262/***************************************************************************
263Summary:
264    Get the number of upstream channels present on this frontend card
265
266Description:
267    Frontend cards may have upstream multiple channels.  This API allows the caller
268    to determine the number of upstream channels available.
269
270See Also:
271    NEXUS_FrontendCard_GetChannel
272 ***************************************************************************/
273NEXUS_Error NEXUS_FrontendCard_GetNumUpstreamChannels(
274    NEXUS_FrontendCardHandle handle,
275    unsigned *pNumUpstreamChannels
276    )
277{
278    BDBG_OBJECT_ASSERT(handle, NEXUS_FrontendCard);
279    BDBG_ASSERT(NULL != pNumUpstreamChannels);
280    *pNumUpstreamChannels = handle->numUpstreamChannels;
281    return BERR_SUCCESS;
282}
283
284/***************************************************************************
285Summary:
286    Get a frontend upstream channel handle for this card
287
288Description:
289    Frontend cards may have multiple upstream channels.  This API allows the caller
290    to retrieve each upstream channel using an index.
291
292See Also:
293    NEXUS_FrontendCard_GetNumChannels
294 ***************************************************************************/
295NEXUS_FrontendHandle NEXUS_FrontendCard_GetUpstreamChannel(
296    NEXUS_FrontendCardHandle handle,
297    unsigned index
298    )
299{
300    BDBG_OBJECT_ASSERT(handle, NEXUS_FrontendCard);
301
302    if ( index >= NEXUS_MAX_FRONTEND_AUS_CHANNELS )
303    {
304        BDBG_ERR(("Index out of range"));
305        return NULL;
306    }
307
308    return handle->upstreamFrontends[index];
309}
310
311
Note: See TracBrowser for help on using the repository browser.