source: svn/trunk/newcon3bcm2_21bu/magnum/syslib/astmlib/7552/bastmlib.h @ 39

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

first commit

  • Property svn:executable set to *
File size: 13.4 KB
Line 
1/***************************************************************************
2*     Copyright (c) 2004-2010, 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: bastmlib.h $
11* $brcm_Revision: Hydra_Software_Devel/7 $
12* $brcm_Date: 11/2/10 4:54p $
13*
14* Revision History:
15*
16* $brcm_Log: /magnum/syslib/astmlib/noarch/bastmlib.h $
17*
18* Hydra_Software_Devel/7   11/2/10 4:54p bandrews
19* SW3548-1159: updated clock coupling recovery to use a second timeout
20* value
21*
22* Hydra_Software_Devel/6   7/14/10 7:44p bandrews
23* SW3548-1161: expose default configs as public
24*
25* Hydra_Software_Devel/5   7/17/09 6:56p bandrews
26* PR49215: playback support
27*
28* Hydra_Software_Devel/4   6/5/09 5:32p bandrews
29* PR52503: Move singleton counter/idgen to astmlib struct
30*
31* Hydra_Software_Devel/3   11/21/08 8:35p bandrews
32* PR49568: Fix presenter naming capability
33*
34* Hydra_Software_Devel/2   4/3/08 2:33p bandrews
35* PR40090: synclib needs to have different contexts for syslib callbacks
36* and synclib callbacks
37*
38* Hydra_Software_Devel/1   3/24/08 3:08p bandrews
39* PR40865: Fixed
40*
41* Hydra_Software_Devel/3   2/15/08 10:02p bandrews
42* PR36148: Updated based on reviews
43*
44* Hydra_Software_Devel/2   1/29/08 9:00p bandrews
45* PR36148: Updated based on simulation
46*
47* Hydra_Software_Devel/1   10/19/07 9:30p bandrews
48* PR36148: Initial implementation
49***************************************************************************/
50
51#include "bstd.h"
52#include "bsyslib.h"
53#include "bsyslib_callback.h"
54
55#ifndef BASTMLIB_H__
56#define BASTMLIB_H__
57
58/***************************************************************************
59Module Overview:
60
61***************************************************************************/
62
63/*
64Summary:
65A handle to an ASTM library instance.  An instance can handle N elementary
66streams and will compute one clock coupling mode and one tsm mode based on the
67information gathered for those streams.
68*/
69typedef struct BASTMlib_Impl * BASTMlib_Handle;
70
71/*
72Summary:
73A presenter handle
74Description:
75A presenter represents any module that normally performs TSM to determine
76when to release content to a display / output.
77*/
78typedef struct BASTMlib_Presenter_Impl * BASTMlib_Presenter_Handle;
79
80/*
81Summary:
82What controls the rate of releasing frames for presentation?
83Description:
84This enum represents a selection between TSM mode and VSYNC / non-TSM mode.
85Basically, we are deciding if frames will be released for presentation based
86on their timestamp, or based on the rate of the output clock.
87*/
88typedef enum BASTMlib_PresentationRateControl
89{
90        BASTMlib_PresentationRateControl_eTimeStamp, /* frames are released based
91                on their time stamp */
92        BASTMlib_PresentationRateControl_eOutputClock, /* frames are released based
93                on output clock rate (timestamps are ignored) */
94        BASTMlib_PresentationRateControl_eMax /* enum terminator */
95} BASTMlib_PresentationRateControl;
96
97/*
98Summary:
99What is the source of the STC?
100*/
101/* TODO: still poorly named */
102typedef enum BASTMlib_StcSource
103{
104        BASTMlib_StcSource_eClockReference, /* PCR, SCR, RTS, etc. */
105        BASTMlib_StcSource_ePresenter, /* a presenter */
106        BASTMlib_StcSource_eMax /* enum terminator */
107} BASTMlib_StcSource;
108
109/*
110Summary:
111Clock rate used for calculating thresholds and normalizing event information
112between events with different rates
113*/
114typedef enum BASTMlib_ClockRate
115{
116        BASTMlib_ClockRate_e45Khz = 45000,
117        BASTMlib_ClockRate_e27Mhz = 27000000,
118        BASTMlib_ClockRate_eMax = 0x7fffffff /* enum terminator */
119} BASTMlib_ClockRate;
120
121/*
122Summary:
123What clock is used to drive the timebases in the system?
124*/
125typedef enum BASTMlib_ClockCoupling
126{
127        BASTMlib_ClockCoupling_eInputClock, /* PCR, VSYNC, HSYNC, etc. */
128        BASTMlib_ClockCoupling_eInternalClock, /* internal XTAL */
129        BASTMlib_ClockCoupling_eMax /* enum terminator */
130} BASTMlib_ClockCoupling;
131
132/*
133Summary:
134Encapsulates all create-time, unchangeable settings for ASTM
135*/
136typedef struct BASTMlib_Settings
137{
138        BSYSlib_TimerCallback cbTimer;
139        struct
140        {
141                BSYSlib_Callback cbStateChange; /* when the presentation state changes,
142                        if a callback is registered here, notification will occur */
143        } sPresentation;
144        struct
145        {
146                BSYSlib_Callback cbStateChange;/* when the clock coupling state changes,
147                        if a callback is registered here, notification will occur */
148        } sClockCoupling;
149} BASTMlib_Settings;
150
151/*
152Summary:
153Presenter create-time settings
154*/
155typedef struct BASTMlib_Presenter_Settings
156{
157        const char * pcName;
158} BASTMlib_Presenter_Settings;
159
160/*
161Summary:
162Presenter configuration
163*/
164typedef struct BASTMlib_Presenter_Config
165{
166        BASTMlib_ClockRate ePtsDomain; /* the clocking domain of timestamps for
167                this presenter */
168        /* TODO: can we make it so older events are the ones that are lost?
169        what happens when we have already started processing events, we prob.
170        don't want to touch older ones as we would introduce discos */
171        unsigned int uiMinimumTimeBetweenEvents; /* minimum time that must elapse
172                between receiving events, in ms. used with presentation processing
173                frequency to determine size of event ring buffer. if events come more
174                often than this time, the event buffer may overflow, and newer events
175                will be lost */
176        unsigned int uiPassEventCountThreshold; /* how many pass events must be
177                received before deeming this presenter as "passing", in events */
178        unsigned int uiFailEventCountThreshold; /* how many fail events must be
179                received before deeming this presenter as "failing", in events */
180} BASTMlib_Presenter_Config;
181
182/*
183Summary:
184Configuration for ASTMlib.
185Description:
186These are configuration parameters that can be changed at any time.
187*/
188typedef struct
189{
190        bool bEnabled; /* if this flag is set to false, ASTM does not take place */
191        BASTMlib_ClockRate eStcRate; /* the rate of the STC managed by this
192                instance of ASTMlib */
193        struct
194        {
195                BASTMlib_StcSource ePreferredStcSource; /* this is used as the highest
196                        level stc source goal of ASTM's presentation task */
197                BASTMlib_Presenter_Handle hPreferredPresenter; /* if this handle is set
198                        and we determine the STC source should be a presenter, this is the
199                        presenter that will be used as the STC master.  If not set, the
200                        master presenter will be chosen in a first-come, first served
201                        (FCFS) fashion. */
202                unsigned int uiInitialAcquisitionTime; /* time just after calling start
203                        before processing presenter event queues for the first time,
204                        in ms */
205                unsigned int uiProcessingFrequency; /* after initial acquisition
206                        period, how often presenter event queues will be processed,
207                        in ms */
208                unsigned int uiTsmDisabledWatchdogTimeout; /* after entering
209                        TSM-disabled mode, how long before we attempt to re-enter
210                        TSM-enabled mode unconditionally */
211                unsigned int uiSettlingTime; /* after changing presentation     modes, how
212                        long we will wait for presenters to settle in the new mode */
213                BASTMlib_PresentationRateControl ePreferredPresentationRateControl; /*
214                        This is used as the highest level presentation rate control goal of
215                        ASTM's presentation task */
216        } sPresentation; /* presentation config */
217        struct
218        {
219                /* TODO: see comment above on loss of old vs. new events */
220                unsigned int uiMinimumTimeBetweenEvents; /* minimum time that must
221                        elapse between receiving events, in ms. used with processing
222                        frequency to determine size of event ring buffer. if events come
223                        more often than this time, the event buffer may overflow, and newer
224                        events will be lost */
225                BASTMlib_ClockRate eClockReferenceDomain; /* the clocking domain of
226                        the clock reference time stamps */
227                unsigned int uiDeviationThreshold; /* threshold above which abs value of
228                        clock reference rate difference to STC will be considered deviant */
229                unsigned int uiDeviantCountThreshold; /* how many deviant clock
230                        coupling measurements must be received before deeming the clock
231                        reference bad and decoupling the timebases from the input */
232                unsigned int uiIdealCountThreshold;/* how many ideal clock
233                        coupling measurements must be received before deeming the clock
234                        reference good and recoupling the timebases to the input */
235                unsigned int uiInitialAcquisitionTime; /* time just after calling start
236                        before processing clock reference event queue for the first time,
237                        in ms */
238                unsigned int uiProcessingFrequency; /* after initial acquisition
239                        period, how often clock reference event queue will be processed,
240                        in ms */
241                unsigned int uiIdealProcessingFrequency; /* after detecting deviant
242                        clock reference events, how often clock reference event queue will
243                        be processed, in ms */
244                unsigned int uiSettlingTime; /* after changing clock coupling modes,
245                        how long we will wait for clock reference to settle in the new
246                        mode */
247                BASTMlib_ClockCoupling ePreferredClockCoupling; /* this is used as the
248                        highest level goal of ASTM's clock coupling task */
249        } sClockCoupling; /* clock coupling config */
250} BASTMlib_Config;
251
252/*
253Summary:
254Status information for a given instance of the library
255*/
256typedef struct
257{
258        BASTMlib_PresentationRateControl ePresentationRateControl;
259        BASTMlib_StcSource eStcSource;
260        BASTMlib_Presenter_Handle hStcMaster; /* if the STC source is PTS, from
261                which presenter are the PTSs derived? NULL if STC source is not PTS. */
262        BASTMlib_ClockCoupling eClockCoupling;
263} BASTMlib_Status;
264
265/*
266Summary:
267The information required by the ASTM algorithm from the system during a
268presenter event
269*/
270typedef struct
271{
272        bool bPass; /* presenter's notion of TSM pass/fail for a given event */
273        unsigned int uiPts; /* in clock ticks in presenter_config.ePtsDomain */
274        unsigned int uiStc; /* in clock ticks at astm_config.eStcRate rate */
275} BASTMlib_Presenter_Event;
276
277/*
278Summary:
279The information required by the ASTM algorithm from the system during a
280clock coupling event
281*/
282typedef struct
283{
284        unsigned int uiClockReference; /* in clock ticks
285                in astm_config.sClockCoupling.eClockReferenceDomain domain */
286        unsigned int uiStc; /* in clock ticks at astm_config.eStcRate rate */
287} BASTMlib_ClockReference_Event;
288
289/*
290Summary:
291Returns the default ASTM lib module settings
292*/
293void BASTMlib_GetDefaultSettings(
294        BASTMlib_Settings * psSettings /* [out] */
295);
296
297/*
298Summary:
299Creates an ASTM lib instance
300*/
301BERR_Code BASTMlib_Create(
302        BASTMlib_Handle * phAstm, /* [out] */
303        const BASTMlib_Settings * psSettings
304);
305
306/*
307Summary:
308Destroys an instance of the ASTM library
309*/
310void BASTMlib_Destroy(
311        BASTMlib_Handle hAstm
312);
313
314/*
315Summary:
316Returns the default configuration of an ASTM instance
317*/
318void BASTMlib_GetDefaultConfig(
319        BASTMlib_Config * psConfig
320);
321
322/*
323Summary:
324Returns the current configuration of an ASTM instance
325*/
326void BASTMlib_GetConfig(
327        const BASTMlib_Handle hAstm, 
328        BASTMlib_Config * psConfig
329);
330
331/*
332Summary:
333Sets the current configuration of an ASTM instance
334*/
335void BASTMlib_SetConfig(
336        BASTMlib_Handle hAstm,
337        const BASTMlib_Config * psConfig
338);
339
340/*
341Summary:
342Starts an ASTM instance
343*/
344BERR_Code BASTMlib_Start(
345        BASTMlib_Handle hAstm
346);
347
348/*
349Summary:
350Stops an ASTM instance
351*/
352BERR_Code BASTMlib_Stop(
353        BASTMlib_Handle hAstm
354);
355
356/*
357Summary:
358Returns the current status of an ASTM instance.
359*/
360void BASTMlib_GetStatus(
361        BASTMlib_Handle hAstm,
362        BASTMlib_Status * psStatus /* [out] */
363);
364
365/*
366Summary:
367Adds a presenter to the ASTM instance
368*/
369BERR_Code BASTMlib_AddPresenter(
370        BASTMlib_Handle hAstm,
371        BASTMlib_Presenter_Handle hPresenter
372);
373
374/*
375Summary:
376Removes a presenter from the ASTM instance
377*/
378void BASTMlib_RemovePresenter(
379        BASTMlib_Handle hAstm,
380        BASTMlib_Presenter_Handle hPresenter
381);
382
383/*
384Summary:
385Updates the current state of the ASTM module with information about a
386clock reference event
387*/
388void BASTMlib_ClockReferenceEventHandler_isr(
389        BASTMlib_Handle hAstm,
390        const BASTMlib_ClockReference_Event * psEvent
391);
392
393/*
394Summary:
395Returns the default ASTM presenter settings
396*/
397void BASTMlib_Presenter_GetDefaultSettings(
398        BASTMlib_Presenter_Settings * psSettings /* [out] */
399);
400
401/*
402Summary:
403Creates an ASTM presenter
404*/
405void BASTMlib_Presenter_Create( 
406        BASTMlib_Handle hAstm,
407        BASTMlib_Presenter_Handle * phPresenter, /* [out] */
408        const BASTMlib_Presenter_Settings * psSettings
409);
410
411/*
412Summary:
413Destroys an ASTM presenter
414*/
415void BASTMlib_Presenter_Destroy(
416        BASTMlib_Presenter_Handle hPresenter
417);
418
419/*
420Summary:
421Returns the current ASTM presenter settings
422*/
423void BASTMlib_Presenter_GetSettings(
424        const BASTMlib_Presenter_Handle hPresenter,
425        BASTMlib_Presenter_Settings * psSettings /* [out] */
426);
427
428/*
429Summary:
430Sets the ASTM presenter settings
431*/
432void BASTMlib_Presenter_SetSettings(
433        BASTMlib_Presenter_Handle hPresenter,
434        const BASTMlib_Presenter_Settings * psSettings
435);
436
437/*
438Summary:
439Gets the default config for the specified presenter.
440*/
441void BASTMlib_Presenter_GetDefaultConfig(
442        BASTMlib_Presenter_Config * psConfig /* [out] */
443);
444/*
445Summary:
446Gets the current config for the specified presenter.  If no config has been
447set since creation, returns the default.
448*/
449void BASTMlib_Presenter_GetConfig(
450        const BASTMlib_Presenter_Handle hPresenter,
451        BASTMlib_Presenter_Config * psConfig /* [out] */
452);
453
454/*
455Summary:
456Sets the current config for the specified presenter
457*/
458void BASTMlib_Presenter_SetConfig(
459        BASTMlib_Presenter_Handle hPresenter,
460        const BASTMlib_Presenter_Config * psConfig
461);
462
463/*
464Summary:
465Updates the current state of the ASTM module with information about a
466presenter event
467*/
468void BASTMlib_Presenter_EventHandler_isr(
469        BASTMlib_Presenter_Handle hPresenter,
470        const BASTMlib_Presenter_Event * psEvent
471);
472
473#endif /* BASTMLIB_H__ */
474
Note: See TracBrowser for help on using the repository browser.