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

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

first commit

  • Property svn:executable set to *
File size: 13.5 KB
Line 
1/***************************************************************************
2 *     Copyright (c) 2003-2009, 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_wss.c $
11 * $brcm_Revision: Hydra_Software_Devel/4 $
12 * $brcm_Date: 6/24/09 4:38p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/portinginterface/vbi/7400/bvbi_wss.c $
19 *
20 * Hydra_Software_Devel/4   6/24/09 4:38p darnstein
21 * PR56289: BVBI compiles for 7340 chipset now.
22 *
23 * Hydra_Software_Devel/3   12/4/08 6:12p darnstein
24 * PR45819: remove some obsolete "alias central" logic.
25 *
26 * Hydra_Software_Devel/2   12/3/08 7:58p darnstein
27 * PR45819: New, more modular form of most BVBI source files.
28 *
29 * Hydra_Software_Devel/62   9/15/08 2:45p darnstein
30 * PR44539: add support for the latest version of the WSE core hardware.
31 * That is, the version present in 7601-A0.
32 *
33 * Hydra_Software_Devel/61   6/20/08 4:48p darnstein
34 * PR38956: adjust a THRESHOLD and a SYNC_LEVEL to get WSS decoding to
35 * work on 3548.
36 *
37 * Hydra_Software_Devel/60   5/12/08 9:11p darnstein
38 * PR42416: adjust decoder video line number when the frame comb work-
39 * around is in place.
40 *
41 * Hydra_Software_Devel/59   4/23/08 1:48p darnstein
42 * PR41309: fix start_delay for WSS encoder with 576P_50Hz output. Assumes
43 * use of the special 54 MHz VEC IT microcode. Thanks to Bo Zhang for
44 * test and measurement.
45 *
46 * Hydra_Software_Devel/58   4/21/08 11:13a darnstein
47 * PR41309: fix output video line number for 576P_50_Hz. Thanks to Bo
48 * Zhang.
49 *
50 * Hydra_Software_Devel/57   4/17/08 5:33p darnstein
51 * PR41309: Need to make a check for field parity a bit looser, for 576P
52 * use.
53 *
54 * Hydra_Software_Devel/56   4/17/08 4:18p darnstein
55 * PR41309: allow 576P_50Hz output. Requires special BVN configuration.
56 *
57 * Hydra_Software_Devel/55   4/2/08 7:55p darnstein
58 * PR38956: VBI software compiles now.
59 *
60 * Hydra_Software_Devel/54   3/19/08 7:40p darnstein
61 * PR40773: change start_delay for AMOE encoder to 0xE. Per Lin Ma.
62 *
63 * Hydra_Software_Devel/53   3/19/08 4:18p darnstein
64 * PR23201: Change HSYNC_DELAY to 0x40. This is required by change of
65 * VDEC_FE_0_HSTART.VBI setting.
66 *
67 * Hydra_Software_Devel/52   12/19/07 2:00p darnstein
68 * PR32758: use WSS decoder register settings provided by Brad Grossman.
69 *
70 * Hydra_Software_Devel/51   12/19/07 1:25p darnstein
71 * PR34586: increase start delay for WSS SECAM output. This compensates
72 * for new SECAM VEC microcode. The new microcode issues the start signal
73 * earlier in the video line.
74 *
75 * Hydra_Software_Devel/50   4/12/07 2:17p darnstein
76 * PR29235: fix computation of WSS parity bit. Same logic as fix on
77 * dedicated 7401 branch of ClearCase.
78 *
79 * Hydra_Software_Devel/49   2/20/07 10:44a darnstein
80 * PR27521: Apply software workaround. The TTE core is reset, at every
81 * video field. Also, the encoder output for the field NOT in use is
82 * disabled, at every video field.
83 *
84 * Hydra_Software_Devel/48   1/2/07 4:20p darnstein
85 * PR26872: Mechanically add SECAM to all cases where PAL formats are
86 * accepted.
87 *
88 * Hydra_Software_Devel/47   12/18/06 1:02p darnstein
89 * PR24573: Adapt to an odd register name for BCM97440-B0 chipset.
90 *
91 * Hydra_Software_Devel/46   12/15/06 4:17p darnstein
92 * PR24573: Continuation of previous checkin (sorry).
93 *
94 * Hydra_Software_Devel/45   12/15/06 3:47p darnstein
95 * PR24573: Adapt to different names for same registers across different
96 * chipsets.
97 *
98 * Hydra_Software_Devel/44   12/14/06 7:18p darnstein
99 * PR25990: Can compile for BCM97400-B0 now.
100 *
101 * Hydra_Software_Devel/43   11/16/06 4:46p darnstein
102 * PR25668: Mechanical changes to support the 97403 chipset.
103 *
104 * Hydra_Software_Devel/42   9/26/06 7:37p darnstein
105 * PR24573: The BVBI porting interface module now compiles for the 7440
106 * chipset. Correct operation has not been verified.
107 *
108 * Hydra_Software_Devel/41   9/1/06 4:48p darnstein
109 * PR23242: Use encoder auto-parity when available. Some code commented
110 * out because RDB header files are not ready yet.
111 *
112 * Hydra_Software_Devel/40   8/31/06 2:09p darnstein
113 * PR23869: clean up the handling of multiple VECs and VDECs.
114 *
115 * Hydra_Software_Devel/39   8/18/06 6:52p darnstein
116 * PR23178: basic compile on 93563 is possible.
117 *
118 * Hydra_Software_Devel/38   7/20/06 6:23p darnstein
119 * PR21688: name of reset bit varies by chip revision, phase of the moon,
120 * etc.
121 *
122 * Hydra_Software_Devel/37   7/20/06 2:23p darnstein
123 * PR21688: Use the new hardware soft reset scheme for later model chips.
124 *
125 * Hydra_Software_Devel/36   6/5/06 4:53p darnstein
126 * PR18010: Previous checkin was in error.
127 *
128 * Hydra_Software_Devel/35   6/5/06 4:41p darnstein
129 * PR18010: silence a compiler warning.
130 *
131 * Hydra_Software_Devel/34   5/3/06 2:24p darnstein
132 * PR18010: Get rid of parity bit computation until it can be properly
133 * tested. Remove extraneous call to BVBI_P_CC_ConfigForOthers() that was
134 * switching to PAL mode.
135 *
136 * Hydra_Software_Devel/33   5/3/06 2:14p darnstein
137 * PR20427: Add parity bit for WSS encoding. Try tuning a pixel offset for
138 * WSS decoding.
139 *
140 * Hydra_Software_Devel/32   1/16/06 12:40p darnstein
141 * PR18903: Use BSTD_UNUSED macro to suppress compiler warnings in
142 * VxWorks.
143 *
144 * Hydra_Software_Devel/31   12/5/05 7:30p darnstein
145 * PR18010: Implement work-around for the bad line number, together with
146 * an exception for customers that now depend on the bad line number.
147 *
148 * Hydra_Software_Devel/30   10/6/05 11:33a darnstein
149 * PR 16817: Use tuning recommended by Kin Fan Ho for WSS encoder. The
150 * setting is for WSE_PRIM_control.start_delay, This change affects ALL
151 * chips.
152 *
153 * Hydra_Software_Devel/29   9/23/05 2:47p darnstein
154 * PR13750: Proper use of BERR_TRACE and BERR_CODEs.
155 *
156 * Hydra_Software_Devel/28   9/19/05 2:57p darnstein
157 * PR17151: Check for chip name where needed. Also, convert to new scheme
158 * for testing chip revisions (BCHP_VER).
159 *
160 * Hydra_Software_Devel/27   8/22/05 8:12p darnstein
161 * PR16057: To support many different chips, use private #defines that
162 * specify number of VECs, VDECs, and (separately) pass-through VECs.
163 *
164 * Hydra_Software_Devel/26   8/8/05 3:09p darnstein
165 * PR13952: Adapt to slight changes to core registers in -C0 version of
166 * BCM97038 chip.
167 *
168 * Hydra_Software_Devel/25   4/14/05 12:01p darnstein
169 * PR 14720: For each reference to BCHP_REV_B[01], add a BCHP_REV_B2.
170 * Still untested.
171 *
172 * Hydra_Software_Devel/24   3/17/05 7:42p darnstein
173 * PR 14472: Eliminate references to secondary VEC if chip is 3560.
174 *
175 * Hydra_Software_Devel/23   3/11/05 3:49p darnstein
176 * PR 14426: use new _0 names for VDEC cores.
177 *
178 * Hydra_Software_Devel/22   1/5/05 4:27p jasonh
179 * PR 13700: Fixed VBI compile issues for 7038 C0.
180 *
181 * Hydra_Software_Devel/21   8/30/04 11:22a darnstein
182 * PR 12502: Fix a simple oversight.
183 *
184 * Hydra_Software_Devel/I656/1   6/28/04 1:10p darnstein
185 * 656 output is ready for testing.
186 *
187 * Hydra_Software_Devel/19   6/17/04 5:56p darnstein
188 * PR 9080: do a better job of handling the fact that WSS data only
189 * appears on top fields. Also, kludge up the software so that WSS works
190 * in NTSC.  This kills its use in PAL, so the kludges will have to be
191 * backed out when PAL is supported.
192 *
193 * Hydra_Software_Devel/18   3/4/04 4:25p darnstein
194 * PR 9080: add some functionality needed for progressive video formats.
195 *
196 * Hydra_Software_Devel/17   2/27/04 6:11p darnstein
197 * PR 9080: handle all PAL formats.  Add checks for supported video
198 * format.  Use Kin Fan Ho's register values.
199 *
200 * Hydra_Software_Devel/16   2/6/04 11:49a darnstein
201 * PR 9080: better handle VBI decoding errors.
202 *
203 * Hydra_Software_Devel/15   2/3/04 4:42p darnstein
204 * PR 9080: fix logic errors in handling decoding errors. A few other
205 * minor fixes.
206 *
207 * Hydra_Software_Devel/14   1/23/04 4:08p darnstein
208 * PR 9080: Routines used in (pseudo) ISRs have no critical sections.
209 *
210 * Hydra_Software_Devel/13   1/15/04 4:33p darnstein
211 * PR 9080: fix problems with critical sections.
212 *
213 * Hydra_Software_Devel/12   12/1/03 2:27p darnstein
214 * Correct name of a function.
215 *
216 * Hydra_Software_Devel/11   10/17/03 3:39p darnstein
217 * VBI encoding can be disabled for one field time.
218 *
219 * Hydra_Software_Devel/10   10/16/03 4:26p darnstein
220 * Use revised #define BAVC_SourceId_Vdec0.
221 *
222 * Hydra_Software_Devel/9   10/16/03 1:22p darnstein
223 * Fix usage of BDBG_ENTER(), BDBG_LEAVE().
224 *
225 * Hydra_Software_Devel/8   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/7   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/6   9/30/03 12:54p darnstein
234 * Fix minor syntax problem.
235 *
236 * Hydra_Software_Devel/5   9/29/03 5:01p darnstein
237 * Put in critical sections.
238 *
239 * Hydra_Software_Devel/4   9/25/03 4:49p darnstein
240 * BVBI module is mostly complete. The only things that I know are missing
241 * are the critical sections, 656 support, macrovision support, and LOTS
242 * OF TESTING.
243 *
244 * Hydra_Software_Devel/3   9/12/03 6:50p darnstein
245 * Done except for VPS, teletext, critical sections, and (lots of)
246 * testing.
247 *
248 * Hydra_Software_Devel/2   9/9/03 7:52p darnstein
249 * I think all API functions have been implemented, though some with
250 * stubs.
251 *
252 * Hydra_Software_Devel/1   8/29/03 10:57a darnstein
253 * WSS specific software to support VBI processing.
254 *
255 ***************************************************************************/
256
257#include "bstd.h"           /* standard types */
258#include "bdbg.h"           /* Dbglib */
259#include "bvbi.h"           /* VBI processing, this module. */
260#include "bkni.h"                       /* For critical sections */
261#include "bvbi_priv.h"      /* VBI internal data structures */
262
263BDBG_MODULE(BVBI);
264
265/***************************************************************************
266* Implementation of "BVBI_" API functions
267***************************************************************************/
268
269/***************************************************************************
270 *
271 */
272BERR_Code BVBI_Field_GetWSSData_isr(
273        BVBI_Field_Handle vbiData, 
274        uint16_t *pusWSSData
275)
276{
277        BVBI_P_Field_Handle* pVbi_Fld;
278        BERR_Code eErr = BERR_SUCCESS;
279
280        BDBG_ENTER(BVBI_Field_GetWSSData_isr);
281
282        /* check parameters */
283        BVBI_P_GET_FIELD_CONTEXT(vbiData, pVbi_Fld);
284        if((!pVbi_Fld) || (!pusWSSData))
285        {
286                return BERR_TRACE(BERR_INVALID_PARAMETER);
287        }
288
289        /* Verify that data is present on this field handle */
290        if (!(pVbi_Fld->ulWhichPresent & BVBI_P_SELECT_WSS))
291                return (BVBI_ERR_FIELD_NODATA);
292        else if (pVbi_Fld->ulErrInfo & BVBI_LINE_ERROR_WSS_NOENCODE)
293                eErr = (BVBI_ERR_FIELD_BADDATA);
294
295        /* Return data as requested */
296    *pusWSSData = pVbi_Fld->usWSSData;
297        BDBG_LEAVE(BVBI_Field_GetWSSData_isr);
298        return eErr;
299}
300
301/***************************************************************************
302 *
303 */
304BERR_Code BVBI_Field_SetWSSData_isr( 
305        BVBI_Field_Handle vbiData, uint16_t usWSSData )
306{
307        BVBI_P_Field_Handle* pVbi_Fld;
308
309        BDBG_ENTER(BVBI_Field_SetWSSData_isr);
310
311        /* check parameters */
312        BVBI_P_GET_FIELD_CONTEXT(vbiData, pVbi_Fld);
313        if(!pVbi_Fld)
314        {
315                BDBG_ERR(("Invalid parameter\n"));
316                return BERR_TRACE(BERR_INVALID_PARAMETER);
317        }
318
319        /* Store data as requested */
320    pVbi_Fld->usWSSData = usWSSData;
321
322        /* Indicate valid data is present */
323        pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_WSS;
324
325        BDBG_LEAVE(BVBI_Field_SetWSSData_isr);
326        return BERR_SUCCESS;
327}
328
329
330/***************************************************************************
331* Implementation of supporting WSS functions that are not in API
332***************************************************************************/
333
334
335BERR_Code BVBI_P_WSS_Init( BVBI_P_Handle *pVbi )
336{
337        uint8_t hwIndex;
338#if (BVBI_P_NUM_VDEC >= 1)
339        uint32_t ulCoreOffset;
340#endif
341
342        BDBG_ENTER(BVBI_P_WSS_Init);
343
344        /* Initialize WSS decoder */
345#if (BVBI_P_NUM_VDEC >= 1)
346        ulCoreOffset = 0x0;
347        BVBI_P_WSS_Dec_Init (pVbi->hReg, ulCoreOffset);
348#endif
349#if (BVBI_P_NUM_VDEC >= 2)
350        ulCoreOffset = BCHP_WSSD_1_Reset - BCHP_WSSD_0_Reset;
351        BVBI_P_WSS_Dec_Init (pVbi->hReg, ulCoreOffset);
352#endif
353
354        /* Initialize WSS encoders */
355        for (hwIndex = 0 ; hwIndex < BVBI_P_NUM_WSE ; ++hwIndex)
356                BVBI_P_WSS_Enc_Init (pVbi->hReg, hwIndex);
357#if (BVBI_P_NUM_WSE_656 > 0)
358        for (hwIndex = 0 ; hwIndex < BVBI_P_NUM_WSE_656 ; ++hwIndex)
359                BVBI_P_WSS_656_Enc_Init (pVbi->hReg, hwIndex);
360#endif
361
362        /* This line of code only serves to shut up a compiler warning: */
363        (void) BVBI_P_AddWSSparity (0);
364
365        BDBG_LEAVE(BVBI_P_WSS_Init);
366        return BERR_SUCCESS;
367}
368
369/***************************************************************************
370 *
371 */
372uint16_t BVBI_P_AddWSSparity (uint16_t usData)
373{
374    uint16_t usOriginalData = usData;
375    uint8_t uchParity       = 0;
376        static const uint16_t mask = 0x0008;
377
378        /* The computation only depends on the 3 LSbits */
379        uchParity += (usData & 0x1);
380        usData >>= 1;
381        uchParity += (usData & 0x1);
382        usData >>= 1;
383        uchParity += (usData & 0x1);
384
385        /* Debug code
386        printf ("%04x (p%d) -> %04x\n",
387                usOriginalData, uchParity,
388                (uchParity & 0x1) ?
389                        (usOriginalData & ~mask) : (usOriginalData | mask));
390        */
391
392        return 
393                (uchParity & 0x1) ? 
394                        (usOriginalData & ~mask) : (usOriginalData | mask);
395}
396
397
398/***************************************************************************
399* Static (private) functions
400***************************************************************************/
401
402/* End of file */
Note: See TracBrowser for help on using the repository browser.