source: svn/newcon3bcm2_21bu/magnum/portinginterface/ape/7552/bape_dummy_output.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 *     Copyright (c) 2006-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: bape_dummy_output.c $
11 * $brcm_Revision: Hydra_Software_Devel/9 $
12 * $brcm_Date: 3/6/12 3:07p $
13 *
14 * Module Description: Dummysink Output Interface
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/ape/7422/bape_dummy_output.c $
19 *
20 * Hydra_Software_Devel/9   3/6/12 3:07p gskerl
21 * SW7425-2570: Renamed OutputPortObject substruct from connector to
22 * outputPort.
23 *
24 * Hydra_Software_Devel/8   11/14/11 3:37p gskerl
25 * SW7429-18: Merging 7429 changes back to main branch.
26 *
27 * Hydra_Software_Devel/SW7429-18/1   10/21/11 6:29p jgarrett
28 * SW7429-18: Initial compileable version for 7429
29 *
30 * Hydra_Software_Devel/7   9/30/11 11:42a gskerl
31 * SW7231-129: Added support for recovering hardware state after power
32 * standby/resume.
33 *
34 * Hydra_Software_Devel/6   5/20/11 5:16p jgarrett
35 * SW7425-402: Adding error code to handle output enable callback failing.
36 *
37 * Hydra_Software_Devel/5   5/3/11 10:50a gskerl
38 * SW7422-354: Added index and type args to APE_P_InitOutputPort macro
39 *
40 * Hydra_Software_Devel/4   4/16/11 12:15p jgarrett
41 * SW7425-371: Removing tab characters
42 *
43 * Hydra_Software_Devel/3   4/6/11 1:24a jgarrett
44 * SW35330-35: Merge to main branch
45 *
46 * Hydra_Software_Devel/SW35330-35/1   4/5/11 12:50p jgarrett
47 * SW35330-35: FMM Abstraction refactoring to support DTV
48 *
49 * Hydra_Software_Devel/2   3/22/11 3:10p gskerl
50 * SW7422-146: Changed audio output connector callbacks to take the output
51 * connector as an argument
52 *
53 * Hydra_Software_Devel/1   3/21/11 7:08p jgarrett
54 * SW7422-356: Adding MuxOutput
55 *
56 ***************************************************************************/
57
58#include "bstd.h"
59#include "bkni.h"
60#include "bape.h"
61#include "bape_priv.h"
62
63BDBG_MODULE(bape_dummy_output);
64
65BDBG_OBJECT_ID(BAPE_DummyOutput);
66
67typedef struct BAPE_DummyOutput
68{
69    BDBG_OBJECT(BAPE_DummyOutput)
70    BAPE_Handle deviceHandle;
71    unsigned index;
72    BAPE_OutputPortObject outputPort;
73    BAPE_DummysinkGroupHandle hDummysinkGroup;
74#if BAPE_CHIP_MAX_FS > 0
75    unsigned fsNum;
76#else
77    BAPE_MclkSource mclkSource;
78    unsigned pllChannel;
79    unsigned mclkFreqToFsRatio;
80#endif
81    bool enabled;
82    char name[14];   /* DummyOutput %d */
83} BAPE_DummyOutput;
84
85/* Static function prototypes */
86static BERR_Code BAPE_DummyOutput_P_OpenHw(BAPE_DummyOutputHandle handle);
87
88/* Output port callbacks */
89static BERR_Code BAPE_DummyOutput_P_Enable(BAPE_OutputPort output);
90static void BAPE_DummyOutput_P_Disable(BAPE_OutputPort output);
91
92/* Timing callbacks */
93#if BAPE_CHIP_MAX_FS > 0
94static void BAPE_DummyOutput_P_SetFs(BAPE_OutputPort output, unsigned fsNum);
95#else
96static void BAPE_DummyOutput_P_SetMclk_isr(BAPE_OutputPort output, BAPE_MclkSource mclkSource, unsigned pllChannel, unsigned mclkFreqToFsRatio);
97#endif
98
99/***************************************************************************
100        Public APIs: From bape_output.h
101***************************************************************************/
102
103void BAPE_DummyOutput_GetDefaultOpenSettings(
104    BAPE_DummyOutputOpenSettings *pSettings       /* [out] */
105    )
106{
107    BDBG_ASSERT(NULL != pSettings);
108    BKNI_Memset(pSettings, 0, sizeof(*pSettings));   
109
110    pSettings->maxMultichannelFormat = BAPE_MultichannelFormat_e2_0;
111}
112
113/**************************************************************************/
114
115BERR_Code BAPE_DummyOutput_Open(
116    BAPE_Handle deviceHandle,
117    unsigned index,
118    const BAPE_DummyOutputOpenSettings *pSettings,
119    BAPE_DummyOutputHandle *pHandle             /* [out] */
120    )
121{
122    BERR_Code errCode;
123    BAPE_DummyOutputHandle handle;
124    unsigned numChannelPairs=1;
125    BAPE_DummysinkGroupCreateSettings dummysinkCreateSettings;
126    BAPE_DummyOutputOpenSettings defaultSettings;
127
128    BDBG_OBJECT_ASSERT(deviceHandle, BAPE_Device);
129    BDBG_ASSERT(NULL != pHandle);
130
131    BDBG_MSG(("%s: Opening DummyOutput: %u", __FUNCTION__, index));
132
133    if ( index >= BAPE_CHIP_MAX_DUMMYSINKS )
134    {
135        BDBG_ERR(("Unable to open dummysink %u.  Max dummysinks is %u on this platform.", index, BAPE_CHIP_MAX_DUMMYSINKS));
136        return BERR_TRACE(BERR_INVALID_PARAMETER);
137    }
138
139    if ( deviceHandle->dummyOutputs[index] )
140    {
141        BDBG_ERR(("DummyOutput %d already open", index));
142        return BERR_TRACE(BERR_INVALID_PARAMETER);
143    }
144
145    /* Init to specified settings */
146    if ( NULL == pSettings )
147    {
148        BAPE_DummyOutput_GetDefaultOpenSettings(&defaultSettings);
149        pSettings = &defaultSettings;
150    }
151
152    /* Allocate the device structure, then fill in all the fields. */
153    handle = BKNI_Malloc(sizeof(BAPE_DummyOutput));
154    if ( NULL == handle )
155    {
156        return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
157    }
158    BKNI_Memset(handle, 0, sizeof(BAPE_DummyOutput));
159    BDBG_OBJECT_SET(handle, BAPE_DummyOutput);
160    handle->deviceHandle = deviceHandle;
161    handle->index = index;
162    BAPE_P_InitOutputPort(&handle->outputPort, BAPE_OutputPortType_eDummyOutput, index, handle);
163
164    switch ( pSettings->maxMultichannelFormat )
165    {
166    case BAPE_MultichannelFormat_e2_0:
167        numChannelPairs = 1;
168        break;
169    case BAPE_MultichannelFormat_e5_1:
170        numChannelPairs = 3;
171        break;
172    case BAPE_MultichannelFormat_e7_1:
173        numChannelPairs = 4;
174        break;
175    default:
176        BDBG_ERR(("Unsupported multichannel format %u", pSettings->maxMultichannelFormat));
177        BAPE_DummyOutput_Close(handle);
178        return BERR_TRACE(BERR_NOT_SUPPORTED);
179    }
180
181    handle->outputPort.maxChannelPairs = numChannelPairs;
182    handle->outputPort.compressedSupported = true;
183    handle->outputPort.enable = BAPE_DummyOutput_P_Enable;
184    handle->outputPort.disable = BAPE_DummyOutput_P_Disable;
185#if BAPE_CHIP_MAX_FS > 0
186    handle->outputPort.fsTiming = true;
187    handle->outputPort.setFs = BAPE_DummyOutput_P_SetFs;
188    handle->fsNum = (unsigned)-1;
189#else
190    handle->outputPort.setMclk_isr = BAPE_DummyOutput_P_SetMclk_isr;
191    handle->mclkSource = BAPE_MclkSource_eNone;
192    handle->pllChannel = 0;
193    handle->mclkFreqToFsRatio = BAPE_BASE_PLL_TO_FS_RATIO;
194#endif
195    BKNI_Snprintf(handle->name, sizeof(handle->name), "Dummysink %u", index); 
196    handle->outputPort.pName = handle->name;
197
198    BAPE_DummysinkGroup_P_GetDefaultCreateSettings(&dummysinkCreateSettings);
199    dummysinkCreateSettings.numChannelPairs = numChannelPairs;
200    errCode = BAPE_DummysinkGroup_P_Create(deviceHandle, &dummysinkCreateSettings, &handle->hDummysinkGroup);
201    if ( errCode )
202    {
203        BAPE_DummyOutput_Close(handle);
204        return BERR_TRACE(errCode);
205    }
206
207    errCode = BAPE_DummyOutput_P_OpenHw(handle);
208    if ( errCode )
209    {
210        BAPE_DummyOutput_Close(handle);
211        return BERR_TRACE(errCode);
212    }
213
214    *pHandle = handle;
215    handle->deviceHandle->dummyOutputs[index] = handle;
216    return BERR_SUCCESS;
217}
218
219/**************************************************************************/
220
221void BAPE_DummyOutput_Close(
222    BAPE_DummyOutputHandle handle
223    )
224{
225    BDBG_OBJECT_ASSERT(handle, BAPE_DummyOutput);
226
227    if ( handle->hDummysinkGroup )
228    {
229        BAPE_DummysinkGroup_P_Destroy(handle->hDummysinkGroup);
230    }
231
232    handle->deviceHandle->dummyOutputs[handle->index] = NULL;
233    BDBG_OBJECT_DESTROY(handle, BAPE_DummyOutput);
234    BKNI_Free(handle);
235}
236
237/**************************************************************************/
238
239void BAPE_DummyOutput_GetOutputPort(
240    BAPE_DummyOutputHandle handle,
241    BAPE_OutputPort *pOutputPort
242    )
243{
244    BDBG_OBJECT_ASSERT(handle, BAPE_DummyOutput);
245    BDBG_ASSERT(NULL != pOutputPort);
246    *pOutputPort = &handle->outputPort;
247}
248
249/***************************************************************************
250        BAPE Internal APIs: From bape_fmm_priv.h
251***************************************************************************/
252
253BERR_Code BAPE_DummyOutput_P_ResumeFromStandby(BAPE_Handle bapeHandle)
254{
255    BERR_Code   errCode = BERR_SUCCESS;
256    unsigned    dummyOutputIndex;
257
258    BDBG_OBJECT_ASSERT(bapeHandle, BAPE_Device);
259
260    /* For each opened DummyOutput, call the functions necessary to restore the
261     * hardware to it's appropriate state.
262     */
263    for ( dummyOutputIndex=0 ; dummyOutputIndex<BAPE_CHIP_MAX_DUMMYSINKS ; dummyOutputIndex++ )
264    {
265        if ( bapeHandle->dummyOutputs[dummyOutputIndex] )       /* If this DummyOutput is open... */
266        {
267            BAPE_DummyOutputHandle hDummyOutput = bapeHandle->dummyOutputs[dummyOutputIndex];
268
269            /* Put the HW into the generic open state. */
270            errCode = BAPE_DummyOutput_P_OpenHw(hDummyOutput);
271            if ( errCode ) return BERR_TRACE(errCode);
272           
273            /* Now apply changes for the settings struct. */
274                /* Nothing to do for that because there's no SetSettings function. */
275
276#if BAPE_CHIP_MAX_FS > 0
277            /* Now restore the timebase and sampleRate from the values saved in the device struct. */
278            if ( hDummyOutput->fsNum !=  (unsigned)-1 )
279            {
280                BAPE_DummyOutput_P_SetFs(&hDummyOutput->outputPort, hDummyOutput->fsNum);
281            }
282#else
283            if ( hDummyOutput->mclkSource != BAPE_MclkSource_eNone )
284            {
285                BKNI_EnterCriticalSection();
286                BAPE_DummyOutput_P_SetMclk_isr(&hDummyOutput->outputPort, hDummyOutput->mclkSource, hDummyOutput->pllChannel, hDummyOutput->mclkFreqToFsRatio);
287                BKNI_LeaveCriticalSection();               
288            }
289#endif
290        } /* end if this DummyOutput was open */
291    } /* end for each DummyOutput */
292    return errCode;
293}
294
295
296/***************************************************************************
297        Private callbacks: Protyped above
298***************************************************************************/
299static BERR_Code BAPE_DummyOutput_P_Enable(BAPE_OutputPort output)
300{
301    BAPE_DummyOutputHandle handle;
302    BAPE_DummysinkGroupSettings dummysinkSettings;
303    BERR_Code errCode;
304
305    BDBG_OBJECT_ASSERT(output, BAPE_OutputPort);
306
307    handle = output->pHandle;
308    BDBG_OBJECT_ASSERT(handle, BAPE_DummyOutput);
309
310    BDBG_ASSERT(false == handle->enabled);
311
312    /* Set Input Parameters */
313    BAPE_DummysinkGroup_P_GetSettings(handle->hDummysinkGroup, &dummysinkSettings);
314    dummysinkSettings.input = handle->outputPort.sourceMixerFci;
315    errCode = BAPE_DummysinkGroup_P_SetSettings(handle->hDummysinkGroup, &dummysinkSettings);
316    if ( errCode )
317    {
318        errCode = BERR_TRACE(errCode);
319        goto err_dummysink_settings;
320    }
321
322    /* Enable each dummysink */
323    errCode = BAPE_DummysinkGroup_P_Start(handle->hDummysinkGroup);
324    if ( errCode )
325    {
326        errCode = BERR_TRACE(errCode);
327        goto err_dummysink_start;
328    }
329
330    /* Done */
331    handle->enabled = true;
332
333err_dummysink_start:   
334err_dummysink_settings:
335    return errCode;
336}
337
338/**************************************************************************/
339
340static void BAPE_DummyOutput_P_Disable(BAPE_OutputPort output)
341{
342    BAPE_DummyOutputHandle handle;
343
344    BDBG_OBJECT_ASSERT(output, BAPE_OutputPort);
345
346    handle = output->pHandle;
347    BDBG_OBJECT_ASSERT(handle, BAPE_DummyOutput);
348
349    /* disable each dummysink */
350    BAPE_DummysinkGroup_P_Stop(handle->hDummysinkGroup);
351
352    /* Done */
353    handle->enabled = false;
354}
355
356/**************************************************************************/
357
358#if BAPE_CHIP_MAX_FS > 0
359static void BAPE_DummyOutput_P_SetFs(BAPE_OutputPort output, unsigned fsNum)
360{
361    BAPE_DummyOutputHandle handle;
362    BAPE_DummysinkGroupSettings dummysinkSettings;
363    BERR_Code errCode;
364
365    BDBG_OBJECT_ASSERT(output, BAPE_OutputPort);
366
367    handle = output->pHandle;
368    BDBG_OBJECT_ASSERT(handle, BAPE_DummyOutput);
369
370    BDBG_ASSERT(false == handle->enabled);
371
372    /* Set Input Parameters */
373    BAPE_DummysinkGroup_P_GetSettings(handle->hDummysinkGroup, &dummysinkSettings);
374    dummysinkSettings.fs = fsNum;
375    errCode = BAPE_DummysinkGroup_P_SetSettings(handle->hDummysinkGroup, &dummysinkSettings);
376
377    handle->fsNum = fsNum;
378
379    BDBG_ASSERT(BERR_SUCCESS == errCode);
380}
381#else
382static void BAPE_DummyOutput_P_SetMclk_isr(BAPE_OutputPort output, BAPE_MclkSource mclkSource, unsigned pllChannel, unsigned mclkFreqToFsRatio)
383{
384    BAPE_DummyOutputHandle handle;
385    BAPE_DummysinkGroupSettings dummysinkSettings;
386    BERR_Code errCode;
387
388    BDBG_OBJECT_ASSERT(output, BAPE_OutputPort);
389
390    handle = output->pHandle;
391    BDBG_OBJECT_ASSERT(handle, BAPE_DummyOutput);
392
393    BDBG_ASSERT(false == handle->enabled);
394
395    /* Set Input Parameters */
396    BAPE_DummysinkGroup_P_GetSettings(handle->hDummysinkGroup, &dummysinkSettings);
397    dummysinkSettings.mclkSource = mclkSource;
398    dummysinkSettings.pllChannel = pllChannel;
399    dummysinkSettings.mclkFreqToFsRatio = mclkFreqToFsRatio;
400    errCode = BAPE_DummysinkGroup_P_SetSettings(handle->hDummysinkGroup, &dummysinkSettings);
401
402    handle->mclkSource = mclkSource;
403    handle->pllChannel = pllChannel;
404    handle->mclkFreqToFsRatio = mclkFreqToFsRatio;
405
406    BDBG_ASSERT(BERR_SUCCESS == errCode);
407}
408#endif
409
410/***************************************************************************
411        Private functions: Protyped above
412***************************************************************************/
413
414static BERR_Code BAPE_DummyOutput_P_OpenHw(BAPE_DummyOutputHandle handle)
415{
416    BDBG_OBJECT_ASSERT(handle, BAPE_DummyOutput);
417
418    BSTD_UNUSED(handle);
419    /* Nothing to do for now. */
420
421    return BERR_SUCCESS;
422}
423
424
Note: See TracBrowser for help on using the repository browser.