source: svn/newcon3bcm2_21bu/nexus/modules/transport/7552/src/nexus_remux.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: 27.0 KB
Line 
1/******************************************************************************
2 *    (c)2008-2011 Broadcom Corporation
3 *
4 * This program is the proprietary software of Broadcom Corporation and/or its licensors,
5 * and may only be used, duplicated, modified or distributed pursuant to the terms and
6 * conditions of a separate, written license agreement executed between you and Broadcom
7 * (an "Authorized License").  Except as set forth in an Authorized License, Broadcom grants
8 * no license (express or implied), right to use, or waiver of any kind with respect to the
9 * Software, and Broadcom expressly reserves all rights in and to the Software and all
10 * intellectual property rights therein.  IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU
11 * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY
12 * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE.
13 *
14 * Except as expressly set forth in the Authorized License,
15 *
16 * 1.     This program, including its structure, sequence and organization, constitutes the valuable trade
17 * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof,
18 * and to use this information only in connection with your use of Broadcom integrated circuit products.
19 *
20 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
21 * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR
22 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
23 * THE SOFTWARE.  BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES
24 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE,
25 * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION
26 * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF
27 * USE OR PERFORMANCE OF THE SOFTWARE.
28 *
29 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS
30 * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR
31 * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR
32 * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF
33 * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT
34 * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
35 * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF
36 * ANY LIMITED REMEDY.
37 *
38 * $brcm_Workfile: nexus_remux.c $
39 * $brcm_Revision: 39 $
40 * $brcm_Date: 10/31/11 7:48p $
41 *
42 * Module Description:
43 *
44 * Revision History:
45 *
46 * $brcm_Log: /nexus/modules/transport/7400/src/nexus_remux.c $
47 *
48 * 39   10/31/11 7:48p bandrews
49 * SW7231-391: merge to main
50 *
51 * SW7420-2078/1   10/25/11 5:22p bandrews
52 * SW7231-391: update parser band and timebase implementations to use
53 *  handles everywhere, even for legacy enum usage
54 *
55 * 38   8/4/11 9:42a erickson
56 * SW7346-394: fix chips w/o remux
57 *
58 * 37   8/3/11 2:15p erickson
59 * SW7346-394: call BXPT_DirecTvRemux_SetMode based on transportType
60 *
61 * 36   2/9/11 2:18p erickson
62 * SW7420-1009: support NEXUS_ANY_ID
63 *
64 * 35   1/26/11 3:40p jrubio
65 * SW7420-1237: fix warning
66 *
67 * 34   1/24/11 9:01a erickson
68 * SW7420-1237: fix warning for DTV
69 *
70 * 33   1/20/11 2:35p erickson
71 * SW7420-1237: support live and playback input to remux, allow per-parser
72 *  band input maxDataRate
73 *
74 * 32   7/23/10 4:44p jgarrett
75 * SW7420-902: Adding NULL packet insertion and SetSettings on-the-fly.
76 *
77 * 31   7/2/10 11:00a erickson
78 * SW7550-448: wrap BXPT_Remux_SetRSXCDataRate with chip-generic #if
79 *
80 * 30   6/30/10 1:54p erickson
81 * SW7405-3940: fix NEXUS_Remux_RemoveAllPidChannels
82 *
83 * 29   5/11/10 10:20a vishk
84 * SW7405-3940: re-code nexus_remux.c to use internal linked list instead
85 *  of an array of size NEXUS_MAX_REMUX_PID_CHANNELS.  Fixed memory leaks.
86 *
87 * 28   5/10/10 8:41p vishk
88 * SW7405-3940: re-code nexus_remux.c to use internal linked list instead
89 *  of an array of size NEXUS_MAX_REMUX_PID_CHANNELS
90 *
91 * 27   2/24/10 10:07a gmullen
92 * SW3548-2790: BXPT_Remux_SetPcrJitterAdj now returns a void
93 *
94 * 26   2/24/10 9:36a mward
95 * SW3548-2790: typo.
96 *
97 * 25   2/23/10 5:42p erickson
98 * SW3548-2790: added NEXUS_RemuxSettings.enablePcrJitterAdjust and
99 *  .playback
100 *
101 * 24   12/14/09 5:02p jrubio
102 * SW7342-11: fix 7340 remux
103 *
104 * 23   12/14/09 11:33a jrubio
105 * SW7342-11: add Remux for 7340/7342
106 *
107 * 22   10/20/09 5:56p jhaberf
108 * SW35230-1: BXPT_Remux_SetRSXCDataRate() is not required for the 35230.
109 *  #ifdef'd out calls to this function.
110 *
111 * 21   8/20/09 4:29p mward
112 * PR55545: Support 7125.
113 *
114 * 20   6/12/09 3:06p jtna
115 * PR55971: register remux as pidchannel consumer
116 *
117 * 19   5/22/09 8:53a erickson
118 * PR55402: fix playback parser band support for remux
119 *
120 * 18   4/20/09 10:21a erickson
121 * PR53728: apply maxDataRate to playback or input band correctly
122 *
123 * 17   4/17/09 12:31p erickson
124 * PR53728: added NEXUS_RemuxSettings.maxDataRate
125 *
126 * 16   3/28/09 10:03a erickson
127 * PR53417: added BXPT_Remux_AddPcrOffset for new remux systems. added
128 *  remux pacing support.
129 *
130 * 15   3/25/09 3:32p erickson
131 * PR53417: fix 7420
132 *
133 * 14   3/24/09 9:43a erickson
134 * PR53417: remove allPass setting for some chips. not needed.
135 *
136 * 13   3/23/09 5:05p erickson
137 * PR53417: temp fix for some chips with different remux api's
138 *
139 * 12   3/23/09 2:46p erickson
140 * PR53417: add NEXUS_RemuxSettings.bypass. Swap bypass and allPass.
141 *  Clarify usage comments. add NEXUS_RemuxSettings.pcrCorrectionEnabled
142 *  and pcrCorrectionOffset.
143 *
144 * 11   12/17/08 1:57p katrep
145 * PR49873: Add support for 7466
146 *
147 * 10   9/3/08 7:36p vishk
148 * PR 46315: Sample code for PID remapping
149 *
150 * 9   9/2/08 3:48p vishk
151 * PR39435 : Add remux capability to Nexus
152 *
153 * 8   9/2/08 11:45a erickson
154 * PR46315: added NEXUS_RemuxSettings.allPass
155 *
156 * 7   8/14/08 5:26p katrep
157 * PR45674: Fix compiiler warning in kernel mode non debug builds
158 *
159 * 6   4/11/08 9:53a erickson
160 * PR41246: convert BDBG_OBJECT_UNSET to BDBG_OBJECT_DESTROY if freeing
161 *  memory
162 *
163 * 5   4/1/08 4:41p erickson
164 * PR41152: fix bounds check
165 *
166 * 4   3/31/08 12:33p erickson
167 * PR41073: check result of malloc and fail graciously
168 *
169 * 3   3/17/08 11:27a erickson
170 * PR40350: convert ERR to MSG
171 *
172 * PR39899/1   3/14/08 8:09p shyam
173 * PR 40350 : Remove non error DBG_ERR messages
174 *
175 * 2   2/22/08 7:22p shyam
176 * PR39435: Add remux capability to Nexus
177 *
178 *****************************************************************************/
179
180#include "nexus_transport_module.h"
181BDBG_MODULE(nexus_remux);
182
183#if NEXUS_NUM_REMUX
184#if B_HAS_DSS
185#include "bxpt_directv_remux.h"
186#endif
187
188BDBG_OBJECT_ID(NEXUS_Remux);
189
190static NEXUS_Error NEXUS_Remux_P_Start(NEXUS_RemuxHandle handle);
191static void NEXUS_Remux_P_Stop(NEXUS_RemuxHandle handle);
192
193void NEXUS_Remux_GetDefaultSettings( NEXUS_RemuxSettings *pSettings )
194{
195    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
196    pSettings->insertNullPackets = true;
197}
198
199/* local storage for instance management */
200static NEXUS_RemuxHandle g_remux[NEXUS_NUM_REMUX];
201
202NEXUS_RemuxHandle NEXUS_Remux_Open( unsigned index, const NEXUS_RemuxSettings *pSettings )
203{
204    BERR_Code rc;
205    NEXUS_RemuxSettings settings;
206    NEXUS_RemuxHandle rmx;
207    unsigned numRmxChannels;
208    BXPT_Remux_ChannelSettings rmxChannelSettings;
209
210    if (!pSettings) {
211        NEXUS_Remux_GetDefaultSettings(&settings);
212        pSettings = &settings;
213    }
214
215    if (index == NEXUS_ANY_ID) {
216        for (index=0;index<NEXUS_NUM_REMUX;index++) {
217            if (!g_remux[index]) break;
218        }
219        if (index == NEXUS_NUM_REMUX) {
220            rc = BERR_TRACE(NEXUS_NOT_AVAILABLE);
221            return NULL;
222        }
223    }
224
225    if (index >= NEXUS_NUM_REMUX) {
226        rc = BERR_TRACE(NEXUS_INVALID_PARAMETER);
227        return NULL;
228    }
229
230    rmx = (NEXUS_RemuxHandle)BKNI_Malloc(sizeof(*rmx));
231    if (!rmx) {
232        rc=BERR_TRACE(NEXUS_OUT_OF_SYSTEM_MEMORY);
233        return NULL;
234    }
235    BKNI_Memset(rmx, 0, sizeof(*rmx));
236    BDBG_OBJECT_SET(rmx, NEXUS_Remux);
237    rmx->settings = *pSettings;
238
239    /* Open the Remux Transport block */
240    rc = BXPT_Remux_GetTotalChannels(pTransport->xpt, &numRmxChannels);
241    if(index >= numRmxChannels)
242    {
243        rc=BERR_TRACE(NEXUS_INVALID_PARAMETER);
244        goto error;
245    }
246
247    rc = BXPT_Remux_GetChannelDefaultSettings(pTransport->xpt, index, &rmxChannelSettings);
248    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
249
250    /* Map nexus params to XPT params */
251    if( pSettings->outputClock <= NEXUS_RemuxClock_e27Mhz_VCXO_A) {
252        rmxChannelSettings.OutputClock = pSettings->outputClock;
253    }
254    else {
255        rmxChannelSettings.OutputClock = pSettings->remuxClockIBSrc+BXPT_RemuxClock_eIb0;
256    }
257    if (rmxChannelSettings.OutputClock > BXPT_RemuxClock_eIb4) { /* TODO: XPT PI needs eMax */
258        rc = BERR_TRACE(NEXUS_INVALID_PARAMETER);
259        goto error;
260    }
261    rmxChannelSettings.ParallelEn = pSettings->parallelOutput;
262    rmxChannelSettings.InvertClk = pSettings->invertClock;
263    rmxChannelSettings.InvertSync = pSettings->invertSync;
264    rmxChannelSettings.ByteSync = pSettings->byteSync;
265    rmxChannelSettings.InsertNullPackets = pSettings->insertNullPackets;
266    rc = BXPT_Remux_OpenChannel(pTransport->xpt, &rmx->xptRmx, index, &rmxChannelSettings);
267    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
268
269    rmx->index = index;
270
271#if BXPT_HAS_REMUX_PCR_OFFSET
272    rc = BXPT_Remux_SetBypassMode(rmx->xptRmx, pSettings->bypass);
273    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
274
275    /* No allPass setting required on this chip. Just attach an allPass pid channel and all data will flow out. */
276
277    rc = BXPT_Remux_AddPcrOffset(rmx->xptRmx, pSettings->pcrCorrectionEnabled, pSettings->pcrCorrectionOffset);
278    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
279
280     BXPT_Remux_SetPcrJitterAdj(rmx->xptRmx, true, pSettings->enablePcrJitterAdjust);
281#else
282    rc = BXPT_Remux_SetBypassMode(rmx->xptRmx, pSettings->bypass);
283    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
284
285    rc = BXPT_Remux_SetAllPassMode(rmx->xptRmx, pSettings->allPass);
286    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
287
288    rc = BXPT_Remux_SetPcrCorrection(rmx->xptRmx, pSettings->pcrCorrectionEnabled, pSettings->pcrCorrectionOffset);
289    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
290
291    rc = BXPT_Remux_ConfigPacing(rmx->xptRmx, pSettings->pacing?BXPT_PacingControl_eStart:BXPT_PacingControl_eStop);
292    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
293
294    rc = BXPT_Remux_SetPacingErrorBound(rmx->xptRmx, pSettings->pacingMaxError);
295    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
296#endif
297
298    BLST_S_INIT(&rmx->pid_list);
299
300    g_remux[index] = rmx;
301    return rmx;
302
303error:
304    if (rmx->xptRmx) {
305        BXPT_Remux_CloseChannel(rmx->xptRmx);
306    }
307    BKNI_Free(rmx);
308    return NULL;
309}
310
311void NEXUS_Remux_Close( NEXUS_RemuxHandle handle )
312{
313    BDBG_OBJECT_ASSERT(handle, NEXUS_Remux);
314
315    NEXUS_Remux_RemoveAllPidChannels(handle);
316    BXPT_Remux_CloseChannel(handle->xptRmx);
317
318    g_remux[handle->index] = NULL;
319    BDBG_OBJECT_DESTROY(handle, NEXUS_Remux);
320    BKNI_Free(handle);
321}
322
323
324void NEXUS_Remux_GetDefaultParserBandwidth(NEXUS_RemuxParserBandwidth *pSettings)
325{
326    BKNI_Memset(pSettings, 0, sizeof(*pSettings));
327    pSettings->parserBand = NEXUS_ParserBand_eInvalid; /* force client to set, unless playback */
328    pSettings->maxDataRate = 25000000; /* 25Mbps*/
329}
330
331NEXUS_Error NEXUS_Remux_SetParserBandwidth( NEXUS_RemuxHandle handle,const NEXUS_RemuxParserBandwidth *pSettings)
332{
333    BERR_Code rc=BERR_SUCCESS;
334#if BXPT_HAS_RSBUF && BXPT_HAS_XCBUF
335    unsigned index,parserNum;
336    BXPT_ParserType parserType;
337    NEXUS_TransportType transportType;
338#endif
339
340    BDBG_OBJECT_ASSERT(handle, NEXUS_Remux);
341    BDBG_ASSERT(pSettings);
342#if BXPT_HAS_RSBUF && BXPT_HAS_XCBUF
343    if (pSettings->maxDataRate){
344        if(pSettings->playpump){
345            NEXUS_PlaypumpSettings playpumpSettings;
346            NEXUS_PlaypumpStatus playpumpStatus;
347            NEXUS_Playpump_GetSettings(pSettings->playpump,&playpumpSettings);
348            NEXUS_Playpump_GetStatus(pSettings->playpump,&playpumpStatus);
349            index = playpumpStatus.index + NEXUS_NUM_PARSER_BANDS;
350            parserNum = playpumpStatus.index;
351            parserType = BXPT_ParserType_ePb;
352            transportType = playpumpSettings.transportType;
353        }
354        else{
355            NEXUS_ParserBandHandle parserBand;
356            NEXUS_ParserBandSettings parserBandSettings;
357            parserType = BXPT_ParserType_eIb;
358            parserBand = NEXUS_ParserBand_Resolve_priv(pSettings->parserBand);
359            if (!parserBand) return BERR_TRACE(NEXUS_INVALID_PARAMETER);
360            parserNum = index = parserBand->hwIndex;
361            NEXUS_ParserBand_P_GetSettings(parserBand, &parserBandSettings);
362            transportType = parserBandSettings.transportType;
363        }
364
365        BKNI_Memcpy(&handle->remuxParserBandwidth[index],pSettings,sizeof(*pSettings));
366
367        rc = BXPT_Remux_SetRSXCDataRate( handle->xptRmx,parserNum,parserType,pSettings->maxDataRate ,
368                                     NEXUS_IS_DSS_MODE(transportType)?130:188);
369        if (rc) return BERR_TRACE(rc);
370    }
371#else
372     /* Do not call BXPT_Remux_SetRSXCDataRate() for chips that do not have RS and XC buffers */
373#endif
374    handle->parserBandCount++;
375    if(handle->parserBandCount > 2){
376        BDBG_WRN(("********* Please consult your FAE for bandwidth requirement if number of parser bands added to the remux is greater than 2 *************"));
377    }
378    return rc;
379}
380
381
382NEXUS_Error NEXUS_Remux_AddPidChannel( NEXUS_RemuxHandle handle, NEXUS_PidChannelHandle pidChannel )
383{
384    BERR_Code rc;
385    NEXUS_Remux_P_PidChannel *pid;
386    unsigned parserIndex;
387    bool firstPid;
388   
389    BDBG_OBJECT_ASSERT(handle, NEXUS_Remux);
390    BDBG_OBJECT_ASSERT(pidChannel, NEXUS_PidChannel);
391   
392    pid = BLST_S_FIRST(&handle->pid_list);
393    firstPid = !pid;
394    if (!firstPid) {
395        /* all pid channels must match on certain attributes */
396        if (pid->pidChn->status.transportType != pidChannel->status.transportType) {
397            return BERR_TRACE(NEXUS_INVALID_PARAMETER);
398        }
399    }   
400
401    pid = BKNI_Malloc(sizeof(NEXUS_Remux_P_PidChannel));
402    if ( NULL == pid )
403    {
404       return BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
405    }
406    pid->pidChn = pidChannel;
407   
408    BLST_S_DICT_ADD(&handle->pid_list, pid, NEXUS_Remux_P_PidChannel, pidChn, link, err_duplicate);
409
410#if B_HAS_DSS
411    if (firstPid) {
412        rc = BXPT_DirecTvRemux_SetMode(handle->xptRmx, NEXUS_IS_DSS_MODE(pidChannel->status.transportType)?BXPT_RemuxMode_eDirecTv:BXPT_RemuxMode_eMpeg);
413        if (rc) { rc = BERR_TRACE(rc); goto err_setmode;}
414    }
415#endif
416
417    rc = BXPT_Remux_AddPidChannelToRemux( handle->xptRmx, handle->index==0?BXPT_RemuxInput_eA:BXPT_RemuxInput_eB, pidChannel->status.pidChannelIndex);
418    if (rc) { rc = BERR_TRACE(rc); goto err_addpid;}
419
420    parserIndex = pidChannel->status.playback?(pidChannel->status.playbackIndex + NEXUS_NUM_PARSER_BANDS):pidChannel->parserBand->hwIndex;
421
422    handle->pidChannelCount[parserIndex]++;
423
424    if (handle->started) {
425        NEXUS_PidChannel_ConsumerStarted(pidChannel);
426    }
427
428    return 0;
429
430err_addpid:
431#if B_HAS_DSS
432err_setmode:
433#endif
434    BLST_S_DICT_REMOVE(&handle->pid_list, pid, pidChannel, NEXUS_Remux_P_PidChannel, pidChn, link);
435    BKNI_Free(pid);
436    return rc;
437   
438err_duplicate:
439    BKNI_Free(pid);
440    return BERR_TRACE(NEXUS_INVALID_PARAMETER);
441}
442
443NEXUS_Error NEXUS_Remux_RemovePidChannel( NEXUS_RemuxHandle handle, NEXUS_PidChannelHandle pidChannel )
444{
445    BERR_Code rc;
446    NEXUS_Remux_P_PidChannel *pid;
447    unsigned parserIndex;
448
449    BDBG_OBJECT_ASSERT(handle, NEXUS_Remux);
450    BDBG_OBJECT_ASSERT(pidChannel, NEXUS_PidChannel);
451
452    parserIndex = pidChannel->status.playback?(pidChannel->status.playbackIndex + NEXUS_NUM_PARSER_BANDS):pidChannel->parserBand->hwIndex;
453
454    BLST_S_DICT_REMOVE(&handle->pid_list, pid, pidChannel, NEXUS_Remux_P_PidChannel, pidChn, link);
455    if(!pid) { rc = BERR_TRACE(NEXUS_INVALID_PARAMETER); goto err_pid;}
456    BKNI_Free(pid);
457
458    BDBG_ASSERT(handle->pidChannelCount[parserIndex]);
459    handle->pidChannelCount[parserIndex]--;
460
461    rc = BXPT_Remux_RemovePidChannelFromRemux( handle->xptRmx, handle->index==0?BXPT_RemuxInput_eA:BXPT_RemuxInput_eB, pidChannel->status.pidChannelIndex);
462    if (rc) return BERR_TRACE(rc);
463
464    if (!handle->pidChannelCount[parserIndex]) {
465        handle->parserBandCount--;
466#if BXPT_HAS_RSBUF && BXPT_HAS_XCBUF
467        if(handle->remuxParserBandwidth[parserIndex].maxDataRate){
468            unsigned parserNum;
469            BXPT_ParserType parserType;
470            NEXUS_TransportType transportType;
471
472            if(pidChannel->status.playback){
473               parserNum = pidChannel->status.playbackIndex;
474               parserType = BXPT_ParserType_ePb;
475            }
476            else{
477                parserNum = (unsigned)pidChannel->parserBand->hwIndex;
478                parserType = BXPT_ParserType_eIb;
479            }
480            transportType = pidChannel->status.transportType;
481            rc = BXPT_Remux_SetRSXCDataRate( handle->xptRmx,parserType, parserNum,25000000,NEXUS_IS_DSS_MODE(transportType)?130:188);
482        if (rc) {rc = BERR_TRACE(rc);} /* fall through */
483
484    }
485#else
486    /* Do not call BXPT_Remux_SetRSXCDataRate() for chips that do not have RS and XC buffers */
487#endif
488    }
489    return 0;
490err_pid:
491    return rc;
492}
493
494void NEXUS_Remux_RemoveAllPidChannels( NEXUS_RemuxHandle handle )
495{
496    BERR_Code rc;
497    NEXUS_Remux_P_PidChannel *pid;
498#if BXPT_HAS_RSBUF && BXPT_HAS_XCBUF
499    unsigned i,parserNum;
500    BXPT_ParserType parserType;
501    NEXUS_TransportType transportType;
502#endif
503
504    BDBG_OBJECT_ASSERT(handle, NEXUS_Remux);
505
506    while(NULL!=(pid=BLST_S_FIRST(&handle->pid_list))) {
507        NEXUS_Error rc;
508        rc = NEXUS_Remux_RemovePidChannel(handle, pid->pidChn);
509        if (rc) break; /* avoid infinite loop */
510    }
511
512    handle->parserBandCount=0;
513    BKNI_Memset(handle->pidChannelCount,0,sizeof(handle->pidChannelCount));
514
515#if BXPT_HAS_RSBUF && BXPT_HAS_XCBUF
516    for(i=0;i<NEXUS_NUM_REMUX_PARSER_INPUTS;i++){
517        if(handle->remuxParserBandwidth[i].maxDataRate){
518            if(handle->remuxParserBandwidth[i].playpump){
519                NEXUS_PlaypumpSettings playpumpSettings;
520                NEXUS_PlaypumpStatus playpumpStatus;
521                NEXUS_Playpump_GetSettings(handle->remuxParserBandwidth[i].playpump,&playpumpSettings);
522                NEXUS_Playpump_GetStatus(handle->remuxParserBandwidth[i].playpump,&playpumpStatus);
523                parserNum = playpumpStatus.index;
524                parserType = BXPT_ParserType_ePb;
525                transportType = playpumpSettings.transportType;
526            }
527            else{
528                NEXUS_ParserBandHandle parserBand;
529                NEXUS_ParserBandSettings parserBandSettings;
530
531                parserType = BXPT_ParserType_eIb;
532                parserBand = NEXUS_ParserBand_Resolve_priv(handle->remuxParserBandwidth[i].parserBand);
533                if (!parserBand) return;/* can't do anything useful if this happens */
534
535                parserNum = parserBand->hwIndex;
536                NEXUS_ParserBand_P_GetSettings(parserBand, &parserBandSettings);
537                transportType = parserBandSettings.transportType;
538            }
539
540            rc = BXPT_Remux_SetRSXCDataRate( handle->xptRmx,parserType, parserNum, 25000000,NEXUS_IS_DSS_MODE(transportType)?130:188);
541            if (rc) {rc = BERR_TRACE(rc);} /* fall through */
542            BKNI_Memset(&handle->remuxParserBandwidth[i],0,sizeof(handle->remuxParserBandwidth[i]));
543        }
544    }
545#else
546    BSTD_UNUSED(rc);
547    /* Do not call BXPT_Remux_SetRSXCDataRate() for chips that do not have RS and XC buffers */
548#endif
549   return;
550}
551
552static NEXUS_Error NEXUS_Remux_P_Start(NEXUS_RemuxHandle handle)
553{
554    BERR_Code rc;
555    NEXUS_Remux_P_PidChannel *pid;
556
557    BDBG_OBJECT_ASSERT(handle, NEXUS_Remux);
558
559    if (handle->started) {
560        BDBG_ERR(("Remux already started"));
561        return BERR_TRACE(NEXUS_NOT_SUPPORTED);
562    }
563
564    BDBG_MSG(("NEXUS_Remux_P_Start %p", handle));
565    rc = BXPT_Remux_DoRemux(handle->xptRmx, true);
566    if(rc != BERR_SUCCESS) {
567        return BERR_TRACE(rc);
568    }
569
570    for ( pid = BLST_S_FIRST(&handle->pid_list); pid; pid = BLST_S_NEXT(pid, link) )
571    {
572        NEXUS_PidChannel_ConsumerStarted(pid->pidChn);
573    }
574
575    handle->started = true;
576    return NEXUS_SUCCESS;
577}
578
579NEXUS_Error NEXUS_Remux_Start(NEXUS_RemuxHandle handle)
580{
581    NEXUS_Error rc;
582    rc = NEXUS_Remux_P_Start(handle);
583    if(rc!=NEXUS_SUCCESS) {
584        return BERR_TRACE(rc);
585    }
586    return NEXUS_SUCCESS;
587}
588
589static void NEXUS_Remux_P_Stop( NEXUS_RemuxHandle handle )
590{
591    BDBG_OBJECT_ASSERT(handle, NEXUS_Remux);
592    BDBG_MSG(("NEXUS_Remux_Stop %p", handle));
593    if (handle->started) {
594        BERR_Code rc;
595        rc = BXPT_Remux_DoRemux(handle->xptRmx, false);
596        if(rc != BERR_SUCCESS) {rc = BERR_TRACE(rc);}
597        handle->started = false;
598    }
599}
600
601void NEXUS_Remux_Stop( NEXUS_RemuxHandle handle )
602{
603    NEXUS_Remux_P_Stop(handle);
604    return;
605}
606
607NEXUS_Error NEXUS_Remux_SetSettings(NEXUS_RemuxHandle handle,const NEXUS_RemuxSettings *pSettings)
608{
609    bool remux_restart_required=false;
610    BERR_Code rc;
611    BDBG_OBJECT_ASSERT(handle, NEXUS_Remux);
612    BDBG_ASSERT(pSettings);
613
614    if(handle->started)
615    {
616      NEXUS_Remux_P_Stop(handle);
617      remux_restart_required=true;
618    }
619
620    #if BXPT_HAS_REMUX_PCR_OFFSET
621    if(pSettings->bypass != handle->settings.bypass){
622    rc = BXPT_Remux_SetBypassMode(handle->xptRmx, pSettings->bypass);
623    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
624    handle->settings.bypass = pSettings->bypass ;
625    }
626    /* No allPass setting required on this chip. Just attach an allPass pid channel and all data will flow out. */
627    if(pSettings->pcrCorrectionEnabled!=handle->settings.pcrCorrectionEnabled
628       || pSettings->pcrCorrectionOffset!= handle->settings.pcrCorrectionOffset){
629    rc = BXPT_Remux_AddPcrOffset(handle->xptRmx, pSettings->pcrCorrectionEnabled, pSettings->pcrCorrectionOffset);
630    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
631    handle->settings.pcrCorrectionEnabled=pSettings->pcrCorrectionEnabled;
632    }
633    if(pSettings->enablePcrJitterAdjust!=handle->settings.enablePcrJitterAdjust){
634     BXPT_Remux_SetPcrJitterAdj(handle->xptRmx, true, pSettings->enablePcrJitterAdjust);
635     handle->settings.enablePcrJitterAdjust = pSettings->enablePcrJitterAdjust;
636    }
637    #else
638
639    if(pSettings->bypass != handle->settings.bypass){
640    rc = BXPT_Remux_SetBypassMode(handle->xptRmx, pSettings->bypass);
641    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
642    handle->settings.bypass = pSettings->bypass ;
643    }
644
645    if(pSettings->allPass!=handle->settings.allPass){
646    rc = BXPT_Remux_SetAllPassMode(handle->xptRmx, pSettings->allPass);
647    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
648    handle->settings.allPass = pSettings->allPass;
649    }
650
651    if(pSettings->pcrCorrectionEnabled!=handle->settings.pcrCorrectionEnabled
652       || pSettings->pcrCorrectionOffset!= handle->settings.pcrCorrectionOffset){
653    rc = BXPT_Remux_SetPcrCorrection(handle->xptRmx, pSettings->pcrCorrectionEnabled, pSettings->pcrCorrectionOffset);
654    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
655    handle->settings.pcrCorrectionEnabled = pSettings->pcrCorrectionEnabled;
656    handle->settings.pcrCorrectionOffset = pSettings->pcrCorrectionOffset;
657    }
658
659    if(pSettings->pacing!=handle->settings.pacing){
660    rc = BXPT_Remux_ConfigPacing(handle->xptRmx, pSettings->pacing?BXPT_PacingControl_eStart:BXPT_PacingControl_eStop);
661    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
662    handle->settings.pacing = pSettings->pacing;
663    }
664
665    if(pSettings->pacingMaxError!=handle->settings.pacingMaxError){
666    rc = BXPT_Remux_SetPacingErrorBound(handle->xptRmx, pSettings->pacingMaxError);
667    if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
668    handle->settings.pacingMaxError = pSettings->pacingMaxError;
669    }
670    #endif
671
672    if(remux_restart_required)
673    {
674      rc = NEXUS_Remux_P_Start(handle);
675      if (rc != BERR_SUCCESS) { rc = BERR_TRACE(rc); goto error; }
676    }
677
678    return NEXUS_SUCCESS;
679error:
680     return rc;
681}
682
683void NEXUS_Remux_GetSettings(NEXUS_RemuxHandle handle,NEXUS_RemuxSettings *pSettings)
684{
685    BDBG_OBJECT_ASSERT(handle, NEXUS_Remux);
686    BDBG_ASSERT(pSettings);
687    *pSettings = handle->settings;
688    return;
689}
690
691#else
692
693void NEXUS_Remux_GetDefaultSettings(
694    NEXUS_RemuxSettings *pSettings /* [out] */
695    )
696{
697    BSTD_UNUSED(pSettings);
698    BDBG_WRN(("Remux not enabled on this chipset"));
699    BERR_TRACE(BERR_NOT_SUPPORTED);
700    return;
701}
702
703
704NEXUS_RemuxHandle NEXUS_Remux_Open( /* attr{destructor=NEXUS_Remux_Close} */
705    unsigned index,
706    const NEXUS_RemuxSettings *pSettings
707    )
708{
709    BSTD_UNUSED(index);
710    BSTD_UNUSED(pSettings);
711    BDBG_WRN(("Remux not enabled on this chipset"));
712    BERR_TRACE(BERR_NOT_SUPPORTED);
713    return NULL;
714}
715
716/*
717Summary:
718Close the remux channel
719*/
720void NEXUS_Remux_Close(
721    NEXUS_RemuxHandle handle
722    )
723{
724    BSTD_UNUSED(handle);
725    BDBG_WRN(("Remux not enabled on this chipset"));
726    BERR_TRACE(BERR_NOT_SUPPORTED);
727    return;
728}
729
730void NEXUS_Remux_GetDefaultParserBandwidth(NEXUS_RemuxParserBandwidth *pSettings)
731{
732    BSTD_UNUSED(pSettings);
733    BDBG_WRN(("Remux not enabled on this chipset"));
734    BERR_TRACE(BERR_NOT_SUPPORTED);
735    return;
736}
737
738NEXUS_Error NEXUS_Remux_SetParserBandwidth( NEXUS_RemuxHandle handle,const NEXUS_RemuxParserBandwidth *pSettings)
739{
740    BSTD_UNUSED(handle);
741    BSTD_UNUSED(pSettings);
742    BDBG_WRN(("Remux not enabled on this chipset"));
743    BERR_TRACE(BERR_NOT_SUPPORTED);
744    return 0;
745}
746/*
747Summary:
748Add a pid channel to the remux output
749*/
750NEXUS_Error NEXUS_Remux_AddPidChannel(
751    NEXUS_RemuxHandle handle,
752    NEXUS_PidChannelHandle pidChannel
753    )
754{
755    BSTD_UNUSED(handle);
756    BSTD_UNUSED(pidChannel);
757    BDBG_WRN(("Remux not enabled on this chipset"));
758    BERR_TRACE(BERR_NOT_SUPPORTED);
759    return 0;
760}
761
762NEXUS_Error NEXUS_Remux_RemovePidChannel(
763    NEXUS_RemuxHandle handle,
764    NEXUS_PidChannelHandle pidChannel
765    )
766{
767    BSTD_UNUSED(handle);
768    BSTD_UNUSED(pidChannel);
769    BDBG_WRN(("Remux not enabled on this chipset"));
770    BERR_TRACE(BERR_NOT_SUPPORTED);
771    return 0;
772}
773
774void NEXUS_Remux_RemoveAllPidChannels( NEXUS_RemuxHandle handle )
775{
776    BSTD_UNUSED(handle);
777    BDBG_WRN(("Remux not enabled on this chipset"));
778    BERR_TRACE(BERR_NOT_SUPPORTED);
779    return;
780}
781
782NEXUS_Error NEXUS_Remux_Start(
783    NEXUS_RemuxHandle handle
784    )
785{
786    BSTD_UNUSED(handle);
787    BDBG_WRN(("Remux not enabled on this chipset"));
788    BERR_TRACE(BERR_NOT_SUPPORTED);
789    return 0;
790}
791
792void NEXUS_Remux_Stop( NEXUS_RemuxHandle handle )
793{
794    BSTD_UNUSED(handle);
795    BDBG_WRN(("Remux not enabled on this chipset"));
796    BERR_TRACE(BERR_NOT_SUPPORTED);
797    return;
798}
799
800
801NEXUS_Error NEXUS_Remux_SetSettings(NEXUS_RemuxHandle handle,const NEXUS_RemuxSettings *pSettings)
802{
803    BSTD_UNUSED(handle);
804    BSTD_UNUSED(pSettings);
805    BDBG_WRN(("Remux not enabled on this chipset"));
806    BERR_TRACE(BERR_NOT_SUPPORTED);
807    return 0;
808}
809
810void NEXUS_Remux_GetSettings(NEXUS_RemuxHandle handle,NEXUS_RemuxSettings *pSettings)
811{
812    BSTD_UNUSED(handle);
813    BSTD_UNUSED(pSettings);
814    BDBG_WRN(("Remux not enabled on this chipset"));
815    BERR_TRACE(BERR_NOT_SUPPORTED);
816    return;
817}
818#endif /* NEXUS_NUM_REMUX */
819
820
Note: See TracBrowser for help on using the repository browser.