source: svn/newcon3bcm2_21bu/nexus/modules/audio/7552/src/nexus_spdif_input.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: 9.3 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_spdif_input.c $
39* $brcm_Revision: 1 $
40* $brcm_Date: 8/18/11 5:51p $
41*
42* API Description:
43*   API name: SpdifInput
44*    Specific APIs related to SPDIF Input
45*
46* Revision History:
47*
48* $brcm_Log: /nexus/modules/audio/7422/src/nexus_spdif_input.c $
49*
50* 1   8/18/11 5:51p jgarrett
51* SWDTV-6306: Merge DTV APE changes to main branch
52*
53* Nexus_APE_Integration/2   8/11/11 6:25p jgarrett
54* SWDTV-6306: Adding SPDIF Input
55*
56* Nexus_APE_Integration/1   7/1/11 5:50p jgarrett
57* SWDTV-6306: Integrated to latest 7422 baseline and nexus audio
58*  directory structure
59*
60* 1   5/5/11 11:44a jgarrett
61* SW7425-354: Adding 35230 stubs
62*
63***************************************************************************/
64#include "nexus_audio_module.h"
65
66BDBG_MODULE(nexus_spdif_input);
67
68#if NEXUS_NUM_SPDIF_INPUTS
69
70BDBG_OBJECT_ID(NEXUS_SpdifInput);
71typedef struct NEXUS_SpdifInput
72{
73    BDBG_OBJECT(NEXUS_SpdifInput)
74    NEXUS_AudioInputObject connector;
75    BAPE_SpdifInputHandle apeHandle;
76    NEXUS_SpdifInputSettings settings;
77    bool opened;
78} NEXUS_SpdifInput;
79
80static NEXUS_SpdifInput g_spdifInputs[NEXUS_NUM_SPDIF_INPUTS];
81
82void NEXUS_SpdifInput_GetDefaultSettings(
83    NEXUS_SpdifInputSettings *pSettings   /* [out] default settings */
84    )
85{
86    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
87}
88
89NEXUS_SpdifInputHandle NEXUS_SpdifInput_Open(  /* attr{destructor=NEXUS_SpdifInput_Close}  */
90    unsigned index,
91    const NEXUS_SpdifInputSettings *pSettings
92    )
93{
94    NEXUS_SpdifInputSettings defaults;
95    BAPE_SpdifInputSettings apeSettings;
96    NEXUS_SpdifInputHandle handle;
97    BAPE_InputPort inputPort;
98    BERR_Code errCode;
99   
100    if ( index >= NEXUS_NUM_SPDIF_INPUTS )
101    {
102        BDBG_ERR(("SPDIF Input %u not supported", index));
103        (void)BERR_TRACE(BERR_NOT_SUPPORTED);
104        return NULL;
105    }
106
107    if ( g_spdifInputs[index].opened )
108    {
109        BDBG_ERR(("SPDIF Input %u already opened.", index));
110        (void)BERR_TRACE(BERR_INVALID_PARAMETER);
111        return NULL;
112    }
113    handle = &g_spdifInputs[index];   
114   
115    if ( NULL == pSettings )
116    {
117        NEXUS_SpdifInput_GetDefaultSettings(&defaults);
118        pSettings = &defaults;
119    }
120           
121    BKNI_Memset(handle, 0, sizeof(NEXUS_SpdifInput));
122    BDBG_OBJECT_SET(handle, NEXUS_SpdifInput);
123    NEXUS_AUDIO_INPUT_INIT(&handle->connector, NEXUS_AudioInputType_eSpdif, handle);
124    handle->opened = true;
125   
126    BAPE_SpdifInput_GetDefaultSettings(&apeSettings);
127    errCode = BAPE_SpdifInput_Open(NEXUS_AUDIO_DEVICE_HANDLE, index, &apeSettings, &handle->apeHandle);
128    if ( errCode )
129    {
130        errCode = BERR_TRACE(errCode);
131        goto err_ape_open;
132    }
133   
134    BAPE_SpdifInput_GetInputPort(handle->apeHandle, &inputPort);
135    handle->connector.inputPort = (uint32_t)inputPort;
136
137    errCode = NEXUS_SpdifInput_SetSettings(handle, pSettings);
138    if ( errCode )
139    {
140        errCode = BERR_TRACE(errCode);
141        goto err_settings;
142    }
143       
144    return handle;
145   
146err_settings:
147    BAPE_SpdifInput_Close(handle->apeHandle);   
148err_ape_open:
149    BKNI_Memset(handle, 0, sizeof(NEXUS_SpdifInput));
150    return NULL;
151}
152
153void NEXUS_SpdifInput_Close(
154    NEXUS_SpdifInputHandle handle
155    )
156{
157    BDBG_OBJECT_ASSERT(handle, NEXUS_SpdifInput);
158    BAPE_SpdifInput_Close(handle->apeHandle);
159    BKNI_Memset(handle, 0, sizeof(NEXUS_SpdifInput));
160}
161
162void NEXUS_SpdifInput_GetSettings(
163    NEXUS_SpdifInputHandle handle,
164    NEXUS_SpdifInputSettings *pSettings    /* [out] Settings */
165    )
166{
167    BDBG_OBJECT_ASSERT(handle, NEXUS_SpdifInput);
168    BDBG_ASSERT(NULL != pSettings);
169    *pSettings = handle->settings;
170}
171
172NEXUS_Error NEXUS_SpdifInput_SetSettings(
173    NEXUS_SpdifInputHandle handle,
174    const NEXUS_SpdifInputSettings *pSettings
175    )
176{
177    BDBG_OBJECT_ASSERT(handle, NEXUS_SpdifInput);
178    BDBG_ASSERT(NULL != pSettings);
179    handle->settings = *pSettings;
180    /* Currently, these settings do not map to APE */
181    return BERR_SUCCESS;
182}
183
184NEXUS_AudioInput NEXUS_SpdifInput_GetConnector( /* attr{shutdown=NEXUS_AudioInput_Shutdown} */
185    NEXUS_SpdifInputHandle handle
186    )
187{
188    BDBG_OBJECT_ASSERT(handle, NEXUS_SpdifInput);
189    return &handle->connector;
190}
191
192NEXUS_Error NEXUS_SpdifInput_P_SetFormatChangeInterrupt(
193    NEXUS_SpdifInputHandle handle,
194    void (*pCallback_isr)(void *, int),
195    void *pParam1,
196    int param2
197    )
198{
199    BERR_Code errCode;
200    BAPE_SpdifInputFormatDetectionSettings detectionSettings;
201   
202    BDBG_OBJECT_ASSERT(handle, NEXUS_SpdifInput);
203   
204    BAPE_SpdifInput_GetFormatDetectionSettings(handle->apeHandle, &detectionSettings);
205    detectionSettings.enabled = (pCallback_isr != NULL) ? true : false;
206    detectionSettings.formatChangeInterrupt.pCallback_isr = pCallback_isr;
207    detectionSettings.formatChangeInterrupt.pParam1 = pParam1;
208    detectionSettings.formatChangeInterrupt.param2 = param2;
209    errCode = BAPE_SpdifInput_SetFormatDetectionSettings(handle->apeHandle, &detectionSettings);
210    if ( errCode )
211    {
212        return BERR_TRACE(errCode);
213    }
214   
215    return BERR_SUCCESS;
216}       
217
218NEXUS_Error NEXUS_SpdifInput_P_GetInputPortStatus(
219    NEXUS_SpdifInputHandle handle,
220    NEXUS_AudioInputPortStatus *pStatus     /* [out] */
221    )
222{
223    BERR_Code errCode;
224    BAPE_SpdifInputFormatDetectionStatus detectionStatus;
225   
226    BDBG_OBJECT_ASSERT(handle, NEXUS_SpdifInput);
227    BDBG_ASSERT(NULL != pStatus);
228   
229    BKNI_Memset(pStatus, 0, sizeof(NEXUS_AudioInputPortStatus));
230    errCode = BAPE_SpdifInput_GetFormatDetectionStatus(handle->apeHandle, &detectionStatus);
231    if ( errCode )
232    {
233        return BERR_TRACE(errCode);
234    }
235    pStatus->signalPresent = detectionStatus.signalPresent;
236    pStatus->compressed = detectionStatus.compressed;
237    pStatus->codec = NEXUS_Audio_P_MagnumToCodec(detectionStatus.preambleC.codec);
238    pStatus->sampleRate = detectionStatus.sampleRate;
239    pStatus->numPcmChannels = 2;
240    return BERR_SUCCESS;
241}
242
243#else
244
245void NEXUS_SpdifInput_GetDefaultSettings(
246    NEXUS_SpdifInputSettings *pSettings   /* [out] default settings */
247    )
248{
249    BSTD_UNUSED(pSettings);
250}
251
252NEXUS_SpdifInputHandle NEXUS_SpdifInput_Open(  /* attr{destructor=NEXUS_SpdifInput_Close}  */
253    unsigned index,
254    const NEXUS_SpdifInputSettings *pSettings
255    )
256{
257    BSTD_UNUSED(index);
258    BSTD_UNUSED(pSettings);
259    (void)BERR_TRACE(BERR_NOT_SUPPORTED);
260    return NULL;
261}
262
263void NEXUS_SpdifInput_Close(
264    NEXUS_SpdifInputHandle handle
265    )
266{
267    BSTD_UNUSED(handle);
268}
269
270void NEXUS_SpdifInput_GetSettings(
271    NEXUS_SpdifInputHandle handle,
272    NEXUS_SpdifInputSettings *pSettings    /* [out] Settings */
273    )
274{
275    BSTD_UNUSED(handle);
276    BSTD_UNUSED(pSettings);
277}
278
279NEXUS_Error NEXUS_SpdifInput_SetSettings(
280    NEXUS_SpdifInputHandle handle,
281    const NEXUS_SpdifInputSettings *pSettings
282    )
283{
284    BSTD_UNUSED(handle);
285    BSTD_UNUSED(pSettings);
286    return BERR_TRACE(BERR_NOT_SUPPORTED);
287}
288
289NEXUS_AudioInput NEXUS_SpdifInput_GetConnector( /* attr{shutdown=NEXUS_AudioInput_Shutdown} */
290    NEXUS_SpdifInputHandle handle
291    )
292{
293    BSTD_UNUSED(handle);
294    return NULL;
295}
296
297#endif
Note: See TracBrowser for help on using the repository browser.