source: svn/newcon3bcm2_21bu/dst/dmw/src/Channel/DMW_ChannelFreq.c @ 22

Last change on this file since 22 was 22, checked in by phkim, 11 years ago
  1. phkim
  2. newcon3sk 를 kctv 로 브랜치 함
  • Property svn:executable set to *
File size: 9.5 KB
Line 
1/*******************************************************************
2 * DMW_ChannelFreq.c
3 *
4 *
5 * Copyright 2003 Digital STREAM Technology, Inc.
6 * All Rights Reserved
7 *
8 * $Id: DMW_ChannelFreq.c,v 1.1  2004 cafrii Exp $
9 *
10 ********************************************************************/
11
12
13
14
15#include "DMW_Platform.h"
16
17
18
19#include "DHL_OSAL.h"
20#include "DHL_AVCAP.h"
21
22
23
24#include "DMW_Config.h"
25#include "DMW_DebugUtil.h"
26
27#include "DMW_Channel.h"
28        //
29        // frequency standard »ó¼ö Á¤ÀÇ
30        //
31
32
33
34
35// µå¶óÀ̹öÀÇ Frequency tableÀ» »ç¿ëÇÏÁö ¾Ê°í, MW ÀÚüÀûÀ¸·Î tableÀ» °ü¸®ÇÑ´Ù.
36// Á» ´õ ÀÚ¼¼ÇÑ Á֯ļö¸¦ »ç¿ëÇÒ¼ö ÀÖ°Ô Çϱâ À§ÇÔÀÌ´Ù.
37
38
39// ±âÁ¸¿¡ Á÷Á¢ Á¤ÀÇÇØ¼­ »ç¿ëÇÏ´ø ÄÚµå..
40
41// ¾Æ·¡ ³×°³ÀÇ Á֯ļö Å×À̺íÀÇ ´ÜÀ§´Â 0.1KHz (100Hz)ÀÌ´Ù.
42// ½ÇÁ¦·Î »ç¿ëÇÒ ¶§¿¡´Â ÀûÀýÇÏ°Ô ´ÜÀ§ ȯ»êÀ» °ÅÃľ߸¸ ÇÑ´Ù.
43
44static UINT32 AirFreq[HIGHEST_AIR_CHANNEL+1] =      // (0, 1,) 2 ~ 83
45{       //    0       1       2       3       4       5       6       7       8       9
46              0,      0, 570000, 630000, 690000, 790000, 850000,1770000,1830000,1890000, //   0~  9
47        1950000,2010000,2070000,2130000,4730000,4790000,4850000,4910000,4970000,5030000, //  10~ 19
48        5090000,5150000,5210000,5270000,5330000,5390000,5450000,5510000,5570000,5630000, //  20~ 29
49        5690000,5750000,5810000,5870000,5930000,5990000,6050000,6110000,6170000,6230000, //  30~ 39
50        6290000,6350000,6410000,6470000,6530000,6590000,6650000,6710000,6770000,6830000, //  40~ 49
51        6890000,6950000,7010000,7070000,7130000,7190000,7250000,7310000,7370000,7430000, //  50~ 59
52        7490000,7550000,7610000,7670000,7730000,7790000,7850000,7910000,7970000,8030000, //  60~ 69
53        8090000,8150000,8210000,8270000,8330000,8390000,8450000,8510000,8570000,8630000, //  70~ 79
54        8690000,8750000,8810000,8870000,                                                 //  80~ 83
55};
56
57static UINT32 CableFreqSTD[HIGHEST_CABLE_CHANNEL+1] =    // (0,) 1 ~ 135
58{       //    0       1       2       3       4       5       6       7       8       9
59          0, 750000, 570000, 630000, 690000, 790000, 850000,1770000,1830000,1890000, //   0~  9
60        1950000,2010000,2070000,2130000,1230125,1290125,1350125,1410000,1470000,1530000, //  10~ 19
61        1590000,1650000,1710000,2190000,2250000,2310125,2370125,2430125,2490125,2550125, //  20~ 29
62        2610125,2670125,2730125,2790125,2850125,2910125,2970125,3030125,3090125,3150125, //  30~ 39
63        3210125,3270125,3330225,3390125,3450125,3510125,3570125,3630125,3690125,3750125, //  40~ 49
64        3810125,3870125,3930125,3990125,4050000,4110000,4170000,4230000,4290000,4350000, //  50~ 59
65        4410000,4470000,4530000,4590000,4650000,4710000,4770000,4830000,4890000,4950000, //  60~ 69
66        5010000,5070000,5130000,5190000,5250000,5310000,5370000,5430000,5490000,5550000, //  70~ 79
67        5610000,5670000,5730000,5790000,5850000,5910000,5970000,6030000,6090000,6150000, //  80~ 89
68        6210000,6270000,6330000,6390000,6450000, 930000, 990000,1050000,1110250,1170250, //  90~ 99
69        6510000,6570000,6630000,6690000,6750000,6810000,6870000,6930000,6990000,7050000, // 100~109
70        7110000,7170000,7230000,7290000,7350000,7410000,7470000,7530000,7590000,7650000, // 110~119
71        7710000,7770000,7830000,7890000,7950000,8010000,8070000,8130000,8190000,8250000, // 120~129
72        8310000,8370000,8430000,8490000,8550000,8610000,                                 // 130~135
73};
74
75static UINT32 CableFreqIRC[HIGHEST_CABLE_CHANNEL+1] =    // (0,) 1 ~ 135
76{       //    0       1       2       3       4       5       6       7       8       9
77              0, 750125, 570125, 630125, 690125, 810125, 870125,1770125,1830125,1890125, //   0~  9
78        1950125,2010125,2070125,2130125,1230125,1290125,1350125,1410125,1470125,1530125, //  10~ 19
79        1590125,1650125,1710125,2190125,2250125,2310125,2370125,2430125,2490125,2550125, //  20~ 29
80        2610125,2670125,2730125,2790125,2850125,2910125,2970125,3030125,3090125,3150125, //  30~ 39
81        3210125,3270125,3330250,3390125,3450125,3510125,3570125,3630125,3690125,3750125, //  40~ 49
82        3810125,3870125,3930125,3990125,4050125,4110125,4170125,4230125,4290125,4350125, //  50~ 59
83        4410125,4470125,4530125,4590125,4650125,4710125,4770125,4830125,4890125,4950125, //  60~ 69
84        5010125,5070125,5130125,5190125,5250125,5310125,5370125,5430125,5490125,5550125, //  70~ 79
85        5610125,5670125,5730125,5790125,5850125,5910125,5970125,6030125,6090125,6150125, //  80~ 89
86        6210125,6270125,6330125,6390125,6450125, 930125, 990125,1050125,1110250,1170125, //  90~ 99
87        6510125,6570125,6630125,6690125,6750125,6810125,6870125,6930125,6990125,7050125, // 100~109
88        7110125,7170125,7230125,7290125,7350125,7410125,7470125,7530125,7590125,7650125, // 110~119
89        7710125,7770125,7830125,7890125,7950125,8010125,8070125,8130125,8190125,8250125, // 120~129
90        8310125,8370125,8430125,8490125,8550125,8610125,                                 // 130~135
91};
92
93static UINT32 CableFreqHRC[HIGHEST_CABLE_CHANNEL+1] =    // (0,) 1 ~ 135
94{       //    0       1       2       3       4       5       6       7       8       9
95              0, 737536, 557527, 617530, 677533, 797539, 857542,1757587,1817590,1877593, //   0~  9
96        1937596,1997599,2057602,2117605,1217560,1277563,1337566,1397569,1457572,1517575, //  10~ 19
97        1577578,1637581,1697584,2177608,2237611,2297614,2357617,2417620,2477623,2537626, //  20~ 29
98        2597629,2657632,2717635,2777638,2837641,2897644,2957647,3017650,3077653,3137656, //  30~ 39
99        3197659,3257662,3317665,3377668,3437668,3497668,3557668,3617668,3677668,3737668, //  40~ 49
100        3797668,3857668,3917668,3977668,4037701,4097704,4157707,4217710,4277713,4337716, //  50~ 59
101        4397719,4457722,4517725,4577728,4637731,4697734,4757737,4817740,4877743,4937746, //  60~ 69
102        4997749,5057752,5117755,5177758,5237761,5297764,5357767,5417770,5477773,5537776, //  70~ 79
103        5597779,5657782,5717785,5777788,5837791,5897794,5957797,6017800,6077803,6137806, //  80~ 89
104        6197809,6257812,6317815,6377818,6437821, 917545, 977548,1037551,1097554,1157557, //  90~ 99
105        6497824,6557827,6617830,6677833,6737836,6797839,6857842,6917845,6977848,7037851, // 100~109
106        7097854,7157857,7217860,7277863,7337866,7397869,7457872,7517875,7577878,7637881, // 110~119
107        7697884,7757887,7817890,7877893,7937896,7997899,8057902,8117905,8177908,8237911, // 120~129
108        8297914,8357917,8417920,8477926,8537926,8597929,                                 // 130~135
109};
110
111
112
113
114// cafrii 050316 add
115//
116// ÁöÁ¤ÇÑ RF ä³ÎÀÇ Hz ´ÜÀ§ÀÇ center frequency Á֯ļö°ªÀ» ¸®ÅÏÇÑ´Ù.
117// Frequency Standard º°·Î ´Ù¸¥ Å×À̺íÀ» Àû¿ëÇÑ´Ù.
118//
119// ÀÎÀÚ°¡ À߸øµÈ °æ¿ì 0À» ¸®ÅÏ.
120//
121UINT32 FindCenterFrequency(int RF, INT32 freqOffset, tDHL_FreqStd std)
122{
123        if (std == eDHL_FREQ_AIR)
124        {
125                if (RF < 2 || RF > HIGHEST_AIR_CHANNEL)
126                        return 0;
127       
128                return (AirFreq[RF]*100 + freqOffset);  // Hz ´ÜÀ§·Î º¯È¯ÇÏ¿© ¸®ÅÏ.
129        }
130        else
131        {
132                UINT32 *table =
133                        std == eDHL_FREQ_STD ? CableFreqSTD :
134                        std == eDHL_FREQ_IRC ? CableFreqIRC :
135                        std == eDHL_FREQ_HRC ? CableFreqHRC : NULL;
136
137                if (table == NULL) {
138                        //dprint("!! FindFrequency: invalid frequency standard\n");
139                        return 0;
140                }
141
142                if (RF < 1 || RF > HIGHEST_CABLE_CHANNEL)
143                        return 0;
144       
145                return (table[RF]*100 + freqOffset);
146        }       
147}
148
149
150
151
152int FindAirRF(UINT32 freq, INT32 *freq_offset)
153{
154        // ÁÖ¾îÁø Á֯ļö °ª¿¡ ÇØ´çÇÏ´Â RF ä³Î ¹øÈ£(Á¤¼ö°ª)¸¦ ¸®ÅÏÇÑ´Ù.
155        // freq:
156        //   VSBÀÎ °æ¿ì freq´Â pilot tone Á֯ļöÀÌ´Ù.
157        //     6MHz bandÀÇ lower-edge Á֯ļö + 310KHz
158        //   ¾Æ³¯·Î±×ÀÎ °æ¿ì´Â picture carrier
159        //     center freq - 1.75MHz == lower-edge + 1.25MHz)
160        //
161        //  --> ÀÌÁ¦ºÎÅÍ´Â center frequency·Î¸¸ »ç¿ëÇϵµ·Ï ÇÑ´Ù.
162        //      VCT¿¡ ÀÖ´Â frequency field´Â °¢ modulation À» °í·ÁÇÏ¿©
163        //      center frequency·Î º¯È¯ ÇÑ ÈÄ¿¡ ÀÌ ÇÔ¼ö¸¦ »ç¿ëÇØ¾ß ÇÑ´Ù.
164        //
165        // freq_offset:
166        //   freq_offsetÀº ¾Æ³¯·Î±×ÀÎ °æ¿ì¿¡¸¸ »ç¿ëÇÏ´Â °ÍÀ¸·Î¼­,
167        //   Å×ÀÌºí »óÀÇ center frequency ¿ÍÀÇ Â÷ÀÌ °ªÀ» ¸®ÅÏÇÑ´Ù.
168        //
169        // return °ª:
170        //   ¹ß°ßµÈ RF ä³Î ¹øÈ£. ¹ß°ßµÇÁö ¾ÊÀ¸¸é -1À» ¸®ÅÏÇÑ´Ù.
171
172        int i;
173        unsigned int center;
174
175        for (i=2; i<=HIGHEST_AIR_CHANNEL; i++)
176        {
177                center = AirFreq[i]*100;
178                if (center-3000000 <= freq && freq <= center+3000000)
179                {
180                        if (freq_offset)
181                                *freq_offset = freq - (center); // ¸ðµç offsetÀº ÀÌÁ¦ center frequency ±âÁØÀ¸·Î º¯°æÇÔ.
182
183                        return i;
184                }
185        }
186        return -1;  // not found!!
187}
188
189int FindCableRF(UINT32 freq, INT32 *freq_offset)
190{
191        int i;
192        unsigned int center;
193
194        for (i=1; i<=HIGHEST_CABLE_CHANNEL; i++)
195        {
196                center = CableFreqSTD[i]*100;
197                if (center-3000000 <= freq && freq <= center+3000000)
198                {
199                        if (freq_offset)
200                                *freq_offset = freq - (center);
201
202                        return i;
203                }
204        }
205        return -1;  // not found!!
206}
207
208int FindMultiStandardRF(UINT32 freq, INT32 *freq_offset, tDHL_FreqStd std)
209{
210        int i;
211        unsigned int center;
212
213        UINT32 *table =
214                        std == eDHL_FREQ_AIR? AirFreq :
215                        std == eDHL_FREQ_STD? CableFreqSTD :
216                        std == eDHL_FREQ_IRC? CableFreqIRC :
217                        std == eDHL_FREQ_HRC ? CableFreqHRC : NULL;
218
219        if (!table) return -1;
220
221        for (i=1; i<=HIGHEST_CABLE_CHANNEL; i++)
222        {
223                center = table[i]*100;
224                if (center-3000000 <= freq && freq <= center+3000000)
225                {
226                        if (freq_offset)
227                                *freq_offset = freq - (center);
228
229                        return i;
230                }
231        }
232        return -1;  // not found!!
233}
234
235
236/********************************************************************
237   $Log: DMW_ChannelFreq.c,v $
238
239        1.12 2005/3/16 maintain its own frequency table
240                       add FindCenterFrequency API
241
242        1.11 2004/8/30 channel.h is now the only required header
243                       isolate from channel DB module
244
245        1.1 2004/6/11 Freqency table removed. import from driver's.
246                      FindMultiStandardRF added
247        1.0 2003/1/30
248           Initial coding from ground. based on M/W API document
249           Table is from HD1100K
250
251 ********************************************************************/
Note: See TracBrowser for help on using the repository browser.