close Warning: Can't use blame annotator:
No changeset 2 in the repository

source: svn/newcon3bcm2_21bu/magnum/syslib/pvrlib/bpvrlib_dynrec.h

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 14.8 KB
RevLine 
1/***************************************************************************
2 *     Copyright (c) 2002, 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: bpvrlib_dynrec.h $
11 * $brcm_Revision: Hydra_Software_Devel/5 $
12 * $brcm_Date: 3/12/04 3:26p $
13 *
14 * Revision History:
15 *
16 * $brcm_Log: /magnum/syslib/pvrlib/bpvrlib_dynrec.h $
17 *
18 * Hydra_Software_Devel/5   3/12/04 3:26p vsilyaev
19 * PR 8927: Added API to return events to the application.
20 *
21 * Hydra_Software_Devel/4   1/21/04 4:43p marcusk
22 * PR8927: Fixed to work with latest version of XPT porting interface.
23 * Validate channel number.
24 *
25 * Hydra_Software_Devel/3   1/15/04 4:40p marcusk
26 * PR8927: Initial working version of the dynamic buffer record syslib.
27 *
28 * Hydra_Software_Devel/2   1/15/04 12:40p marcusk
29 * PR8927: Fixed comment and paramter to Open() routine.
30 *
31 * Hydra_Software_Devel/1   1/15/04 11:23a marcusk
32 * PR8927: Initial version.
33 *
34 ***************************************************************************/
35
36/*================== Module Overview =====================================
37
38This module implements the record functionality for pvr using a list
39of complete, free, and hardware buffers.  Free buffers can be shared between
40all record channels in order to handle peaks in bandwidth (since it is
41less likely that all record channels will peak at the same time).  This
42allows more efficient memory utilization than having static buffers for
43each channel.
44
45It is only possible to include either the standard ring buffer based record
46or this dynamic implementation (which is why they share the same API).
47
48The following general overview describes the record algorithm:
49
50 0.0 Master Handle Creation
51   - A master record handle is created (it is then used for subsequent record
52     channel open calls)
53   - Size of entire record buffer is passed as parameter (same for all record channels)
54   
55 1.0 Open
56   - Resources (events, lists, etc) are created.
57 
58 1.1 Configure Record
59   - These should be performed outside the record syslib
60   - Data transport PIDs are enabled and configured
61   - Record parameters are configured (including decryption/encryption, etc)
62   - Record pid channel bitmap is enabled
63   - SCT record parameters should be set
64 
65 1.2 Start Record (SCT record channel should be started first if required)
66   - Free buffers are added to record hardware and hardware list
67   - Record hardware is started
68 
69 1.3 Get Data (not re-entrant for same record channel)
70   - Record buffer address and size is obtained from buffer complete list
71   (this step may block if there is no data available)
72   (blocking is disabled if the record channel is stopped)
73   - Data is copied to specified buffer
74   - Buffer complete list is updated (descriptor is added to free list)
75   - The amount of data copied from record channel is returned
76   - Overflow status is returned
77 
78 (Alternate to 1.3)
79 1.3.1 Request to Get Data (steps 1.3.x not re-entrant for same record channel)
80   - Record buffer address and size is obtained from buffer complete list
81   (this step may block if there is no space available)
82   (blocking is disabled if the record channel is stopped)
83   - Overflow status is returned
84 
85 1.3.2 Data is copied from specified buffer by calling code
86 
87 1.3.3 Complete list is updated
88   - Buffer complete list is updated (descriptor is added to free list)
89 
90 1.4 Descriptor complete ISR()
91   - First descriptor is removed from hardware list and checked for completion
92   - If complete, descriptor is added to complete list
93   - Check if next descriptor has also completed (repeat process if necessary)
94   - Set event to notify of data arrival
95 
96 1.5 Stop Record
97   - Record hardware is stopped
98   - Wait for record done interrupt to occur if we are stopping a transport record channel
99   - Partially complete descriptor is moved to complete list (with special flag
100     specifying how much of the buffer is occupied)
101   - All left over descriptors are moved from hw to the free list
102   - Any blocking calls are released (future calls are not allowed to block)
103   - Additional get data function call should be called to get remaining
104          data from record.
105 
106 1.6 Free
107   - Free descriptor buffer
108   - Free record buffer manager
109 
110========================================================================*/
111#ifndef __BPVRLIB_DYNREC_H__
112#define __BPVRLIB_DYNREC_H__
113
114#include "bxpt_record.h"
115
116#ifdef __cplusplus
117extern "C" {
118#endif
119
120/*
121Summary:
122This callback is compatible with the standard 'c' memcpy routine.
123It is used to copy data between a user buffer and the ring
124buffer during a pvr_recordGetData() function call.
125*/
126typedef void *(*BPVRlib_Rec_CopyMemoryCb)( void *, const void *, size_t ); 
127
128/*
129Summary:
130This handle is used to store the context of a pvr record instance.
131*/
132typedef struct BPVRlib_Rec_P_Handle *BPVRlib_Rec_Handle;
133
134/*
135Summary:
136This handle is used to store the context of a pvr record channel.
137*/
138typedef struct BPVRlib_Rec_P_MasterHandle *BPVRlib_Rec_MasterHandle;
139
140/*
141Summary:
142This structure is used to store various statistics that can
143be used to monitor and debug a record that is in progress.
144Note: All stats are reset when the record is started or flushed!
145*/
146typedef struct
147{
148        size_t          numBytesRecorded;       /* Number of bytes recorded by hardware */
149        size_t          numBytesRemoved;        /* Number of bytes removed from the record buffer by software */
150        size_t          numFreeDesc;            /* Current number of free descriptors (for all record channels) */
151        uint32_t        numInHwDesc;            /* Current number of descriptors being processed by hardware */
152        uint32_t        numCompDesc;            /* Current number of complete descriptors */
153        uint32_t        numDesc;                        /* Total number of descriptors (for all record channels) */
154        uint32_t        numDescAdded;           /* Number of descriptors added in to hardware */
155        uint32_t        numDescCompleted;       /* Number of descriptors completed by hardware */
156        uint32_t        numOverFlows;           /* Number of times the hardware has reached the end of its descriptor list */
157        uint32_t        numBufferBlocks;        /* Number of times blocking has occurred due to buffer resources */
158        uint32_t        numTimeouts;            /* Number of times blocking has failed due to a timeout */
159        size_t          maxBfrDepth;            /* Maximum number of bytes stored in buffer */
160        size_t          bfrDepth;                       /* Current number of valid bytes stored in the buffer */
161        size_t          descSize;                       /* Size of each descriptor */
162} BPVRlib_Rec_Stats;
163
164/*
165        The BPVRlib_Rec_Events structure is used to return various events used by the record module.
166        Those events could be latter useful when application useed nonblocking flavor of record
167*/
168typedef struct BPVRlib_Rec_Events
169{
170        BKNI_EventHandle        descEvent;              /* Event used to signal when descriptor is added to free list */
171        BKNI_EventHandle        finishedEvent;  /* Event used to signal when the record has finished */
172} BPVRlib_Rec_Events;
173
174
175/****************************************************************
176Summary:
177This function allocates the resources required for a record. 
178
179See also:
180BPVRlib_Rec_Close(), BPVRlib_Rec_Start(), BPVRlib_Rec_GetData()
181****************************************************************/
182BERR_Code BPVRlib_Rec_Open(
183        BPVRlib_Rec_MasterHandle *pRecMasterHandle,     /* [out] context handle */
184        BXPT_Handle xptHandle,                          /* XPT handle */
185        BMEM_Handle memHandle,                          /* Mem handle */
186        BINT_Handle intHandle,                          /* Int handle */
187        BXPT_ChanType chanType,                         /* Record channel type */
188        uint8_t *p_bfr,                                         /* pointer to buffer that should be used for record buffer, 0 to allocate the buffer internally */
189        size_t bfrSize,                                         /* size of record record buffer (in bytes). Should be multiple of descSize */
190        uint32_t numDesc,                                       /* number of descriptors to use (minimum of 3 per record channel that will be used) */
191        BPVRlib_Rec_CopyMemoryCb copyMemCb      /* function pointer for memory copies (optional) */
192        );
193
194/****************************************************************
195Summary:
196This function frees any resources used by a record
197channel.
198****************************************************************/
199BERR_Code BPVRlib_Rec_Close( 
200        BPVRlib_Rec_MasterHandle recMasterHandle                /* context handle */
201        );
202
203/****************************************************************
204Summary:
205This function allocates the resources required for a record channel. 
206
207Description:
208This includes a buffer, descriptor list, etc.
209The pvrMemCopyCb parameter only needs to be valid
210if the BPVRlib_Rec_GetData() function is going to be
211used.
212
213The buffer used by this specific record channel may be shared by
214other record channels.
215
216See also:
217BPVRlib_Rec_Close(), BPVRlib_Rec_Start(), BPVRlib_Rec_GetData()
218****************************************************************/
219BERR_Code BPVRlib_Rec_ChannelOpen(
220        BPVRlib_Rec_Handle *pRecChanHandle,     /* [out] context handle */
221        BPVRlib_Rec_MasterHandle recMasterHandle, /* master handle context */
222        BXPT_Record_Handle xptRecHandle,        /* XPT record handle */
223        unsigned chanNum,                                               /* record channel number */
224        uint32_t minDesc                                        /* minimum number of descriptors that should be always allocated for this record channel (0 is auto) */
225        );
226
227
228/****************************************************************
229Summary:
230This function frees any resources used by a record
231channel.
232****************************************************************/
233BERR_Code BPVRlib_Rec_ChannelClose( 
234        BPVRlib_Rec_Handle recChanHandle                /* context handle */
235        );
236
237/****************************************************************
238Summary:
239This function returns events used by the record module
240****************************************************************/
241BERR_Code BPVRlib_Rec_GetEvents( 
242        BPVRlib_Rec_Handle recHandle,   /* context handle*/
243        BPVRlib_Rec_Events *events    /* events would be returned in this structure */ 
244        );
245
246
247/****************************************************************
248Summary:
249This function starts a record channel.
250****************************************************************/
251BERR_Code BPVRlib_Rec_Start( 
252        BPVRlib_Rec_Handle recChanHandle                /* context handle */
253        );
254
255/****************************************************************
256Summary:
257This function checks if any data has been recorded
258into the record buffer.  If not, it can optionally block
259until data is recorded, or return immediately.  When
260data is in the record buffer, it is copied (using the
261memcpy funtion pointer passed in pvr_recordAllocate)
262to the destination buffer.  The function always returns
263when ANY amount of data is available, ie the destination
264buffer will not always be filled, so make sure to
265check the *p_bfrSize when this function returns!
266****************************************************************/
267BERR_Code BPVRlib_Rec_GetData( 
268        BPVRlib_Rec_Handle recChanHandle,       /* context handle */
269        uint8_t *p_bfr,                                         /* [out,sizeof(*p_bfrSize)] pointer to destination buffer */
270        size_t *p_bfrSize,                                      /* [in,out] size of destination buffer (in bytes), returns number of bytes actually copied */ 
271        bool block,                                                     /* false (do not block), true (block until data is available) */
272        bool *p_overflow                                        /* [out] returns 1 if record overflow has occurred */
273        );
274
275/****************************************************************
276Summary:
277This function checks if any data has been recorded
278into the record buffer.  If not, it can optionally block
279until data is recorded, or return immediately.  When
280data is in the record buffer, the address and size
281of the valid data is returned.  It is up to the
282calling code to copy data from this location and
283update the read pointer for the record channel
284using the BPVRlib_Rec_UpdateReadPointer() function.
285****************************************************************/
286BERR_Code BPVRlib_Rec_GetDataRequest( 
287        BPVRlib_Rec_Handle recChanHandle,       /* context handle */
288        uint8_t **pp_bfr,                                       /* [out] returns pointer to the start of valid data */
289        size_t *p_bfrSize,                                      /* [out] returns size of the valid data (in bytes) */ 
290        bool block                                                      /* 0 (do not block), 1 (block until data is available) */
291        );
292
293/****************************************************************
294Summary:
295This function updates the read pointer for the
296record record buffer.  It is used to notify the record
297buffer when data has been copied out of the buffer and
298this space can be re-used for new record data.
299****************************************************************/
300BERR_Code BPVRlib_Rec_UpdateReadPointer( 
301        BPVRlib_Rec_Handle recChanHandle,       /* context handle */
302        size_t bytesRead,                                       /* number of bytes that have been read from ring buffer */
303        bool block,                                             /* not currently used */
304        bool *p_overflow                                        /* [out] returns true if record overflow has occurred */
305        );
306
307/****************************************************************
308Summary:
309This function stops a record channel and waits for
310the record done interrupt to occur.  After the stop
311function is called, don't forget to remove the last
312remains of the record from the record buffer!
313
314This function will return an error if there is any overflow
315pending in the record channel (overflow must be handled
316before the record can be stopped!)
317****************************************************************/
318BERR_Code BPVRlib_Rec_Stop( 
319        BPVRlib_Rec_Handle recChanHandle        /* context handle */
320        );
321
322/****************************************************************
323Summary:
324This function returns the number of valid bytes in the
325record buffer (already recorded by hardware).
326****************************************************************/
327void BPVRlib_Rec_GetBufferDepth( 
328        BPVRlib_Rec_Handle recChanHandle,       /* context handle */
329        size_t *p_bfrDepth                                      /* [out] number of valid bytes in the record buffer */ 
330        );
331
332/****************************************************************
333Summary:
334This function sets the maximum timeout value allowed when
335waiting for buffer space or descriptors to become available.
336INFINITE is used by default and is the recommended value.
337****************************************************************/
338void BPVRlib_Rec_SetTimeout( 
339        BPVRlib_Rec_Handle recChanHandle,       /* context handle */
340        uint32_t numMsec                                        /* timeout value in msec */
341        );
342
343/****************************************************************
344Summary:
345This function returns the current timeout value
346used when waiting for buffer space or descriptors
347to become available.
348****************************************************************/
349void BPVRlib_Rec_GetTimeout( 
350        BPVRlib_Rec_Handle recChanHandle,       /* context handle */
351        uint32_t *p_numMsec                             /* [out] returns current timeout value in msec */
352        );
353
354/****************************************************************
355Summary:
356This function returns various record channel statistics.
357****************************************************************/
358BERR_Code BPVRlib_Rec_GetStats( 
359        BPVRlib_Rec_Handle recChanHandle,       /* context handle */
360        BPVRlib_Rec_Stats *p_stats                      /* [out] this structure is filled with statistics */
361        );
362
363#ifdef __cplusplus
364}
365#endif
366
367#endif
368
Note: See TracBrowser for help on using the repository browser.