| 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_cgms.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/3 $ |
|---|
| 12 | * $brcm_Date: 6/24/09 3:53p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/vbi/7400/bvbi_cgms.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/3 6/24/09 3:53p darnstein |
|---|
| 21 | * PR56289: now compiles for chipsets that do not have ITU-R 656 output. |
|---|
| 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/84 9/12/08 1:24p darnstein |
|---|
| 27 | * PR46112: Implement variant of CGMS-B (output) defined in CEA-805-D. |
|---|
| 28 | * |
|---|
| 29 | * Hydra_Software_Devel/82 7/18/08 2:08p darnstein |
|---|
| 30 | * PR44039: Adjusted line number for 480P input. I also adjusted the |
|---|
| 31 | * horizontal offset. Problem: this might not be optimal for all |
|---|
| 32 | * chipsets. |
|---|
| 33 | * |
|---|
| 34 | * Hydra_Software_Devel/81 6/26/08 7:51p darnstein |
|---|
| 35 | * PR40710: update for 50 Hz HDTV video formats. |
|---|
| 36 | * |
|---|
| 37 | * Hydra_Software_Devel/80 6/26/08 4:15p darnstein |
|---|
| 38 | * PR40709,PR40710: Adjust register settings for CGMS-B output with 720P |
|---|
| 39 | * video and 1080I video. |
|---|
| 40 | * |
|---|
| 41 | * Hydra_Software_Devel/79 6/24/08 7:32p darnstein |
|---|
| 42 | * PR40709: Choose a value for six bit CGMS-B header. |
|---|
| 43 | * |
|---|
| 44 | * Hydra_Software_Devel/78 6/24/08 6:22p darnstein |
|---|
| 45 | * PR40709: Tune up some register settings for CGMS-B output. More work to |
|---|
| 46 | * follow. |
|---|
| 47 | * |
|---|
| 48 | * Hydra_Software_Devel/77 6/24/08 2:17p darnstein |
|---|
| 49 | * PR38956: Got CGMS decoding to work for 1080i video. |
|---|
| 50 | * |
|---|
| 51 | * Hydra_Software_Devel/76 6/24/08 1:56p darnstein |
|---|
| 52 | * PR38956: Got CGMS decoding to work for 720P video. |
|---|
| 53 | * |
|---|
| 54 | * Hydra_Software_Devel/75 6/23/08 7:58p darnstein |
|---|
| 55 | * PR38956: Got CGMS decoding to work for 480P video. |
|---|
| 56 | * |
|---|
| 57 | * Hydra_Software_Devel/74 6/13/08 12:11p darnstein |
|---|
| 58 | * PR43463: Ror CGMSB, the BCHP_CGMSAE_PRIM_Reg_updt register must be |
|---|
| 59 | * programmed. |
|---|
| 60 | * |
|---|
| 61 | * Hydra_Software_Devel/73 6/6/08 5:34p darnstein |
|---|
| 62 | * PR38956: fix some typing errors in register names (CGMS-B output). |
|---|
| 63 | * |
|---|
| 64 | * Hydra_Software_Devel/72 4/28/08 7:49p darnstein |
|---|
| 65 | * PR38956: CGMS-B encoding ready for bring-up. Need accurate register |
|---|
| 66 | * settings for tuning. |
|---|
| 67 | * |
|---|
| 68 | * Hydra_Software_Devel/71 4/14/08 8:09p darnstein |
|---|
| 69 | * PR41309: Fix PULSE_WIDTH for IEC 62375 (576P_50Hz) output. |
|---|
| 70 | * |
|---|
| 71 | * Hydra_Software_Devel/70 4/4/08 3:07p darnstein |
|---|
| 72 | * PR41359: port PR36108 to main branch. Use CGMSAE core to produce |
|---|
| 73 | * WSS/576P waveform. |
|---|
| 74 | * |
|---|
| 75 | * Hydra_Software_Devel/69 4/2/08 7:54p darnstein |
|---|
| 76 | * PR38956: VBI software compiles now. |
|---|
| 77 | * |
|---|
| 78 | * Hydra_Software_Devel/68 3/19/08 5:38p darnstein |
|---|
| 79 | * PR40768: Change (CGMSAE)_FORMAT.INIT_DELAY to 0x20. Per Lin Ma. |
|---|
| 80 | * |
|---|
| 81 | * Hydra_Software_Devel/66 1/2/08 2:26p darnstein |
|---|
| 82 | * PR32758: use PAL decoder settings from Brad Grossman. |
|---|
| 83 | * |
|---|
| 84 | * Hydra_Software_Devel/65 11/27/07 3:00p darnstein |
|---|
| 85 | * PR37493: first guess at CGMS for 1080i_50Hz and 720p_50Hz. |
|---|
| 86 | * |
|---|
| 87 | * Hydra_Software_Devel/64 2/20/07 10:43a darnstein |
|---|
| 88 | * PR27521: Apply software workaround. The TTE core is reset, at every |
|---|
| 89 | * video field. Also, the encoder output for the field NOT in use is |
|---|
| 90 | * disabled, at every video field. |
|---|
| 91 | * |
|---|
| 92 | * Hydra_Software_Devel/63 12/14/06 7:18p darnstein |
|---|
| 93 | * PR25990: Can compile for BCM97400-B0 now. |
|---|
| 94 | * |
|---|
| 95 | * Hydra_Software_Devel/62 11/21/06 2:53p darnstein |
|---|
| 96 | * PR26103: I applied small changes to register settings specified by Dan |
|---|
| 97 | * Martinez. |
|---|
| 98 | * |
|---|
| 99 | * Hydra_Software_Devel/61 11/16/06 4:41p darnstein |
|---|
| 100 | * PR20428: Change the way interrupts for progressive video input is |
|---|
| 101 | * handled. This might have to be revisited. |
|---|
| 102 | * |
|---|
| 103 | * Hydra_Software_Devel/60 10/19/06 5:47p darnstein |
|---|
| 104 | * PR24979: change horizontal offset of waveform when sending NTSC. |
|---|
| 105 | * Theory: VEC microcode changed in such a way that the register values |
|---|
| 106 | * are interpreted differently. |
|---|
| 107 | * |
|---|
| 108 | * Hydra_Software_Devel/59 8/31/06 2:09p darnstein |
|---|
| 109 | * PR23869: clean up the handling of multiple VECs and VDECs. |
|---|
| 110 | * |
|---|
| 111 | * Hydra_Software_Devel/58 8/18/06 6:50p darnstein |
|---|
| 112 | * PR23178: basic compile on 93563 is possible. |
|---|
| 113 | * |
|---|
| 114 | * Hydra_Software_Devel/57 7/20/06 2:23p darnstein |
|---|
| 115 | * PR21688: Use the new hardware soft reset scheme for later model chips. |
|---|
| 116 | * |
|---|
| 117 | * Hydra_Software_Devel/56 5/26/06 1:20p darnstein |
|---|
| 118 | * PR21710: A field handle can be dequeued for encoding at any one of |
|---|
| 119 | * three times: top field, bottom field, or FRAME. FRAME is the new |
|---|
| 120 | * choice. The field handles themselves continue to be defined as top |
|---|
| 121 | * field, bottom field, or both. The new logic is when a field handle is |
|---|
| 122 | * dequeued at time FRAME, it is always encoded immediately. The rest of |
|---|
| 123 | * the logic is the same: a "top" field handle is only dequeued and |
|---|
| 124 | * encoded at "top field" time, same for bottoms. When setting up field |
|---|
| 125 | * interrupt callbacks, for progressive video output, the argument |
|---|
| 126 | * BAVC_Polarity_eFrame should be used now. |
|---|
| 127 | * |
|---|
| 128 | * Hydra_Software_Devel/55 5/3/06 2:30p darnstein |
|---|
| 129 | * PR18010: Remove extraneous call to BVBI_P_CC_ConfigForOthers() that |
|---|
| 130 | * might change the video format of closed caption encoder core. |
|---|
| 131 | * |
|---|
| 132 | * Hydra_Software_Devel/54 4/12/06 6:17p darnstein |
|---|
| 133 | * PR18010: Don't try to program encoders for don't exist for 656 output. |
|---|
| 134 | * |
|---|
| 135 | * Hydra_Software_Devel/53 1/16/06 12:40p darnstein |
|---|
| 136 | * PR18903: Use BSTD_UNUSED macro to suppress compiler warnings in |
|---|
| 137 | * VxWorks. |
|---|
| 138 | * |
|---|
| 139 | * Hydra_Software_Devel/52 12/22/05 6:08p darnstein |
|---|
| 140 | * PR11725: support HDTV formats in decoding. |
|---|
| 141 | * |
|---|
| 142 | * Hydra_Software_Devel/51 9/23/05 2:46p darnstein |
|---|
| 143 | * PR13750: Proper use of BERR_TRACE and BERR_CODEs. |
|---|
| 144 | * |
|---|
| 145 | * Hydra_Software_Devel/50 9/19/05 2:56p darnstein |
|---|
| 146 | * PR17151: Check for chip name where needed. Also, convert to new scheme |
|---|
| 147 | * for testing chip revisions (BCHP_VER). |
|---|
| 148 | * |
|---|
| 149 | * Hydra_Software_Devel/49 8/23/05 11:53a darnstein |
|---|
| 150 | * PR16057: Fix error in last checkin. Affects compilation for BCM93560. |
|---|
| 151 | * |
|---|
| 152 | * Hydra_Software_Devel/48 8/22/05 8:11p darnstein |
|---|
| 153 | * PR16057: To support many different chips, use private #defines that |
|---|
| 154 | * specify number of VECs, VDECs, and (separately) pass-through VECs. |
|---|
| 155 | * |
|---|
| 156 | * Hydra_Software_Devel/47 6/20/05 12:38p darnstein |
|---|
| 157 | * PR 15923: I missed something in last checkin. |
|---|
| 158 | * |
|---|
| 159 | * Hydra_Software_Devel/46 6/20/05 12:04p darnstein |
|---|
| 160 | * PR 15923: Adjust some #define's to support 93560 chip. |
|---|
| 161 | * |
|---|
| 162 | * Hydra_Software_Devel/45 4/14/05 12:00p darnstein |
|---|
| 163 | * PR 14720: For each reference to BCHP_REV_B[01], add a BCHP_REV_B2. |
|---|
| 164 | * Still untested. |
|---|
| 165 | * |
|---|
| 166 | * Hydra_Software_Devel/44 3/31/05 11:55a darnstein |
|---|
| 167 | * PR 13952: Apply different register settings for 7038-C0. |
|---|
| 168 | * |
|---|
| 169 | * Hydra_Software_Devel/44 3/31/05 11:53a darnstein |
|---|
| 170 | * PR 13952: Apply different register settings for 7038-C0. |
|---|
| 171 | * |
|---|
| 172 | * Hydra_Software_Devel/43 3/21/05 4:48p vsilyaev |
|---|
| 173 | * PR 14472: Fixed compile problem on 3560. |
|---|
| 174 | * |
|---|
| 175 | * Hydra_Software_Devel/42 3/17/05 6:14p darnstein |
|---|
| 176 | * PR 14472: Eliminate references to secondary VEC if chip is 3560. |
|---|
| 177 | * |
|---|
| 178 | * Hydra_Software_Devel/41 3/17/05 6:10p darnstein |
|---|
| 179 | * PR 14487: work around hardware bug with line count. |
|---|
| 180 | * |
|---|
| 181 | * Hydra_Software_Devel/40 3/11/05 3:48p darnstein |
|---|
| 182 | * PR 14426: use new _0 names for VDEC cores. |
|---|
| 183 | * |
|---|
| 184 | * Hydra_Software_Devel/39 1/5/05 4:26p jasonh |
|---|
| 185 | * PR 13700: Fixed VBI compile issues for 7038 C0. |
|---|
| 186 | * |
|---|
| 187 | * Hydra_Software_Devel/38 11/11/04 11:53a darnstein |
|---|
| 188 | * PR 13104: Fix a bad comment. |
|---|
| 189 | * |
|---|
| 190 | * Hydra_Software_Devel/37 10/28/04 4:30p darnstein |
|---|
| 191 | * PR 13104: The horizontal offset is now 11.u us, just what a customer |
|---|
| 192 | * wanted. Customer wanted a rise time of 0.14 us. The rise time is now |
|---|
| 193 | * 0.12 us, and this is the best that I can do. |
|---|
| 194 | * |
|---|
| 195 | * Hydra_Software_Devel/36 10/27/04 5:25p darnstein |
|---|
| 196 | * PR 13050: The microcode for setting line number in 480p analog output |
|---|
| 197 | * has been fixed. So, don't kludge line number any more. |
|---|
| 198 | * |
|---|
| 199 | * Hydra_Software_Devel/35 10/12/04 4:53p darnstein |
|---|
| 200 | * PR 12855: Adjust VBI line for 480p encoding. Clean up some sloppy |
|---|
| 201 | * coding too. |
|---|
| 202 | * |
|---|
| 203 | * Hydra_Software_Devel/34 10/1/04 4:48p darnstein |
|---|
| 204 | * PR 9080: For decoder, subtract 1 from video line number. Work-around |
|---|
| 205 | * for quirk in line counter logic elsewhere on chip. |
|---|
| 206 | * |
|---|
| 207 | * Hydra_Software_Devel/33 6/3/04 7:45p darnstein |
|---|
| 208 | * PR 11308: CGMS encoder now puts its data on line 41 for 480p video. |
|---|
| 209 | * |
|---|
| 210 | * Hydra_Software_Devel/32 5/5/04 4:31p darnstein |
|---|
| 211 | * PR 9080: for encoding 1080i CGMS, change init_delay to 0xB5, per Kin |
|---|
| 212 | * FanHo. |
|---|
| 213 | * |
|---|
| 214 | * Hydra_Software_Devel/31 5/5/04 3:48p darnstein |
|---|
| 215 | * PR 9080: for encoding 1080i CGMS, change init_delay to 0xB5, per Kin |
|---|
| 216 | * Fan Ho. |
|---|
| 217 | * |
|---|
| 218 | * Hydra_Software_Devel/30 5/3/04 12:54p darnstein |
|---|
| 219 | * PR 9080: change rise time for encoder to 1 for 480p video output (re. |
|---|
| 220 | * Kin Fan Ho). |
|---|
| 221 | * |
|---|
| 222 | * Hydra_Software_Devel/29 4/29/04 5:11p darnstein |
|---|
| 223 | * PR 9080: Tune init_delay and pulse_width for 480p and 720p video |
|---|
| 224 | * output. |
|---|
| 225 | * |
|---|
| 226 | * Hydra_Software_Devel/28 4/28/04 8:57p darnstein |
|---|
| 227 | * PR 9080: begin to bring up for HD standards. More tuning is required. |
|---|
| 228 | * |
|---|
| 229 | * Hydra_Software_Devel/27 4/2/04 6:42p darnstein |
|---|
| 230 | * PR 9080: Allow NTSC-J video format. |
|---|
| 231 | * |
|---|
| 232 | * Hydra_Software_Devel/26 3/18/04 11:11a darnstein |
|---|
| 233 | * PR 9080: use a "crude" method for clearing status bits upon decode. |
|---|
| 234 | * Necessary because of a hardware fault in A0 and B0 chips. |
|---|
| 235 | * |
|---|
| 236 | * Hydra_Software_Devel/25 3/4/04 8:07p darnstein |
|---|
| 237 | * PR 9080: adjust GAIN and INIT_DELAY values for 720P and 1080i video |
|---|
| 238 | * formats. Worked with Kin Fan to get these corrected values. |
|---|
| 239 | * |
|---|
| 240 | * Hydra_Software_Devel/24 3/4/04 4:26p darnstein |
|---|
| 241 | * PR 9080: add support for progressive and HDTV video formats. |
|---|
| 242 | * |
|---|
| 243 | * Hydra_Software_Devel/23 2/27/04 6:11p darnstein |
|---|
| 244 | * PR 9080: fix misuse of critical sections. |
|---|
| 245 | * |
|---|
| 246 | * Hydra_Software_Devel/22 2/26/04 3:13p darnstein |
|---|
| 247 | * PR 9906: When doing CRC computation in software, cache last computation |
|---|
| 248 | * for reuse, to save CPU cycles. |
|---|
| 249 | * |
|---|
| 250 | * Hydra_Software_Devel/21 2/26/04 2:05p darnstein |
|---|
| 251 | * PR 9906: Compute CRC in software for CGMS encoder. |
|---|
| 252 | * |
|---|
| 253 | * Hydra_Software_Devel/20 2/20/04 4:36p darnstein |
|---|
| 254 | * PR 9090: almost working. |
|---|
| 255 | * |
|---|
| 256 | * Hydra_Software_Devel/19 2/19/04 6:25p darnstein |
|---|
| 257 | * PR 9080: When responding to decoder interrupt, be more careful about |
|---|
| 258 | * clearing interrupt condition bits in control register. |
|---|
| 259 | * |
|---|
| 260 | * Hydra_Software_Devel/18 2/6/04 11:49a darnstein |
|---|
| 261 | * PR 9080: better handle VBI decoding errors. |
|---|
| 262 | * |
|---|
| 263 | * Hydra_Software_Devel/17 2/3/04 4:42p darnstein |
|---|
| 264 | * PR 9080: fix logic errors in handling decoding errors. A few other |
|---|
| 265 | * minor fixes. |
|---|
| 266 | * |
|---|
| 267 | * Hydra_Software_Devel/16 1/26/04 1:17p darnstein |
|---|
| 268 | * PR 8730: Comment out some debugging code that was causing compiler |
|---|
| 269 | * warnings. |
|---|
| 270 | * |
|---|
| 271 | * Hydra_Software_Devel/15 1/23/04 4:08p darnstein |
|---|
| 272 | * PR 9080: Routines used in (pseudo) ISRs have no critical sections. |
|---|
| 273 | * |
|---|
| 274 | * Hydra_Software_Devel/14 1/19/04 12:00p darnstein |
|---|
| 275 | * PR 9080: Tune some register values. Put in debugging code (temporary). |
|---|
| 276 | * |
|---|
| 277 | * Hydra_Software_Devel/13 1/15/04 4:28p darnstein |
|---|
| 278 | * PR 9080: fix problems with critical sections. |
|---|
| 279 | * |
|---|
| 280 | * Hydra_Software_Devel/12 12/19/03 5:07p darnstein |
|---|
| 281 | * PR 9080: adapt to changed BAVC enum for field polarity. |
|---|
| 282 | * |
|---|
| 283 | * Hydra_Software_Devel/11 12/1/03 2:27p darnstein |
|---|
| 284 | * Correct name of a function. |
|---|
| 285 | * |
|---|
| 286 | * Hydra_Software_Devel/10 10/17/03 3:38p darnstein |
|---|
| 287 | * VBI encoding can be disabled for one field time. |
|---|
| 288 | * |
|---|
| 289 | * Hydra_Software_Devel/9 10/16/03 4:26p darnstein |
|---|
| 290 | * Use revised #define BAVC_SourceId_Vdec0. |
|---|
| 291 | * |
|---|
| 292 | * Hydra_Software_Devel/8 10/16/03 1:21p darnstein |
|---|
| 293 | * Fix usage of BDBG_ENTER(), BDBG_LEAVE(). |
|---|
| 294 | * |
|---|
| 295 | * Hydra_Software_Devel/7 10/9/03 3:57p darnstein |
|---|
| 296 | * Change name of several API functions to indicate that they may be |
|---|
| 297 | * called from an ISR. |
|---|
| 298 | * |
|---|
| 299 | * Hydra_Software_Devel/6 10/2/03 2:24p darnstein |
|---|
| 300 | * Remove improper use of BERR_TRACE. |
|---|
| 301 | * Put in some missing BDBG_LEAVE statements. |
|---|
| 302 | * |
|---|
| 303 | * Hydra_Software_Devel/5 9/29/03 5:00p darnstein |
|---|
| 304 | * Put in critical sections. |
|---|
| 305 | * |
|---|
| 306 | * Hydra_Software_Devel/4 9/25/03 4:48p darnstein |
|---|
| 307 | * BVBI module is mostly complete. The only things that I know are missing |
|---|
| 308 | * are the critical sections, 656 support, macrovision support, and LOTS |
|---|
| 309 | * OF TESTING. |
|---|
| 310 | * |
|---|
| 311 | * Hydra_Software_Devel/3 9/12/03 6:50p darnstein |
|---|
| 312 | * Done except for VPS, teletext, critical sections, and (lots of) |
|---|
| 313 | * testing. |
|---|
| 314 | * |
|---|
| 315 | * Hydra_Software_Devel/2 9/9/03 7:53p darnstein |
|---|
| 316 | * I think all API functions have been implemented, though some with |
|---|
| 317 | * stubs. |
|---|
| 318 | * |
|---|
| 319 | * Hydra_Software_Devel/1 8/29/03 10:56a darnstein |
|---|
| 320 | * CGMS specific software to support VBI processing. |
|---|
| 321 | * |
|---|
| 322 | ***************************************************************************/ |
|---|
| 323 | |
|---|
| 324 | #include "bstd.h" /* standard types */ |
|---|
| 325 | #include "bdbg.h" /* Dbglib */ |
|---|
| 326 | #include "bkni.h" /* For critical sections */ |
|---|
| 327 | #include "bvbi.h" /* VBI processing, this module. */ |
|---|
| 328 | #include "bvbi_priv.h" /* VBI internal data structures */ |
|---|
| 329 | |
|---|
| 330 | BDBG_MODULE(BVBI); |
|---|
| 331 | |
|---|
| 332 | |
|---|
| 333 | /*************************************************************************** |
|---|
| 334 | * Forward declarations of static (private) functions |
|---|
| 335 | ***************************************************************************/ |
|---|
| 336 | |
|---|
| 337 | |
|---|
| 338 | /*************************************************************************** |
|---|
| 339 | * Implementation of "BVBI_" API functions |
|---|
| 340 | ***************************************************************************/ |
|---|
| 341 | |
|---|
| 342 | /*************************************************************************** |
|---|
| 343 | * |
|---|
| 344 | */ |
|---|
| 345 | BERR_Code |
|---|
| 346 | BVBI_Field_GetCGMSAData_isr( BVBI_Field_Handle vbiData, uint32_t *pulCGMSData ) |
|---|
| 347 | { |
|---|
| 348 | BVBI_P_Field_Handle* pVbi_Fld; |
|---|
| 349 | BERR_Code eErr = BERR_SUCCESS; |
|---|
| 350 | |
|---|
| 351 | BDBG_ENTER(BVBI_Field_GetCGMSAData_isr); |
|---|
| 352 | |
|---|
| 353 | /* check parameters */ |
|---|
| 354 | BVBI_P_GET_FIELD_CONTEXT(vbiData, pVbi_Fld); |
|---|
| 355 | if((!pVbi_Fld) || (!pulCGMSData)) |
|---|
| 356 | { |
|---|
| 357 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | /* Verify that data is present on this field handle */ |
|---|
| 361 | if (!(pVbi_Fld->ulWhichPresent & BVBI_P_SELECT_CGMSA)) |
|---|
| 362 | return (BVBI_ERR_FIELD_NODATA); |
|---|
| 363 | else if (pVbi_Fld->ulErrInfo & BVBI_LINE_ERROR_CGMS_NOENCODE) |
|---|
| 364 | eErr = (BVBI_ERR_FIELD_BADDATA); |
|---|
| 365 | |
|---|
| 366 | /* Return data as requested */ |
|---|
| 367 | *pulCGMSData = pVbi_Fld->ulCGMSData; |
|---|
| 368 | BDBG_LEAVE(BVBI_Field_GetCGMSAData_isr); |
|---|
| 369 | return eErr; |
|---|
| 370 | } |
|---|
| 371 | |
|---|
| 372 | /*************************************************************************** |
|---|
| 373 | * |
|---|
| 374 | */ |
|---|
| 375 | BERR_Code BVBI_Field_SetCGMSAData_isr( |
|---|
| 376 | BVBI_Field_Handle vbiData, uint32_t ulCGMSData ) |
|---|
| 377 | { |
|---|
| 378 | BVBI_P_Field_Handle* pVbi_Fld; |
|---|
| 379 | |
|---|
| 380 | BDBG_ENTER(BVBI_Field_SetCGMSAData_isr); |
|---|
| 381 | |
|---|
| 382 | /* check parameters */ |
|---|
| 383 | BVBI_P_GET_FIELD_CONTEXT(vbiData, pVbi_Fld); |
|---|
| 384 | if(!pVbi_Fld) |
|---|
| 385 | { |
|---|
| 386 | BDBG_ERR(("Invalid parameter\n")); |
|---|
| 387 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 388 | } |
|---|
| 389 | |
|---|
| 390 | /* Store data as requested */ |
|---|
| 391 | pVbi_Fld->ulCGMSData = ulCGMSData; |
|---|
| 392 | |
|---|
| 393 | /* Indicate valid data is present */ |
|---|
| 394 | pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_CGMSA; |
|---|
| 395 | |
|---|
| 396 | BDBG_LEAVE(BVBI_Field_SetCGMSAData_isr); |
|---|
| 397 | return BERR_SUCCESS; |
|---|
| 398 | } |
|---|
| 399 | |
|---|
| 400 | /*************************************************************************** |
|---|
| 401 | * |
|---|
| 402 | */ |
|---|
| 403 | BERR_Code |
|---|
| 404 | BVBI_Field_GetCGMSBData_isr( |
|---|
| 405 | BVBI_Field_Handle vbiData, BVBI_CGMSB_Datum* pDatum) |
|---|
| 406 | { |
|---|
| 407 | int subIndex; |
|---|
| 408 | BVBI_P_Field_Handle* pVbi_Fld; |
|---|
| 409 | BERR_Code eErr = BERR_SUCCESS; |
|---|
| 410 | |
|---|
| 411 | BDBG_ENTER(BVBI_Field_GetCGMSBData_isr); |
|---|
| 412 | |
|---|
| 413 | /* check parameters */ |
|---|
| 414 | BVBI_P_GET_FIELD_CONTEXT(vbiData, pVbi_Fld); |
|---|
| 415 | if((!pVbi_Fld) || (!pDatum)) |
|---|
| 416 | { |
|---|
| 417 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 418 | } |
|---|
| 419 | |
|---|
| 420 | /* Verify that data is present on this field handle */ |
|---|
| 421 | if (!(pVbi_Fld->ulWhichPresent & BVBI_P_SELECT_CGMSB)) |
|---|
| 422 | return (BVBI_ERR_FIELD_NODATA); |
|---|
| 423 | else if (pVbi_Fld->ulErrInfo & BVBI_LINE_ERROR_CGMS_NOENCODE) |
|---|
| 424 | eErr = (BVBI_ERR_FIELD_BADDATA); |
|---|
| 425 | |
|---|
| 426 | /* Check that field handle was properly sized */ |
|---|
| 427 | if (!pVbi_Fld->pCgmsbDatum) |
|---|
| 428 | { |
|---|
| 429 | return BERR_TRACE (BVBI_ERR_FLDH_CONFLICT); |
|---|
| 430 | } |
|---|
| 431 | |
|---|
| 432 | /* Return data as requested */ |
|---|
| 433 | for (subIndex = 0 ; subIndex < 5 ; ++subIndex) |
|---|
| 434 | (*pDatum)[subIndex] = (*pVbi_Fld->pCgmsbDatum)[subIndex]; |
|---|
| 435 | BDBG_LEAVE(BVBI_Field_GetCGMSBData_isr); |
|---|
| 436 | return eErr; |
|---|
| 437 | } |
|---|
| 438 | |
|---|
| 439 | /*************************************************************************** |
|---|
| 440 | * |
|---|
| 441 | */ |
|---|
| 442 | BERR_Code BVBI_Field_SetCGMSBData_isr( |
|---|
| 443 | BVBI_Field_Handle vbiData, BVBI_CGMSB_Datum* pDatum) |
|---|
| 444 | { |
|---|
| 445 | BVBI_P_Field_Handle* pVbi_Fld; |
|---|
| 446 | int subIndex; |
|---|
| 447 | |
|---|
| 448 | BDBG_ENTER(BVBI_Field_SetCGMSBData_isr); |
|---|
| 449 | |
|---|
| 450 | /* check parameters */ |
|---|
| 451 | BVBI_P_GET_FIELD_CONTEXT(vbiData, pVbi_Fld); |
|---|
| 452 | if(!pVbi_Fld) |
|---|
| 453 | { |
|---|
| 454 | BDBG_ERR(("Invalid parameter\n")); |
|---|
| 455 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 456 | } |
|---|
| 457 | |
|---|
| 458 | /* Check that field handle was properly sized */ |
|---|
| 459 | if (!pVbi_Fld->pCgmsbDatum) |
|---|
| 460 | { |
|---|
| 461 | return BERR_TRACE (BVBI_ERR_FLDH_CONFLICT); |
|---|
| 462 | } |
|---|
| 463 | |
|---|
| 464 | /* Store data as requested */ |
|---|
| 465 | for (subIndex = 0 ; subIndex < 5 ; ++subIndex) |
|---|
| 466 | (*pVbi_Fld->pCgmsbDatum)[subIndex] = (*pDatum)[subIndex]; |
|---|
| 467 | |
|---|
| 468 | /* Indicate valid data is present */ |
|---|
| 469 | pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_CGMSB; |
|---|
| 470 | |
|---|
| 471 | BDBG_LEAVE(BVBI_Field_SetCGMSBData_isr); |
|---|
| 472 | return BERR_SUCCESS; |
|---|
| 473 | } |
|---|
| 474 | |
|---|
| 475 | |
|---|
| 476 | /*************************************************************************** |
|---|
| 477 | * Implementation of supporting CGMS functions that are not in API |
|---|
| 478 | ***************************************************************************/ |
|---|
| 479 | |
|---|
| 480 | |
|---|
| 481 | BERR_Code BVBI_P_CGMS_Init( BVBI_P_Handle *pVbi ) |
|---|
| 482 | { |
|---|
| 483 | #if (BVBI_P_NUM_VDEC >= 1) |
|---|
| 484 | uint32_t ulCoreOffset; |
|---|
| 485 | #endif |
|---|
| 486 | uint8_t hwIndex; |
|---|
| 487 | |
|---|
| 488 | #if (BVBI_P_NUM_VDEC >= 1) |
|---|
| 489 | ulCoreOffset = 0x0; |
|---|
| 490 | BVBI_P_CGMS_Dec_Init (pVbi->hReg, ulCoreOffset); |
|---|
| 491 | #endif |
|---|
| 492 | |
|---|
| 493 | BDBG_ENTER(BVBI_P_CGMS_Init); |
|---|
| 494 | |
|---|
| 495 | #if (BVBI_P_NUM_VDEC >= 2) |
|---|
| 496 | ulCoreOffset = BCHP_CGMSD_1_RevID - BCHP_CGMSD_0_RevID; |
|---|
| 497 | BVBI_P_CGMS_Dec_Init (pVbi->hReg, ulCoreOffset); |
|---|
| 498 | #endif |
|---|
| 499 | |
|---|
| 500 | /* Initialize CGMS encoders */ |
|---|
| 501 | for (hwIndex = 0 ; hwIndex < BVBI_P_NUM_CGMSAE ; ++hwIndex) |
|---|
| 502 | BVBI_P_CGMS_Enc_Init (pVbi->hReg, false, hwIndex); |
|---|
| 503 | #if (BVBI_P_NUM_CGMSAE_656 > 0) |
|---|
| 504 | for (hwIndex = 0 ; hwIndex < BVBI_P_NUM_CGMSAE_656 ; ++hwIndex) |
|---|
| 505 | BVBI_P_CGMS_Enc_Init (pVbi->hReg, true, hwIndex); |
|---|
| 506 | #endif |
|---|
| 507 | |
|---|
| 508 | BDBG_LEAVE(BVBI_P_CGMS_Init); |
|---|
| 509 | return BERR_SUCCESS; |
|---|
| 510 | } |
|---|
| 511 | |
|---|
| 512 | uint32_t BVPI_P_CGMS_format_data (uint32_t userdata) |
|---|
| 513 | { |
|---|
| 514 | /* Do CRC calculation if hardware is broken */ |
|---|
| 515 | /* Otherwise, just transform from decoder format to encoder format. */ |
|---|
| 516 | #ifdef P_CGMS_SOFTWARE_CRC |
|---|
| 517 | userdata &= 0x00003fff; |
|---|
| 518 | userdata = P_CalculateCRC (userdata); |
|---|
| 519 | userdata <<= 2; |
|---|
| 520 | userdata &= 0x003ffffc; |
|---|
| 521 | userdata |= 0x00000001; |
|---|
| 522 | #else |
|---|
| 523 | userdata <<= 2; |
|---|
| 524 | userdata &= 0x0000fffc; |
|---|
| 525 | #endif |
|---|
| 526 | |
|---|
| 527 | return userdata; |
|---|
| 528 | } |
|---|
| 529 | |
|---|
| 530 | |
|---|
| 531 | /*************************************************************************** |
|---|
| 532 | * Static (private) functions |
|---|
| 533 | ***************************************************************************/ |
|---|
| 534 | |
|---|
| 535 | |
|---|
| 536 | /* End of file */ |
|---|