source: svn/newcon3bcm2_21bu/magnum/portinginterface/xpt/7552/bxpt_xcbuf_priv.c

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

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

  • Property svn:executable set to *
File size: 25.8 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_xcbuf_priv.c $
11 * $brcm_Revision: Hydra_Software_Devel/11 $
12 * $brcm_Date: 3/8/12 3:41p $
13 *
14 * Porting interface code for the data transport core.
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/xpt/base2/bxpt_xcbuf_priv.c $
19 *
20 * Hydra_Software_Devel/11   3/8/12 3:41p gmullen
21 * SW7425-2497: Merged to Hydra
22 *
23 * Hydra_Software_Devel/SW7425-2497/1   3/5/12 4:30p gmullen
24 * SW7425-2497: Checks for errors in data pipeline
25 *
26 * Hydra_Software_Devel/10   2/28/12 10:49a gmullen
27 * SW7425-2403: Back were we started from...
28 *
29 * Hydra_Software_Devel/9   2/16/12 9:55a gmullen
30 * SW7425-2403: Corrected blockout count and change warning mesg
31 *
32 * Hydra_Software_Devel/8   12/20/11 1:29p gmullen
33 * SW7358-176: Merged to Hydra
34 *
35 * Hydra_Software_Devel/SW7358-176/1   12/20/11 1:05p gmullen
36 * SW7358-175: Added per-client control of XC and RS buffer alloc
37 *
38 * Hydra_Software_Devel/7   4/13/11 8:34a gmullen
39 * SW7344-33: Merged fix to mainline
40 *
41 * Hydra_Software_Devel/SW7344-33/1   3/8/11 1:36p gmullen
42 * SW7425-153: Incorrect param passed to ComputeBlockout()
43 *
44 * Hydra_Software_Devel/6   4/11/11 9:15a gmullen
45 * SW7346-119: Merged fix to mainline
46 *
47 * Hydra_Software_Devel/SW7346-119/1   4/7/11 3:43p gmullen
48 * SW7346-119: Disable CC checking when enabling all-pass mode. Restore
49 * when exiting all-pass
50 *
51 * Hydra_Software_Devel/5   3/23/11 5:12p gmullen
52 * SW7346-124: Do not allocate XC buffers for unused remux blocks
53 *
54 * Hydra_Software_Devel/4   3/8/11 9:58a gmullen
55 * SW7425-156: Fixed incorrect blockout calculations
56 *
57 * Hydra_Software_Devel/3   12/6/10 10:01a gmullen
58 * SW7422-117: Disable pausing from XC buffer to flush data on playback
59 * stopping
60 *
61 * Hydra_Software_Devel/2   10/28/10 2:08p gmullen
62 * SW7422-20: Checkin ported files
63 *
64 *
65 ***************************************************************************/
66
67#include "bstd.h"
68#include "bxpt_priv.h"
69#include "bxpt.h"
70#include "bkni.h"
71#include "bxpt_xcbuf_priv.h"
72#include "bchp_xpt_xcbuff.h"
73
74#if( BDBG_DEBUG_BUILD == 1 )
75BDBG_MODULE( xpt_xcbuf_priv );
76#endif
77
78#define INPUT_BAND_BUF_SIZE         (200* 1024)
79#define PLAYBACK_BUF_SIZE           (8 * 1024)
80#define MINIMUM_BUF_SIZE            (256)
81#define BUFFER_PTR_REG_STEPSIZE     (6 * 4)
82#define MAX_BITRATE                 ( 108000000 )
83#define BLOCKOUT_REG_STEPSIZE       4
84#define DEFAULT_PACKET_SIZE         (188)
85
86/* Threshold for pause generation when XC Buffer for a corresponding band is almost full */
87#define DEFAULT_PACKET_PAUSE_LEVEL  ( 12 )
88
89static BERR_Code AllocateBuffer(
90    BXPT_Handle hXpt,               
91    unsigned BaseRegAddr,       /* [in] Which client buffer we are dealing with */
92    unsigned WhichInstance,
93    unsigned long Size          /* [in] Size in bytes. Must be a multiple of 256. */
94    )
95{
96    uint32_t Offset;
97    void *Buffer;
98
99    BERR_Code ExitCode = BERR_SUCCESS;
100
101    /* If there is a secure heap defined, use it. */
102    BMEM_Handle hMem = hXpt->hRHeap ? hXpt->hRHeap : hXpt->hMemory;
103
104    BaseRegAddr = BaseRegAddr + WhichInstance * BUFFER_PTR_REG_STEPSIZE;
105
106    /* Size must be a multiple of 256. */
107    Size = Size - ( Size % 256 );
108
109    Buffer = BMEM_AllocAligned( hMem, Size, 8, 0 ); 
110    if( !Buffer )
111    {
112        BDBG_ERR(( "XC buffer alloc failed!" ));
113        ExitCode = BERR_TRACE( BERR_OUT_OF_DEVICE_MEMORY );
114        goto Done;
115    }
116    BMEM_ConvertAddressToOffset( hMem, Buffer, &Offset );
117
118    BREG_Write32( hXpt->hRegister, BaseRegAddr, Offset );                   /* Set BASE */
119    BREG_Write32( hXpt->hRegister, BaseRegAddr + 4, Offset + Size - 1 );    /* Set END */
120    BREG_Write32( hXpt->hRegister, BaseRegAddr + 8, Offset - 1 );           /* Set WRITE */
121    BREG_Write32( hXpt->hRegister, BaseRegAddr + 12, Offset - 1 );          /* Set VALID */
122    BREG_Write32( hXpt->hRegister, BaseRegAddr + 16, Offset - 1 );          /* Set READ */
123    BREG_Write32( hXpt->hRegister, BaseRegAddr + 20, 0 );                   /* Set WATERMARK */
124
125    Done:
126    return( ExitCode );
127}
128
129static BERR_Code DeleteBuffer(
130    BXPT_Handle hXpt, 
131    unsigned BaseRegAddr,       /* [in] Which client buffer we are dealing with */
132    unsigned WhichInstance
133    )
134{
135    uint32_t Offset;
136    void *Buffer;
137
138    BERR_Code ExitCode = BERR_SUCCESS;
139
140    /* If there is a secure heap defined, use it. */
141    BMEM_Handle hMem = hXpt->hRHeap ? hXpt->hRHeap : hXpt->hMemory;
142
143    BaseRegAddr = BaseRegAddr + WhichInstance * BUFFER_PTR_REG_STEPSIZE;
144
145    Offset = BREG_Read32( hXpt->hRegister, BaseRegAddr );
146    BMEM_ConvertOffsetToAddress( hMem, Offset, ( void ** ) &Buffer );
147    BMEM_Free( hMem, Buffer );
148   
149    return( ExitCode );
150}
151
152static BERR_Code SetBufferEnable( 
153    BXPT_Handle hXpt, 
154    unsigned EnableRegAddr,
155    unsigned Index,
156    bool EnableIt
157    )
158{
159    uint32_t EnReg;
160
161    BERR_Code ExitCode = BERR_SUCCESS;
162
163    EnReg = BREG_Read32( hXpt->hRegister, EnableRegAddr );
164    if( EnableIt )
165    {
166        EnReg |= ( 1ul << Index );
167    }
168    else
169    {
170        EnReg &= ~( 1ul << Index );
171    }
172    BREG_Write32( hXpt->hRegister, EnableRegAddr, EnReg ); 
173   
174    return( ExitCode );
175}
176
177static unsigned long ComputeBlockOut( 
178        unsigned long PeakRate,                 /* [in] Max data rate (in bps) the band will handle. */
179    unsigned PacketLen,             /* [in] Packet size ,130 for dss and 188 for mpeg */
180    char *BufferName,
181    unsigned BufferIndex
182    )
183{
184    /* Need to double the peak rate in order to support simultaneous R and G pipe traffic. */
185    PeakRate *= 2;
186
187    /* Error reporting is done in the RS buffer setup only. The RS rates really determine the
188    bandwidth needs. This code just needs to make sure we don't overflow the bitfield. */
189    if( PeakRate < BXPT_MIN_PARSER_RATE )
190    {
191#if 0
192        BDBG_WRN(( "Requested rate for %s [%u] is %u bps, but supported minimum is %u bps. Minimum rate will be used.",
193            BufferName, BufferIndex, PeakRate, BXPT_MIN_PARSER_RATE ));
194#else
195    BSTD_UNUSED( BufferName );
196    BSTD_UNUSED( BufferIndex );
197#endif
198
199        PeakRate = BXPT_MIN_PARSER_RATE;
200    }
201    else if( PeakRate > BXPT_MAX_PARSER_RATE )
202    {
203#if 0
204        BDBG_WRN(( "Requested rate for %s [%u] is %u bps, but supported maximum is %u bps. Maximum rate will be used.",
205            BufferName, BufferIndex, PeakRate, BXPT_MAX_PARSER_RATE ));
206#else
207    BSTD_UNUSED( BufferName );
208    BSTD_UNUSED( BufferIndex );
209#endif
210        PeakRate = BXPT_MAX_PARSER_RATE;
211    }
212
213    return (10800 * PacketLen * 8) / ( PeakRate / 10000 );
214}
215
216static BERR_Code SetBlockout(
217    BXPT_Handle hXpt,           /* [in] Handle for this transport */
218    unsigned BufferTypeBlockoutAddr,
219    unsigned WhichInstance,
220    unsigned long NewB0       
221    )
222{
223    uint32_t Reg, RegAddr;
224
225    BERR_Code ExitCode = BERR_SUCCESS;
226
227    BDBG_ASSERT( hXpt );
228
229    RegAddr = BufferTypeBlockoutAddr + WhichInstance * BLOCKOUT_REG_STEPSIZE;
230    Reg = BREG_Read32( hXpt->hRegister, RegAddr );
231    Reg &= ~BCHP_MASK( XPT_XCBUFF_BO_RAVE_IBP0, BO_COUNT );
232    Reg |= BCHP_FIELD_DATA( XPT_XCBUFF_BO_RAVE_IBP0, BO_COUNT, NewB0 );
233    BREG_Write32( hXpt->hRegister, RegAddr, Reg );
234
235    return( ExitCode );
236}
237
238BERR_Code BXPT_P_XcBuf_Init(
239    BXPT_Handle hXpt,           /* [in] Handle for this transport */
240    const BXPT_BandWidthConfig *BandwidthConfig
241    )
242{
243    uint32_t Reg;
244    unsigned ii;
245
246    BERR_Code ExitCode = BERR_SUCCESS;
247    unsigned totalAllocated = 0;
248
249    BDBG_ASSERT( hXpt );
250
251    /* Set Pause to 12 packets */
252    Reg = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_PAUSE_THRESHOLD );
253    Reg &= ~( BCHP_MASK( XPT_XCBUFF_PAUSE_THRESHOLD, PACKETS ) );
254    Reg |= ( BCHP_FIELD_DATA( XPT_XCBUFF_PAUSE_THRESHOLD, PACKETS, DEFAULT_PACKET_PAUSE_LEVEL ) );
255    BREG_Write32( hXpt->hRegister, BCHP_XPT_XCBUFF_PAUSE_THRESHOLD, Reg );
256   
257    /*
258    ** XC buffer bitrates should be set to 2 times the expected input rate, to handle watch and
259    ** record. That usage requires both the R-pipe and G-pipe to be enabled. 
260    */
261    #if BXPT_HAS_IB_PID_PARSERS && BXPT_HAS_RAVE
262    for( ii = 0; ii < BXPT_NUM_PID_PARSERS; ii++ )
263    {
264        if( BandwidthConfig->MaxInputRate[ ii ] && BandwidthConfig->IbParserClients[ ii ].ToRave )
265        {
266            BDBG_MSG(( "Alloc XC for IB parser %u to RAVE, %u bps", ii, BandwidthConfig->MaxInputRate[ ii ] ));
267            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RAVE_IBP0, ii, INPUT_BAND_BUF_SIZE );
268            SetBlockout( hXpt, BCHP_XPT_XCBUFF_BO_RAVE_IBP0, ii, 
269               ComputeBlockOut( BandwidthConfig->MaxInputRate[ ii ], DEFAULT_PACKET_SIZE, "MaxInputRate", ii ) );
270
271            SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RAVE_CTRL_BUFFER_EN_IBP, ii, true );
272            totalAllocated += INPUT_BAND_BUF_SIZE;
273        }
274        else
275        {
276            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RAVE_IBP0, ii, MINIMUM_BUF_SIZE );
277            totalAllocated += MINIMUM_BUF_SIZE;
278        }
279    }
280    #endif
281
282    #if BXPT_HAS_PLAYBACK_PARSERS && BXPT_HAS_RAVE
283    for( ii = 0; ii < BXPT_NUM_PLAYBACKS; ii++ )
284    {
285        if( BandwidthConfig->MaxPlaybackRate[ ii ] && BandwidthConfig->PlaybackParserClients[ ii ].ToRave )
286        {
287            BDBG_MSG(( "Alloc XC for PB parser %u to RAVE, %u bps", ii, BandwidthConfig->MaxPlaybackRate[ ii ] ));
288            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RAVE_PBP0, ii, PLAYBACK_BUF_SIZE );
289            SetBlockout( hXpt, BCHP_XPT_XCBUFF_BO_RAVE_PBP0, ii, 
290               ComputeBlockOut( BandwidthConfig->MaxPlaybackRate[ ii ], DEFAULT_PACKET_SIZE, "MaxPlaybackRate", ii ) );
291            SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RAVE_CTRL_BUFFER_EN_PBP, ii, true );
292            totalAllocated += PLAYBACK_BUF_SIZE;
293        }
294        else
295        {
296            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RAVE_PBP0, ii, MINIMUM_BUF_SIZE );
297            totalAllocated += MINIMUM_BUF_SIZE;
298        }
299    }
300    #endif
301
302    #if BXPT_HAS_IB_PID_PARSERS && BXPT_HAS_MESG_BUFFERS
303    for( ii = 0; ii < BXPT_NUM_PID_PARSERS; ii++ )
304    {
305        if( BandwidthConfig->MaxInputRate[ ii ] && BandwidthConfig->IbParserClients[ ii ].ToMsg )
306        {
307            BDBG_MSG(( "Alloc XC for IB parser %u to MSG, %u bps", ii, BandwidthConfig->MaxInputRate[ ii ] ));
308            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_MSG_IBP0, ii, INPUT_BAND_BUF_SIZE );
309            SetBlockout( hXpt, BCHP_XPT_XCBUFF_BO_MSG_IBP0, ii, 
310               ComputeBlockOut( BandwidthConfig->MaxInputRate[ ii ], DEFAULT_PACKET_SIZE, "MaxInputRate", ii ) );
311            SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_MSG_CTRL_BUFFER_EN_IBP, ii, true );
312            totalAllocated += INPUT_BAND_BUF_SIZE;
313        }
314        else
315        {
316            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_MSG_IBP0, ii, MINIMUM_BUF_SIZE );
317            totalAllocated += MINIMUM_BUF_SIZE;
318        }
319    }
320    #endif
321
322    #if BXPT_HAS_PLAYBACK_PARSERS && BXPT_HAS_MESG_BUFFERS
323    for( ii = 0; ii < BXPT_NUM_PLAYBACKS; ii++ )
324    {
325        if( BandwidthConfig->MaxPlaybackRate[ ii ] && BandwidthConfig->PlaybackParserClients[ ii ].ToMsg )
326        {
327            BDBG_MSG(( "Alloc XC for PB parser %u to MSG, %u bps", ii, BandwidthConfig->MaxPlaybackRate[ ii ] ));
328            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_MSG_PBP0, ii, PLAYBACK_BUF_SIZE );
329            SetBlockout( hXpt, BCHP_XPT_XCBUFF_BO_MSG_PBP0, ii, 
330               ComputeBlockOut( BandwidthConfig->MaxPlaybackRate[ ii ], DEFAULT_PACKET_SIZE, "MaxPlaybackRate", ii ) );
331            SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_MSG_CTRL_BUFFER_EN_PBP, ii, true );
332            totalAllocated += PLAYBACK_BUF_SIZE;
333        }
334        else
335        {
336            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_MSG_PBP0, ii, MINIMUM_BUF_SIZE );
337            totalAllocated += MINIMUM_BUF_SIZE;
338        }
339    }
340    #endif
341
342    #if BXPT_HAS_IB_PID_PARSERS && BXPT_HAS_REMUX
343    /* We have at least RMX0 */
344    for( ii = 0; ii < BXPT_NUM_PID_PARSERS; ii++ )
345    {
346        if( BandwidthConfig->MaxInputRate[ ii ] && BandwidthConfig->RemuxUsed[ 0 ] && BandwidthConfig->IbParserClients[ ii ].ToRmx[ 0 ] )
347        {
348            BDBG_MSG(( "Alloc XC for IB parser %u to RMX0, %u bps", ii, BandwidthConfig->MaxInputRate[ ii ] ));
349            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX0_IBP0, ii, INPUT_BAND_BUF_SIZE );
350            SetBlockout( hXpt, BCHP_XPT_XCBUFF_BO_RMX0_IBP0, ii, 
351               ComputeBlockOut( BandwidthConfig->MaxInputRate[ ii ], DEFAULT_PACKET_SIZE, "MaxInputRate", ii ) );
352            SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RMX0_CTRL_BUFFER_EN_IBP, ii, true );
353            totalAllocated += INPUT_BAND_BUF_SIZE;
354        }
355        else
356        {
357            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX0_IBP0, ii, MINIMUM_BUF_SIZE );
358            totalAllocated += MINIMUM_BUF_SIZE;
359        }
360    }
361   
362    #if BXPT_NUM_REMULTIPLEXORS > 0
363    /* We've got at least RMX1 */
364    for( ii = 0; ii < BXPT_NUM_PID_PARSERS; ii++ )
365    {
366        if( BandwidthConfig->MaxInputRate[ ii ] && BandwidthConfig->RemuxUsed[ 1 ] && BandwidthConfig->IbParserClients[ ii ].ToRmx[ 1 ])
367        {
368            BDBG_MSG(( "Alloc XC for IB parser %u to RMX1, %u bps", ii, BandwidthConfig->MaxInputRate[ ii ] ));
369            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX1_IBP0, ii, INPUT_BAND_BUF_SIZE );
370            SetBlockout( hXpt, BCHP_XPT_XCBUFF_BO_RMX1_IBP0, ii, 
371               ComputeBlockOut( BandwidthConfig->MaxInputRate[ ii ], DEFAULT_PACKET_SIZE, "MaxInputRate", ii ) );
372            SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RMX1_CTRL_BUFFER_EN_IBP, ii, true );
373            totalAllocated += INPUT_BAND_BUF_SIZE;
374        }
375        else
376        {
377            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX1_IBP0, ii, MINIMUM_BUF_SIZE );
378            totalAllocated += MINIMUM_BUF_SIZE;
379        }
380    }
381    #endif
382
383    #if BXPT_NUM_REMULTIPLEXORS > 2
384    #error "Add support for remux2 and higher, input bands"
385    #endif
386
387    #endif
388
389    #if BXPT_HAS_PLAYBACK_PARSERS && BXPT_HAS_REMUX
390    /* We have at least RMX0 */
391    for( ii = 0; ii < BXPT_NUM_PLAYBACKS; ii++ )
392    {
393        if( BandwidthConfig->MaxPlaybackRate[ ii ] && BandwidthConfig->RemuxUsed[ 0 ] && BandwidthConfig->PlaybackParserClients[ ii ].ToRmx[ 0 ] )
394        {
395            BDBG_MSG(( "Alloc XC for PB parser %u to RMX0, %u bps", ii, BandwidthConfig->MaxPlaybackRate[ ii ] ));
396            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX0_PBP0, ii, PLAYBACK_BUF_SIZE );
397            SetBlockout( hXpt, BCHP_XPT_XCBUFF_BO_RMX0_PBP0, ii, 
398               ComputeBlockOut( BandwidthConfig->MaxPlaybackRate[ ii ], DEFAULT_PACKET_SIZE, "MaxPlaybackRate", ii ) );
399            SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RMX0_CTRL_BUFFER_EN_PBP, ii, true );
400            totalAllocated += PLAYBACK_BUF_SIZE;
401        }
402        else
403        {
404            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX0_PBP0, ii, MINIMUM_BUF_SIZE );
405            totalAllocated += MINIMUM_BUF_SIZE;
406        }
407    }
408
409    #if BXPT_NUM_REMULTIPLEXORS > 0
410    /* We've got at least RMX1 */
411    for( ii = 0; ii < BXPT_NUM_PLAYBACKS; ii++ )
412    {
413        if( BandwidthConfig->MaxPlaybackRate[ ii ] && BandwidthConfig->RemuxUsed[ 1 ] && BandwidthConfig->PlaybackParserClients[ ii ].ToRmx[ 1 ])
414        {
415            BDBG_MSG(( "Alloc XC for PB parser %u to RMX1, %u bps", ii, BandwidthConfig->MaxPlaybackRate[ ii ] ));
416            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX1_PBP0, ii, PLAYBACK_BUF_SIZE );
417            SetBlockout( hXpt, BCHP_XPT_XCBUFF_BO_RMX1_PBP0, ii, 
418               ComputeBlockOut( BandwidthConfig->MaxPlaybackRate[ ii ], DEFAULT_PACKET_SIZE, "MaxPlaybackRate", ii ) );
419            SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RMX1_CTRL_BUFFER_EN_PBP, ii, true );
420            totalAllocated += PLAYBACK_BUF_SIZE;
421        }
422        else
423        {
424            AllocateBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX1_PBP0, ii, MINIMUM_BUF_SIZE );
425            totalAllocated += MINIMUM_BUF_SIZE;
426        }
427    }
428    #endif
429
430    #if BXPT_NUM_REMULTIPLEXORS > 2
431    #error "Add support for remux2 and higher, playback channels"
432    #endif
433
434    #endif
435
436    BDBG_MSG(( "XC totalAllocated: %u bytes", totalAllocated ));
437    return( ExitCode );
438}
439
440BERR_Code BXPT_P_XcBuf_Shutdown(
441    BXPT_Handle hXpt            /* [in] Handle for this transport */
442    )
443{
444    unsigned ii;
445
446    BERR_Code ExitCode = BERR_SUCCESS;
447
448    BDBG_ASSERT( hXpt );
449
450    #if BXPT_HAS_IB_PID_PARSERS && BXPT_HAS_RAVE
451    for( ii = 0; ii < BXPT_NUM_PID_PARSERS; ii++ )
452    {
453        ExitCode |= SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RAVE_CTRL_BUFFER_EN_IBP, ii, false );
454        ExitCode |= DeleteBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RAVE_IBP0, ii );
455        if( ExitCode != BERR_SUCCESS )
456        {
457            BDBG_ERR(( "Disable/Delete of XC RAVE Buffer %d failed", ii ));
458            goto Done;
459        }
460    }
461    #endif
462
463    #if BXPT_HAS_PLAYBACK_PARSERS && BXPT_HAS_RAVE
464    for( ii = 0; ii < BXPT_NUM_PLAYBACKS; ii++ )
465    {
466        ExitCode |= SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RAVE_CTRL_BUFFER_EN_PBP, ii, false );
467        ExitCode |= DeleteBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RAVE_PBP0, ii );
468        if( ExitCode != BERR_SUCCESS )
469        {
470            BDBG_ERR(( "Disable/Delete of XC RAVE Buffer %d failed", ii ));
471            goto Done;
472        }
473    }
474    #endif
475
476    #if BXPT_HAS_IB_PID_PARSERS && BXPT_HAS_MESG_BUFFERS
477    for( ii = 0; ii < BXPT_NUM_PID_PARSERS; ii++ )
478    {
479        ExitCode |= SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_MSG_CTRL_BUFFER_EN_IBP, ii, false );
480        ExitCode |= DeleteBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_MSG_IBP0, ii );
481        if( ExitCode != BERR_SUCCESS )
482        {
483            BDBG_ERR(( "Disable/Delete of XC Msg Input Buffer %d failed", ii ));
484            goto Done;
485        }
486    }
487    #endif
488
489    #if BXPT_HAS_PLAYBACK_PARSERS && BXPT_HAS_MESG_BUFFERS
490    for( ii = 0; ii < BXPT_NUM_PLAYBACKS; ii++ )
491    {
492        ExitCode |= SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_MSG_CTRL_BUFFER_EN_PBP, ii, false );
493        ExitCode |= DeleteBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_MSG_PBP0, ii );
494        if( ExitCode != BERR_SUCCESS )
495        {
496            BDBG_ERR(( "Disable/Delete of XC Msg Playback Buffer %d failed", ii ));
497            goto Done;
498        }
499    }
500    #endif
501
502    #if BXPT_HAS_IB_PID_PARSERS && BXPT_HAS_REMUX
503    /* We have at least RMX0 */
504    for( ii = 0; ii < BXPT_NUM_PID_PARSERS; ii++ )
505    {
506        ExitCode |= SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RMX0_CTRL_BUFFER_EN_IBP, ii, false );
507        ExitCode |= DeleteBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX0_IBP0, ii );
508        if( ExitCode != BERR_SUCCESS )
509        {
510            BDBG_ERR(( "Disable/Delete of XC RMX0 Input Buffer %d failed", ii ));
511            goto Done;
512        }
513    }
514   
515    #if BXPT_NUM_REMULTIPLEXORS > 0
516    /* We've got at least RMX1 */
517    for( ii = 0; ii < BXPT_NUM_PID_PARSERS; ii++ )
518    {
519        ExitCode |= SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RMX1_CTRL_BUFFER_EN_IBP, ii, false );
520        ExitCode |= DeleteBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX1_IBP0, ii );
521        if( ExitCode != BERR_SUCCESS )
522        {
523            BDBG_ERR(( "Disable/Delete of XC RMX1 Input Buffer %d failed", ii ));
524            goto Done;
525        }
526    }
527    #endif
528
529    #if BXPT_NUM_REMULTIPLEXORS > 2
530    #error "Add support for remux2 and higher, input bands"
531    #endif
532
533    #endif
534
535    #if BXPT_HAS_PLAYBACK_PARSERS && BXPT_HAS_REMUX
536    /* We have at least RMX0 */
537    for( ii = 0; ii < BXPT_NUM_PLAYBACKS; ii++ )
538    {
539        ExitCode |= SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RMX0_CTRL_BUFFER_EN_PBP, ii, false );
540        ExitCode |= DeleteBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX0_PBP0, ii );
541        if( ExitCode != BERR_SUCCESS )
542        {
543            BDBG_ERR(( "Disable/Delete of XC RMX0 Playback Buffer %d failed", ii ));
544            goto Done;
545        }
546    }
547
548    #if BXPT_NUM_REMULTIPLEXORS > 0
549    /* We've got at least RMX1 */
550    for( ii = 0; ii < BXPT_NUM_PLAYBACKS; ii++ )
551    {
552        ExitCode |= SetBufferEnable( hXpt, BCHP_XPT_XCBUFF_RMX1_CTRL_BUFFER_EN_PBP, ii, false );
553        ExitCode |= DeleteBuffer( hXpt, BCHP_XPT_XCBUFF_BASE_POINTER_RMX1_PBP0, ii );
554        if( ExitCode != BERR_SUCCESS )
555        {
556            BDBG_ERR(( "Disable/Delete of XC RMX1 Playback Buffer %d failed", ii ));
557            goto Done;
558        }
559    }
560    #endif
561
562    #if BXPT_NUM_REMULTIPLEXORS > 2
563    #error "Add support for remux2 and higher, playback channels"
564    #endif
565
566    #endif
567
568    Done:
569    return( ExitCode );
570}
571
572void BXPT_XcBuf_P_EnablePlaybackPausing( 
573    BXPT_Handle hXpt, 
574    unsigned PbChannelNum,
575    bool PauseEn
576    )
577{
578    uint32_t Reg = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RAVE_CTRL_PAUSE_EN_PBP );
579
580    if( PauseEn) 
581    {
582        BREG_Write32( hXpt->hRegister, BCHP_XPT_XCBUFF_RAVE_CTRL_PAUSE_EN_PBP, Reg | ( 1 << PbChannelNum ) );
583    }
584    else
585    {
586        BREG_Write32( hXpt->hRegister, BCHP_XPT_XCBUFF_RAVE_CTRL_PAUSE_EN_PBP, Reg & ~( 1 << PbChannelNum ) );
587    }
588}
589
590BERR_Code BXPT_P_XcBuf_ReportOverflows( 
591    BXPT_Handle hXpt
592    )
593{
594    uint32_t Overflow;
595    unsigned BufferNum;
596
597    BERR_Code Status = 0;
598
599    #if BXPT_HAS_IB_PID_PARSERS && BXPT_HAS_RAVE
600    Overflow = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RAVE_CTRL_BUFFER_EN_IBP ) & 
601        BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RAVE_OVERFLOW_STATUS_IBP );
602    Status |= Overflow;
603    for( BufferNum = 0; BufferNum < BXPT_NUM_PID_PARSERS; BufferNum++ )
604    {
605        if (Overflow & 1 << BufferNum)
606            BDBG_ERR(( "XC buffer for IB parser %u to RAVE has overflowed. Consider increasing BXPT_BandWidthConfig.MaxInputRate[%u] or enable RAVE overflow interrupts", BufferNum ));
607    }
608    #endif
609
610    #if BXPT_HAS_PLAYBACK_PARSERS && BXPT_HAS_RAVE
611    Overflow = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RAVE_CTRL_BUFFER_EN_PBP ) & 
612        BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RAVE_OVERFLOW_STATUS_PBP );
613    Status |= Overflow;
614    for( BufferNum = 0; BufferNum < BXPT_NUM_PLAYBACKS; BufferNum++ )
615    {
616        if (Overflow & 1 << BufferNum)
617            BDBG_ERR(( "XC buffer for PB parser %u to RAVE has overflowed. Consider increasing BXPT_BandWidthConfig.MaxPlaybackRate[%u] or enable RAVE overflow interrupts", BufferNum ));
618    }
619    #endif
620
621    #if BXPT_HAS_IB_PID_PARSERS && BXPT_HAS_MESG_BUFFERS
622    Overflow = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_MSG_CTRL_BUFFER_EN_IBP ) & 
623        BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_MSG_OVERFLOW_STATUS_IBP );
624    Status |= Overflow;
625    for( BufferNum = 0; BufferNum < BXPT_NUM_PID_PARSERS; BufferNum++ )
626    {
627        if (Overflow & 1 << BufferNum)
628            BDBG_ERR(( "XC buffer for IB parser %u to Mesg filter has overflowed. Consider increasing BXPT_BandWidthConfig.MaxInputRate[%u] or enable Mesg overflow interrupts", BufferNum ));
629    }
630    #endif
631
632    #if BXPT_HAS_PLAYBACK_PARSERS && BXPT_HAS_MESG_BUFFERS
633    Overflow = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_MSG_CTRL_BUFFER_EN_PBP ) & 
634        BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_MSG_OVERFLOW_STATUS_PBP );
635    Status |= Overflow;
636    for( BufferNum = 0; BufferNum < BXPT_NUM_PLAYBACKS; BufferNum++ )
637    {
638        if (Overflow & 1 << BufferNum)
639            BDBG_ERR(( "XC buffer for PB parser %u to Mesg filter has overflowed. Consider increasing BXPT_BandWidthConfig.MaxPlaybackRate[%u] or enable Mesg overflow interrupts", BufferNum ));
640    }
641    #endif
642
643    #if BXPT_HAS_IB_PID_PARSERS && BXPT_HAS_REMUX
644    Overflow = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RMX0_CTRL_BUFFER_EN_IBP ) & 
645        BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RMX0_OVERFLOW_STATUS_IBP );
646    Status |= Overflow;
647    for( BufferNum = 0; BufferNum < BXPT_NUM_PID_PARSERS; BufferNum++ )
648    {
649        if (Overflow & 1 << BufferNum)
650            BDBG_ERR(( "XC buffer for IB parser %u to Remux0 has overflowed. Consider increasing BXPT_BandWidthConfig.MaxInputRate[%u]", BufferNum ));
651    }
652
653    #if BXPT_NUM_REMULTIPLEXORS > 0
654    /* We've got at least RMX1 */
655    Overflow = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RMX1_CTRL_BUFFER_EN_IBP ) & 
656        BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RMX1_OVERFLOW_STATUS_IBP );
657    Status |= Overflow;
658    for( BufferNum = 0; BufferNum < BXPT_NUM_PID_PARSERS; BufferNum++ )
659    {
660        if (Overflow & 1 << BufferNum)
661            BDBG_ERR(( "XC buffer for IB parser %u to Remux0 has overflowed. Consider increasing BXPT_BandWidthConfig.MaxInputRate[%u]", BufferNum ));
662    }
663    #endif
664
665    #if BXPT_NUM_REMULTIPLEXORS > 2
666    #error "Add support for remux2 and higher, input bands"
667    #endif
668
669    #endif
670
671    #if BXPT_HAS_PLAYBACK_PARSERS && BXPT_HAS_REMUX
672    Overflow = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RMX0_CTRL_BUFFER_EN_PBP ) & 
673        BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RMX0_OVERFLOW_STATUS_PBP );
674    Status |= Overflow;
675    for( BufferNum = 0; BufferNum < BXPT_NUM_PLAYBACKS; BufferNum++ )
676    {
677        if (Overflow & 1 << BufferNum)
678            BDBG_ERR(( "XC buffer for PB parser %u to Remux0 has overflowed. Consider increasing BXPT_BandWidthConfig.MaxPlaybackRate[%u]", BufferNum ));
679    }
680
681    #if BXPT_NUM_REMULTIPLEXORS > 0
682    /* We've got at least RMX1 */
683    Overflow = BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RMX1_CTRL_BUFFER_EN_PBP ) & 
684        BREG_Read32( hXpt->hRegister, BCHP_XPT_XCBUFF_RMX1_OVERFLOW_STATUS_PBP );
685    Status |= Overflow;
686    for( BufferNum = 0; BufferNum < BXPT_NUM_PLAYBACKS; BufferNum++ )
687    {
688        if (Overflow & 1 << BufferNum)
689            BDBG_ERR(( "XC buffer for PB parser %u to Remux0 has overflowed. Consider increasing BXPT_BandWidthConfig.MaxPlaybackRate[%u]", BufferNum ));
690    }
691    #endif
692
693    #if BXPT_NUM_REMULTIPLEXORS > 2
694    #error "Add support for remux2 and higher, input bands"
695    #endif
696
697    #endif
698
699    return Status;
700}
Note: See TracBrowser for help on using the repository browser.