| 1 | /* |
|---|
| 2 | LG3305.c |
|---|
| 3 | |
|---|
| 4 | LG Demod Driver Ver. 0.9.4 |
|---|
| 5 | LG Demod Driver Ver. 0.9.5 |
|---|
| 6 | |
|---|
| 7 | LG ¿¡¼ Á¦°øÇÏ´Â Demod Driver + API (User coding) |
|---|
| 8 | |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | #include "DHL_OSAL.h" |
|---|
| 12 | #include "DHL_DEV_Priv.h" |
|---|
| 13 | |
|---|
| 14 | #include <math.h> |
|---|
| 15 | |
|---|
| 16 | #include "LG3305.h" |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | //#define DSI_printf(...) |
|---|
| 20 | |
|---|
| 21 | |
|---|
| 22 | |
|---|
| 23 | |
|---|
| 24 | #if COMMENT |
|---|
| 25 | ____Config____(){} |
|---|
| 26 | #endif |
|---|
| 27 | |
|---|
| 28 | /* º¸µå¿¡¼ »ç¿ëµÇ´Â LG3305 ÀÇ µð¹ÙÀ̽º ¼ö¸¦ ÁöĪÇÏ¸ç µ¿½Ã¿¡ FE ID °¹¼ö¿Í ÀÏÄ¡ ÇÊ¿ä!! |
|---|
| 29 | ºñ·Ï LG3305¸¦ ÇѰ³ »ç¿ëÇÏ´õ¶óµµ FE ID°¡ 2·Î ÇÒ´ç ¹ÞÀ» °æ¿ì NUM_LG3305_MAX ´Â 3ÀÌ µÇ¾ßÇÔ!! |
|---|
| 30 | */ |
|---|
| 31 | #define NUM_LG3305_MAX 1 |
|---|
| 32 | |
|---|
| 33 | // Revision.. Start Ver 0.9.4 |
|---|
| 34 | #define Ver_095 1 |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | #if COMMENT |
|---|
| 38 | ____Global____(){} |
|---|
| 39 | #endif |
|---|
| 40 | |
|---|
| 41 | // Init ÇÔ¼ö¿¡¼ °ªÀ» ³Ñ°Ü ¹Þ´Â´Ù. |
|---|
| 42 | static unsigned char g_i2cId[NUM_LG3305_MAX]; |
|---|
| 43 | static unsigned char g_i2cAddr[NUM_LG3305_MAX]; |
|---|
| 44 | static unsigned char g_feId; |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | |
|---|
| 48 | #if COMMENT |
|---|
| 49 | _____________LG_Code_____________(){} |
|---|
| 50 | #endif |
|---|
| 51 | |
|---|
| 52 | |
|---|
| 53 | #if COMMENT |
|---|
| 54 | _____Defines_____(){} |
|---|
| 55 | #endif |
|---|
| 56 | |
|---|
| 57 | #if Ver_095 |
|---|
| 58 | #define LGDT_VERSION_MAJOR 0 |
|---|
| 59 | #define LGDT_VERSION_MINOR 9 |
|---|
| 60 | #define LGDT_VERSION_CUSTOM 5 |
|---|
| 61 | #else |
|---|
| 62 | #define LGDT_VERSION_MAJOR 0 |
|---|
| 63 | #define LGDT_VERSION_MINOR 9 |
|---|
| 64 | #define LGDT_VERSION_CUSTOM 4 |
|---|
| 65 | #endif |
|---|
| 66 | |
|---|
| 67 | #if COMMENT |
|---|
| 68 | _____Functions_____(){} |
|---|
| 69 | #endif |
|---|
| 70 | |
|---|
| 71 | LgdtReturn_t LgdtInitFAT(LgdtOperMode_t modeOper, bool IsExtAGC) |
|---|
| 72 | { |
|---|
| 73 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 74 | |
|---|
| 75 | if (IsExtAGC) |
|---|
| 76 | { |
|---|
| 77 | switch(modeOper) /*---- When External AGC is used : Manaul AGC -----*/ |
|---|
| 78 | { |
|---|
| 79 | case LGDT_QAM64: |
|---|
| 80 | case LGDT_QAM256: |
|---|
| 81 | nRet = LgdtInitQAM_ExternAGC(modeOper); // Check AGC mode |
|---|
| 82 | if (nRet != LGDT_ERR_NO) |
|---|
| 83 | { |
|---|
| 84 | nRet = (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 85 | } |
|---|
| 86 | break; |
|---|
| 87 | case LGDT_VSB: |
|---|
| 88 | nRet = LgdtInitVSB_ExternAGC(); |
|---|
| 89 | if (nRet != LGDT_ERR_NO) |
|---|
| 90 | { |
|---|
| 91 | nRet = (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 92 | } |
|---|
| 93 | break; |
|---|
| 94 | default: |
|---|
| 95 | nRet = (LgdtReturn_t)(LGDT_ERR_INIT|LGDT_ERR_PARAM); |
|---|
| 96 | break; |
|---|
| 97 | } |
|---|
| 98 | } |
|---|
| 99 | else |
|---|
| 100 | { |
|---|
| 101 | switch(modeOper) /*---- When Internal AGC is used : Automatic AGC -----*/ |
|---|
| 102 | { |
|---|
| 103 | case LGDT_QAM64: |
|---|
| 104 | case LGDT_QAM256: |
|---|
| 105 | nRet = LgdtInitQAM(modeOper); |
|---|
| 106 | if (nRet != LGDT_ERR_NO) |
|---|
| 107 | { |
|---|
| 108 | nRet = (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 109 | } |
|---|
| 110 | break; |
|---|
| 111 | case LGDT_VSB: |
|---|
| 112 | nRet = LgdtInitVSB(); |
|---|
| 113 | if (nRet != LGDT_ERR_NO) |
|---|
| 114 | { |
|---|
| 115 | nRet = (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 116 | } |
|---|
| 117 | break; |
|---|
| 118 | default: |
|---|
| 119 | nRet = (LgdtReturn_t)(LGDT_ERR_INIT|LGDT_ERR_PARAM); |
|---|
| 120 | break; |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | /*----- nSFTRST -----*/ |
|---|
| 125 | nRet = LgdtResetFAT(); |
|---|
| 126 | if (nRet != LGDT_ERR_NO) |
|---|
| 127 | return nRet; |
|---|
| 128 | return nRet; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | |
|---|
| 132 | |
|---|
| 133 | LgdtReturn_t LgdtInitQAM_ExternAGC(LgdtOperMode_t mode) |
|---|
| 134 | { |
|---|
| 135 | DATA08 pData; |
|---|
| 136 | LgdtReturn_t nRet; |
|---|
| 137 | |
|---|
| 138 | /*----- 1) OPERMODE[1:0] -----*/ |
|---|
| 139 | switch(mode) |
|---|
| 140 | { |
|---|
| 141 | case LGDT_QAM64: |
|---|
| 142 | nRet = LgdtCheckRegi(0x0000, &pData); |
|---|
| 143 | if(nRet != LGDT_ERR_NO) |
|---|
| 144 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 145 | |
|---|
| 146 | pData &= 0xFC; |
|---|
| 147 | |
|---|
| 148 | nRet = LgdtAlterRegi(0x0000, 0x00); |
|---|
| 149 | if (nRet != LGDT_ERR_NO) |
|---|
| 150 | return nRet; |
|---|
| 151 | |
|---|
| 152 | // 2) DAGCREF[15:0] <-- 0x2A00 (@0x0012,0x0013) |
|---|
| 153 | nRet = LgdtAlterRegi(0x0012, 0x2A); |
|---|
| 154 | if (nRet != LGDT_ERR_NO) |
|---|
| 155 | return nRet; |
|---|
| 156 | |
|---|
| 157 | nRet = LgdtAlterRegi(0x0013, 0x00); |
|---|
| 158 | if (nRet != LGDT_ERR_NO) |
|---|
| 159 | return nRet; |
|---|
| 160 | |
|---|
| 161 | break; |
|---|
| 162 | case LGDT_QAM256: |
|---|
| 163 | nRet = LgdtCheckRegi(0x0000, &pData); |
|---|
| 164 | if(nRet != LGDT_ERR_NO) |
|---|
| 165 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 166 | |
|---|
| 167 | pData &= 0xFC; |
|---|
| 168 | pData |= 0x01; |
|---|
| 169 | |
|---|
| 170 | nRet = LgdtAlterRegi(0x0000, 0x01); |
|---|
| 171 | if (nRet != LGDT_ERR_NO) |
|---|
| 172 | return nRet; |
|---|
| 173 | |
|---|
| 174 | // 2) DAGCREF[15:0] <-- 0x2A80 (@0x0012,0x0013) |
|---|
| 175 | nRet = LgdtAlterRegi(0x0012, 0x2A); |
|---|
| 176 | if (nRet != LGDT_ERR_NO) |
|---|
| 177 | return nRet; |
|---|
| 178 | |
|---|
| 179 | nRet = LgdtAlterRegi(0x0013, 0x80); |
|---|
| 180 | if (nRet != LGDT_ERR_NO) |
|---|
| 181 | return nRet; |
|---|
| 182 | |
|---|
| 183 | break; |
|---|
| 184 | default: |
|---|
| 185 | |
|---|
| 186 | break; |
|---|
| 187 | } |
|---|
| 188 | |
|---|
| 189 | // 3) LOCKDTEN <- '1' (@0x0314[1]) |
|---|
| 190 | nRet = LgdtAlterRegi(0x0314, 0xE3); |
|---|
| 191 | if(nRet != LGDT_ERR_NO) |
|---|
| 192 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 193 | |
|---|
| 194 | // 4) IFBW[15:0] <-- 0x8888 (@0x0308,0x0309) |
|---|
| 195 | nRet = LgdtAlterRegi(0x0308, 0x88); |
|---|
| 196 | if(nRet != LGDT_ERR_NO) |
|---|
| 197 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 198 | |
|---|
| 199 | nRet = LgdtAlterRegi(0x0309, 0x88); |
|---|
| 200 | if(nRet != LGDT_ERR_NO) |
|---|
| 201 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 202 | |
|---|
| 203 | // 5) ACQEN <- '1'b (@0x030C[2]) |
|---|
| 204 | nRet = LgdtAlterRegi(0x030C, 0x34); |
|---|
| 205 | if(nRet != LGDT_ERR_NO) |
|---|
| 206 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 207 | |
|---|
| 208 | // 6) QAMFBEXT <- '1'b (@0x043F[2]) |
|---|
| 209 | nRet = LgdtAlterRegi(0x043F, 0xAE); |
|---|
| 210 | if(nRet != LGDT_ERR_NO) |
|---|
| 211 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 212 | |
|---|
| 213 | ///////////////////////////////////////// |
|---|
| 214 | // for using RF AGC |
|---|
| 215 | // 7) REFD[11:0] <- 0x046B (@0x0302, 0x0303) |
|---|
| 216 | nRet = LgdtAlterRegi(0x0302, 0x04); |
|---|
| 217 | if(nRet != LGDT_ERR_NO) |
|---|
| 218 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 219 | |
|---|
| 220 | nRet = LgdtAlterRegi(0x0303, 0x6B); |
|---|
| 221 | if(nRet != LGDT_ERR_NO) |
|---|
| 222 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 223 | |
|---|
| 224 | // 8) RFBW[15:0] <-- 0x8889 (@0x0306,0x0307) |
|---|
| 225 | nRet = LgdtAlterRegi(0x0306, 0x88); |
|---|
| 226 | if(nRet != LGDT_ERR_NO) |
|---|
| 227 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 228 | |
|---|
| 229 | nRet = LgdtAlterRegi(0x0307, 0x89); |
|---|
| 230 | if(nRet != LGDT_ERR_NO) |
|---|
| 231 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 232 | |
|---|
| 233 | #if Ver_095 |
|---|
| 234 | // 9) RFFIX <- '0'b (@0x030D[2] |
|---|
| 235 | nRet = LgdtCheckRegi(0x030D, &pData); |
|---|
| 236 | if(nRet != LGDT_ERR_NO) |
|---|
| 237 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 238 | |
|---|
| 239 | pData &= 0xFB; |
|---|
| 240 | |
|---|
| 241 | nRet = LgdtAlterRegi(0x030D, pData); |
|---|
| 242 | if(nRet != LGDT_ERR_NO) |
|---|
| 243 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 244 | #endif |
|---|
| 245 | |
|---|
| 246 | |
|---|
| 247 | // 9) reset |
|---|
| 248 | nRet = LgdtCheckRegi(0x0002, &pData); |
|---|
| 249 | if(nRet != LGDT_ERR_NO) |
|---|
| 250 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 251 | |
|---|
| 252 | pData &= 0xFE; |
|---|
| 253 | |
|---|
| 254 | nRet = LgdtAlterRegi(0x0002, pData); |
|---|
| 255 | if(nRet != LGDT_ERR_NO) |
|---|
| 256 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 257 | |
|---|
| 258 | LgdtDelay((DATA16)20); // reset delay |
|---|
| 259 | |
|---|
| 260 | nRet = LgdtCheckRegi(0x0002, &pData); |
|---|
| 261 | if(nRet != LGDT_ERR_NO) |
|---|
| 262 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 263 | |
|---|
| 264 | pData &= 0xFE; |
|---|
| 265 | pData |= 0x01; |
|---|
| 266 | |
|---|
| 267 | nRet = LgdtAlterRegi(0x0002, pData); |
|---|
| 268 | if(nRet != LGDT_ERR_NO) |
|---|
| 269 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 270 | |
|---|
| 271 | return LGDT_ERR_NO; |
|---|
| 272 | } |
|---|
| 273 | |
|---|
| 274 | |
|---|
| 275 | LgdtReturn_t LgdtInitVSB_ExternAGC(void) |
|---|
| 276 | { |
|---|
| 277 | DATA08 pData; |
|---|
| 278 | LgdtReturn_t nRet; |
|---|
| 279 | |
|---|
| 280 | |
|---|
| 281 | // 1) OPERMODE[1:0] <-- '11'b |
|---|
| 282 | nRet = LgdtCheckRegi(0x0000, &pData); |
|---|
| 283 | if(nRet != LGDT_ERR_NO) |
|---|
| 284 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 285 | |
|---|
| 286 | pData &= 0xFC; |
|---|
| 287 | pData |= 0x03; |
|---|
| 288 | |
|---|
| 289 | nRet = LgdtAlterRegi(0x0000, pData); |
|---|
| 290 | if(nRet != LGDT_ERR_NO) |
|---|
| 291 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 292 | |
|---|
| 293 | // 2) DAGCREF[15:0] <-- 0x32C4 (@0x0012,0x0013) |
|---|
| 294 | nRet = LgdtAlterRegi(0x0012, 0x32); |
|---|
| 295 | if (nRet != LGDT_ERR_NO) |
|---|
| 296 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 297 | |
|---|
| 298 | nRet = LgdtAlterRegi(0x0013, 0xC4); |
|---|
| 299 | if (nRet != LGDT_ERR_NO) |
|---|
| 300 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 301 | |
|---|
| 302 | // 3) LOCKDTEN <- '0' (@0x0314[1]) |
|---|
| 303 | nRet = LgdtAlterRegi(0x0314, 0xE1); |
|---|
| 304 | if(nRet != LGDT_ERR_NO) |
|---|
| 305 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 306 | |
|---|
| 307 | // 4) IFBW[15:0] <-- 0x8000 (@0x0308,0x0309) |
|---|
| 308 | nRet = LgdtAlterRegi(0x0308, 0x80); |
|---|
| 309 | if(nRet != LGDT_ERR_NO) |
|---|
| 310 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 311 | |
|---|
| 312 | nRet = LgdtAlterRegi(0x0309, 0x00); |
|---|
| 313 | if(nRet != LGDT_ERR_NO) |
|---|
| 314 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 315 | |
|---|
| 316 | // 5) ACQEN <- '0'b (@0x030C[2]) |
|---|
| 317 | nRet = LgdtAlterRegi(0x030C, 0x30); |
|---|
| 318 | if(nRet != LGDT_ERR_NO) |
|---|
| 319 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 320 | |
|---|
| 321 | // 6) QAMFBEXT <- '0'b (@0x043F[2]) |
|---|
| 322 | nRet = LgdtAlterRegi(0x043F, 0xAA); |
|---|
| 323 | if(nRet != LGDT_ERR_NO) |
|---|
| 324 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 325 | |
|---|
| 326 | ///////////////////////////////////////// |
|---|
| 327 | // for using RF AGC |
|---|
| 328 | // 7) REFD[11:0] <- 0x04C0 (@0x0302, 0x0303) |
|---|
| 329 | nRet = LgdtAlterRegi(0x0302, 0x04); |
|---|
| 330 | if(nRet != LGDT_ERR_NO) |
|---|
| 331 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 332 | |
|---|
| 333 | nRet = LgdtAlterRegi(0x0303, 0xC0); |
|---|
| 334 | if(nRet != LGDT_ERR_NO) |
|---|
| 335 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 336 | |
|---|
| 337 | // 8) RFBW[15:0] <-- 0x8000 (@0x0306,0x0307) |
|---|
| 338 | nRet = LgdtAlterRegi(0x0306, 0x80); |
|---|
| 339 | if(nRet != LGDT_ERR_NO) |
|---|
| 340 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 341 | |
|---|
| 342 | nRet = LgdtAlterRegi(0x0307, 0x00); |
|---|
| 343 | if(nRet != LGDT_ERR_NO) |
|---|
| 344 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 345 | |
|---|
| 346 | #ifdef VSB_PLL_SWEEP |
|---|
| 347 | nRet = LgdtAlterRegi(0x012A, 0xC9); |
|---|
| 348 | if(nRet != LGDT_ERR_NO) |
|---|
| 349 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 350 | #endif |
|---|
| 351 | // 9) GCONCIR <- '0'b (@0x0116[7] |
|---|
| 352 | nRet = LgdtCheckRegi(0x0116, &pData); |
|---|
| 353 | if(nRet != LGDT_ERR_NO) |
|---|
| 354 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 355 | |
|---|
| 356 | pData &= 0x7F; |
|---|
| 357 | |
|---|
| 358 | nRet = LgdtAlterRegi(0x0116, pData); |
|---|
| 359 | if(nRet != LGDT_ERR_NO) |
|---|
| 360 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 361 | |
|---|
| 362 | #if Ver_095 |
|---|
| 363 | // 10) RFFIX <- '0'b (@0x030D[2] |
|---|
| 364 | nRet = LgdtCheckRegi(0x030D, &pData); |
|---|
| 365 | if(nRet != LGDT_ERR_NO) |
|---|
| 366 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 367 | |
|---|
| 368 | pData &= 0xFB; |
|---|
| 369 | |
|---|
| 370 | nRet = LgdtAlterRegi(0x030D, pData); |
|---|
| 371 | if(nRet != LGDT_ERR_NO) |
|---|
| 372 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 373 | #endif |
|---|
| 374 | |
|---|
| 375 | // 10) Reset |
|---|
| 376 | nRet = LgdtCheckRegi(0x0002, &pData); |
|---|
| 377 | if(nRet != LGDT_ERR_NO) |
|---|
| 378 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 379 | |
|---|
| 380 | pData &= 0xFE; |
|---|
| 381 | |
|---|
| 382 | nRet = LgdtAlterRegi(0x0002, pData); |
|---|
| 383 | if(nRet != LGDT_ERR_NO) |
|---|
| 384 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 385 | |
|---|
| 386 | LgdtDelay((DATA16)20); // reset delay |
|---|
| 387 | |
|---|
| 388 | nRet = LgdtCheckRegi(0x0002, &pData); |
|---|
| 389 | if(nRet != LGDT_ERR_NO) |
|---|
| 390 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 391 | |
|---|
| 392 | pData &= 0xFE; |
|---|
| 393 | pData |= 0x01; |
|---|
| 394 | |
|---|
| 395 | nRet = LgdtAlterRegi(0x0002, pData); |
|---|
| 396 | if(nRet != LGDT_ERR_NO) |
|---|
| 397 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 398 | |
|---|
| 399 | return LGDT_ERR_NO; |
|---|
| 400 | |
|---|
| 401 | } |
|---|
| 402 | |
|---|
| 403 | |
|---|
| 404 | LgdtReturn_t LgdtInitQAM(LgdtOperMode_t mode) |
|---|
| 405 | { |
|---|
| 406 | DATA08 pData; |
|---|
| 407 | LgdtReturn_t nRet; |
|---|
| 408 | |
|---|
| 409 | /*----- 1) OPERMODE[1:0] -----*/ |
|---|
| 410 | switch(mode) |
|---|
| 411 | { |
|---|
| 412 | case LGDT_QAM64: |
|---|
| 413 | nRet = LgdtCheckRegi(0x0000, &pData); |
|---|
| 414 | if(nRet != LGDT_ERR_NO) |
|---|
| 415 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 416 | |
|---|
| 417 | pData &= 0xFC; |
|---|
| 418 | |
|---|
| 419 | nRet = LgdtAlterRegi(0x0000, 0x00); |
|---|
| 420 | if (nRet != LGDT_ERR_NO) |
|---|
| 421 | return nRet; |
|---|
| 422 | |
|---|
| 423 | // 2) DAGCREF[15:0] <-- 0x2A00 (@0x0012,0x0013) |
|---|
| 424 | nRet = LgdtAlterRegi(0x0012, 0x2A); |
|---|
| 425 | if (nRet != LGDT_ERR_NO) |
|---|
| 426 | return nRet; |
|---|
| 427 | |
|---|
| 428 | nRet = LgdtAlterRegi(0x0013, 0x00); |
|---|
| 429 | if (nRet != LGDT_ERR_NO) |
|---|
| 430 | return nRet; |
|---|
| 431 | |
|---|
| 432 | break; |
|---|
| 433 | case LGDT_QAM256: |
|---|
| 434 | nRet = LgdtCheckRegi(0x0000, &pData); |
|---|
| 435 | if(nRet != LGDT_ERR_NO) |
|---|
| 436 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 437 | |
|---|
| 438 | pData &= 0xFC; |
|---|
| 439 | pData |= 0x01; |
|---|
| 440 | |
|---|
| 441 | nRet = LgdtAlterRegi(0x0000, 0x01); |
|---|
| 442 | if (nRet != LGDT_ERR_NO) |
|---|
| 443 | return nRet; |
|---|
| 444 | |
|---|
| 445 | // 2) DAGCREF[15:0] <-- 0x2A80 (@0x0012,0x0013) |
|---|
| 446 | nRet = LgdtAlterRegi(0x0012, 0x2A); |
|---|
| 447 | if (nRet != LGDT_ERR_NO) |
|---|
| 448 | return nRet; |
|---|
| 449 | |
|---|
| 450 | nRet = LgdtAlterRegi(0x0013, 0x80); |
|---|
| 451 | if (nRet != LGDT_ERR_NO) |
|---|
| 452 | return nRet; |
|---|
| 453 | |
|---|
| 454 | break; |
|---|
| 455 | default: |
|---|
| 456 | |
|---|
| 457 | break; |
|---|
| 458 | } |
|---|
| 459 | |
|---|
| 460 | // 3) LOCKDTEN <- '1' (@0x0314[1]) |
|---|
| 461 | nRet = LgdtAlterRegi(0x0314, 0xE3); |
|---|
| 462 | if(nRet != LGDT_ERR_NO) |
|---|
| 463 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 464 | |
|---|
| 465 | // 4) IFBW[15:0] <-- 0x8888 (@0x0308,0x0309) |
|---|
| 466 | nRet = LgdtAlterRegi(0x0308, 0x88); |
|---|
| 467 | if(nRet != LGDT_ERR_NO) |
|---|
| 468 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 469 | |
|---|
| 470 | nRet = LgdtAlterRegi(0x0309, 0x88); |
|---|
| 471 | if(nRet != LGDT_ERR_NO) |
|---|
| 472 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 473 | |
|---|
| 474 | // 5) ACQEN <- '1'b (@0x030C[2]) |
|---|
| 475 | nRet = LgdtAlterRegi(0x030C, 0x34); |
|---|
| 476 | if(nRet != LGDT_ERR_NO) |
|---|
| 477 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 478 | |
|---|
| 479 | // 6) QAMFBEXT <- '1'b (@0x043F[2]) |
|---|
| 480 | nRet = LgdtAlterRegi(0x043F, 0xAE); |
|---|
| 481 | if(nRet != LGDT_ERR_NO) |
|---|
| 482 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 483 | |
|---|
| 484 | #if Ver_095 |
|---|
| 485 | // 7) RFFIX <- '1'b (@0x030D[2] |
|---|
| 486 | nRet = LgdtCheckRegi(0x030D, &pData); |
|---|
| 487 | if(nRet != LGDT_ERR_NO) |
|---|
| 488 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 489 | |
|---|
| 490 | pData |= 0x04; |
|---|
| 491 | |
|---|
| 492 | nRet = LgdtAlterRegi(0x030D, pData); |
|---|
| 493 | if(nRet != LGDT_ERR_NO) |
|---|
| 494 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 495 | #endif |
|---|
| 496 | |
|---|
| 497 | // 6) reset |
|---|
| 498 | nRet = LgdtCheckRegi(0x0002, &pData); |
|---|
| 499 | if(nRet != LGDT_ERR_NO) |
|---|
| 500 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 501 | |
|---|
| 502 | pData &= 0xFE; |
|---|
| 503 | |
|---|
| 504 | nRet = LgdtAlterRegi(0x0002, pData); |
|---|
| 505 | if(nRet != LGDT_ERR_NO) |
|---|
| 506 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 507 | |
|---|
| 508 | LgdtDelay((DATA16)20); // reset delay |
|---|
| 509 | |
|---|
| 510 | nRet = LgdtCheckRegi(0x0002, &pData); |
|---|
| 511 | if(nRet != LGDT_ERR_NO) |
|---|
| 512 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 513 | |
|---|
| 514 | pData &= 0xFE; |
|---|
| 515 | pData |= 0x01; |
|---|
| 516 | |
|---|
| 517 | nRet = LgdtAlterRegi(0x0002, pData); |
|---|
| 518 | if(nRet != LGDT_ERR_NO) |
|---|
| 519 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 520 | |
|---|
| 521 | return LGDT_ERR_NO; |
|---|
| 522 | } |
|---|
| 523 | |
|---|
| 524 | |
|---|
| 525 | LgdtReturn_t LgdtInitVSB(void) |
|---|
| 526 | { |
|---|
| 527 | DATA08 pData; |
|---|
| 528 | LgdtReturn_t nRet; |
|---|
| 529 | |
|---|
| 530 | // 1) OPERMODE[1:0] <-- '11'b |
|---|
| 531 | nRet = LgdtCheckRegi(0x0000, &pData); |
|---|
| 532 | if(nRet != LGDT_ERR_NO) |
|---|
| 533 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 534 | |
|---|
| 535 | pData &= 0xFC; |
|---|
| 536 | pData |= 0x03; |
|---|
| 537 | |
|---|
| 538 | nRet = LgdtAlterRegi(0x0000, pData); |
|---|
| 539 | if(nRet != LGDT_ERR_NO) |
|---|
| 540 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 541 | |
|---|
| 542 | // 2) DAGCREF[15:0] <-- 0x32C4 (@0x0012,0x0013) |
|---|
| 543 | nRet = LgdtAlterRegi(0x0012, 0x32); |
|---|
| 544 | if (nRet != LGDT_ERR_NO) |
|---|
| 545 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 546 | |
|---|
| 547 | nRet = LgdtAlterRegi(0x0013, 0xC4); |
|---|
| 548 | if (nRet != LGDT_ERR_NO) |
|---|
| 549 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 550 | |
|---|
| 551 | // 3) LOCKDTEN <- '0' (@0x0314[1]) |
|---|
| 552 | nRet = LgdtAlterRegi(0x0314, 0xE1); |
|---|
| 553 | if(nRet != LGDT_ERR_NO) |
|---|
| 554 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 555 | |
|---|
| 556 | // 4) IFBW[15:0] <-- 0x8000 (@0x0308,0x0309) |
|---|
| 557 | nRet = LgdtAlterRegi(0x0308, 0x80); |
|---|
| 558 | if(nRet != LGDT_ERR_NO) |
|---|
| 559 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 560 | |
|---|
| 561 | nRet = LgdtAlterRegi(0x0309, 0x00); |
|---|
| 562 | if(nRet != LGDT_ERR_NO) |
|---|
| 563 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 564 | |
|---|
| 565 | // 5) ACQEN <- '0'b (@0x030C[2]) |
|---|
| 566 | nRet = LgdtAlterRegi(0x030C, 0x30); |
|---|
| 567 | if(nRet != LGDT_ERR_NO) |
|---|
| 568 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 569 | |
|---|
| 570 | // 6) QAMFBEXT <- '0'b (@0x043F[2]) |
|---|
| 571 | nRet = LgdtAlterRegi(0x043F, 0xAA); |
|---|
| 572 | if(nRet != LGDT_ERR_NO) |
|---|
| 573 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 574 | |
|---|
| 575 | #ifdef VSB_PLL_SWEEP |
|---|
| 576 | nRet = LgdtAlterRegi(0x012A, 0xC9); |
|---|
| 577 | if(nRet != LGDT_ERR_NO) |
|---|
| 578 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 579 | #endif |
|---|
| 580 | // 7) GCONCIR <- '0'b (@0x0116[7] |
|---|
| 581 | nRet = LgdtCheckRegi(0x0116, &pData); |
|---|
| 582 | if(nRet != LGDT_ERR_NO) |
|---|
| 583 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 584 | |
|---|
| 585 | pData &= 0x7F; |
|---|
| 586 | |
|---|
| 587 | nRet = LgdtAlterRegi(0x0116, pData); |
|---|
| 588 | if(nRet != LGDT_ERR_NO) |
|---|
| 589 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 590 | |
|---|
| 591 | #if Ver_095 |
|---|
| 592 | // 8) RFFIX <- '1'b (@0x030D[2] |
|---|
| 593 | nRet = LgdtCheckRegi(0x030D, &pData); |
|---|
| 594 | if(nRet != LGDT_ERR_NO) |
|---|
| 595 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 596 | |
|---|
| 597 | pData |= 0x04; |
|---|
| 598 | |
|---|
| 599 | nRet = LgdtAlterRegi(0x030D, pData); |
|---|
| 600 | if(nRet != LGDT_ERR_NO) |
|---|
| 601 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 602 | #endif |
|---|
| 603 | |
|---|
| 604 | // 8) Reset |
|---|
| 605 | nRet = LgdtCheckRegi(0x0002, &pData); |
|---|
| 606 | if(nRet != LGDT_ERR_NO) |
|---|
| 607 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 608 | |
|---|
| 609 | pData &= 0xFE; |
|---|
| 610 | |
|---|
| 611 | nRet = LgdtAlterRegi(0x0002, pData); |
|---|
| 612 | if(nRet != LGDT_ERR_NO) |
|---|
| 613 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 614 | |
|---|
| 615 | LgdtDelay((DATA16)20); // reset delay |
|---|
| 616 | |
|---|
| 617 | nRet = LgdtCheckRegi(0x0002, &pData); |
|---|
| 618 | if(nRet != LGDT_ERR_NO) |
|---|
| 619 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 620 | |
|---|
| 621 | pData &= 0xFE; |
|---|
| 622 | pData |= 0x01; |
|---|
| 623 | |
|---|
| 624 | nRet = LgdtAlterRegi(0x0002, pData); |
|---|
| 625 | if(nRet != LGDT_ERR_NO) |
|---|
| 626 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 627 | |
|---|
| 628 | return LGDT_ERR_NO; |
|---|
| 629 | } |
|---|
| 630 | |
|---|
| 631 | |
|---|
| 632 | LgdtReturn_t LgdtResetFAT(void) |
|---|
| 633 | { |
|---|
| 634 | LgdtReturn_t nRet; |
|---|
| 635 | DATA08 nData; |
|---|
| 636 | |
|---|
| 637 | nRet = LgdtCheckRegi(0x0002, &nData); |
|---|
| 638 | if (nRet != LGDT_ERR_NO) |
|---|
| 639 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 640 | |
|---|
| 641 | nData = nData & 0xFE; |
|---|
| 642 | nRet = LgdtAlterRegi(0x0002, nData); |
|---|
| 643 | if (nRet != LGDT_ERR_NO) |
|---|
| 644 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 645 | |
|---|
| 646 | LgdtDelay((DATA16)20); // reset delay |
|---|
| 647 | |
|---|
| 648 | nData |= 0x01; |
|---|
| 649 | nRet = LgdtAlterRegi(0x0002, nData); |
|---|
| 650 | if (nRet != LGDT_ERR_NO) |
|---|
| 651 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 652 | |
|---|
| 653 | return LGDT_ERR_NO; |
|---|
| 654 | } |
|---|
| 655 | |
|---|
| 656 | |
|---|
| 657 | LgdtReturn_t LgdtCheckRegi(DATA16 nAddr, DATA08* pData) |
|---|
| 658 | { |
|---|
| 659 | DATA08 nSize = 1; |
|---|
| 660 | DATA08 nData; |
|---|
| 661 | LgdtReturn_t nRet; |
|---|
| 662 | |
|---|
| 663 | nRet = (LgdtReturn_t)Lgdt_I2C_Read(g_i2cAddr[g_feId], nAddr, &nData, nSize); |
|---|
| 664 | if (nRet != LGDT_ERR_NO) |
|---|
| 665 | return LGDT_ERR_I2C; |
|---|
| 666 | |
|---|
| 667 | *pData = nData; |
|---|
| 668 | return LGDT_ERR_NO; |
|---|
| 669 | } |
|---|
| 670 | |
|---|
| 671 | |
|---|
| 672 | LgdtReturn_t LgdtAlterRegi(DATA16 nAddr, DATA08 nData) |
|---|
| 673 | { |
|---|
| 674 | DATA08 nTemp; |
|---|
| 675 | DATA08 nDataWrite[4]; |
|---|
| 676 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 677 | |
|---|
| 678 | nDataWrite[0] = g_i2cAddr[g_feId]; |
|---|
| 679 | |
|---|
| 680 | nTemp = nAddr >> 8; |
|---|
| 681 | nTemp &= 0xFF; |
|---|
| 682 | nDataWrite[1] = nTemp; |
|---|
| 683 | |
|---|
| 684 | nTemp = nAddr & 0xFF; |
|---|
| 685 | nDataWrite[2] = nTemp; |
|---|
| 686 | |
|---|
| 687 | nDataWrite[3] = nData; |
|---|
| 688 | |
|---|
| 689 | nRet = (LgdtReturn_t)Lgdt_I2C_Write(nDataWrite, 4); |
|---|
| 690 | if (nRet != LGDT_ERR_NO) |
|---|
| 691 | nRet = (LgdtReturn_t)(nRet|LGDT_ERR_I2C); |
|---|
| 692 | |
|---|
| 693 | return (LgdtReturn_t)nRet; |
|---|
| 694 | } |
|---|
| 695 | |
|---|
| 696 | |
|---|
| 697 | /* Delay time in milliseconds */ |
|---|
| 698 | int LgdtDelay(DATA16 nDelayTime) |
|---|
| 699 | { |
|---|
| 700 | /* FOLLOWING ROUTINE IS AN EXAMPLE FOR CUSTOMER */ |
|---|
| 701 | Lgdt_Delay(nDelayTime); |
|---|
| 702 | |
|---|
| 703 | return 0; |
|---|
| 704 | } |
|---|
| 705 | |
|---|
| 706 | |
|---|
| 707 | LgdtReturn_t LgdtRepeaterI2C(bool mode) |
|---|
| 708 | { |
|---|
| 709 | LgdtReturn_t nRet; |
|---|
| 710 | DATA08 nData; |
|---|
| 711 | |
|---|
| 712 | // Add 1ms delay by j.y. won : 2007.08.21 (due to tuner) |
|---|
| 713 | LgdtDelay(1); |
|---|
| 714 | |
|---|
| 715 | nRet = LgdtCheckRegi(0x0001, &nData); |
|---|
| 716 | if (nRet != LGDT_ERR_NO) |
|---|
| 717 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 718 | |
|---|
| 719 | nData &= 0xDF; |
|---|
| 720 | |
|---|
| 721 | if (mode == true) /*----- I2C Repeater Turn ON -----*/ |
|---|
| 722 | { |
|---|
| 723 | nRet = LgdtAlterRegi(0x0001, nData); |
|---|
| 724 | if (nRet != LGDT_ERR_NO) |
|---|
| 725 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 726 | } |
|---|
| 727 | else /*----- I2C Repeater Turn OFF -----*/ |
|---|
| 728 | { |
|---|
| 729 | nData |= 0x20; |
|---|
| 730 | nRet = LgdtAlterRegi(0x0001, nData); |
|---|
| 731 | if (nRet != LGDT_ERR_NO) |
|---|
| 732 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 733 | } |
|---|
| 734 | |
|---|
| 735 | // Add 1ms delay by j.y. won : 2007.08.21 (due to tuner) |
|---|
| 736 | LgdtDelay(1); |
|---|
| 737 | |
|---|
| 738 | return LGDT_ERR_NO; |
|---|
| 739 | } |
|---|
| 740 | |
|---|
| 741 | |
|---|
| 742 | |
|---|
| 743 | LgdtReturn_t LgdtCheckVersion(LgdtVersion_s *pVersion) |
|---|
| 744 | { |
|---|
| 745 | pVersion->Major = LGDT_VERSION_MAJOR; |
|---|
| 746 | pVersion->Minor = LGDT_VERSION_MINOR; |
|---|
| 747 | pVersion->Custom= LGDT_VERSION_CUSTOM; |
|---|
| 748 | |
|---|
| 749 | //pVersion->Tuner = cfgTuner.modelTuner; |
|---|
| 750 | |
|---|
| 751 | return LGDT_ERR_NO; |
|---|
| 752 | } |
|---|
| 753 | |
|---|
| 754 | |
|---|
| 755 | LgdtReturn_t LgdtCheckOperMode(LgdtOperMode_t* modeOper) |
|---|
| 756 | { |
|---|
| 757 | DATA08 pData; |
|---|
| 758 | LgdtReturn_t nRet; |
|---|
| 759 | |
|---|
| 760 | nRet = LgdtCheckRegi(0x0000, &pData); |
|---|
| 761 | if (nRet != LGDT_ERR_NO) |
|---|
| 762 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 763 | |
|---|
| 764 | pData &= 0x03; |
|---|
| 765 | switch(pData) |
|---|
| 766 | { |
|---|
| 767 | case LGDT_QAM64: |
|---|
| 768 | *modeOper = LGDT_QAM64; |
|---|
| 769 | break; |
|---|
| 770 | case LGDT_QAM256: |
|---|
| 771 | *modeOper = LGDT_QAM256; |
|---|
| 772 | break; |
|---|
| 773 | case LGDT_VSB: |
|---|
| 774 | *modeOper = LGDT_VSB; |
|---|
| 775 | break; |
|---|
| 776 | default: |
|---|
| 777 | return LGDT_ERR_CHECK_FUNC; |
|---|
| 778 | } |
|---|
| 779 | |
|---|
| 780 | return LGDT_ERR_NO; |
|---|
| 781 | } |
|---|
| 782 | |
|---|
| 783 | |
|---|
| 784 | |
|---|
| 785 | LgdtReturn_t LgdtAlterMpegMode(LgdtMpegMode_t isMPEG) |
|---|
| 786 | { |
|---|
| 787 | DATA08 pData; |
|---|
| 788 | DATA08 nTemp; |
|---|
| 789 | LgdtReturn_t nRet; |
|---|
| 790 | |
|---|
| 791 | if ( (isMPEG != LGDT_PARAL) && (isMPEG != LGDT_SERIAL) ) |
|---|
| 792 | return (LgdtReturn_t)(LGDT_ERR_PARAM|LGDT_ERR_ALTER_FUNC); |
|---|
| 793 | |
|---|
| 794 | nTemp = isMPEG << 5; |
|---|
| 795 | |
|---|
| 796 | nRet = LgdtCheckRegi(0x050E, &pData); |
|---|
| 797 | if (nRet != LGDT_ERR_NO) |
|---|
| 798 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 799 | |
|---|
| 800 | pData &= 0xDF; |
|---|
| 801 | pData |= nTemp; |
|---|
| 802 | |
|---|
| 803 | nRet = LgdtAlterRegi(0x050E, pData); |
|---|
| 804 | if(nRet != LGDT_ERR_NO) |
|---|
| 805 | { |
|---|
| 806 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 807 | } |
|---|
| 808 | |
|---|
| 809 | nRet = LgdtResetFAT(); |
|---|
| 810 | if (nRet != LGDT_ERR_NO) |
|---|
| 811 | { |
|---|
| 812 | return nRet; |
|---|
| 813 | } |
|---|
| 814 | |
|---|
| 815 | return LGDT_ERR_NO; |
|---|
| 816 | } |
|---|
| 817 | |
|---|
| 818 | |
|---|
| 819 | LgdtReturn_t LgdtAlterMpegPolarity(LgdtClock_t isCLKEDG, LgdtClock_t isVALID) |
|---|
| 820 | { |
|---|
| 821 | DATA08 pData; |
|---|
| 822 | DATA08 nTemp; |
|---|
| 823 | LgdtReturn_t nRet; |
|---|
| 824 | |
|---|
| 825 | nTemp = 0x00; |
|---|
| 826 | if (isCLKEDG == LGDT_CLOCK_HIGH) |
|---|
| 827 | nTemp |= 0x08; |
|---|
| 828 | if (isVALID == LGDT_CLOCK_HIGH) |
|---|
| 829 | nTemp |= 0x01; |
|---|
| 830 | |
|---|
| 831 | nRet = LgdtCheckRegi(0x050E, &pData); |
|---|
| 832 | if (nRet != LGDT_ERR_NO) |
|---|
| 833 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 834 | |
|---|
| 835 | pData &= 0xF6; |
|---|
| 836 | pData |= nTemp; |
|---|
| 837 | |
|---|
| 838 | nRet = LgdtAlterRegi(0x050E, pData); |
|---|
| 839 | if(nRet != LGDT_ERR_NO) |
|---|
| 840 | { |
|---|
| 841 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 842 | } |
|---|
| 843 | |
|---|
| 844 | nRet = LgdtResetFAT(); |
|---|
| 845 | if (nRet != LGDT_ERR_NO) |
|---|
| 846 | { |
|---|
| 847 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 848 | } |
|---|
| 849 | |
|---|
| 850 | return LGDT_ERR_NO; |
|---|
| 851 | } |
|---|
| 852 | |
|---|
| 853 | |
|---|
| 854 | LgdtReturn_t LgdtAlterSpectrumFAT(LgdtInvert_t isPol) |
|---|
| 855 | { |
|---|
| 856 | DATA08 pData; |
|---|
| 857 | LgdtReturn_t nRet; |
|---|
| 858 | |
|---|
| 859 | nRet = LgdtCheckRegi(0x0504, &pData); |
|---|
| 860 | if(nRet != LGDT_ERR_NO) |
|---|
| 861 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 862 | |
|---|
| 863 | pData &= 0xF5; /*----- 0xF5 : 1111 x1x1 -----*/ |
|---|
| 864 | if (isPol == LGDT_INVERTED) |
|---|
| 865 | pData |= 0x02; |
|---|
| 866 | |
|---|
| 867 | nRet = LgdtAlterRegi(0x0504, pData); |
|---|
| 868 | if(nRet != LGDT_ERR_NO) |
|---|
| 869 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 870 | |
|---|
| 871 | /*----- FEC Not-Reset -----*/ |
|---|
| 872 | nRet = LgdtAlterRegi(0x0504, pData | 0x08); |
|---|
| 873 | if(nRet != LGDT_ERR_NO) |
|---|
| 874 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 875 | |
|---|
| 876 | |
|---|
| 877 | return LGDT_ERR_NO; |
|---|
| 878 | } |
|---|
| 879 | |
|---|
| 880 | |
|---|
| 881 | |
|---|
| 882 | LgdtReturn_t LgdtIsLockSync(bool* isLock) |
|---|
| 883 | { |
|---|
| 884 | DATA08 pData; |
|---|
| 885 | LgdtReturn_t nRet; |
|---|
| 886 | |
|---|
| 887 | *isLock = false; |
|---|
| 888 | nRet = LgdtCheckRegi(0x0003, &pData); |
|---|
| 889 | if (nRet != LGDT_ERR_NO) |
|---|
| 890 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 891 | |
|---|
| 892 | pData &= 0x04; // ¼öÁ¤..±âÁ¸ Inlock ¿¡¼ synclock À¸·Î.. |
|---|
| 893 | if (pData == 0x04) |
|---|
| 894 | *isLock = true; |
|---|
| 895 | |
|---|
| 896 | return LGDT_ERR_NO; |
|---|
| 897 | } |
|---|
| 898 | |
|---|
| 899 | |
|---|
| 900 | LgdtReturn_t LgdtIsLockCR(bool *isLock) |
|---|
| 901 | { |
|---|
| 902 | DATA08 pData; |
|---|
| 903 | LgdtOperMode_t modeOper; |
|---|
| 904 | LgdtReturn_t nRet; |
|---|
| 905 | |
|---|
| 906 | nRet = LgdtCheckRegi(0x011D, &pData); |
|---|
| 907 | if (nRet != LGDT_ERR_NO) |
|---|
| 908 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 909 | |
|---|
| 910 | nRet = LgdtCheckOperMode(&modeOper); |
|---|
| 911 | if(nRet != LGDT_ERR_NO) |
|---|
| 912 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 913 | |
|---|
| 914 | *isLock = false; |
|---|
| 915 | if (modeOper == LGDT_VSB) |
|---|
| 916 | { |
|---|
| 917 | pData &= 0x80; |
|---|
| 918 | if (pData == 0x80) |
|---|
| 919 | *isLock = true; |
|---|
| 920 | } |
|---|
| 921 | else |
|---|
| 922 | { |
|---|
| 923 | pData &= 0x02; |
|---|
| 924 | if (pData == 0x02) |
|---|
| 925 | *isLock = true; |
|---|
| 926 | } |
|---|
| 927 | |
|---|
| 928 | return LGDT_ERR_NO; |
|---|
| 929 | } |
|---|
| 930 | |
|---|
| 931 | |
|---|
| 932 | |
|---|
| 933 | LgdtReturn_t LgdtCheckSnrFAT(DATA_DOUBLE* nSNR) |
|---|
| 934 | { |
|---|
| 935 | DATA_DOUBLE nData = 0; |
|---|
| 936 | LgdtOperMode_t modeOper; |
|---|
| 937 | LgdtReturn_t nRet; |
|---|
| 938 | |
|---|
| 939 | nRet = LgdtCheckOperMode(&modeOper); |
|---|
| 940 | if (nRet != LGDT_ERR_NO) |
|---|
| 941 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 942 | |
|---|
| 943 | switch(modeOper) |
|---|
| 944 | { |
|---|
| 945 | case LGDT_QAM64: |
|---|
| 946 | case LGDT_QAM256: |
|---|
| 947 | nRet = LgdtCheckSnrQAM(&nData, modeOper); |
|---|
| 948 | if (nRet != LGDT_ERR_NO) |
|---|
| 949 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 950 | *nSNR = nData; |
|---|
| 951 | break; |
|---|
| 952 | default: |
|---|
| 953 | nRet = LgdtCheckSnrVSB(&nData); |
|---|
| 954 | if (nRet != LGDT_ERR_NO) |
|---|
| 955 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 956 | *nSNR = nData; |
|---|
| 957 | break; |
|---|
| 958 | } |
|---|
| 959 | |
|---|
| 960 | return LGDT_ERR_NO; |
|---|
| 961 | } |
|---|
| 962 | |
|---|
| 963 | |
|---|
| 964 | LgdtReturn_t LgdtCheckSnrQAM(DATA_DOUBLE* nEQ, LgdtOperMode_t modeOper) |
|---|
| 965 | { |
|---|
| 966 | LgdtReturn_t nRet; |
|---|
| 967 | DATA08 pData; |
|---|
| 968 | DATA16 nData = 0; |
|---|
| 969 | DATA32 nSignalPower = 0; |
|---|
| 970 | |
|---|
| 971 | /*----- Assgin Ps(Signal Power) based upon the mode -----*/ |
|---|
| 972 | if (modeOper == LGDT_QAM64) |
|---|
| 973 | nSignalPower = 688128; |
|---|
| 974 | else if (modeOper == LGDT_QAM256) |
|---|
| 975 | nSignalPower = 696320; |
|---|
| 976 | else |
|---|
| 977 | return (LgdtReturn_t)(LGDT_ERR_PARAM|LGDT_ERR_CHECK_FUNC); |
|---|
| 978 | /*----- End of assigning Ps -----*/ |
|---|
| 979 | |
|---|
| 980 | nRet = LgdtCheckRegi(0x011B, &pData); |
|---|
| 981 | if (nRet != LGDT_ERR_NO) |
|---|
| 982 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 983 | nData = pData << 8; |
|---|
| 984 | |
|---|
| 985 | nRet = LgdtCheckRegi(0x011C, &pData); |
|---|
| 986 | if (nRet != LGDT_ERR_NO) |
|---|
| 987 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 988 | nData |= pData; |
|---|
| 989 | |
|---|
| 990 | //DSI_printf(DSI_PORT_0, "FE_ID : %d, SNR nData : %u \r\n", g_feId, nData); |
|---|
| 991 | |
|---|
| 992 | if ((nData != 0xFFFF) && (nData !=0)) |
|---|
| 993 | { |
|---|
| 994 | *nEQ = 10 * log10((DATA_DOUBLE)nSignalPower / nData); // Bug fixed by j.y. won : 2007.06.18 |
|---|
| 995 | } |
|---|
| 996 | else |
|---|
| 997 | *nEQ = 0; |
|---|
| 998 | |
|---|
| 999 | if (*nEQ < 0) |
|---|
| 1000 | *nEQ = 0; |
|---|
| 1001 | |
|---|
| 1002 | return LGDT_ERR_NO; |
|---|
| 1003 | } |
|---|
| 1004 | |
|---|
| 1005 | |
|---|
| 1006 | LgdtReturn_t LgdtCheckSnrVSB(DATA_DOUBLE* nPT) |
|---|
| 1007 | { |
|---|
| 1008 | DATA08 pData; |
|---|
| 1009 | DATA32 nData = 0; |
|---|
| 1010 | LgdtReturn_t nRet; |
|---|
| 1011 | |
|---|
| 1012 | // PT SNR |
|---|
| 1013 | nRet = LgdtCheckRegi(0x0417, &pData); |
|---|
| 1014 | if (nRet != LGDT_ERR_NO) |
|---|
| 1015 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1016 | nData = pData & 0x0F; |
|---|
| 1017 | nData <<= 16; |
|---|
| 1018 | |
|---|
| 1019 | nRet = LgdtCheckRegi(0x0418, &pData); |
|---|
| 1020 | if (nRet != LGDT_ERR_NO) |
|---|
| 1021 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1022 | nData |= (pData << 8); // 2006-09-21, by sungwee |
|---|
| 1023 | |
|---|
| 1024 | nRet = LgdtCheckRegi(0x0419, &pData); |
|---|
| 1025 | if (nRet != LGDT_ERR_NO) |
|---|
| 1026 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1027 | nData |= pData; |
|---|
| 1028 | |
|---|
| 1029 | //DSI_printf(DSI_PORT_0, "FE_ID : %d, SNR nData : %u \r\n", g_feId, nData); |
|---|
| 1030 | |
|---|
| 1031 | if ((nData < 0x0FFFFF) && (nData > 0)) |
|---|
| 1032 | { |
|---|
| 1033 | *nPT = 10 * log10((DATA_DOUBLE)(25 * 32 * 32) / nData); // Bug fixed by j.y. won : 2007.06.18 |
|---|
| 1034 | } |
|---|
| 1035 | else |
|---|
| 1036 | *nPT = 0; |
|---|
| 1037 | |
|---|
| 1038 | if (*nPT < 0) |
|---|
| 1039 | *nPT = 0; |
|---|
| 1040 | |
|---|
| 1041 | return LGDT_ERR_NO; |
|---|
| 1042 | } |
|---|
| 1043 | |
|---|
| 1044 | |
|---|
| 1045 | |
|---|
| 1046 | LgdtReturn_t LgdtCheckPacketErr(DATA16* nErr) |
|---|
| 1047 | { |
|---|
| 1048 | DATA08 pData; |
|---|
| 1049 | DATA16 nData; |
|---|
| 1050 | LgdtReturn_t nRet; |
|---|
| 1051 | |
|---|
| 1052 | nRet = LgdtCheckRegi(0x050C, &pData); |
|---|
| 1053 | if (nRet != LGDT_ERR_NO) |
|---|
| 1054 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1055 | |
|---|
| 1056 | nData = pData << 8; |
|---|
| 1057 | |
|---|
| 1058 | nRet = LgdtCheckRegi(0x050D, &pData); |
|---|
| 1059 | if (nRet != LGDT_ERR_NO) |
|---|
| 1060 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1061 | |
|---|
| 1062 | nData |= pData; |
|---|
| 1063 | *nErr = nData; |
|---|
| 1064 | |
|---|
| 1065 | return LGDT_ERR_NO; |
|---|
| 1066 | } |
|---|
| 1067 | |
|---|
| 1068 | |
|---|
| 1069 | LgdtReturn_t LgdtIsLockBER(bool *isLock) |
|---|
| 1070 | { |
|---|
| 1071 | DATA08 pData; |
|---|
| 1072 | LgdtReturn_t nRet; |
|---|
| 1073 | |
|---|
| 1074 | *isLock = false; |
|---|
| 1075 | |
|---|
| 1076 | // Added by j.y. won : 2007.06.18 |
|---|
| 1077 | nRet = LgdtCheckRegi(0x0800, &pData); |
|---|
| 1078 | if(nRet != LGDT_ERR_NO) |
|---|
| 1079 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1080 | if(pData&0x01) |
|---|
| 1081 | return LGDT_ERR_OTHER; |
|---|
| 1082 | |
|---|
| 1083 | nRet = LgdtCheckRegi(0x0809, &pData); |
|---|
| 1084 | if(nRet != LGDT_ERR_NO) |
|---|
| 1085 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1086 | |
|---|
| 1087 | pData &= 0x01; |
|---|
| 1088 | if(pData == 0x01) |
|---|
| 1089 | *isLock = true; |
|---|
| 1090 | |
|---|
| 1091 | return LGDT_ERR_NO; |
|---|
| 1092 | } |
|---|
| 1093 | |
|---|
| 1094 | |
|---|
| 1095 | LgdtReturn_t LgdtCheckBer(float* nBer) |
|---|
| 1096 | { |
|---|
| 1097 | DATA08 pData; |
|---|
| 1098 | DATA32 nPeriod; |
|---|
| 1099 | DATA32 nErr1, nErr2, nErr3, nErr4; |
|---|
| 1100 | LgdtReturn_t nRet; |
|---|
| 1101 | |
|---|
| 1102 | /*----- Checks BERTPERD -----*/ |
|---|
| 1103 | nRet = LgdtCheckRegi(0x0801, &pData); |
|---|
| 1104 | if(nRet != LGDT_ERR_NO) |
|---|
| 1105 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1106 | pData &= 0x1F; |
|---|
| 1107 | // added by j.y. won : 2007.10.24 |
|---|
| 1108 | if(pData < 4) pData = 4; |
|---|
| 1109 | |
|---|
| 1110 | /*----- Period = 2^BERTPERD -----*/ |
|---|
| 1111 | nPeriod = 1<<pData; |
|---|
| 1112 | |
|---|
| 1113 | /*----- Reads 4 registers -----*/ |
|---|
| 1114 | nRet = LgdtCheckRegi(0x080A, &pData); |
|---|
| 1115 | if(nRet != LGDT_ERR_NO) |
|---|
| 1116 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1117 | nErr1 = (DATA32)pData << 24; |
|---|
| 1118 | |
|---|
| 1119 | nRet = LgdtCheckRegi(0x080B, &pData); |
|---|
| 1120 | if(nRet != LGDT_ERR_NO) |
|---|
| 1121 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1122 | nErr2 = (DATA32)pData << 16; |
|---|
| 1123 | |
|---|
| 1124 | nRet = LgdtCheckRegi(0x080C, &pData); |
|---|
| 1125 | if(nRet != LGDT_ERR_NO) |
|---|
| 1126 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1127 | nErr3 = (DATA32)pData << 8; |
|---|
| 1128 | |
|---|
| 1129 | nRet = LgdtCheckRegi(0x080D, &pData); |
|---|
| 1130 | if(nRet != LGDT_ERR_NO) |
|---|
| 1131 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1132 | nErr4 = (DATA32)pData; |
|---|
| 1133 | |
|---|
| 1134 | /*----- Calculation for the average value during the nPeriod -----*/ |
|---|
| 1135 | |
|---|
| 1136 | // Modified by j.y. won : 2007.06.18 |
|---|
| 1137 | *nBer = (float)(nErr1+nErr2+nErr3+nErr4)/nPeriod; |
|---|
| 1138 | |
|---|
| 1139 | return LGDT_ERR_NO; |
|---|
| 1140 | } |
|---|
| 1141 | |
|---|
| 1142 | |
|---|
| 1143 | LgdtReturn_t LgdtResetBER(void) |
|---|
| 1144 | { |
|---|
| 1145 | LgdtReturn_t nRet; |
|---|
| 1146 | DATA08 nData; |
|---|
| 1147 | |
|---|
| 1148 | // added by j.y. won : 2007.10.24 |
|---|
| 1149 | // FEC RESET.... |
|---|
| 1150 | nRet = LgdtCheckRegi(0x0504, &nData); |
|---|
| 1151 | if (nRet != LGDT_ERR_NO) |
|---|
| 1152 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 1153 | nData = 0xF7; |
|---|
| 1154 | nRet = LgdtAlterRegi(0x0504, nData); |
|---|
| 1155 | if (nRet != LGDT_ERR_NO) |
|---|
| 1156 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 1157 | |
|---|
| 1158 | LgdtDelay(20); |
|---|
| 1159 | nData |= 0x08; |
|---|
| 1160 | nRet = LgdtAlterRegi(0x0504, nData); |
|---|
| 1161 | if (nRet != LGDT_ERR_NO) |
|---|
| 1162 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 1163 | |
|---|
| 1164 | nRet = LgdtCheckRegi(0x0800, &nData); |
|---|
| 1165 | if (nRet != LGDT_ERR_NO) |
|---|
| 1166 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 1167 | |
|---|
| 1168 | nData &= 0xFE; |
|---|
| 1169 | nRet = LgdtAlterRegi(0x0800, (nData|0x01) ); |
|---|
| 1170 | if (nRet != LGDT_ERR_NO) |
|---|
| 1171 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 1172 | |
|---|
| 1173 | LgdtDelay((DATA16)DELAY); |
|---|
| 1174 | |
|---|
| 1175 | nRet = LgdtAlterRegi(0x0800, nData); |
|---|
| 1176 | if (nRet != LGDT_ERR_NO) |
|---|
| 1177 | return (LgdtReturn_t)(nRet|LGDT_ERR_INIT); |
|---|
| 1178 | |
|---|
| 1179 | return LGDT_ERR_NO; |
|---|
| 1180 | } |
|---|
| 1181 | |
|---|
| 1182 | |
|---|
| 1183 | LgdtReturn_t LgdtAlterPolyPRBS(LgdtPolyPRBS_t modePRBS, DATA32 nData) |
|---|
| 1184 | { |
|---|
| 1185 | const DATA32 MODE15 = 0x00C001; /*--- Refers to the Datasheet ---*/ |
|---|
| 1186 | const DATA32 MODE23 = 0x840001; /*--- Refers to the Datasheet ---*/ |
|---|
| 1187 | |
|---|
| 1188 | DATA08 pData; |
|---|
| 1189 | LgdtReturn_t nRet; |
|---|
| 1190 | |
|---|
| 1191 | switch(modePRBS) |
|---|
| 1192 | { |
|---|
| 1193 | case LGDT_PolyPRBS: |
|---|
| 1194 | break; |
|---|
| 1195 | case LGDT_PolyPRBS15: |
|---|
| 1196 | nData = MODE15; |
|---|
| 1197 | break; |
|---|
| 1198 | case LGDT_PolyPRBS23: |
|---|
| 1199 | nData = MODE23; |
|---|
| 1200 | break; |
|---|
| 1201 | default: |
|---|
| 1202 | return (LgdtReturn_t)(LGDT_ERR_NO|LGDT_ERR_PARAM); |
|---|
| 1203 | } |
|---|
| 1204 | |
|---|
| 1205 | pData = (DATA08)((nData >> 16) & 0xFF); |
|---|
| 1206 | nRet = LgdtAlterRegi(0x0803, pData); |
|---|
| 1207 | if(nRet != LGDT_ERR_NO) |
|---|
| 1208 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 1209 | |
|---|
| 1210 | pData = (DATA08)((nData >> 8) & 0xFF); |
|---|
| 1211 | nRet = LgdtAlterRegi(0x0804, pData); |
|---|
| 1212 | if(nRet != LGDT_ERR_NO) |
|---|
| 1213 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 1214 | |
|---|
| 1215 | pData = (DATA08)(nData & 0xFF); |
|---|
| 1216 | nRet = LgdtAlterRegi(0x0805, pData); |
|---|
| 1217 | if(nRet != LGDT_ERR_NO) |
|---|
| 1218 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 1219 | |
|---|
| 1220 | LgdtDelay((DATA16)DELAY); |
|---|
| 1221 | LgdtResetBER(); |
|---|
| 1222 | |
|---|
| 1223 | return LGDT_ERR_NO; |
|---|
| 1224 | } |
|---|
| 1225 | |
|---|
| 1226 | |
|---|
| 1227 | LgdtReturn_t LgdtAlterInvertPRBS(LgdtInvert_t isPol) |
|---|
| 1228 | { |
|---|
| 1229 | DATA08 pData; |
|---|
| 1230 | DATA08 nData; |
|---|
| 1231 | LgdtReturn_t nRet; |
|---|
| 1232 | |
|---|
| 1233 | nRet = LgdtCheckRegi(0x0800, &pData); |
|---|
| 1234 | if(nRet != LGDT_ERR_NO) |
|---|
| 1235 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 1236 | nData = pData & 0xFB; |
|---|
| 1237 | |
|---|
| 1238 | if (isPol == LGDT_INVERTED) |
|---|
| 1239 | nData |= 0x04; /*--- Bit #3 to HIGH ---*/ |
|---|
| 1240 | |
|---|
| 1241 | nRet = LgdtAlterRegi(0x0800, nData); |
|---|
| 1242 | if(nRet != LGDT_ERR_NO) |
|---|
| 1243 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 1244 | |
|---|
| 1245 | nRet = LgdtResetFAT(); |
|---|
| 1246 | if(nRet != LGDT_ERR_NO) |
|---|
| 1247 | return (LgdtReturn_t)nRet; |
|---|
| 1248 | |
|---|
| 1249 | return LGDT_ERR_NO; |
|---|
| 1250 | } |
|---|
| 1251 | |
|---|
| 1252 | |
|---|
| 1253 | |
|---|
| 1254 | |
|---|
| 1255 | #if COMMENT |
|---|
| 1256 | __________User_Code__________(){} |
|---|
| 1257 | #endif |
|---|
| 1258 | |
|---|
| 1259 | |
|---|
| 1260 | #if COMMENT |
|---|
| 1261 | ______Global______(){} |
|---|
| 1262 | #endif |
|---|
| 1263 | |
|---|
| 1264 | |
|---|
| 1265 | |
|---|
| 1266 | // id : LG3305 ¿¡ ÇÒ´çµÈ FE ID |
|---|
| 1267 | #define CHECK_LG3305_id(id) { \ |
|---|
| 1268 | } |
|---|
| 1269 | |
|---|
| 1270 | |
|---|
| 1271 | |
|---|
| 1272 | #if COMMENT |
|---|
| 1273 | ______Low_Level______(){} |
|---|
| 1274 | #endif |
|---|
| 1275 | |
|---|
| 1276 | |
|---|
| 1277 | #if COMMENT |
|---|
| 1278 | ______Delay_____(){} |
|---|
| 1279 | #endif |
|---|
| 1280 | |
|---|
| 1281 | /* |
|---|
| 1282 | Delay ÇÔ¼ö |
|---|
| 1283 | Delay time in milliseconds |
|---|
| 1284 | */ |
|---|
| 1285 | LgdtReturn_t Lgdt_Delay(DATA16 nDelayTime) |
|---|
| 1286 | { |
|---|
| 1287 | |
|---|
| 1288 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1289 | |
|---|
| 1290 | DHL_OS_Delay(nDelayTime); |
|---|
| 1291 | |
|---|
| 1292 | return nRet; |
|---|
| 1293 | } |
|---|
| 1294 | |
|---|
| 1295 | |
|---|
| 1296 | #if COMMENT |
|---|
| 1297 | ______I2C_____(){} |
|---|
| 1298 | #endif |
|---|
| 1299 | |
|---|
| 1300 | /* LG3305 I2C write format |
|---|
| 1301 | |
|---|
| 1302 | S - DeviceAddr(W) - SubAddr(2byte) - writeData0(1byte) - ..... - writeData(n-1) - P |
|---|
| 1303 | |
|---|
| 1304 | LG3305 ¿¡¼ Á¤ÀÇÇÏ´Â Device Address ´Â 0xB2 Àϰæ¿ì ½ÇÁ¦ Bit ´Â 1011 0010 |
|---|
| 1305 | |
|---|
| 1306 | */ |
|---|
| 1307 | LgdtReturn_t Lgdt_I2C_Write(DATA08 *pData, DATA08 nSizeData) |
|---|
| 1308 | { |
|---|
| 1309 | DHL_RESULT dhr = DHL_OK; |
|---|
| 1310 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1311 | UINT8 chip_addr; |
|---|
| 1312 | UINT16 sub_addr; |
|---|
| 1313 | |
|---|
| 1314 | chip_addr = pData[0]; |
|---|
| 1315 | sub_addr = ((UINT16)pData[1] << 8) | pData[2]; |
|---|
| 1316 | dhr = dhl_i2c_write3(g_i2cId[g_feId], chip_addr, sub_addr, &(pData[3]), |
|---|
| 1317 | nSizeData - 3); |
|---|
| 1318 | if (dhr != DHL_OK) |
|---|
| 1319 | { |
|---|
| 1320 | DHL_OS_Printf("|%s| fail to write demod(chip_addr:0x%x).\n", |
|---|
| 1321 | __FUNCTION__, chip_addr); |
|---|
| 1322 | } |
|---|
| 1323 | |
|---|
| 1324 | return nRet; |
|---|
| 1325 | } |
|---|
| 1326 | |
|---|
| 1327 | |
|---|
| 1328 | /* LG3305 I2C read format |
|---|
| 1329 | |
|---|
| 1330 | S - DeviceAddr(W) - SubAddr(2byte) - Rs - DeviceAddr(R) - readData0(1byte) - ..... - readData(n-1) - P |
|---|
| 1331 | |
|---|
| 1332 | LG3305 ¿¡¼ Á¤ÀÇÇÏ´Â Device Address ´Â 0xB2 Àϰæ¿ì ½ÇÁ¦ Bit ´Â 1011 0011 |
|---|
| 1333 | |
|---|
| 1334 | */ |
|---|
| 1335 | LgdtReturn_t Lgdt_I2C_Read(DATA08 nAddrDev, DATA16 nAddrReg, DATA08 *pData, DATA08 nSizeData) |
|---|
| 1336 | { |
|---|
| 1337 | DHL_RESULT dhr = DHL_OK; |
|---|
| 1338 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1339 | |
|---|
| 1340 | dhr = dhl_i2c_read3(g_i2cId[g_feId], nAddrDev, nAddrReg, pData, nSizeData); |
|---|
| 1341 | if (dhr != DHL_OK) |
|---|
| 1342 | { |
|---|
| 1343 | DHL_OS_Printf("|%s| fail to read demod(chip_addr:0x%x).\n", |
|---|
| 1344 | __FUNCTION__, nAddrDev); |
|---|
| 1345 | } |
|---|
| 1346 | |
|---|
| 1347 | return nRet; |
|---|
| 1348 | } |
|---|
| 1349 | |
|---|
| 1350 | |
|---|
| 1351 | |
|---|
| 1352 | #if COMMENT |
|---|
| 1353 | ______High_Level______(){} |
|---|
| 1354 | #endif |
|---|
| 1355 | |
|---|
| 1356 | |
|---|
| 1357 | #if COMMENT |
|---|
| 1358 | ___________(){} |
|---|
| 1359 | #endif |
|---|
| 1360 | |
|---|
| 1361 | LgdtReturn_t LgdtIsLockAgc(bool* isLock) |
|---|
| 1362 | { |
|---|
| 1363 | |
|---|
| 1364 | LgdtReturn_t nRet; |
|---|
| 1365 | DATA08 pData; |
|---|
| 1366 | |
|---|
| 1367 | *isLock = false; |
|---|
| 1368 | |
|---|
| 1369 | nRet = LgdtCheckRegi(0x031E, &pData); |
|---|
| 1370 | if (nRet != LGDT_ERR_NO) |
|---|
| 1371 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1372 | |
|---|
| 1373 | pData &= 0x01; |
|---|
| 1374 | if (pData == 0x01) |
|---|
| 1375 | *isLock = true; |
|---|
| 1376 | |
|---|
| 1377 | |
|---|
| 1378 | return LGDT_ERR_NO; |
|---|
| 1379 | |
|---|
| 1380 | } |
|---|
| 1381 | |
|---|
| 1382 | |
|---|
| 1383 | LgdtReturn_t LgdtIsLockTR(bool* isLock) |
|---|
| 1384 | { |
|---|
| 1385 | |
|---|
| 1386 | LgdtReturn_t nRet; |
|---|
| 1387 | DATA08 pData; |
|---|
| 1388 | |
|---|
| 1389 | *isLock = false; |
|---|
| 1390 | |
|---|
| 1391 | nRet = LgdtCheckRegi(0x021B, &pData); |
|---|
| 1392 | if (nRet != LGDT_ERR_NO) |
|---|
| 1393 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1394 | |
|---|
| 1395 | pData &= 0x07; |
|---|
| 1396 | |
|---|
| 1397 | //DSI_printf(0, " TR Lock status : %d \r\n", pData); |
|---|
| 1398 | |
|---|
| 1399 | if (pData == 0x04) |
|---|
| 1400 | *isLock = true; |
|---|
| 1401 | |
|---|
| 1402 | |
|---|
| 1403 | return LGDT_ERR_NO; |
|---|
| 1404 | |
|---|
| 1405 | } |
|---|
| 1406 | |
|---|
| 1407 | |
|---|
| 1408 | /* |
|---|
| 1409 | AGCLOCK(1) : 0 (Unlock), 1 (lock) => ÀÏ´Ü Á¦¿Ü.. ÀÔ·Â ½ÅÈ£°¡ ³·À¸¸é 0 ÀÌ µÉ ¼ö µµ ÀÖ´Ù.. |
|---|
| 1410 | SYNCLOCK(1) : 0 (Unlock), 1 (Lock) |
|---|
| 1411 | CLOCKVSB(1) : 0 (Unlock), 1 (Lock) |
|---|
| 1412 | */ |
|---|
| 1413 | LgdtReturn_t Lgdt_get_VSBLock(DATA08 *lock) |
|---|
| 1414 | { |
|---|
| 1415 | |
|---|
| 1416 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1417 | bool agclock, synclock, clockvsb; |
|---|
| 1418 | |
|---|
| 1419 | |
|---|
| 1420 | *lock = 0; // 0 : unlock, 1 : lock |
|---|
| 1421 | |
|---|
| 1422 | nRet = LgdtIsLockAgc(&agclock); |
|---|
| 1423 | if (nRet != LGDT_ERR_NO) |
|---|
| 1424 | goto err_exit; |
|---|
| 1425 | |
|---|
| 1426 | nRet = LgdtIsLockCR(&clockvsb); |
|---|
| 1427 | if(nRet != LGDT_ERR_NO) |
|---|
| 1428 | goto err_exit; |
|---|
| 1429 | |
|---|
| 1430 | nRet = LgdtIsLockSync(&synclock); |
|---|
| 1431 | if (nRet != LGDT_ERR_NO) |
|---|
| 1432 | goto err_exit; |
|---|
| 1433 | |
|---|
| 1434 | |
|---|
| 1435 | //DSI_printf(DSI_PORT_0, "FE_ID : %d, VSB : agclock = %d, synclock = %d, clockvsb = %d \r\n", g_feId, agclock, synclock, clockvsb); |
|---|
| 1436 | |
|---|
| 1437 | #if 0 |
|---|
| 1438 | if(agclock == true && synclock == true && clockvsb == true) |
|---|
| 1439 | #else |
|---|
| 1440 | if(synclock == true && clockvsb == true) |
|---|
| 1441 | #endif |
|---|
| 1442 | { |
|---|
| 1443 | *lock = 1; |
|---|
| 1444 | } |
|---|
| 1445 | |
|---|
| 1446 | |
|---|
| 1447 | |
|---|
| 1448 | err_exit: |
|---|
| 1449 | |
|---|
| 1450 | return nRet; |
|---|
| 1451 | |
|---|
| 1452 | |
|---|
| 1453 | } |
|---|
| 1454 | |
|---|
| 1455 | |
|---|
| 1456 | /* |
|---|
| 1457 | AGCLOCK(1) : 0 (Unlock), 1 (Lock) |
|---|
| 1458 | SYNCLOCK(1) : 0 (Unlock), 1 (Lock) |
|---|
| 1459 | TRLOCK(3) : 0x04 (Lock ??) |
|---|
| 1460 | */ |
|---|
| 1461 | LgdtReturn_t Lgdt_get_QAMLock(DATA08 *lock) |
|---|
| 1462 | { |
|---|
| 1463 | |
|---|
| 1464 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1465 | bool agclock, synclock, trlock; |
|---|
| 1466 | |
|---|
| 1467 | |
|---|
| 1468 | *lock = 0; // 0 : unlock, 1 : lock |
|---|
| 1469 | |
|---|
| 1470 | nRet = LgdtIsLockAgc(&agclock); |
|---|
| 1471 | if (nRet != LGDT_ERR_NO) |
|---|
| 1472 | goto err_exit; |
|---|
| 1473 | |
|---|
| 1474 | nRet = LgdtIsLockTR(&trlock); |
|---|
| 1475 | if(nRet != LGDT_ERR_NO) |
|---|
| 1476 | goto err_exit; |
|---|
| 1477 | |
|---|
| 1478 | nRet = LgdtIsLockSync(&synclock); |
|---|
| 1479 | if (nRet != LGDT_ERR_NO) |
|---|
| 1480 | goto err_exit; |
|---|
| 1481 | |
|---|
| 1482 | |
|---|
| 1483 | //DSI_printf(DSI_PORT_0, "FE_ID : %d, QAM : agclock = %d, synclock = %d, trlock = %d \r\n", g_feId, agclock, synclock, trlock); |
|---|
| 1484 | |
|---|
| 1485 | #if 0 |
|---|
| 1486 | if(agclock == true && synclock == true && trlock == true) |
|---|
| 1487 | #else |
|---|
| 1488 | if(synclock == true && trlock == true) |
|---|
| 1489 | #endif |
|---|
| 1490 | { |
|---|
| 1491 | *lock = 1; |
|---|
| 1492 | } |
|---|
| 1493 | |
|---|
| 1494 | |
|---|
| 1495 | |
|---|
| 1496 | |
|---|
| 1497 | |
|---|
| 1498 | |
|---|
| 1499 | err_exit: |
|---|
| 1500 | |
|---|
| 1501 | return nRet; |
|---|
| 1502 | |
|---|
| 1503 | |
|---|
| 1504 | } |
|---|
| 1505 | |
|---|
| 1506 | |
|---|
| 1507 | /* |
|---|
| 1508 | MPEG TS parameter settings |
|---|
| 1509 | |
|---|
| 1510 | Data1st ¼³Á¤.. |
|---|
| 1511 | errins ¼³Á¤.. |
|---|
| 1512 | ±âŸ Polarity ¼³Á¤.. |
|---|
| 1513 | |
|---|
| 1514 | */ |
|---|
| 1515 | LgdtReturn_t LgdtAlterMpegSettings(LgdtData1st_t data1st, LgdtErrins_t errins, |
|---|
| 1516 | LgdtTpclkmod_t tpclkmod, LgdtClock_t tpsoppol, LgdtClock_t tperrpol) |
|---|
| 1517 | { |
|---|
| 1518 | |
|---|
| 1519 | LgdtReturn_t nRet; |
|---|
| 1520 | DATA08 pData[2]; |
|---|
| 1521 | DATA08 nTemp; |
|---|
| 1522 | |
|---|
| 1523 | nRet = LgdtCheckRegi(0x050E, &pData[0]); |
|---|
| 1524 | if (nRet != LGDT_ERR_NO) |
|---|
| 1525 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1526 | |
|---|
| 1527 | nRet = LgdtCheckRegi(0x050F, &pData[1]); |
|---|
| 1528 | if (nRet != LGDT_ERR_NO) |
|---|
| 1529 | return (LgdtReturn_t)(nRet|LGDT_ERR_CHECK_FUNC); |
|---|
| 1530 | |
|---|
| 1531 | |
|---|
| 1532 | nTemp = pData[0] & 0xAD; |
|---|
| 1533 | |
|---|
| 1534 | pData[0] = nTemp | (data1st << 4) | (errins << 1) | (tpclkmod << 6); |
|---|
| 1535 | |
|---|
| 1536 | nTemp = pData[1] & 0xFC; |
|---|
| 1537 | |
|---|
| 1538 | pData[1] = nTemp | (tpsoppol << 1) | tperrpol; |
|---|
| 1539 | |
|---|
| 1540 | nRet = LgdtAlterRegi(0x050E, pData[0]); |
|---|
| 1541 | if(nRet != LGDT_ERR_NO) |
|---|
| 1542 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 1543 | |
|---|
| 1544 | nRet = LgdtAlterRegi(0x050F, pData[1]); |
|---|
| 1545 | if(nRet != LGDT_ERR_NO) |
|---|
| 1546 | return (LgdtReturn_t)(nRet|LGDT_ERR_ALTER_FUNC); |
|---|
| 1547 | |
|---|
| 1548 | //DSI_printf(DSI_PORT_0, " FE_ID : %d, Reg = 0x050E val : 0x%x, 0x050F val : 0x%x \r\n", g_feId, pData[0], pData[1]); |
|---|
| 1549 | |
|---|
| 1550 | nRet = LgdtResetFAT(); |
|---|
| 1551 | if (nRet != LGDT_ERR_NO) |
|---|
| 1552 | { |
|---|
| 1553 | return nRet; |
|---|
| 1554 | } |
|---|
| 1555 | |
|---|
| 1556 | |
|---|
| 1557 | return LGDT_ERR_NO; |
|---|
| 1558 | |
|---|
| 1559 | } |
|---|
| 1560 | |
|---|
| 1561 | |
|---|
| 1562 | /* |
|---|
| 1563 | IF center Freq, spectrum inversion, complex ¼³Á¤. |
|---|
| 1564 | ±âÁ¸ LG API ¼Ò½º¿¡¼ ¾à°£ ±¸Á¶ º¯°æ.. |
|---|
| 1565 | |
|---|
| 1566 | if_freq : MHz |
|---|
| 1567 | |
|---|
| 1568 | IF center freq ¼ÂÆÃ |
|---|
| 1569 | 1. VSB : |
|---|
| 1570 | complex_multiplier À϶§ fc : pilot freq |
|---|
| 1571 | inversion À̸é pilot freq = if freq + pilot offset |
|---|
| 1572 | inversion ÀÌ ¾Æ´Ï¸é pilot freq = if freq - pilot offset |
|---|
| 1573 | |
|---|
| 1574 | NCOCTF = (fc/fs)*2^26 |
|---|
| 1575 | |
|---|
| 1576 | real_multiplier À϶§ fc : center freq |
|---|
| 1577 | NCOCTF = (fc/fs)*2^26 |
|---|
| 1578 | |
|---|
| 1579 | fs : demod system clk |
|---|
| 1580 | |
|---|
| 1581 | 2. QAM : |
|---|
| 1582 | NCOCTF = (fc/fs)*2^30 |
|---|
| 1583 | |
|---|
| 1584 | fc : center freq |
|---|
| 1585 | fs : demod system clk |
|---|
| 1586 | |
|---|
| 1587 | |
|---|
| 1588 | */ |
|---|
| 1589 | LgdtReturn_t LgdtSetManualIfandSpectrum(double if_freq, LgdtOperMode_t demod, |
|---|
| 1590 | bool complex_multiplier, bool vsb_inversion) |
|---|
| 1591 | { |
|---|
| 1592 | int n_nco = 0; |
|---|
| 1593 | double nco_freq = 0.0; |
|---|
| 1594 | double pilot_offset = 2.690559; |
|---|
| 1595 | |
|---|
| 1596 | LgdtReturn_t nRet; |
|---|
| 1597 | DATA08 pData; |
|---|
| 1598 | DATA08 n_nco_b1, n_nco_b2, n_nco_b3, n_nco_b4; |
|---|
| 1599 | |
|---|
| 1600 | if(complex_multiplier) // complex multiplier |
|---|
| 1601 | { |
|---|
| 1602 | // Downmode set - complex multiplier |
|---|
| 1603 | nRet = LgdtCheckRegi(0x0007, &pData); |
|---|
| 1604 | if(nRet != LGDT_ERR_NO) |
|---|
| 1605 | return LGDT_ERR_INIT; |
|---|
| 1606 | pData |= 0x40; |
|---|
| 1607 | nRet = LgdtAlterRegi(0x0007, pData); |
|---|
| 1608 | if(nRet != LGDT_ERR_NO) |
|---|
| 1609 | return LGDT_ERR_INIT; |
|---|
| 1610 | |
|---|
| 1611 | if(demod == LGDT_QAM64 || demod == LGDT_QAM256) // QAM mode |
|---|
| 1612 | { |
|---|
| 1613 | nco_freq = if_freq/25.0*1073741824.0; // NCOCTF = (fc/fs)*2^30 |
|---|
| 1614 | n_nco = (int)nco_freq; |
|---|
| 1615 | n_nco_b4 = (n_nco>>24)&0x3f; |
|---|
| 1616 | n_nco_b4 |= 0x40; |
|---|
| 1617 | n_nco_b3 = (n_nco>>16)&0xff; |
|---|
| 1618 | n_nco_b2 = (n_nco>>8)&0xff; |
|---|
| 1619 | n_nco_b1 = n_nco&0xff; |
|---|
| 1620 | |
|---|
| 1621 | // set spectrum |
|---|
| 1622 | if(vsb_inversion) |
|---|
| 1623 | LgdtAlterSpectrumFAT(LGDT_NOT_INVERTED); |
|---|
| 1624 | else |
|---|
| 1625 | LgdtAlterSpectrumFAT(LGDT_INVERTED); |
|---|
| 1626 | |
|---|
| 1627 | } |
|---|
| 1628 | else // VSB mode |
|---|
| 1629 | { |
|---|
| 1630 | |
|---|
| 1631 | // for spectrum inversion |
|---|
| 1632 | nRet = LgdtCheckRegi(0x0126, &pData); |
|---|
| 1633 | if(nRet != LGDT_ERR_NO) |
|---|
| 1634 | return LGDT_ERR_INIT; |
|---|
| 1635 | |
|---|
| 1636 | if(vsb_inversion) //VSB spectrum inversion |
|---|
| 1637 | { |
|---|
| 1638 | pData |= 0x80; |
|---|
| 1639 | nco_freq = (if_freq+pilot_offset)/25.0*67108864.0; // NCOCTF = (fc/fs)*2^26 |
|---|
| 1640 | } |
|---|
| 1641 | else //VSB spectrum non-inversion |
|---|
| 1642 | { |
|---|
| 1643 | pData &= 0x7F; |
|---|
| 1644 | nco_freq = (if_freq-pilot_offset)/25.0*67108864.0; // NCOCTF = (fc/fs)*2^26 |
|---|
| 1645 | } |
|---|
| 1646 | |
|---|
| 1647 | nRet = LgdtAlterRegi(0x0126, pData); |
|---|
| 1648 | if(nRet != LGDT_ERR_NO) |
|---|
| 1649 | return LGDT_ERR_INIT; |
|---|
| 1650 | |
|---|
| 1651 | n_nco = (int)nco_freq; |
|---|
| 1652 | n_nco_b4 = (n_nco>>24)&0x3f; |
|---|
| 1653 | n_nco_b4 |= 0x40; |
|---|
| 1654 | n_nco_b3 = (n_nco>>16)&0xff; |
|---|
| 1655 | n_nco_b2 = (n_nco>>8)&0xff; |
|---|
| 1656 | n_nco_b1 = n_nco&0xff; |
|---|
| 1657 | } |
|---|
| 1658 | |
|---|
| 1659 | if( (if_freq >5.8 && if_freq <6.2) || (if_freq >43.8 && if_freq <44.2) ) |
|---|
| 1660 | { |
|---|
| 1661 | // DSAWBPY, DAGCBPY enable |
|---|
| 1662 | nRet = LgdtCheckRegi(0x000D, &pData); |
|---|
| 1663 | if(nRet != LGDT_ERR_NO) |
|---|
| 1664 | return LGDT_ERR_INIT; |
|---|
| 1665 | |
|---|
| 1666 | pData &= 0x3F; |
|---|
| 1667 | nRet = LgdtAlterRegi(0x000D, pData); |
|---|
| 1668 | if(nRet != LGDT_ERR_NO) |
|---|
| 1669 | return LGDT_ERR_INIT; |
|---|
| 1670 | } |
|---|
| 1671 | else |
|---|
| 1672 | { |
|---|
| 1673 | // DSAWBPY, DAGCBPY disable |
|---|
| 1674 | nRet = LgdtCheckRegi(0x000D, &pData); |
|---|
| 1675 | if(nRet != LGDT_ERR_NO) |
|---|
| 1676 | return LGDT_ERR_INIT; |
|---|
| 1677 | |
|---|
| 1678 | pData |= 0xC0; |
|---|
| 1679 | nRet = LgdtAlterRegi(0x000D, pData); |
|---|
| 1680 | if(nRet != LGDT_ERR_NO) |
|---|
| 1681 | return LGDT_ERR_INIT; |
|---|
| 1682 | } |
|---|
| 1683 | |
|---|
| 1684 | nRet = LgdtAlterRegi(0x0106, n_nco_b4); |
|---|
| 1685 | if(nRet != LGDT_ERR_NO) |
|---|
| 1686 | return LGDT_ERR_INIT; |
|---|
| 1687 | nRet = LgdtAlterRegi(0x0107, n_nco_b3); |
|---|
| 1688 | if(nRet != LGDT_ERR_NO) |
|---|
| 1689 | return LGDT_ERR_INIT; |
|---|
| 1690 | nRet = LgdtAlterRegi(0x0108, n_nco_b2); |
|---|
| 1691 | if(nRet != LGDT_ERR_NO) |
|---|
| 1692 | return LGDT_ERR_INIT; |
|---|
| 1693 | nRet = LgdtAlterRegi(0x0109, n_nco_b1); |
|---|
| 1694 | if(nRet != LGDT_ERR_NO) |
|---|
| 1695 | return LGDT_ERR_INIT; |
|---|
| 1696 | |
|---|
| 1697 | } |
|---|
| 1698 | else // real multiplier |
|---|
| 1699 | { |
|---|
| 1700 | // Downmode set - real multiplier |
|---|
| 1701 | nRet = LgdtCheckRegi(0x0007, &pData); |
|---|
| 1702 | if(nRet != LGDT_ERR_NO) |
|---|
| 1703 | return LGDT_ERR_INIT; |
|---|
| 1704 | pData &= 0xBF; |
|---|
| 1705 | nRet = LgdtAlterRegi(0x0007, pData); |
|---|
| 1706 | if(nRet != LGDT_ERR_NO) |
|---|
| 1707 | return LGDT_ERR_INIT; |
|---|
| 1708 | |
|---|
| 1709 | // DSAWBPY, DAGCBPY enable |
|---|
| 1710 | nRet = LgdtCheckRegi(0x000D, &pData); |
|---|
| 1711 | if(nRet != LGDT_ERR_NO) |
|---|
| 1712 | return LGDT_ERR_INIT; |
|---|
| 1713 | |
|---|
| 1714 | pData &= 0x3F; |
|---|
| 1715 | nRet = LgdtAlterRegi(0x000D, pData); |
|---|
| 1716 | if(nRet != LGDT_ERR_NO) |
|---|
| 1717 | return LGDT_ERR_INIT; |
|---|
| 1718 | |
|---|
| 1719 | if(demod == LGDT_QAM64 || demod == LGDT_QAM256) // QAM mode |
|---|
| 1720 | { |
|---|
| 1721 | nco_freq = if_freq/25.0*1073741824.0; // NCOCTF = (fc/fs)*2^30 |
|---|
| 1722 | n_nco = (int)nco_freq; |
|---|
| 1723 | n_nco_b4 = (n_nco>>24)&0x3f; |
|---|
| 1724 | n_nco_b4 |= 0x40; |
|---|
| 1725 | n_nco_b3 = (n_nco>>16)&0xff; |
|---|
| 1726 | n_nco_b2 = (n_nco>>8)&0xff; |
|---|
| 1727 | n_nco_b1 = n_nco&0xff; |
|---|
| 1728 | |
|---|
| 1729 | // set spectrum |
|---|
| 1730 | LgdtAlterSpectrumFAT(LGDT_NOT_INVERTED); |
|---|
| 1731 | } |
|---|
| 1732 | else // VSB mode |
|---|
| 1733 | { |
|---|
| 1734 | |
|---|
| 1735 | // for spectrum inversion |
|---|
| 1736 | nRet = LgdtCheckRegi(0x0126, &pData); |
|---|
| 1737 | if(nRet != LGDT_ERR_NO) |
|---|
| 1738 | return LGDT_ERR_INIT; |
|---|
| 1739 | |
|---|
| 1740 | if(vsb_inversion) // VSB spectrum inversion |
|---|
| 1741 | { |
|---|
| 1742 | pData |= 0x80; |
|---|
| 1743 | nco_freq = if_freq/25.0*67108864.0; // NCOCTF = (fc/fs)*2^26 |
|---|
| 1744 | } |
|---|
| 1745 | else // VSB spectrum non-inversion |
|---|
| 1746 | { |
|---|
| 1747 | pData &= 0x7F; |
|---|
| 1748 | nco_freq = if_freq/25.0*67108864.0; // NCOCTF = (fc/fs)*2^26 |
|---|
| 1749 | } |
|---|
| 1750 | |
|---|
| 1751 | nRet = LgdtAlterRegi(0x0126, pData); |
|---|
| 1752 | if(nRet != LGDT_ERR_NO) |
|---|
| 1753 | return LGDT_ERR_INIT; |
|---|
| 1754 | |
|---|
| 1755 | n_nco = (int)nco_freq; |
|---|
| 1756 | n_nco_b4 = (n_nco>>24)&0x3f; |
|---|
| 1757 | n_nco_b4 |= 0x40; |
|---|
| 1758 | n_nco_b3 = (n_nco>>16)&0xff; |
|---|
| 1759 | n_nco_b2 = (n_nco>>8)&0xff; |
|---|
| 1760 | n_nco_b1 = n_nco&0xff; |
|---|
| 1761 | } |
|---|
| 1762 | |
|---|
| 1763 | nRet = LgdtAlterRegi(0x0106, n_nco_b4); |
|---|
| 1764 | if(nRet != LGDT_ERR_NO) |
|---|
| 1765 | return LGDT_ERR_INIT; |
|---|
| 1766 | nRet = LgdtAlterRegi(0x0107, n_nco_b3); |
|---|
| 1767 | if(nRet != LGDT_ERR_NO) |
|---|
| 1768 | return LGDT_ERR_INIT; |
|---|
| 1769 | nRet = LgdtAlterRegi(0x0108, n_nco_b2); |
|---|
| 1770 | if(nRet != LGDT_ERR_NO) |
|---|
| 1771 | return LGDT_ERR_INIT; |
|---|
| 1772 | nRet = LgdtAlterRegi(0x0109, n_nco_b1); |
|---|
| 1773 | if(nRet != LGDT_ERR_NO) |
|---|
| 1774 | return LGDT_ERR_INIT; |
|---|
| 1775 | } |
|---|
| 1776 | |
|---|
| 1777 | return LGDT_ERR_NO; |
|---|
| 1778 | |
|---|
| 1779 | } |
|---|
| 1780 | |
|---|
| 1781 | |
|---|
| 1782 | #if COMMENT |
|---|
| 1783 | __________API__________(){} |
|---|
| 1784 | #endif |
|---|
| 1785 | |
|---|
| 1786 | |
|---|
| 1787 | |
|---|
| 1788 | #if COMMENT |
|---|
| 1789 | ______Tune______(){} |
|---|
| 1790 | #endif |
|---|
| 1791 | |
|---|
| 1792 | |
|---|
| 1793 | /* LG3305 ÃʱâÈ API |
|---|
| 1794 | |
|---|
| 1795 | -FE ä³Î ¹× I2C °ü·Ã ÃʱâÈ ¼öÇà.. |
|---|
| 1796 | -MPEG TS ¿¡ ´ëÇÑ ¼³Á¤ ¼öÇà..(Decoder ÀÇ ¼³Á¤°ª°ú ÀÏÄ¡ ½ÃÅ´..) |
|---|
| 1797 | -±âŸ ÇÊ¿äÇÑ ¼³Á¤ ?? |
|---|
| 1798 | |
|---|
| 1799 | ´Ù¸¥ API º¸´Ù ²À!! °¡Àå ¸ÕÀú ¼öÇàµÇ¾î¾ß Çϸç App·Î ºÎÅÍ FE_ID, I2C_ID, I2C_Addr À» |
|---|
| 1800 | ¹Þ¾Æ¾ß µÈ´Ù.!!! |
|---|
| 1801 | |
|---|
| 1802 | */ |
|---|
| 1803 | LgdtReturn_t LG3305_init(DATA08 id, DATA08 hI2c, DATA08 i2cAddr) |
|---|
| 1804 | { |
|---|
| 1805 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1806 | LgdtVersion_s api_ver; |
|---|
| 1807 | |
|---|
| 1808 | CHECK_LG3305_id(id); |
|---|
| 1809 | |
|---|
| 1810 | g_feId = id; |
|---|
| 1811 | g_i2cId[g_feId] = hI2c; |
|---|
| 1812 | g_i2cAddr[g_feId] = i2cAddr; |
|---|
| 1813 | |
|---|
| 1814 | nRet = LgdtCheckVersion(&api_ver); //API ¹öÁ¯À» Àоî¿È..reg¿¡¼ Àоî¿À´Â °ÍÀº ¾Æ´Ô!! |
|---|
| 1815 | |
|---|
| 1816 | DHL_OS_Printf(" LG3305 API Ver %d. %d. %d \r\n", api_ver.Major, api_ver.Minor, api_ver.Custom); |
|---|
| 1817 | |
|---|
| 1818 | #if 0 // Serial TS |
|---|
| 1819 | nRet = LgdtAlterMpegMode(LGDT_SERIAL); // MPEG TS Data mode ¼³Á¤.. |
|---|
| 1820 | #else // Parallel TS |
|---|
| 1821 | nRet = LgdtAlterMpegMode(LGDT_PARAL); // MPEG TS Data mode ¼³Á¤.. |
|---|
| 1822 | #endif |
|---|
| 1823 | if(nRet != LGDT_ERR_NO) |
|---|
| 1824 | goto err_exit; |
|---|
| 1825 | |
|---|
| 1826 | nRet = LgdtAlterMpegPolarity(LGDT_CLOCK_HIGH, LGDT_CLOCK_HIGH); // Clk, Valid ÀÇ polarity ¼³Á¤.. |
|---|
| 1827 | if(nRet != LGDT_ERR_NO) |
|---|
| 1828 | goto err_exit; |
|---|
| 1829 | |
|---|
| 1830 | nRet = LgdtAlterMpegSettings(LGDT_MSB1ST, LGDT_ERRINS_DISABLE, LGDT_FIXED_CLOCK, |
|---|
| 1831 | LGDT_CLOCK_HIGH, LGDT_CLOCK_LOW); // ±âŸ MPEG TS ¼³Á¤.. |
|---|
| 1832 | if(nRet != LGDT_ERR_NO) |
|---|
| 1833 | goto err_exit; |
|---|
| 1834 | |
|---|
| 1835 | |
|---|
| 1836 | err_exit: |
|---|
| 1837 | |
|---|
| 1838 | return nRet; |
|---|
| 1839 | } |
|---|
| 1840 | |
|---|
| 1841 | /* LG3305 tune API |
|---|
| 1842 | |
|---|
| 1843 | In-band tune ¸¸ Áö¿ø..(Air : VSB, Cable : 64QAM, 256QAM) |
|---|
| 1844 | |
|---|
| 1845 | */ |
|---|
| 1846 | LgdtReturn_t LG3305_tune(DATA08 id, LgdtOperMode_t demod, DATA_DOUBLE if_freq) |
|---|
| 1847 | { |
|---|
| 1848 | |
|---|
| 1849 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1850 | |
|---|
| 1851 | CHECK_LG3305_id(id); |
|---|
| 1852 | |
|---|
| 1853 | g_feId = id; |
|---|
| 1854 | |
|---|
| 1855 | |
|---|
| 1856 | if(demod == LGDT_QAM64 || demod == LGDT_QAM256 || demod == LGDT_VSB) // Áö¿øÇÏ´Â in-band mod type |
|---|
| 1857 | { |
|---|
| 1858 | |
|---|
| 1859 | nRet = LgdtSetManualIfandSpectrum(if_freq, demod, false, true); // if_freq, multiplier, spectrum inversion ¼ÂÆÃ. |
|---|
| 1860 | if(nRet != LGDT_ERR_NO) |
|---|
| 1861 | goto err_exit; |
|---|
| 1862 | |
|---|
| 1863 | nRet = LgdtInitFAT(demod, false); // internal AGC use |
|---|
| 1864 | |
|---|
| 1865 | } |
|---|
| 1866 | else |
|---|
| 1867 | { |
|---|
| 1868 | nRet = LGDT_ERR_RUN; |
|---|
| 1869 | } |
|---|
| 1870 | |
|---|
| 1871 | err_exit: |
|---|
| 1872 | |
|---|
| 1873 | return nRet; |
|---|
| 1874 | |
|---|
| 1875 | |
|---|
| 1876 | } |
|---|
| 1877 | |
|---|
| 1878 | |
|---|
| 1879 | /* |
|---|
| 1880 | Tuner I2C Control À» À§ÇÑ Passport enable ÇÔ¼ö. |
|---|
| 1881 | |
|---|
| 1882 | Tuner Á¦¾î¸¦ À§ÇÑ I2C ¶óÀÎÀÌ Demod ¸¦ ÅëÇØ¼ ¿¬°áµÊ.. |
|---|
| 1883 | Repeater ÇÔ¼ö¸¦ ÀÌ¿ëÇÏ¿© Pass ¸¦ On/Off ÇØÁÜ.. |
|---|
| 1884 | Demod ¼ÂÆÃÇÒ¶§´Â Off, Tuner ¼ÂÆÃÇÒ¶§´Â On |
|---|
| 1885 | |
|---|
| 1886 | On : true, Tuner ¼ÂÆÃ. |
|---|
| 1887 | Off : false, Demod ¼ÂÆÃ. |
|---|
| 1888 | |
|---|
| 1889 | */ |
|---|
| 1890 | LgdtReturn_t LG3305_RepeaterI2C(DATA08 id, bool mode) |
|---|
| 1891 | { |
|---|
| 1892 | |
|---|
| 1893 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1894 | |
|---|
| 1895 | CHECK_LG3305_id(id); |
|---|
| 1896 | |
|---|
| 1897 | g_feId = id; |
|---|
| 1898 | |
|---|
| 1899 | nRet = LgdtRepeaterI2C(mode); |
|---|
| 1900 | if(nRet != LGDT_ERR_NO) |
|---|
| 1901 | { |
|---|
| 1902 | DHL_OS_Printf(" FE_ID : %d, mode : %d, LG3305 Repeat Error!!! \r\n", id, mode); |
|---|
| 1903 | } |
|---|
| 1904 | |
|---|
| 1905 | |
|---|
| 1906 | return nRet; |
|---|
| 1907 | |
|---|
| 1908 | } |
|---|
| 1909 | |
|---|
| 1910 | |
|---|
| 1911 | |
|---|
| 1912 | |
|---|
| 1913 | #if COMMENT |
|---|
| 1914 | ______Status______(){} |
|---|
| 1915 | #endif |
|---|
| 1916 | |
|---|
| 1917 | /* |
|---|
| 1918 | Demod ÀÇ Lock »óÅ üũ.. |
|---|
| 1919 | |
|---|
| 1920 | VSB, QAM ¸ðµåº° °¢ Lock üũ.. ¸ðµÎ Lock µÇ¸é ÃÖÁ¾ Lock À¸·Î ÆÇ´Ü.. |
|---|
| 1921 | |
|---|
| 1922 | Demod ÀÇ ¼³Á¤°ª°ú Reg ÀÇ ¼ÂÆÃµÈ °ªÀ» üũÇÑ ÈÄ Lock üũ ¼öÇà.. |
|---|
| 1923 | |
|---|
| 1924 | */ |
|---|
| 1925 | LgdtReturn_t LG3305_get_LockStatus(DATA08 id, LgdtOperMode_t demod, DATA08 *lock) |
|---|
| 1926 | { |
|---|
| 1927 | |
|---|
| 1928 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1929 | LgdtOperMode_t demod_LGDT; |
|---|
| 1930 | |
|---|
| 1931 | CHECK_LG3305_id(id); |
|---|
| 1932 | |
|---|
| 1933 | g_feId = id; |
|---|
| 1934 | |
|---|
| 1935 | nRet = LgdtCheckOperMode(&demod_LGDT); // RegÀÇ Demod ¼ÂÆÃ°ªÀ» °¡Á®¿È.. |
|---|
| 1936 | if(nRet != LGDT_ERR_NO) |
|---|
| 1937 | goto err_exit; |
|---|
| 1938 | |
|---|
| 1939 | if(demod != demod_LGDT) // Demod ÀÇ ¼³Á¤°ª°ú ¼ÂÆÃ°ªÀ» ºñ±³ üũ.. |
|---|
| 1940 | { |
|---|
| 1941 | nRet = LGDT_ERR_PARAM; |
|---|
| 1942 | goto err_exit; |
|---|
| 1943 | } |
|---|
| 1944 | |
|---|
| 1945 | if(demod_LGDT == LGDT_VSB) // VSB Lock üũ.. |
|---|
| 1946 | { |
|---|
| 1947 | nRet = Lgdt_get_VSBLock(lock); |
|---|
| 1948 | } |
|---|
| 1949 | else if(demod_LGDT == LGDT_QAM64 || demod_LGDT == LGDT_QAM256) // QAM Lock üũ.. |
|---|
| 1950 | { |
|---|
| 1951 | nRet = Lgdt_get_QAMLock(lock); |
|---|
| 1952 | } |
|---|
| 1953 | else |
|---|
| 1954 | { |
|---|
| 1955 | nRet = LGDT_ERR_PARAM; |
|---|
| 1956 | } |
|---|
| 1957 | |
|---|
| 1958 | |
|---|
| 1959 | |
|---|
| 1960 | |
|---|
| 1961 | err_exit: |
|---|
| 1962 | |
|---|
| 1963 | return nRet; |
|---|
| 1964 | |
|---|
| 1965 | } |
|---|
| 1966 | |
|---|
| 1967 | |
|---|
| 1968 | /* SNR ÃøÁ¤ API |
|---|
| 1969 | |
|---|
| 1970 | Demod º° SNR °ª »êÃâÀÌ ´Ù¸§.. |
|---|
| 1971 | |
|---|
| 1972 | */ |
|---|
| 1973 | LgdtReturn_t LG3305_get_Snr(DATA08 id, LgdtOperMode_t demod, DATA_DOUBLE *nSNR) |
|---|
| 1974 | { |
|---|
| 1975 | |
|---|
| 1976 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 1977 | LgdtOperMode_t demod_LGDT; |
|---|
| 1978 | |
|---|
| 1979 | CHECK_LG3305_id(id); |
|---|
| 1980 | |
|---|
| 1981 | g_feId = id; |
|---|
| 1982 | |
|---|
| 1983 | nRet = LgdtCheckOperMode(&demod_LGDT); // RegÀÇ Demod ¼ÂÆÃ°ªÀ» °¡Á®¿È.. |
|---|
| 1984 | if(nRet != LGDT_ERR_NO) |
|---|
| 1985 | goto err_exit; |
|---|
| 1986 | |
|---|
| 1987 | if(demod != demod_LGDT) // Demod ÀÇ ¼³Á¤°ª°ú ¼ÂÆÃ°ªÀ» ºñ±³ üũ.. |
|---|
| 1988 | { |
|---|
| 1989 | nRet = LGDT_ERR_PARAM; |
|---|
| 1990 | goto err_exit; |
|---|
| 1991 | } |
|---|
| 1992 | |
|---|
| 1993 | nRet = LgdtCheckSnrFAT(nSNR); |
|---|
| 1994 | |
|---|
| 1995 | |
|---|
| 1996 | err_exit: |
|---|
| 1997 | |
|---|
| 1998 | return nRet; |
|---|
| 1999 | |
|---|
| 2000 | } |
|---|
| 2001 | |
|---|
| 2002 | /* FEC packet Err Count API |
|---|
| 2003 | |
|---|
| 2004 | ¿¡·¯ Ä«¿îÆ® °ªÀÌ °è¼Ó ´©ÀûµÇ´Â °ÍÀÌ ¾Æ´Ï¶ó ÀÏÁ¤ ½Ã°£ ¸¶´Ù °»½ÅµÇ´Â°Í °°À½ !! |
|---|
| 2005 | |
|---|
| 2006 | */ |
|---|
| 2007 | LgdtReturn_t LG3305_get_FECerr(DATA08 id, LgdtOperMode_t demod, DATA16 *nErr) |
|---|
| 2008 | { |
|---|
| 2009 | |
|---|
| 2010 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 2011 | LgdtOperMode_t demod_LGDT; |
|---|
| 2012 | |
|---|
| 2013 | CHECK_LG3305_id(id); |
|---|
| 2014 | |
|---|
| 2015 | g_feId = id; |
|---|
| 2016 | |
|---|
| 2017 | nRet = LgdtCheckOperMode(&demod_LGDT); // RegÀÇ Demod ¼ÂÆÃ°ªÀ» °¡Á®¿È.. |
|---|
| 2018 | if(nRet != LGDT_ERR_NO) |
|---|
| 2019 | goto err_exit; |
|---|
| 2020 | |
|---|
| 2021 | if(demod != demod_LGDT) // Demod ÀÇ ¼³Á¤°ª°ú ¼ÂÆÃ°ªÀ» ºñ±³ üũ.. |
|---|
| 2022 | { |
|---|
| 2023 | nRet = LGDT_ERR_PARAM; |
|---|
| 2024 | goto err_exit; |
|---|
| 2025 | } |
|---|
| 2026 | |
|---|
| 2027 | nRet = LgdtCheckPacketErr(nErr); |
|---|
| 2028 | |
|---|
| 2029 | err_exit: |
|---|
| 2030 | |
|---|
| 2031 | return nRet; |
|---|
| 2032 | |
|---|
| 2033 | } |
|---|
| 2034 | |
|---|
| 2035 | |
|---|
| 2036 | |
|---|
| 2037 | #if COMMENT |
|---|
| 2038 | ______TEST______(){} |
|---|
| 2039 | #endif |
|---|
| 2040 | |
|---|
| 2041 | |
|---|
| 2042 | |
|---|
| 2043 | /* |
|---|
| 2044 | BER(bit error rations) Check |
|---|
| 2045 | |
|---|
| 2046 | BER üũ¸¦ À§Çؼ´Â modulator ¿¡¼ PRBS mode ¸¦ Áö¿øÇØ¾ß Çϸç |
|---|
| 2047 | modulator ¿¡¼ ÁöÁ¤ÇÑ PRBS ¿Í demod ÀÇ PRBS °¡ ÀÏÄ¡½Ã¿¡¸¸ BER üũ°¡ °¡´É.. |
|---|
| 2048 | |
|---|
| 2049 | PRBS ¼ÂÆÃ -> BER Lock È®ÀÎ -> Lock À̸é BER üũ. |
|---|
| 2050 | |
|---|
| 2051 | */ |
|---|
| 2052 | LgdtReturn_t LG3305_get_Ber(DATA08 id, int mode_PRBS, int invertion) |
|---|
| 2053 | { |
|---|
| 2054 | |
|---|
| 2055 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 2056 | bool lock; |
|---|
| 2057 | float ber; |
|---|
| 2058 | |
|---|
| 2059 | CHECK_LG3305_id(id); |
|---|
| 2060 | |
|---|
| 2061 | g_feId = id; |
|---|
| 2062 | |
|---|
| 2063 | DHL_OS_Printf("FE_ID : %d, Check BER !!!\r\n", g_feId); |
|---|
| 2064 | |
|---|
| 2065 | nRet = LgdtAlterPolyPRBS((LgdtPolyPRBS_t)mode_PRBS, 0); |
|---|
| 2066 | if(nRet != LGDT_ERR_NO) |
|---|
| 2067 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtAlterPolyPRBS \r\n", g_feId, nRet); |
|---|
| 2068 | |
|---|
| 2069 | nRet = LgdtAlterInvertPRBS((LgdtInvert_t)invertion); |
|---|
| 2070 | if(nRet != LGDT_ERR_NO) |
|---|
| 2071 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtAlterInvertPRBS \r\n", g_feId, nRet); |
|---|
| 2072 | |
|---|
| 2073 | nRet = LgdtIsLockBER(&lock); |
|---|
| 2074 | if(nRet != LGDT_ERR_NO) |
|---|
| 2075 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtIsLockBER \r\n", g_feId, nRet); |
|---|
| 2076 | |
|---|
| 2077 | if(lock) |
|---|
| 2078 | { |
|---|
| 2079 | nRet = LgdtCheckBer(&ber); // bit error rations check |
|---|
| 2080 | if(nRet != LGDT_ERR_NO) |
|---|
| 2081 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtCheckBer \r\n", g_feId, nRet); |
|---|
| 2082 | |
|---|
| 2083 | DHL_OS_Printf("FE_ID : %d, BER value : %f \r\n", g_feId, ber); |
|---|
| 2084 | |
|---|
| 2085 | } |
|---|
| 2086 | else |
|---|
| 2087 | { |
|---|
| 2088 | DHL_OS_Printf("FE_ID : %d, BER unlock!!! \r\n", g_feId); |
|---|
| 2089 | } |
|---|
| 2090 | |
|---|
| 2091 | return nRet; |
|---|
| 2092 | |
|---|
| 2093 | } |
|---|
| 2094 | |
|---|
| 2095 | |
|---|
| 2096 | /* |
|---|
| 2097 | Timing recovery ¸¦ À§ÇÑ ¼³Á¤. |
|---|
| 2098 | |
|---|
| 2099 | mode : 0 À̸é default mode, 1À̸é user defined mode |
|---|
| 2100 | |
|---|
| 2101 | trfcw |
|---|
| 2102 | 1. VSB Àϰæ¿ì : trfcw = (sampling rate / (symbol rate * 2)) * 2^24 |
|---|
| 2103 | 2. QAM Àϰæ¿ì : trfcw = (sampling rate / (symbol rate * 4)) * 2^24 |
|---|
| 2104 | |
|---|
| 2105 | */ |
|---|
| 2106 | LgdtReturn_t LG3305_timing_recovery(DATA08 id, int mode, DATA32 trfcw) |
|---|
| 2107 | { |
|---|
| 2108 | |
|---|
| 2109 | LgdtReturn_t nRet = LGDT_ERR_NO; |
|---|
| 2110 | DATA08 pData; |
|---|
| 2111 | DATA32 nTemp; |
|---|
| 2112 | |
|---|
| 2113 | CHECK_LG3305_id(id); |
|---|
| 2114 | |
|---|
| 2115 | g_feId = id; |
|---|
| 2116 | |
|---|
| 2117 | DHL_OS_Printf("FE_ID : %d, Timing recovery !!!\r\n", g_feId); |
|---|
| 2118 | |
|---|
| 2119 | if(mode) |
|---|
| 2120 | mode = 0x40; // User defined |
|---|
| 2121 | else |
|---|
| 2122 | mode = 0x00; // Not user defined |
|---|
| 2123 | |
|---|
| 2124 | nRet = LgdtCheckRegi(0x0200, &pData); |
|---|
| 2125 | if (nRet != LGDT_ERR_NO) |
|---|
| 2126 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtCheckRegi \r\n", g_feId, nRet); |
|---|
| 2127 | |
|---|
| 2128 | pData &= 0xBF; |
|---|
| 2129 | pData |= mode; |
|---|
| 2130 | |
|---|
| 2131 | nRet = LgdtAlterRegi(0x0200, pData); |
|---|
| 2132 | if(nRet != LGDT_ERR_NO) |
|---|
| 2133 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtAlterRegi \r\n", g_feId, nRet); |
|---|
| 2134 | |
|---|
| 2135 | if(mode == 0x40) // User defined |
|---|
| 2136 | { |
|---|
| 2137 | nTemp = trfcw & 0xFFFFFFFF; |
|---|
| 2138 | DHL_OS_Printf("FE_ID : %d, trfcw value : 0x%08x \r\n", g_feId, nTemp); |
|---|
| 2139 | |
|---|
| 2140 | pData = (nTemp >> 24) & 0xFF; |
|---|
| 2141 | |
|---|
| 2142 | nRet = LgdtAlterRegi(0x0202, pData); |
|---|
| 2143 | if(nRet != LGDT_ERR_NO) |
|---|
| 2144 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtAlterRegi \r\n", g_feId, nRet); |
|---|
| 2145 | |
|---|
| 2146 | pData = (nTemp >> 16) & 0xFF; |
|---|
| 2147 | |
|---|
| 2148 | nRet = LgdtAlterRegi(0x0203, pData); |
|---|
| 2149 | if(nRet != LGDT_ERR_NO) |
|---|
| 2150 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtAlterRegi \r\n", g_feId, nRet); |
|---|
| 2151 | |
|---|
| 2152 | pData = (nTemp >> 8) & 0xFF; |
|---|
| 2153 | |
|---|
| 2154 | nRet = LgdtAlterRegi(0x0204, pData); |
|---|
| 2155 | if(nRet != LGDT_ERR_NO) |
|---|
| 2156 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtAlterRegi \r\n", g_feId, nRet); |
|---|
| 2157 | |
|---|
| 2158 | pData = nTemp & 0xFF; |
|---|
| 2159 | |
|---|
| 2160 | nRet = LgdtAlterRegi(0x0205, pData); |
|---|
| 2161 | if(nRet != LGDT_ERR_NO) |
|---|
| 2162 | DHL_OS_Printf("FE_ID : %d, Error (%d)LgdtAlterRegi \r\n", g_feId, nRet); |
|---|
| 2163 | |
|---|
| 2164 | } |
|---|
| 2165 | |
|---|
| 2166 | return nRet; |
|---|
| 2167 | |
|---|
| 2168 | } |
|---|
| 2169 | |
|---|
| 2170 | void set_demod(DATA16 addr, DATA08 data) |
|---|
| 2171 | { |
|---|
| 2172 | LgdtAlterRegi(addr, data); |
|---|
| 2173 | DHL_OS_Printf("0x%x = 0x%x\n", addr, data); |
|---|
| 2174 | } |
|---|
| 2175 | |
|---|
| 2176 | void get_demod(DATA16 addr) |
|---|
| 2177 | { |
|---|
| 2178 | DATA08 data = 0xff; |
|---|
| 2179 | |
|---|
| 2180 | LgdtCheckRegi(addr, &data); |
|---|
| 2181 | DHL_OS_Printf("0x%x = 0x%x\n", addr, data); |
|---|
| 2182 | } |
|---|
| 2183 | |
|---|
| 2184 | |
|---|