source: svn/newcon3bcm2_21bu/magnum/portinginterface/ape/7552/bape_audyssey_abx.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: 13.6 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: bape_audyssey_abx.c $
39* $brcm_Revision: Hydra_Software_Devel/1 $
40* $brcm_Date: 5/14/11 11:22a $
41*
42* API Description:
43*   API name: AudysseyAbx
44*    Specific APIs related to Audyssey ABX Audio Processing
45*
46* Revision History:
47*
48* $brcm_Log: /magnum/portinginterface/ape/7422/bape_audyssey_abx.c $
49*
50* Hydra_Software_Devel/1   5/14/11 11:22a jgarrett
51* SWDTV-6762: Adding Audyssey ADV/ABX
52*
53***************************************************************************/
54
55#include "bape.h"
56#include "bape_priv.h"
57#include "bdsp_raaga.h"
58
59BDBG_MODULE(bape_audyssey_abx);
60
61BDBG_OBJECT_ID(BAPE_AudysseyAbx);
62
63typedef struct BAPE_AudysseyAbx
64{
65    BDBG_OBJECT(BAPE_AudysseyAbx)
66    BAPE_PathNode node;
67    BAPE_AudysseyAbxSettings settings;
68    BAPE_Connector input;
69} BAPE_AudysseyAbx;
70
71static BERR_Code BAPE_AudysseyAbx_P_ConnectorSupported(struct BAPE_PathNode *pNode, BAPE_PathConnector *pConnector);
72static BERR_Code BAPE_AudysseyAbx_P_AllocatePathFromInput(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
73static BERR_Code BAPE_AudysseyAbx_P_ConfigPathFromInput(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
74static BERR_Code BAPE_AudysseyAbx_P_ApplyDspSettings(BAPE_AudysseyAbxHandle handle, BDSP_TaskHandle task, unsigned branchId, unsigned stageId);
75static void BAPE_AudysseyAbx_P_StopPathFromInput(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection);
76static void BAPE_AudysseyAbx_P_RemoveInputCallback(struct BAPE_PathNode *pNode, BAPE_PathConnector *pConnector);
77
78void BAPE_AudysseyAbx_GetDefaultSettings(
79    BAPE_AudysseyAbxSettings *pSettings   /* [out] default settings */
80    )
81{
82    BDSP_Raaga_Audio_ABXConfigParams dspSettings;
83
84    BDBG_ASSERT(NULL != pSettings);
85    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
86    BDSP_Raaga_GetDefaultAudioProcessingSettings(BDSP_AudioProcessing_eAudysseyABX, (void *)&dspSettings, sizeof(dspSettings));
87
88    pSettings->enabled = (dspSettings.ui32OperationMode == 0) ? false : true;
89    pSettings->filterSet = dspSettings.ui32FilterSet;
90    pSettings->harmonicGain = dspSettings.ui32HarmonicGain;
91    pSettings->dryGain = dspSettings.ui32DryGain;
92}
93
94/***************************************************************************
95Summary:
96    Open an SRS AudysseyAbx stage
97***************************************************************************/
98BERR_Code BAPE_AudysseyAbx_Create(
99    BAPE_Handle deviceHandle,
100    const BAPE_AudysseyAbxSettings *pSettings,
101    BAPE_AudysseyAbxHandle *pHandle
102    )
103{
104    BAPE_AudysseyAbxHandle handle;
105
106    BDBG_OBJECT_ASSERT(deviceHandle, BAPE_Device);
107    BDBG_ASSERT(NULL != pSettings);
108    BDBG_ASSERT(NULL != pHandle);
109
110
111    handle = BKNI_Malloc(sizeof(BAPE_AudysseyAbx));
112    if ( NULL == handle )
113    {
114        return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
115    }
116    BKNI_Memset(handle, 0, sizeof(BAPE_AudysseyAbx));
117    BDBG_OBJECT_SET(handle, BAPE_AudysseyAbx);
118    handle->settings = *pSettings;
119    BAPE_P_InitPathNode(&handle->node, BAPE_PathNodeType_ePostProcessor, BAPE_PostProcessorType_eAudysseyAbx, 1, deviceHandle, handle);
120    handle->node.pName = "AVL";
121    handle->node.paths[0].connector.numChannelPairs = 1; /* Only output stereo */
122    handle->node.paths[0].connector.useBufferPool = true;   
123    handle->node.paths[0].connector.dataSource = BAPE_DataSource_eDspBuffer;   
124
125    /* Generic Routines */
126    handle->node.allocatePathToOutput = BAPE_DSP_P_AllocatePathToOutput;
127    handle->node.configPathToOutput = BAPE_DSP_P_ConfigPathToOutput;
128    handle->node.stopPathToOutput = BAPE_DSP_P_StopPathToOutput;
129    handle->node.startPathToOutput = BAPE_DSP_P_StartPathToOutput;
130    handle->node.stopPathToOutput = BAPE_DSP_P_StopPathToOutput;
131
132    /* AudysseyAbx Specifics */
133    handle->node.connectorSupported = BAPE_AudysseyAbx_P_ConnectorSupported;
134    handle->node.allocatePathFromInput = BAPE_AudysseyAbx_P_AllocatePathFromInput;
135    handle->node.configPathFromInput = BAPE_AudysseyAbx_P_ConfigPathFromInput;
136    handle->node.stopPathFromInput = BAPE_AudysseyAbx_P_StopPathFromInput;
137    handle->node.removeInput = BAPE_AudysseyAbx_P_RemoveInputCallback;
138
139    *pHandle = handle;
140    return BERR_SUCCESS;
141}
142
143void BAPE_AudysseyAbx_Destroy(
144    BAPE_AudysseyAbxHandle handle
145    )
146{
147    bool running;
148    BDBG_OBJECT_ASSERT(handle, BAPE_AudysseyAbx);
149    running = (handle->node.paths[0].connector.task != NULL)?true:false;
150    BDBG_ASSERT(false == running);
151    BDBG_ASSERT(NULL == handle->input);
152    BDBG_OBJECT_DESTROY(handle, BAPE_AudysseyAbx);
153    BKNI_Free(handle);
154}
155
156void BAPE_AudysseyAbx_GetSettings(
157    BAPE_AudysseyAbxHandle handle,
158    BAPE_AudysseyAbxSettings *pSettings    /* [out] Settings */
159    )
160{
161    BDBG_OBJECT_ASSERT(handle, BAPE_AudysseyAbx);
162    BDBG_ASSERT(NULL != pSettings);
163    *pSettings = handle->settings;
164}
165
166BERR_Code BAPE_AudysseyAbx_SetSettings(
167    BAPE_AudysseyAbxHandle handle,
168    const BAPE_AudysseyAbxSettings *pSettings
169    )
170{
171    BERR_Code errCode;
172    BDBG_OBJECT_ASSERT(handle, BAPE_AudysseyAbx);
173    BDBG_ASSERT(NULL != pSettings);
174
175    if ( pSettings != &handle->settings )
176    {
177        handle->settings = *pSettings;
178    }
179
180    if ( handle->node.paths[0].connector.task != NULL )
181    {
182        errCode = BAPE_AudysseyAbx_P_ApplyDspSettings(handle, 
183                                                          handle->node.paths[0].connector.task, 
184                                                          handle->node.paths[0].connector.branchId, 
185                                                          handle->node.paths[0].connector.stageId);
186        if ( errCode )
187        {
188            return BERR_TRACE(errCode);
189        }
190    }
191
192    return BERR_SUCCESS;
193}
194
195
196void BAPE_AudysseyAbx_GetConnector(
197    BAPE_AudysseyAbxHandle handle,
198    BAPE_Connector *pConnector
199    )
200{
201    BDBG_OBJECT_ASSERT(handle, BAPE_AudysseyAbx);
202    BDBG_ASSERT(NULL != pConnector);
203    *pConnector = &handle->node.paths[0].connector;
204}
205
206
207BERR_Code BAPE_AudysseyAbx_AddInput(
208    BAPE_AudysseyAbxHandle handle,
209    BAPE_Connector input
210    )
211{
212    BERR_Code errCode;
213    BDBG_OBJECT_ASSERT(handle, BAPE_AudysseyAbx);
214    BDBG_OBJECT_ASSERT(input, BAPE_PathConnector);
215    if ( NULL != handle->input )
216    {
217        BDBG_ERR(("Can not have more than one input"));
218        return BERR_TRACE(BERR_NOT_SUPPORTED);
219    }
220    errCode = BAPE_PathNode_P_AddInput(&handle->node, input);
221    if ( errCode )
222    {
223        return BERR_TRACE(errCode);
224    }
225    handle->input = input;
226    return BERR_SUCCESS;
227}
228
229
230BERR_Code BAPE_AudysseyAbx_RemoveInput(
231    BAPE_AudysseyAbxHandle handle,
232    BAPE_Connector input
233    )
234{
235    BERR_Code errCode;
236    BDBG_OBJECT_ASSERT(handle, BAPE_AudysseyAbx);
237    BDBG_OBJECT_ASSERT(input, BAPE_PathConnector);
238    if ( input != handle->input )
239    {
240        BDBG_ERR(("Input %s %s (%#x) is not connected", input->pParent->pName, input->pName, input));
241        return BERR_TRACE(BERR_INVALID_PARAMETER);
242    }
243    errCode = BAPE_PathNode_P_RemoveInput(&handle->node, input);
244    if ( errCode )
245    {
246        return BERR_TRACE(errCode);
247    }
248    handle->input = NULL;
249    return BERR_SUCCESS;
250}
251
252
253BERR_Code BAPE_AudysseyAbx_RemoveAllInputs(
254    BAPE_AudysseyAbxHandle handle
255    )
256{
257    BDBG_OBJECT_ASSERT(handle, BAPE_AudysseyAbx);
258    if ( handle->input )
259    {
260        return BAPE_AudysseyAbx_RemoveInput(handle, handle->input);
261    }
262    return BERR_SUCCESS;
263}
264
265static BERR_Code BAPE_AudysseyAbx_P_ConnectorSupported(struct BAPE_PathNode *pNode, BAPE_PathConnector *pConnector)
266{
267    BDBG_OBJECT_ASSERT(pNode, BAPE_PathNode);
268    BDBG_OBJECT_ASSERT(pConnector, BAPE_PathConnector);
269    if ( pConnector->dataSource == BAPE_DataSource_eDspBuffer &&
270         pConnector->numChannelPairs == 1 &&
271         !pConnector->compressed )
272    {
273        return BERR_SUCCESS;
274    }
275    else
276    {
277        BDBG_ERR(("Only stereo DSP input is supported"));
278        return BERR_TRACE(BERR_INVALID_PARAMETER);
279    }
280}
281
282static BERR_Code BAPE_AudysseyAbx_P_AllocatePathFromInput(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection)
283{
284    BERR_Code errCode;
285    BAPE_AudysseyAbxHandle handle;
286    BDBG_OBJECT_ASSERT(pNode, BAPE_PathNode);
287    BDBG_OBJECT_ASSERT(pConnection, BAPE_PathConnection);
288    BDBG_ASSERT(NULL != pConnection->pSource->pTaskCreateSettings);
289    handle = pNode->pHandle;
290    BDBG_OBJECT_ASSERT(handle, BAPE_AudysseyAbx);
291    /* Add stage to CIT and propagate task settings */
292    errCode = BAPE_DSP_P_AddProcessingStage(pConnection->pSource->pTaskCreateSettings, pConnection->pSource->branchId, pConnection->pSource->stageId, 
293                                            BAPE_DSP_P_GetDataTypeFromConnector(handle->input), 
294                                            BDSP_AudioProcessing_eAudysseyABX,
295                                            false,
296                                            &pNode->paths[0].connector.branchId, &pNode->paths[0].connector.stageId);
297    if ( errCode )
298    {
299        return BERR_TRACE(errCode);
300    }
301    pNode->paths[0].connector.pTaskCreateSettings = pConnection->pSource->pTaskCreateSettings;
302    return BERR_SUCCESS;
303}
304
305static BERR_Code BAPE_AudysseyAbx_P_ConfigPathFromInput(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection)
306{
307    BERR_Code errCode;
308    BAPE_AudysseyAbxHandle handle;
309    BDBG_OBJECT_ASSERT(pNode, BAPE_PathNode);
310    BDBG_OBJECT_ASSERT(pConnection, BAPE_PathConnection);
311    BDBG_ASSERT(NULL != pConnection->pSource->task);
312
313    handle = pNode->pHandle;
314    BDBG_OBJECT_ASSERT(handle, BAPE_AudysseyAbx);
315    pNode->paths[0].connector.task = pConnection->pSource->task;
316    errCode = BAPE_AudysseyAbx_P_ApplyDspSettings(handle, 
317                                                      handle->node.paths[0].connector.task, 
318                                                      handle->node.paths[0].connector.branchId, 
319                                                      handle->node.paths[0].connector.stageId);
320    if ( errCode )
321    {
322        return BERR_TRACE(errCode);
323    }
324
325    return BERR_SUCCESS;   
326}
327
328static BERR_Code BAPE_AudysseyAbx_P_ApplyDspSettings(BAPE_AudysseyAbxHandle handle, BDSP_TaskHandle task, unsigned branchId, unsigned stageId)
329{
330    BERR_Code errCode;
331    BDSP_Raaga_Audio_ABXConfigParams userConfig;
332
333    errCode = BDSP_Task_GetStageSettings(task, branchId, stageId, &userConfig, sizeof(userConfig));
334    if ( errCode )
335    {
336        return BERR_TRACE(errCode);
337    }
338    BAPE_DSP_P_SET_VARIABLE(userConfig, ui32OperationMode, handle->settings.enabled?1:0);
339    BAPE_DSP_P_SET_VARIABLE(userConfig, ui32FilterSet, handle->settings.filterSet);
340    BAPE_DSP_P_SET_VARIABLE(userConfig, ui32HarmonicGain, handle->settings.harmonicGain);
341    BAPE_DSP_P_SET_VARIABLE(userConfig, ui32DryGain, handle->settings.dryGain);
342
343    errCode = BDSP_Task_SetStageSettings(task, branchId, stageId, &userConfig, sizeof(userConfig));
344    if ( errCode )
345    {
346        return BERR_TRACE(errCode);
347    }
348
349    return BERR_SUCCESS;
350}
351
352static void BAPE_AudysseyAbx_P_StopPathFromInput(struct BAPE_PathNode *pNode, struct BAPE_PathConnection *pConnection)
353{
354    /* Invalidate task handle */
355    BDBG_OBJECT_ASSERT(pNode, BAPE_PathNode);
356    BSTD_UNUSED(pConnection);
357    pNode->paths[0].connector.task = NULL;
358}
359
360static void BAPE_AudysseyAbx_P_RemoveInputCallback(struct BAPE_PathNode *pNode, BAPE_PathConnector *pConnector)
361{
362    (void)BAPE_AudysseyAbx_RemoveInput(pNode->pHandle, pConnector);
363}
364
Note: See TracBrowser for help on using the repository browser.