source: svn/newcon3bcm2_21bu/magnum/syslib/pcrlib/7552/bpcrlib.h @ 74

Last change on this file since 74 was 74, checked in by phkim, 10 years ago
  1. phkim
  2. zasc
  3. 변경 내용
    • CT_ChMapUpdatePMTAC3AudioDescriptor 메모리 leak 버그 수정
  • Property svn:executable set to *
File size: 21.4 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2011, 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: bpcrlib.h $
11 * $brcm_Revision: Hydra_Software_Devel/32 $
12 * $brcm_Date: 6/27/11 4:41p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/syslib/pcrlib/7038/bpcrlib.h $
19 *
20 * Hydra_Software_Devel/32   6/27/11 4:41p bandrews
21 * SW7425-654: merge to main
22 *
23 * Hydra_Software_Devel/SW7425-654/2   6/24/11 12:25a bandrews
24 * SW7425-654: add pairing to config
25 *
26 * Hydra_Software_Devel/SW7425-654/1   6/23/11 11:41p bandrews
27 * SW7425-654: add non-real-time behavior and setting to pcrlib
28 *
29 * Hydra_Software_Devel/31   11/12/10 5:47p bandrews
30 * SW35230-2125: renamed config option to refresh_stc_on_invalidate, fixed
31 * warning
32 *
33 * Hydra_Software_Devel/30   11/11/10 9:00p bandrews
34 * SW35230-2125: allow pcrlib to seed STC from lowest PTS during
35 * invalidate
36 *
37 * Hydra_Software_Devel/29   7/23/08 3:46p jgarrett
38 * PR 39452: Merging to main branch
39 *
40 * Hydra_Software_Devel/Nexus_Audio_Descriptors/1   5/15/08 4:13p jgarrett
41 * PR 42360: Adding tertiary decoder for audio descriptors
42 *
43 * Hydra_Software_Devel/28   2/15/08 9:50p bandrews
44 * PR39635: Update to handle non-TSM tsm mode
45 *
46 * Hydra_Software_Devel/27   10/17/07 5:45p bandrews
47 * PR33892: Fixed by using dropped frame count to determine errors
48 * unrecoverable by DM and recover in PCRlib
49 *
50 * Hydra_Software_Devel/26   9/19/07 4:10p bandrews
51 * PR33851: Add decoder flush request when outside sync limit
52 *
53 * Hydra_Software_Devel/25   8/27/07 8:07p bandrews
54 * PR33851: Audio master mode and prep for adaptive tsm
55 *
56 * Hydra_Software_Devel/24   6/28/07 8:01p bandrews
57 * PR31796: PCRlib implementation of audio and video master modes
58 *
59 * Hydra_Software_Devel/23   12/4/06 1:39p erickson
60 * PR26295: only call BXPT_PcrOffset_RegenOffset_isr on request_stc, not
61 * pts_error. this requires a new param to UpdateStc.
62 *
63 * Hydra_Software_Devel/22   10/2/06 4:24p vsilyaev
64 * PR 23826: Added functions to allow user control STC
65 *
66 * Hydra_Software_Devel/21   8/25/06 3:21p jjordan
67 * PR23128: fix build for non-IP STB
68 *
69 * Hydra_Software_Devel/20   8/4/06 12:46p erickson
70 * PR23098: convert b_stc and b_delta_stc to uint32_t and int32_t. these
71 * are standard values for PTS math. also made BPCRlib_StcDiff_isr
72 * unconditionally public.
73 *
74 * Hydra_Software_Devel/19   3/1/06 3:26p jjordan
75 * PR18981: fix "live playback" and add config option IP_USE_LIVE_PLAYBACK
76 *
77 * Hydra_Software_Devel/18   2/28/06 1:47p jjordan
78 * PR18981: PR18981: prototype "live playback"
79 *
80 * Hydra_Software_Devel/17   2/3/06 3:50p vsilyaev
81 * PR 18642: Update PCRlibrary to support playback of constant bitrate
82 * streams
83 *
84 * Hydra_Software_Devel/PR18642/2   1/27/06 2:28p vsilyaev
85 * PR18642: Added code to use PCR for STC update
86 *
87 * Hydra_Software_Devel/PR18642/1   1/19/06 6:15p vsilyaev
88 * PR18642: Use PTS offset to control buffer depth in the decoders
89 *
90 * Hydra_Software_Devel/16   12/20/05 2:12p vsilyaev
91 * PR 18642: Added BPCRlib_Channel_LoadStc function to load user defined
92 * STC
93 *
94 * Hydra_Software_Devel/15   12/15/05 3:58p vsilyaev
95 * PR 18642: Added support for the PTS offset and CDB check
96 *
97 * Hydra_Software_Devel/14   8/29/05 6:23p vsilyaev
98 * PR 16685,PR15967: Added use of UpdateStc function.
99 *
100 * Hydra_Software_Devel/13   8/26/05 12:32p erickson
101 * PR15967: Added Invalidate function to cover decoder based trickmodes
102 *
103 * Hydra_Software_Devel/12   8/17/05 7:56p vsilyaev
104 * PR 15967: Added BPCRlib_Channel_AudioPtsError_isr function.
105 *
106 * Hydra_Software_Devel/11   8/10/05 4:14p vsilyaev
107 * PR 15967: Removed references to BMVD_.
108 *
109 * Hydra_Software_Devel/10   8/9/05 2:31p vsilyaev
110 * PR 15967: Use both aux transport and decoder to access STC.
111 *
112 * Hydra_Software_Devel/9   6/28/05 1:16p vsilyaev
113 * PR 15697: Improved interface to update STC.
114 *
115 * Hydra_Software_Devel/8   6/24/05 3:54p vsilyaev
116 * PR 15967: Use audio/video interface to read STC and PTS.
117 *
118 * Hydra_Software_Devel/7   3/16/05 11:09a vsilyaev
119 * PR 14413:  Removed reference to xpt_record.h (it's not needed for 7038
120 * as well).
121 *
122 * Hydra_Software_Devel/6   3/4/04 5:03p vsilyaev
123 * PR 8915: Added VideoPtsError handler
124 *
125 * Hydra_Software_Devel/5   2/1/04 6:01p vsilyaev
126 * PR 8915: Use video specific structur for passing in PTS value (video
127 * PTS could be either coded(a real one) or iterpolated.
128 *
129 * Hydra_Software_Devel/4   12/10/03 6:35p vsilyaev
130 * PR 8915: Changed BPCRlib_Channel_GetConfig to return a void.
131 *
132 * Hydra_Software_Devel/3   12/9/03 4:13p vsilyaev
133 * PR 8915:Added comments into for arguments of XXX_isr functions.
134 *
135 * Hydra_Software_Devel/2   12/9/03 2:30p vsilyaev
136 * PR 8915: PCRLib module for 7038.
137 *
138 * Hydra_Software_Devel/1   12/3/03 6:38p vsilyaev
139 * 7038 PCRlib module
140 *
141 ***************************************************************************/
142#ifndef BPCRLIB_H_
143#define BPCRLIB_H_
144
145#include "bxpt.h"
146#include "bxpt_pcr.h"
147#include "bchp.h"
148#include "bavc.h"
149#include "bkni.h"
150
151/*= Module Overview *********************************************************
152Overview
153PCRlib module manages local timebase, aka STC (System Time Clock) of
154a decoder channel. Decoder channel is a combination of single MPEG video
155decoder and audio decoder. Task of PCRlib is to keep decoders reference
156time in sync with each other (to maintain lip-sync) and with incoming
157MPEG stream.
158
159User controls PCRLib module by connecting video and audio decoders
160into the single timebase. For PVR type of applications users could
161choose to connect record channel. For systems with dual audio
162output user have to connect secondary audio decoder to the
163selected timebase channel.  For systems with three audio decodes,
164the user will need to connect the tertiary audio decoder as well.
165
166***************************************************************************/
167
168/* This tyoe is used to represent instance of PCRLib module */
169typedef struct BPCRlib_P_Handle *BPCRlib_Handle;
170
171/***************************************************************************
172Summary:
173    Activates PCRLib module
174Description:
175    This function initializes internal structures of the PCRLib module
176    and returns handle to the module instance.
177See Also:
178    BPCRlib_Close
179Returns:
180    BERR_SUCCESS                - if successful
181    BERR_INVALID_PARAMETER      - Bad input parameter
182***************************************************************************/
183BERR_Code
184BPCRlib_Open(
185        BPCRlib_Handle *handle, /* [out] the BPCRlib handle */
186        BCHP_Handle hChip   /* [in] the chip handle */
187        );
188
189/***************************************************************************
190Summary:
191    Deactivates PCRlib module
192Description:
193    This function release all resources allocated during call to
194    the BPCRlib_Open function.
195See Also:
196    BPCRlib_Open
197Returns:
198    N/A
199***************************************************************************/
200void 
201BPCRlib_Close(
202        BPCRlib_Handle handle /* [in] the BPCRlib handle */
203        );
204
205/***************************************************************************
206Summary:
207    Standard decoder interface for time-related functions
208***************************************************************************/
209typedef struct BPCRlib_StcDecIface {
210    BERR_Code (*getPts)(void *dec, BAVC_PTSInfo *pts);
211    BERR_Code (*getStc)(void *trp, void *dec, uint32_t *stc);
212    BERR_Code (*getCdbLevel)(void *dec, unsigned *level);
213    BERR_Code (*setStc)(void *trp, void *dec, bool dss, uint32_t stc);
214    BERR_Code (*updateStc)(void *trp, bool is_request_stc);
215    bool useAuxTrp;
216} BPCRlib_StcDecIface;
217
218/***************************************************************************
219Summary:
220    <Needs summary>
221***************************************************************************/
222typedef enum BPCRlib_Mode {
223    BPCRlib_Mode_eAutoPts,
224    BPCRlib_Mode_eConstantDelay
225} BPCRlib_Mode;
226
227/***************************************************************************
228Summary:
229    Synchronization mode
230***************************************************************************/
231typedef enum BPCRlib_TsmMode
232{
233    BPCRlib_TsmMode_eSTCMaster = 0,             /* STC is seeded with either the video or audio PTS, depending on which decoder makes an STC request first */
234    BPCRlib_TsmMode_eVideoMaster,           /* STC is seeded with the video PTS */
235    BPCRlib_TsmMode_eAudioMaster,           /* STC is seeded with the audio PTS */
236    BPCRlib_TsmMode_eOutputMaster,          /* No tsm is performed.  Output clock pulls data through decoder.  Also called VSYNC mode. */
237    BPCRlib_TsmMode_eMax
238} BPCRlib_TsmMode;
239
240/***************************************************************************
241Summary: 
242    This structure is used for run-time configuration of PCRLib channel
243Description:
244    This structure has a information about managed timebase channel.
245    It's an user role to fill in this structure with values appropriate for
246    desired configuration.
247***************************************************************************/
248
249typedef struct BPCRlib_Config {
250    bool playback; /* true if PCRlib channel is used to manage playback type of sources, false otherwise */
251    BAVC_StreamType stream; /* Type of the managed stream */
252    void *audio; /* Audio decoder handle for the primary audio channel */
253    const BPCRlib_StcDecIface *audio_iface; /* interface to control the primary audio decoder */
254    void *video; /* Video decoder handle */
255    const BPCRlib_StcDecIface *video_iface; /* interface to control the video decoder */
256    void *secondary_audio; /* Audio decode handle for the secondary audio channel */
257    const BPCRlib_StcDecIface *secondary_audio_iface; /* interface to control the secondary audio decoder */
258    void *tertiary_audio; /* Audio decode handle for the tertiary audio channel */
259    const BPCRlib_StcDecIface *tertiary_audio_iface; /* interface to control the tertiary audio decoder */
260    void *aux_transport; /* pointer for the auxilary transport engine */
261    unsigned video_cdb_level; /* threshold for the video decoder's  compressed buffer, this is used to detect underflow condition in the decoder */
262    int video_pts_offset; /* this offset is used in playback mode, when STC initially loaded from the video PTS, 45KHz units */
263    int video_stc_discard; /* this delta is a discard threashold between video PTS and STC, 45KHz units */
264    unsigned audio_cdb_level; /* threshold for the video decoder's  compressed buffer, this is used to detect underflow condition in the decoder */
265    int audio_pts_offset; /* this offset is used in playback mode, when STC initially loaded from the audio PTS, 45KHz units */
266    int audio_stc_discard; /* this delta is a discard threashold between audio PTS and STC, 45KHz units  */
267    int pcr_offset; /* offset between PCR and STC. thise offset is used to set an additional dealy in the decoders in order to compoensate fro the jitter, 45KHz units */
268    int pcr_discard; /* threshold to discard PCR-PTS , to discard PCR value , 45KHz units */
269    BPCRlib_Mode mode; /* operation mode for the PCR channel */
270    bool is_playback_ip; /* true if PCRlib channel is used to manage IP playback type of sources, false otherwise */
271    BPCRlib_TsmMode tsm_mode; /* allows the user to control which decoder will control the STC --> defaults to whoever requests an STC first */
272    unsigned int sync_limit; /* the limit outside of which the decoders will not apply master mode TSM */
273    BKNI_EventHandle flush; /* requests that decoder CDBs be flushed */
274    uint32_t consecutive_pts_error_limit; /* how many consecutive pts errors before we do something different */
275    bool refresh_stc_on_invalidate; /* force a refresh of the STC when invalidate is called, defaults true */
276    bool non_real_time; /* causes various changes to behavior when in non real time mode */
277    bool paired; /* causes changes to behavior when paired with another pcrlib instance */
278} BPCRlib_Config;
279
280/* This tyoe is used to control PCRLib initial configuration */
281typedef void *BPCRlib_ChannelSettings;
282
283/***************************************************************************
284Summary: 
285    This function initializes PCRlib channel initial configuration
286Description:
287    This function is used to populate channel initial configuration
288    with default parameters.
289Returns:
290    BERR_SUCCESS                - if successful
291***************************************************************************/
292BERR_Code BPCRlib_Channel_GetChannelDefSettings(
293        BPCRlib_Handle handle,  /* [in] PCRlib handle */
294        BPCRlib_ChannelSettings *config /* [out] default PCRlib channel settings */
295    );
296
297/* This tyoe is used to represent instance of the PCRlib channel */
298typedef struct BPCRlib_P_Channel *BPCRlib_Channel;
299
300/***************************************************************************
301Summary:
302    Activates PCRlib channel
303Description:
304    This function initializes internal structures of the PCRLib channel
305    and returns handle to the channel instance.
306See Also:
307    BPCRlib_DestroyChannel
308Returns:
309    BERR_SUCCESS                - if successful
310    BERR_INVALID_PARAMETER      - Bad input parameter
311***************************************************************************/
312BERR_Code
313BPCRlib_Channel_Create(
314        BPCRlib_Handle handle,  /* [in] PCRlib handle */
315        BXPT_PCR_Handle pcr,    /* [in] XPT_PCR handle */
316        BPCRlib_Channel *channel, /* [out] PCRlib channel handle */
317        const BPCRlib_ChannelSettings *settings /* [in[ PCRlib channel configuration */
318    );
319
320/***************************************************************************
321Summary:
322    Deactivates PCRlib channel
323Description:
324    This function release all resources allocated during call to
325    the BPCRlib_Channel_Create function.
326See Also:
327    BPCRlib_Channel_Create
328Returns:
329    N/A
330***************************************************************************/
331void
332BPCRlib_Channel_Destroy(
333        BPCRlib_Channel channel /* [in] PCRlib channel handle */
334    );
335
336/***************************************************************************
337Summary:
338    Get current configuration for PCRlib channel
339Description:
340    This function is used to retrieve current configuration of the PCRlib channel
341See Also:
342    BPCRlib_Channel_SetConfig
343Returns:
344    BERR_SUCCESS                - if successful
345***************************************************************************/
346void
347BPCRlib_Channel_GetConfig(
348        BPCRlib_Channel channel, /* [in] PCRlib channel handle */
349        BPCRlib_Config *config /* [out] current configuration of the PCRlib channel  */
350        );
351
352/***************************************************************************
353Summary:
354    Set new configuration to PCRlib channel
355Description:
356    This function is used to sent new configuration to the PCRlib channel
357See Also:
358    BPCRlib_Channel_SetConfig
359Returns:
360    BERR_SUCCESS                - if successful
361    BERR_INVALID_PARAMETER      - Bad input parameter
362***************************************************************************/
363BERR_Code
364BPCRlib_Channel_SetConfig(
365        BPCRlib_Channel channel,/* [in] PCRlib channel handle */
366        const BPCRlib_Config *config /* [out] new configuration for the PCRlib channel  */
367        );
368
369/***************************************************************************
370Summary:
371    Invalidates state of PCRlib channel
372Description:
373    This function is used to invalidate state of all decoders attached to the PCRlib channels, usually it cases
374    to reload STC to the decoders on earliest opportunity.
375See Also:
376    BPCRlib_Channel_SetConfig
377Returns:
378    BERR_SUCCESS                - if successful
379    BERR_INVALID_PARAMETER      - Bad input parameter
380***************************************************************************/
381BERR_Code
382BPCRlib_Channel_Invalidate(
383        BPCRlib_Channel channel /* [in] PCRlib channel handle */
384        );
385
386/***************************************************************************
387Summary:
388    Update STC in audio decoder
389Description:
390    This function shall be called by an user when audio decoder
391    has requested STC. Usually user have to install ISR callback
392    and call this function from a callback.
393See Also:
394    BPCRlib_Channel_SetConfig, BPCRlib_Channel_VideoRequestStc_isr
395Returns:
396    BERR_SUCCESS                - if successful
397    BERR_INVALID_PARAMETER      - Bad input parameter
398***************************************************************************/
399BERR_Code
400BPCRlib_Channel_AudioRequestStc_isr(
401    BPCRlib_Handle handle, /* [in] PCRlib channel handle */
402    void *audio,           /* [in] audio decoder handle */
403    uint32_t audio_pts     /* [in] last PTS from the audio stream, in 45KHz units */
404    );
405
406/***************************************************************************
407Summary:
408    Update STC in video decoder
409Description:
410    This function shall be called by an user when video decoder
411    has requested STC. Usually user have to install ISR callback
412    and call this function from a callback.
413See Also:
414    BPCRlib_Channel_SetConfig, BPCRlib_Channel_AudioRequestStc_isr
415Returns:
416    BERR_SUCCESS                - if successful
417    BERR_INVALID_PARAMETER      - Bad input parameter
418***************************************************************************/
419BERR_Code
420BPCRlib_Channel_VideoRequestStc_isr(
421    BPCRlib_Handle handle, /* [in] PCRlib channel handle */
422    void *video, /* [in] video decoder handle */
423    const BAVC_PTSInfo *video_pts /* [in] last PTS from the video stream, in 45KHz units */
424    );
425
426/***************************************************************************
427Summary:
428    Resynchronize video decoder
429Description:
430    This function shall be called by an user when video decoder
431    has received PTS Error. Usually user have to install ISR callback
432    and call this function from a callback.
433See Also:
434    BPCRlib_Channel_SetConfig, BPCRlib_Channel_VideoRequestStc_isr
435Returns:
436    BERR_SUCCESS                - if successful
437    BERR_INVALID_PARAMETER      - Bad input parameter
438***************************************************************************/
439BERR_Code
440BPCRlib_Channel_VideoPtsError_isr(
441    BPCRlib_Handle handle, /* [in] PCRlib channel handle */
442    void *video, /* [in] video decoder handle */
443    const BAVC_PTSInfo *video_pts, /* [in] last PTS from the video stream, in 45KHz units */
444    uint32_t video_stc /* [in] snapshot value of STC from the video decoder, in 45KHz units */ 
445    );
446
447/***************************************************************************
448Summary:
449    Resynchronize audio decoder
450Description:
451    This function shall be called by an user when video decoder
452    has received PTS Error. Usually user have to install ISR callback
453    and call this function from a callback.
454See Also:
455    BPCRlib_Channel_SetConfig, BPCRlib_Channel_AudioRequestStc_isr
456Returns:
457    BERR_SUCCESS                - if successful
458    BERR_INVALID_PARAMETER      - Bad input parameter
459***************************************************************************/
460BERR_Code
461BPCRlib_Channel_AudioPtsError_isr(
462    BPCRlib_Handle handle, /* [in] PCRlib channel handle */
463    void *audio, /* [in] audio decoder handle */
464    const BAVC_PTSInfo *audio_pts, /* [in] last PTS from the audio stream, in 45KHz units */
465    uint32_t audio_stc /* [in] snapshot value of STC from the audio decoder, in 45KHz units */ 
466    );
467
468/***************************************************************************
469Summary:
470    Set new STC
471Description:
472    This function is used to update STC value for the PCRLib channel
473See Also:
474    BPCRlib_Channel_GetStc
475Returns:
476    BERR_SUCCESS                - if successful
477    BERR_INVALID_PARAMETER      - Bad input parameter
478***************************************************************************/
479BERR_Code
480BPCRlib_Channel_PcrUpdate(
481        BPCRlib_Channel channel,/* [in] PCRlib channel handle */
482        uint32_t stc/* [in] new stc */
483        );
484
485/***************************************************************************
486Summary:
487    Get current STC
488Description:
489    This function is used to retrieve STC  value for the PCRLib channel
490See Also:
491    BPCRlib_Channel_PcrUpdate
492Returns:
493    BERR_SUCCESS                - if successful
494    BERR_INVALID_PARAMETER      - Bad input parameter
495***************************************************************************/
496BERR_Code
497BPCRlib_Channel_GetStc(BPCRlib_Channel channel, uint32_t *stc);
498
499/***************************************************************************
500Summary:
501    Calculate STC difference
502Description:
503    This function takes stc in the 45KHz domain (MPEG) or 27MHz domain (DSS)
504    as 32 bit unsigned and returns delta in the 22.5KHz domain, 32 bit signed
505Returns:
506
507***************************************************************************/
508int32_t BPCRlib_StcDiff_isr(bool dss, uint32_t stc1, uint32_t stc2);
509
510/***************************************************************************
511Summary:
512    Check to see if PCR discontinuity has occured
513Description:
514Returns:
515    BERR_SUCCESS                - if successful
516    BERR_INVALID_PARAMETER      - Bad input parameter
517***************************************************************************/
518BERR_Code
519BPCRlib_HasPcrDisco(
520    BPCRlib_Handle handle, /* [in] PCRlib channel handle */
521    void *decoder, /* [in] decoder handle */
522    bool *has_disco
523    );
524
525#endif /* BPCRLIB_H_ */
526
527
Note: See TracBrowser for help on using the repository browser.