source: svn/newcon3bcm2_21bu/nexus/modules/audio/7552/src/nexus_dolby_volume.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: 11.4 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_dolby_volume.c $
39* $brcm_Revision: 2 $
40* $brcm_Date: 5/25/11 5:16p $
41*
42* API Description:
43*   API name: DolbyVolume
44*    Specific APIs related to Dolby Volume Audio Processing
45*
46* Revision History:
47*
48* $brcm_Log: /nexus/modules/audio/7422/src/nexus_dolby_volume.c $
49*
50* 2   5/25/11 5:16p jgarrett
51* SW7425-408: Adding BDBG_OBJECT to input/output types and MS11 features
52*
53* 1   1/10/11 3:26p jgarrett
54* SW7422-146: Adding full nexus API set
55*
56***************************************************************************/
57
58#include "nexus_audio_module.h"
59
60BDBG_MODULE(nexus_dolby_volume);
61
62void NEXUS_DolbyVolume_GetDefaultSettings(
63    NEXUS_DolbyVolumeSettings *pSettings   /* [out] default settings */
64    )
65{
66    BSTD_UNUSED(pSettings);
67}
68
69NEXUS_DolbyVolumeHandle NEXUS_DolbyVolume_Open(
70    const NEXUS_DolbyVolumeSettings *pSettings     /* Pass NULL for default settings */
71    )
72{
73    BSTD_UNUSED(pSettings);
74    (void)BERR_TRACE(BERR_NOT_SUPPORTED);
75    return NULL;
76}
77
78void NEXUS_DolbyVolume_Close(
79    NEXUS_DolbyVolumeHandle handle
80    )
81{
82    BSTD_UNUSED(handle);
83}
84
85void NEXUS_DolbyVolume_GetSettings(
86    NEXUS_DolbyVolumeHandle handle,
87    NEXUS_DolbyVolumeSettings *pSettings    /* [out] Settings */
88    )
89{
90    BSTD_UNUSED(handle);
91    BSTD_UNUSED(pSettings);
92}
93
94NEXUS_Error NEXUS_DolbyVolume_SetSettings(
95    NEXUS_DolbyVolumeHandle handle,
96    const NEXUS_DolbyVolumeSettings *pSettings
97    )
98{
99    BSTD_UNUSED(handle);
100    BSTD_UNUSED(pSettings);
101    return BERR_TRACE(BERR_NOT_SUPPORTED);
102}
103
104NEXUS_AudioInput NEXUS_DolbyVolume_GetConnector(
105    NEXUS_DolbyVolumeHandle handle
106    )
107{
108    BSTD_UNUSED(handle);
109    return NULL;
110}
111
112NEXUS_Error NEXUS_DolbyVolume_AddInput(
113    NEXUS_DolbyVolumeHandle handle,
114    NEXUS_AudioInput input
115    )
116{
117    BSTD_UNUSED(handle);
118    BSTD_UNUSED(input);
119    return BERR_TRACE(BERR_NOT_SUPPORTED);
120}
121
122NEXUS_Error NEXUS_DolbyVolume_RemoveInput(
123    NEXUS_DolbyVolumeHandle handle,
124    NEXUS_AudioInput input
125    )
126{
127    BSTD_UNUSED(handle);
128    BSTD_UNUSED(input);
129    return BERR_TRACE(BERR_NOT_SUPPORTED);
130}
131
132NEXUS_Error NEXUS_DolbyVolume_RemoveAllInputs(
133    NEXUS_DolbyVolumeHandle handle
134    )
135{
136    BSTD_UNUSED(handle);
137    return BERR_TRACE(BERR_NOT_SUPPORTED);
138}
139
140NEXUS_Error NEXUS_DolbyVolume_P_Init(void)
141{
142    return BERR_SUCCESS;
143}
144
145void NEXUS_DolbyVolume_P_Uninit(void)
146{
147}
148
149BDBG_OBJECT_ID(NEXUS_DolbyVolume258);
150typedef struct NEXUS_DolbyVolume258
151{
152    BDBG_OBJECT(NEXUS_DolbyVolume258)
153    NEXUS_AudioInputObject connector;
154    NEXUS_DolbyVolume258Settings settings;
155    NEXUS_AudioInput input;
156    BAPE_DolbyVolumeHandle apeHandle;
157} NEXUS_DolbyVolume258;
158
159void NEXUS_DolbyVolume258_GetDefaultSettings(
160    NEXUS_DolbyVolume258Settings *pSettings   /* [out] default settings */
161    )
162{
163    BAPE_DolbyVolumeSettings piSettings;
164    BDBG_ASSERT(NULL != pSettings);
165    BAPE_DolbyVolume_GetDefaultSettings(&piSettings);
166    pSettings->enabled = piSettings.enabled;
167    pSettings->preGain = piSettings.preGain;
168    pSettings->inputReferenceLevel = piSettings.inputReferenceLevel;
169    pSettings->outputReferenceLevel = piSettings.outputReferenceLevel;
170    pSettings->calibrationOffset = piSettings.calibrationOffset;
171    pSettings->reset = piSettings.reset;
172    pSettings->volumeModelerEnabled = piSettings.volumeModelerEnabled;
173    pSettings->digitalVolumeLevel = piSettings.digitalVolumeLevel;
174    pSettings->analogVolumeLevel = piSettings.analogVolumeLevel;
175    pSettings->midsideProcessingEnabled = piSettings.midsideProcessingEnabled;
176    pSettings->halfModeEnabled = piSettings.halfModeEnabled;
177    pSettings->volumeLevelerAmount = piSettings.volumeLevelerAmount;
178    pSettings->limiterEnabled = piSettings.limiterEnabled;
179}
180
181NEXUS_DolbyVolume258Handle NEXUS_DolbyVolume258_Open(
182    const NEXUS_DolbyVolume258Settings *pSettings     /* Pass NULL for default settings */
183    )
184{
185    NEXUS_DolbyVolume258Settings defaults;
186    NEXUS_DolbyVolume258Handle handle;
187    BAPE_Connector connector;
188    BERR_Code errCode;
189
190    if ( NULL == pSettings )
191    {
192        pSettings = &defaults;
193        NEXUS_DolbyVolume258_GetDefaultSettings(&defaults);
194    }
195
196    handle = BKNI_Malloc(sizeof(NEXUS_DolbyVolume258));
197    if ( NULL == handle )
198    {
199        (void)BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
200        goto err_malloc;
201    }
202    BKNI_Memset(handle, 0, sizeof(NEXUS_DolbyVolume258));
203
204    errCode = BAPE_DolbyVolume_Create(NEXUS_AUDIO_DEVICE_HANDLE, NULL, &handle->apeHandle);
205    if ( errCode )
206    {
207        errCode = BERR_TRACE(errCode);
208        goto err_ape_handle;
209    }
210
211    BDBG_OBJECT_SET(handle, NEXUS_DolbyVolume258);
212    NEXUS_AUDIO_INPUT_INIT(&handle->connector, NEXUS_AudioInputType_eDolbyVolume258, handle);
213    handle->connector.format = NEXUS_AudioInputFormat_eNone;    /* Inherit from parent */
214    BAPE_DolbyVolume_GetConnector(handle->apeHandle, &connector);
215    handle->connector.port = (uint32_t)connector;
216
217    errCode = NEXUS_DolbyVolume258_SetSettings(handle, pSettings);
218    if ( errCode )
219    {
220        errCode = BERR_TRACE(errCode);
221        goto err_settings;
222    }
223   
224    /* Success */
225    return handle;
226
227err_settings:
228    BAPE_DolbyVolume_Destroy(handle->apeHandle);
229    BDBG_OBJECT_DESTROY(handle, NEXUS_DolbyVolume258);
230err_ape_handle:
231    BKNI_Free(handle);
232err_malloc:
233    return NULL;
234}
235
236void NEXUS_DolbyVolume258_Close(
237    NEXUS_DolbyVolume258Handle handle
238    )
239{
240    BDBG_OBJECT_ASSERT(handle, NEXUS_DolbyVolume258);
241
242    NEXUS_AudioInput_Shutdown(&handle->connector);
243    BAPE_DolbyVolume_Destroy(handle->apeHandle);
244    BDBG_OBJECT_DESTROY(handle, NEXUS_DolbyVolume258);
245    BKNI_Free(handle);
246}
247
248void NEXUS_DolbyVolume258_GetSettings(
249    NEXUS_DolbyVolume258Handle handle,
250    NEXUS_DolbyVolume258Settings *pSettings    /* [out] Settings */
251    )
252{
253    BDBG_OBJECT_ASSERT(handle, NEXUS_DolbyVolume258);
254    *pSettings = handle->settings;
255}
256
257NEXUS_Error NEXUS_DolbyVolume258_SetSettings(
258    NEXUS_DolbyVolume258Handle handle,
259    const NEXUS_DolbyVolume258Settings *pSettings
260    )
261{
262    BERR_Code errCode;
263    BAPE_DolbyVolumeSettings piSettings;
264
265    BDBG_OBJECT_ASSERT(handle, NEXUS_DolbyVolume258);
266
267    BAPE_DolbyVolume_GetSettings(handle->apeHandle, &piSettings);
268    piSettings.enabled = pSettings->enabled;
269    piSettings.preGain = pSettings->preGain;
270    piSettings.inputReferenceLevel = pSettings->inputReferenceLevel;
271    piSettings.outputReferenceLevel = pSettings->outputReferenceLevel;
272    piSettings.calibrationOffset = pSettings->calibrationOffset;
273    piSettings.reset = pSettings->reset;
274    piSettings.volumeModelerEnabled = pSettings->volumeModelerEnabled;
275    piSettings.digitalVolumeLevel = pSettings->digitalVolumeLevel;
276    piSettings.analogVolumeLevel = pSettings->analogVolumeLevel;
277    piSettings.midsideProcessingEnabled = pSettings->midsideProcessingEnabled;
278    piSettings.halfModeEnabled = pSettings->halfModeEnabled;
279    piSettings.volumeLevelerAmount = pSettings->volumeLevelerAmount;
280    piSettings.limiterEnabled = pSettings->limiterEnabled;
281
282    errCode = BAPE_DolbyVolume_SetSettings(handle->apeHandle, &piSettings);
283    if ( errCode )
284    {
285        return BERR_TRACE(errCode);
286    }
287
288    handle->settings = *pSettings;
289    return BERR_SUCCESS;
290}
291
292NEXUS_AudioInput NEXUS_DolbyVolume258_GetConnector(
293    NEXUS_DolbyVolume258Handle handle
294    )
295{
296    BDBG_OBJECT_ASSERT(handle, NEXUS_DolbyVolume258);
297    return &handle->connector;
298}
299
300NEXUS_Error NEXUS_DolbyVolume258_AddInput(
301    NEXUS_DolbyVolume258Handle handle,
302    NEXUS_AudioInput input
303    )
304{
305    NEXUS_Error errCode;
306    BDBG_OBJECT_ASSERT(handle, NEXUS_DolbyVolume258);
307    BDBG_ASSERT(NULL != input);
308    if ( NULL != handle->input )
309    {
310        BDBG_ERR(("Only one input can be added"));
311        return BERR_TRACE(BERR_NOT_SUPPORTED);
312    }
313    errCode = BAPE_DolbyVolume_AddInput(handle->apeHandle, (BAPE_Connector)input->port);
314    if ( errCode )
315    {
316        return BERR_TRACE(errCode);
317    }
318    errCode = NEXUS_AudioInput_P_AddInput(&handle->connector, input);
319    if ( errCode )
320    {
321        (void)BAPE_DolbyVolume_RemoveInput(handle->apeHandle, (BAPE_Connector)input->port);
322        return BERR_TRACE(errCode);
323    }
324    handle->input = input;
325    return BERR_SUCCESS;
326}
327
328NEXUS_Error NEXUS_DolbyVolume258_RemoveInput(
329    NEXUS_DolbyVolume258Handle handle,
330    NEXUS_AudioInput input
331    )
332{
333    NEXUS_Error errCode;
334    BDBG_OBJECT_ASSERT(handle, NEXUS_DolbyVolume258);
335    BDBG_ASSERT(NULL != handle->input);
336    if ( input != handle->input )
337    {
338        BDBG_ERR(("Input not connected"));
339        return BERR_TRACE(BERR_NOT_SUPPORTED);
340    }
341    errCode = BAPE_DolbyVolume_RemoveInput(handle->apeHandle, (BAPE_Connector)input->port);
342    if ( errCode )
343    {
344        return BERR_TRACE(errCode);
345    }
346    errCode = NEXUS_AudioInput_P_RemoveInput(&handle->connector, input);
347    if ( errCode )
348    {
349        return BERR_TRACE(errCode);
350    }
351    handle->input = NULL;
352    return BERR_SUCCESS;
353}
354
355NEXUS_Error NEXUS_DolbyVolume258_RemoveAllInputs(
356    NEXUS_DolbyVolume258Handle handle
357    )
358{
359    BDBG_OBJECT_ASSERT(handle, NEXUS_DolbyVolume258);
360    if ( handle->input )
361    {
362        return NEXUS_DolbyVolume258_RemoveInput(handle, handle->input);
363    }
364    return BERR_SUCCESS;
365}
366
Note: See TracBrowser for help on using the repository browser.