| 1 | /* |
|---|
| 2 | NTSC FullSearch Test Code |
|---|
| 3 | |
|---|
| 4 | ARZHNA |
|---|
| 5 | |
|---|
| 6 | */ |
|---|
| 7 | #include "DHL_OSAL.h" |
|---|
| 8 | #include "DHL_FE.h" |
|---|
| 9 | #include "DHL_DBG.h" |
|---|
| 10 | #include "DMW_Status.h" |
|---|
| 11 | |
|---|
| 12 | /* ¸ðµÎ KHz ´ÜÀ§ */ |
|---|
| 13 | #define SEARCH_STEP_FREQ 831 |
|---|
| 14 | #define SHORT_SEARCH_HALF_BOUND SEARCH_STEP_FREQ |
|---|
| 15 | #define SEARCH_FREQ_POSITIVE_BOUNDARY 844 |
|---|
| 16 | #define SEARCH_FREQ_NEGATIVE_BOUNDARY -831 |
|---|
| 17 | |
|---|
| 18 | static STATUS dmw_search_ntsc_get_deviation(tDHL_TunerID id, UINT32 freqKHz, INT32* freq) |
|---|
| 19 | { |
|---|
| 20 | DHL_RESULT dhl_result; |
|---|
| 21 | |
|---|
| 22 | dhl_result = DHL_FE_Start(id, freqKHz, eDHL_DEMOD_NTSC, NULL); |
|---|
| 23 | if(dhl_result) |
|---|
| 24 | return statusError; |
|---|
| 25 | |
|---|
| 26 | DHL_OS_Delay(10); |
|---|
| 27 | |
|---|
| 28 | dhl_result = DHL_FE_GetSignalStatus(id, eDHL_SIGNAL_NTSC_FREQ_DEVIATION, (UINT32*)freq); |
|---|
| 29 | if(dhl_result) |
|---|
| 30 | return statusError; |
|---|
| 31 | return statusOK; |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | /* ¸ðµç freq´Â KHz ´ÜÀ§·Î ÀÔ·ÂÇÑ´Ù */ |
|---|
| 35 | static STATUS dmw_search_ntsc_one_channel(tDHL_TunerID id, UINT32 start_freq, UINT32 end_freq, UINT32 step_freq, UINT32 *tune_freq) |
|---|
| 36 | { |
|---|
| 37 | STATUS result; |
|---|
| 38 | UINT32 freqKHz; |
|---|
| 39 | INT32 freq; |
|---|
| 40 | |
|---|
| 41 | /* ¿ì¼± Center Frequency·Î ãÀ½. */ |
|---|
| 42 | freqKHz = (start_freq+end_freq)/2; |
|---|
| 43 | |
|---|
| 44 | result = dmw_search_ntsc_get_deviation(id, freqKHz, &freq); |
|---|
| 45 | if(result) |
|---|
| 46 | return result; |
|---|
| 47 | |
|---|
| 48 | if(freq < SEARCH_FREQ_POSITIVE_BOUNDARY && freq > SEARCH_FREQ_NEGATIVE_BOUNDARY){ |
|---|
| 49 | *tune_freq = freqKHz + freq; |
|---|
| 50 | return statusOK; |
|---|
| 51 | }else{ |
|---|
| 52 | for(freqKHz=start_freq; freqKHz<end_freq; freqKHz+=step_freq) |
|---|
| 53 | { |
|---|
| 54 | /* ½Ã°£À» ÁÙÀ̱â À§ÇØ ÀÌ¹Ì ºñ±³ÇÑ Center Frequency´Â ãÁö ¾Ê´Â´Ù. */ |
|---|
| 55 | if(((start_freq+end_freq)/2)+step_freq>freqKHz && ((start_freq+end_freq)/2)-step_freq<freqKHz) |
|---|
| 56 | continue; |
|---|
| 57 | |
|---|
| 58 | result = dmw_search_ntsc_get_deviation(id, freqKHz, &freq); |
|---|
| 59 | if(result) |
|---|
| 60 | return result; |
|---|
| 61 | |
|---|
| 62 | if(freq < SEARCH_FREQ_POSITIVE_BOUNDARY && freq > SEARCH_FREQ_NEGATIVE_BOUNDARY){ |
|---|
| 63 | *tune_freq = freqKHz + freq; |
|---|
| 64 | return statusOK; |
|---|
| 65 | } |
|---|
| 66 | } |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | return statusError; |
|---|
| 70 | } |
|---|
| 71 | |
|---|
| 72 | |
|---|
| 73 | STATUS DMW_NtscFullSearch(tDHL_TunerID id, int channel, tDHL_FreqStd freqTbl, INT32 *tune_freq, UINT32 search_range) |
|---|
| 74 | { |
|---|
| 75 | STATUS result; |
|---|
| 76 | UINT32 try_freq; |
|---|
| 77 | |
|---|
| 78 | /* |
|---|
| 79 | * Convert Channel to Frequency if bFreq == CHANNEL. |
|---|
| 80 | */ |
|---|
| 81 | try_freq = DHL_FE_ChannelToFrequency(channel, freqTbl); |
|---|
| 82 | |
|---|
| 83 | result = dmw_search_ntsc_one_channel(id, try_freq-search_range, try_freq+search_range, SEARCH_STEP_FREQ, &tune_freq); |
|---|
| 84 | |
|---|
| 85 | return result; |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | STATUS DMW_NtscShortSearch(tDHL_TunerID id, int channel, tDHL_FreqStd freqTbl, INT32 *tune_freq, UINT32 search_range) |
|---|
| 89 | { |
|---|
| 90 | STATUS result; |
|---|
| 91 | UINT32 try_freq; |
|---|
| 92 | |
|---|
| 93 | result = DMW_NtscFullSearch(id, channel, freqTbl, tune_freq, SHORT_SEARCH_HALF_BOUND); |
|---|
| 94 | |
|---|
| 95 | return result; |
|---|
| 96 | } |
|---|