source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/xpt/7552/bxpt_packetsub.h

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

first commit

  • Property svn:executable set to *
File size: 23.2 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-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: bxpt_packetsub.h $
11 * $brcm_Revision: Hydra_Software_Devel/5 $
12 * $brcm_Date: 1/12/12 2:40p $
13 *
14 * Porting interface code for the packet substitution section of the
15 * data transport core.
16 *
17 * Revision History:
18 *
19 * $brcm_Log: /magnum/portinginterface/xpt/base2/bxpt_packetsub.h $
20 *
21 * Hydra_Software_Devel/5   1/12/12 2:40p gmullen
22 * SW7425-2138: Fixed incorrect parser band index
23 *
24 * Hydra_Software_Devel/4   1/11/12 10:32a gmullen
25 * SW7425-2138: Added BXPT_HAS_PB_PACKETSUB
26 *
27 * Hydra_Software_Devel/3   12/15/11 9:50a gmullen
28 * SW7425-1589: Merged to Hydra_Software_Devel
29 *
30 * Hydra_Software_Devel/SW7425-1589/1   12/12/11 4:35p gmullen
31 * SW7425-1589: Added BXPT_PacketSub_GetEobIntId()
32 *
33 * Hydra_Software_Devel/2   1/25/11 3:11p rjlewis
34 * SW7420-879: supply a means to provide an output rate default on open.
35 * Get defaults provides the default value.
36 *
37 * Hydra_Software_Devel/1   10/25/10 2:09p gmullen
38 * SW7425-15: Moved srcs to base2 folder
39 *
40 * Hydra_Software_Devel/2   10/25/10 9:11a gmullen
41 * SW7425-15: Updated headers and added stub versions of C files
42 *
43 * Hydra_Software_Devel/1   10/8/10 2:57p gmullen
44 * SW7425-15: Added header files
45 *
46 * Hydra_Software_Devel/9   8/18/10 7:55a gmullen
47 * SW7403-924: Merged to mainline
48 *
49 * Hydra_Software_Devel/SW7403-924/2   8/11/10 10:53a gmullen
50 * SW7403-924: New method: change band_num in PSUB
51 *
52 * Hydra_Software_Devel/SW7403-924/1   8/9/10 9:07a gmullen
53 * SW7403-924: See the JIRA for the workaround notes
54 *
55 * Hydra_Software_Devel/8   6/17/09 6:46p gmullen
56 * PR56110: Added support.xpt/7550/uif_image/a0
57 *
58 * Hydra_Software_Devel/7   4/7/09 5:25p piyushg
59 * PR52986: Add support for 7635
60 * Added directory element "7635".
61 *
62 * Hydra_Software_Devel/6   1/27/09 1:09p gmullen
63 * PR51625: Added 7336 support
64 *
65 * Hydra_Software_Devel/5   11/26/08 4:14p gmullen
66 * PR47755: Added support for 7420.
67 *
68 * Hydra_Software_Devel/4   3/26/08 11:24a gmullen
69 * PR38954: Added 3548 support to XPT PI.
70 *
71 * Hydra_Software_Devel/3   11/28/07 11:24a gmullen
72 * PR36900: Added 7335 support
73 *
74 * Hydra_Software_Devel/2   10/30/07 3:11p gmullen
75 * PR35018: Added support for 7325
76 *
77 * Hydra_Software_Devel/1   5/13/05 1:27p gmullen
78 * PR15309: First draft of XPT PI.
79 *
80 * Hydra_Software_Devel/14   10/4/04 3:26p gmullen
81 * PR12902: Added requested function
82 *
83 * Hydra_Software_Devel/13   3/25/04 11:15a gmullen
84 * PR8852: Checked for duplicate PID usage in record, remux, and hsx.
85 *
86 * Hydra_Software_Devel/12   2/8/04 5:21p gmullen
87 * PR9210: Changed includes to comply.
88 *
89 * Hydra_Software_Devel/11   1/19/04 2:54p gmullen
90 * PR8852: Changed definition of _SetOutputRate(). RDB description is
91 * confusing.
92 *
93 * Hydra_Software_Devel/10   1/5/04 2:49p gmullen
94 * PR9142: Fixed compiler warnings.
95 *
96 * Hydra_Software_Devel/9   1/5/04 12:21p gmullen
97 * PR8852: Moved BandNum from ChannelSettings to SetPidChanNum()
98 *
99 * Hydra_Software_Devel/8   12/4/03 5:32p gmullen
100 * PR8729: Added prototype for
101 * BXPT_PacketSub_GetChannelDefaultSettings().
102 *
103 * Hydra_Software_Devel/7   10/3/03 5:06p gmullen
104 * Updated function prototypes.
105 *
106 * Hydra_Software_Devel/6   9/26/03 4:50p gmullen
107 * Replaced stubs with real code.
108 *
109 * Hydra_Software_Devel/5   9/8/03 9:21a gmullen
110 * Updated for channel-based API.
111 *
112 * Hydra_Software_Devel/4   8/14/03 4:06p gmullen
113 * Replaced Get/Set calls.
114 *
115 * Hydra_Software_Devel/3   7/31/03 10:55a gmullen
116 * Changed 'Description' fields in enum and structure comments to
117 * 'Summary' so they'll show up in auto-generated docs.
118 *
119 * Hydra_Software_Devel/2   7/30/03 6:35p gmullen
120 * Added comments to enums
121 *
122 * Hydra_Software_Devel/1   7/25/03 3:39p gmullen
123 * Initial release for 7038
124 *
125 ***************************************************************************/
126
127/*= Module Overview *********************************************************
128The packet substitution module provides a method to adjust the contents of
129PIDs carrying PSI or SI information, after packets have been removed by the
130PID parsers. Every time packet is removed, a 'gap' is created in the stream
131where the packet used to be. The packet substitution logic can insert new
132data into those gaps. The modified stream that is created is available to
133all other blocks in the transport core, and can be treated like any data
134packet stream.
135***************************************************************************/
136
137#ifndef BXPT_PACKETSUB_H__
138#define BXPT_PACKETSUB_H__
139
140#include "bxpt.h"
141
142/***************************************************************************
143Summary:
144Defines the DMA priority levels a packet sub channel can use. A channel with
145HIGH priority will output all its packets before a channel with LOW priority
146will be allowed to output any.
147****************************************************************************/
148typedef enum BXPT_PacketSubDmaPriority
149{
150    BXPT_PacketSubDmaPriority_eHigh = 1,                       
151    BXPT_PacketSubDmaPriority_eLow = 0
152}
153BXPT_PacketSubDmaPriority;
154
155/***************************************************************************
156Summary:
157Handle for accessing the packet substitution API via a channel. Users should
158not directly access the contents of the structure.
159****************************************************************************/
160typedef struct BXPT_P_PacketSubHandle *BXPT_PacketSub_Handle;
161
162/***************************************************************************
163Summary:
164Settings for the Playback channels. These values can be passed in when the
165channel is opened, and will be used as the new default settings.
166****************************************************************************/
167typedef struct BXPT_PacketSub_ChannelSettings
168{
169        unsigned int    PacketLen;                                                      /* Packet length. */
170
171        /*
172        ** Insert packet in gap between upstream data. When enabled, forced packet
173        ** insertion mode for this pasrser band is enabled and normal substitution
174        ** of null packet for this band is disabled. Output rate control is the
175        ** same for forced packet insertion mode and normal substitution mode.
176        */
177        bool ForcedInsertionEn; 
178
179        /* Provides a default rate for packet insertion. */
180        uint32_t OutputRate;
181}
182BXPT_PacketSub_ChannelSettings;
183
184/***************************************************************************
185Summary:
186Layout of a packet sub descriptor. The order of the members matches the order
187the hardware will expect them in when the descriptor is read from memory.
188Thus, the descriptor's contents can be accessed by creating a pointer to this
189type of struct and setting that pointer to the address of the real descriptor
190in memory (after being memory mapped, of course).
191****************************************************************************/
192typedef struct BXPT_PacketSub_Descriptor
193{
194        uint32_t        BufferStartAddr;        /* (Pointer to) the buffer associated with this descriptor. */
195        uint32_t        BufferLength;           /* Length (in bytes) of the buffer. */
196        uint32_t        Flags;                          /* Channel-specific flags. */
197        uint32_t        NextDescAddr;           /* (Pointer to) the next descriptor in the chain. */
198} 
199BXPT_PacketSub_Descriptor;
200
201/***************************************************************************
202Summary:
203Status bits for the packet substitution channel.
204****************************************************************************/
205typedef struct BXPT_PacketSub_ChannelStatus
206{
207        bool Finished;          /* true if channel has processed last descriptor in the chain. */
208        bool Busy;                      /* true if channel is active. */
209        bool Run;                       /* true if a playback session has been started. */
210}
211BXPT_PacketSub_ChannelStatus;
212
213#ifdef __cplusplus
214extern "C" {
215#endif
216
217/***************************************************************************
218Summary:
219Return the number of packet substitution channels.
220
221Description:
222For the given transport core, return the number of packet substitution channels
223that is supported.
224
225Returns:
226    BERR_SUCCESS                - Retrieved channel count.
227    BERR_INVALID_PARAMETER      - Bad input parameter
228****************************************************************************/
229BERR_Code BXPT_PacketSub_GetTotalChannels(
230        BXPT_Handle hXpt,                       /* [in] Handle for this transport */
231        unsigned int *TotalChannels             /* [out] The number of PacketSub channels. */
232        );     
233
234/***************************************************************************
235Summary:
236Open a given packet substitution channel.
237
238Description:
239Reset the given playback channel, configure it using the given defaults, then
240return a handle to access that channel.
241
242Returns:
243    BERR_SUCCESS                - Packet substitution channel opened.
244    BERR_INVALID_PARAMETER      - Bad input parameter
245****************************************************************************/
246BERR_Code BXPT_PacketSub_OpenChannel(
247        BXPT_Handle hXpt,                                                       /* [in] Handle for this transport */
248        BXPT_PacketSub_Handle *hPSub,                           /* [out] Handle for opened packet sub channel */
249        unsigned int ChannelNo,                                                 /* [in] Which channel to open. */
250        BXPT_PacketSub_ChannelSettings *ChannelSettings /* [in] The defaults to use */
251        );     
252
253/***************************************************************************
254Summary:
255Close a given packet sub channel.
256
257Description:
258Shutdown a given playback channel, disable any interrupts from it.
259
260Returns:
261        void
262****************************************************************************/
263void BXPT_PacketSub_CloseChannel(
264        BXPT_PacketSub_Handle hPSub     /* [in] Handle for the channel to close*/
265        );     
266
267/***************************************************************************
268Summary:
269Get the default settings for a given packet sub channel.
270
271Description:
272Retrieves the default values used when opening a packet sub channel. The user
273can change the defaults, then pass the new settings in when
274BXPT_PacketSub_OpenChannel() is called.
275
276Returns:
277    BERR_SUCCESS                - Call completed successfully.
278    BERR_INVALID_PARAMETER      - Bad channel number
279****************************************************************************/
280BERR_Code BXPT_PacketSub_GetChannelDefaultSettings(
281        BXPT_Handle hXpt,                       /* [in] Handle for this transport */
282        unsigned int ChannelNo,                 /* [in] Which channel to get defaults from. */
283        BXPT_PacketSub_ChannelSettings *ChannelSettings /* [out] The defaults */
284        );
285
286/***************************************************************************
287Summary:
288Set the ouput PID channel number.
289
290Description:
291Set the PID channel number that the substituted packets will be given.
292
293All chips support substitution into PID channels from live feeds (via the
294front end parsers). On some chips, substitution from playback feeds is also
295supported. Such chips have BXPT_HAS_PB_PACKETSUB defined for them in bxpt.h .
296To use playback feeds, add the BXPT_PB_PARSER macro like so:
297 
298    BXPT_PacketSub_SetPidChanNum( hPSub, PidChanNum, BXPT_PB_PARSER( BandNum ) );
299 
300BandNum should be set to the index of the playback channel that the PID channel
301is mapped to, i.e. BandNum should be 1 if playback 1 is used. 
302
303Returns:
304    BERR_SUCCESS                - Call completed successfully.
305    BERR_INVALID_PARAMETER      - Bad input parameter
306****************************************************************************/
307BERR_Code BXPT_PacketSub_SetPidChanNum( 
308        BXPT_PacketSub_Handle hPSub,    /* [in] Handle for the channel. */
309        unsigned int PidChanNum,                /* [in] Which PID channel to assign the output to. */
310        unsigned int BandNum                    /* [in] Which band number to assign the output to */
311        );
312
313/***************************************************************************
314Summary:
315Get the ouput PID channel number.
316
317Description:
318On certain chips (the 7403 right now), only certain PID channels can
319be used with the PSUB hardware. This API will return the correct PID channel
320number for the given PSUB.
321
322Returns:
323    unsigned int - PID channel number to be used with this PacketSub block.
324****************************************************************************/
325unsigned int BXPT_PacketSub_GetPidChanNum( 
326        BXPT_PacketSub_Handle hPSub     /* [in] Handle for the channel. */
327        );
328
329/***************************************************************************
330Summary:
331Force immediate output.
332
333Description:
334Substitution data is normally inserted on a space-available basis, meaning
335the PID parsers must drop a packet from the selected output band to make room
336for a substitution packet. This function forces immediate insertion for the
337given channel. For a live stream, forced insertion means that input packets
338are dropped immediatly to make room. For a playback stream with pacing, the
339playback channel will be paused to allow the insertion. Playback without
340pacing is handled like a live stream.
341
342Returns:
343    BERR_SUCCESS                - Immediate output enabled.
344    BERR_INVALID_PARAMETER      - Bad input parameter
345
346See Also:
347BXPT_PacketSub_SetFullRateOutput, BXPT_PacketSub_SetOutputRate
348****************************************************************************/
349BERR_Code BXPT_PacketSub_SetForcedOutput( 
350        BXPT_PacketSub_Handle hPSub,    /* [in] Handle for the channel. */
351        bool Enable                     /* [in] Force output immediately if TRUE */
352        );
353
354/***************************************************************************
355Summary:
356Set output rate equal to input rate.
357
358Description:
359Ignore the programmable output rate that was set through
360BXPT_PacketSub_SetOutputRate(), and make the output rate equal to the input
361rate. Disabling this feature will return to the programmable rate.
362
363Returns:
364    BERR_SUCCESS                - Output rate now matches input.
365    BERR_INVALID_PARAMETER      - Bad input parameter
366
367See Also:
368BXPT_PacketSub_SetForcedOutput, BXPT_PacketSub_SetOutputRate
369****************************************************************************/
370BERR_Code BXPT_PacketSub_SetFullRateOutput( 
371        BXPT_PacketSub_Handle hPSub,    /* [in] Handle for the channel. */
372        bool Enable                     /* [in] Use full rate if TRUE */
373        );
374
375/***************************************************************************
376Summary:
377Set output rate to the user-supplied value.
378
379Description:
380Set packet output rate, expressed in bits/second. Unless overridden by
381BXPT_PacketSub_SetFullRateOutput(), the output rate for substituted packets
382will the given bitrate, rounded to the nearest 1600 bits/second.
383
384Returns:
385    BERR_SUCCESS                - Output rate now set.
386    BERR_INVALID_PARAMETER      - Bad input parameter
387
388See Also:
389BXPT_PacketSub_SetFullRateOutput, BXPT_PacketSub_SetForcedOutput
390****************************************************************************/
391BERR_Code BXPT_PacketSub_SetOutputRate( 
392        BXPT_PacketSub_Handle hPSub,    /* [in] Handle for the channel. */
393        uint32_t OutputRate     /* [in] The output rate, in bits/second */
394        );
395
396/***************************************************************************
397Summary:
398Pause packet substitution.
399
400Description:
401Pause the packet substitution channel. Packet subbing stops until this
402function is called again to disable the pause.
403
404Returns:
405    BERR_SUCCESS                - Paused enabled or disabled.
406    BERR_INVALID_PARAMETER      - Bad input parameter
407****************************************************************************/
408BERR_Code BXPT_PacketSub_PauseChannel( 
409        BXPT_PacketSub_Handle hPSub,    /* [in] Handle for the channel. */
410        bool Pause                      /* [in] Pause channel if TRUE, continue if FALSE */
411        );
412
413/***************************************************************************
414Summary:
415Initialize a descriptor for the packet substitution linked list.
416
417Description:
418Initialize the contents of a packet sub descriptor. The caller passes in the
419starting address of the buffer that the descriptor will point to.
420The buffer can start at any byte address, and may be of any length.
421
422The caller specifies if an interrupt should be generated when the
423hardware has finished processing the contents of the descriptor's
424buffer.
425
426The memory for the descriptor must be allocated by the caller, and must
427start on a 16-byte boundary.
428
429Since descriptors are usually used in chains, the function allows the
430descriptor's NextDescAddr to be initialized along with the rest of the
431fields. This next descriptor does not have to be initialized itself. The
432address must meet the 16-byte boundary requirement.
433
434Returns:
435    BERR_SUCCESS                - Descriptor initialized.
436    BERR_INVALID_PARAMETER      - Bad input parameter
437
438See Also:
439BXPT_PacketSub_AddDescriptors, BXPT_PacketSub_CheckHeadDescriptor
440****************************************************************************/
441BERR_Code BXPT_PacketSub_CreateDesc( 
442        BXPT_Handle hXpt,                                               /* [in] Handle for this transport */
443        BXPT_PacketSub_Descriptor * const Desc,         /* [in] Descriptor to initialize */ 
444        uint8_t *Buffer,                                                        /* [in] Data buffer. */
445        uint32_t BufferLength,                                          /* [in] Size of buffer (in bytes). */
446        bool IntEnable,                                                         /* [in] Interrupt when done? */
447        BXPT_PacketSub_Descriptor * const NextDesc      /* [in] Next descriptor, or NULL */
448        );
449
450/***************************************************************************
451Summary:
452Add a descriptor to a packet substitution linked list.
453
454Description:
455Add a descriptor chain to an existing (but possibly empty) chain used by a
456packet sub channel. If the existing chain is empty, the chain being added
457simply becomes the current chain.
458
459The FirstDesc argument is a pointer to the descriptor at the start of the
460chain being added. The LastDesc argument passed in is a pointer to the end
461of that chain.
462
463Returns:
464    BERR_SUCCESS                - Descriptor added to the list.
465    BERR_INVALID_PARAMETER      - Bad input parameter
466
467See Also:
468BXPT_PacketSub_CreateDesc, BXPT_PacketSub_CheckHeadDescriptor
469****************************************************************************/
470BERR_Code BXPT_PacketSub_AddDescriptors( 
471        BXPT_PacketSub_Handle hPSub,    /* [in] Handle for the channel. */
472        BXPT_PacketSub_Descriptor *LastDesc,    /* [in] Last descriptor in new chain */
473        BXPT_PacketSub_Descriptor *FirstDesc    /* [in] First descriptor in new chain */
474        );
475
476/***************************************************************************
477Summary:
478Return the address of the current packet sub descriptor.
479
480Description:
481For a given packet substitution channel, get the address of the descriptor
482that is currently being used by the hardware.
483
484Returns:
485    BERR_SUCCESS                - Retrieved address from hardware.
486    BERR_INVALID_PARAMETER      - Bad input parameter
487****************************************************************************/
488BERR_Code BXPT_PacketSub_GetCurrentDescriptorAddress(
489        BXPT_PacketSub_Handle hPSub,    /* [in] Handle for the channel. */
490        BXPT_PacketSub_Descriptor **LastDesc            /* [in] Address of the current descriptor. */
491        );
492
493/***************************************************************************
494Summary:
495Determine if a descriptor is the head of a linked list.
496
497Description:
498Determine if the current descriptor being processed by the packet sub channel
499is the first on the channel's chain (which means this descriptor is still
500being used). For packet sub channels that are still 'busy', the size of the
501descriptor's buffer is also returned. This value should be ignore for all
502other types of channels.
503
504Returns:
505    BERR_SUCCESS                - No errors occurred during the check.
506    BERR_INVALID_PARAMETER      - Bad input parameter
507
508See Also:
509BXPT_PacketSub_CreateDesc, BXPT_PacketSub_CheckHeadDescriptor
510****************************************************************************/
511BERR_Code BXPT_PacketSub_CheckHeadDescriptor( 
512        BXPT_PacketSub_Handle hPSub,    /* [in] Handle for the channel. */
513        BXPT_PacketSub_Descriptor *Desc,        /* [in] Descriptor to check. */
514        bool *InUse,                                            /* [out] Is descriptor in use? */
515        uint32_t *BufferSize                            /* [out] Size of the buffer (in bytes). */
516        );
517
518/***************************************************************************
519Summary:
520Begin packet substitution on the specified channel.
521
522Description:
523Start a packet sub channel. If no buffers have been added to the packet sub
524channel, the hardware is not actually started until the first buffer is added.
525
526Note: the caller should install an interrupt handler prior to calling this
527function. That handler will be called when a descriptor's data has been
528processed if the IntEnable bit in the descriptor was set.
529
530Returns:
531    BERR_SUCCESS                - Channel started.
532    BERR_INVALID_PARAMETER      - Bad input parameter
533
534See Also:
535BXPT_PacketSub_StopChannel, BXPT_PacketSub_PauseChannel
536****************************************************************************/
537BERR_Code BXPT_PacketSub_StartChannel( 
538        BXPT_PacketSub_Handle hPSub     /* [in] Handle for the channel. */
539        );
540
541/***************************************************************************
542Summary:
543Stop a packet sub channel.
544
545Description:
546Stop packet substitution on the specified channel.The interrupts for the
547given channel are disabled.
548
549Returns:
550    BERR_SUCCESS                - Channel stopped.
551    BERR_INVALID_PARAMETER      - Bad input parameter
552
553See Also:
554BXPT_PacketSub_StartChannel, BXPT_PacketSub_PauseChannel
555****************************************************************************/
556BERR_Code BXPT_PacketSub_StopChannel( 
557        BXPT_PacketSub_Handle hPSub     /* [in] Handle for the channel. */
558        );
559
560/***************************************************************************
561Summary:
562Get the packet sub channels status bits.
563
564Description:
565Return the packet sub channels FINISHED, RUN, and BUSY status bits. The bits
566are read directly from the hardware.
567
568Returns:
569    BERR_SUCCESS                - Settings read from hardware successfully.
570****************************************************************************/
571BERR_Code BXPT_PacketSub_GetChannelStatus(
572        BXPT_PacketSub_Handle hPSub,                    /* [in] Handle for the channel. */
573        BXPT_PacketSub_ChannelStatus *Status    /* [out] Channel status. */
574        );
575
576/***************************************************************************
577Summary:
578Return BINT_Id for the packetsub end-of-buffer interrupt.
579
580Description:
581The result is a BINT_Id value suitable for use in BINT_CreateCallback().
582
583Returns:
584    BERR_SUCCESS                - Id generated successfully.
585    BERR_INVALID_PARAMETER      - Bad input parameter 
586****************************************************************************/
587BERR_Code BXPT_PacketSub_GetEobIntId(
588        BXPT_PacketSub_Handle hPSub,                    /* [in] Handle for the channel. */
589    BINT_Id *IntId
590    );
591
592/***************************************************************************
593Summary:
594Insert a packet in any gap between upstream packet.
595 
596Description:
597This API provides the same functionality as ForcedInsertionEn in the
598BXPT_PacketSub_ChannelSettings struct. It is provided for cases where setting
599ForcedInsertionEn at open is inconvenient. 
600 
601Returns:
602    BERR_SUCCESS                - Id generated successfully.
603    BERR_INVALID_PARAMETER      - Bad input parameter 
604****************************************************************************/
605BERR_Code BXPT_PacketSub_SetForcedInsertion( 
606        BXPT_PacketSub_Handle hPSub,    /* [in] Handle for the channel. */
607        bool Enable                     /* [in] */
608        );
609
610#ifdef __cplusplus
611}
612#endif
613
614#endif /* #ifndef BXPT_PACKETSUB_H__ */
615
616/* end of file */
Note: See TracBrowser for help on using the repository browser.