source: svn/newcon3bcm2_21bu/dst/dhl/src/DHL_FE_Platform_s5h1411.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: 10.7 KB
Line 
1
2
3/********************************************************************
4        DHL_FE_Platform_s5h1411.c
5
6        write by khkim
7       
8        s5h1411 µå¶óÀ̹ö¸¦ Áö¿øÇϱâ À§ÇÑ È®Àå¿ë API
9       
10********************************************************************/
11       
12#include "DHL_OSAL.h"
13#include "DHL_DBG.h"
14#include "DHL_SYS.h"
15#include "DHL_SYS_Config.h"
16       
17#include "DHL_FE_Priv.h"
18#include "MxL601_TunerApi.h"
19
20
21#include "S5H1411.h"
22
23
24
25/*
26        DHL µð¹ö±× ¸ðµâ À̸§ Á¤ÀÇ ·ê Âü°í:
27
28        DHL ¸ðµâµéÀº ¸ðµÎ * ·Î ½ÃÀÛ.
29        API´Â ´ë¹®ÀÚ, Platform ¹× ±âŸ´Â ¼Ò¹®ÀÚ »ç¿ë.
30
31        µðÆúÆ® ·¹º§Àº 0À¸·Î ¼³Á¤ÇÑ´Ù. (0: ¿¡·¯ ¸Þ½ÃÁö¸¸ Ãâ·Â)
32       
33       
34*/
35
36
37//DHL_MODULE("*fe", 0);
38
39
40
41
42static tDHL_Demod g_last_demod_type[DHL_CFG_NUM_TUNER];
43
44static DHL_RESULT dhl_s5h1411_check_lock(tDHL_TunerID id, UINT32 *pValue);
45static DHL_RESULT dhl_s5h1411_check_snr1000(tDHL_TunerID id, UINT32 *pValue);
46static DHL_RESULT dhl_s5h1411_check_ser(tDHL_TunerID id, UINT32 *pValue);
47SSdtReturn_t s5h1411_init(DATA08 id, DATA08 hI2c, DATA08 i2cAddr);     
48DATA_DOUBLE Sec_1411xVsbSnrResultCheck(void);
49DATA32 S5H1411x_UncorrectableError(void);
50DATA32 Sec_1411xVsbEqLock(void);
51
52
53
54#if COMMENT
55___Local_Func__() {}
56#endif
57
58
59struct curv_pt {
60        int x;
61        int y;
62};
63
64static struct curv_pt c_linear[] = // ¼±Çü ¸ÅÇÎ.
65{
66        { 0, 0 },
67        { 1000,1000 },
68};
69
70static struct curv_pt c_s_soft[] = // s curve ¸ÅÇÎ.
71{ 
72        { 0, 0 },
73        { 400, 300, },
74        { 600, 700, },
75        { 1000, 1000 },
76};
77
78static struct curv_pt c_s_strong[] = // s curve ¸ÅÇÎ 2
79{ 
80        { 0, 0 },
81        { 400, 200, },
82        { 600, 800, },
83        { 1000, 1000 },
84};
85
86static struct curv_pt c_snr_2_strength[] = 
87{
88        {   0,    0 },
89        {  60,   60 }, // x1.0
90        { 120,  180 }, // x1.5
91        { 180,  360 }, // x2.0
92        { 240,  600 }, // x2.5
93        { 300,  900 }, // x3.0
94        { 400, 1000 },
95};
96
97#define N_ELEM(a) (sizeof(a)/sizeof(a[0]))
98
99static struct {
100        struct curv_pt* tbl;
101        int size;
102} tables[] = {
103        // Á¦°ø °¡´ÉÇÑ curve µéÀ» ¿©±â¿¡ ³ª¿­.
104        {c_linear, N_ELEM(c_linear)},   // 0
105        {c_s_soft, N_ELEM(c_s_soft)},   // 1
106        {c_s_strong, N_ELEM(c_s_strong)}, // 2
107        {c_snr_2_strength, N_ELEM(c_snr_2_strength)}, // 3
108};
109       
110       
111
112static float p_interpolate(int x1, int y1, int x2, int y2, int xi)
113{
114        if (x1 == x2)
115                return (y1 + y2)/2.;
116       
117        return ((y2)-(y1)) * ((xi)-(x1)) / (float)((x2)-(x1)) + (y1);
118}
119
120static float p_apply_curve(UINT32 type, int x)
121{
122        int i;
123       
124       
125
126        struct curv_pt *tbl;
127        int size;
128        float fy;
129       
130        if (type > N_ELEM(tables)) {
131                printf("!! invalid curve type %d\n", type);
132                type = 0;
133        }
134
135        tbl = tables[type].tbl;
136        size = tables[type].size;
137
138        if (x <= tbl[0].x) { // ÁÂÃø °æ°è ¹þ¾î³². ù¹øÂ° boundary °ª »ç¿ë.
139                fy = tbl[0].y;
140                goto label_end;
141        }
142
143        //printf(" tble : (%d %d) (%d %d)\n", tbl[0].x, tbl[0].y, tbl[1].x, tbl[1].y);
144       
145        for (i=1; i<size; i++)
146        {
147                // x°¡ tbl[i-1] tbl[i] »çÀÌ °ªÀ̸é
148                if (tbl[i-1].x <= x && x <= tbl[i].x)
149                {
150                        // ±× Áß°£ °ªÀ» °è»ê.
151                        fy = p_interpolate(tbl[i-1].x, tbl[i-1].y, tbl[i].x, tbl[i].y, x);
152                        //printf(" -> %d, size %d, %d<%d<%d \n", (int)fy, size, tbl[i-1].x, x, tbl[i].x);
153
154                        goto label_end;
155                }
156        }
157        fy = tbl[size-1].y; // ¿ìÃø °æ°è ¹þ¾î³². ¸¶Áö¸· boundary °ªÀ» »ç¿ë.
158        //printf(" x:%d -> fy:%d, right limit\n", x, (int)fy);
159
160label_end:
161
162        return fy;
163       
164}
165
166
167
168static int p_get_sig_strength(int snr10)
169{
170        int strength;
171       
172        strength=(int)p_apply_curve(3, snr10)/10;
173       
174        return strength;
175}
176
177
178
179#if COMMENT
180____API____(){}
181#endif
182
183
184DHL_RESULT dhl_s5h1411_init(tDHL_TunerID id, DHL_BOARD_REV rev, 
185        tDHL_DEV_I2C_ID hI2c, UINT8 i2cAddr)
186{
187
188        DHL_RESULT dhr = DHL_OK;
189        SSdtReturn_t nRet = SSDT_ERR_NO;
190       
191
192        if(id == 0)
193        {
194        //      dprint(1, "id : %d, Rev : 0x%04x, I2C_ID : %d, I2C_Addr : 0x%02x, LG3305 \r\n",
195        //                              id, rev, hI2c, i2cAddr);
196
197                // Demod Reset Active low (> 1ms)
198                DHL_SYS_ResetGPIO(GPIO_DEMOD_RST);                     
199                DHL_OS_Delay(1);
200                DHL_SYS_SetGPIO(GPIO_DEMOD_RST);
201
202                nRet = s5h1411_init(id, hI2c, i2cAddr);
203
204                if(nRet != SSDT_ERR_NO)
205                {
206                        dprint(0, " FE_ID : %d, S5H1411 in-band init Error!!! \r\n", id);
207                        dhr = DHL_FAIL;
208                }
209                else
210                {
211                        dprint(0, " FE_ID : %d, S5H1411 in-band init OK!!! \r\n", id);
212                }
213
214
215               
216        }
217       
218       
219
220        return dhr;
221
222}
223
224
225
226DHL_RESULT dhl_s5h1411_stop(tDHL_TunerID id, DHL_BOARD_REV rev)
227{
228
229        DHL_RESULT dhr = DHL_OK;
230
231
232        if(id == 0)
233        {
234        }
235       
236
237        return dhr;
238
239}
240
241
242
243DHL_RESULT dhl_s5h1411_open(tDHL_TunerID id, DHL_BOARD_REV rev)
244{
245
246        DHL_RESULT dhr = DHL_OK;
247       
248       
249        if(id == 0)
250        {
251        }
252       
253
254        return dhr;
255
256}
257
258DHL_RESULT dhl_s5h1411_control(tDHL_TunerID id, DHL_BOARD_REV rev, 
259        tDHL_FeControlType selector, UINT32 arg)
260{
261
262        DHL_RESULT dhr = DHL_OK;
263
264       
265
266        if(id == 0)
267        {
268                switch(selector) {
269                        default :
270                                //dprint(0, "!! %s : not supported control type\n", __FUNCTION__);
271                                dhr = DHL_FAIL_NOT_IMPLEMENTED;
272                                break;
273               
274                } 
275        } // id : 0
276       
277
278        return dhr;
279
280}
281
282
283
284
285
286
287DHL_RESULT dhl_s5h1411_start(tDHL_TunerID id,DHL_BOARD_REV rev,
288        UINT32 freqkhz, tDHL_Demod demod, tDHL_DemodExtSettings *settings)
289{
290
291                DHL_RESULT dhr = DHL_OK;
292                SSdtReturn_t nRet = SSDT_ERR_NO;
293                SSdtOperMode_t demod_SSDT;
294                unsigned int result;
295                DATA_DOUBLE afc;
296
297               
298                if(id == 0)
299                {
300                        if(demod == eDHL_DEMOD_8VSB)
301                                demod_SSDT = SSDT_VSB;
302                        else if(demod == eDHL_DEMOD_64QAM)
303                                demod_SSDT = SSDT_QAM64;
304                        else if(demod == eDHL_DEMOD_256QAM)
305                                demod_SSDT = SSDT_QAM256;
306                        else
307                        {                               
308                                dprint(0, " FE_ID : %d, S5H1411 demod type out of range !!! \r\n", id);
309                                dhr = DHL_FAIL;
310                                goto err_exit;                 
311                        }                                               
312                        g_last_demod_type[id] = demod;  // Demod ¼³Á¤°ªÀ» ÀúÀå.. Â÷ÈÄ ºñ±³ ¹× ¹ÝȯÀ» À§ÇØ..
313       
314                DHL_OS_Delay(30);       //¿¬¼ÓµÈ ¸®¸ðÄÁ ¼ö½Å¿¡ ´ëÇÑ µô·¹ÀÌ
315               
316                Sec_1411xRepeaterEnable();     
317       
318                SemcoMxL601_SetAGC(0,AGC_EXTERNAL, DIG_ISDBT_ATSC);
319       
320                Sec_1411xRepeaterDisable();
321                Sec_1411xSoftReset();                   //When a channel is changed  clear
322       
323
324
325        }// id : 0
326       
327       
328err_exit:
329
330        return dhr;
331
332}
333
334
335
336DHL_RESULT dhl_s5h1411_get_sig_info(tDHL_TunerID id, DHL_BOARD_REV rev, 
337        tDHL_SignalStatus selector, UINT32 *pValue)
338{
339        DHL_RESULT dhr = DHL_OK;
340
341       
342        if(id == 0)
343        {
344                switch(selector)
345                {
346
347                        case eDHL_SIGNAL_LOCK :
348                                dhr = dhl_s5h1411_check_lock(id, pValue);       
349                                break;
350                        case eDHL_SIGNAL_LOCK_PROGRESS:                         
351                                break;
352                        case eDHL_SIGNAL_SER:
353                        case eDHL_SIGNAL_SER_1SEC:
354                        case eDHL_SIGNAL_SER_10SEC:
355                        case eDHL_SIGNAL_PER:
356                        case eDHL_SIGNAL_BER:
357                                dhr = dhl_s5h1411_check_ser(id, pValue);
358                                break;
359               
360                        case eDHL_SIGNAL_STRENGTH :
361                        case eDHL_SIGNAL_METER :
362                                dhr = dhl_s5h1411_check_snr1000(id, pValue);
363                                if(dhr==DHL_OK)
364                                        *pValue=(int)p_get_sig_strength(*pValue/100);
365                       
366                                else
367                                        pValue=0;
368                                       
369                                break;
370                       
371                        case eDHL_SIGNAL_SNR :
372                        case eDHL_SIGNAL_SNR2 :
373                                dhr = dhl_s5h1411_check_snr1000(id, pValue); // snr À» ´ã´Â º¯¼ö´Â INT ÇüÀε¥..pValue º¯¼ö´Â UINT.. - Àϰæ¿ì´Â..??
374                                break;
375                       
376                        default :
377                                //dprint(0, "!! %s : not supported signal status type\n", __FUNCTION__);
378                                dhr = DHL_FAIL_NOT_IMPLEMENTED;
379                                break;
380
381                }
382        }
383       
384
385        return dhr;
386}
387
388
389/*
390        ¼³Á¤µÈ Demod type À» °¡Á®¿È..
391        Lock üũ¸¦ ¼öÇàÇϸé Lock üũ ¾È¿¡ Demod type À» üũÇÏ´Â ºÎºÐÀÌ ÀÖÀ¸¸ç
392        Lock ÀÌ µÇ¸é Demod type ÀÌ app ¼³Á¤°ª°ú reg ¼ÂÆÃ°ªÀÌ °°´Ù´Â Àǹ̰¡ µÇ¸ç
393        À̶§ App ¼³Á¤°ªÀ» ¹ÝÈ¯ÇØ ÁØ´Ù.
394       
395*/
396
397DHL_RESULT dhl_s5h1411_get_demod_type(tDHL_TunerID id, DHL_BOARD_REV rev, 
398        tDHL_Demod *pDemod)
399{
400        DHL_RESULT dhr = DHL_OK;
401        UINT32 pValue;
402
403        if(id == 0)
404        {
405                if(pDemod != NULL)
406                {
407                        dhl_s5h1411_check_lock(id, &pValue);
408
409                        if (pValue)
410                                *pDemod = g_last_demod_type[id];
411                        else
412                                *pDemod = eDHL_DEMOD_INVALID;
413                }
414        } // id : 0
415       
416        return dhr;
417
418}
419
420
421
422DHL_RESULT dhl_s5h1411_get_device_info(tDHL_TunerID id, DHL_BOARD_REV rev, 
423        tDHL_TunerDeviceInfo selector, void *pValue)
424{
425        DHL_RESULT dhr = DHL_OK;
426       
427                if(id == 0)
428                {
429                        if(selector==eDHL_FE_DEV_VENDOR_NAME) {
430                                strcat((char *)pValue,"SS");
431                        }
432                        else if(selector==eDHL_FE_DEV_CAPABILITY_1) {
433                                UINT32 value = 0;
434                                value |= eDHL_TUCAP_VSB;
435                                value |= eDHL_TUCAP_QAM;
436                                //value |= eDHL_TUCAP_OOB;
437                                *(UINT32 *)pValue = value;
438                        }
439                        else {
440                                return DHL_FAIL_INVALID_PARAM;
441                        }       
442                }
443       
444                return dhr;
445
446
447
448}
449
450
451//ä³Îº¯°æ½Ã lock check ¿©ºÎ¹× ¼³Á¤
452static DHL_RESULT dhl_s5h1411_check_lock(tDHL_TunerID id, UINT32 *pValue)
453{
454        DHL_RESULT dhr = DHL_OK;
455        SSdtReturn_t nRet = SSDT_ERR_NO;
456        SSdtOperMode_t demod_SSDT;
457       
458        BOOL MasterLock = 0;
459        BOOL syncLock,VSBEqLock,VSBFecLock;
460        BOOL QAMFecLock,QAMEqLock;
461        BOOL returnLock =0;
462/*
463        if(g_last_demod_type[id] == eDHL_DEMOD_8VSB)
464                demod_SSDT = SSDT_VSB;
465        else if(g_last_demod_type[id] == eDHL_DEMOD_64QAM)
466                demod_SSDT = SSDT_QAM64;
467        else if(g_last_demod_type[id] == eDHL_DEMOD_256QAM)
468                demod_SSDT = SSDT_QAM256;
469        else
470        {                                               
471                dhr = DHL_FAIL;
472                goto err_exit;                 
473        }
474*/
475        //°¢ ¶ôÀÇ ¿ëµµ¸¦ ãÀÚ ÀÏ´Ü syncLock ¸¸ ³Ñ±âÀÚ
476       
477        syncLock = Sec_1411xSyncLock();
478
479//      DHL_OS_Printf("\n____ %d ____\n",syncLock);
480
481       
482        //      MasterLock = Sec_1411xVsbQAM_Master_Lock();
483
484/*
485        if(g_last_demod_type[id] == eDHL_DEMOD_8VSB)
486        {
487                syncLock = Sec_1411xSyncLock();
488                VSBEqLock = Sec_1411xVsbEqLock();
489                VSBFecLock = Sec_1411xVSBFecLock();
490        }
491        else if(g_last_demod_type[id] == eDHL_DEMOD_64QAM ||
492                g_last_demod_type[id] == eDHL_DEMOD_256QAM)
493        {
494                QAMFecLock = Sec_1411xQAMFec_Lock();
495                QAMEqLock = Sec_1411xQAMEq_Lock();
496        }
497        else
498        {
499                dhr = DHL_FAIL;
500                goto err_exit;
501        }
502*/
503//err_exit:
504
505
506        *pValue = syncLock;
507
508        return dhr;
509
510
511}
512
513
514static DHL_RESULT dhl_s5h1411_check_snr1000(tDHL_TunerID id, UINT32 *pValue)
515{
516        DHL_RESULT dhr = DHL_OK;
517    DATA_DOUBLE snrExt=0,p_data=0;
518        BOOL EQLock,FECLOCK;
519        BOOL MasterLock;
520                       
521        MasterLock = Sec_1411xVsbQAM_Master_Lock();
522
523        if(MasterLock)
524        {
525                snrExt = Sec_1411xVsbSnrResultCheck();
526                *pValue = snrExt * 1000;
527
528        }
529       
530
531
532        return dhr;
533
534}
535static DHL_RESULT dhl_s5h1411_check_ser(tDHL_TunerID id, UINT32 *pValue)
536{
537        DHL_RESULT dhr = DHL_OK;
538        DATA_DOUBLE ser = 0;
539
540        ser = S5H1411x_UncorrectableError();
541
542        *pValue = ser;
543       
544        return dhr;
545}
546
547
548
549#if COMMENT
550____Function____(){}
551#endif
552
553
554
555//LG3305 ¿Í´Â ´Ù¸£°Ô (LG´Â start ¿¡¼­ ·¹Áö½ºÅÍ  ¼¼ÆÃ -> ÃʱâÈ­½Ã ·¹Áö½ºÅÍ ¼¼ÆÃ ÇØÁÜ  //
556SSdtReturn_t s5h1411_init(DATA08 id, DATA08 hI2c, DATA08 i2cAddr)
557{
558
559        SSdtReturn_t nRet = SSDT_ERR_NO;
560        SSdtVersion_s api_ver;
561        I2C_STATUS check;
562
563        nRet = Sec_1411xRegReset();     //All register values to have default values-> initalize register
564
565        nRet = Sec_1411xInitialize();   //initalize the register value, and VSB mode is set as a default
566
567        //VSB Mode
568        nRet = Sec_1411xVsbMode();
569
570        //MPEG Mod setting
571        nRet = TS_Parallel_Set();       //sent out  check !!
572
573        //MPEG Timing Set
574        //¿ØÁö continuous/inverting ¹æ½Ä°°À½
575        nRet = Cont_Non_Invert_Set();
576//      nRet = Cont_Invert_Set();
577//      nRet = Non_Cont_Invert_Set();
578//      nRet = Cont_Non_Invert_Set();
579
580       
581err_exit:       
582
583        return nRet;
584
585}
586
587
Note: See TracBrowser for help on using the repository browser.