source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/vbi/7552/bvbi_dec.c

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

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 33.1 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2010, Broadcom Corporation
3 *     All Rights Reserved
4 *     Confidential Property of Broadcom Corporation
5 *
6 *  THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *  AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *  EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: bvbi_dec.c $
11 * $brcm_Revision: Hydra_Software_Devel/6 $
12 * $brcm_Date: 4/9/10 7:37p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/vbi/7400/bvbi_dec.c $
19 *
20 * Hydra_Software_Devel/6   4/9/10 7:37p darnstein
21 * SW7125-256,SW7125-257: When creating decoder object, do all  ocations
22 * in a different order. This simplifies error-recovery logic for the
23 * benefit of Coverity.
24 *
25 * Hydra_Software_Devel/5   1/8/10 5:26p darnstein
26 * SW7408-15: compiling for chipsets without VDEC or IN656 results in
27 *      ed in warnings about unused variables and labels.
28 *
29 * Hydra_Software_Devel/4   12/10/09 6:46p darnstein
30 * SW7420-498: Move memory management from "apply changes" functions to
31 * "create" functions. Applies to teletext memory only.
32 *
33 * Hydra_Software_Devel/3   11/18/09 3:54p darnstein
34 * SW7468-24: Gemstar options now placed in dedicated data structure.
35 *
36 * Hydra_Software_Devel/2   2/20/09 12:37p darnstein
37 * PR49987: Add a missing piece of logic for the bBrokenDataCount option.
38 *
39 * Hydra_Software_Devel/1   12/3/08 8:01p darnstein
40 * PR45819:
41 *
42 ***************************************************************************/
43
44#include "bstd.h"           /* standard types */
45#include "bdbg.h"           /* Dbglib */
46#include "bkni.h"                       /* For critical sections */
47#include "bvbi.h"           /* VBI processing, this module. */
48#include "bvbi_priv.h"      /* VBI internal data structures */
49#ifdef BVBI_P_TTD_SCB2_ERROR
50#include "bmem.h"
51#endif
52
53BDBG_MODULE(BVBI);
54
55/***************************************************************************
56* Forward declarations of static (private) functions
57***************************************************************************/
58
59static BERR_Code BVBI_P_Decode_ApplyChanges (
60        BVBI_P_Decode_Handle* pVbi_Dec, BVBI_P_Decode_CNState* cnState, bool force);
61
62static BERR_Code BVBI_P_Decode_Set_VBI(
63        BVBI_Decode_Handle decodeHandle,
64        bool bEnabled,
65        uint32_t ulSelect_Standard);
66
67static BERR_Code BVBI_P_Decode_Get_VBI(
68        BVBI_Decode_Handle decodeHandle,
69        bool* pbEnabled,
70        uint32_t ulSelect_Standard);
71
72#if (BVBI_P_NUM_VDEC >= 1)
73static bool BVBI_P_Decode_IsDirty (
74        BVBI_P_Decode_Handle *pVbi_Dec, bool isActive, uint32_t ulSelect_Standard);
75#endif
76
77static void BVBI_P_Decode_ChangesApplied (BVBI_P_Decode_Handle *pVbi_Dec);
78
79
80/***************************************************************************
81* Implementation of API functions
82***************************************************************************/
83
84/***************************************************************************
85 *
86 */
87BERR_Code BVBI_Decode_Create(BVBI_Handle vbiHandle,
88                             BAVC_SourceId eSource,
89                             BVBI_Decode_Handle *pDecodeHandle)
90{
91        BVBI_P_Handle *pVbi;
92        BVBI_P_Decode_Handle *pVbi_Dec = NULL;
93        BVBI_P_TTData* pttDataT = NULL;
94        BVBI_P_TTData* pttDataB = NULL;
95#ifdef BVBI_P_TTD_SCB2_ERROR
96        BVBI_P_TTData* pttDataTs = NULL;
97        BVBI_P_TTData* pttDataBs = NULL;
98#endif
99        BERR_Code eErr = BERR_SUCCESS;
100
101        BDBG_ENTER(BVBI_Decode_Create);
102
103        /* check parameters */
104        BVBI_P_GET_CONTEXT(vbiHandle, pVbi);
105        if((!pVbi) || (!pDecodeHandle))
106        {
107                BDBG_ERR(("Invalid parameter\n"));
108                eErr = BERR_TRACE(BERR_INVALID_PARAMETER);
109                goto BVBI_Decode_Create_Done;
110        }
111
112        /* This check is important.  I don't have to do this check again when
113        decoding VBI data.  It saves time and simplifies the software. */
114        switch (eSource)
115        {
116        case BAVC_SourceId_eVdec0:
117                break;
118#if (BVBI_P_NUM_VDEC > 1)
119        case BAVC_SourceId_eVdec1:
120                break;
121#endif
122        case BAVC_SourceId_e656In0:
123                break;
124#if (BVBI_P_NUM_VDEC > 1)
125        case BAVC_SourceId_e656In1:
126                break;
127#endif
128        default:
129                BDBG_ERR(("Invalid parameter\n"));
130                eErr = BERR_TRACE(BERR_INVALID_PARAMETER);
131                goto BVBI_Decode_Create_Done;
132        }
133
134        /* Check to see if the caller has already opened a decode handle that
135           controls the same video source */
136        for (pVbi_Dec = BLST_D_FIRST (&pVbi->decode_contexts) ;
137                 pVbi_Dec ;
138                 pVbi_Dec = BLST_D_NEXT (pVbi_Dec, link))
139        {
140                if (pVbi_Dec->eSource == eSource)
141                {
142                        BDBG_ERR(("Multiple handles for one VBI core\n"));
143                        eErr = BERR_TRACE(BVBI_ERR_HW_CONFLICT);
144                        goto BVBI_Decode_Create_Done;
145                }
146        }
147
148        /* Alloc the VBI decode handle. */
149        pVbi_Dec =
150                (BVBI_P_Decode_Handle*)(BKNI_Malloc(sizeof(BVBI_P_Decode_Handle)));
151        if(!pVbi_Dec)
152        {
153                eErr = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
154                goto BVBI_Decode_Create_Done;
155        }
156
157        /* Clear out the context and set defaults. */
158        BKNI_Memset((void*)pVbi_Dec, 0x0, sizeof(BVBI_P_Decode_Handle));
159        pVbi_Dec->gsOptionsChanged = true;
160
161        /* Initialize current/next state */
162        pVbi_Dec->curr.eVideoFormat                      = BFMT_VideoFmt_eNTSC;
163        pVbi_Dec->curr.ulActive_Standards                = 0x0;
164        pVbi_Dec->curr.e656Format                        = BVBI_656Fmt_SAA7113;
165        pVbi_Dec->curr.SMPTE291Moptions.fParseCb         =
166                                                                                BVBI_Decode_656_SMPTE291MbrcmCb_isr;
167        pVbi_Dec->curr.SMPTE291Moptions.fParseCbArg0     = 0x0;
168        pVbi_Dec->curr.SMPTE291Moptions.bLongHeader      = false;
169        pVbi_Dec->curr.SMPTE291Moptions.bBrokenDataCount = true;
170        pVbi_Dec->curr.wssVline576i             = 23;
171        pVbi_Dec->curr.gsOptions.baseline_top   = 10;
172        pVbi_Dec->curr.gsOptions.linemask_top   = 0x01F;
173        pVbi_Dec->curr.gsOptions.baseline_bot   = 273;
174        pVbi_Dec->curr.gsOptions.linemask_bot   = 0x01F;
175        pVbi_Dec->next = pVbi_Dec->curr;
176
177        /* Save back pointer to VBI handle */
178        pVbi_Dec->pVbi = pVbi;
179
180        /* Remember where to decode from */
181        pVbi_Dec->eSource = eSource;
182
183        /* Initialize teletext pointers for LCO */
184        pttDataT = (BVBI_P_TTData*)(BKNI_Malloc(sizeof(BVBI_P_TTData)));
185        if(!pttDataT)
186        {
187                eErr = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
188                goto BVBI_Decode_Create_Done;
189        }
190        BKNI_Memset((void*)pttDataT, 0x0, sizeof(BVBI_P_TTData));
191        eErr = BVBI_P_TTData_Alloc (
192                pVbi->hMem, BVBI_TT_MAX_LINES, BVBI_TT_MAX_LINELENGTH, pttDataT);
193        if (eErr != BERR_SUCCESS)
194        {
195                eErr = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
196                goto BVBI_Decode_Create_Done;
197        }
198
199        pttDataB = (BVBI_P_TTData*)(BKNI_Malloc(sizeof(BVBI_P_TTData)));
200        if(!pttDataB)
201        {
202                eErr = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
203                goto BVBI_Decode_Create_Done;
204        }
205        BKNI_Memset((void*)pttDataB, 0x0, sizeof(BVBI_P_TTData));
206        eErr = BVBI_P_TTData_Alloc (
207                pVbi->hMem, BVBI_TT_MAX_LINES, BVBI_TT_MAX_LINELENGTH, pttDataB);
208        if (eErr != BERR_SUCCESS)
209        {
210                eErr = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
211                goto BVBI_Decode_Create_Done;
212        }
213
214#ifdef BVBI_P_TTD_SCB2_ERROR
215        pttDataTs = (uint8_t*)BMEM_AllocAligned (pVbi->hMem, 13*512, 10, 0);
216        if (!pttDataTs)
217        {
218                eErr = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
219                goto BVBI_Decode_Create_Done;
220        }
221        pVbi_Dec->topTTscratch = pttDataTs;
222        BKNI_Memset ((void*)(pVbi_Dec->topTTscratch), 0x0, 13*512);
223
224        pttDataBs = (uint8_t*)BMEM_AllocAligned (pVbi->hMem, 13*512, 10, 0);
225        if (!pttDataBs)
226        {
227                eErr = BERR_TRACE(BERR_OUT_OF_SYSTEM_MEMORY);
228                goto BVBI_Decode_Create_Done;
229        }
230        pVbi_Dec->botTTscratch = pttDataBs;
231        BKNI_Memset ((void*)(pVbi_Dec->botTTscratch), 0x0, 13*512);
232#endif
233
234        /* Initialize 656 ancillary data parser (software) */
235        if ((eSource == BAVC_SourceId_e656In0) ||
236            (eSource == BAVC_SourceId_e656In1))
237        {
238                if ((eErr = BERR_TRACE (BVBI_P_P656_Init (pVbi_Dec))) != 
239                        BERR_SUCCESS)
240                {
241                        goto BVBI_Decode_Create_Done;
242                }
243        }
244       
245        /* Smart pointers come last. This will make the error handling logic easier
246         * for Coverity to understand. */
247        BVBI_P_LCOP_CREATE (pVbi_Dec, topTTDataO, pttDataT, clink);
248        BVBI_P_LCOP_CREATE (pVbi_Dec, botTTDataO, pttDataB, clink);
249
250        /* Link decode context into VBI handle's list */
251        BLST_D_INSERT_HEAD (&pVbi->decode_contexts, pVbi_Dec, link);
252
253        /* Initialize magic number to the size of the struct */
254        pVbi_Dec->ulBlackMagic = sizeof(BVBI_P_Decode_Handle);
255
256        /* All done. now return the new fresh context to user. */
257        *pDecodeHandle = (BVBI_Decode_Handle)pVbi_Dec;
258
259BVBI_Decode_Create_Done:
260
261        /* In case of failure, take care of partial allocations */
262        if (BERR_SUCCESS != eErr) 
263        {
264#ifdef BVBI_P_TTD_SCB2_ERROR
265                if (NULL != pttDataBs)
266                        BMEM_Free (pVbi->hMem, (void*)pttDataBs);
267                if (NULL != pttDataTs)
268                        BMEM_Free (pVbi->hMem, (void*)pttDataTs);
269#endif
270                if (NULL != pttDataB)
271                {
272                        BVBI_P_TTData_Alloc (pVbi->hMem, 0, 0, pttDataB);
273                        BKNI_Free ((void*)pttDataB); 
274                }
275                if (NULL != pttDataT)
276                {
277                        BVBI_P_TTData_Alloc (pVbi->hMem, 0, 0, pttDataT);
278                        BKNI_Free ((void*)pttDataT); 
279                }
280                if (NULL != pVbi_Dec)
281                        BKNI_Free((void*)pVbi_Dec);
282        }
283
284        BDBG_LEAVE(BVBI_Decode_Create);
285        return eErr;
286}
287
288/***************************************************************************
289 *
290 */
291BERR_Code BVBI_Decode_Destroy(BVBI_Decode_Handle decodeHandle)
292{
293        BVBI_P_Handle *pVbi;
294        BVBI_P_Decode_Handle* pVbi_Dec;
295        BVBI_P_TTData* pttData;
296
297        BDBG_ENTER(BVBI_Decode_Destroy);
298
299        /* check parameters */
300        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
301        if(!pVbi_Dec)
302        {
303                BDBG_ERR(("Invalid parameter\n"));
304                return BERR_TRACE(BERR_INVALID_PARAMETER);
305        }
306
307        /* Shut down any active cores */
308        pVbi_Dec->next.ulActive_Standards = 0x0;
309        BVBI_Decode_ApplyChanges( decodeHandle );
310
311        /* The handle will be invalid */
312        pVbi_Dec->ulBlackMagic = 0;
313
314        /* Deallocate bulky data storage if necessary */
315        pVbi = pVbi_Dec->pVbi;
316        BVBI_P_LCOP_DESTROY (pVbi_Dec, topTTDataO, &pVbi->ttFreelist, clink);
317        pttData = BVBI_P_LCOP_GET (pVbi_Dec, topTTDataO);
318        BVBI_P_TTData_Alloc (pVbi->hMem, 0, 0, pttData);
319        BKNI_Free ((void*)pttData);
320        BVBI_P_LCOP_DESTROY (pVbi_Dec, botTTDataO, &pVbi->ttFreelist, clink);
321        pttData = BVBI_P_LCOP_GET (pVbi_Dec, botTTDataO);
322        BVBI_P_TTData_Alloc (pVbi->hMem, 0, 0, pttData);
323        BKNI_Free ((void*)pttData);
324#ifdef BVBI_P_TTD_SCB2_ERROR
325        BMEM_Free (pVbi->hMem, (void*)pVbi_Dec->topTTscratch);
326        BMEM_Free (pVbi->hMem, (void*)pVbi_Dec->botTTscratch);
327#endif
328
329        /* Shut down 656 ancillary data parser (software) */
330        if ((pVbi_Dec->eSource == BAVC_SourceId_e656In0) ||
331            (pVbi_Dec->eSource == BAVC_SourceId_e656In1))
332        {
333                BVBI_P_P656_DeInit (pVbi_Dec);
334        }
335
336        /* Unlink from parent VBI context */
337        BLST_D_REMOVE (&pVbi->decode_contexts, pVbi_Dec, link);
338
339        /* Release context in system memory */
340        BKNI_Free((void*)pVbi_Dec);
341
342        BDBG_LEAVE(BVBI_Decode_Destroy);
343        return BERR_SUCCESS;
344}
345
346/***************************************************************************
347 *
348 */
349BERR_Code BVBI_Decode_ApplyChanges( BVBI_Decode_Handle decodeHandle )
350{
351        BVBI_P_Decode_Handle *pVbi_Dec;
352        BERR_Code eErr;
353
354        BDBG_ENTER(BVBI_Decode_ApplyChanges);
355
356        /* check parameters */
357        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
358        if(!pVbi_Dec)
359        {
360                BDBG_ERR(("Invalid parameter\n"));
361                return BERR_TRACE(BERR_INVALID_PARAMETER);
362        }
363
364        /* Try to apply changes */
365        eErr = BVBI_P_Decode_ApplyChanges (pVbi_Dec, &pVbi_Dec->next, false);
366
367        /* On failure, restore state */
368        if (eErr != BERR_SUCCESS)
369        {
370                (void)BVBI_P_Decode_ApplyChanges (pVbi_Dec, &pVbi_Dec->curr, true);
371                goto done;
372        }
373
374        /* Hardware should now be fully programmed */
375        BVBI_P_Decode_ChangesApplied (pVbi_Dec);
376
377done:
378        BDBG_LEAVE(BVBI_Decode_ApplyChanges);
379        return eErr;
380}
381
382/***************************************************************************
383 *
384 */
385BERR_Code BVBI_Decode_SetVideoFormat(BVBI_Decode_Handle decodeHandle,
386                                                                         BFMT_VideoFmt eVideoFormat)
387{
388        BVBI_P_Decode_Handle *pVbi_Dec;
389
390        BDBG_ENTER(BVBI_Decode_SetVideoFormat);
391
392        /* check parameters */
393        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
394        if(!pVbi_Dec)
395        {
396                BDBG_ERR(("Invalid parameter\n"));
397                return BERR_TRACE(BERR_INVALID_PARAMETER);
398        }
399
400        /* Remember format as requested */
401        pVbi_Dec->next.eVideoFormat = eVideoFormat;
402
403        BDBG_LEAVE(BVBI_Decode_SetVideoFormat);
404        return BERR_SUCCESS;
405}
406
407/***************************************************************************
408 *
409 */
410BERR_Code BVBI_Decode_GetVideoFormat(BVBI_Decode_Handle decodeHandle,
411                                                                         BFMT_VideoFmt *peVideoFormat)
412{
413        BVBI_P_Decode_Handle *pVbi_Dec;
414
415        BDBG_ENTER(BVBI_Decode_GetVideoFormat);
416
417        /* check parameters */
418        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
419        if((!pVbi_Dec) || (!peVideoFormat))
420        {
421                BDBG_ERR(("Invalid parameter\n"));
422                return BERR_TRACE(BERR_INVALID_PARAMETER);
423        }
424
425        /* Return format as requested */
426        *peVideoFormat = pVbi_Dec->curr.eVideoFormat;
427
428        BDBG_LEAVE(BVBI_Decode_GetVideoFormat);
429        return BERR_SUCCESS;
430}
431
432/***************************************************************************
433 *
434 */
435BERR_Code BVBI_Decode_656_SetFormat(BVBI_Decode_Handle decodeHandle,
436                                                                        BVBI_656Fmt anci656Fmt)
437{
438        BVBI_P_Decode_Handle *pVbi_Dec;
439
440        BDBG_ENTER(BVBI_Decode_656_SetFormat);
441
442        /* check parameters */
443        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
444        if(!pVbi_Dec)
445        {
446                BDBG_ERR(("Invalid parameter\n"));
447                BDBG_LEAVE(BVBI_Decode_SetVideoFormat);
448                return BERR_TRACE(BERR_INVALID_PARAMETER);
449        }
450
451        /* Remember format as requested */
452        switch (anci656Fmt)
453        {
454        case BVBI_656Fmt_SAA7113:
455        case BVBI_656Fmt_SAA7114A:
456        case BVBI_656Fmt_SAA7114B:
457        case BVBI_656Fmt_SAA7114C:
458        case BVBI_656Fmt_SAA7115:
459        case BVBI_656Fmt_SMPTE291:
460                pVbi_Dec->next.e656Format = anci656Fmt;
461                break;
462        default:
463                BDBG_LEAVE(BVBI_Decode_SetVideoFormat);
464                return BERR_TRACE(BERR_INVALID_PARAMETER);
465        }
466
467        BDBG_LEAVE(BVBI_Decode_656_SetFormat);
468        return BERR_SUCCESS;
469}
470
471/***************************************************************************
472 *
473 */
474BERR_Code BVBI_Decode_656_GetFormat(BVBI_Decode_Handle decodeHandle,
475                                                                        BVBI_656Fmt* pAnci656Fmt)
476{
477        BVBI_P_Decode_Handle *pVbi_Dec;
478
479        BDBG_ENTER(BVBI_Decode_656_GetFormat);
480
481        /* check parameters */
482        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
483        if((!pVbi_Dec) || (!pAnci656Fmt))
484        {
485                BDBG_ERR(("Invalid parameter\n"));
486                return BERR_TRACE(BERR_INVALID_PARAMETER);
487        }
488
489        /* Return format as requested */
490        *pAnci656Fmt = pVbi_Dec->curr.e656Format;
491
492        BDBG_LEAVE(BVBI_Decode_656_GetFormat);
493        return BERR_SUCCESS;
494}
495
496/***************************************************************************
497 *
498 */
499BERR_Code BVBI_Decode_656_SetSMPTE291Moptions (
500        BVBI_Decode_Handle decodeHandle,
501        BVBI_Decode_656_SMPTE291M_Cb fParserCb_isr,
502        void* arg0,
503        bool bLongHeader,
504        bool bBrokenDataCount
505)
506{
507        BVBI_P_Decode_Handle *pVbi_Dec;
508
509        BDBG_ENTER(BVBI_Decode_656_SetSMPTE291Moptions);
510
511        /* check parameters */
512        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
513        if ((!pVbi_Dec) || (!fParserCb_isr))
514        {
515                BDBG_ERR(("Invalid parameter\n"));
516                return BERR_TRACE(BERR_INVALID_PARAMETER);
517        }
518
519        /* Remember options as requested */
520        pVbi_Dec->next.SMPTE291Moptions.fParseCb         = fParserCb_isr;
521        pVbi_Dec->next.SMPTE291Moptions.fParseCbArg0     = arg0;
522        pVbi_Dec->next.SMPTE291Moptions.bLongHeader      = bLongHeader;
523        pVbi_Dec->next.SMPTE291Moptions.bBrokenDataCount = bBrokenDataCount;
524
525        BDBG_LEAVE(BVBI_Decode_656_SetSMPTE291Moptions);
526        return BERR_SUCCESS;
527}
528
529/***************************************************************************
530 *
531 */
532BERR_Code BVBI_Decode_SetGemstarOptions(
533        BVBI_Decode_Handle decodeHandle,
534        const BVBI_GSOptions* gsOptions
535)
536{
537        BVBI_P_Decode_Handle *pVbi_Dec;
538
539        BDBG_ENTER(BVBI_Decode_SetGemstarOptions);
540
541        /* check parameters */
542        if (gsOptions == 0x0)
543        {
544                BDBG_ERR(("Invalid parameter\n"));
545                return BERR_TRACE(BERR_INVALID_PARAMETER);
546        }
547        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
548        if (!pVbi_Dec)
549        {
550                BDBG_ERR(("Invalid parameter\n"));
551                return BERR_TRACE(BERR_INVALID_PARAMETER);
552        }
553
554        if (gsOptions->baseline_bot <= 256)
555        {
556                BDBG_ERR(("Invalid parameter\n"));
557                return BERR_TRACE(BERR_INVALID_PARAMETER);
558        }
559
560        /* Remember options as requested */
561        pVbi_Dec->next.gsOptions = *gsOptions;
562        pVbi_Dec->gsOptionsChanged = true;
563
564        BDBG_LEAVE(BVBI_Decode_SetGemstarOptions);
565        return BERR_SUCCESS;
566}
567
568/***************************************************************************
569 *
570 */
571BERR_Code BVBI_Decode_GetGemstarOptions(
572        BVBI_Decode_Handle decodeHandle,
573        BVBI_GSOptions*    gsOptions
574)
575{
576        BVBI_P_Decode_Handle *pVbi_Dec;
577
578        BDBG_ENTER(BVBI_Decode_GetGemstarOptions);
579
580        /* check parameters */
581        if (gsOptions == 0x0)
582        {
583                BDBG_ERR(("Invalid parameter\n"));
584                return BERR_TRACE(BERR_INVALID_PARAMETER);
585        }
586        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
587        if (!pVbi_Dec)
588        {
589                BDBG_ERR(("Invalid parameter\n"));
590                return BERR_TRACE(BERR_INVALID_PARAMETER);
591        }
592
593        /* Return options as requested */
594        *gsOptions = pVbi_Dec->curr.gsOptions;
595
596        BDBG_LEAVE(BVBI_Decode_GetGemstarOptions);
597        return BERR_SUCCESS;
598}
599
600/***************************************************************************
601 *
602 */
603BERR_Code BVBI_Decode_SetWssOptions(
604        BVBI_Decode_Handle decodeHandle,
605        uint16_t              vline576i
606)
607{
608        BVBI_P_Decode_Handle *pVbi_Dec;
609
610        BDBG_ENTER(BVBI_Decode_SetWssOptions);
611
612        /* check parameters */
613        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
614        if (!pVbi_Dec)
615        {
616                BDBG_ERR(("Invalid parameter\n"));
617                return BERR_TRACE(BERR_INVALID_PARAMETER);
618        }
619
620        if (vline576i > 255)
621        {
622                BDBG_ERR(("Invalid parameter\n"));
623                return BERR_TRACE(BERR_INVALID_PARAMETER);
624        }
625
626        /* Remember options as requested */
627        pVbi_Dec->next.wssVline576i = vline576i;
628
629        BDBG_LEAVE(BVBI_Decode_SetWssOptions);
630        return BERR_SUCCESS;
631}
632
633/***************************************************************************
634 *
635 */
636BERR_Code BVBI_Decode_GetWssOptions(
637        BVBI_Decode_Handle decodeHandle,
638        uint16_t*            pVline576i
639)
640{
641        BVBI_P_Decode_Handle *pVbi_Dec;
642
643        BDBG_ENTER(BVBI_Decode_GetWssOptions);
644
645        /* check parameters */
646        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
647        if (!pVbi_Dec)
648        {
649                BDBG_ERR(("Invalid parameter\n"));
650                return BERR_TRACE(BERR_INVALID_PARAMETER);
651        }
652
653        if (pVline576i == 0x0) 
654        {
655                BDBG_ERR(("Invalid parameter\n"));
656                return BERR_TRACE(BERR_INVALID_PARAMETER);
657        }
658
659        /* Return options as requested */
660        *pVline576i = pVbi_Dec->curr.wssVline576i;
661
662        BDBG_LEAVE(BVBI_Decode_GetWssOptions);
663        return BERR_SUCCESS;
664}
665
666/***************************************************************************
667 *
668 */
669BERR_Code BVBI_Decode_Data_isr( BVBI_Decode_Handle decodeHandle,
670                                BVBI_Field_Handle  fieldHandle,
671                                                                BAVC_Polarity polarity )
672{
673        BVBI_P_Handle* pVbi;
674        BVBI_P_Decode_Handle* pVbi_Dec;
675        BVBI_P_Field_Handle*  pVbi_Fld;
676        BVBI_P_Decode_CNState* currentState;
677        uint32_t whatActive;
678#if (BVBI_P_NUM_VDEC >= 1)
679        uint32_t ulErrInfo = 0;
680#endif
681
682        BDBG_ENTER(BVBI_Decode_Data_isr);
683
684        /* check parameters */
685        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
686        if(!pVbi_Dec)
687        {
688                BDBG_ERR(("Invalid parameter\n"));
689                return BERR_TRACE(BERR_INVALID_PARAMETER);
690        }
691        pVbi = pVbi_Dec->pVbi;
692        currentState = &pVbi_Dec->curr;
693        whatActive = currentState->ulActive_Standards;
694        BVBI_P_GET_FIELD_CONTEXT(fieldHandle, pVbi_Fld);
695        if(!pVbi_Fld)
696        {
697                BDBG_ERR(("Invalid parameter\n"));
698                return BERR_TRACE(BERR_INVALID_PARAMETER);
699        }
700
701        /* Clear out the error bits.  The next set of function calls may
702           set them again. */
703        pVbi_Fld->ulErrInfo = 0x0;
704        pVbi_Fld->ulWhichPresent = 0x0;
705
706        /* Decode the various forms of analog VBI data as configured */
707        if ((pVbi_Dec->eSource == BAVC_SourceId_eVdec0) ||
708            (pVbi_Dec->eSource == BAVC_SourceId_eVdec1))
709        {
710#if (BVBI_P_NUM_VDEC >= 1) /** { **/
711                if (whatActive & BVBI_P_SELECT_CC)
712                {
713                        ulErrInfo = BVBI_P_CC_Decode_Data_isr (
714                                                        pVbi->hReg,
715                                                        pVbi_Dec->eSource,
716                                                        polarity,
717                                                        &pVbi_Fld->usCCData );
718                        if ( (ulErrInfo & BVBI_LINE_ERROR_CC_NODATA) == 0)
719                                pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_CC;
720                        pVbi_Fld->ulErrInfo |= ulErrInfo;
721                }
722                if (whatActive & BVBI_P_SELECT_CGMSA)
723                {
724                        ulErrInfo = BVBI_P_CGMS_Decode_Data_isr (
725                                                        pVbi->hReg,
726                                                        pVbi_Dec->eSource,
727                                                        polarity,
728                                                        &pVbi_Fld->ulCGMSData );
729                        if ( (ulErrInfo & BVBI_LINE_ERROR_CGMS_NODATA) == 0)
730                                pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_CGMSA;
731                        pVbi_Fld->ulErrInfo |= ulErrInfo;
732                }
733                if (whatActive & BVBI_P_SELECT_WSS)
734                {
735                        ulErrInfo = BVBI_P_WSS_Decode_Data_isr (
736                                                        pVbi->hReg,
737                                                        pVbi_Dec->eSource,
738                                                        polarity,
739                                                        &pVbi_Fld->usWSSData );
740                        if ( (ulErrInfo & BVBI_LINE_ERROR_WSS_NODATA) == 0)
741                                pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_WSS;
742                        pVbi_Fld->ulErrInfo |= ulErrInfo;
743                }
744#ifdef BVBI_P_HAS_VPSD
745                if (whatActive & BVBI_P_SELECT_VPS)
746                {
747                        ulErrInfo = BVBI_P_VPS_Decode_Data_isr (
748                                                        pVbi->hReg,
749                                                        pVbi_Dec->eSource,
750                                                        polarity,
751                                                        pVbi_Fld->pVPSData );
752                        if ( (ulErrInfo & BVBI_LINE_ERROR_VPS_NODATA) == 0)
753                                pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_VPS;
754                        pVbi_Fld->ulErrInfo |= ulErrInfo;
755                }
756#endif
757#ifdef BVBI_P_HAS_GSD
758                if (whatActive & BVBI_P_SELECT_GS)
759                {
760                        ulErrInfo = BVBI_P_GS_Decode_Data_isr (
761                                                        pVbi->hReg,
762                                                        pVbi_Dec->eSource,
763                                                        currentState->eVideoFormat,
764                                                        polarity,
765                                                        pVbi_Fld->pGSData );
766                        if ( (ulErrInfo & BVBI_LINE_ERROR_GEMSTAR_NODATA) == 0)
767                                pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_GS;
768                        pVbi_Fld->ulErrInfo |= ulErrInfo;
769                }
770#endif
771                if (whatActive & BVBI_P_SELECT_TT)
772                {
773                        /* Debug code
774                        *(uint32_t*)(pVbi_Fld->TTDataO.pucData) = 0xDEADBEEF;
775                        */
776                        BVBI_P_TTData* pttData;
777                        #ifdef BVBI_P_TTD_SCB2_ERROR
778                        uint8_t* ttScratch = 0x0;
779                        uint32_t scratchMask;
780                        int iBit;
781                        #endif
782                        if (polarity == BAVC_Polarity_eTopField)
783                        {
784                                BVBI_P_LCOP_TRANSFER_isr (
785                                        pVbi_Dec, topTTDataO, pVbi_Fld, TTDataO,
786                                        &pVbi->ttFreelist, clink);
787                                pttData = BVBI_P_LCOP_GET_isr (pVbi_Dec, topTTDataO);
788                                #ifdef BVBI_P_TTD_SCB2_ERROR
789                                ttScratch = pVbi_Dec->topTTscratch;
790                                #endif
791                        }
792                        else
793                        {
794                                BVBI_P_LCOP_TRANSFER_isr (
795                                        pVbi_Dec, botTTDataO, pVbi_Fld, TTDataO,
796                                        &pVbi->ttFreelist, clink);
797                                pttData = BVBI_P_LCOP_GET_isr (pVbi_Dec, botTTDataO);
798                                #ifdef BVBI_P_TTD_SCB2_ERROR
799                                ttScratch = pVbi_Dec->botTTscratch;
800                                #endif
801                        }
802                        #ifdef BVBI_P_TTD_SCB2_ERROR
803                        BKNI_Memcpy (pttData->pucData, ttScratch, 47);
804                        scratchMask = *(uint32_t*)(pttData->pucData);
805                        for (iBit = 0 ; iBit < 32 ; ++iBit)
806                        {
807                                uint32_t wiper = (1 << iBit);
808                                if ((scratchMask & wiper) != 0x0)
809                                {
810                                        *(uint32_t*)(pttData->pucData) = wiper;
811                                        break;
812                                }
813                        }
814                        #endif
815                        ulErrInfo = BVBI_P_TT_Decode_Data_isr (
816                                                        pVbi->hReg,
817                                                        pVbi->hMem,
818                                                        pVbi_Dec->eSource,
819                                                        currentState->eVideoFormat,
820                                                        polarity,
821                                                        pttData );
822                        /* Debug code
823                        *(uint32_t*)(pttData->pucData) = 0x0;
824                        */
825                        if ( (ulErrInfo & BVBI_LINE_ERROR_TELETEXT_NODATA) == 0)
826                        {
827                                int iLine;
828                                BVBI_P_TTData* capData = 
829                                        BVBI_P_LCOP_GET_isr (pVbi_Fld, TTDataO);
830                                uint32_t lineMask = *(uint32_t*)(capData->pucData);
831                                for (iLine = 0 ; iLine < capData->ucLines ; ++iLine)
832                                {
833                                        if ((lineMask & (1 << iLine)) != 0)
834                                                break;
835                                }
836                                capData->firstLine = iLine;
837                                capData->lineMask = (lineMask >> iLine);
838                                *(uint32_t*)(capData->pucData) = 0xFFFFFFFF;
839                                pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_TT;
840                        }
841                        pVbi_Fld->ulErrInfo |= ulErrInfo;
842                }
843#endif /** } (BVBI_P_NUM_VDEC >= 1) **/
844        }
845#if (BVBI_P_NUM_IN656 > 0) /** { **/
846        else /* Decode the various forms of ITU-R 656 VBI data as configured */
847        {
848                bool bDataFound;
849                BVBI_P_IN656_Decode_Data_isr (
850                                                        pVbi_Dec->pVbi->hReg,
851                                                        pVbi_Dec->eSource,
852                                                        polarity,
853                                                        &bDataFound);
854                if (bDataFound)
855                        BVBI_P_P656_Process_Data_isr (polarity, pVbi_Dec, pVbi_Fld);
856        }
857#endif /** } (BVBI_P_NUM_IN656 > 0) **/
858
859        /* Record the data's field polarity */
860        if (polarity == BAVC_Polarity_eFrame)
861                pVbi_Fld->polarityMask = (1<<BAVC_Polarity_eTopField);
862        else
863                pVbi_Fld->polarityMask = (1<<polarity);
864
865        BDBG_LEAVE(BVBI_Decode_Data_isr);
866        return BERR_SUCCESS;
867}
868
869/***************************************************************************
870 *
871 */
872static BERR_Code BVBI_P_Decode_ApplyChanges (
873        BVBI_P_Decode_Handle* pVbi_Dec, BVBI_P_Decode_CNState* cnState, bool force)
874{
875        BVBI_P_Handle *pVbi;
876        uint32_t whatActive;
877#if (BVBI_P_NUM_VDEC > 0) || (BVBI_P_NUM_IN656 > 0)
878        bool isActive;
879        BERR_Code eErr;
880#endif
881        BERR_Code firstErr = BERR_SUCCESS;
882
883        BDBG_ENTER(BVBI_P_Decode_ApplyChanges);
884
885#if (BVBI_P_NUM_VDEC == 0) && (BVBI_P_NUM_IN656 == 0)
886        BSTD_UNUSED(force);
887#endif
888
889        /* Get back pointer to VBI module, for convenience. */
890        pVbi = pVbi_Dec->pVbi;
891
892        /* More convenience */
893        whatActive = cnState->ulActive_Standards;
894
895        /* Program analog decoder cores not already done */
896        if ((pVbi_Dec->eSource == BAVC_SourceId_eVdec0) ||
897            (pVbi_Dec->eSource == BAVC_SourceId_eVdec1))
898        {
899#if (BVBI_P_NUM_VDEC > 0) /** { **/
900                isActive = ((whatActive & BVBI_P_SELECT_CC) != 0);
901                if (force ||
902                        BVBI_P_Decode_IsDirty (pVbi_Dec, isActive, BVBI_P_SELECT_CC))
903                {
904                        eErr = BERR_TRACE (BVBI_P_CC_Dec_Program (
905                                pVbi->hReg,
906                                pVbi_Dec->eSource,
907                                isActive,
908                                cnState->eVideoFormat));
909                        if (eErr != BERR_SUCCESS)
910                        {
911                                if (firstErr == BERR_SUCCESS)
912                                        firstErr = eErr;
913                                if (!force)
914                                        goto done;
915                        }
916                }
917                isActive = ((whatActive & BVBI_P_SELECT_CGMSA) != 0);
918                if (force ||
919                        BVBI_P_Decode_IsDirty (pVbi_Dec, isActive, BVBI_P_SELECT_CGMSA))
920                {
921                        eErr = BERR_TRACE (BVBI_P_CGMS_Dec_Program (
922                                pVbi->hReg, pVbi_Dec->eSource,
923                                isActive,
924                                cnState->eVideoFormat));
925                        if (eErr != BERR_SUCCESS)
926                        {
927                                if (firstErr == BERR_SUCCESS)
928                                        firstErr = eErr;
929                                if (!force)
930                                        goto done;
931                        }
932                }
933                isActive = ((whatActive & BVBI_P_SELECT_WSS) != 0);
934                if (force ||
935                        BVBI_P_Decode_IsDirty (pVbi_Dec, isActive, BVBI_P_SELECT_WSS))
936                {
937                        eErr = BERR_TRACE (BVBI_P_WSS_Dec_Program (
938                                pVbi->hReg,
939                                pVbi_Dec->eSource,
940                                isActive,
941                                cnState->eVideoFormat,
942                                cnState->wssVline576i));
943                        if (eErr != BERR_SUCCESS)
944                        {
945                                if (firstErr == BERR_SUCCESS)
946                                        firstErr = eErr;
947                                if (!force)
948                                        goto done;
949                        }
950                }
951#ifdef BVBI_P_HAS_VPSD
952                isActive = ((whatActive & BVBI_P_SELECT_VPS) != 0);
953                if (force ||
954                        BVBI_P_Decode_IsDirty (pVbi_Dec, isActive, BVBI_P_SELECT_VPS))
955                {
956                        eErr = BERR_TRACE (BVBI_P_VPS_Dec_Program (
957                                pVbi->hReg,
958                                pVbi_Dec->eSource,
959                                isActive,
960                                cnState->eVideoFormat));
961                        if (eErr != BERR_SUCCESS)
962                        {
963                                if (firstErr == BERR_SUCCESS)
964                                        firstErr = eErr;
965                                if (!force)
966                                        goto done;
967                        }
968                }
969#endif
970#ifdef BVBI_P_HAS_GSD
971                isActive = ((whatActive & BVBI_P_SELECT_GS) != 0);
972                if (force ||
973                        BVBI_P_Decode_IsDirty (pVbi_Dec, isActive, BVBI_P_SELECT_GS))
974                {
975                        eErr = BERR_TRACE (BVBI_P_GS_Dec_Program (
976                                pVbi->hReg,
977                                pVbi_Dec->eSource,
978                                isActive,
979                                cnState->eVideoFormat,
980                                &cnState->gsOptions));
981                        if (eErr != BERR_SUCCESS)
982                        {
983                                if (firstErr == BERR_SUCCESS)
984                                        firstErr = eErr;
985                                if (!force)
986                                        goto done;
987                        }
988                }
989#endif
990                isActive = ((whatActive & BVBI_P_SELECT_TT) != 0);
991                if (force ||
992                        BVBI_P_Decode_IsDirty (pVbi_Dec, isActive, BVBI_P_SELECT_TT))
993                {
994                        BVBI_P_TTData* ptopData = 0x0;
995                        BVBI_P_TTData* pbotData = 0x0;
996
997                        /* Allocate space for double buffering TT lines */
998                        if (isActive)
999                        {
1000                                BVBI_P_LCOP_WRITE (
1001                                        pVbi_Dec, topTTDataO, &pVbi->ttFreelist, clink);
1002                                ptopData = BVBI_P_LCOP_GET (pVbi_Dec, topTTDataO);
1003                                BVBI_P_LCOP_WRITE (
1004                                        pVbi_Dec, botTTDataO, &pVbi->ttFreelist, clink);
1005                                pbotData = BVBI_P_LCOP_GET (pVbi_Dec, botTTDataO);
1006                        }
1007
1008                        /* Debug code
1009                        *(uint32_t*)(pVbi_Dec->topTTDataO.pucData) = 0xDEADBEEF;
1010                        *(uint32_t*)(pVbi_Dec->botTTDataO.pucData) = 0xDEADBEEF;
1011                        */
1012
1013#ifdef BVBI_P_TTD_SCB2_ERROR
1014                        eErr = BERR_TRACE (BVBI_P_TT_Dec_Program (
1015                                pVbi->hReg,
1016                                pVbi->hMem,
1017                                pVbi_Dec->eSource,
1018                                isActive,
1019                                cnState->eVideoFormat,
1020                                pVbi_Dec->topTTscratch,
1021                                pVbi_Dec->botTTscratch,
1022                                ptopData,
1023                                pbotData));
1024#else
1025                        eErr = BERR_TRACE (BVBI_P_TT_Dec_Program (
1026                                pVbi->hReg,
1027                                pVbi->hMem,
1028                                pVbi_Dec->eSource,
1029                                isActive,
1030                                cnState->eVideoFormat,
1031                                ptopData,
1032                                pbotData));
1033#endif
1034                        if (eErr != BERR_SUCCESS)
1035                        {
1036                                if (firstErr == BERR_SUCCESS)
1037                                        firstErr = eErr;
1038                                if (!force)
1039                                        goto done;
1040                        }
1041                }
1042
1043                /* Program lines for interrupts, analog case */
1044                eErr = BERR_TRACE (BVBI_P_VDTOP_Dec_Program (
1045                        pVbi->hReg,
1046                        pVbi_Dec->eSource,
1047                        cnState->eVideoFormat));
1048                if (eErr != BERR_SUCCESS)
1049                {
1050                        if (firstErr == BERR_SUCCESS)
1051                                firstErr = eErr;
1052                        if (!force)
1053                                goto done;
1054                }
1055
1056#endif /** } (BVBI_P_NUM_VDEC > 0) **/
1057        }
1058        else /* Program 656 input cores */
1059        {
1060#if (BVBI_P_NUM_IN656 > 0) /** { **/
1061
1062                isActive = (whatActive != 0);
1063
1064                /* Program the IN656 core */
1065                eErr = BERR_TRACE (BVBI_P_IN656_Dec_Program (
1066                        pVbi->hReg,
1067                        pVbi->hMem,
1068                        pVbi_Dec->eSource,
1069                        isActive,
1070                        cnState->e656Format,
1071                        &(cnState->SMPTE291Moptions),
1072                        cnState->eVideoFormat,
1073                        pVbi_Dec->top656Data,
1074                        pVbi_Dec->bot656Data));
1075                if (eErr != BERR_SUCCESS)
1076                {
1077                        if (firstErr == BERR_SUCCESS)
1078                                firstErr = eErr;
1079                        if (!force)
1080                                goto done;
1081                }
1082
1083#if (BVBI_P_NUM_VDEC > 0)
1084                /* Program lines for interrupts, 656 case. */
1085                eErr = BERR_TRACE (BVBI_P_VDTOP_656_Dec_Program (
1086                        pVbi->hReg,
1087                        pVbi_Dec->eSource,
1088                        cnState->eVideoFormat));
1089                if (eErr != BERR_SUCCESS)
1090                {
1091                        if (firstErr == BERR_SUCCESS)
1092                                firstErr = eErr;
1093                        if (!force)
1094                                goto done;
1095                }
1096#endif
1097#endif /** } (BVBI_P_NUM_IN656 >= 1) **/
1098        }
1099
1100#if (BVBI_P_NUM_VDEC > 0) || (BVBI_P_NUM_IN656 > 0)
1101done:
1102#endif
1103        BDBG_LEAVE(BVBI_P_Decode_ApplyChanges);
1104        return firstErr;
1105}
1106
1107/***************************************************************************
1108 *
1109 */
1110BERR_Code BVBI_Decode_SetCC(BVBI_Decode_Handle decodeHandle, bool bEnabled)
1111{
1112        return BVBI_P_Decode_Set_VBI (decodeHandle, bEnabled, BVBI_P_SELECT_CC);
1113}
1114BERR_Code BVBI_Decode_SetCGMS(BVBI_Decode_Handle decodeHandle, bool bEnabled)
1115{
1116        return BVBI_P_Decode_Set_VBI (decodeHandle, bEnabled, BVBI_P_SELECT_CGMSA);
1117}
1118BERR_Code BVBI_Decode_SetWSS(BVBI_Decode_Handle decodeHandle, bool bEnabled)
1119{
1120        return BVBI_P_Decode_Set_VBI (decodeHandle, bEnabled, BVBI_P_SELECT_WSS);
1121}
1122BERR_Code BVBI_Decode_SetVPS(BVBI_Decode_Handle decodeHandle, bool bEnabled)
1123{
1124        return BVBI_P_Decode_Set_VBI (decodeHandle, bEnabled, BVBI_P_SELECT_VPS);
1125}
1126BERR_Code BVBI_Decode_SetTeletext(
1127        BVBI_Decode_Handle decodeHandle, bool bEnabled)
1128{
1129        return BVBI_P_Decode_Set_VBI (decodeHandle, bEnabled, BVBI_P_SELECT_TT);
1130}
1131BERR_Code BVBI_Decode_SetGemstar(BVBI_Decode_Handle decodeHandle, bool bEnabled)
1132{
1133        return BVBI_P_Decode_Set_VBI (decodeHandle, bEnabled, BVBI_P_SELECT_GS);
1134}
1135
1136BERR_Code BVBI_Decode_GetCC(BVBI_Decode_Handle decodeHandle, bool* pbEnabled)
1137{
1138        return BVBI_P_Decode_Get_VBI (decodeHandle, pbEnabled, BVBI_P_SELECT_CC);
1139}
1140BERR_Code BVBI_Decode_GetCGMS(BVBI_Decode_Handle decodeHandle, bool* pbEnabled)
1141{
1142        return BVBI_P_Decode_Get_VBI (decodeHandle, pbEnabled, BVBI_P_SELECT_CGMSA);
1143}
1144BERR_Code BVBI_Decode_GetWSS(BVBI_Decode_Handle decodeHandle, bool* pbEnabled)
1145{
1146        return BVBI_P_Decode_Get_VBI (decodeHandle, pbEnabled, BVBI_P_SELECT_WSS);
1147}
1148BERR_Code BVBI_Decode_GetVPS(BVBI_Decode_Handle decodeHandle, bool* pbEnabled)
1149{
1150        return BVBI_P_Decode_Get_VBI (decodeHandle, pbEnabled, BVBI_P_SELECT_VPS);
1151}
1152BERR_Code BVBI_Decode_GetTeletext(
1153        BVBI_Decode_Handle decodeHandle, bool* pbEnabled)
1154{
1155        return BVBI_P_Decode_Get_VBI (decodeHandle, pbEnabled, BVBI_P_SELECT_TT);
1156}
1157BERR_Code BVBI_Decode_GetGemstar(
1158        BVBI_Decode_Handle decodeHandle, bool* pbEnabled)
1159{
1160        return BVBI_P_Decode_Get_VBI (decodeHandle, pbEnabled, BVBI_P_SELECT_GS);
1161}
1162
1163/***************************************************************************
1164* Static (private) functions
1165***************************************************************************/
1166
1167/***************************************************************************
1168 *
1169 */
1170static BERR_Code BVBI_P_Decode_Set_VBI(
1171        BVBI_Decode_Handle decodeHandle,
1172        bool bEnabled,
1173        uint32_t ulSelect_Standard)
1174{
1175        BVBI_P_Decode_Handle *pVbi_Dec;
1176
1177        BDBG_ENTER(BVBI_P_Decode_Set_VBI);
1178
1179        /* check parameters */
1180        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
1181        if(!pVbi_Dec)
1182        {
1183                BDBG_ERR(("Invalid parameter\n"));
1184                return BERR_TRACE(BERR_INVALID_PARAMETER);
1185        }
1186
1187        /* Record change to desired state */
1188        if (bEnabled)
1189        {
1190                pVbi_Dec->next.ulActive_Standards |= ulSelect_Standard;
1191        }
1192        else
1193        {
1194                pVbi_Dec->next.ulActive_Standards &= ~ulSelect_Standard;
1195        }
1196
1197        BDBG_LEAVE(BVBI_P_Decode_Set_VBI);
1198        return BERR_SUCCESS;
1199}
1200
1201/***************************************************************************
1202 *
1203 */
1204static BERR_Code BVBI_P_Decode_Get_VBI(
1205        BVBI_Decode_Handle decodeHandle,
1206        bool* pbEnabled,
1207        uint32_t ulSelect_Standard)
1208{
1209        BVBI_P_Decode_Handle* pVbi_Dec;
1210
1211        BDBG_ENTER(BVBI_P_Decode_Get_VBI);
1212
1213        /* check parameters */
1214        BVBI_P_GET_DECODE_CONTEXT(decodeHandle, pVbi_Dec);
1215        if((!pVbi_Dec) || (!pbEnabled))
1216        {
1217                BDBG_ERR(("Invalid parameter\n"));
1218                return BERR_TRACE(BERR_INVALID_PARAMETER);
1219        }
1220
1221        /* Return info */
1222        *pbEnabled =
1223                ((pVbi_Dec->curr.ulActive_Standards & ulSelect_Standard) != 0);
1224
1225        BDBG_LEAVE(BVBI_P_Decode_Get_VBI);
1226        return BERR_SUCCESS;
1227}
1228
1229#if (BVBI_P_NUM_VDEC >= 1) /** { **/
1230/***************************************************************************
1231 *
1232 */
1233static bool BVBI_P_Decode_IsDirty (
1234        BVBI_P_Decode_Handle *pVbi_Dec, bool isActive, uint32_t ulSelect_Standard)
1235{
1236        BVBI_P_Decode_CNState* curr = &pVbi_Dec->curr;
1237        BVBI_P_Decode_CNState* next = &pVbi_Dec->next;
1238        bool retval = (
1239                ((next->eVideoFormat != curr->eVideoFormat) &&
1240                isActive)
1241                ||
1242                ((curr->ulActive_Standards & ulSelect_Standard) !=
1243                 (next->ulActive_Standards & ulSelect_Standard) )
1244          );
1245
1246        if (ulSelect_Standard == BVBI_P_SELECT_GS)
1247                retval = retval || pVbi_Dec->gsOptionsChanged;
1248
1249        else if (ulSelect_Standard == BVBI_P_SELECT_WSS)
1250                retval = retval || (curr->wssVline576i != next->wssVline576i);
1251
1252        return retval;
1253}
1254#endif /** } (BVBI_P_NUM_VDEC >= 1) **/
1255
1256/***************************************************************************
1257 *
1258 */
1259static void BVBI_P_Decode_ChangesApplied (BVBI_P_Decode_Handle *pVbi_Dec)
1260{
1261        pVbi_Dec->curr = pVbi_Dec->next;
1262        pVbi_Dec->gsOptionsChanged = false;
1263}
Note: See TracBrowser for help on using the repository browser.