| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2011, 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_amol.c $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/4 $ |
|---|
| 12 | * $brcm_Date: 2/10/11 5:35p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/portinginterface/vbi/7400/bvbi_amol.c $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/4 2/10/11 5:35p darnstein |
|---|
| 21 | * SW7422-255: The two set/get functions for AMOL data now have a length |
|---|
| 22 | * argument. |
|---|
| 23 | * |
|---|
| 24 | * Hydra_Software_Devel/3 11/24/09 4:35p darnstein |
|---|
| 25 | * SW35230-16: first cut at 35230 support. |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/2 12/3/08 7:56p darnstein |
|---|
| 28 | * PR45819: New, more modular form of most BVBI source files. |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/16 6/6/08 5:36p darnstein |
|---|
| 31 | * PR38956: compile in support for SCTE and AMOL in 93548. |
|---|
| 32 | * |
|---|
| 33 | * Hydra_Software_Devel/15 3/19/08 7:38p darnstein |
|---|
| 34 | * PR40770: change Pedestal gain value for AMOL to 0x4d. Per Lin Ma. |
|---|
| 35 | * |
|---|
| 36 | * Hydra_Software_Devel/14 2/15/08 7:05p darnstein |
|---|
| 37 | * PR20429: The AMOL waveforms were going out on the wrong video lines. |
|---|
| 38 | * |
|---|
| 39 | * Hydra_Software_Devel/13 12/4/07 1:19p darnstein |
|---|
| 40 | * PR36897: VBI software is ready for testing with 97335 chipset. |
|---|
| 41 | * |
|---|
| 42 | * Hydra_Software_Devel/12 10/31/07 3:51p darnstein |
|---|
| 43 | * PR34528: BVBI is ready for testing on 7325. |
|---|
| 44 | * |
|---|
| 45 | * Hydra_Software_Devel/11 9/17/07 2:47p darnstein |
|---|
| 46 | * PR29723: The fact that only primary VEC has an AMOLE core was not |
|---|
| 47 | * handled correctly. |
|---|
| 48 | * |
|---|
| 49 | * Hydra_Software_Devel/10 4/20/07 3:36p darnstein |
|---|
| 50 | * PR29723: Compilation for 7405 chipset. |
|---|
| 51 | * |
|---|
| 52 | * Hydra_Software_Devel/9 12/15/06 2:38p darnstein |
|---|
| 53 | * PR25990: Improve method for switching among VEC paths. |
|---|
| 54 | * |
|---|
| 55 | * Hydra_Software_Devel/8 11/1/06 5:17p darnstein |
|---|
| 56 | * PR24979: Kin Fan Ho scoped the waveform and picked the correct |
|---|
| 57 | * horizontal offset. |
|---|
| 58 | * |
|---|
| 59 | * Hydra_Software_Devel/7 7/20/06 6:21p darnstein |
|---|
| 60 | * PR21688: Fix typo in previous check-in. |
|---|
| 61 | * |
|---|
| 62 | * Hydra_Software_Devel/6 7/20/06 2:33p darnstein |
|---|
| 63 | * PR21688: Use the new hardware soft reset scheme for later model chips. |
|---|
| 64 | * |
|---|
| 65 | * Hydra_Software_Devel/5 5/26/06 4:58p darnstein |
|---|
| 66 | * PR20612: adapt to new register names in the AMOL core. |
|---|
| 67 | * |
|---|
| 68 | * Hydra_Software_Devel/4 4/25/06 4:42p darnstein |
|---|
| 69 | * PR20949: Adapt to fixed up names in RDB for NULL_ENABLE register |
|---|
| 70 | * fields. |
|---|
| 71 | * |
|---|
| 72 | * Hydra_Software_Devel/3 4/18/06 1:49p darnstein |
|---|
| 73 | * PR18010: Silence some compiler warnings encountered by David Lwin. |
|---|
| 74 | * |
|---|
| 75 | * Hydra_Software_Devel/2 4/12/06 6:17p darnstein |
|---|
| 76 | * PR18010: Don't try to program encoders for don't exist for 656 output. |
|---|
| 77 | * |
|---|
| 78 | * Hydra_Software_Devel/1 4/11/06 7:25p darnstein |
|---|
| 79 | * PR20429: First cut at AMOL encoder software. |
|---|
| 80 | * |
|---|
| 81 | ***************************************************************************/ |
|---|
| 82 | |
|---|
| 83 | #include "bstd.h" /* standard types */ |
|---|
| 84 | #include "bdbg.h" /* Dbglib */ |
|---|
| 85 | #include "bkni.h" /* For critical sections */ |
|---|
| 86 | #include "bvbi.h" /* VBI processing, this module. */ |
|---|
| 87 | #include "bvbi_priv.h" /* VBI internal data structures */ |
|---|
| 88 | |
|---|
| 89 | BDBG_MODULE(BVBI); |
|---|
| 90 | |
|---|
| 91 | /*************************************************************************** |
|---|
| 92 | * Private data |
|---|
| 93 | ***************************************************************************/ |
|---|
| 94 | |
|---|
| 95 | /*************************************************************************** |
|---|
| 96 | * Forward declarations of static (private) functions |
|---|
| 97 | ***************************************************************************/ |
|---|
| 98 | |
|---|
| 99 | static int P_size_by_type (BVBI_AMOL_Type type); |
|---|
| 100 | |
|---|
| 101 | |
|---|
| 102 | /*************************************************************************** |
|---|
| 103 | * Implementation of "BVBI_" API functions |
|---|
| 104 | ***************************************************************************/ |
|---|
| 105 | |
|---|
| 106 | |
|---|
| 107 | /*************************************************************************** |
|---|
| 108 | * |
|---|
| 109 | */ |
|---|
| 110 | BERR_Code BVBI_Field_GetAMOLData_isr ( |
|---|
| 111 | BVBI_Field_Handle fieldHandle, |
|---|
| 112 | BVBI_AMOL_Type *pAmolType, |
|---|
| 113 | uint8_t *pAMOLData, |
|---|
| 114 | unsigned int* pLength |
|---|
| 115 | ) |
|---|
| 116 | { |
|---|
| 117 | int count; |
|---|
| 118 | int size; |
|---|
| 119 | uint8_t* fdata; |
|---|
| 120 | BVBI_P_Field_Handle* pVbi_Fld; |
|---|
| 121 | BERR_Code eErr = BERR_SUCCESS; |
|---|
| 122 | |
|---|
| 123 | BDBG_ENTER(BVBI_Field_GetAMOLData_isr); |
|---|
| 124 | |
|---|
| 125 | /* check parameters */ |
|---|
| 126 | BVBI_P_GET_FIELD_CONTEXT(fieldHandle, pVbi_Fld); |
|---|
| 127 | if((!pVbi_Fld) || (!pAMOLData) || (!pAmolType) || (!pLength)) |
|---|
| 128 | { |
|---|
| 129 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | /* Verify that data is present on this field handle */ |
|---|
| 133 | if (!(pVbi_Fld->ulWhichPresent & BVBI_P_SELECT_AMOL)) |
|---|
| 134 | return (BVBI_ERR_FIELD_NODATA); |
|---|
| 135 | else if (pVbi_Fld->ulErrInfo & BVBI_LINE_ERROR_AMOL_NOENCODE) |
|---|
| 136 | eErr = (BVBI_ERR_FIELD_BADDATA); |
|---|
| 137 | |
|---|
| 138 | /* Check that field handle was properly sized */ |
|---|
| 139 | fdata = pVbi_Fld->pAmolData; |
|---|
| 140 | if (!fdata) |
|---|
| 141 | { |
|---|
| 142 | return BERR_TRACE (BVBI_ERR_FLDH_CONFLICT); |
|---|
| 143 | } |
|---|
| 144 | |
|---|
| 145 | /* Return data as requested */ |
|---|
| 146 | BDBG_ASSERT (pVbi_Fld->amolType != BVBI_AMOL_Type_None); |
|---|
| 147 | size = P_size_by_type (pVbi_Fld->amolType); |
|---|
| 148 | BDBG_ASSERT (size >= 0); |
|---|
| 149 | *pAmolType = pVbi_Fld->amolType; |
|---|
| 150 | for (count = 0 ; count < size ; ++count) |
|---|
| 151 | *pAMOLData++ = *fdata++; |
|---|
| 152 | *pLength = P_size_by_type (*pAmolType); |
|---|
| 153 | |
|---|
| 154 | BDBG_LEAVE(BVBI_Field_GetAMOLData_isr); |
|---|
| 155 | return eErr; |
|---|
| 156 | } |
|---|
| 157 | |
|---|
| 158 | /*************************************************************************** |
|---|
| 159 | * |
|---|
| 160 | */ |
|---|
| 161 | BERR_Code BVBI_Field_SetAMOLData_isr( |
|---|
| 162 | BVBI_Field_Handle fieldHandle, |
|---|
| 163 | BVBI_AMOL_Type amolType, |
|---|
| 164 | uint8_t *pAMOLData, |
|---|
| 165 | unsigned int length |
|---|
| 166 | ) |
|---|
| 167 | { |
|---|
| 168 | int count; |
|---|
| 169 | int size; |
|---|
| 170 | BVBI_P_Field_Handle* pVbi_Fld; |
|---|
| 171 | |
|---|
| 172 | BDBG_ENTER(BVBI_Field_SetAMOLData_isr); |
|---|
| 173 | |
|---|
| 174 | /* check parameters */ |
|---|
| 175 | BVBI_P_GET_FIELD_CONTEXT(fieldHandle, pVbi_Fld); |
|---|
| 176 | if((!pVbi_Fld) || (!pAMOLData)) |
|---|
| 177 | { |
|---|
| 178 | BDBG_ERR(("Invalid parameter\n")); |
|---|
| 179 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 180 | } |
|---|
| 181 | /* TODO: Check amolType more carefully? */ |
|---|
| 182 | if (amolType == BVBI_AMOL_Type_None) |
|---|
| 183 | { |
|---|
| 184 | BDBG_ERR(("Invalid parameter\n")); |
|---|
| 185 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 186 | } |
|---|
| 187 | size = P_size_by_type (amolType); |
|---|
| 188 | if (size < 0) |
|---|
| 189 | { |
|---|
| 190 | BDBG_ERR(("Invalid parameter\n")); |
|---|
| 191 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 192 | } |
|---|
| 193 | if ((unsigned int)size > length) |
|---|
| 194 | { |
|---|
| 195 | BDBG_ERR(("Invalid parameter\n")); |
|---|
| 196 | return BERR_TRACE(BERR_INVALID_PARAMETER); |
|---|
| 197 | } |
|---|
| 198 | |
|---|
| 199 | /* Check that field handle was properly sized */ |
|---|
| 200 | if (!pVbi_Fld->pAmolData) |
|---|
| 201 | { |
|---|
| 202 | return BERR_TRACE (BVBI_ERR_FLDH_CONFLICT); |
|---|
| 203 | } |
|---|
| 204 | if (pVbi_Fld->amolSize < size) |
|---|
| 205 | { |
|---|
| 206 | return BERR_TRACE (BVBI_ERR_FLDH_CONFLICT); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | /* Store data as requested */ |
|---|
| 210 | pVbi_Fld->amolType = amolType; |
|---|
| 211 | for (count = 0 ; count < size ; ++count) |
|---|
| 212 | pVbi_Fld->pAmolData[count] = *pAMOLData++; |
|---|
| 213 | |
|---|
| 214 | /* Indicate valid data is present */ |
|---|
| 215 | pVbi_Fld->ulWhichPresent |= BVBI_P_SELECT_AMOL; |
|---|
| 216 | |
|---|
| 217 | BDBG_LEAVE(BVBI_Field_SetAMOLData_isr); |
|---|
| 218 | return BERR_SUCCESS; |
|---|
| 219 | } |
|---|
| 220 | |
|---|
| 221 | |
|---|
| 222 | /*************************************************************************** |
|---|
| 223 | * Implementation of supporting AMOL functions that are not in API |
|---|
| 224 | ***************************************************************************/ |
|---|
| 225 | |
|---|
| 226 | BERR_Code BVBI_P_AMOL_Init( BVBI_P_Handle *pVbi ) |
|---|
| 227 | { |
|---|
| 228 | #if (BVBI_P_NUM_AMOLE > 0) || (BVBI_P_NUM_AMOLE_656 > 0) |
|---|
| 229 | uint8_t hwIndex; |
|---|
| 230 | #endif |
|---|
| 231 | |
|---|
| 232 | BDBG_ENTER(BVBI_P_AMOL_Init); |
|---|
| 233 | |
|---|
| 234 | #if (BVBI_P_NUM_AMOLE == 0) && (BVBI_P_NUM_AMOLE_656 == 0) |
|---|
| 235 | BSTD_UNUSED (pVbi); |
|---|
| 236 | #endif |
|---|
| 237 | |
|---|
| 238 | #if (BVBI_P_NUM_AMOLE > 0) |
|---|
| 239 | for (hwIndex = 0 ; hwIndex < BVBI_P_NUM_AMOLE ; ++hwIndex) |
|---|
| 240 | BVBI_P_AMOL_Enc_Init (pVbi->hReg, false, hwIndex); |
|---|
| 241 | #endif |
|---|
| 242 | #if (BVBI_P_NUM_AMOLE_656 > 0) |
|---|
| 243 | for (hwIndex = 0 ; hwIndex < BVBI_P_NUM_AMOLE_656 ; ++hwIndex) |
|---|
| 244 | BVBI_P_AMOL_Enc_Init (pVbi->hReg, true, hwIndex); |
|---|
| 245 | #endif |
|---|
| 246 | |
|---|
| 247 | BDBG_LEAVE(BVBI_P_AMOL_Init); |
|---|
| 248 | return BERR_SUCCESS; |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | |
|---|
| 252 | /*************************************************************************** |
|---|
| 253 | * Static (private) functions |
|---|
| 254 | ***************************************************************************/ |
|---|
| 255 | |
|---|
| 256 | /*************************************************************************** |
|---|
| 257 | * |
|---|
| 258 | */ |
|---|
| 259 | static int P_size_by_type (BVBI_AMOL_Type type) |
|---|
| 260 | { |
|---|
| 261 | int size; |
|---|
| 262 | |
|---|
| 263 | switch (type) |
|---|
| 264 | { |
|---|
| 265 | case BVBI_AMOL_Type_None: |
|---|
| 266 | size = 0; |
|---|
| 267 | break; |
|---|
| 268 | case BVBI_AMOL_Type_I: |
|---|
| 269 | size = 6; |
|---|
| 270 | break; |
|---|
| 271 | case BVBI_AMOL_Type_II_Lowrate: |
|---|
| 272 | size = 12; |
|---|
| 273 | break; |
|---|
| 274 | case BVBI_AMOL_Type_II_Highrate: |
|---|
| 275 | size = 24; |
|---|
| 276 | break; |
|---|
| 277 | default: |
|---|
| 278 | size = -1; |
|---|
| 279 | break; |
|---|
| 280 | } |
|---|
| 281 | |
|---|
| 282 | return size; |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | /* End of file */ |
|---|