source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/ape/7552/bape_mixer.c

Last change on this file was 2, checked in by jglee, 11 years ago

first commit

  • Property svn:executable set to *
File size: 27.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_mixer.c $
11 * $brcm_Revision: Hydra_Software_Devel/39 $
12 * $brcm_Date: 3/16/12 6:07p $
13 *
14 * Module Description: Mixer Interface
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/ape/7422/bape_mixer.c $
19 *
20 * Hydra_Software_Devel/39   3/16/12 6:07p gskerl
21 * SW7425-1178: Added code so that bape_startprint will print info about
22 * InputPorts and RAVE contexts.
23 *
24 * Hydra_Software_Devel/38   1/27/12 4:52p jgarrett
25 * SW7429-55: Setting default NCO to 0 on chips that have an NCO
26 *
27 * Hydra_Software_Devel/37   12/2/11 3:19p jgarrett
28 * SW7346-578: Adding ability to change some mixer settings without
29 * destroying and re-creating the mixer
30 *
31 * Hydra_Software_Devel/36   8/23/11 1:23p gskerl
32 * SW7425-1119: Added prototypes and stubs for BAPE_Mixer_Start() and
33 * BAPE_Mixer_Stop(). For now, they just return BERR_NOT_SUPPORTED
34 *
35 * Hydra_Software_Devel/35   7/8/11 4:26p gskerl
36 * SW7552-72: Added support for NCO/Mclkgen audio clock sources
37 *
38 * Hydra_Software_Devel/34   6/29/11 4:07p gskerl
39 * SW7425-321: Resolved the bape_mixerprint in kernel mode issue
40 *
41 * Hydra_Software_Devel/33   6/29/11 11:27a gskerl
42 * SW7425-321: Disabled bape_mixerprint when in kernel mode (because BDBG
43 * level detection doesn't work in kernel mode)
44 *
45 * Hydra_Software_Devel/32   6/20/11 7:02p jgarrett
46 * SW7425-406: Adding input scaling coefficients to mixer
47 *
48 * Hydra_Software_Devel/31   6/16/11 4:56p gskerl
49 * SW7425-321: Changed diagnostic prints to use new BDBG_LOG macro
50 *
51 * Hydra_Software_Devel/30   6/14/11 6:53p gskerl
52 * SW7425-321: Added BAPE_Mixer_P_PrintMixers() function to print a mixer-
53 * centric representation of the filter graph
54 *
55 * Hydra_Software_Devel/29   6/3/11 6:41p jgarrett
56 * SW7425-406: Adding BAPE_Mixer_GetConnector routines
57 *
58 * Hydra_Software_Devel/28   5/31/11 6:37p jgarrett
59 * SW7425-406: Adding initial DSP mixer code
60 *
61 * Hydra_Software_Devel/27   5/27/11 7:48p gskerl
62 * SW7425-321: Split mixer code into multiple files. Added framework for
63 * dispatching mixer API calls to multiple mixer types.
64 *
65 * Hydra_Software_Devel/26   5/26/11 5:38p jgarrett
66 * SW7346-224: Making sure buffers are validated even if mixer path is
67 * cached.  Removing other connections may have removed buffers.
68 *
69 * Hydra_Software_Devel/25   5/20/11 5:16p jgarrett
70 * SW7425-402: Adding error code to handle output enable callback failing.
71 *
72 * Hydra_Software_Devel/24   5/13/11 3:45p jgarrett
73 * SW7425-571: Resetting input sample rate when resources are released.
74 * Fixes issues when enabling/disabling PPM correction at non-bypass
75 * sample rates
76 *
77 * Hydra_Software_Devel/23   4/27/11 3:11p jgarrett
78 * SW7346-160: Making input format changes less restrictive while running
79 *
80 * Hydra_Software_Devel/22   4/20/11 7:00p gskerl
81 * SW7425-384: Refactored BAPE_P_SetFsTiming_isr() to improve PLLCLKSEL
82 * logic and to add support for multiple DACS
83 *
84 * Hydra_Software_Devel/21   4/18/11 10:09p jgarrett
85 * SW7425-361: Refactoring DSP branch decisions
86 *
87 * Hydra_Software_Devel/20   4/17/11 12:28p jgarrett
88 * SW7344-46: Resetting connection state after resource release
89 *
90 * Hydra_Software_Devel/19   4/16/11 12:32p jgarrett
91 * SW7425-371: Removing tabs
92 *
93 * Hydra_Software_Devel/18   4/16/11 12:15p jgarrett
94 * SW7425-371: Removing tab characters
95 *
96 * Hydra_Software_Devel/17   4/14/11 6:18p jgarrett
97 * SW7231-125: Fixing buffer allocation/free order on input format change
98 *
99 * Hydra_Software_Devel/16   4/12/11 5:34p jgarrett
100 * SW7425-292: Fixing input mute and preserving output mute across
101 * start/stop
102 *
103 * Hydra_Software_Devel/15   4/6/11 1:23a jgarrett
104 * SW35330-35: Merge to main branch
105 *
106 * Hydra_Software_Devel/SW35330-35/1   4/5/11 12:49p jgarrett
107 * SW35330-35: FMM Abstraction refactoring to support DTV
108 *
109 * Hydra_Software_Devel/14   3/22/11 2:57p gskerl
110 * SW7422-146: Changed audio output connector callbacks to take the output
111 * connector as an argument
112 *
113 * Hydra_Software_Devel/13   3/11/11 12:20p jgarrett
114 * SW7422-146: Enabling PPM Correction
115 *
116 * Hydra_Software_Devel/12   3/11/11 11:17a jgarrett
117 * SW7422-146: Coverity CID 289
118 *
119 * Hydra_Software_Devel/11   3/9/11 2:54p jgarrett
120 * SW7422-146: Fixing SRC lockup with decode stop/start
121 *
122 * Hydra_Software_Devel/10   2/28/11 1:28p jgarrett
123 * SW7422-146: Filter graph reworked to remove mixer dependencies
124 *
125 * Hydra_Software_Devel/9   2/22/11 5:43p jgarrett
126 * SW7422-146: Implemented type renaming based on filter graph review
127 * comments
128 *
129 * Hydra_Software_Devel/8   2/10/11 5:45p gskerl
130 * SW7422-146: Changed calling sequence for the audio output setMclk_isr
131 * callbacks
132 *
133 * Hydra_Software_Devel/7   1/21/11 10:58a jgarrett
134 * SW7422-146: Fixing second mixer port offset on 7422/7425
135 *
136 * Hydra_Software_Devel/6   1/19/11 7:20p jgarrett
137 * SW7422-146: Fixing volume register offset on 734x
138 *
139 * Hydra_Software_Devel/5   1/19/11 2:58p jgarrett
140 * SW7422-146: Initial decode/passthrough of ac3
141 *
142 * Hydra_Software_Devel/4   1/13/11 2:26p jgarrett
143 * SW7422-146: Adding 7346 APE support
144 *
145 * Hydra_Software_Devel/3   1/10/11 5:19p jgarrett
146 * SW7422-146: Adding ramp step APIs
147 *
148 * Hydra_Software_Devel/2   12/17/10 3:58p jgarrett
149 * SW7422-146: Nexus APE integration on 7422
150 *
151 * Hydra_Software_Devel/1   12/16/10 4:05p jgarrett
152 * SW7422-146: Initial compilable APE for 7422
153 *
154 ***************************************************************************/
155
156#include "bstd.h"
157#include "bkni.h"
158#include "bape.h"
159#include "bape_priv.h"
160
161BDBG_MODULE(bape_mixer);
162
163BDBG_OBJECT_ID(BAPE_Mixer);
164BDBG_OBJECT_ID(BAPE_OutputPort);
165
166/*************************************************************************/
167/* Generic mixer functions (independent of mixer type)                   */
168/*************************************************************************/
169void BAPE_Mixer_GetDefaultSettings(
170    BAPE_MixerSettings *pSettings   /* [out] */
171    )
172{
173    BDBG_ASSERT(NULL != pSettings);
174    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
175    pSettings->defaultSampleRate = 48000;
176    #if BAPE_CHIP_MAX_NCOS > 0
177    pSettings->outputNco = BAPE_Nco_e0;
178    #else
179    pSettings->outputNco = BAPE_Nco_eMax;       /* eMax => Don't use an NCO  */
180    #endif
181}
182
183/*************************************************************************/
184void BAPE_Mixer_GetDefaultAddInputSettings(
185    BAPE_MixerAddInputSettings *pSettings   /* [out] */
186    )
187{
188    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
189}
190
191/*************************************************************************/
192unsigned BAPE_Mixer_P_FindInputIndex(BAPE_MixerHandle handle, BAPE_Connector input)
193{
194    unsigned i;
195
196    for ( i = 0; i < BAPE_CHIP_MAX_MIXER_INPUTS; i++ )
197    {
198        if ( handle->inputs[i] == input )
199        {
200            return i;
201        }
202    }
203
204    return BAPE_MIXER_INPUT_INDEX_INVALID;
205}
206
207/*************************************************************************/
208void BAPE_Mixer_P_GetDefaultInputVolume(BAPE_MixerInputVolume *pVolume)
209{
210    unsigned i;
211    BKNI_Memset(pVolume, 0, sizeof(*pVolume));
212    for ( i = 0; i < BAPE_Channel_eMax; i++ )
213    {
214        pVolume->coefficients[i][i] = BAPE_VOLUME_NORMAL;
215    }
216}
217
218/*************************************************************************/
219/* Some functions more related to outputs than mixers.                   */
220/*************************************************************************/
221BERR_Code BAPE_GetOutputVolume(
222    BAPE_OutputPort output,
223    BAPE_OutputVolume *pVolume      /* [out] */
224    )
225{
226    BDBG_OBJECT_ASSERT(output, BAPE_OutputPort);
227    BDBG_ASSERT(NULL != pVolume);
228   
229    *pVolume = output->volume;
230    return BERR_SUCCESS;
231}
232
233/*************************************************************************/
234BERR_Code BAPE_SetOutputVolume(
235    BAPE_OutputPort output,
236    const BAPE_OutputVolume *pVolume
237    )
238{
239    BERR_Code errCode;
240
241    BDBG_OBJECT_ASSERT(output, BAPE_OutputPort);
242    BDBG_ASSERT(NULL != pVolume);
243
244    output->volume = *pVolume;
245    if ( output->mixer && output->mixer->running )
246    {
247        errCode = BAPE_Mixer_P_ApplyOutputVolume(output->mixer, output);
248        if ( errCode )
249        {
250            return BERR_TRACE(errCode);
251        }
252    }
253
254    return BERR_SUCCESS;
255}
256
257/*************************************************************************/
258void BAPE_GetOutputDelayStatus(
259    BAPE_OutputPort output,
260    BAPE_OutputDelayStatus *pStatus     /* [out] */
261    )
262{
263    BDBG_OBJECT_ASSERT(output, BAPE_OutputPort);
264    BDBG_ASSERT(NULL != pStatus);
265
266    pStatus->pathDelay = BAPE_CHIP_MAX_PATH_DELAY;
267    pStatus->additionalDelay = (output->mixer)?output->mixer->settings.outputDelay:0;   
268}   
269
270/*************************************************************************/
271/* Dispatchers for type-specific mixer functions                         */
272/*************************************************************************/
273BERR_Code BAPE_Mixer_Create(
274    BAPE_Handle deviceHandle,
275    const BAPE_MixerSettings *pSettings,
276    BAPE_MixerHandle *pHandle               /* [out] */
277    )
278{
279    BERR_Code errCode;
280    BAPE_MixerSettings defaultSettings;
281
282    BDBG_OBJECT_ASSERT(deviceHandle, BAPE_Device);
283    BDBG_ASSERT(NULL != pHandle);
284
285    *pHandle = NULL;
286
287    if ( NULL == pSettings )
288    {
289        BAPE_Mixer_GetDefaultSettings(&defaultSettings);
290        pSettings = &defaultSettings;
291    }
292
293    switch ( pSettings->type )
294    {
295    #if BAPE_CHIP_MAX_MIXERS
296    case BAPE_MixerType_eStandard:
297        errCode = BAPE_StandardMixer_P_Create( deviceHandle, pSettings, pHandle );
298        break;
299    #endif
300       
301    #if BAPE_CHIP_MAX_BYPASS_MIXERS
302    case BAPE_MixerType_eBypass:
303        errCode = BAPE_BypassMixer_P_Create( deviceHandle, pSettings, pHandle );
304        break;
305    #endif
306       
307    #if BAPE_CHIP_MAX_DSP_MIXERS
308    case BAPE_MixerType_eDsp:
309        errCode = BAPE_DspMixer_P_Create( deviceHandle, pSettings, pHandle );
310        break;
311    #endif
312   
313    default:
314        BDBG_ERR(("MixerType %u is invalid or not supported", pSettings->type ));
315        errCode = BERR_INVALID_PARAMETER;
316        break;
317    }
318
319    return BERR_TRACE(errCode);
320}
321
322/*************************************************************************/
323void BAPE_Mixer_Destroy(
324    BAPE_MixerHandle handle
325    )
326{
327    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
328    BDBG_ASSERT(NULL != handle->interface);
329
330    if(handle->interface->destroy) {
331        handle->interface->destroy(handle);
332    } else {
333        (void) BERR_TRACE(BERR_NOT_SUPPORTED);
334    }
335}
336
337/**************************************************************************/
338void BAPE_Mixer_GetSettings(
339    BAPE_MixerHandle hMixer,
340    BAPE_MixerSettings *pSettings   /* [out] */
341    )
342{
343    BDBG_OBJECT_ASSERT(hMixer, BAPE_Mixer);
344    BDBG_ASSERT(NULL != pSettings);
345    *pSettings = hMixer->settings;
346}
347
348/**************************************************************************/
349BERR_Code BAPE_Mixer_SetSettings(
350    BAPE_MixerHandle hMixer,
351    const BAPE_MixerSettings *pSettings
352    )
353{
354    BDBG_OBJECT_ASSERT(hMixer, BAPE_Mixer);
355    BDBG_ASSERT(NULL != pSettings);
356    BDBG_ASSERT(NULL != hMixer->interface);
357
358    if ( hMixer->running )
359    {
360        BDBG_ERR(("Cannot change mixer settings while running.  Please stop all inputs."));
361        return BERR_TRACE(BERR_NOT_SUPPORTED);
362    }
363    if ( hMixer->settings.type != pSettings->type )
364    {
365        BDBG_ERR(("Mixer type cannot be changed on the fly."));
366        return BERR_TRACE(BERR_NOT_SUPPORTED);
367    }
368
369    if ( hMixer->interface->setSettings )
370    {
371        return hMixer->interface->setSettings(hMixer, pSettings);
372    }
373    else
374    {   
375        BDBG_ERR(("This mixer type does not support changing settings on the fly."));
376        return BERR_TRACE(BERR_NOT_SUPPORTED);
377    }   
378}
379
380/*************************************************************************/
381BERR_Code BAPE_Mixer_Start(
382    BAPE_MixerHandle handle
383    )
384{
385    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
386    BDBG_ASSERT(NULL != handle->interface);
387   
388    if(handle->interface->start) {
389        return handle->interface->start(handle);
390    } else {
391        return BERR_TRACE(BERR_NOT_SUPPORTED);
392    }
393}
394
395/*************************************************************************/
396void BAPE_Mixer_Stop(
397    BAPE_MixerHandle handle
398    )
399{
400    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
401    BDBG_ASSERT(NULL != handle->interface);
402
403    if(handle->interface->stop) {
404        handle->interface->stop(handle);
405    } else {
406        (void) BERR_TRACE(BERR_NOT_SUPPORTED);
407    }
408}
409
410/*************************************************************************/
411BERR_Code BAPE_Mixer_AddInput(
412    BAPE_MixerHandle handle,
413    BAPE_Connector input,
414    const BAPE_MixerAddInputSettings *pSettings     /* Optional, pass NULL for default settings */
415    )
416{
417    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
418    BDBG_ASSERT(NULL != handle->interface);
419
420    if(handle->interface->addInput) {
421        return handle->interface->addInput(handle, input, pSettings);
422    } else {
423        return BERR_TRACE(BERR_NOT_SUPPORTED);
424    }
425}
426
427/*************************************************************************/
428BERR_Code BAPE_Mixer_RemoveInput(
429    BAPE_MixerHandle handle,
430    BAPE_Connector input
431    )
432{
433    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
434    BDBG_ASSERT(NULL != handle->interface);
435
436    if(handle->interface->removeInput) {
437        return handle->interface->removeInput(handle, input);
438    } else {
439        return BERR_TRACE(BERR_NOT_SUPPORTED);
440    }
441}
442
443/*************************************************************************/
444BERR_Code BAPE_Mixer_RemoveAllInputs(
445    BAPE_MixerHandle handle
446    )
447{
448    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
449    BDBG_ASSERT(NULL != handle->interface);
450
451    if(handle->interface->removeAllInputs) {
452        return handle->interface->removeAllInputs(handle);
453    } else {
454        return BERR_TRACE(BERR_NOT_SUPPORTED);
455    }
456}
457
458/*************************************************************************/
459BERR_Code BAPE_Mixer_AddOutput(
460    BAPE_MixerHandle handle,
461    BAPE_OutputPort output
462    )
463{
464    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
465    BDBG_ASSERT(NULL != handle->interface);
466
467    if(handle->interface->addOutput) {
468        return handle->interface->addOutput(handle, output);
469    } else {
470        return BERR_TRACE(BERR_NOT_SUPPORTED);
471    }
472}
473
474/*************************************************************************/
475BERR_Code BAPE_Mixer_RemoveOutput(
476    BAPE_MixerHandle handle,
477    BAPE_OutputPort output
478    )
479{
480    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
481    BDBG_ASSERT(NULL != handle->interface);
482
483    if(handle->interface->removeOutput) {
484        return handle->interface->removeOutput(handle, output);
485    } else {
486        return BERR_TRACE(BERR_NOT_SUPPORTED);
487    }
488}
489
490/*************************************************************************/
491BERR_Code BAPE_Mixer_RemoveAllOutputs(
492    BAPE_MixerHandle handle
493    )
494{
495    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
496    BDBG_ASSERT(NULL != handle->interface);
497
498    if(handle->interface->removeAllOutputs) {
499        return handle->interface->removeAllOutputs(handle);
500    } else {
501        return BERR_TRACE(BERR_NOT_SUPPORTED);
502    }
503}
504
505/*************************************************************************/
506BERR_Code BAPE_Mixer_GetInputVolume(
507    BAPE_MixerHandle handle,
508    BAPE_Connector input,
509    BAPE_MixerInputVolume *pVolume      /* [out] */
510    )
511{
512    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
513    BDBG_ASSERT(NULL != handle->interface);
514
515    if(handle->interface->getInputVolume) {
516        return handle->interface->getInputVolume(handle, input, pVolume);
517    } else {
518        return BERR_TRACE(BERR_NOT_SUPPORTED);
519    }
520}
521
522/*************************************************************************/
523BERR_Code BAPE_Mixer_SetInputVolume(
524    BAPE_MixerHandle handle,
525    BAPE_Connector input,
526    const BAPE_MixerInputVolume *pVolume
527    )
528{
529    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
530    BDBG_ASSERT(NULL != handle->interface);
531
532    if(handle->interface->setInputVolume) {
533        return handle->interface->setInputVolume(handle, input, pVolume);
534    } else {
535        return BERR_TRACE(BERR_NOT_SUPPORTED);
536    }
537}
538
539/*************************************************************************/
540BERR_Code BAPE_Mixer_P_ApplyOutputVolume(BAPE_MixerHandle handle, BAPE_OutputPort output)
541{
542    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
543    BDBG_ASSERT(NULL != handle->interface);
544
545    if(handle->interface->applyOutputVolume) {
546        return handle->interface->applyOutputVolume(handle, output);
547    } else {
548        return BERR_TRACE(BERR_NOT_SUPPORTED);
549    }
550}
551
552void BAPE_Mixer_GetConnector(
553    BAPE_MixerHandle handle,
554    BAPE_Connector *pConnector /* [out] */
555    )
556{
557    BDBG_OBJECT_ASSERT(handle, BAPE_Mixer);
558    BDBG_ASSERT(NULL != pConnector);
559    *pConnector = &handle->pathNode.paths[0].connector;
560}
561
562/*************************************************************************/
563const char *BAPE_Mixer_P_MclkSourceToText( BAPE_MclkSource mclkSource )
564{
565    return ( mclkSource == BAPE_MclkSource_eNone       ?  "None"      : 
566             mclkSource == BAPE_MclkSource_ePll0       ?  "Pll0"      : 
567             mclkSource == BAPE_MclkSource_ePll1       ?  "Pll1"      : 
568             mclkSource == BAPE_MclkSource_ePll2       ?  "Pll2"      : 
569             mclkSource == BAPE_MclkSource_eHifidac0   ?  "Hifidac0"  : 
570             mclkSource == BAPE_MclkSource_eHifidac1   ?  "Hifidac1"  : 
571             mclkSource == BAPE_MclkSource_eHifidac2   ?  "Hifidac2"  : 
572             mclkSource == BAPE_MclkSource_eNco0       ?  "Nco0"      : 
573             mclkSource == BAPE_MclkSource_eNco1       ?  "Nco1"      : 
574             mclkSource == BAPE_MclkSource_eNco2       ?  "Nco2"      : 
575             mclkSource == BAPE_MclkSource_eMax        ?  "<eMax>"    : 
576                                                          "<Undefined>" );
577
578    BDBG_CASSERT((int)BAPE_MclkSource_eMax == (int)10);  /* This should cause compile error if somebody adds to the BAPE_MclkSource enum */
579}
580/*************************************************************************/
581
582
583#if BDBG_DEBUG_BUILD
584
585BDBG_FILE_MODULE(bape_diag);
586
587static BERR_Code BAPE_Mixer_P_PrintOutputPortObjectInfo( BAPE_OutputPortObject  *pOutputPortObject, int level)
588{
589    BERR_Code errCode=BERR_SUCCESS;
590
591    #if 0
592       
593            /* When we find a way to get info about the specific output device, then
594             * we can print info specific to the output type like this:
595             */
596       
597            if ( BAPE_OutputPortType_eI2sOutput == pOutputPortObject->type  )
598            {
599                BAPE_I2sOutputHandle  i2sOutputHandle = pOutputPortObject->pHandle;
600       
601                BDBG_MODULE_LOG(bape_diag,("%*sOutputPort: %s (%p) muted:%u Fs:%u enab:%u", level*4, "",
602                                            pOutputPortObject->pName, (void *) pOutputPortObject,
603                                            pOutputPortObject->volume.muted  ));
604            }
605            else
606    #endif
607    {
608        BDBG_LOG(("%*sOutputPort: %s (%p)", level*4, "", 
609        pOutputPortObject->pName, (void *) pOutputPortObject  ));
610    }
611
612    return( errCode );
613}
614
615
616BERR_Code BAPE_Mixer_P_PrintInputPortInfo( BAPE_PathNode *pPathNode, int level, int index)
617{
618    BERR_Code errCode=BERR_SUCCESS;
619    BAPE_InputPort  inputPort = NULL;
620    BAVC_XptContextMap *pContextMap = NULL;
621    BSTD_UNUSED(index);
622
623    /* This function only works for nodes that can have an input port connected to them.
624     * That means either a decoder, or input capture nodes.   */
625    if ( BAPE_PathNodeType_eDecoder == pPathNode->type  )
626    {
627        BAPE_DecoderHandle      decoderHandle;
628
629        /* The node is a decoder, so try to get either the input port or the RAVE context map.  */
630        decoderHandle = pPathNode->pHandle;
631        if (decoderHandle)
632        {
633            if (decoderHandle->startSettings.inputPort)
634            {
635                inputPort = decoderHandle->startSettings.inputPort;
636            }
637            else if (decoderHandle->startSettings.pContextMap)
638            {
639                pContextMap = &decoderHandle->contextMap;   
640            }
641        }
642    }
643    else if ( BAPE_PathNodeType_eInputCapture == pPathNode->type    )
644    {
645        BAPE_InputCaptureHandle      inputCaptureHandle;
646
647        /* The node is an InputCapture, so get the connected InputPort.  */
648        inputCaptureHandle = pPathNode->pHandle;
649        if (inputCaptureHandle)
650        {
651            if (inputCaptureHandle->startSettings.input)
652            {
653                inputPort = inputCaptureHandle->startSettings.input;
654            }
655        }
656    }
657
658    if (inputPort)
659    {
660        /* Print out a line to describe the input port.  */
661        BDBG_LOG(("%*sInputPort: %s (%p) Pairs:%u Fs:%u Compr:%s", level*4, "", 
662                                    inputPort->pName,  (void *) inputPort,
663                                    inputPort->numChannelPairs, 
664                                    inputPort->sampleRate,
665                                    inputPort->compressed ? "TRUE" : "false" ));
666    }
667    else if (pContextMap)
668    {
669        /* For a RAVE context input, just print the context index.  */
670        BDBG_LOG(("%*sRAVE Context Index:%u", level*4, "", 
671                                    pContextMap->ContextIdx ));
672    }
673    return( errCode );
674}
675
676
677BERR_Code BAPE_Mixer_P_PrintNodeInfo( BAPE_PathNode *pPathNode, int level, int index)
678{
679    BERR_Code errCode=BERR_SUCCESS;
680    BSTD_UNUSED(index);
681
682    /*  BDBG_ERR(("%s : %d : pPathNode:%p  level:%d  index:%u", __FUNCTION__, __LINE__ , pPathNode, level, index )); */
683    if ( BAPE_PathNodeType_eDecoder == pPathNode->type  )
684    {
685        BAPE_DecoderHandle      decoderHandle;
686
687        decoderHandle = pPathNode->pHandle;
688        if (decoderHandle)
689        {
690            const BAPE_CodecAttributes  *pCodecAttributes = BAPE_P_GetCodecAttributes(decoderHandle->startSettings.codec);
691
692            BDBG_LOG(("%*sPathNode: %s (%p) Type:%s Codec:%s", level*4, "", 
693                                        pPathNode->pName,  (void *) pPathNode,   
694                                        BAPE_PathNode_P_PathNodeTypeToText(pPathNode->type), 
695                                        pCodecAttributes->pName ) );
696        }
697    }
698    else if ( BAPE_PathNodeType_eMixer == pPathNode->type  )
699    {
700        BAPE_MixerHandle mixerHandle = pPathNode->pHandle;
701        BAPE_OutputPortObject *pOutputPortObject;
702
703        BDBG_LOG(("%*sPathNode: %s (%p) Type:%s %s(%u) Pairs:%u Fs:%u MclkSource:%s", level*4, "", 
704                                    pPathNode->pName,  (void *) pPathNode,   
705                                    BAPE_PathNode_P_PathNodeTypeToText(pPathNode->type),
706                                    mixerHandle->running ? "RUNNING" : "stopped",
707                                    mixerHandle->running , 
708                                    mixerHandle->numChannelPairs,
709                                    mixerHandle->sampleRate,
710                                    BAPE_Mixer_P_MclkSourceToText(mixerHandle->mclkSource)  ));
711       
712        for ( pOutputPortObject = BLST_S_FIRST(&mixerHandle->outputList);
713              pOutputPortObject != NULL;
714              pOutputPortObject = BLST_S_NEXT(pOutputPortObject, node) )
715        {
716            level++;
717                BAPE_Mixer_P_PrintOutputPortObjectInfo( pOutputPortObject, level );
718            level--;
719        }
720
721    }
722    else
723    {
724        BDBG_LOG(("%*sPathNode: %s (%p) Type:%s ", level*4, "", 
725        pPathNode->pName,  (void *) pPathNode,   BAPE_PathNode_P_PathNodeTypeToText(pPathNode->type) ) );
726   
727    }
728    return( errCode );
729}
730
731
732static const char  *BAPE_Mixer_P_CheckBdbgEnabled(bool *enabled) {
733    *enabled = true;
734     return "";
735}
736
737
738BDBG_FILE_MODULE(bape_mixerprint);
739BERR_Code BAPE_Mixer_P_PrintMixers(BAPE_Handle deviceHandle)
740{
741    BERR_Code errCode=BERR_SUCCESS;
742    BAPE_MixerHandle mixer;
743    BAPE_PathNode   *pPathNode;
744    unsigned mixerIndex;
745    bool  dbug_enabled = false;
746
747    /* To determine if our debuglevel is enabled, we'll need to make two calls to BDBG_MODULE_MSG.  The first call
748     * is to make sure that the module gets registered, then the second will only evaluate the argument list
749     * if the BDBG level is enabled.
750     */ 
751    BDBG_MODULE_MSG(bape_mixerprint,("bape_mixerprint is enabled"));                                                      /* Make sure that bape_mixerprint is registered with BDBG   */
752    BDBG_MODULE_MSG(bape_mixerprint,("Printing Audio Filter Graph...%s", BAPE_Mixer_P_CheckBdbgEnabled(&dbug_enabled)));  /* Set dbug_enabled if bape_mixerprint is enabled           */
753    if (!dbug_enabled)
754    {
755        return BERR_SUCCESS;    /* if debug level not enabled, just return without printing */
756    }
757
758    for ( mixer = BLST_S_FIRST(&deviceHandle->mixerList), mixerIndex=0;
759          mixer != NULL;
760          mixer = BLST_S_NEXT(mixer, node), mixerIndex++ )
761    {
762        BDBG_MODULE_LOG(bape_diag,("==================  Mixer:%u (%p) Begin  =====================================",
763                                    mixerIndex, (void *) mixer ));
764
765        pPathNode = &mixer->pathNode;
766        BAPE_PathNode_P_EnumerateUpstreamPathNodes(pPathNode, 0, BAPE_Mixer_P_PrintNodeInfo );
767        BAPE_Mixer_P_PrintNodeInfo( pPathNode, 0, 0);
768        BAPE_PathNode_P_EnumerateDownstreamPathNodes(pPathNode, 0, BAPE_Mixer_P_PrintNodeInfo );
769
770        BDBG_MODULE_LOG(bape_diag,("===================  Mixer:%u (%p) End  ======================================",
771                                    mixerIndex, (void *) mixer ));
772
773        BDBG_MODULE_LOG(bape_diag,(""));
774    }
775
776    return( errCode );
777}
778
779
780BDBG_FILE_MODULE(bape_startprint);
781BERR_Code BAPE_Mixer_P_PrintDownstreamNodes(BAPE_PathNode *pPathNode)
782{
783    BERR_Code errCode=BERR_SUCCESS;
784    bool  dbug_enabled = false;
785
786    /* To determine if our debuglevel is enabled, we'll need to make two calls to BDBG_MODULE_MSG.  The first call
787     * is to make sure that the module gets registered, then the second will only evaluate the argument list
788     * if the BDBG level is enabled.
789     */ 
790    BDBG_MODULE_MSG(bape_startprint,("bape_startprint is enabled"));                                                 /* Make sure that bape_startprint is registered with BDBG   */
791    BDBG_MODULE_MSG(bape_startprint,("Printing Started Nodes...%s", BAPE_Mixer_P_CheckBdbgEnabled(&dbug_enabled)));  /* Set dbug_enabled if bape_startprint is enabled           */
792    if (!dbug_enabled)
793    {
794        return BERR_SUCCESS;    /* if debug level not enabled, just return without printing */
795    }
796
797        BDBG_MODULE_LOG(bape_diag,("==================  Started node:%s (%p) Begin  =====================================",
798                                    pPathNode->pName, pPathNode));
799
800        /* First, try to print the InputPort or RAVE context that's attached to our starting node. */
801        BAPE_Mixer_P_PrintInputPortInfo(pPathNode, 0, 0);
802
803        /* Then print the starting node... */
804        BAPE_Mixer_P_PrintNodeInfo( pPathNode, 1, 0);
805        /* Then recurse down through the remaining connected nodes.  */
806        BAPE_PathNode_P_EnumerateDownstreamPathNodes(pPathNode, 1, BAPE_Mixer_P_PrintNodeInfo );
807
808        BDBG_MODULE_LOG(bape_diag,("==================  Started node:%s (%p) End  =====================================",
809                                    pPathNode->pName, pPathNode));
810
811        BDBG_MODULE_LOG(bape_diag,(""));
812
813    return( errCode );
814}
815
816
817#else  /* BDBG_DEBUG_BUILD is false */
818BERR_Code BAPE_Mixer_P_PrintMixers(BAPE_Handle deviceHandle)
819{
820    BERR_Code errCode=BERR_SUCCESS;
821    BSTD_UNUSED(deviceHandle);
822    return errCode;
823}
824
825#endif /* BDBG_DEBUG_BUILD */
826
827
Note: See TracBrowser for help on using the repository browser.