source: svn/newcon3bcm2_21bu/dst/dhl/src/DHL_FE_Platform_lgh952f.c

Last change on this file was 76, checked in by megakiss, 10 years ago

1W 대기전력을 만족시키기 위하여 POWEROFF시 튜너를 Standby 상태로 함

  • Property svn:executable set to *
File size: 7.3 KB
Line 
1
2/********************************************************************
3        DHL_FE_Platform_LGH952F.c
4
5        write by yhkim
6       
7        LGH952F µå¶óÀ̹ö¸¦ Áö¿øÇϱâ À§ÇÑ È®Àå¿ë API
8       
9********************************************************************/
10
11#include "DHL_OSAL.h"
12#include "DHL_DBG.h"
13#include "DHL_DEV_Priv.h"
14#include "LG3305.h"
15
16#include "DHL_FE_Priv.h"
17
18//#include <string.h>
19
20
21#define NUM_TUNER_MAX   1
22
23
24#if COMMENT
25____DBG____(){}
26#endif
27
28//DHL_MODULE("*fe", 0);
29
30
31
32#if COMMENT
33____Global____(){}
34#endif
35
36
37
38#define LGH952F_VENDOR_NAME "LG-"
39#define LGH952F_MODEL_NAME "LGH952F"
40
41static struct {
42        UINT8 div1;
43        UINT8 div2;
44       
45        UINT8 ct1_76;  // :2
46        UINT8 atp;  // :3
47        UINT8 rs;  // :3
48               
49        UINT8 cp;  // :2
50        UINT8 aisl;  // :1
51        UINT8 p5;  // :1
52        UINT8 bs;  // :4
53               
54        UINT8 ct2_76;  // :2
55        UINT8 atc;  // :1
56        UINT8 stby;  // :1
57        UINT8 t32;  // :2
58        UINT8 t1;  // :1
59        UINT8 t0;  // :1
60               
61} p_tuner_arg[NUM_TUNER_MAX]=
62{
63        {
64                0,
65                0,
66                2, 0, 0,
67                0, 0, 0, 0,
68                3, 0, 0, 0, 0
69        }
70};
71
72static struct {
73        UINT8 tuner_id;
74        UINT8 i2c_id;
75        UINT8 i2c_addr;
76} p_tuner_attr[NUM_TUNER_MAX];
77
78
79
80#if COMMENT
81____API____(){}
82#endif
83
84
85static DHL_RESULT p_i2c_write(UINT8 i2c_id, UINT8 i2c_addr, UINT8 *pdata, UINT8 num_bytes)
86{
87        DHL_RESULT dhr = DHL_OK;
88        int i;
89
90        #if (defined _FE_DTQS22DDP101A_LG ||defined _FE_DTQS22DDP101B_LG ||defined _FE_LGH952F_LG)     
91                LG3305_RepeaterI2C(i2c_id, PASS_ON);
92        #else
93                Sec_1411xRepeaterEnable();
94        #endif
95               
96        dhr = dhl_i2c_write1(i2c_id, i2c_addr, pdata, num_bytes);
97        if (dhr != DHL_OK)
98        {
99                DHL_OS_Printf("|%s| fail to write tuner(chip_addr:0x%x).\n",
100                              __FUNCTION__, i2c_addr);
101        }
102        #if (defined _FE_DTQS22DDP101A_LG ||defined _FE_DTQS22DDP101B_LG ||defined _FE_LGH952F_LG)     
103                LG3305_RepeaterI2C(i2c_id, PASS_OFF);
104        #else
105                Sec_1411xRepeaterDisable();
106                Sec_1411xSoftReset();                   //When a channel is changed  clear
107        #endif
108       
109        return dhr;
110}
111
112
113
114/* ÃʱâÈ­ Driver API ÇÔ¼ö
115
116        ÀÎÀÚ : I2C Ch.No , Device Addr
117
118        Driver API ·Î ²À! FE_ID, I2C_ID, I2C_Addr À» ³Ñ°ÜÁØ´Ù..
119
120*/
121DHL_RESULT dhl_LGH952F_init(tDHL_TunerID id, DHL_BOARD_REV rev, tDHL_DEV_I2C_ID hI2c, 
122        UINT8 i2cAddr)
123{
124        DHL_RESULT dhr = DHL_OK;       
125
126        if(id == 0)
127        {
128                dprint(1, "id : %d, Rev : 0x%04x, I2C_ID : %d, I2C_Addr : 0x%02x, LGH952F \r\n",
129                                        id, rev, hI2c, i2cAddr);
130               
131                p_tuner_attr[id].tuner_id=id;
132                p_tuner_attr[id].i2c_id=hI2c;
133                p_tuner_attr[id].i2c_addr=i2cAddr;
134        }
135       
136        return dhr;
137}
138
139
140
141DHL_RESULT dhl_LGH952F_open(tDHL_TunerID id, DHL_BOARD_REV rev)
142{
143
144        DHL_RESULT dhr = DHL_OK;
145
146
147        if(id == 0)
148        {
149        }
150       
151
152        return dhr;
153
154}
155
156
157
158DHL_RESULT dhl_LGH952F_close(tDHL_TunerID id, DHL_BOARD_REV rev)
159{
160
161        DHL_RESULT dhr = DHL_OK;
162
163
164        if(id == 0)
165        {
166        }
167       
168
169        return dhr;
170
171}
172
173
174
175
176
177
178static int atp=3;
179static int rs=3;
180static int cp=0;
181static int aisl=0;
182static int p5=1;
183static int atc=1;
184static int stby=0;
185static int t32=0;
186static int t1=0;
187static int t0=0;
188
189void tuner_set(int attr, int val)
190{
191        switch(attr) {
192                case 0: atp=val; break;
193                case 1: rs=val; break;
194                case 2: cp=val; break;
195                case 3: aisl=val; break;
196                case 4: p5=val; break;
197                case 5: atc=val; break;
198                case 6: stby=val; break;
199                case 7: t32=val; break;
200                case 8: t1=val; break;
201                case 9: t0=val; break;
202        }
203}
204
205
206/*  tune start Driver API ÇÔ¼ö
207
208        ÁÖ¾îÁø Á֯ļö(KHz) ·Î Æ©´× µ¿ÀÛ ¼öÇà.
209       
210               
211*/
212DHL_RESULT dhl_LGH952F_start(tDHL_TunerID id, DHL_BOARD_REV rev, 
213        UINT32 freqKHz, tDHL_Demod demod, tDHL_DemodExtSettings *settings)
214{
215
216        DHL_RESULT dhr = DHL_OK;
217        int retVal = 0; 
218       
219        if (freqKHz == 0) return DHL_FAIL;
220       
221        if(id == 0)
222        {
223                int n, fss;
224                UINT8 data[5];
225
226#if 0
227                p_tuner_arg[id].atp=3;
228                p_tuner_arg[id].rs=3;
229                p_tuner_arg[id].cp=0;
230                p_tuner_arg[id].aisl=0;
231                p_tuner_arg[id].p5=1;
232                p_tuner_arg[id].bs=freqKHz>=426000?8:freqKHz>=162000?2:1;
233                p_tuner_arg[id].atc=1;
234                p_tuner_arg[id].stby=0;
235                p_tuner_arg[id].t32=0;
236                p_tuner_arg[id].t1=0;
237                p_tuner_arg[id].t0=0; //xtal output disable
238#else
239                p_tuner_arg[id].atp=atp;
240                p_tuner_arg[id].rs=rs;
241                p_tuner_arg[id].cp=cp;
242                p_tuner_arg[id].aisl=aisl;
243                p_tuner_arg[id].p5=p5;
244                p_tuner_arg[id].bs=freqKHz>=426000?8:freqKHz>=162000?2:1;
245                p_tuner_arg[id].atc=atc;
246                p_tuner_arg[id].stby=stby;
247                p_tuner_arg[id].t32=t32;
248                p_tuner_arg[id].t1=t1;
249                p_tuner_arg[id].t0=t0; //xtal output disable
250#endif
251
252                fss=
253                        p_tuner_arg[id].rs==0?166670:
254                        p_tuner_arg[id].rs==1?142860:
255                        p_tuner_arg[id].rs==2?80000:
256                        p_tuner_arg[id].rs==3?62500:
257                        p_tuner_arg[id].rs==4?31250:50000;
258               
259                n=(freqKHz*1000+44000000)/fss;
260               
261                p_tuner_arg[id].div1=(n>>8)&0xff;
262                p_tuner_arg[id].div2=n&0xff;
263               
264                DHL_OS_Printf("div(0x%x, 0x%x), n(%d), fss(%d)\n", 
265                        p_tuner_arg[id].div1, p_tuner_arg[id].div2, n, fss);
266
267                data[0] = p_tuner_arg[id].div1;
268                data[1] = p_tuner_arg[id].div2;
269                data[2] = (p_tuner_arg[id].ct1_76 << 6) | (p_tuner_arg[id].atp << 3) |
270                          (p_tuner_arg[id].rs << 0);
271                data[3] = (p_tuner_arg[id].cp << 6) | (p_tuner_arg[id].aisl << 5) |
272                          (p_tuner_arg[id].p5 << 4) | (p_tuner_arg[id].bs << 0);
273                data[4] = (p_tuner_arg[id].ct2_76 << 6) | (p_tuner_arg[id].atc << 5) |
274                          (p_tuner_arg[id].stby << 4) | (p_tuner_arg[id].t32 << 2) |
275                          (p_tuner_arg[id].t1 << 1) | (p_tuner_arg[id].t0 << 0);
276               
277                p_i2c_write(p_tuner_attr[id].i2c_id, p_tuner_attr[id].i2c_addr, 
278                        (UINT8 *)data, sizeof(data));
279        }
280
281        return dhr;
282
283}
284
285
286/*      tune stop Driver API ÇÔ¼ö
287
288        FE ¿¡ Çѹø tune ¸í·ÉÀ» ³»·Á tune ÀÌ µÇ¸é tune »óŰ¡ À¯ÁöµÈ´Ù.
289        FE ¿¡¼­ Lock üũ¸¦ ÇÏ¿© snr, Lock »óŵîÀ» °¡Áö°í Decoder ´Ü¿¡¼­ È­¸é Ãâ·ÂÀ» ÆÇ´Ü...
290        µû¶ó¼­ stop À» À§ÇØ tune ¼³Á¤°ªÀ» ¹Ù²ÙÁö ¾Ê°í Lock üũ ºÎºÐÀ» disable ÇÏ¿© tune ¾ÈµÈ°Í ó·³
291        º¸À̰ÔÇÔ..
292        ÀÌÀü Lock »óŰªÀº ÃʱâÈ­ ½ÃÅ´..
293       
294       
295*/
296DHL_RESULT dhl_LGH952F_stop(tDHL_TunerID id, DHL_BOARD_REV rev)
297{
298        DHL_RESULT dhr = DHL_OK;
299
300        if(id == 0)
301        {
302               
303        }
304
305        return dhr;
306}
307
308
309DHL_RESULT dhl_LGH952F_get_sig_info(tDHL_TunerID id, DHL_BOARD_REV rev, 
310        tDHL_SignalStatus selector, UINT32 *pValue)
311{
312
313        DHL_RESULT dhr = DHL_OK;       
314
315        if(id == 0)
316        {
317               
318        } 
319
320        return dhr;
321}
322
323
324DHL_RESULT dhl_LGH952F_control(tDHL_TunerID id, DHL_BOARD_REV rev,
325        tDHL_FeControlType selector, UINT32 arg)
326{
327        DHL_RESULT dhr = DHL_OK;
328
329        if(id == 0)
330        {
331                switch(selector) {
332
333                        case eDHL_FECTL_ATC_MODE:
334                               
335                                p_tuner_arg[id].atc=(UINT8)arg;
336                                break;
337               
338                        default :
339                                dhr = DHL_FAIL_NOT_IMPLEMENTED;
340                                break;
341                }
342        } 
343
344        return dhr;
345}
346
347
348/*
349
350        Device ÀÇ Vendor ¹× Partname ¹Ýȯ..
351
352*/
353DHL_RESULT dhl_LGH952F_get_device_info(tDHL_TunerID id, DHL_BOARD_REV rev, 
354        tDHL_TunerDeviceInfo selector, void *pValue)
355{
356        DHL_RESULT dhr = DHL_OK;
357
358        if(id == 0)
359        {
360                if(selector==eDHL_FE_DEV_VENDOR_NAME) {
361                        strncpy((char *)pValue, LGH952F_VENDOR_NAME, FE_VENDOR_NAME_LEN);
362                        ((char *)pValue)[FE_VENDOR_NAME_LEN-1] = 0;
363                }
364                else if(selector==eDHL_FE_DEV_MODEL_NAME) {
365                        strncpy((char *)pValue, LGH952F_MODEL_NAME, FE_VENDOR_NAME_LEN);
366                        ((char *)pValue)[FE_VENDOR_NAME_LEN-1] = 0;
367                }               
368                else 
369                        return DHL_FAIL_INVALID_PARAM;
370        } // id : 0
371       
372        return dhr;
373}
374
375
376
377
378
379
380
381
382#if COMMENT
383____Test_Code____(){}
384#endif
385
386
387void set_lgh(UINT8 data)
388{
389        p_i2c_write(p_tuner_attr[0].i2c_id, p_tuner_attr[0].i2c_addr, &data, 1);
390        DHL_OS_Printf("0x%x = 0x%x\n", p_tuner_attr[0].i2c_addr, data);
391}
392
393
394
395
396
Note: See TracBrowser for help on using the repository browser.