-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathr848a.c
5617 lines (4701 loc) · 172 KB
/
r848a.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//-----------------------------------------------------//
//
// Filename: R848.c
//
// This file is R848 tuner driver
// Copyright 2015 by Rafaelmicro., Inc.
// Author: Ryan Chang
//-----------------------------------------------------//
#include "r848a.h"
#define ADC_MULTI_READ 1
u32 ADC_READ_DELAY = 2;
u8 ADC_READ_COUNT = 1;
u8 VGA_DELAY = 2;
u8 FILTER_DELAY = 2;
#define dev_dbg(fmt, args...) \
do {\
if (debug)\
printk("R848: %s: " fmt, __func__, ##args);\
} while (0)
MODULE_PARM_DESC(debug, "\n\t\t Enable Rafael R848 tuner debug information");
static int debug;
module_param(debug, int, 0644);
//PLL LO=161MHz (R20:0x70 ; R24:0x70 ; R28:0x10 ; R29:0x00 ; R30:0x80)
u8 R848_iniArray_hybrid[R848_REG_NUM] = {
0x00, 0x00, 0x40, 0x44, 0x17, 0x00, 0x06, 0xF0, 0x00, 0x41,
// 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11
0x7B, 0x0B, 0x70, 0x0A, 0x6E, 0x20, 0x70, 0x87, 0x96, 0x00, //adr:0x19 from 0x83(1.05+-0.25) modify to 0x87 (1.4+-0.6)
// 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B
0x10, 0x00, 0x80, 0xA5, 0xB7, 0x00, 0x40, 0xCB, 0x95, 0x70,
// 0x1C 0x1D 0x1E 0x1F 0x20 0x21 0x22 0x23 0x24 0x25
0x24, 0x00, 0xFD, 0x8B, 0x17, 0x13, 0x01, 0x07, 0x01, 0x3F};
// 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F
u8 R848_iniArray_dvbs[R848_REG_NUM] = {
0x80, 0x05, 0x40, 0x40, 0x1F, 0x1F, 0x07, 0xFF, 0x00, 0x40,
// 0x08 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 0x11
0xF0, 0x0F, 0x4D, 0x0A, 0x6F, 0x20, 0x28, 0x87, 0x96, 0x00, //0x16[1] pulse_flag HPF : Bypass ; 0x19[1:0] Deglich SW Cur : highest
// 0x12 0x13 0x14 0x15 0x16 0x17 0x18 0x19 0x1A 0x1B
0x1C, 0x99, 0xC1, 0x83, 0xB7, 0x00, 0x4F, 0xCB, 0x95, 0x7D,
// 0x1C 0x1D 0x1E 0x1F 0x20 0x21 0x22 0x23 0x24 0x25
0xA4, 0x01, 0x24, 0x0B, 0x4F, 0x05, 0x01, 0x47, 0x3F, 0x3F};
// 0x26 0x27 0x28 0x29 0x2A 0x2B 0x2C 0x2D 0x2E 0x2F
u8 R848_ADDRESS = 0xF4;
u8 R848_XtalDiv = XTAL_DIV2;
u8 R848_SetTfType = R848_TF_BEAD; //Depend on HW
//u8 R848_SetTfType = R848_TF_82N_270N; //Depend on HW
u8 R848_DetectTfType = R848_UL_USING_BEAD;
//u8 R848_DetectTfType = R848_UL_USING_270NH;
u8 R848_Fil_Cal_Gap = 8;
u32 R848_IF_HIGH = 8500;
u8 R848_Xtal_Pwr = XTAL_SMALL_HIGHEST;
u8 R848_Xtal_Pwr_tmp = XTAL_LARGE_HIGHEST;
//----------------------------------------------------------//
// Internal Parameters //
//----------------------------------------------------------//
u8 R848_Array[40];
R848_SectType R848_IMR_Data[5] = {
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0},
{0, 0, 0, 0}
};//Please keep this array data for standby mode.
I2C_TYPE R848_I2C;
I2C_LEN_TYPE R848_I2C_Len;
I2C_LEN_TYPE Test_Len;
u8 R848_IMR_point_num;
u8 R848_Initial_done_flag = R848_FALSE;
u8 R848_Initial_xtal_check_flag = R848_FALSE;
u8 R848_IMR_done_flag = R848_FALSE;
u8 R848_Bandwidth = 0x00;
u8 R848_SATELLITE_FLAG = 0;
u8 R848_Fil_Cal_flag[R848_STD_SIZE];
static u8 R848_Fil_Cal_BW[R848_STD_SIZE];
static u8 R848_Fil_Cal_code[R848_STD_SIZE];
static u8 R848_IMR_Cal_Type = R848_IMR_CAL;
static R848_Standard_Type R848_pre_standard = R848_STD_SIZE;
static u32 R848_pre_DVBS_bw;
//0: L270n/68n(ISDB-T, DVB-T/T2)
//1: Bead/68n(DTMB)
//2: L270n/68n(N/A)
//3: L270n/68n(ATV)
//4: Bead/68n(DTMB+ATV)
//5: L270n/68n(ATSC, DVB-C, J83B)
//6: Bead/68n(ATSC, DVB-C, J83B)
//7: Bead/82n(R848_DTMB)
//8: L270n/82n(R848_DVB-C, J83B, ATSC, DVB-T/T2, ISDB-T)
u32 R848_LNA_HIGH_MID[R848_TF_SIZE] = { 644000, 644000, 644000, 644000, 644000, 500000, 500000, 500000, 500000};
u32 R848_LNA_MID_LOW[R848_TF_SIZE] = { 388000, 388000, 348000, 348000, 348000, 300000, 300000, 300000, 300000};
u32 R848_LNA_LOW_LOWEST[R848_TF_SIZE] = {164000, 164000, 148000, 124000, 124000, 156000, 156000, 108000, 108000};
u32 R848_TF_Freq_High[R848_TF_SIZE][R848_TF_HIGH_NUM] =
{ { 784000, 784000, 776000, 744000, 712000, 680000, 648000, 647000},
{ 784000, 784000, 776000, 744000, 712000, 680000, 648000, 647000},
{ 784000, 784000, 776000, 744000, 712000, 680000, 648000, 647000},
{ 784000, 784000, 776000, 744000, 712000, 680000, 648000, 647000},
{ 784000, 784000, 776000, 744000, 712000, 680000, 648000, 647000},
{ 784000, 784000, 776000, 680000, 608000, 584000, 536000, 504000},
{ 784000, 784000, 776000, 680000, 608000, 584000, 536000, 504000},
{ 784000, 776000, 712000, 616000, 584000, 560000, 520000, 504000},
{ 784000, 776000, 712000, 616000, 584000, 560000, 520000, 504000}
};
u32 R848_TF_Freq_Mid[R848_TF_SIZE][R848_TF_MID_NUM] =
{ {608000, 584000, 560000, 536000, 488000, 440000, 416000, 392000},
{608000, 584000, 560000, 536000, 488000, 440000, 416000, 392000},
{608000, 560000, 536000, 488000, 440000, 392000, 376000, 352000},
{608000, 560000, 536000, 488000, 440000, 392000, 376000, 352000},
{608000, 560000, 536000, 488000, 440000, 392000, 376000, 352000},
{488000, 464000, 440000, 416000, 392000, 352000, 320000, 304000},
{488000, 464000, 440000, 416000, 392000, 352000, 320000, 304000},
{480000, 464000, 440000, 416000, 392000, 352000, 320000, 304000},
{480000, 464000, 440000, 416000, 392000, 352000, 320000, 304000},
};
u32 R848_TF_Freq_Low[R848_TF_SIZE][R848_TF_LOW_NUM] =
{ {320000, 304000, 272000, 240000, 232000, 216000, 192000, 168000}, //164~388
{320000, 304000, 272000, 240000, 232000, 216000, 192000, 168000}, //164~388
{256000, 240000, 232000, 224000, 216000, 192000, 168000, 160000}, //148~348
{256000, 240000, 232000, 192000, 160000, 152000, 144000, 128000}, //124~348
{264000, 240000, 192000, 184000, 176000, 152000, 144000, 128000}, //124~348
{280000, 248000, 232000, 216000, 192000, 176000, 168000, 160000}, //156~300
{280000, 248000, 232000, 216000, 192000, 176000, 168000, 160000}, //156~300
{296000, 280000, 256000, 216000, 184000, 168000, 136000, 112000}, //
{296000, 280000, 256000, 216000, 184000, 168000, 136000, 112000} //
};
u32 R848_TF_Freq_Lowest[R848_TF_SIZE][R848_TF_LOWEST_NUM] =
{ {160000, 120000, 104000, 88000, 80000, 72000, 56000, 48000},
{160000, 120000, 104000, 88000, 80000, 72000, 56000, 48000},
{144000, 120000, 104000, 88000, 80000, 72000, 56000, 48000},
{120000, 96000, 88000, 80000, 72000, 64000, 56000, 48000},
{104000, 96000, 88000, 80000, 72000, 64000, 56000, 48000},
{136000, 120000, 104000, 88000, 72000, 64000, 56000, 48000},
{128000, 120000, 104000, 96000, 80000, 72000, 64000, 56000},
{104000, 96000, 88000, 80000, 72000, 64000, 56000, 48000},
{104000, 96000, 88000, 80000, 72000, 64000, 56000, 48000}
};
u8 R848_TF_Result_High[R848_TF_SIZE][R848_TF_HIGH_NUM] =
{ {0x00, 0x00, 0x01, 0x03, 0x04, 0x05, 0x07, 0x07},
{0x00, 0x00, 0x01, 0x03, 0x04, 0x05, 0x07, 0x07},
{0x00, 0x00, 0x01, 0x03, 0x04, 0x05, 0x07, 0x07},
{0x00, 0x00, 0x01, 0x03, 0x04, 0x05, 0x07, 0x07},
{0x00, 0x00, 0x01, 0x03, 0x04, 0x05, 0x07, 0x07},
{0x00, 0x00, 0x01, 0x05, 0x0A, 0x0C, 0x13, 0x19},
{0x00, 0x00, 0x01, 0x05, 0x0A, 0x0C, 0x13, 0x19},
{0x00, 0x03, 0x07, 0x0C, 0x0E, 0x0F, 0x16, 0x1A},
{0x00, 0x03, 0x07, 0x0C, 0x0E, 0x0F, 0x16, 0x1A}
};
u8 R848_TF_Result_Mid[R848_TF_SIZE][R848_TF_MID_NUM] =
{ {0x00, 0x01, 0x03, 0x03, 0x06, 0x0B, 0x0E, 0x11},
{0x00, 0x01, 0x03, 0x03, 0x06, 0x0B, 0x0E, 0x11},
{0x00, 0x03, 0x03, 0x06, 0x0B, 0x11, 0x12, 0x19},
{0x00, 0x03, 0x03, 0x06, 0x0B, 0x11, 0x12, 0x19},
{0x00, 0x03, 0x03, 0x06, 0x0B, 0x11, 0x12, 0x19},
{0x06, 0x08, 0x0B, 0x0E, 0x13, 0x17, 0x1E, 0x1F},
{0x06, 0x08, 0x0B, 0x0E, 0x13, 0x17, 0x1E, 0x1F},
{0x09, 0x0D, 0x10, 0x12, 0x16, 0x1B, 0x1E, 0x1F},
{0x09, 0x0D, 0x10, 0x12, 0x16, 0x1B, 0x1E, 0x1F}
};
u8 R848_TF_Result_Low[R848_TF_SIZE][R848_TF_LOW_NUM] =
{ {0x00, 0x02, 0x04, 0x07, 0x0A, 0x0B, 0x0F, 0x16},
{0x00, 0x02, 0x04, 0x07, 0x0A, 0x0B, 0x0F, 0x16},
{0x05, 0x07, 0x0A, 0x0B, 0x0B, 0x0F, 0x16, 0x1A},
{0x05, 0x07, 0x0A, 0x0F, 0x1A, 0x1A, 0x23, 0x2A},
{0x05, 0x08, 0x10, 0x13, 0x1A, 0x1A, 0x23, 0x2A},
{0x05, 0x08, 0x0C, 0x0E, 0x10, 0x14, 0x18, 0x1A},
{0x05, 0x08, 0x0C, 0x0E, 0x10, 0x14, 0x18, 0x1A},
{0x00, 0x01, 0x03, 0x07, 0x0D, 0x11, 0x1E, 0x2F},
{0x00, 0x01, 0x03, 0x07, 0x0D, 0x11, 0x1E, 0x2F}
};
u8 R848_TF_Result_Lowest[R848_TF_SIZE][R848_TF_LOWEST_NUM] =
{ {0x00, 0x06, 0x0C, 0x15, 0x1C, 0x1F, 0x3C, 0x3F},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x08},
{0x02, 0x06, 0x0C, 0x15, 0x1C, 0x1F, 0x3C, 0x3F},
{0x06, 0x11, 0x15, 0x1C, 0x1F, 0x2F, 0x3C, 0x3F},
{0x04, 0x08, 0x08, 0x08, 0x10, 0x12, 0x13, 0x13},
{0x06, 0x09, 0x0E, 0x18, 0x25, 0x2F, 0x3C, 0x3F},
{0x00, 0x04, 0x04, 0x08, 0x08, 0x10, 0x12, 0x13},
{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x08},
{0x0E, 0x14, 0x18, 0x1E, 0x25, 0x2F, 0x3C, 0x3F}
};
u8 R848_TF = 0;
//----------------------------------------------------------//
// Internal static struct //
//----------------------------------------------------------//
static R848_SysFreq_Info_Type SysFreq_Info1;
static R848_Sys_Info_Type Sys_Info1;
static R848_Freq_Info_Type Freq_Info1;
//----------------------------------------------------------//
// Internal Functions //
//----------------------------------------------------------//
R848_ErrCode R848_TF_Check(struct r848_priv *priv);
R848_ErrCode R848_Xtal_Check(struct r848_priv *priv);
R848_ErrCode R848_InitReg(struct r848_priv *priv, R848_Standard_Type R848_Standard);
R848_ErrCode R848_Cal_Prepare(struct r848_priv *priv, u8 u1CalFlag);
R848_ErrCode R848_IMR(struct r848_priv *priv, u8 IMR_MEM, BOOL IM_Flag);
R848_ErrCode R848_PLL(struct r848_priv *priv, u32 LO_Freq, R848_Standard_Type R848_Standard);
R848_ErrCode R848_MUX(struct r848_priv *priv, u32 LO_KHz, u32 RF_KHz, R848_Standard_Type R848_Standard);
R848_ErrCode R848_IQ(struct r848_priv *priv, R848_SectType* IQ_Pont);
R848_ErrCode R848_IQ_Tree(struct r848_priv *priv, u8 FixPot, u8 FlucPot, u8 PotReg, R848_SectType* CompareTree);
R848_ErrCode R848_CompreCor(struct r848_priv *priv, R848_SectType* CorArry);
R848_ErrCode R848_CompreStep(struct r848_priv *priv, R848_SectType* StepArry, u8 Pace);
R848_ErrCode R848_Muti_Read(struct r848_priv *priv, u8* IMR_Result_Data);
R848_ErrCode R848_Section(struct r848_priv *priv, R848_SectType* SectionArry);
R848_ErrCode R848_F_IMR(struct r848_priv *priv, R848_SectType* IQ_Pont);
R848_ErrCode R848_IMR_Cross(struct r848_priv *priv, R848_SectType* IQ_Pont, u8* X_Direct);
R848_ErrCode R848_IMR_Iqcap(struct r848_priv *priv, R848_SectType* IQ_Point);
R848_ErrCode R848_SetTF(struct r848_priv *priv, u32 u4FreqKHz, u8 u1TfType);
R848_ErrCode R848_SetStandard(struct r848_priv *priv, R848_Standard_Type RT_Standard);
R848_ErrCode R848_SetFrequency(struct r848_priv *priv, R848_Set_Info R848_INFO);
R848_ErrCode R848_DVBS_Setting(struct r848_priv *priv, R848_Set_Info R848_INFO);
R848_Sys_Info_Type R848_Sys_Sel(struct r848_priv *priv, R848_Standard_Type R848_Standard);
R848_Freq_Info_Type R848_Freq_Sel(struct r848_priv *priv, u32 LO_freq, u32 RF_freq, R848_Standard_Type R848_Standard);
R848_SysFreq_Info_Type R848_SysFreq_Sel(struct r848_priv *priv, R848_Standard_Type R848_Standard,u32 RF_freq);
u8 R848_Filt_Cal_ADC(struct r848_priv *priv, u32 IF_Freq, u8 R848_BW, u8 FilCal_Gap);
//---------------------------------------------------------------------------
// I2C functions
//---------------------------------------------------------------------------
int R848_Convert(int InvertNum)
{
int ReturnNum = 0;
int AddNum = 0x80;
int BitNum = 0x01;
int CuntNum = 0;
for(CuntNum = 0;CuntNum < 8;CuntNum ++)
{
if(BitNum & InvertNum)
ReturnNum += AddNum;
AddNum /= 2;
BitNum *= 2;
}
return ReturnNum;
}
int r848_i2c_readreg(struct r848_priv *priv, u8 *data, u16 size)
{
int ret;
struct i2c_msg msg[1] = {
{
.addr = priv->cfg->i2c_address,
.flags = I2C_M_RD,
.buf = data,
.len = size,
}
};
ret = i2c_transfer(priv->i2c, msg, 1);
if (ret == 1) {
ret = 0;
} else {
dev_dbg("i2c r848_i2c_readreg failed=%d\n", ret);
ret = -EREMOTEIO;
}
//dev_dbg("r848_i2c_readreg: data[0]=%d ret=%d size=%d\n", KBUILD_MODNAME, data[0], ret, size);//vit
return ret;
}
int r848_i2c_writereg(struct r848_priv *priv, u8 *data, u16 size)
{
int ret;
struct i2c_msg msg ={
.addr = priv->cfg->i2c_address,
.flags = 0, .buf = data, .len = size };
ret = i2c_transfer(priv->i2c, &msg, 1);
if (ret == 1) {
ret = 0;
} else {
dev_dbg("i2c r848_i2c_writereg failed=%d\n", ret);
ret = -EREMOTEIO;
}
//dev_dbg("r848_i2c_writereg: data[0]=%d ret=%d size=%d\n", KBUILD_MODNAME, data[0], ret, size);//vit
return ret;
}
bool I2C_Write_Len(struct r848_priv *priv, I2C_LEN_TYPE *R848_I2C_Len)
{
int ret = 0;
u8 buffer[64] = {0};
u16 i = 0;
u16 size = 0;
buffer[0] = R848_I2C_Len->RegAddr;
for(i = 0;i < R848_I2C_Len->Len; i++)
{
buffer[1+i] = R848_I2C_Len->Data[i];
}
size = R848_I2C_Len->Len+1;
ret = r848_i2c_writereg(priv, buffer, size);
//dev_dbg("I2C_Write_Len: ret=%d buffer[0]=%d size=%d\n", KBUILD_MODNAME, ret, buffer[0], size);//vit
if (ret)
return false;
else
return true;
}
bool I2C_Write(struct r848_priv *priv, I2C_TYPE *R848_I2C)
{
int ret = 0;
I2C_LEN_TYPE i2c_para;
i2c_para.RegAddr = R848_I2C->RegAddr;
i2c_para.Data[0] = R848_I2C->Data;
i2c_para.Len = 1;
if (I2C_Write_Len(priv,&i2c_para) != true)
{
return false;
}
return true;
}
bool I2C_Read_Len(struct r848_priv *priv, I2C_LEN_TYPE *R848_I2C_Len)
{
int ret = 0;
u8 buffer[64] = {0};
u16 i = 0;
u16 size = 0;
size = R848_I2C_Len->Len;
ret = r848_i2c_readreg(priv, buffer, size);
if (ret)
return false;
for(i = 0;i < size;i++)
{
R848_I2C_Len->Data[i] = R848_Convert(buffer[i]);
}
//dev_dbg("I2C_Read_Len: ret=%d buffer[0]=%d size=%d\n", KBUILD_MODNAME, ret, buffer[0], size);//vit
return true;
}
//---------------------------------------------------------------------------
// Lock status
//---------------------------------------------------------------------------
int R848_GetLockStatus(struct r848_priv *priv)
{
int ret;
I2C_LEN_TYPE i2c_para;
i2c_para.RegAddr = 0x00;
i2c_para.Len = 3;
if(I2C_Read_Len(priv, &i2c_para) != RT_Success)
{
dev_dbg("i2c R848_GetLockStatus failed!\n");
ret = -EREMOTEIO;
}
if ((i2c_para.Data[2] & 0x40) == 0x00)
ret = 1; //tuner unlock
else
ret = 0; //tuner lock
dev_dbg("R848_GETLOCKSTATUS=0x%x\n", i2c_para.Data[2]);
return ret;
}
//---------------------------------------------------------------------------
// Read regs for debug only
//---------------------------------------------------------------------------
int R848_ReadReg(struct r848_priv *priv)
{
I2C_LEN_TYPE i2c_para;
int i, index = 47;
i2c_para.RegAddr = 0x00;
i2c_para.Len = 48;
if(I2C_Read_Len(priv, &i2c_para) != RT_Success)
{
return 1;
}
printk("print Reg value start!\n");
for(i = 0; i<=index; i++)
{
printk("0x%X\n",i2c_para.Data[i]);
}
printk("print Reg value end!\n");
return 0;
}
//-----------------------------------------------------------------------------------------------------------------------------
R848_Sys_Info_Type R848_Sys_Sel(struct r848_priv *priv, R848_Standard_Type R848_Standard)
{
R848_Sys_Info_Type R848_Sys_Info;
switch (R848_Standard)
{
case R848_MN_5100:
R848_Sys_Info.IF_KHz=5100; //IF
R848_Sys_Info.BW=0x60; //BW=6M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=6050; //CAL IF
R848_Sys_Info.HPF_COR=0x0F; //R11[3:0]=15 R848:R19[3:0]
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable R848:R19[4]
R848_Sys_Info.FILT_EXT_WIDEST=0x00; //R30[2]=0, ext normal R848:R38[2]
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 R848:R38[1:0]
break;
case R848_MN_5800:
R848_Sys_Info.IF_KHz=5800; //IF
R848_Sys_Info.BW=0x40; //BW=7M R11[6:5] R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=6800; //CAL IF (%)
R848_Sys_Info.HPF_COR=0x0A; //R11[3:0]=10 (%) R848:R19[3:0]
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable R848:R19[4]
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal R848:R38[2]
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 R848:R38[1:0]
break;
case R848_MN_CIF_5M:
R848_Sys_Info.IF_KHz=6750; //IF
R848_Sys_Info.BW=0x40; //BW=7M
R848_Sys_Info.FILT_CAL_IF=7750; //CAL IF
R848_Sys_Info.HPF_COR=0x05; //R11[3:0]=5 (2M)
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 & Buf 4, hpf+1
break;
case R848_PAL_I:
R848_Sys_Info.IF_KHz=7300; //IF
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8650; //CAL IF
R848_Sys_Info.HPF_COR=0x0D; //R11[3:0]=13
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1
break;
case R848_PAL_I_CIF_5M:
R848_Sys_Info.IF_KHz=7750; //IF
R848_Sys_Info.BW=0x00; //BW=8M
R848_Sys_Info.FILT_CAL_IF=9100; //CAL IF
R848_Sys_Info.HPF_COR=0x09; //R11[3:0]=9 (1.15M)
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 & Buf 4, hpf+1
break;
case R848_PAL_DK:
R848_Sys_Info.IF_KHz=7300; //IF
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8500; //CAL IF
R848_Sys_Info.HPF_COR=0x0D; //R11[3:0]=13
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1
break;
case R848_PAL_DK_CIF_5M:
R848_Sys_Info.IF_KHz=7750; //IF
R848_Sys_Info.BW=0x00; //BW=8M
R848_Sys_Info.FILT_CAL_IF=8950; //CAL IF
R848_Sys_Info.HPF_COR=0x09; //R11[3:0]=9 (1.15M)
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 & Buf 4, hpf+1
break;
case R848_PAL_B_7M:
R848_Sys_Info.IF_KHz=6600; //IF
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7800; //CAL IF
//R848_Sys_Info.HPF_COR=0x0D; //R11[3:0]=13
R848_Sys_Info.HPF_COR=0x0A; //R11[3:0]=10 (0.9M)
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1
break;
case R848_PAL_B_7M_CIF_5M:
R848_Sys_Info.IF_KHz=7250; //IF
R848_Sys_Info.BW=0x00; //BW=8M
R848_Sys_Info.FILT_CAL_IF=8450; //CAL IF
R848_Sys_Info.HPF_COR=0x08; //R11[3:0]=8 (1.45M)
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 & Buf 4, hpf+1
break;
case R848_PAL_BGH_8M:
R848_Sys_Info.IF_KHz=6600; //IF
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7800; //CAL IF
R848_Sys_Info.HPF_COR=0x0D; //R11[3:0]=13
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1
break;
case R848_PAL_BGH_8M_CIF_5M:
R848_Sys_Info.IF_KHz=7750; //IF
R848_Sys_Info.BW=0x00; //BW=8M
R848_Sys_Info.FILT_CAL_IF=8950; //CAL IF
R848_Sys_Info.HPF_COR=0x09; //R11[3:0]=9 (1.15M)
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 & Buf 4, hpf+1
break;
case R848_SECAM_L:
R848_Sys_Info.IF_KHz=7300; //IF
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8550; //CAL IF
R848_Sys_Info.HPF_COR=0x0D; //R11[3:0]=13
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1
break;
case R848_SECAM_L_CIF_5M:
R848_Sys_Info.IF_KHz=7750; //IF
R848_Sys_Info.BW=0x00; //BW=8M
R848_Sys_Info.FILT_CAL_IF=8950; //CAL IF
R848_Sys_Info.HPF_COR=0x09; //R11[3:0]=9 (1.15M)
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 & Buf 4, hpf+1
break;
case R848_SECAM_L1:
R848_Sys_Info.IF_KHz=1320; //IF
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8050; //CAL IF
R848_Sys_Info.HPF_COR=0x0F; //R11[3:0]=13
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1
break;
case R848_SECAM_L1_CIF_5M:
R848_Sys_Info.IF_KHz=2250; //IF
R848_Sys_Info.BW=0x00; //BW=8M
R848_Sys_Info.FILT_CAL_IF=8950; //CAL IF
R848_Sys_Info.HPF_COR=0x09; //R11[3:0]=9 (1.15M)
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 & Buf 4, hpf+1
break;
case R848_SECAM_L1_INV:
R848_Sys_Info.IF_KHz=7300; //IF
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8550; //CAL IF
R848_Sys_Info.HPF_COR=0x0D; //R11[3:0]=13
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1
break;
case R848_SECAM_L1_INV_CIF_5M:
R848_Sys_Info.IF_KHz=7750; //IF
R848_Sys_Info.BW=0x00; //BW=8M
R848_Sys_Info.FILT_CAL_IF=8950; //CAL IF
R848_Sys_Info.HPF_COR=0x09; //R11[3:0]=9 (1.15M)
R848_Sys_Info.FILT_EXT_ENA=0x00; //R11[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R30[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R30[1:0]=0, lna=max-1 & Buf 4, hpf+1
break;
case R848_DVB_T_6M:
case R848_DVB_T2_6M:
R848_Sys_Info.IF_KHz=4570; //IF
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7450; //CAL IF
R848_Sys_Info.HPF_COR=0x05; //R19[3:0]=5
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x03; //R38[1:0]=11, buf 8
break;
case R848_DVB_T_7M:
case R848_DVB_T2_7M:
R848_Sys_Info.IF_KHz=4570; //IF
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7750; //CAL IF
R848_Sys_Info.HPF_COR=0x08; //R19[3:0]=8 (1.45M)
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x03; //R38[1:0]=11, buf 8
break;
case R848_DVB_T_8M:
case R848_DVB_T2_8M:
R848_Sys_Info.IF_KHz=4570; //IF
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8730; //CAL IF
R848_Sys_Info.HPF_COR=0x0B; //R19[3:0]=11
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x03; //R38[1:0]=11, buf 8
break;
case R848_DVB_T2_1_7M:
R848_Sys_Info.IF_KHz=1900;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7800; //CAL IF
R848_Sys_Info.HPF_COR=0x08; //R19[3:0]=8
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_DVB_T2_10M:
R848_Sys_Info.IF_KHz=5600;
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=10800; //CAL IF
R848_Sys_Info.HPF_COR=0x0C; //R19[3:0]=12
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_DVB_C_8M:
#if (FOR_TDA10024==1)
R848_Sys_Info.IF_KHz=5070;
R848_Sys_Info.BW=0x00; //BW=8M R11[6:5]
R848_Sys_Info.FILT_CAL_IF=9200; //CAL IF //8750
R848_Sys_Info.HPF_COR=0x0A; //R19[3:0]=10
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=1, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x02; //R38[1:0]=10, lna=max-1 & Buf 4
#else
R848_Sys_Info.IF_KHz=5070;
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=9000; //CAL IF //9150
R848_Sys_Info.HPF_COR=0x0A; //R19[3:0]=10
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x02; //R38[1:0]=10, lna=max-1 & Buf 4
#endif
break;
case R848_DVB_C_6M:
R848_Sys_Info.IF_KHz=5070;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8025; //CAL IF
R848_Sys_Info.HPF_COR=0x03; //R19[3:0]=3 //3
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_J83B:
R848_Sys_Info.IF_KHz=5070;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8025; //CAL IF
R848_Sys_Info.HPF_COR=0x03; //R19[3:0]=3 //3
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_ISDB_T:
R848_Sys_Info.IF_KHz=4063;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7000; //CAL IF //7200
R848_Sys_Info.HPF_COR=0x08; //R19[3:0]=8
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x03; //R38[1:0]=11, buf 8
break;
case R848_ISDB_T_4570:
R848_Sys_Info.IF_KHz=4570; //IF
R848_Sys_Info.BW=0x40; //BW=7M
R848_Sys_Info.FILT_CAL_IF=7250; //CAL IF
R848_Sys_Info.HPF_COR=0x05; //R19[3:0]=5 (2.0M)
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x03; //R38[1:0]=11, buf 8, hpf+3
break;
case R848_DTMB_4570:
R848_Sys_Info.IF_KHz=4570;
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8330; //CAL IF //8130
R848_Sys_Info.HPF_COR=0x0B; //R19[3:0]=11
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_DTMB_6000:
R848_Sys_Info.IF_KHz=6000;
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=9550;//9650; 2015-07-23 //CAL IF
R848_Sys_Info.HPF_COR=0x03;//0x05;2015-07-23 //R19[3:0]=3
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x02; //R38[1:0]=10, lna=max-1 & Buf 4
break;
case R848_DTMB_6M_BW_IF_5M:
R848_Sys_Info.IF_KHz=5000;
R848_Sys_Info.BW=0x40; //BW=7M
R848_Sys_Info.FILT_CAL_IF=7700; //CAL IF
R848_Sys_Info.HPF_COR=0x04; //R19[3:0]=4
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1 & Buf 4, hpf+1
break;
case R848_DTMB_6M_BW_IF_4500:
R848_Sys_Info.IF_KHz=4500;
R848_Sys_Info.BW=0x40; //BW=7M
R848_Sys_Info.FILT_CAL_IF=7000; //CAL IF
R848_Sys_Info.HPF_COR=0x05; //R19[3:0]=5
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x02; //R38[1:0]=10, lna=max-1 & Buf 4, hpf+3
break;
case R848_ATSC:
R848_Sys_Info.IF_KHz=5070;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7900; //CAL IF 20130621 Ryan Modify
R848_Sys_Info.HPF_COR=0x04; //R19[3:0]=4
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_DVB_T_6M_IF_5M:
case R848_DVB_T2_6M_IF_5M:
R848_Sys_Info.IF_KHz=5000; //IF
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7800; //CAL IF
R848_Sys_Info.HPF_COR=0x04; //R19[3:0]=4
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x03; //R38[1:0]=11, buf 8
break;
case R848_DVB_T_7M_IF_5M:
case R848_DVB_T2_7M_IF_5M:
R848_Sys_Info.IF_KHz=5000; //IF
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8300; //CAL IF
R848_Sys_Info.HPF_COR=0x07; //R19[3:0]=7
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x03; //R38[1:0]=11, buf 8
break;
case R848_DVB_T_8M_IF_5M:
case R848_DVB_T2_8M_IF_5M:
R848_Sys_Info.IF_KHz=5000; //IF
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=9000; //CAL IF
R848_Sys_Info.HPF_COR=0x09; //R19[3:0]=9
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=1, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x03; //R38[1:0]=11, buf 8
break;
case R848_DVB_T2_1_7M_IF_5M:
R848_Sys_Info.IF_KHz=5000;
R848_Sys_Info.BW=0x60; //BW=6M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=5900; //CAL IF
R848_Sys_Info.HPF_COR=0x01; //R19[3:0]=1
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_DVB_C_8M_IF_5M:
// case R848_DVB_C_CHINA_IF_5M: //RF>115MHz
R848_Sys_Info.IF_KHz=5000;
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=9000; //CAL IF
R848_Sys_Info.HPF_COR=0x0A; //R19[3:0]=10
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x02; //R38[1:0]=10, lna=max-1 & Buf 4
break;
case R848_DVB_C_6M_IF_5M:
R848_Sys_Info.IF_KHz=5000;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8100; //CAL IF
R848_Sys_Info.HPF_COR=0x04; //R19[3:0]=4
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_J83B_IF_5M:
R848_Sys_Info.IF_KHz=5000;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8025; //CAL IF
R848_Sys_Info.HPF_COR=0x03; //R19[3:0]=3
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_ISDB_T_IF_5M:
R848_Sys_Info.IF_KHz=5000;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7940; //CAL IF
R848_Sys_Info.HPF_COR=0x04; //R19[3:0]=4
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x03; //R38[1:0]=11, buf 8
break;
case R848_DTMB_IF_5M:
R848_Sys_Info.IF_KHz=5000;
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8650;//8825;2015-7-23 //CAL IF 8650 2015-07-06 //2015-07-10 9000
R848_Sys_Info.HPF_COR=0x09;//0x0B;2015-7-23 //R19[3:0]=9
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x02; //R38[1:0]=0, lna=max-1
break;
case R848_ATSC_IF_5M:
R848_Sys_Info.IF_KHz=5000;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7900; //CAL IF
R848_Sys_Info.HPF_COR=0x04; //R19[3:0]=4
R848_Sys_Info.FILT_EXT_ENA=0x00; //R19[4]=0, ext disable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
case R848_FM:
R848_Sys_Info.IF_KHz=2400;
R848_Sys_Info.BW=0x40; //BW=7M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=7200; //CAL IF
R848_Sys_Info.HPF_COR=0x02; //R19[3:0]=2
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
default: //R848_DVB_T_8M
R848_Sys_Info.IF_KHz=4570; //IF
R848_Sys_Info.BW=0x00; //BW=8M R848:R19[6:5]
R848_Sys_Info.FILT_CAL_IF=8330; //CAL IF
R848_Sys_Info.HPF_COR=0x0B; //R19[3:0]=11
R848_Sys_Info.FILT_EXT_ENA=0x10; //R19[4]=1, ext enable
R848_Sys_Info.FILT_EXT_WIDEST=0x00;//R38[2]=0, ext normal
R848_Sys_Info.FILT_EXT_POINT=0x00; //R38[1:0]=0, lna=max-1
break;
}
//Set By DTV/ATV
if (R848_Standard < R848_ATV_SIZE) //ATV
{
//R848_Sys_Info.INDUC_BIAS = 0x01; //normal (R4[0]=1)
R848_Sys_Info.SWCAP_CLK = 0x02; //8k // R848:R26[1:0]
R848_Sys_Info.NA_PWR_DET = 0x80; //off //R848:R38[7]
}
else
{
//R848_Sys_Info.INDUC_BIAS = 0x01; //normal
//R848_Sys_Info.SWCAP_CLK = 0x01; //32k
R848_Sys_Info.SWCAP_CLK = 0x02; //8k //AGC 500Hz map to 8k R26[1:0]
R848_Sys_Info.NA_PWR_DET = 0x00; //on R38[7]
}
#if(FOR_KOREA_CTMR==R848_TRUE)
if (R848_Standard < R848_ATV_SIZE) //ATV
{
R848_Sys_Info.SWBUF_CUR = 0x00; //high ( R12[2]=0)
R848_Sys_Info.FILT_CUR = 0x20; //high (R18[6:5]=2'b01)
}
else
{
R848_Sys_Info.SWBUF_CUR = 0x04; //low ( R12[2]=1)
R848_Sys_Info.FILT_CUR = 0x00; //highest (R18[6:5]=2'b00)
}
#else
R848_Sys_Info.SWBUF_CUR = 0x04; //low ( R12[2]=1)
R848_Sys_Info.FILT_CUR = 0x00; //highest (R18[6:5]=2'b00)
#endif
R848_Sys_Info.TF_CUR = 0x40; //low R11[6]=1
switch(R848_Standard)
{
case R848_DTMB_4570:
case R848_DTMB_6000:
case R848_DTMB_6M_BW_IF_5M:
case R848_DTMB_6M_BW_IF_4500:
case R848_DTMB_IF_5M:
R848_Sys_Info.FILT_COMP = 0x00; //0 R38[6:5]
break;
default:
R848_Sys_Info.FILT_COMP = 0x20; //1 R38[6:5]
break;
}
//Filter 3dB
switch(R848_Standard)
{
case R848_DVB_C_8M_IF_5M:
R848_Sys_Info.FILT_3DB = 0x08; // ON R38[3]
break;
default:
R848_Sys_Info.FILT_3DB = 0x00; // OFF R38[3]
break;
}
//BW 1.7M
if((R848_Standard==R848_DVB_T2_1_7M) || (R848_Standard==R848_FM))
R848_Sys_Info.V17M = 0x80; //enable, R19[7]
else
R848_Sys_Info.V17M = 0x00; //disable, (include DVBT2 1.7M IF=5MHz) R19[7]
//TF Type select
switch(R848_Standard)
{
case R848_MN_5100:
case R848_MN_5800:
case R848_PAL_I:
case R848_PAL_DK:
case R848_PAL_B_7M:
case R848_PAL_BGH_8M:
case R848_SECAM_L:
case R848_SECAM_L1:
case R848_SECAM_L1_INV:
case R848_MN_CIF_5M:
case R848_PAL_I_CIF_5M:
case R848_PAL_DK_CIF_5M:
case R848_PAL_B_7M_CIF_5M:
case R848_PAL_BGH_8M_CIF_5M:
case R848_SECAM_L_CIF_5M:
case R848_SECAM_L1_CIF_5M:
case R848_SECAM_L1_INV_CIF_5M:
if(R848_DetectTfType == R848_UL_USING_BEAD )
{
R848_SetTfType = R848_TF_82N_BEAD;
}
else
{
R848_SetTfType = R848_TF_82N_270N;
}
break;
case R848_DTMB_4570:
case R848_DTMB_6000:
case R848_DTMB_6M_BW_IF_5M:
case R848_DTMB_6M_BW_IF_4500:
case R848_DTMB_IF_5M:
if(R848_DetectTfType == R848_UL_USING_BEAD )
{
R848_SetTfType = R848_TF_82N_BEAD;
}
else
{
R848_SetTfType = R848_TF_82N_270N;