source: svn/trunk/newcon3bcm2_21bu/magnum/portinginterface/vbi/7552/bvbi_cc.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: 12.9 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2008, 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_cc.c $
11 * $brcm_Revision: Hydra_Software_Devel/3 $
12 * $brcm_Date: 12/4/08 6:12p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/vbi/7400/bvbi_cc.c $
19 *
20 * Hydra_Software_Devel/3   12/4/08 6:12p darnstein
21 * PR45819: remove some obsolete "alias central" logic.
22 *
23 * Hydra_Software_Devel/2   12/3/08 7:56p darnstein
24 * PR45819: New, more modular form of most BVBI source files.
25 *
26 * Hydra_Software_Devel/64   5/13/08 12:02p darnstein
27 * PR42416: adjust decoder video line number when the frame comb work-
28 * around is in place.
29 *
30 * Hydra_Software_Devel/63   12/19/07 2:06p darnstein
31 * PR32758: apply register settings for PAL CC decode, provided by Brad
32 * Grossman.
33 *
34 * Hydra_Software_Devel/62   10/31/07 7:13p darnstein
35 * PR35463: Implement CC PAL decoding solution contributed by xkliu.
36 *
37 * Hydra_Software_Devel/61   2/20/07 10:43a darnstein
38 * PR27521: Apply software workaround. The TTE core is reset, at every
39 * video field. Also, the encoder output for the field NOT in use is
40 * disabled, at every video field.
41 *
42 * Hydra_Software_Devel/60   1/2/07 4:20p darnstein
43 * PR26872: Mechanically add SECAM to all cases where PAL formats are
44 * accepted.
45 *
46 * Hydra_Software_Devel/59   12/18/06 1:01p darnstein
47 * PR24573: Adapt to an odd register name for BCM97440-B0 chipset.
48 *
49 * Hydra_Software_Devel/58   12/15/06 3:45p darnstein
50 * PR24573: Adapt to an odd register name for BCM97440-A0 chipset.
51 *
52 * Hydra_Software_Devel/57   12/14/06 7:16p darnstein
53 * PR25990: Can compile for BCM97400-B0 now.
54 *
55 * Hydra_Software_Devel/56   10/19/06 5:47p darnstein
56 * PR24979: change horizontal offset of waveform when sending NTSC.
57 * Theory: VEC microcode changed in such a way that the register values
58 * are interpreted differently.
59 *
60 * Hydra_Software_Devel/55   9/26/06 7:37p darnstein
61 * PR24573: The BVBI porting interface module now compiles for the 7440
62 * chipset. Correct operation has not been verified.
63 *
64 * Hydra_Software_Devel/54   9/20/06 5:21p darnstein
65 * PR23621: The reset register name has been changed in RDB as per my
66 * request.
67 *
68 * Hydra_Software_Devel/53   8/31/06 2:09p darnstein
69 * PR23869: clean up the handling of multiple VECs and VDECs.
70 *
71 * Hydra_Software_Devel/52   8/18/06 6:50p darnstein
72 * PR23178: basic compile on 93563 is possible.
73 *
74 * Hydra_Software_Devel/51   7/20/06 2:22p darnstein
75 * PR21688: Use the new hardware soft reset scheme for later model chips.
76 *
77 * Hydra_Software_Devel/50   4/12/06 8:04p darnstein
78 * PR18010: When in PR18010 compatibility mode, put in 0x0400 for line
79 * number register fields. This is what the external MPEG encoder
80 * expects, apparently.
81 *
82 * Hydra_Software_Devel/49   1/16/06 12:39p darnstein
83 * PR18903: Use BSTD_UNUSED macro to suppress compiler warnings in
84 * VxWorks.
85 *
86 * Hydra_Software_Devel/48   12/5/05 7:29p darnstein
87 * PR18010: Implement work-around for the bad line number, together with
88 * an exception for customers that now depend on the bad line number.
89 *
90 * Hydra_Software_Devel/47   9/23/05 2:46p darnstein
91 * PR13750: Proper use of BERR_TRACE and BERR_CODEs.
92 *
93 * Hydra_Software_Devel/46   9/20/05 5:46p darnstein
94 * PR17162: Use new settings for GAIN and DELAY in CCE core. New settings
95 * only apply to 97038-C0 and later chips.
96 *
97 * Hydra_Software_Devel/45   9/19/05 2:56p darnstein
98 * PR17151: Check for chip name where needed. Also, convert to new scheme
99 * for testing chip revisions (BCHP_VER).
100 *
101 * Hydra_Software_Devel/44   8/22/05 8:11p darnstein
102 * PR16057: To support many different chips, use private #defines that
103 * specify number of VECs, VDECs, and (separately) pass-through VECs.
104 *
105 * Hydra_Software_Devel/43   7/25/05 5:19p darnstein
106 * PR15630, PR16218: Avoid reset of the CCE cores. This seems to cause
107 * the VEC to hang.
108 *
109 * Hydra_Software_Devel/42   6/16/05 3:12p darnstein
110 * PR 14487: fix typing error in previous checkin.
111 *
112 * Hydra_Software_Devel/41   6/15/05 5:05p darnstein
113 * PR 14487: Put in runtime checking for workaround for hardware PR 13583.
114 *
115 * Hydra_Software_Devel/40   6/15/05 12:03p darnstein
116 * PR 14487: bring up VBI decoding on 97038-C1.
117 *
118 * Hydra_Software_Devel/39   4/14/05 12:00p darnstein
119 * PR 14720: For each reference to BCHP_REV_B[01], add a BCHP_REV_B2.
120 * Still untested.
121 *
122 * Hydra_Software_Devel/38   4/4/05 3:42p darnstein
123 * PR 14696: Get rid of a compiler warning (minor).
124 *
125 * Hydra_Software_Devel/37   3/18/05 2:38p darnstein
126 * PR 14487: Eliminate an irritating compiler warning.
127 *
128 * Hydra_Software_Devel/36   3/17/05 6:09p darnstein
129 * PR 14472: Eliminate references to secondary VEC if chip is 3560.
130 *
131 * Hydra_Software_Devel/35   3/17/05 1:20p darnstein
132 * PR 14487: work around line counter bug in hardware.
133 *
134 * Hydra_Software_Devel/34   3/11/05 3:48p darnstein
135 * PR 14426: use new _0 names for VDEC cores.
136 *
137 * Hydra_Software_Devel/33   2/14/05 6:15p darnstein
138 * PR 14116:  Make accesses to Gain_Delay register conditional.  Avoid bus
139 * error.
140 *
141 * Hydra_Software_Devel/32   1/5/05 4:13p jasonh
142 * PR 13700: Fixed VBI compile issues for 7038 C0.
143 *
144 * Hydra_Software_Devel/31   11/17/04 1:40p darnstein
145 * PR 8365 : Removed Parity bit clear in BVBI_Field_GetCCData_isr().
146 *
147 * Hydra_Software_Devel/30   7/16/04 7:06p darnstein
148 * PR 9080: merge in 656 input and output work. Some testing and debugging
149 * remains to be done.
150 *
151 * Hydra_Software_Devel/I656/2   7/8/04 7:45p darnstein
152 * ITU-R 656 decoding of VBI seems to be ready for bring up.  Expect bugs.
153 *
154 * Hydra_Software_Devel/I656/1   6/28/04 1:10p darnstein
155 * 656 output is ready for testing.
156 *
157 * Hydra_Software_Devel/29   5/24/04 8:06p jasonh
158 * PR 11189: Merge down from B0 to main-line
159 *
160 * Hydra_Software_Devel/Refsw_Devel_7038_B0/2   5/6/04 6:17p darnstein
161 * PR 9080: for encoding, set delay_count to x16. Per Kin Fan Ho.
162 *
163 * Hydra_Software_Devel/Refsw_Devel_7038_B0/1   4/26/04 6:21p darnstein
164 * PR 9080: Set the correct delay_count value for encoding.  This register
165 * field was broken in the A0 chip.  It works fine now.
166 *
167 * Hydra_Software_Devel/26   4/26/04 5:52p darnstein
168 * PR 9080: fix the gain value for closed caption output.  Kin Fan Ho
169 * found the amplitutde of the waveform was much too low.
170 *
171 * Hydra_Software_Devel/25   4/2/04 6:41p darnstein
172 * PR 9080: Allow NTSC-J video format.
173 *
174 * Hydra_Software_Devel/24   3/4/04 4:25p darnstein
175 * PR 9080: add some functionality needed for progressive video formats.
176 *
177 * Hydra_Software_Devel/23   2/27/04 6:09p darnstein
178 * PR 9080: handle ALL of the PAL formats.
179 *
180 * Hydra_Software_Devel/22   2/19/04 2:50p darnstein
181 * PR 9493: Use new PAL format enums.
182 *
183 * Hydra_Software_Devel/21   2/6/04 11:49a darnstein
184 * PR 9080: better handle VBI decoding errors.
185 *
186 * Hydra_Software_Devel/20   2/3/04 4:42p darnstein
187 * PR 9080: fix logic errors in handling decoding errors. A few other
188 * minor fixes.
189 *
190 * Hydra_Software_Devel/19   1/27/04 6:23p darnstein
191 * PR 9080: Don't check for overrun errors on encoding.  It is only
192 * possible for closed caption encoding, anyway.
193 *
194 * Hydra_Software_Devel/18   1/23/04 4:10p darnstein
195 * PR 9080: Closed caption encoding and decoding seems to work for NTSC
196 * now.
197 *
198 * Hydra_Software_Devel/17   1/21/04 5:21p darnstein
199 * PR 9080: The porting interface API refers to closed caption data as a
200 * pair of bytes per video field.  Internally, the CC data is still
201 * stored as a 16-bit quantity, for speedy access to the chip registers.
202 *
203 * Hydra_Software_Devel/16   1/15/04 4:27p darnstein
204 * PR 9080: fix problems with critical sections. Other clean-ups.  Closed
205 * caption encoding seems to work now.
206 *
207 * Hydra_Software_Devel/15   12/19/03 5:06p darnstein
208 * PR 9080: adapt to changed BAVC enum for field polarity.
209 *
210 * Hydra_Software_Devel/14   12/1/03 2:28p darnstein
211 * Put default: in a switch statement in order to prevent a lint warning.
212 *
213 * Hydra_Software_Devel/13   11/25/03 1:26p darnstein
214 * Correct name of a function.
215 *
216 * Hydra_Software_Devel/12   10/17/03 3:38p darnstein
217 * VBI encoding can be disabled for one field time.
218 *
219 * Hydra_Software_Devel/11   10/16/03 4:25p darnstein
220 * Use revised #define BAVC_SourceId_Vdec0.
221 *
222 * Hydra_Software_Devel/10   10/16/03 1:21p darnstein
223 * Fix usage of BDBG_ENTER(), BDBG_LEAVE().
224 *
225 * Hydra_Software_Devel/9   10/9/03 3:57p darnstein
226 * Change name of several API functions to indicate that they may be
227 * called from an ISR.
228 *
229 * Hydra_Software_Devel/8   10/2/03 2:25p darnstein
230 * Remove improper use of BERR_TRACE.
231 * Put in some missing BDBG_LEAVE statements.
232 *
233 * Hydra_Software_Devel/7   9/29/03 5:00p darnstein
234 * Put in critical sections.
235 *
236 * Hydra_Software_Devel/6   9/25/03 4:48p darnstein
237 * BVBI module is mostly complete. The only things that I know are missing
238 * are the critical sections, 656 support, macrovision support, and LOTS
239 * OF TESTING.
240 *
241 * Hydra_Software_Devel/5   9/12/03 6:50p darnstein
242 * Done except for VPS, teletext, critical sections, and (lots of)
243 * testing.
244 *
245 * Hydra_Software_Devel/4   9/9/03 7:53p darnstein
246 * I think all API functions have been implemented, though some with
247 * stubs.
248 *
249 * Hydra_Software_Devel/3   9/2/03 8:08p darnstein
250 * Still not ready for use.
251 *
252 * Hydra_Software_Devel/2   8/29/03 6:47p darnstein
253 * Closed caption specific code to support VBI processing.
254 *
255 * Hydra_Software_Devel/1   8/29/03 10:55a darnstein
256 * Closed caption specific code to support VBI processing.
257 *
258 ***************************************************************************/
259
260#include "bstd.h"           /* standard types */
261#include "bdbg.h"           /* Dbglib */
262#include "bkni.h"                       /* For critical sections */
263#include "bvbi.h"           /* VBI processing, this module. */
264#include "bvbi_priv.h"      /* VBI internal data structures */
265
266BDBG_MODULE(BVBI);
267
268/***************************************************************************
269* Implementation of "BVBI_" API functions
270***************************************************************************/
271
272/***************************************************************************
273 *
274 */
275BERR_Code BVBI_Field_GetCCData_isr (
276        BVBI_Field_Handle fieldHandle, 
277        uint8_t           *pucLowByte, 
278        uint8_t          *pucHighByte
279)
280{
281        BVBI_P_Field_Handle* pVbi_Fld;
282        BERR_Code eErr = BERR_SUCCESS;
283
284        BDBG_ENTER(BVBI_Field_GetCCData_isr);
285
286        /* check parameters */
287        BVBI_P_GET_FIELD_CONTEXT(fieldHandle, pVbi_Fld);
288        if((!pVbi_Fld) || (!pucLowByte) || (!pucHighByte))
289        {
290                return BERR_TRACE(BERR_INVALID_PARAMETER);
291        }
292
293        /* Verify that data is present on this field handle */
294        if (!(pVbi_Fld->ulWhichPresent & BVBI_P_SELECT_CC))
295                return (BVBI_ERR_FIELD_NODATA);
296        else if (pVbi_Fld->ulErrInfo & BVBI_LINE_ERROR_CC_NOENCODE)
297                eErr = (BVBI_ERR_FIELD_BADDATA);
298
299        /* Return data as requested */
300        *pucLowByte  = pVbi_Fld->usCCData;
301        *pucHighByte = (pVbi_Fld->usCCData >> 8);
302
303        BDBG_LEAVE(BVBI_Field_GetCCData_isr);
304        return eErr;
305}
306
307/***************************************************************************
308 *
309 */
310BERR_Code BVBI_Field_SetCCData_isr( 
311        BVBI_Field_Handle fieldHandle, 
312         uint8_t             cLowByte, 
313         uint8_t            cHighByte
314)
315{
316        BVBI_P_Field_Handle* pVbi_Fld;
317
318        BDBG_ENTER(BVBI_SetCCData_isr);
319
320        /* check parameters */
321        BVBI_P_GET_FIELD_CONTEXT(fieldHandle, pVbi_Fld);
322        if(!pVbi_Fld)
323        {
324                BDBG_ERR(("Invalid parameter\n"));
325                return BERR_TRACE(BERR_INVALID_PARAMETER);
326        }
327
328        /* Store data as requested */
329    pVbi_Fld->usCCData = ((uint16_t)cHighByte << 8) | (uint16_t)cLowByte;
330
331        /* Indicate valid data is present */
332        pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_CC;
333
334        BDBG_LEAVE(BVBI_SetCCData_isr);
335        return BERR_SUCCESS;
336}
337
338
339/***************************************************************************
340* Implementation supporting closed caption functions that are not in API
341***************************************************************************/
342
343
344BERR_Code BVBI_P_CC_Init( BVBI_P_Handle *pVbi )
345{
346        uint8_t hwIndex;
347#if (BVBI_P_NUM_VDEC >= 1)
348        uint32_t ulCoreOffset;
349#endif
350
351        BDBG_ENTER(BVBI_P_CC_Init);
352
353        /* Initialize CC decoders */
354#if (BVBI_P_NUM_VDEC >= 1)
355        ulCoreOffset = 0x0;
356        BVBI_P_CC_Dec_Init (pVbi->hReg, ulCoreOffset);
357#endif
358#if (BVBI_P_NUM_VDEC >= 2)
359        ulCoreOffset = BCHP_CCD_1_RevID - BCHP_CCD_0_RevID;
360        BVBI_P_CC_Dec_Init (pVbi->hReg, ulCoreOffset);
361#endif
362
363        /* Initialize CC encoders */
364        for (hwIndex = 0 ; hwIndex < BVBI_P_NUM_CCE ; ++hwIndex)
365                BVBI_P_CC_Enc_Init (pVbi->hReg, false, hwIndex);
366#if (BVBI_P_NUM_CCE_656 > 0)
367        for (hwIndex = 0 ; hwIndex < BVBI_P_NUM_CCE_656 ; ++hwIndex)
368                BVBI_P_CC_Enc_Init (pVbi->hReg, true, hwIndex);
369#endif
370
371        BDBG_LEAVE(BVBI_P_CC_Init);
372        return BERR_SUCCESS;
373}
374
375/* End of file */
Note: See TracBrowser for help on using the repository browser.