| 1 | /**************************************************************************** |
|---|
| 2 | * Module: S5H1409 |
|---|
| 3 | * |
|---|
| 4 | * Description: Tuner Driver for DTF8640 Main Routines |
|---|
| 5 | * |
|---|
| 6 | * Notes: 20041019/hwatk |
|---|
| 7 | * |
|---|
| 8 | * TO DO |
|---|
| 9 | * |
|---|
| 10 | * ChannelChange() ¿¡ ´ëÇÑ ÀÎÀÚ¸¦ ´Ù½ÃÈ®ÀÎÇÏÀÚ. |
|---|
| 11 | * |
|---|
| 12 | ************************************************************************^^*/ |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | //#include "VDL.h" |
|---|
| 16 | //#include "utility.h" |
|---|
| 17 | //#include "HiDTV_RTC.h" |
|---|
| 18 | //#include "HiDTV_GPIO.h" |
|---|
| 19 | //#include "params.h" |
|---|
| 20 | //#include "comm.h" |
|---|
| 21 | //#include "client.h" |
|---|
| 22 | |
|---|
| 23 | #include "dsthalcommon.h" |
|---|
| 24 | |
|---|
| 25 | #include "S5H1411.h" |
|---|
| 26 | #include "S5H1411Core.h" |
|---|
| 27 | |
|---|
| 28 | extern DS_U32 gdhlExtDbgLvl; |
|---|
| 29 | |
|---|
| 30 | /*================================================================== |
|---|
| 31 | Configuration Section |
|---|
| 32 | |
|---|
| 33 | - USE_CODE_SWITCH : 2B / 2C Switch Code »ç¿ë ¿©ºÎ |
|---|
| 34 | - USE_2B : 2B / 2C »ç¿ë ¿©ºÎ |
|---|
| 35 | ==================================================================*/ |
|---|
| 36 | |
|---|
| 37 | #define USE_CODE_SWITCH 0 |
|---|
| 38 | |
|---|
| 39 | typedef struct tag_S5H2C_info { |
|---|
| 40 | OS_SEMAPHORE_ID Mutex; |
|---|
| 41 | DS_U32 OrenI2cAddr; |
|---|
| 42 | /* DS_U16 Tda9885Addr; */ |
|---|
| 43 | /* DS_U16 TunerAddr; TunerAddrÀº »ç¿ëµÇÁö ¾ÊÀ½. -- OREN DemodulatorÀÇ I2C¿¡ ¹°·ÁÀÖÀ½. */ |
|---|
| 44 | /* Current FAT channel information. */ |
|---|
| 45 | DS_U32 FATFreq; |
|---|
| 46 | TunerDemod CurFATDemod; |
|---|
| 47 | DS_U8 *pMicroCode; |
|---|
| 48 | DS_U16 microCodeLen; |
|---|
| 49 | DS_U32 bInitialized; |
|---|
| 50 | DS_U8 isNtsc; |
|---|
| 51 | } *P_S5H_INFO, S5H_INFO; |
|---|
| 52 | |
|---|
| 53 | S5H_INFO g_S5H_info; |
|---|
| 54 | P_S5H_INFO pS5H = &g_S5H_info; |
|---|
| 55 | |
|---|
| 56 | int S5H_SetFrequencyDTV( DS_U32 dMHz ); |
|---|
| 57 | |
|---|
| 58 | int S5H_GetVersion( DS_U32 *pVersion ) |
|---|
| 59 | { |
|---|
| 60 | DS_U32 version; |
|---|
| 61 | |
|---|
| 62 | version = 0x00000001; |
|---|
| 63 | |
|---|
| 64 | *pVersion = version; |
|---|
| 65 | |
|---|
| 66 | return 0; |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | int S5H_Initialize(void) |
|---|
| 70 | { |
|---|
| 71 | DS_BOOL retVal = 0; |
|---|
| 72 | static int sem_initialized = 0; |
|---|
| 73 | |
|---|
| 74 | if ( sem_initialized == 0 ) { |
|---|
| 75 | pS5H->Mutex = OS_CreateBinarySemaphore( "S5H_Sema4", 0, 1 ); |
|---|
| 76 | if ( pS5H->Mutex == (OS_SEMAPHORE_ID)0 ) { |
|---|
| 77 | DHL_DbgPrintf(gdhlExtDbgLvl,DHLDBG_EXT, "ERROR: OS_CreateMutexSemaphore\n"); |
|---|
| 78 | retVal = -1; |
|---|
| 79 | goto done; |
|---|
| 80 | } |
|---|
| 81 | pS5H->OrenI2cAddr = 0; |
|---|
| 82 | sem_initialized = 1; |
|---|
| 83 | } |
|---|
| 84 | |
|---|
| 85 | DHL_SYS_SetGPIO(GPIO_DEMOD_RESETN, 0); |
|---|
| 86 | OS_mDelay(200); |
|---|
| 87 | DHL_SYS_SetGPIO(GPIO_DEMOD_RESETN, 1); |
|---|
| 88 | OS_mDelay(200); |
|---|
| 89 | |
|---|
| 90 | retVal = S5H1411x_Initialize(); |
|---|
| 91 | if (retVal != OK) { |
|---|
| 92 | DHL_DbgPrintf(0,DHLDBG_EXT, "ERROR: Cannot Initialize S5H1409.Line : %d \n",__LINE__); |
|---|
| 93 | retVal = -1; |
|---|
| 94 | } |
|---|
| 95 | #ifndef SERIAL_TS |
|---|
| 96 | retVal = S5H1411x_TS_ParallelMode(); |
|---|
| 97 | #else |
|---|
| 98 | retVal = S5H1411x_TS_SerialMode(); |
|---|
| 99 | #endif |
|---|
| 100 | if (retVal != OK) { |
|---|
| 101 | DHL_DbgPrintf(0,DHLDBG_EXT, "ERROR: Cannot Initialize S5H1409.Line : %d \n",__LINE__); |
|---|
| 102 | retVal = -1; |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | done: |
|---|
| 106 | return retVal; |
|---|
| 107 | |
|---|
| 108 | } |
|---|
| 109 | |
|---|
| 110 | /**************************************************************************** |
|---|
| 111 | |
|---|
| 112 | S5H_Start() |
|---|
| 113 | |
|---|
| 114 | Summary : Start Oren demodulator. |
|---|
| 115 | Returns : 0 on success, others on failure. |
|---|
| 116 | |
|---|
| 117 | ************************************************************************^^*/ |
|---|
| 118 | int S5H_Start( TunerDemod Demod, int Ntsc, int Cable ) |
|---|
| 119 | { |
|---|
| 120 | int retVal = 0; |
|---|
| 121 | DS_U8 sdmRet; |
|---|
| 122 | DS_U32 semErr; |
|---|
| 123 | |
|---|
| 124 | /* Take Mutex. */ |
|---|
| 125 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 126 | if ( semErr != 0 ) |
|---|
| 127 | return -1; |
|---|
| 128 | |
|---|
| 129 | if (Ntsc) { |
|---|
| 130 | // |
|---|
| 131 | // ´Ü¼øÈ÷ Tuner¸¸ Æ©´×ÇÏÀÚ. |
|---|
| 132 | // |
|---|
| 133 | sdmRet = S5H1411x_SleepOn(); |
|---|
| 134 | if (sdmRet) { |
|---|
| 135 | printf("|%s| ERROR, LINE=%d\n", __FUNCTION__, __LINE__); |
|---|
| 136 | retVal = -1; |
|---|
| 137 | goto done; |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | #if NIMTN_TYPE==NIMTN_DTT7611 |
|---|
| 141 | retVal = Tuner_DTT7611SendFreq( pS5H->FATFreq, TUNERDTT7611_REF_DIVIDER_RATIO_62_5, TUNERDTT7611_AGC_WIDE_BAND_OFF, 2, TUNERDTT7611_CHARGE_PUMP_60, TUNERDTT7611_AGC_TIME_CONSTANT_2_SEC ); |
|---|
| 142 | if ( retVal != DTT7611_SUCCESS ) { |
|---|
| 143 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 144 | retVal = -1; |
|---|
| 145 | } |
|---|
| 146 | #elif NIMTN_TYPE==NIMTN_U7A06 |
|---|
| 147 | retVal = Tuner_U7A06_SendFreq( pS5H->FATFreq, Demod ); |
|---|
| 148 | if ( retVal < 0 ) { |
|---|
| 149 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 150 | retVal = -1; |
|---|
| 151 | } |
|---|
| 152 | #elif NIMTN_TYPE==NIMTN_DTVS205 |
|---|
| 153 | retVal = TunerDTVS205FH201ASendFreq( |
|---|
| 154 | pS5H->FATFreq, TUNERDTVS205FH201A_REF_DIVIDER_RATIO_62_5, |
|---|
| 155 | TUNERDTVS205FH201A_AGC_WIDE_BAND_OFF,0,TUNERDTVS205FH201A_CHARGE_PUMP_100, |
|---|
| 156 | TUNERDTVS205FH201A_AGC_TIME_CONSTANT_2_SEC ); |
|---|
| 157 | // retVal = Tuner_DTT7611SendFreq( pS5H->FATFreq, TUNERDTT7611_REF_DIVIDER_RATIO_62_5, TUNERDTT7611_AGC_WIDE_BAND_OFF, 2, TUNERDTT7611_CHARGE_PUMP_60, TUNERDTT7611_AGC_TIME_CONSTANT_2_SEC ); |
|---|
| 158 | if ( retVal != DTVS205FH201A_SUCCESS ) { |
|---|
| 159 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 160 | retVal = -1; |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | #elif NIMTN_TYPE==NIMTN_U7A26 |
|---|
| 164 | retVal = Tuner_U7A26_SendFreq( pS5H->FATFreq, Demod ); |
|---|
| 165 | if ( retVal < 0 ) { |
|---|
| 166 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 167 | retVal = -1; |
|---|
| 168 | } |
|---|
| 169 | #else |
|---|
| 170 | #error NIMTN_TYPE shall be defined first. |
|---|
| 171 | #endif |
|---|
| 172 | sdmRet = S5H1411x_RepeaterDisable(); |
|---|
| 173 | if (sdmRet) { |
|---|
| 174 | printf("|%s| ERROR, LINE=%d\n", __FUNCTION__, __LINE__); |
|---|
| 175 | retVal = -1; |
|---|
| 176 | goto done; |
|---|
| 177 | } |
|---|
| 178 | sdmRet = S5H1411x_SoftReset(); |
|---|
| 179 | if (sdmRet) { |
|---|
| 180 | printf("|%s| ERROR, LINE=%d\n", __FUNCTION__, __LINE__); |
|---|
| 181 | retVal = -1; |
|---|
| 182 | goto done; |
|---|
| 183 | } |
|---|
| 184 | // Sdm_1409xSetQamInterleave(FALSE); |
|---|
| 185 | } else { |
|---|
| 186 | sdmRet = S5H1411x_SleepOff(); |
|---|
| 187 | if (sdmRet) { |
|---|
| 188 | printf("|%s| ERROR, LINE=%d\n", __FUNCTION__, __LINE__); |
|---|
| 189 | retVal = -1; |
|---|
| 190 | goto done; |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | if ( Demod == DEMOD_8VSB ) { |
|---|
| 194 | // sdmRet = Sdm_1409SetScanMode(TRUE); |
|---|
| 195 | if (sdmRet) { |
|---|
| 196 | printf("|%s| ERROR, LINE=%d\n", __FUNCTION__, __LINE__); |
|---|
| 197 | retVal = -1; |
|---|
| 198 | goto done; |
|---|
| 199 | } |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | #if NIMTN_TYPE==NIMTN_DTT7611 |
|---|
| 203 | retVal = Tuner_DTT7611SendFreq( pS5H->FATFreq, TUNERDTT7611_REF_DIVIDER_RATIO_62_5, TUNERDTT7611_AGC_93, 1, TUNERDTT7611_CHARGE_PUMP_60, TUNERDTT7611_AGC_TIME_CONSTANT_2_SEC ); |
|---|
| 204 | if ( retVal != DTT7611_SUCCESS ) { |
|---|
| 205 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 206 | retVal = -1; |
|---|
| 207 | goto done; |
|---|
| 208 | } |
|---|
| 209 | #elif NIMTN_TYPE==NIMTN_U7A06 |
|---|
| 210 | retVal = Tuner_U7A06_SendFreq( pS5H->FATFreq, Demod ); |
|---|
| 211 | if ( retVal < 0 ) { |
|---|
| 212 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 213 | retVal = -1; |
|---|
| 214 | goto done; |
|---|
| 215 | } |
|---|
| 216 | #elif NIMTN_TYPE==NIMTN_DTVS205 |
|---|
| 217 | retVal = TunerDTVS205FH201ASendFreq( |
|---|
| 218 | pS5H->FATFreq, TUNERDTVS205FH201A_REF_DIVIDER_RATIO_62_5, |
|---|
| 219 | TUNERDTVS205FH201A_AGC_WIDE_BAND_OFF,0,TUNERDTVS205FH201A_CHARGE_PUMP_100, |
|---|
| 220 | TUNERDTVS205FH201A_AGC_TIME_CONSTANT_2_SEC ); |
|---|
| 221 | // retVal = Tuner_DTT7611SendFreq( pS5H->FATFreq, TUNERDTT7611_REF_DIVIDER_RATIO_62_5, TUNERDTT7611_AGC_WIDE_BAND_OFF, 2, TUNERDTT7611_CHARGE_PUMP_60, TUNERDTT7611_AGC_TIME_CONSTANT_2_SEC ); |
|---|
| 222 | if ( retVal != DTVS205FH201A_SUCCESS ) { |
|---|
| 223 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 224 | retVal = -1; |
|---|
| 225 | goto done; |
|---|
| 226 | } |
|---|
| 227 | #elif NIMTN_TYPE==NIMTN_U7A26 |
|---|
| 228 | retVal = Tuner_U7A26_SendFreq( pS5H->FATFreq, Demod ); |
|---|
| 229 | if ( retVal < 0 ) { |
|---|
| 230 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 231 | retVal = -1; |
|---|
| 232 | goto done; |
|---|
| 233 | } |
|---|
| 234 | #else |
|---|
| 235 | #error NIMTN_TYPE shall be defined first. |
|---|
| 236 | #endif |
|---|
| 237 | |
|---|
| 238 | switch(Demod) { |
|---|
| 239 | case DEMOD_8VSB: sdmRet = S5H1411x_VsbMode(); break; |
|---|
| 240 | case DEMOD_QAM: sdmRet = S5H1411x_QamMode(); break; |
|---|
| 241 | case DEMOD_64QAM: sdmRet = S5H1411x_64QamMode(); break; |
|---|
| 242 | case DEMOD_256QAM: sdmRet = S5H1411x_256QamMode(); break; |
|---|
| 243 | case DEMOD_OFF: break; |
|---|
| 244 | case DEMOD_ISDBT: |
|---|
| 245 | case DEMOD_ISDBT_MANUAL: |
|---|
| 246 | default: |
|---|
| 247 | printf("|%s| ERROR, LINE=%d\n", __FUNCTION__, __LINE__); |
|---|
| 248 | goto done; |
|---|
| 249 | } |
|---|
| 250 | if (sdmRet) { |
|---|
| 251 | printf("|%s| ERROR, LINE=%d\n", __FUNCTION__, __LINE__); |
|---|
| 252 | goto done; |
|---|
| 253 | } |
|---|
| 254 | |
|---|
| 255 | if ( Demod == DEMOD_8VSB ) { |
|---|
| 256 | // sdmRet = Sdm_1409SetScanMode(FALSE); |
|---|
| 257 | if (sdmRet) { |
|---|
| 258 | printf("|%s| ERROR, LINE=%d\n", __FUNCTION__, __LINE__); |
|---|
| 259 | retVal = -1; |
|---|
| 260 | goto done; |
|---|
| 261 | } |
|---|
| 262 | } |
|---|
| 263 | } |
|---|
| 264 | |
|---|
| 265 | pS5H->CurFATDemod = Demod; |
|---|
| 266 | |
|---|
| 267 | DHL_DbgPrintf(gdhlExtDbgLvl,DHLDBG_EXT,"dMHz = %ld Mode=%s(%d)\n", pS5H->FATFreq, |
|---|
| 268 | Demod == DEMOD_8VSB ? "8VSB" : |
|---|
| 269 | Demod == DEMOD_QAM ? "QAM" : |
|---|
| 270 | Demod == DEMOD_64QAM ? "64QAM" : |
|---|
| 271 | Demod == DEMOD_256QAM ? "256QAM" : |
|---|
| 272 | Demod == DEMOD_NTSC ? "NTSC" : |
|---|
| 273 | Demod == DEMOD_ISDBT ? "ISDB-T" :"Unknown", |
|---|
| 274 | Demod); |
|---|
| 275 | |
|---|
| 276 | done: |
|---|
| 277 | /* Give Mutex. */ |
|---|
| 278 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 279 | if ( semErr != 0 ) |
|---|
| 280 | retVal = -1; |
|---|
| 281 | |
|---|
| 282 | if (!retVal) |
|---|
| 283 | DHL_DbgPrintf(gdhlExtDbgLvl,DHLDBG_EXT,"success.\n"); |
|---|
| 284 | else |
|---|
| 285 | DHL_DbgPrintf(gdhlExtDbgLvl,DHLDBG_EXT,"failure.\n"); |
|---|
| 286 | |
|---|
| 287 | return retVal; |
|---|
| 288 | } |
|---|
| 289 | |
|---|
| 290 | /**************************************************************************** |
|---|
| 291 | |
|---|
| 292 | S5H_Stop() |
|---|
| 293 | |
|---|
| 294 | Summary : Stop the Oren demodulator. |
|---|
| 295 | Returns : 0 on success, others on failure. |
|---|
| 296 | |
|---|
| 297 | ************************************************************************^^*/ |
|---|
| 298 | int S5H_Stop(void) |
|---|
| 299 | { |
|---|
| 300 | int retVal = 0; |
|---|
| 301 | DS_U32 semErr; |
|---|
| 302 | |
|---|
| 303 | /* Take Mutex. */ |
|---|
| 304 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 305 | if ( semErr != 0 ) |
|---|
| 306 | return -1; |
|---|
| 307 | |
|---|
| 308 | /* DO NOTHING. */ |
|---|
| 309 | |
|---|
| 310 | /* Give Mutex. */ |
|---|
| 311 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 312 | if ( semErr != 0 ) |
|---|
| 313 | retVal = -1; |
|---|
| 314 | |
|---|
| 315 | return retVal; |
|---|
| 316 | } |
|---|
| 317 | |
|---|
| 318 | |
|---|
| 319 | /**************************************************************************** |
|---|
| 320 | |
|---|
| 321 | S5H_Close() |
|---|
| 322 | |
|---|
| 323 | Summary : Close the Oren demodulator. |
|---|
| 324 | Returns : 0 on success, others on failure. |
|---|
| 325 | |
|---|
| 326 | ************************************************************************^^*/ |
|---|
| 327 | int S5H_Close(void) |
|---|
| 328 | { |
|---|
| 329 | int retVal = 0; |
|---|
| 330 | DS_U32 semErr; |
|---|
| 331 | |
|---|
| 332 | /* Take Mutex. */ |
|---|
| 333 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 334 | if ( semErr != 0 ) |
|---|
| 335 | return -1; |
|---|
| 336 | |
|---|
| 337 | |
|---|
| 338 | /* DO NOTHING */ |
|---|
| 339 | goto done; |
|---|
| 340 | |
|---|
| 341 | done: |
|---|
| 342 | /* Give Mutex. */ |
|---|
| 343 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 344 | if ( semErr != 0 ) |
|---|
| 345 | retVal = -1; |
|---|
| 346 | |
|---|
| 347 | return retVal; |
|---|
| 348 | } |
|---|
| 349 | |
|---|
| 350 | /**************************************************************************** |
|---|
| 351 | |
|---|
| 352 | S5H_Reset() |
|---|
| 353 | |
|---|
| 354 | Summary : Reset the Oren demodulator. |
|---|
| 355 | Returns : 0 on success, others on failure. |
|---|
| 356 | |
|---|
| 357 | ************************************************************************^^*/ |
|---|
| 358 | int S5H_Reset(void) |
|---|
| 359 | { |
|---|
| 360 | int retVal = 0; |
|---|
| 361 | DS_U32 semErr; |
|---|
| 362 | |
|---|
| 363 | /* Take Mutex. */ |
|---|
| 364 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 365 | if ( semErr != 0 ) |
|---|
| 366 | return -1; |
|---|
| 367 | |
|---|
| 368 | /* Give Mutex. */ |
|---|
| 369 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 370 | if ( semErr != 0 ) |
|---|
| 371 | retVal = -1; |
|---|
| 372 | |
|---|
| 373 | return retVal; |
|---|
| 374 | } |
|---|
| 375 | |
|---|
| 376 | /**************************************************************************** |
|---|
| 377 | |
|---|
| 378 | S5H_SetFrequency() |
|---|
| 379 | |
|---|
| 380 | Summary : Set Frequency |
|---|
| 381 | Returns : 0 on success, others on failure. |
|---|
| 382 | |
|---|
| 383 | ************************************************************************^^*/ |
|---|
| 384 | int S5H_SetFrequencyNTSC( DS_U32 dMHz ) |
|---|
| 385 | { |
|---|
| 386 | int retVal = 0; |
|---|
| 387 | DS_U32 semErr; |
|---|
| 388 | |
|---|
| 389 | /* Take Mutex. */ |
|---|
| 390 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 391 | if ( semErr != 0 ) |
|---|
| 392 | return -1; |
|---|
| 393 | |
|---|
| 394 | pS5H->FATFreq = dMHz; |
|---|
| 395 | S5H1411x_SleepOn(); |
|---|
| 396 | |
|---|
| 397 | #if NIMTN_TYPE==NIMTN_DTT7611 |
|---|
| 398 | retVal = Tuner_DTT7611SendFreq( dMHz, TUNERDTT7611_REF_DIVIDER_RATIO_62_5, TUNERDTT7611_AGC_WIDE_BAND_OFF, 2, TUNERDTT7611_CHARGE_PUMP_60, TUNERDTT7611_AGC_TIME_CONSTANT_2_SEC ); |
|---|
| 399 | if ( retVal != DTT7611_SUCCESS ) { |
|---|
| 400 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 401 | retVal = -1; |
|---|
| 402 | } |
|---|
| 403 | #elif NIMTN_TYPE==NIMTN_U7A06 |
|---|
| 404 | retVal = Tuner_U7A06_SendFreq( dMHz, DEMOD_NTSC ); |
|---|
| 405 | if ( retVal < 0 ) { |
|---|
| 406 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 407 | retVal = -1; |
|---|
| 408 | } |
|---|
| 409 | #elif NIMTN_TYPE==NIMTN_DTVS205 |
|---|
| 410 | retVal = TunerDTVS205FH201ASendFreq( |
|---|
| 411 | dMHz, TUNERDTVS205FH201A_REF_DIVIDER_RATIO_62_5, |
|---|
| 412 | TUNERDTVS205FH201A_AGC_WIDE_BAND_OFF,0,TUNERDTVS205FH201A_CHARGE_PUMP_100, |
|---|
| 413 | TUNERDTVS205FH201A_AGC_TIME_CONSTANT_2_SEC ); |
|---|
| 414 | // retVal = Tuner_DTT7611SendFreq( pS5H->FATFreq, TUNERDTT7611_REF_DIVIDER_RATIO_62_5, TUNERDTT7611_AGC_WIDE_BAND_OFF, 2, TUNERDTT7611_CHARGE_PUMP_60, TUNERDTT7611_AGC_TIME_CONSTANT_2_SEC ); |
|---|
| 415 | if ( retVal != DTVS205FH201A_SUCCESS ) { |
|---|
| 416 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 417 | retVal = -1; |
|---|
| 418 | } |
|---|
| 419 | #elif NIMTN_TYPE==NIMTN_U7A26 |
|---|
| 420 | retVal = Tuner_U7A26_SendFreq( dMHz, DEMOD_NTSC ); |
|---|
| 421 | if ( retVal < 0 ) { |
|---|
| 422 | DHL_DbgPrintf(0,DHLDBG_EXT,"ERROR: line=%d, Result = %d\n", __LINE__, retVal ); |
|---|
| 423 | retVal = -1; |
|---|
| 424 | } |
|---|
| 425 | #else |
|---|
| 426 | |
|---|
| 427 | #error NIMTN_TYPE shall be defined first. |
|---|
| 428 | #endif |
|---|
| 429 | |
|---|
| 430 | S5H1411x_RepeaterDisable(); |
|---|
| 431 | |
|---|
| 432 | /* Give Mutex. */ |
|---|
| 433 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 434 | if ( semErr != 0 ) |
|---|
| 435 | retVal = -1; |
|---|
| 436 | |
|---|
| 437 | return retVal; |
|---|
| 438 | } |
|---|
| 439 | |
|---|
| 440 | // |
|---|
| 441 | // Tuner Á¦¾îÇÏÁö ¾Ê°í, ³»ºÎÀûÀ¸·Î TuningÇÒ Á֯ļö¸¦ ¸í½ÃÇÏ´Â ÇÔ¼ö. |
|---|
| 442 | // ¼³Á¤µÈ Á֯ļö´Â ´ÙÀ½ S5H_Start() È£Ã⠽ÿ¡ Àû¿ëµÊ. |
|---|
| 443 | // |
|---|
| 444 | int S5H_SetFrequency( DS_U32 dMHz ) |
|---|
| 445 | { |
|---|
| 446 | int retVal = 0; |
|---|
| 447 | DS_U32 semErr; |
|---|
| 448 | DS_U32 freq; |
|---|
| 449 | |
|---|
| 450 | /* Take Mutex. */ |
|---|
| 451 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 452 | if ( semErr != 0 ) |
|---|
| 453 | return -1; |
|---|
| 454 | |
|---|
| 455 | freq = (DS_U32)dMHz; |
|---|
| 456 | pS5H->FATFreq = freq; |
|---|
| 457 | DHL_DbgPrintf(gdhlExtDbgLvl,DHLDBG_EXT,"dMHz = %d\n", (int)freq ); |
|---|
| 458 | |
|---|
| 459 | /* Give Mutex. */ |
|---|
| 460 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 461 | if ( semErr != 0 ) |
|---|
| 462 | retVal = -1; |
|---|
| 463 | |
|---|
| 464 | return retVal; |
|---|
| 465 | } |
|---|
| 466 | |
|---|
| 467 | DS_U32 S5H_GetFrequency(void) |
|---|
| 468 | { |
|---|
| 469 | return pS5H->FATFreq; |
|---|
| 470 | } |
|---|
| 471 | |
|---|
| 472 | /**************************************************************************** |
|---|
| 473 | |
|---|
| 474 | S5H_GetLockStatus() |
|---|
| 475 | |
|---|
| 476 | Summary : Set Frequency |
|---|
| 477 | Returns : 0 on success, others on failure. |
|---|
| 478 | |
|---|
| 479 | ************************************************************************^^*/ |
|---|
| 480 | int S5H_GetLockStatus( int *pLockStatus ) |
|---|
| 481 | { |
|---|
| 482 | int retVal = 0; |
|---|
| 483 | DS_U32 semErr; |
|---|
| 484 | DS_U16 lock; |
|---|
| 485 | |
|---|
| 486 | /* Take Mutex. */ |
|---|
| 487 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 488 | if ( semErr != 0 ) |
|---|
| 489 | return -1; |
|---|
| 490 | |
|---|
| 491 | if (pS5H->CurFATDemod != DEMOD_NTSC) { |
|---|
| 492 | lock = S5H1411x_Vsb_QAM_Master_Lock(); |
|---|
| 493 | *pLockStatus = lock ? 1 : 0; |
|---|
| 494 | |
|---|
| 495 | switch(pS5H->CurFATDemod) { |
|---|
| 496 | case DEMOD_8VSB: lock = S5H1411x_Vsb_Sync_Lock(); break; |
|---|
| 497 | case DEMOD_QAM: |
|---|
| 498 | case DEMOD_256QAM: |
|---|
| 499 | case DEMOD_64QAM: lock = S5H1411x_QAM_Eq_Lock(); break; |
|---|
| 500 | case DEMOD_OFF: |
|---|
| 501 | case DEMOD_ISDBT: |
|---|
| 502 | case DEMOD_ISDBT_MANUAL: |
|---|
| 503 | break; |
|---|
| 504 | |
|---|
| 505 | default: |
|---|
| 506 | printf("|%s| ERROR: Invalid demodulation mode=%d\n", __FUNCTION__, pS5H->CurFATDemod); |
|---|
| 507 | } |
|---|
| 508 | } else { |
|---|
| 509 | /* shall be implemented. */ |
|---|
| 510 | *pLockStatus = 0; |
|---|
| 511 | } |
|---|
| 512 | |
|---|
| 513 | /* Give Mutex. */ |
|---|
| 514 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 515 | if ( semErr != 0 ) |
|---|
| 516 | retVal = -1; |
|---|
| 517 | |
|---|
| 518 | return retVal; |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | int S5H_GetLockStatusNTSC( int *pLockStatus ) |
|---|
| 522 | { |
|---|
| 523 | int retVal = 0; |
|---|
| 524 | DS_U32 semErr; |
|---|
| 525 | |
|---|
| 526 | /* Take Mutex. */ |
|---|
| 527 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 528 | if ( semErr != 0 ) |
|---|
| 529 | return -1; |
|---|
| 530 | |
|---|
| 531 | /* Give Mutex. */ |
|---|
| 532 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 533 | if ( semErr != 0 ) |
|---|
| 534 | retVal = -1; |
|---|
| 535 | |
|---|
| 536 | return retVal; |
|---|
| 537 | } |
|---|
| 538 | |
|---|
| 539 | /**************************************************************************** |
|---|
| 540 | |
|---|
| 541 | S5H_GetSignalStrength() |
|---|
| 542 | |
|---|
| 543 | Summary : Get signal strength from demodulator. |
|---|
| 544 | Returns : 0 on success, others on failure. |
|---|
| 545 | |
|---|
| 546 | ************************************************************************^^*/ |
|---|
| 547 | int S5H_GetSignalStrength( int *pSQI ) |
|---|
| 548 | { |
|---|
| 549 | #if 0 |
|---|
| 550 | int retVal = 0; |
|---|
| 551 | #endif |
|---|
| 552 | DS_U32 semErr; |
|---|
| 553 | float SNR = 0; |
|---|
| 554 | int maxSNR = 30; |
|---|
| 555 | TunerDemod mode; |
|---|
| 556 | |
|---|
| 557 | if ( pS5H->CurFATDemod == DEMOD_NTSC ) { |
|---|
| 558 | *pSQI = 0; |
|---|
| 559 | return 0; |
|---|
| 560 | } |
|---|
| 561 | |
|---|
| 562 | /* Take Mutex. */ |
|---|
| 563 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 564 | if ( semErr != 0 ) |
|---|
| 565 | return -1; |
|---|
| 566 | |
|---|
| 567 | if (pS5H->CurFATDemod == DEMOD_QAM){ |
|---|
| 568 | if(S5H1411x_Get_QAMMode()){ |
|---|
| 569 | mode = DEMOD_256QAM; |
|---|
| 570 | }else{ |
|---|
| 571 | mode = DEMOD_64QAM; |
|---|
| 572 | } |
|---|
| 573 | |
|---|
| 574 | }else{ |
|---|
| 575 | mode = pS5H->CurFATDemod; |
|---|
| 576 | } |
|---|
| 577 | switch(mode) { |
|---|
| 578 | case DEMOD_8VSB: |
|---|
| 579 | { |
|---|
| 580 | maxSNR=30; |
|---|
| 581 | SNR = S5H1411x_VsbAGCResultCheck(); |
|---|
| 582 | break; |
|---|
| 583 | } |
|---|
| 584 | |
|---|
| 585 | case DEMOD_64QAM: |
|---|
| 586 | { |
|---|
| 587 | SNR = S5H1411x_QamAGCResultCheck(); |
|---|
| 588 | maxSNR=30; |
|---|
| 589 | break; |
|---|
| 590 | } |
|---|
| 591 | |
|---|
| 592 | case DEMOD_256QAM: |
|---|
| 593 | { |
|---|
| 594 | SNR = S5H1411x_QamAGCResultCheck(); |
|---|
| 595 | |
|---|
| 596 | break; |
|---|
| 597 | } |
|---|
| 598 | |
|---|
| 599 | case DEMOD_QAM: |
|---|
| 600 | { |
|---|
| 601 | SNR = S5H1411x_QamAGCResultCheck(); |
|---|
| 602 | maxSNR=30; |
|---|
| 603 | break; |
|---|
| 604 | } |
|---|
| 605 | |
|---|
| 606 | default: |
|---|
| 607 | goto done; |
|---|
| 608 | } |
|---|
| 609 | |
|---|
| 610 | done: |
|---|
| 611 | /* Give Mutex. */ |
|---|
| 612 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 613 | #if 0 |
|---|
| 614 | if ( semErr != 0 ) |
|---|
| 615 | retVal = -1; |
|---|
| 616 | SNR = (SNR / 0xffff)*100; |
|---|
| 617 | SNR = 100 - SNR; |
|---|
| 618 | #endif |
|---|
| 619 | *pSQI = SNR; |
|---|
| 620 | return 0; |
|---|
| 621 | } |
|---|
| 622 | |
|---|
| 623 | |
|---|
| 624 | int S5H_GetSignalPower( int *pPower ) |
|---|
| 625 | { |
|---|
| 626 | int retVal = 0; |
|---|
| 627 | DS_U32 semErr; |
|---|
| 628 | |
|---|
| 629 | /* Take Mutex. */ |
|---|
| 630 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 631 | if ( semErr != 0 ) |
|---|
| 632 | return -1; |
|---|
| 633 | |
|---|
| 634 | /* Give Mutex. */ |
|---|
| 635 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 636 | if ( semErr != 0 ) |
|---|
| 637 | retVal = -1; |
|---|
| 638 | |
|---|
| 639 | return retVal; |
|---|
| 640 | } |
|---|
| 641 | |
|---|
| 642 | /**************************************************************************** |
|---|
| 643 | |
|---|
| 644 | S5H_GetSNR |
|---|
| 645 | |
|---|
| 646 | Summary : Get signal strength from demodulator. |
|---|
| 647 | Returns : 0 on success, others on failure. |
|---|
| 648 | |
|---|
| 649 | ************************************************************************^^*/ |
|---|
| 650 | int S5H_GetSNR( float *pSNR ) |
|---|
| 651 | { |
|---|
| 652 | int retVal = 0; |
|---|
| 653 | DS_U32 semErr; |
|---|
| 654 | double SNR = 0.0; |
|---|
| 655 | |
|---|
| 656 | /* Take Mutex. */ |
|---|
| 657 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 658 | if ( semErr != 0 ) |
|---|
| 659 | return -1; |
|---|
| 660 | |
|---|
| 661 | if (pS5H->CurFATDemod == DEMOD_NTSC) { |
|---|
| 662 | *pSNR = 6; |
|---|
| 663 | } else { |
|---|
| 664 | switch(pS5H->CurFATDemod) { |
|---|
| 665 | case DEMOD_8VSB: SNR = S5H1411x_VsbSnrResultCheck(); break; |
|---|
| 666 | case DEMOD_QAM: |
|---|
| 667 | case DEMOD_256QAM: |
|---|
| 668 | case DEMOD_64QAM: SNR = S5H1411x_QamSnrResultCheck(); break; |
|---|
| 669 | default: |
|---|
| 670 | printf("|%s| ERROR: Invalid demodulation mode=%d\n", __FUNCTION__, pS5H->CurFATDemod); |
|---|
| 671 | } |
|---|
| 672 | } |
|---|
| 673 | |
|---|
| 674 | if ( SNR == 77 ) |
|---|
| 675 | *pSNR = 0.0; |
|---|
| 676 | else |
|---|
| 677 | *pSNR = SNR; |
|---|
| 678 | |
|---|
| 679 | /* Give Mutex. */ |
|---|
| 680 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 681 | if ( semErr != 0 ) |
|---|
| 682 | retVal = -1; |
|---|
| 683 | |
|---|
| 684 | return retVal; |
|---|
| 685 | } |
|---|
| 686 | |
|---|
| 687 | |
|---|
| 688 | /**************************************************************************** |
|---|
| 689 | |
|---|
| 690 | S5H_GetModFormat |
|---|
| 691 | |
|---|
| 692 | Summary : Get signal strength from demodulator. |
|---|
| 693 | Returns : 0 on success, others on failure. |
|---|
| 694 | |
|---|
| 695 | ************************************************************************^^*/ |
|---|
| 696 | int S5H_GetModFormat( TunerDemod *mode ) |
|---|
| 697 | { |
|---|
| 698 | int retVal = 0; |
|---|
| 699 | DS_U32 semErr; |
|---|
| 700 | //TunerDemod qam_mode; |
|---|
| 701 | |
|---|
| 702 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 703 | if ( semErr != 0 ) |
|---|
| 704 | return -1; |
|---|
| 705 | |
|---|
| 706 | if (pS5H->CurFATDemod == DEMOD_QAM) { |
|---|
| 707 | if(S5H1411x_Get_QAMMode()){ |
|---|
| 708 | *mode = DEMOD_256QAM; |
|---|
| 709 | }else{ |
|---|
| 710 | *mode = DEMOD_64QAM; |
|---|
| 711 | } |
|---|
| 712 | //qam_mode = S5H1411x_Get_QAMMode(); |
|---|
| 713 | //*mode = qam_mode; |
|---|
| 714 | } else |
|---|
| 715 | *mode = pS5H->CurFATDemod; |
|---|
| 716 | |
|---|
| 717 | /* Give Mutex. */ |
|---|
| 718 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 719 | if ( semErr != 0 ) |
|---|
| 720 | retVal = -1; |
|---|
| 721 | |
|---|
| 722 | return retVal; |
|---|
| 723 | } |
|---|
| 724 | |
|---|
| 725 | |
|---|
| 726 | /**************************************************************************** |
|---|
| 727 | |
|---|
| 728 | S5H_GetErrCount |
|---|
| 729 | |
|---|
| 730 | Summary : Get signal strength from demodulator. |
|---|
| 731 | Returns : 0 on success, others on failure. |
|---|
| 732 | |
|---|
| 733 | ************************************************************************^^*/ |
|---|
| 734 | int S5H_GetErrCount( DS_U32 *pRSErrCnt ) |
|---|
| 735 | { |
|---|
| 736 | int retVal = 0; |
|---|
| 737 | DS_U32 semErr; |
|---|
| 738 | |
|---|
| 739 | /* Take Mutex. */ |
|---|
| 740 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 741 | if ( semErr != 0 ) |
|---|
| 742 | return -1; |
|---|
| 743 | |
|---|
| 744 | // *pRSErrCnt = Sdm_1409xGetRSErrCnt(); |
|---|
| 745 | |
|---|
| 746 | /* Give Mutex. */ |
|---|
| 747 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 748 | if ( semErr != 0 ) |
|---|
| 749 | retVal = -1; |
|---|
| 750 | |
|---|
| 751 | return retVal; |
|---|
| 752 | } |
|---|
| 753 | |
|---|
| 754 | |
|---|
| 755 | /**************************************************************************** |
|---|
| 756 | |
|---|
| 757 | S5H_GetTDA9885Reg |
|---|
| 758 | |
|---|
| 759 | Summary : |
|---|
| 760 | Returns : 0 on success, others on failure. |
|---|
| 761 | |
|---|
| 762 | ************************************************************************^^*/ |
|---|
| 763 | int S5H_GetTDA9885Reg( DS_U8 *pStatus ) |
|---|
| 764 | { |
|---|
| 765 | int retVal = 0; |
|---|
| 766 | DS_U32 semErr; |
|---|
| 767 | #if ((NIMTN_TYPE==NIMTN_DTT7611) || (NIMTN_TYPE==NIMTN_U7A06) || (NIMTN_TYPE == NIMTN_U7A26)) |
|---|
| 768 | DS_U8 data; |
|---|
| 769 | #endif |
|---|
| 770 | /* Take Mutex. */ |
|---|
| 771 | semErr = OS_TakeSemaphore( pS5H->Mutex ); |
|---|
| 772 | if ( semErr != 0 ) |
|---|
| 773 | return -1; |
|---|
| 774 | |
|---|
| 775 | #if NIMTN_TYPE==NIMTN_DTT7611 |
|---|
| 776 | data = Tuner_GetTDA9885(); |
|---|
| 777 | *pStatus = data; |
|---|
| 778 | #elif NIMTN_TYPE==NIMTN_U7A06 |
|---|
| 779 | data = Tuner_U7A06GetADC(); |
|---|
| 780 | *pStatus = data; |
|---|
| 781 | #elif NIMTN_TYPE==NIMTN_U7A26 |
|---|
| 782 | data = Tuner_U7A26GetADC(); |
|---|
| 783 | *pStatus = data; |
|---|
| 784 | #endif |
|---|
| 785 | /* Give Mutex. */ |
|---|
| 786 | semErr = OS_GiveSemaphore( pS5H->Mutex ); |
|---|
| 787 | if ( semErr != 0 ) |
|---|
| 788 | retVal = -1; |
|---|
| 789 | |
|---|
| 790 | return retVal; |
|---|
| 791 | } |
|---|
| 792 | |
|---|
| 793 | // |
|---|
| 794 | // Notes: Standard ÁöÁ¤Çϸé, ´ÙÀ½ Æ©´× ¶§¿¡ Àû¿ëµÊ. |
|---|
| 795 | // |
|---|
| 796 | int S5H_SetAudioStandard( DS_U32 AudioStandard) |
|---|
| 797 | { |
|---|
| 798 | int err = 0; |
|---|
| 799 | |
|---|
| 800 | return err; |
|---|
| 801 | } |
|---|
| 802 | |
|---|
| 803 | int S5H_SetAudioMode( DS_U32 AudioMode ) |
|---|
| 804 | { |
|---|
| 805 | int err = 0; |
|---|
| 806 | |
|---|
| 807 | return err; |
|---|
| 808 | } |
|---|
| 809 | |
|---|
| 810 | int S5H_GetAudioMode( DS_U32 *pAudioMode ) |
|---|
| 811 | { |
|---|
| 812 | int err = 0; |
|---|
| 813 | |
|---|
| 814 | return err; |
|---|
| 815 | } |
|---|
| 816 | |
|---|
| 817 | int S5H_GetAudioStandard( DS_U32 *pAudioStandard ) |
|---|
| 818 | { |
|---|
| 819 | return 0; |
|---|
| 820 | } |
|---|