aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Toth <stoth@hauppauge.com>2008-05-01 03:57:01 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-05-14 01:56:33 -0400
commit52c99bda04d8bb1fb390821695b0f9efc1e1db44 (patch)
tree32848f7543334e688e28d5b513d5de7c4702c8c6
parente4671b6bc0b5b488adc5acbcfcbfa6661abec94e (diff)
V4L/DVB (7862): Add mxl5505s driver for MaxiLinear 5505 chipsets
Initial check-in of the original driver to establish history. Signed-off-by: Chia-Ling Lu Developer <chialing@realtek.com.tw> Signed-off-by: Steven Toth <stoth@hauppauge.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r--drivers/media/common/tuners/mxl5005s.c4989
-rw-r--r--drivers/media/common/tuners/mxl5005s.h718
2 files changed, 5707 insertions, 0 deletions
diff --git a/drivers/media/common/tuners/mxl5005s.c b/drivers/media/common/tuners/mxl5005s.c
new file mode 100644
index 000000000000..a32475fa1472
--- /dev/null
+++ b/drivers/media/common/tuners/mxl5005s.c
@@ -0,0 +1,4989 @@
1/*
2 * For the Realtek RTL chip RTL2831U
3 * Realtek Release Date: 2008-03-14, ver 080314
4 * Realtek version RTL2831 Linux driver version 080314
5 * ver 080314
6 *
7 * for linux kernel version 2.6.21.4 - 2.6.22-14
8 * support MXL5005s and MT2060 tuners (support tuner auto-detecting)
9 * support two IR types -- RC5 and NEC
10 *
11 * Known boards with Realtek RTL chip RTL2821U
12 * Freecom USB stick 14aa:0160 (version 4)
13 * Conceptronic CTVDIGRCU
14 *
15 * Copyright (c) 2008 Realtek
16 * Copyright (c) 2008 Jan Hoogenraad, Barnaby Shearer, Andy Hasper
17 * This code is placed under the terms of the GNU General Public License
18 *
19 * Released by Realtek under GPLv2.
20 * Thanks to Realtek for a lot of support we received !
21 *
22 * Revision: 080314 - original version
23 */
24
25
26/**
27
28@file
29
30@brief MxL5005S tuner module definition
31
32One can manipulate MxL5005S tuner through MxL5005S module.
33MxL5005S module is derived from tuner module.
34
35*/
36
37
38#include "tuner_mxl5005s.h"
39#include "tuner_demod_io.h"
40
41
42
43
44
45
46/**
47
48@defgroup MXL5005S_TUNER_MODULE MxL5005S tuner module
49
50MxL5005S tuner module is drived from tuner base module.
51
52@see TUNER_BASE_MODULE
53
54*/
55
56
57
58
59
60/**
61
62@defgroup MXL5005S_MODULE_BUILDER MxL5005S module builder
63@ingroup MXL5005S_TUNER_MODULE
64
65One should call MxL5005S module builder before using MxL5005S module.
66
67*/
68/// @{
69
70
71
72
73
74/**
75
76@brief MxL5005S tuner module builder
77
78Use BuildMxl5005sModule() to build MxL5005S module, set all module function pointers with the corresponding functions,
79and initialize module private variables.
80
81
82@param [in] ppTuner Pointer to MxL5005S tuner module pointer
83@param [in] pTunerModuleMemory Pointer to an allocated tuner module memory
84@param [in] pMxl5005sExtraModuleMemory Pointer to an allocated MxL5005S extra module memory
85@param [in] pI2cBridgeModuleMemory Pointer to an allocated I2C bridge module memory
86@param [in] DeviceAddr MxL5005S I2C device address
87@param [in] CrystalFreqHz MxL5005S crystal frequency in Hz
88
89
90@note \n
91 -# One should call BuildMxl5005sModule() to build MxL5005S module before using it.
92
93*/
94void
95BuildMxl5005sModule(
96 TUNER_MODULE **ppTuner,
97 TUNER_MODULE *pTunerModuleMemory,
98 MXL5005S_EXTRA_MODULE *pMxl5005sExtraModuleMemory,
99 BASE_INTERFACE_MODULE *pBaseInterfaceModuleMemory,
100 I2C_BRIDGE_MODULE *pI2cBridgeModuleMemory,
101 unsigned char DeviceAddr,
102 int StandardMode
103 )
104{
105 MXL5005S_EXTRA_MODULE *pExtra;
106
107 int MxlModMode;
108 int MxlIfMode;
109 unsigned long MxlBandwitdh;
110 unsigned long MxlIfFreqHz;
111 unsigned long MxlCrystalFreqHz;
112 int MxlAgcMode;
113 unsigned short MxlTop;
114 unsigned short MxlIfOutputLoad;
115 int MxlClockOut;
116 int MxlDivOut;
117 int MxlCapSel;
118 int MxlRssiOnOff;
119 unsigned char MxlStandard;
120 unsigned char MxlTfType;
121
122
123
124 // Set tuner module pointer, tuner extra module pointer, and I2C bridge module pointer.
125 *ppTuner = pTunerModuleMemory;
126 (*ppTuner)->pExtra = pMxl5005sExtraModuleMemory;
127 (*ppTuner)->pBaseInterface = pBaseInterfaceModuleMemory;
128 (*ppTuner)->pI2cBridge = pI2cBridgeModuleMemory;
129
130 // Get tuner extra module pointer.
131 pExtra = (MXL5005S_EXTRA_MODULE *)(*ppTuner)->pExtra;
132
133
134 // Set I2C bridge tuner arguments.
135 mxl5005s_SetI2cBridgeModuleTunerArg(*ppTuner);
136
137
138 // Set tuner module manipulating function pointers.
139 (*ppTuner)->SetDeviceAddr = mxl5005s_SetDeviceAddr;
140
141 (*ppTuner)->GetTunerType = mxl5005s_GetTunerType;
142 (*ppTuner)->GetDeviceAddr = mxl5005s_GetDeviceAddr;
143
144 (*ppTuner)->Initialize = mxl5005s_Initialize;
145 (*ppTuner)->SetRfFreqHz = mxl5005s_SetRfFreqHz;
146 (*ppTuner)->GetRfFreqHz = mxl5005s_GetRfFreqHz;
147
148
149 // Set tuner extra module manipulating function pointers.
150 pExtra->SetRegsWithTable = mxl5005s_SetRegsWithTable;
151 pExtra->SetRegMaskBits = mxl5005s_SetRegMaskBits;
152 pExtra->SetSpectrumMode = mxl5005s_SetSpectrumMode;
153 pExtra->SetBandwidthHz = mxl5005s_SetBandwidthHz;
154
155
156 // Initialize tuner parameter setting status.
157 (*ppTuner)->IsDeviceAddrSet = NO;
158 (*ppTuner)->IsRfFreqHzSet = NO;
159
160
161 // Set MxL5005S parameters.
162 MxlModMode = MXL_DIGITAL_MODE;
163 MxlIfMode = MXL_ZERO_IF;
164 MxlBandwitdh = MXL5005S_BANDWIDTH_8MHZ;
165 MxlIfFreqHz = IF_FREQ_4570000HZ;
166 MxlCrystalFreqHz = CRYSTAL_FREQ_16000000HZ;
167 MxlAgcMode = MXL_SINGLE_AGC;
168 MxlTop = MXL5005S_TOP_25P2;
169 MxlIfOutputLoad = MXL5005S_IF_OUTPUT_LOAD_200_OHM;
170 MxlClockOut = MXL_CLOCK_OUT_DISABLE;
171 MxlDivOut = MXL_DIV_OUT_4;
172 MxlCapSel = MXL_CAP_SEL_ENABLE;
173 MxlRssiOnOff = MXL_RSSI_ENABLE;
174 MxlTfType = MXL_TF_C_H;
175
176
177 // Set MxL5005S parameters according to standard mode
178 switch(StandardMode)
179 {
180 default:
181 case MXL5005S_STANDARD_DVBT: MxlStandard = MXL_DVBT; break;
182 case MXL5005S_STANDARD_ATSC: MxlStandard = MXL_ATSC; break;
183 }
184
185
186 // Set MxL5005S extra module.
187 pExtra->AgcMasterByte = (MxlAgcMode == MXL_DUAL_AGC) ? 0x4 : 0x0;
188
189 MXL5005_TunerConfig(&pExtra->MxlDefinedTunerStructure, (unsigned char)MxlModMode, (unsigned char)MxlIfMode,
190 MxlBandwitdh, MxlIfFreqHz, MxlCrystalFreqHz, (unsigned char)MxlAgcMode, MxlTop, MxlIfOutputLoad,
191 (unsigned char)MxlClockOut, (unsigned char)MxlDivOut, (unsigned char)MxlCapSel, (unsigned char)MxlRssiOnOff,
192 MxlStandard, MxlTfType);
193
194
195
196 // Note: Need to set all module arguments before using module functions.
197
198
199 // Set tuner type.
200 (*ppTuner)->TunerType = TUNER_TYPE_MXL5005S;
201
202 // Set tuner I2C device address.
203 (*ppTuner)->SetDeviceAddr(*ppTuner, DeviceAddr);
204
205
206 return;
207}
208
209
210
211
212
213/// @}
214
215
216
217
218
219/**
220
221@defgroup MXL5005S_MANIPULATING_FUNCTIONS MxL5005S manipulating functions derived from tuner base module
222@ingroup MXL5005S_TUNER_MODULE
223
224One can use the MxL5005S tuner module manipulating interface implemented by MxL5005S manipulating functions to
225manipulate MxL5005S tuner.
226
227*/
228/// @{
229
230
231
232
233
234/**
235
236@brief Set MxL5005S tuner I2C device address.
237
238@note \n
239 -# MxL5005S tuner builder will set TUNER_FP_SET_DEVICE_ADDR() function pointer with mxl5005s_SetDeviceAddr().
240
241@see TUNER_FP_SET_DEVICE_ADDR
242
243*/
244void
245mxl5005s_SetDeviceAddr(
246 TUNER_MODULE *pTuner,
247 unsigned char DeviceAddr
248 )
249{
250 // Set tuner I2C device address.
251 pTuner->DeviceAddr = DeviceAddr;
252 pTuner->IsDeviceAddrSet = YES;
253
254
255 return;
256}
257
258
259
260
261
262/**
263
264@brief Get MxL5005S tuner type.
265
266@note \n
267 -# MxL5005S tuner builder will set TUNER_FP_GET_TUNER_TYPE() function pointer with mxl5005s_GetTunerType().
268
269@see TUNER_FP_GET_TUNER_TYPE
270
271*/
272void
273mxl5005s_GetTunerType(
274 TUNER_MODULE *pTuner,
275 int *pTunerType
276 )
277{
278 // Get tuner type from tuner module.
279 *pTunerType = pTuner->TunerType;
280
281
282 return;
283}
284
285
286
287
288
289/**
290
291@brief Get MxL5005S tuner I2C device address.
292
293@note \n
294 -# MxL5005S tuner builder will set TUNER_FP_GET_DEVICE_ADDR() function pointer with mxl5005s_GetDeviceAddr().
295
296@see TUNER_FP_GET_DEVICE_ADDR
297
298*/
299int
300mxl5005s_GetDeviceAddr(
301 TUNER_MODULE *pTuner,
302 unsigned char *pDeviceAddr
303 )
304{
305 // Get tuner I2C device address from tuner module.
306 if(pTuner->IsDeviceAddrSet != YES)
307 goto error_status_get_tuner_i2c_device_addr;
308
309 *pDeviceAddr = pTuner->DeviceAddr;
310
311
312 return FUNCTION_SUCCESS;
313
314
315error_status_get_tuner_i2c_device_addr:
316 return FUNCTION_ERROR;
317}
318
319
320
321
322
323/**
324
325@brief Initialize MxL5005S tuner.
326
327@note \n
328 -# MxL5005S tuner builder will set TUNER_FP_INITIALIZE() function pointer with mxl5005s_Initialize().
329
330@see TUNER_FP_INITIALIZE
331
332*/
333int
334mxl5005s_Initialize(
335 struct dvb_usb_device* dib,
336 TUNER_MODULE *pTuner
337 )
338{
339 MXL5005S_EXTRA_MODULE *pExtra;
340
341 unsigned char AgcMasterByte;
342 unsigned char AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
343 unsigned char ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
344 int TableLen;
345
346
347
348 // Get tuner extra module.
349 pExtra = (MXL5005S_EXTRA_MODULE *)pTuner->pExtra;
350
351
352 // Get AGC master byte
353 AgcMasterByte = pExtra->AgcMasterByte;
354
355
356 // Initialize MxL5005S tuner according to MxL5005S tuner example code.
357
358 // Tuner initialization stage 0
359 MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET);
360 AddrTable[0] = MASTER_CONTROL_ADDR;
361 ByteTable[0] |= AgcMasterByte;
362
363 if(pExtra->SetRegsWithTable( dib,pTuner, AddrTable, ByteTable, LEN_1_BYTE) != FUNCTION_SUCCESS)
364 goto error_status_set_tuner_registers;
365
366
367 // Tuner initialization stage 1
368 MXL_GetInitRegister(&pExtra->MxlDefinedTunerStructure, AddrTable, ByteTable, &TableLen);
369
370 if(pExtra->SetRegsWithTable( dib,pTuner, AddrTable, ByteTable, TableLen) != FUNCTION_SUCCESS)
371 goto error_status_set_tuner_registers;
372
373
374 return FUNCTION_SUCCESS;
375
376
377error_status_set_tuner_registers:
378 return FUNCTION_ERROR;
379}
380
381
382
383
384
385/**
386
387@brief Set MxL5005S tuner RF frequency in Hz.
388
389@note \n
390 -# MxL5005S tuner builder will set TUNER_FP_SET_RF_FREQ_HZ() function pointer with mxl5005s_SetRfFreqHz().
391
392@see TUNER_FP_SET_RF_FREQ_HZ
393
394*/
395int
396mxl5005s_SetRfFreqHz(
397 struct dvb_usb_device* dib,
398 TUNER_MODULE *pTuner,
399 unsigned long RfFreqHz
400 )
401{
402 MXL5005S_EXTRA_MODULE *pExtra;
403 BASE_INTERFACE_MODULE *pBaseInterface;
404
405 unsigned char AgcMasterByte;
406 unsigned char AddrTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
407 unsigned char ByteTable[MXL5005S_REG_WRITING_TABLE_LEN_MAX];
408 int TableLen;
409
410 unsigned long IfDivval;
411 unsigned char MasterControlByte;
412
413
414
415 // Get tuner extra module and base interface module.
416 pExtra = (MXL5005S_EXTRA_MODULE *)pTuner->pExtra;
417 pBaseInterface = pTuner->pBaseInterface;
418
419
420 // Get AGC master byte
421 AgcMasterByte = pExtra->AgcMasterByte;
422
423
424 // Set MxL5005S tuner RF frequency according to MxL5005S tuner example code.
425
426 // Tuner RF frequency setting stage 0
427 MXL_GetMasterControl(ByteTable, MC_SYNTH_RESET) ;
428 AddrTable[0] = MASTER_CONTROL_ADDR;
429 ByteTable[0] |= AgcMasterByte;
430
431 if(pExtra->SetRegsWithTable( dib,pTuner, AddrTable, ByteTable, LEN_1_BYTE) != FUNCTION_SUCCESS)
432 goto error_status_set_tuner_registers;
433
434
435 // Tuner RF frequency setting stage 1
436 MXL_TuneRF(&pExtra->MxlDefinedTunerStructure, RfFreqHz);
437
438 MXL_ControlRead(&pExtra->MxlDefinedTunerStructure, IF_DIVVAL, &IfDivval);
439
440 MXL_ControlWrite(&pExtra->MxlDefinedTunerStructure, SEQ_FSM_PULSE, 0);
441 MXL_ControlWrite(&pExtra->MxlDefinedTunerStructure, SEQ_EXTPOWERUP, 1);
442 MXL_ControlWrite(&pExtra->MxlDefinedTunerStructure, IF_DIVVAL, 8);
443
444 MXL_GetCHRegister(&pExtra->MxlDefinedTunerStructure, AddrTable, ByteTable, &TableLen) ;
445
446 MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START) ;
447 AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
448 ByteTable[TableLen] = MasterControlByte | AgcMasterByte;
449 TableLen += 1;
450
451 if(pExtra->SetRegsWithTable( dib,pTuner, AddrTable, ByteTable, TableLen) != FUNCTION_SUCCESS)
452 goto error_status_set_tuner_registers;
453
454
455 // Wait 30 ms.
456 pBaseInterface->WaitMs(pBaseInterface, 30);
457
458
459 // Tuner RF frequency setting stage 2
460 MXL_ControlWrite(&pExtra->MxlDefinedTunerStructure, SEQ_FSM_PULSE, 1) ;
461 MXL_ControlWrite(&pExtra->MxlDefinedTunerStructure, IF_DIVVAL, IfDivval) ;
462 MXL_GetCHRegister_ZeroIF(&pExtra->MxlDefinedTunerStructure, AddrTable, ByteTable, &TableLen) ;
463
464 MXL_GetMasterControl(&MasterControlByte, MC_LOAD_START) ;
465 AddrTable[TableLen] = MASTER_CONTROL_ADDR ;
466 ByteTable[TableLen] = MasterControlByte | AgcMasterByte ;
467 TableLen += 1;
468
469 if(pExtra->SetRegsWithTable( dib,pTuner, AddrTable, ByteTable, TableLen) != FUNCTION_SUCCESS)
470 goto error_status_set_tuner_registers;
471
472
473 // Set tuner RF frequency parameter.
474 pTuner->RfFreqHz = RfFreqHz;
475 pTuner->IsRfFreqHzSet = YES;
476
477
478 return FUNCTION_SUCCESS;
479
480
481error_status_set_tuner_registers:
482 return FUNCTION_ERROR;
483}
484
485
486
487
488
489/**
490
491@brief Get MxL5005S tuner RF frequency in Hz.
492
493@note \n
494 -# MxL5005S tuner builder will set TUNER_FP_GET_RF_FREQ_HZ() function pointer with mxl5005s_GetRfFreqHz().
495
496@see TUNER_FP_GET_RF_FREQ_HZ
497
498*/
499int
500mxl5005s_GetRfFreqHz(
501 struct dvb_usb_device* dib,
502 TUNER_MODULE *pTuner,
503 unsigned long *pRfFreqHz
504 )
505{
506 // Get tuner RF frequency in Hz from tuner module.
507 if(pTuner->IsRfFreqHzSet != YES)
508 goto error_status_get_tuner_rf_frequency;
509
510 *pRfFreqHz = pTuner->RfFreqHz;
511
512
513 return FUNCTION_SUCCESS;
514
515
516error_status_get_tuner_rf_frequency:
517 return FUNCTION_ERROR;
518}
519
520
521
522
523
524/**
525
526@brief Set MxL5005S tuner registers with table.
527
528*/
529/*
530int
531mxl5005s_SetRegsWithTable(
532 struct dvb_usb_device* dib,
533 TUNER_MODULE *pTuner,
534 unsigned char *pAddrTable,
535 unsigned char *pByteTable,
536 int TableLen
537 )
538{
539 BASE_INTERFACE_MODULE *pBaseInterface;
540 I2C_BRIDGE_MODULE *pI2cBridge;
541 unsigned char WritingByteNumMax;
542
543 int i;
544 unsigned char WritingBuffer[I2C_BUFFER_LEN];
545 unsigned char WritingIndex;
546
547
548
549 // Get base interface, I2C bridge, and maximum writing byte number.
550 pBaseInterface = pTuner->pBaseInterface;
551 pI2cBridge = pTuner->pI2cBridge;
552 WritingByteNumMax = pBaseInterface->I2cWritingByteNumMax;
553
554
555 // Set registers with table.
556 // Note: 1. The I2C format of MxL5005S is described as follows:
557 // start_bit + (device_addr | writing_bit) + (register_addr + writing_byte) * n + stop_bit
558 // ...
559 // start_bit + (device_addr | writing_bit) + (register_addr + writing_byte) * m + latch_byte + stop_bit
560 // 2. The latch_byte is 0xfe.
561 // 3. The following writing byte separating scheme takes latch_byte as two byte data.
562 for(i = 0, WritingIndex = 0; i < TableLen; i++)
563 {
564 // Put register address and register byte value into writing buffer.
565 WritingBuffer[WritingIndex] = pAddrTable[i];
566 WritingBuffer[WritingIndex + 1] = pByteTable[i];
567 WritingIndex += 2;
568
569 // If writing buffer is full, send the I2C writing command with writing buffer.
570 if(WritingIndex > (WritingByteNumMax - 2))
571 {
572 if(pI2cBridge->ForwardI2cWritingCmd(pI2cBridge, WritingBuffer, WritingIndex) != FUNCTION_SUCCESS)
573 goto error_status_set_tuner_registers;
574
575 WritingIndex = 0;
576 }
577 }
578
579
580 // Send the last I2C writing command with writing buffer and latch byte.
581 WritingBuffer[WritingIndex] = MXL5005S_LATCH_BYTE;
582 WritingIndex += 1;
583
584 if(pI2cBridge->ForwardI2cWritingCmd(pI2cBridge, WritingBuffer, WritingIndex) != FUNCTION_SUCCESS)
585 goto error_status_set_tuner_registers;
586
587
588 return FUNCTION_SUCCESS;
589
590
591error_status_set_tuner_registers:
592 return FUNCTION_ERROR;
593}
594*/
595
596
597int
598mxl5005s_SetRegsWithTable(
599 struct dvb_usb_device* dib,
600 TUNER_MODULE *pTuner,
601 unsigned char *pAddrTable,
602 unsigned char *pByteTable,
603 int TableLen
604 )
605{
606 int i;
607 u8 end_two_bytes_buf[]={ 0 , 0 };
608 u8 tuner_addr=0x00;
609
610 pTuner->GetDeviceAddr(pTuner , &tuner_addr);
611
612 for( i = 0 ; i < TableLen - 1 ; i++)
613 {
614 if ( TUNER_WI2C(dib , tuner_addr , pAddrTable[i] , &pByteTable[i] , 1 ) )
615 return FUNCTION_ERROR;
616 }
617
618 end_two_bytes_buf[0] = pByteTable[i];
619 end_two_bytes_buf[1] = MXL5005S_LATCH_BYTE;
620
621 if ( TUNER_WI2C(dib , tuner_addr , pAddrTable[i] , end_two_bytes_buf , 2 ) )
622 return FUNCTION_ERROR;
623
624 return FUNCTION_SUCCESS;
625}
626
627
628
629
630
631/**
632
633@brief Set MxL5005S tuner register bits.
634
635*/
636int
637mxl5005s_SetRegMaskBits(
638 struct dvb_usb_device* dib,
639 TUNER_MODULE *pTuner,
640 unsigned char RegAddr,
641 unsigned char Msb,
642 unsigned char Lsb,
643 const unsigned char WritingValue
644 )
645{
646 MXL5005S_EXTRA_MODULE *pExtra;
647
648 int i;
649
650 unsigned char Mask;
651 unsigned char Shift;
652
653 unsigned char RegByte;
654
655
656
657 // Get tuner extra module.
658 pExtra = (MXL5005S_EXTRA_MODULE *)pTuner->pExtra;
659
660
661 // Generate mask and shift according to MSB and LSB.
662 Mask = 0;
663 for(i = Lsb; i < (unsigned char)(Msb + 1); i++)
664 Mask |= 0x1 << i;
665
666 Shift = Lsb;
667
668
669 // Get tuner register byte according to register adddress.
670 MXL_RegRead(&pExtra->MxlDefinedTunerStructure, RegAddr, &RegByte);
671
672
673 // Reserve register byte unmask bit with mask and inlay writing value into it.
674 RegByte &= ~Mask;
675 RegByte |= (WritingValue << Shift) & Mask;
676
677
678 // Update tuner register byte table.
679 MXL_RegWrite(&pExtra->MxlDefinedTunerStructure, RegAddr, RegByte);
680
681
682 // Write tuner register byte with writing byte.
683 if(pExtra->SetRegsWithTable( dib, pTuner, &RegAddr, &RegByte, LEN_1_BYTE) != FUNCTION_SUCCESS)
684 goto error_status_set_tuner_registers;
685
686
687 return FUNCTION_SUCCESS;
688
689
690error_status_set_tuner_registers:
691 return FUNCTION_ERROR;
692}
693
694
695
696
697
698/**
699
700@brief Set MxL5005S tuner spectrum mode.
701
702*/
703int
704mxl5005s_SetSpectrumMode(
705 struct dvb_usb_device* dib,
706 TUNER_MODULE *pTuner,
707 int SpectrumMode
708 )
709{
710 static const unsigned char BbIqswapTable[SPECTRUM_MODE_NUM] =
711 {
712 // BB_IQSWAP
713 0, // Normal spectrum
714 1, // Inverse spectrum
715 };
716
717
718 MXL5005S_EXTRA_MODULE *pExtra;
719
720
721
722 // Get tuner extra module.
723 pExtra = (MXL5005S_EXTRA_MODULE *)pTuner->pExtra;
724
725
726 // Set BB_IQSWAP according to BB_IQSWAP table and spectrum mode.
727 if(pExtra->SetRegMaskBits(dib,pTuner, MXL5005S_BB_IQSWAP_ADDR, MXL5005S_BB_IQSWAP_MSB,
728 MXL5005S_BB_IQSWAP_LSB, BbIqswapTable[SpectrumMode]) != FUNCTION_SUCCESS)
729 goto error_status_set_tuner_registers;
730
731
732 return FUNCTION_SUCCESS;
733
734
735error_status_set_tuner_registers:
736 return FUNCTION_ERROR;
737}
738
739
740
741
742
743/**
744
745@brief Set MxL5005S tuner bandwidth in Hz.
746
747*/
748int
749mxl5005s_SetBandwidthHz(
750 struct dvb_usb_device* dib,
751 TUNER_MODULE *pTuner,
752 unsigned long BandwidthHz
753 )
754{
755 MXL5005S_EXTRA_MODULE *pExtra;
756
757 unsigned char BbDlpfBandsel;
758
759
760
761 // Get tuner extra module.
762 pExtra = (MXL5005S_EXTRA_MODULE *)pTuner->pExtra;
763
764
765 // Set BB_DLPF_BANDSEL according to bandwidth.
766 switch(BandwidthHz)
767 {
768 default:
769 case MXL5005S_BANDWIDTH_6MHZ: BbDlpfBandsel = 3; break;
770 case MXL5005S_BANDWIDTH_7MHZ: BbDlpfBandsel = 2; break;
771 case MXL5005S_BANDWIDTH_8MHZ: BbDlpfBandsel = 0; break;
772 }
773
774 if(pExtra->SetRegMaskBits(dib,pTuner, MXL5005S_BB_DLPF_BANDSEL_ADDR, MXL5005S_BB_DLPF_BANDSEL_MSB,
775 MXL5005S_BB_DLPF_BANDSEL_LSB, BbDlpfBandsel) != FUNCTION_SUCCESS)
776 goto error_status_set_tuner_registers;
777
778
779 return FUNCTION_SUCCESS;
780
781
782error_status_set_tuner_registers:
783 return FUNCTION_ERROR;
784}
785
786
787
788
789
790/// @}
791
792
793
794
795
796/**
797
798@defgroup MXL5005S_DEPENDENCE MxL5005S dependence
799@ingroup MXL5005S_TUNER_MODULE
800
801MxL5005S dependence is the related functions for MxL5005S tuner module interface.
802One should not use MxL5005S dependence directly.
803
804*/
805/// @{
806
807
808
809
810
811/**
812
813@brief Set I2C bridge module tuner arguments.
814
815MxL5005S builder will use mxl5005s_SetI2cBridgeModuleTunerArg() to set I2C bridge module tuner arguments.
816
817
818@param [in] pTuner The tuner module pointer
819
820
821@see BuildMxl5005sModule()
822
823*/
824void
825mxl5005s_SetI2cBridgeModuleTunerArg(
826 TUNER_MODULE *pTuner
827 )
828{
829 I2C_BRIDGE_MODULE *pI2cBridge;
830
831
832
833 // Get I2C bridge module.
834 pI2cBridge = pTuner->pI2cBridge;
835
836 // Set I2C bridge module tuner arguments.
837 pI2cBridge->pTunerDeviceAddr = &pTuner->DeviceAddr;
838
839
840 return;
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// The following context is source code provided by MaxLinear.
872
873
874
875
876
877// MaxLinear source code - MXL5005_Initialize.cpp
878
879
880
881//#ifdef _MXL_HEADER
882//#include "stdafx.h"
883//#endif
884//#include "MXL5005_c.h"
885
886_u16 MXL5005_RegisterInit (Tuner_struct * Tuner)
887{
888 Tuner->TunerRegs_Num = TUNER_REGS_NUM ;
889// Tuner->TunerRegs = (TunerReg_struct *) calloc( TUNER_REGS_NUM, sizeof(TunerReg_struct) ) ;
890
891 Tuner->TunerRegs[0].Reg_Num = 9 ;
892 Tuner->TunerRegs[0].Reg_Val = 0x40 ;
893
894 Tuner->TunerRegs[1].Reg_Num = 11 ;
895 Tuner->TunerRegs[1].Reg_Val = 0x19 ;
896
897 Tuner->TunerRegs[2].Reg_Num = 12 ;
898 Tuner->TunerRegs[2].Reg_Val = 0x60 ;
899
900 Tuner->TunerRegs[3].Reg_Num = 13 ;
901 Tuner->TunerRegs[3].Reg_Val = 0x00 ;
902
903 Tuner->TunerRegs[4].Reg_Num = 14 ;
904 Tuner->TunerRegs[4].Reg_Val = 0x00 ;
905
906 Tuner->TunerRegs[5].Reg_Num = 15 ;
907 Tuner->TunerRegs[5].Reg_Val = 0xC0 ;
908
909 Tuner->TunerRegs[6].Reg_Num = 16 ;
910 Tuner->TunerRegs[6].Reg_Val = 0x00 ;
911
912 Tuner->TunerRegs[7].Reg_Num = 17 ;
913 Tuner->TunerRegs[7].Reg_Val = 0x00 ;
914
915 Tuner->TunerRegs[8].Reg_Num = 18 ;
916 Tuner->TunerRegs[8].Reg_Val = 0x00 ;
917
918 Tuner->TunerRegs[9].Reg_Num = 19 ;
919 Tuner->TunerRegs[9].Reg_Val = 0x34 ;
920
921 Tuner->TunerRegs[10].Reg_Num = 21 ;
922 Tuner->TunerRegs[10].Reg_Val = 0x00 ;
923
924 Tuner->TunerRegs[11].Reg_Num = 22 ;
925 Tuner->TunerRegs[11].Reg_Val = 0x6B ;
926
927 Tuner->TunerRegs[12].Reg_Num = 23 ;
928 Tuner->TunerRegs[12].Reg_Val = 0x35 ;
929
930 Tuner->TunerRegs[13].Reg_Num = 24 ;
931 Tuner->TunerRegs[13].Reg_Val = 0x70 ;
932
933 Tuner->TunerRegs[14].Reg_Num = 25 ;
934 Tuner->TunerRegs[14].Reg_Val = 0x3E ;
935
936 Tuner->TunerRegs[15].Reg_Num = 26 ;
937 Tuner->TunerRegs[15].Reg_Val = 0x82 ;
938
939 Tuner->TunerRegs[16].Reg_Num = 31 ;
940 Tuner->TunerRegs[16].Reg_Val = 0x00 ;
941
942 Tuner->TunerRegs[17].Reg_Num = 32 ;
943 Tuner->TunerRegs[17].Reg_Val = 0x40 ;
944
945 Tuner->TunerRegs[18].Reg_Num = 33 ;
946 Tuner->TunerRegs[18].Reg_Val = 0x53 ;
947
948 Tuner->TunerRegs[19].Reg_Num = 34 ;
949 Tuner->TunerRegs[19].Reg_Val = 0x81 ;
950
951 Tuner->TunerRegs[20].Reg_Num = 35 ;
952 Tuner->TunerRegs[20].Reg_Val = 0xC9 ;
953
954 Tuner->TunerRegs[21].Reg_Num = 36 ;
955 Tuner->TunerRegs[21].Reg_Val = 0x01 ;
956
957 Tuner->TunerRegs[22].Reg_Num = 37 ;
958 Tuner->TunerRegs[22].Reg_Val = 0x00 ;
959
960 Tuner->TunerRegs[23].Reg_Num = 41 ;
961 Tuner->TunerRegs[23].Reg_Val = 0x00 ;
962
963 Tuner->TunerRegs[24].Reg_Num = 42 ;
964 Tuner->TunerRegs[24].Reg_Val = 0xF8 ;
965
966 Tuner->TunerRegs[25].Reg_Num = 43 ;
967 Tuner->TunerRegs[25].Reg_Val = 0x43 ;
968
969 Tuner->TunerRegs[26].Reg_Num = 44 ;
970 Tuner->TunerRegs[26].Reg_Val = 0x20 ;
971
972 Tuner->TunerRegs[27].Reg_Num = 45 ;
973 Tuner->TunerRegs[27].Reg_Val = 0x80 ;
974
975 Tuner->TunerRegs[28].Reg_Num = 46 ;
976 Tuner->TunerRegs[28].Reg_Val = 0x88 ;
977
978 Tuner->TunerRegs[29].Reg_Num = 47 ;
979 Tuner->TunerRegs[29].Reg_Val = 0x86 ;
980
981 Tuner->TunerRegs[30].Reg_Num = 48 ;
982 Tuner->TunerRegs[30].Reg_Val = 0x00 ;
983
984 Tuner->TunerRegs[31].Reg_Num = 49 ;
985 Tuner->TunerRegs[31].Reg_Val = 0x00 ;
986
987 Tuner->TunerRegs[32].Reg_Num = 53 ;
988 Tuner->TunerRegs[32].Reg_Val = 0x94 ;
989
990 Tuner->TunerRegs[33].Reg_Num = 54 ;
991 Tuner->TunerRegs[33].Reg_Val = 0xFA ;
992
993 Tuner->TunerRegs[34].Reg_Num = 55 ;
994 Tuner->TunerRegs[34].Reg_Val = 0x92 ;
995
996 Tuner->TunerRegs[35].Reg_Num = 56 ;
997 Tuner->TunerRegs[35].Reg_Val = 0x80 ;
998
999 Tuner->TunerRegs[36].Reg_Num = 57 ;
1000 Tuner->TunerRegs[36].Reg_Val = 0x41 ;
1001
1002 Tuner->TunerRegs[37].Reg_Num = 58 ;
1003 Tuner->TunerRegs[37].Reg_Val = 0xDB ;
1004
1005 Tuner->TunerRegs[38].Reg_Num = 59 ;
1006 Tuner->TunerRegs[38].Reg_Val = 0x00 ;
1007
1008 Tuner->TunerRegs[39].Reg_Num = 60 ;
1009 Tuner->TunerRegs[39].Reg_Val = 0x00 ;
1010
1011 Tuner->TunerRegs[40].Reg_Num = 61 ;
1012 Tuner->TunerRegs[40].Reg_Val = 0x00 ;
1013
1014 Tuner->TunerRegs[41].Reg_Num = 62 ;
1015 Tuner->TunerRegs[41].Reg_Val = 0x00 ;
1016
1017 Tuner->TunerRegs[42].Reg_Num = 65 ;
1018 Tuner->TunerRegs[42].Reg_Val = 0xF8 ;
1019
1020 Tuner->TunerRegs[43].Reg_Num = 66 ;
1021 Tuner->TunerRegs[43].Reg_Val = 0xE4 ;
1022
1023 Tuner->TunerRegs[44].Reg_Num = 67 ;
1024 Tuner->TunerRegs[44].Reg_Val = 0x90 ;
1025
1026 Tuner->TunerRegs[45].Reg_Num = 68 ;
1027 Tuner->TunerRegs[45].Reg_Val = 0xC0 ;
1028
1029 Tuner->TunerRegs[46].Reg_Num = 69 ;
1030 Tuner->TunerRegs[46].Reg_Val = 0x01 ;
1031
1032 Tuner->TunerRegs[47].Reg_Num = 70 ;
1033 Tuner->TunerRegs[47].Reg_Val = 0x50 ;
1034
1035 Tuner->TunerRegs[48].Reg_Num = 71 ;
1036 Tuner->TunerRegs[48].Reg_Val = 0x06 ;
1037
1038 Tuner->TunerRegs[49].Reg_Num = 72 ;
1039 Tuner->TunerRegs[49].Reg_Val = 0x00 ;
1040
1041 Tuner->TunerRegs[50].Reg_Num = 73 ;
1042 Tuner->TunerRegs[50].Reg_Val = 0x20 ;
1043
1044 Tuner->TunerRegs[51].Reg_Num = 76 ;
1045 Tuner->TunerRegs[51].Reg_Val = 0xBB ;
1046
1047 Tuner->TunerRegs[52].Reg_Num = 77 ;
1048 Tuner->TunerRegs[52].Reg_Val = 0x13 ;
1049
1050 Tuner->TunerRegs[53].Reg_Num = 81 ;
1051 Tuner->TunerRegs[53].Reg_Val = 0x04 ;
1052
1053 Tuner->TunerRegs[54].Reg_Num = 82 ;
1054 Tuner->TunerRegs[54].Reg_Val = 0x75 ;
1055
1056 Tuner->TunerRegs[55].Reg_Num = 83 ;
1057 Tuner->TunerRegs[55].Reg_Val = 0x00 ;
1058
1059 Tuner->TunerRegs[56].Reg_Num = 84 ;
1060 Tuner->TunerRegs[56].Reg_Val = 0x00 ;
1061
1062 Tuner->TunerRegs[57].Reg_Num = 85 ;
1063 Tuner->TunerRegs[57].Reg_Val = 0x00 ;
1064
1065 Tuner->TunerRegs[58].Reg_Num = 91 ;
1066 Tuner->TunerRegs[58].Reg_Val = 0x70 ;
1067
1068 Tuner->TunerRegs[59].Reg_Num = 92 ;
1069 Tuner->TunerRegs[59].Reg_Val = 0x00 ;
1070
1071 Tuner->TunerRegs[60].Reg_Num = 93 ;
1072 Tuner->TunerRegs[60].Reg_Val = 0x00 ;
1073
1074 Tuner->TunerRegs[61].Reg_Num = 94 ;
1075 Tuner->TunerRegs[61].Reg_Val = 0x00 ;
1076
1077 Tuner->TunerRegs[62].Reg_Num = 95 ;
1078 Tuner->TunerRegs[62].Reg_Val = 0x0C ;
1079
1080 Tuner->TunerRegs[63].Reg_Num = 96 ;
1081 Tuner->TunerRegs[63].Reg_Val = 0x00 ;
1082
1083 Tuner->TunerRegs[64].Reg_Num = 97 ;
1084 Tuner->TunerRegs[64].Reg_Val = 0x00 ;
1085
1086 Tuner->TunerRegs[65].Reg_Num = 98 ;
1087 Tuner->TunerRegs[65].Reg_Val = 0xE2 ;
1088
1089 Tuner->TunerRegs[66].Reg_Num = 99 ;
1090 Tuner->TunerRegs[66].Reg_Val = 0x00 ;
1091
1092 Tuner->TunerRegs[67].Reg_Num = 100 ;
1093 Tuner->TunerRegs[67].Reg_Val = 0x00 ;
1094
1095 Tuner->TunerRegs[68].Reg_Num = 101 ;
1096 Tuner->TunerRegs[68].Reg_Val = 0x12 ;
1097
1098 Tuner->TunerRegs[69].Reg_Num = 102 ;
1099 Tuner->TunerRegs[69].Reg_Val = 0x80 ;
1100
1101 Tuner->TunerRegs[70].Reg_Num = 103 ;
1102 Tuner->TunerRegs[70].Reg_Val = 0x32 ;
1103
1104 Tuner->TunerRegs[71].Reg_Num = 104 ;
1105 Tuner->TunerRegs[71].Reg_Val = 0xB4 ;
1106
1107 Tuner->TunerRegs[72].Reg_Num = 105 ;
1108 Tuner->TunerRegs[72].Reg_Val = 0x60 ;
1109
1110 Tuner->TunerRegs[73].Reg_Num = 106 ;
1111 Tuner->TunerRegs[73].Reg_Val = 0x83 ;
1112
1113 Tuner->TunerRegs[74].Reg_Num = 107 ;
1114 Tuner->TunerRegs[74].Reg_Val = 0x84 ;
1115
1116 Tuner->TunerRegs[75].Reg_Num = 108 ;
1117 Tuner->TunerRegs[75].Reg_Val = 0x9C ;
1118
1119 Tuner->TunerRegs[76].Reg_Num = 109 ;
1120 Tuner->TunerRegs[76].Reg_Val = 0x02 ;
1121
1122 Tuner->TunerRegs[77].Reg_Num = 110 ;
1123 Tuner->TunerRegs[77].Reg_Val = 0x81 ;
1124
1125 Tuner->TunerRegs[78].Reg_Num = 111 ;
1126 Tuner->TunerRegs[78].Reg_Val = 0xC0 ;
1127
1128 Tuner->TunerRegs[79].Reg_Num = 112 ;
1129 Tuner->TunerRegs[79].Reg_Val = 0x10 ;
1130
1131 Tuner->TunerRegs[80].Reg_Num = 131 ;
1132 Tuner->TunerRegs[80].Reg_Val = 0x8A ;
1133
1134 Tuner->TunerRegs[81].Reg_Num = 132 ;
1135 Tuner->TunerRegs[81].Reg_Val = 0x10 ;
1136
1137 Tuner->TunerRegs[82].Reg_Num = 133 ;
1138 Tuner->TunerRegs[82].Reg_Val = 0x24 ;
1139
1140 Tuner->TunerRegs[83].Reg_Num = 134 ;
1141 Tuner->TunerRegs[83].Reg_Val = 0x00 ;
1142
1143 Tuner->TunerRegs[84].Reg_Num = 135 ;
1144 Tuner->TunerRegs[84].Reg_Val = 0x00 ;
1145
1146 Tuner->TunerRegs[85].Reg_Num = 136 ;
1147 Tuner->TunerRegs[85].Reg_Val = 0x7E ;
1148
1149 Tuner->TunerRegs[86].Reg_Num = 137 ;
1150 Tuner->TunerRegs[86].Reg_Val = 0x40 ;
1151
1152 Tuner->TunerRegs[87].Reg_Num = 138 ;
1153 Tuner->TunerRegs[87].Reg_Val = 0x38 ;
1154
1155 Tuner->TunerRegs[88].Reg_Num = 146 ;
1156 Tuner->TunerRegs[88].Reg_Val = 0xF6 ;
1157
1158 Tuner->TunerRegs[89].Reg_Num = 147 ;
1159 Tuner->TunerRegs[89].Reg_Val = 0x1A ;
1160
1161 Tuner->TunerRegs[90].Reg_Num = 148 ;
1162 Tuner->TunerRegs[90].Reg_Val = 0x62 ;
1163
1164 Tuner->TunerRegs[91].Reg_Num = 149 ;
1165 Tuner->TunerRegs[91].Reg_Val = 0x33 ;
1166
1167 Tuner->TunerRegs[92].Reg_Num = 150 ;
1168 Tuner->TunerRegs[92].Reg_Val = 0x80 ;
1169
1170 Tuner->TunerRegs[93].Reg_Num = 156 ;
1171 Tuner->TunerRegs[93].Reg_Val = 0x56 ;
1172
1173 Tuner->TunerRegs[94].Reg_Num = 157 ;
1174 Tuner->TunerRegs[94].Reg_Val = 0x17 ;
1175
1176 Tuner->TunerRegs[95].Reg_Num = 158 ;
1177 Tuner->TunerRegs[95].Reg_Val = 0xA9 ;
1178
1179 Tuner->TunerRegs[96].Reg_Num = 159 ;
1180 Tuner->TunerRegs[96].Reg_Val = 0x00 ;
1181
1182 Tuner->TunerRegs[97].Reg_Num = 160 ;
1183 Tuner->TunerRegs[97].Reg_Val = 0x00 ;
1184
1185 Tuner->TunerRegs[98].Reg_Num = 161 ;
1186 Tuner->TunerRegs[98].Reg_Val = 0x00 ;
1187
1188 Tuner->TunerRegs[99].Reg_Num = 162 ;
1189 Tuner->TunerRegs[99].Reg_Val = 0x40 ;
1190
1191 Tuner->TunerRegs[100].Reg_Num = 166 ;
1192 Tuner->TunerRegs[100].Reg_Val = 0xAE ;
1193
1194 Tuner->TunerRegs[101].Reg_Num = 167 ;
1195 Tuner->TunerRegs[101].Reg_Val = 0x1B ;
1196
1197 Tuner->TunerRegs[102].Reg_Num = 168 ;
1198 Tuner->TunerRegs[102].Reg_Val = 0xF2 ;
1199
1200 Tuner->TunerRegs[103].Reg_Num = 195 ;
1201 Tuner->TunerRegs[103].Reg_Val = 0x00 ;
1202
1203 return 0 ;
1204}
1205
1206_u16 MXL5005_ControlInit (Tuner_struct *Tuner)
1207{
1208 Tuner->Init_Ctrl_Num = INITCTRL_NUM ;
1209
1210 Tuner->Init_Ctrl[0].Ctrl_Num = DN_IQTN_AMP_CUT ;
1211 Tuner->Init_Ctrl[0].size = 1 ;
1212 Tuner->Init_Ctrl[0].addr[0] = 73;
1213 Tuner->Init_Ctrl[0].bit[0] = 7;
1214 Tuner->Init_Ctrl[0].val[0] = 0;
1215
1216 Tuner->Init_Ctrl[1].Ctrl_Num = BB_MODE ;
1217 Tuner->Init_Ctrl[1].size = 1 ;
1218 Tuner->Init_Ctrl[1].addr[0] = 53;
1219 Tuner->Init_Ctrl[1].bit[0] = 2;
1220 Tuner->Init_Ctrl[1].val[0] = 1;
1221
1222 Tuner->Init_Ctrl[2].Ctrl_Num = BB_BUF ;
1223 Tuner->Init_Ctrl[2].size = 2 ;
1224 Tuner->Init_Ctrl[2].addr[0] = 53;
1225 Tuner->Init_Ctrl[2].bit[0] = 1;
1226 Tuner->Init_Ctrl[2].val[0] = 0;
1227 Tuner->Init_Ctrl[2].addr[1] = 57;
1228 Tuner->Init_Ctrl[2].bit[1] = 0;
1229 Tuner->Init_Ctrl[2].val[1] = 1;
1230
1231 Tuner->Init_Ctrl[3].Ctrl_Num = BB_BUF_OA ;
1232 Tuner->Init_Ctrl[3].size = 1 ;
1233 Tuner->Init_Ctrl[3].addr[0] = 53;
1234 Tuner->Init_Ctrl[3].bit[0] = 0;
1235 Tuner->Init_Ctrl[3].val[0] = 0;
1236
1237 Tuner->Init_Ctrl[4].Ctrl_Num = BB_ALPF_BANDSELECT ;
1238 Tuner->Init_Ctrl[4].size = 3 ;
1239 Tuner->Init_Ctrl[4].addr[0] = 53;
1240 Tuner->Init_Ctrl[4].bit[0] = 5;
1241 Tuner->Init_Ctrl[4].val[0] = 0;
1242 Tuner->Init_Ctrl[4].addr[1] = 53;
1243 Tuner->Init_Ctrl[4].bit[1] = 6;
1244 Tuner->Init_Ctrl[4].val[1] = 0;
1245 Tuner->Init_Ctrl[4].addr[2] = 53;
1246 Tuner->Init_Ctrl[4].bit[2] = 7;
1247 Tuner->Init_Ctrl[4].val[2] = 1;
1248
1249 Tuner->Init_Ctrl[5].Ctrl_Num = BB_IQSWAP ;
1250 Tuner->Init_Ctrl[5].size = 1 ;
1251 Tuner->Init_Ctrl[5].addr[0] = 59;
1252 Tuner->Init_Ctrl[5].bit[0] = 0;
1253 Tuner->Init_Ctrl[5].val[0] = 0;
1254
1255 Tuner->Init_Ctrl[6].Ctrl_Num = BB_DLPF_BANDSEL ;
1256 Tuner->Init_Ctrl[6].size = 2 ;
1257 Tuner->Init_Ctrl[6].addr[0] = 53;
1258 Tuner->Init_Ctrl[6].bit[0] = 3;
1259 Tuner->Init_Ctrl[6].val[0] = 0;
1260 Tuner->Init_Ctrl[6].addr[1] = 53;
1261 Tuner->Init_Ctrl[6].bit[1] = 4;
1262 Tuner->Init_Ctrl[6].val[1] = 1;
1263
1264 Tuner->Init_Ctrl[7].Ctrl_Num = RFSYN_CHP_GAIN ;
1265 Tuner->Init_Ctrl[7].size = 4 ;
1266 Tuner->Init_Ctrl[7].addr[0] = 22;
1267 Tuner->Init_Ctrl[7].bit[0] = 4;
1268 Tuner->Init_Ctrl[7].val[0] = 0;
1269 Tuner->Init_Ctrl[7].addr[1] = 22;
1270 Tuner->Init_Ctrl[7].bit[1] = 5;
1271 Tuner->Init_Ctrl[7].val[1] = 1;
1272 Tuner->Init_Ctrl[7].addr[2] = 22;
1273 Tuner->Init_Ctrl[7].bit[2] = 6;
1274 Tuner->Init_Ctrl[7].val[2] = 1;
1275 Tuner->Init_Ctrl[7].addr[3] = 22;
1276 Tuner->Init_Ctrl[7].bit[3] = 7;
1277 Tuner->Init_Ctrl[7].val[3] = 0;
1278
1279 Tuner->Init_Ctrl[8].Ctrl_Num = RFSYN_EN_CHP_HIGAIN ;
1280 Tuner->Init_Ctrl[8].size = 1 ;
1281 Tuner->Init_Ctrl[8].addr[0] = 22;
1282 Tuner->Init_Ctrl[8].bit[0] = 2;
1283 Tuner->Init_Ctrl[8].val[0] = 0;
1284
1285 Tuner->Init_Ctrl[9].Ctrl_Num = AGC_IF ;
1286 Tuner->Init_Ctrl[9].size = 4 ;
1287 Tuner->Init_Ctrl[9].addr[0] = 76;
1288 Tuner->Init_Ctrl[9].bit[0] = 0;
1289 Tuner->Init_Ctrl[9].val[0] = 1;
1290 Tuner->Init_Ctrl[9].addr[1] = 76;
1291 Tuner->Init_Ctrl[9].bit[1] = 1;
1292 Tuner->Init_Ctrl[9].val[1] = 1;
1293 Tuner->Init_Ctrl[9].addr[2] = 76;
1294 Tuner->Init_Ctrl[9].bit[2] = 2;
1295 Tuner->Init_Ctrl[9].val[2] = 0;
1296 Tuner->Init_Ctrl[9].addr[3] = 76;
1297 Tuner->Init_Ctrl[9].bit[3] = 3;
1298 Tuner->Init_Ctrl[9].val[3] = 1;
1299
1300 Tuner->Init_Ctrl[10].Ctrl_Num = AGC_RF ;
1301 Tuner->Init_Ctrl[10].size = 4 ;
1302 Tuner->Init_Ctrl[10].addr[0] = 76;
1303 Tuner->Init_Ctrl[10].bit[0] = 4;
1304 Tuner->Init_Ctrl[10].val[0] = 1;
1305 Tuner->Init_Ctrl[10].addr[1] = 76;
1306 Tuner->Init_Ctrl[10].bit[1] = 5;
1307 Tuner->Init_Ctrl[10].val[1] = 1;
1308 Tuner->Init_Ctrl[10].addr[2] = 76;
1309 Tuner->Init_Ctrl[10].bit[2] = 6;
1310 Tuner->Init_Ctrl[10].val[2] = 0;
1311 Tuner->Init_Ctrl[10].addr[3] = 76;
1312 Tuner->Init_Ctrl[10].bit[3] = 7;
1313 Tuner->Init_Ctrl[10].val[3] = 1;
1314
1315 Tuner->Init_Ctrl[11].Ctrl_Num = IF_DIVVAL ;
1316 Tuner->Init_Ctrl[11].size = 5 ;
1317 Tuner->Init_Ctrl[11].addr[0] = 43;
1318 Tuner->Init_Ctrl[11].bit[0] = 3;
1319 Tuner->Init_Ctrl[11].val[0] = 0;
1320 Tuner->Init_Ctrl[11].addr[1] = 43;
1321 Tuner->Init_Ctrl[11].bit[1] = 4;
1322 Tuner->Init_Ctrl[11].val[1] = 0;
1323 Tuner->Init_Ctrl[11].addr[2] = 43;
1324 Tuner->Init_Ctrl[11].bit[2] = 5;
1325 Tuner->Init_Ctrl[11].val[2] = 0;
1326 Tuner->Init_Ctrl[11].addr[3] = 43;
1327 Tuner->Init_Ctrl[11].bit[3] = 6;
1328 Tuner->Init_Ctrl[11].val[3] = 1;
1329 Tuner->Init_Ctrl[11].addr[4] = 43;
1330 Tuner->Init_Ctrl[11].bit[4] = 7;
1331 Tuner->Init_Ctrl[11].val[4] = 0;
1332
1333 Tuner->Init_Ctrl[12].Ctrl_Num = IF_VCO_BIAS ;
1334 Tuner->Init_Ctrl[12].size = 6 ;
1335 Tuner->Init_Ctrl[12].addr[0] = 44;
1336 Tuner->Init_Ctrl[12].bit[0] = 2;
1337 Tuner->Init_Ctrl[12].val[0] = 0;
1338 Tuner->Init_Ctrl[12].addr[1] = 44;
1339 Tuner->Init_Ctrl[12].bit[1] = 3;
1340 Tuner->Init_Ctrl[12].val[1] = 0;
1341 Tuner->Init_Ctrl[12].addr[2] = 44;
1342 Tuner->Init_Ctrl[12].bit[2] = 4;
1343 Tuner->Init_Ctrl[12].val[2] = 0;
1344 Tuner->Init_Ctrl[12].addr[3] = 44;
1345 Tuner->Init_Ctrl[12].bit[3] = 5;
1346 Tuner->Init_Ctrl[12].val[3] = 1;
1347 Tuner->Init_Ctrl[12].addr[4] = 44;
1348 Tuner->Init_Ctrl[12].bit[4] = 6;
1349 Tuner->Init_Ctrl[12].val[4] = 0;
1350 Tuner->Init_Ctrl[12].addr[5] = 44;
1351 Tuner->Init_Ctrl[12].bit[5] = 7;
1352 Tuner->Init_Ctrl[12].val[5] = 0;
1353
1354 Tuner->Init_Ctrl[13].Ctrl_Num = CHCAL_INT_MOD_IF ;
1355 Tuner->Init_Ctrl[13].size = 7 ;
1356 Tuner->Init_Ctrl[13].addr[0] = 11;
1357 Tuner->Init_Ctrl[13].bit[0] = 0;
1358 Tuner->Init_Ctrl[13].val[0] = 1;
1359 Tuner->Init_Ctrl[13].addr[1] = 11;
1360 Tuner->Init_Ctrl[13].bit[1] = 1;
1361 Tuner->Init_Ctrl[13].val[1] = 0;
1362 Tuner->Init_Ctrl[13].addr[2] = 11;
1363 Tuner->Init_Ctrl[13].bit[2] = 2;
1364 Tuner->Init_Ctrl[13].val[2] = 0;
1365 Tuner->Init_Ctrl[13].addr[3] = 11;
1366 Tuner->Init_Ctrl[13].bit[3] = 3;
1367 Tuner->Init_Ctrl[13].val[3] = 1;
1368 Tuner->Init_Ctrl[13].addr[4] = 11;
1369 Tuner->Init_Ctrl[13].bit[4] = 4;
1370 Tuner->Init_Ctrl[13].val[4] = 1;
1371 Tuner->Init_Ctrl[13].addr[5] = 11;
1372 Tuner->Init_Ctrl[13].bit[5] = 5;
1373 Tuner->Init_Ctrl[13].val[5] = 0;
1374 Tuner->Init_Ctrl[13].addr[6] = 11;
1375 Tuner->Init_Ctrl[13].bit[6] = 6;
1376 Tuner->Init_Ctrl[13].val[6] = 0;
1377
1378 Tuner->Init_Ctrl[14].Ctrl_Num = CHCAL_FRAC_MOD_IF ;
1379 Tuner->Init_Ctrl[14].size = 16 ;
1380 Tuner->Init_Ctrl[14].addr[0] = 13;
1381 Tuner->Init_Ctrl[14].bit[0] = 0;
1382 Tuner->Init_Ctrl[14].val[0] = 0;
1383 Tuner->Init_Ctrl[14].addr[1] = 13;
1384 Tuner->Init_Ctrl[14].bit[1] = 1;
1385 Tuner->Init_Ctrl[14].val[1] = 0;
1386 Tuner->Init_Ctrl[14].addr[2] = 13;
1387 Tuner->Init_Ctrl[14].bit[2] = 2;
1388 Tuner->Init_Ctrl[14].val[2] = 0;
1389 Tuner->Init_Ctrl[14].addr[3] = 13;
1390 Tuner->Init_Ctrl[14].bit[3] = 3;
1391 Tuner->Init_Ctrl[14].val[3] = 0;
1392 Tuner->Init_Ctrl[14].addr[4] = 13;
1393 Tuner->Init_Ctrl[14].bit[4] = 4;
1394 Tuner->Init_Ctrl[14].val[4] = 0;
1395 Tuner->Init_Ctrl[14].addr[5] = 13;
1396 Tuner->Init_Ctrl[14].bit[5] = 5;
1397 Tuner->Init_Ctrl[14].val[5] = 0;
1398 Tuner->Init_Ctrl[14].addr[6] = 13;
1399 Tuner->Init_Ctrl[14].bit[6] = 6;
1400 Tuner->Init_Ctrl[14].val[6] = 0;
1401 Tuner->Init_Ctrl[14].addr[7] = 13;
1402 Tuner->Init_Ctrl[14].bit[7] = 7;
1403 Tuner->Init_Ctrl[14].val[7] = 0;
1404 Tuner->Init_Ctrl[14].addr[8] = 12;
1405 Tuner->Init_Ctrl[14].bit[8] = 0;
1406 Tuner->Init_Ctrl[14].val[8] = 0;
1407 Tuner->Init_Ctrl[14].addr[9] = 12;
1408 Tuner->Init_Ctrl[14].bit[9] = 1;
1409 Tuner->Init_Ctrl[14].val[9] = 0;
1410 Tuner->Init_Ctrl[14].addr[10] = 12;
1411 Tuner->Init_Ctrl[14].bit[10] = 2;
1412 Tuner->Init_Ctrl[14].val[10] = 0;
1413 Tuner->Init_Ctrl[14].addr[11] = 12;
1414 Tuner->Init_Ctrl[14].bit[11] = 3;
1415 Tuner->Init_Ctrl[14].val[11] = 0;
1416 Tuner->Init_Ctrl[14].addr[12] = 12;
1417 Tuner->Init_Ctrl[14].bit[12] = 4;
1418 Tuner->Init_Ctrl[14].val[12] = 0;
1419 Tuner->Init_Ctrl[14].addr[13] = 12;
1420 Tuner->Init_Ctrl[14].bit[13] = 5;
1421 Tuner->Init_Ctrl[14].val[13] = 1;
1422 Tuner->Init_Ctrl[14].addr[14] = 12;
1423 Tuner->Init_Ctrl[14].bit[14] = 6;
1424 Tuner->Init_Ctrl[14].val[14] = 1;
1425 Tuner->Init_Ctrl[14].addr[15] = 12;
1426 Tuner->Init_Ctrl[14].bit[15] = 7;
1427 Tuner->Init_Ctrl[14].val[15] = 0;
1428
1429 Tuner->Init_Ctrl[15].Ctrl_Num = DRV_RES_SEL ;
1430 Tuner->Init_Ctrl[15].size = 3 ;
1431 Tuner->Init_Ctrl[15].addr[0] = 147;
1432 Tuner->Init_Ctrl[15].bit[0] = 2;
1433 Tuner->Init_Ctrl[15].val[0] = 0;
1434 Tuner->Init_Ctrl[15].addr[1] = 147;
1435 Tuner->Init_Ctrl[15].bit[1] = 3;
1436 Tuner->Init_Ctrl[15].val[1] = 1;
1437 Tuner->Init_Ctrl[15].addr[2] = 147;
1438 Tuner->Init_Ctrl[15].bit[2] = 4;
1439 Tuner->Init_Ctrl[15].val[2] = 1;
1440
1441 Tuner->Init_Ctrl[16].Ctrl_Num = I_DRIVER ;
1442 Tuner->Init_Ctrl[16].size = 2 ;
1443 Tuner->Init_Ctrl[16].addr[0] = 147;
1444 Tuner->Init_Ctrl[16].bit[0] = 0;
1445 Tuner->Init_Ctrl[16].val[0] = 0;
1446 Tuner->Init_Ctrl[16].addr[1] = 147;
1447 Tuner->Init_Ctrl[16].bit[1] = 1;
1448 Tuner->Init_Ctrl[16].val[1] = 1;
1449
1450 Tuner->Init_Ctrl[17].Ctrl_Num = EN_AAF ;
1451 Tuner->Init_Ctrl[17].size = 1 ;
1452 Tuner->Init_Ctrl[17].addr[0] = 147;
1453 Tuner->Init_Ctrl[17].bit[0] = 7;
1454 Tuner->Init_Ctrl[17].val[0] = 0;
1455
1456 Tuner->Init_Ctrl[18].Ctrl_Num = EN_3P ;
1457 Tuner->Init_Ctrl[18].size = 1 ;
1458 Tuner->Init_Ctrl[18].addr[0] = 147;
1459 Tuner->Init_Ctrl[18].bit[0] = 6;
1460 Tuner->Init_Ctrl[18].val[0] = 0;
1461
1462 Tuner->Init_Ctrl[19].Ctrl_Num = EN_AUX_3P ;
1463 Tuner->Init_Ctrl[19].size = 1 ;
1464 Tuner->Init_Ctrl[19].addr[0] = 156;
1465 Tuner->Init_Ctrl[19].bit[0] = 0;
1466 Tuner->Init_Ctrl[19].val[0] = 0;
1467
1468 Tuner->Init_Ctrl[20].Ctrl_Num = SEL_AAF_BAND ;
1469 Tuner->Init_Ctrl[20].size = 1 ;
1470 Tuner->Init_Ctrl[20].addr[0] = 147;
1471 Tuner->Init_Ctrl[20].bit[0] = 5;
1472 Tuner->Init_Ctrl[20].val[0] = 0;
1473
1474 Tuner->Init_Ctrl[21].Ctrl_Num = SEQ_ENCLK16_CLK_OUT ;
1475 Tuner->Init_Ctrl[21].size = 1 ;
1476 Tuner->Init_Ctrl[21].addr[0] = 137;
1477 Tuner->Init_Ctrl[21].bit[0] = 4;
1478 Tuner->Init_Ctrl[21].val[0] = 0;
1479
1480 Tuner->Init_Ctrl[22].Ctrl_Num = SEQ_SEL4_16B ;
1481 Tuner->Init_Ctrl[22].size = 1 ;
1482 Tuner->Init_Ctrl[22].addr[0] = 137;
1483 Tuner->Init_Ctrl[22].bit[0] = 7;
1484 Tuner->Init_Ctrl[22].val[0] = 0;
1485
1486 Tuner->Init_Ctrl[23].Ctrl_Num = XTAL_CAPSELECT ;
1487 Tuner->Init_Ctrl[23].size = 1 ;
1488 Tuner->Init_Ctrl[23].addr[0] = 91;
1489 Tuner->Init_Ctrl[23].bit[0] = 5;
1490 Tuner->Init_Ctrl[23].val[0] = 1;
1491
1492 Tuner->Init_Ctrl[24].Ctrl_Num = IF_SEL_DBL ;
1493 Tuner->Init_Ctrl[24].size = 1 ;
1494 Tuner->Init_Ctrl[24].addr[0] = 43;
1495 Tuner->Init_Ctrl[24].bit[0] = 0;
1496 Tuner->Init_Ctrl[24].val[0] = 1;
1497
1498 Tuner->Init_Ctrl[25].Ctrl_Num = RFSYN_R_DIV ;
1499 Tuner->Init_Ctrl[25].size = 2 ;
1500 Tuner->Init_Ctrl[25].addr[0] = 22;
1501 Tuner->Init_Ctrl[25].bit[0] = 0;
1502 Tuner->Init_Ctrl[25].val[0] = 1;
1503 Tuner->Init_Ctrl[25].addr[1] = 22;
1504 Tuner->Init_Ctrl[25].bit[1] = 1;
1505 Tuner->Init_Ctrl[25].val[1] = 1;
1506
1507 Tuner->Init_Ctrl[26].Ctrl_Num = SEQ_EXTSYNTHCALIF ;
1508 Tuner->Init_Ctrl[26].size = 1 ;
1509 Tuner->Init_Ctrl[26].addr[0] = 134;
1510 Tuner->Init_Ctrl[26].bit[0] = 2;
1511 Tuner->Init_Ctrl[26].val[0] = 0;
1512
1513 Tuner->Init_Ctrl[27].Ctrl_Num = SEQ_EXTDCCAL ;
1514 Tuner->Init_Ctrl[27].size = 1 ;
1515 Tuner->Init_Ctrl[27].addr[0] = 137;
1516 Tuner->Init_Ctrl[27].bit[0] = 3;
1517 Tuner->Init_Ctrl[27].val[0] = 0;
1518
1519 Tuner->Init_Ctrl[28].Ctrl_Num = AGC_EN_RSSI ;
1520 Tuner->Init_Ctrl[28].size = 1 ;
1521 Tuner->Init_Ctrl[28].addr[0] = 77;
1522 Tuner->Init_Ctrl[28].bit[0] = 7;
1523 Tuner->Init_Ctrl[28].val[0] = 0;
1524
1525 Tuner->Init_Ctrl[29].Ctrl_Num = RFA_ENCLKRFAGC ;
1526 Tuner->Init_Ctrl[29].size = 1 ;
1527 Tuner->Init_Ctrl[29].addr[0] = 166;
1528 Tuner->Init_Ctrl[29].bit[0] = 7;
1529 Tuner->Init_Ctrl[29].val[0] = 1;
1530
1531 Tuner->Init_Ctrl[30].Ctrl_Num = RFA_RSSI_REFH ;
1532 Tuner->Init_Ctrl[30].size = 3 ;
1533 Tuner->Init_Ctrl[30].addr[0] = 166;
1534 Tuner->Init_Ctrl[30].bit[0] = 0;
1535 Tuner->Init_Ctrl[30].val[0] = 0;
1536 Tuner->Init_Ctrl[30].addr[1] = 166;
1537 Tuner->Init_Ctrl[30].bit[1] = 1;
1538 Tuner->Init_Ctrl[30].val[1] = 1;
1539 Tuner->Init_Ctrl[30].addr[2] = 166;
1540 Tuner->Init_Ctrl[30].bit[2] = 2;
1541 Tuner->Init_Ctrl[30].val[2] = 1;
1542
1543 Tuner->Init_Ctrl[31].Ctrl_Num = RFA_RSSI_REF ;
1544 Tuner->Init_Ctrl[31].size = 3 ;
1545 Tuner->Init_Ctrl[31].addr[0] = 166;
1546 Tuner->Init_Ctrl[31].bit[0] = 3;
1547 Tuner->Init_Ctrl[31].val[0] = 1;
1548 Tuner->Init_Ctrl[31].addr[1] = 166;
1549 Tuner->Init_Ctrl[31].bit[1] = 4;
1550 Tuner->Init_Ctrl[31].val[1] = 0;
1551 Tuner->Init_Ctrl[31].addr[2] = 166;
1552 Tuner->Init_Ctrl[31].bit[2] = 5;
1553 Tuner->Init_Ctrl[31].val[2] = 1;
1554
1555 Tuner->Init_Ctrl[32].Ctrl_Num = RFA_RSSI_REFL ;
1556 Tuner->Init_Ctrl[32].size = 3 ;
1557 Tuner->Init_Ctrl[32].addr[0] = 167;
1558 Tuner->Init_Ctrl[32].bit[0] = 0;
1559 Tuner->Init_Ctrl[32].val[0] = 1;
1560 Tuner->Init_Ctrl[32].addr[1] = 167;
1561 Tuner->Init_Ctrl[32].bit[1] = 1;
1562 Tuner->Init_Ctrl[32].val[1] = 1;
1563 Tuner->Init_Ctrl[32].addr[2] = 167;
1564 Tuner->Init_Ctrl[32].bit[2] = 2;
1565 Tuner->Init_Ctrl[32].val[2] = 0;
1566
1567 Tuner->Init_Ctrl[33].Ctrl_Num = RFA_FLR ;
1568 Tuner->Init_Ctrl[33].size = 4 ;
1569 Tuner->Init_Ctrl[33].addr[0] = 168;
1570 Tuner->Init_Ctrl[33].bit[0] = 0;
1571 Tuner->Init_Ctrl[33].val[0] = 0;
1572 Tuner->Init_Ctrl[33].addr[1] = 168;
1573 Tuner->Init_Ctrl[33].bit[1] = 1;
1574 Tuner->Init_Ctrl[33].val[1] = 1;
1575 Tuner->Init_Ctrl[33].addr[2] = 168;
1576 Tuner->Init_Ctrl[33].bit[2] = 2;
1577 Tuner->Init_Ctrl[33].val[2] = 0;
1578 Tuner->Init_Ctrl[33].addr[3] = 168;
1579 Tuner->Init_Ctrl[33].bit[3] = 3;
1580 Tuner->Init_Ctrl[33].val[3] = 0;
1581
1582 Tuner->Init_Ctrl[34].Ctrl_Num = RFA_CEIL ;
1583 Tuner->Init_Ctrl[34].size = 4 ;
1584 Tuner->Init_Ctrl[34].addr[0] = 168;
1585 Tuner->Init_Ctrl[34].bit[0] = 4;
1586 Tuner->Init_Ctrl[34].val[0] = 1;
1587 Tuner->Init_Ctrl[34].addr[1] = 168;
1588 Tuner->Init_Ctrl[34].bit[1] = 5;
1589 Tuner->Init_Ctrl[34].val[1] = 1;
1590 Tuner->Init_Ctrl[34].addr[2] = 168;
1591 Tuner->Init_Ctrl[34].bit[2] = 6;
1592 Tuner->Init_Ctrl[34].val[2] = 1;
1593 Tuner->Init_Ctrl[34].addr[3] = 168;
1594 Tuner->Init_Ctrl[34].bit[3] = 7;
1595 Tuner->Init_Ctrl[34].val[3] = 1;
1596
1597 Tuner->Init_Ctrl[35].Ctrl_Num = SEQ_EXTIQFSMPULSE ;
1598 Tuner->Init_Ctrl[35].size = 1 ;
1599 Tuner->Init_Ctrl[35].addr[0] = 135;
1600 Tuner->Init_Ctrl[35].bit[0] = 0;
1601 Tuner->Init_Ctrl[35].val[0] = 0;
1602
1603 Tuner->Init_Ctrl[36].Ctrl_Num = OVERRIDE_1 ;
1604 Tuner->Init_Ctrl[36].size = 1 ;
1605 Tuner->Init_Ctrl[36].addr[0] = 56;
1606 Tuner->Init_Ctrl[36].bit[0] = 3;
1607 Tuner->Init_Ctrl[36].val[0] = 0;
1608
1609 Tuner->Init_Ctrl[37].Ctrl_Num = BB_INITSTATE_DLPF_TUNE ;
1610 Tuner->Init_Ctrl[37].size = 7 ;
1611 Tuner->Init_Ctrl[37].addr[0] = 59;
1612 Tuner->Init_Ctrl[37].bit[0] = 1;
1613 Tuner->Init_Ctrl[37].val[0] = 0;
1614 Tuner->Init_Ctrl[37].addr[1] = 59;
1615 Tuner->Init_Ctrl[37].bit[1] = 2;
1616 Tuner->Init_Ctrl[37].val[1] = 0;
1617 Tuner->Init_Ctrl[37].addr[2] = 59;
1618 Tuner->Init_Ctrl[37].bit[2] = 3;
1619 Tuner->Init_Ctrl[37].val[2] = 0;
1620 Tuner->Init_Ctrl[37].addr[3] = 59;
1621 Tuner->Init_Ctrl[37].bit[3] = 4;
1622 Tuner->Init_Ctrl[37].val[3] = 0;
1623 Tuner->Init_Ctrl[37].addr[4] = 59;
1624 Tuner->Init_Ctrl[37].bit[4] = 5;
1625 Tuner->Init_Ctrl[37].val[4] = 0;
1626 Tuner->Init_Ctrl[37].addr[5] = 59;
1627 Tuner->Init_Ctrl[37].bit[5] = 6;
1628 Tuner->Init_Ctrl[37].val[5] = 0;
1629 Tuner->Init_Ctrl[37].addr[6] = 59;
1630 Tuner->Init_Ctrl[37].bit[6] = 7;
1631 Tuner->Init_Ctrl[37].val[6] = 0;
1632
1633 Tuner->Init_Ctrl[38].Ctrl_Num = TG_R_DIV ;
1634 Tuner->Init_Ctrl[38].size = 6 ;
1635 Tuner->Init_Ctrl[38].addr[0] = 32;
1636 Tuner->Init_Ctrl[38].bit[0] = 2;
1637 Tuner->Init_Ctrl[38].val[0] = 0;
1638 Tuner->Init_Ctrl[38].addr[1] = 32;
1639 Tuner->Init_Ctrl[38].bit[1] = 3;
1640 Tuner->Init_Ctrl[38].val[1] = 0;
1641 Tuner->Init_Ctrl[38].addr[2] = 32;
1642 Tuner->Init_Ctrl[38].bit[2] = 4;
1643 Tuner->Init_Ctrl[38].val[2] = 0;
1644 Tuner->Init_Ctrl[38].addr[3] = 32;
1645 Tuner->Init_Ctrl[38].bit[3] = 5;
1646 Tuner->Init_Ctrl[38].val[3] = 0;
1647 Tuner->Init_Ctrl[38].addr[4] = 32;
1648 Tuner->Init_Ctrl[38].bit[4] = 6;
1649 Tuner->Init_Ctrl[38].val[4] = 1;
1650 Tuner->Init_Ctrl[38].addr[5] = 32;
1651 Tuner->Init_Ctrl[38].bit[5] = 7;
1652 Tuner->Init_Ctrl[38].val[5] = 0;
1653
1654 Tuner->Init_Ctrl[39].Ctrl_Num = EN_CHP_LIN_B ;
1655 Tuner->Init_Ctrl[39].size = 1 ;
1656 Tuner->Init_Ctrl[39].addr[0] = 25;
1657 Tuner->Init_Ctrl[39].bit[0] = 3;
1658 Tuner->Init_Ctrl[39].val[0] = 1;
1659
1660
1661 Tuner->CH_Ctrl_Num = CHCTRL_NUM ;
1662
1663 Tuner->CH_Ctrl[0].Ctrl_Num = DN_POLY ;
1664 Tuner->CH_Ctrl[0].size = 2 ;
1665 Tuner->CH_Ctrl[0].addr[0] = 68;
1666 Tuner->CH_Ctrl[0].bit[0] = 6;
1667 Tuner->CH_Ctrl[0].val[0] = 1;
1668 Tuner->CH_Ctrl[0].addr[1] = 68;
1669 Tuner->CH_Ctrl[0].bit[1] = 7;
1670 Tuner->CH_Ctrl[0].val[1] = 1;
1671
1672 Tuner->CH_Ctrl[1].Ctrl_Num = DN_RFGAIN ;
1673 Tuner->CH_Ctrl[1].size = 2 ;
1674 Tuner->CH_Ctrl[1].addr[0] = 70;
1675 Tuner->CH_Ctrl[1].bit[0] = 6;
1676 Tuner->CH_Ctrl[1].val[0] = 1;
1677 Tuner->CH_Ctrl[1].addr[1] = 70;
1678 Tuner->CH_Ctrl[1].bit[1] = 7;
1679 Tuner->CH_Ctrl[1].val[1] = 0;
1680
1681 Tuner->CH_Ctrl[2].Ctrl_Num = DN_CAP_RFLPF ;
1682 Tuner->CH_Ctrl[2].size = 9 ;
1683 Tuner->CH_Ctrl[2].addr[0] = 69;
1684 Tuner->CH_Ctrl[2].bit[0] = 5;
1685 Tuner->CH_Ctrl[2].val[0] = 0;
1686 Tuner->CH_Ctrl[2].addr[1] = 69;
1687 Tuner->CH_Ctrl[2].bit[1] = 6;
1688 Tuner->CH_Ctrl[2].val[1] = 0;
1689 Tuner->CH_Ctrl[2].addr[2] = 69;
1690 Tuner->CH_Ctrl[2].bit[2] = 7;
1691 Tuner->CH_Ctrl[2].val[2] = 0;
1692 Tuner->CH_Ctrl[2].addr[3] = 68;
1693 Tuner->CH_Ctrl[2].bit[3] = 0;
1694 Tuner->CH_Ctrl[2].val[3] = 0;
1695 Tuner->CH_Ctrl[2].addr[4] = 68;
1696 Tuner->CH_Ctrl[2].bit[4] = 1;
1697 Tuner->CH_Ctrl[2].val[4] = 0;
1698 Tuner->CH_Ctrl[2].addr[5] = 68;
1699 Tuner->CH_Ctrl[2].bit[5] = 2;
1700 Tuner->CH_Ctrl[2].val[5] = 0;
1701 Tuner->CH_Ctrl[2].addr[6] = 68;
1702 Tuner->CH_Ctrl[2].bit[6] = 3;
1703 Tuner->CH_Ctrl[2].val[6] = 0;
1704 Tuner->CH_Ctrl[2].addr[7] = 68;
1705 Tuner->CH_Ctrl[2].bit[7] = 4;
1706 Tuner->CH_Ctrl[2].val[7] = 0;
1707 Tuner->CH_Ctrl[2].addr[8] = 68;
1708 Tuner->CH_Ctrl[2].bit[8] = 5;
1709 Tuner->CH_Ctrl[2].val[8] = 0;
1710
1711 Tuner->CH_Ctrl[3].Ctrl_Num = DN_EN_VHFUHFBAR ;
1712 Tuner->CH_Ctrl[3].size = 1 ;
1713 Tuner->CH_Ctrl[3].addr[0] = 70;
1714 Tuner->CH_Ctrl[3].bit[0] = 5;
1715 Tuner->CH_Ctrl[3].val[0] = 0;
1716
1717 Tuner->CH_Ctrl[4].Ctrl_Num = DN_GAIN_ADJUST ;
1718 Tuner->CH_Ctrl[4].size = 3 ;
1719 Tuner->CH_Ctrl[4].addr[0] = 73;
1720 Tuner->CH_Ctrl[4].bit[0] = 4;
1721 Tuner->CH_Ctrl[4].val[0] = 0;
1722 Tuner->CH_Ctrl[4].addr[1] = 73;
1723 Tuner->CH_Ctrl[4].bit[1] = 5;
1724 Tuner->CH_Ctrl[4].val[1] = 1;
1725 Tuner->CH_Ctrl[4].addr[2] = 73;
1726 Tuner->CH_Ctrl[4].bit[2] = 6;
1727 Tuner->CH_Ctrl[4].val[2] = 0;
1728
1729 Tuner->CH_Ctrl[5].Ctrl_Num = DN_IQTNBUF_AMP ;
1730 Tuner->CH_Ctrl[5].size = 4 ;
1731 Tuner->CH_Ctrl[5].addr[0] = 70;
1732 Tuner->CH_Ctrl[5].bit[0] = 0;
1733 Tuner->CH_Ctrl[5].val[0] = 0;
1734 Tuner->CH_Ctrl[5].addr[1] = 70;
1735 Tuner->CH_Ctrl[5].bit[1] = 1;
1736 Tuner->CH_Ctrl[5].val[1] = 0;
1737 Tuner->CH_Ctrl[5].addr[2] = 70;
1738 Tuner->CH_Ctrl[5].bit[2] = 2;
1739 Tuner->CH_Ctrl[5].val[2] = 0;
1740 Tuner->CH_Ctrl[5].addr[3] = 70;
1741 Tuner->CH_Ctrl[5].bit[3] = 3;
1742 Tuner->CH_Ctrl[5].val[3] = 0;
1743
1744 Tuner->CH_Ctrl[6].Ctrl_Num = DN_IQTNGNBFBIAS_BST ;
1745 Tuner->CH_Ctrl[6].size = 1 ;
1746 Tuner->CH_Ctrl[6].addr[0] = 70;
1747 Tuner->CH_Ctrl[6].bit[0] = 4;
1748 Tuner->CH_Ctrl[6].val[0] = 1;
1749
1750 Tuner->CH_Ctrl[7].Ctrl_Num = RFSYN_EN_OUTMUX ;
1751 Tuner->CH_Ctrl[7].size = 1 ;
1752 Tuner->CH_Ctrl[7].addr[0] = 111;
1753 Tuner->CH_Ctrl[7].bit[0] = 4;
1754 Tuner->CH_Ctrl[7].val[0] = 0;
1755
1756 Tuner->CH_Ctrl[8].Ctrl_Num = RFSYN_SEL_VCO_OUT ;
1757 Tuner->CH_Ctrl[8].size = 1 ;
1758 Tuner->CH_Ctrl[8].addr[0] = 111;
1759 Tuner->CH_Ctrl[8].bit[0] = 7;
1760 Tuner->CH_Ctrl[8].val[0] = 1;
1761
1762 Tuner->CH_Ctrl[9].Ctrl_Num = RFSYN_SEL_VCO_HI ;
1763 Tuner->CH_Ctrl[9].size = 1 ;
1764 Tuner->CH_Ctrl[9].addr[0] = 111;
1765 Tuner->CH_Ctrl[9].bit[0] = 6;
1766 Tuner->CH_Ctrl[9].val[0] = 1;
1767
1768 Tuner->CH_Ctrl[10].Ctrl_Num = RFSYN_SEL_DIVM ;
1769 Tuner->CH_Ctrl[10].size = 1 ;
1770 Tuner->CH_Ctrl[10].addr[0] = 111;
1771 Tuner->CH_Ctrl[10].bit[0] = 5;
1772 Tuner->CH_Ctrl[10].val[0] = 0;
1773
1774 Tuner->CH_Ctrl[11].Ctrl_Num = RFSYN_RF_DIV_BIAS ;
1775 Tuner->CH_Ctrl[11].size = 2 ;
1776 Tuner->CH_Ctrl[11].addr[0] = 110;
1777 Tuner->CH_Ctrl[11].bit[0] = 0;
1778 Tuner->CH_Ctrl[11].val[0] = 1;
1779 Tuner->CH_Ctrl[11].addr[1] = 110;
1780 Tuner->CH_Ctrl[11].bit[1] = 1;
1781 Tuner->CH_Ctrl[11].val[1] = 0;
1782
1783 Tuner->CH_Ctrl[12].Ctrl_Num = DN_SEL_FREQ ;
1784 Tuner->CH_Ctrl[12].size = 3 ;
1785 Tuner->CH_Ctrl[12].addr[0] = 69;
1786 Tuner->CH_Ctrl[12].bit[0] = 2;
1787 Tuner->CH_Ctrl[12].val[0] = 0;
1788 Tuner->CH_Ctrl[12].addr[1] = 69;
1789 Tuner->CH_Ctrl[12].bit[1] = 3;
1790 Tuner->CH_Ctrl[12].val[1] = 0;
1791 Tuner->CH_Ctrl[12].addr[2] = 69;
1792 Tuner->CH_Ctrl[12].bit[2] = 4;
1793 Tuner->CH_Ctrl[12].val[2] = 0;
1794
1795 Tuner->CH_Ctrl[13].Ctrl_Num = RFSYN_VCO_BIAS ;
1796 Tuner->CH_Ctrl[13].size = 6 ;
1797 Tuner->CH_Ctrl[13].addr[0] = 110;
1798 Tuner->CH_Ctrl[13].bit[0] = 2;
1799 Tuner->CH_Ctrl[13].val[0] = 0;
1800 Tuner->CH_Ctrl[13].addr[1] = 110;
1801 Tuner->CH_Ctrl[13].bit[1] = 3;
1802 Tuner->CH_Ctrl[13].val[1] = 0;
1803 Tuner->CH_Ctrl[13].addr[2] = 110;
1804 Tuner->CH_Ctrl[13].bit[2] = 4;
1805 Tuner->CH_Ctrl[13].val[2] = 0;
1806 Tuner->CH_Ctrl[13].addr[3] = 110;
1807 Tuner->CH_Ctrl[13].bit[3] = 5;
1808 Tuner->CH_Ctrl[13].val[3] = 0;
1809 Tuner->CH_Ctrl[13].addr[4] = 110;
1810 Tuner->CH_Ctrl[13].bit[4] = 6;
1811 Tuner->CH_Ctrl[13].val[4] = 0;
1812 Tuner->CH_Ctrl[13].addr[5] = 110;
1813 Tuner->CH_Ctrl[13].bit[5] = 7;
1814 Tuner->CH_Ctrl[13].val[5] = 1;
1815
1816 Tuner->CH_Ctrl[14].Ctrl_Num = CHCAL_INT_MOD_RF ;
1817 Tuner->CH_Ctrl[14].size = 7 ;
1818 Tuner->CH_Ctrl[14].addr[0] = 14;
1819 Tuner->CH_Ctrl[14].bit[0] = 0;
1820 Tuner->CH_Ctrl[14].val[0] = 0;
1821 Tuner->CH_Ctrl[14].addr[1] = 14;
1822 Tuner->CH_Ctrl[14].bit[1] = 1;
1823 Tuner->CH_Ctrl[14].val[1] = 0;
1824 Tuner->CH_Ctrl[14].addr[2] = 14;
1825 Tuner->CH_Ctrl[14].bit[2] = 2;
1826 Tuner->CH_Ctrl[14].val[2] = 0;
1827 Tuner->CH_Ctrl[14].addr[3] = 14;
1828 Tuner->CH_Ctrl[14].bit[3] = 3;
1829 Tuner->CH_Ctrl[14].val[3] = 0;
1830 Tuner->CH_Ctrl[14].addr[4] = 14;
1831 Tuner->CH_Ctrl[14].bit[4] = 4;
1832 Tuner->CH_Ctrl[14].val[4] = 0;
1833 Tuner->CH_Ctrl[14].addr[5] = 14;
1834 Tuner->CH_Ctrl[14].bit[5] = 5;
1835 Tuner->CH_Ctrl[14].val[5] = 0;
1836 Tuner->CH_Ctrl[14].addr[6] = 14;
1837 Tuner->CH_Ctrl[14].bit[6] = 6;
1838 Tuner->CH_Ctrl[14].val[6] = 0;
1839
1840 Tuner->CH_Ctrl[15].Ctrl_Num = CHCAL_FRAC_MOD_RF ;
1841 Tuner->CH_Ctrl[15].size = 18 ;
1842 Tuner->CH_Ctrl[15].addr[0] = 17;
1843 Tuner->CH_Ctrl[15].bit[0] = 6;
1844 Tuner->CH_Ctrl[15].val[0] = 0;
1845 Tuner->CH_Ctrl[15].addr[1] = 17;
1846 Tuner->CH_Ctrl[15].bit[1] = 7;
1847 Tuner->CH_Ctrl[15].val[1] = 0;
1848 Tuner->CH_Ctrl[15].addr[2] = 16;
1849 Tuner->CH_Ctrl[15].bit[2] = 0;
1850 Tuner->CH_Ctrl[15].val[2] = 0;
1851 Tuner->CH_Ctrl[15].addr[3] = 16;
1852 Tuner->CH_Ctrl[15].bit[3] = 1;
1853 Tuner->CH_Ctrl[15].val[3] = 0;
1854 Tuner->CH_Ctrl[15].addr[4] = 16;
1855 Tuner->CH_Ctrl[15].bit[4] = 2;
1856 Tuner->CH_Ctrl[15].val[4] = 0;
1857 Tuner->CH_Ctrl[15].addr[5] = 16;
1858 Tuner->CH_Ctrl[15].bit[5] = 3;
1859 Tuner->CH_Ctrl[15].val[5] = 0;
1860 Tuner->CH_Ctrl[15].addr[6] = 16;
1861 Tuner->CH_Ctrl[15].bit[6] = 4;
1862 Tuner->CH_Ctrl[15].val[6] = 0;
1863 Tuner->CH_Ctrl[15].addr[7] = 16;
1864 Tuner->CH_Ctrl[15].bit[7] = 5;
1865 Tuner->CH_Ctrl[15].val[7] = 0;
1866 Tuner->CH_Ctrl[15].addr[8] = 16;
1867 Tuner->CH_Ctrl[15].bit[8] = 6;
1868 Tuner->CH_Ctrl[15].val[8] = 0;
1869 Tuner->CH_Ctrl[15].addr[9] = 16;
1870 Tuner->CH_Ctrl[15].bit[9] = 7;
1871 Tuner->CH_Ctrl[15].val[9] = 0;
1872 Tuner->CH_Ctrl[15].addr[10] = 15;
1873 Tuner->CH_Ctrl[15].bit[10] = 0;
1874 Tuner->CH_Ctrl[15].val[10] = 0;
1875 Tuner->CH_Ctrl[15].addr[11] = 15;
1876 Tuner->CH_Ctrl[15].bit[11] = 1;
1877 Tuner->CH_Ctrl[15].val[11] = 0;
1878 Tuner->CH_Ctrl[15].addr[12] = 15;
1879 Tuner->CH_Ctrl[15].bit[12] = 2;
1880 Tuner->CH_Ctrl[15].val[12] = 0;
1881 Tuner->CH_Ctrl[15].addr[13] = 15;
1882 Tuner->CH_Ctrl[15].bit[13] = 3;
1883 Tuner->CH_Ctrl[15].val[13] = 0;
1884 Tuner->CH_Ctrl[15].addr[14] = 15;
1885 Tuner->CH_Ctrl[15].bit[14] = 4;
1886 Tuner->CH_Ctrl[15].val[14] = 0;
1887 Tuner->CH_Ctrl[15].addr[15] = 15;
1888 Tuner->CH_Ctrl[15].bit[15] = 5;
1889 Tuner->CH_Ctrl[15].val[15] = 0;
1890 Tuner->CH_Ctrl[15].addr[16] = 15;
1891 Tuner->CH_Ctrl[15].bit[16] = 6;
1892 Tuner->CH_Ctrl[15].val[16] = 1;
1893 Tuner->CH_Ctrl[15].addr[17] = 15;
1894 Tuner->CH_Ctrl[15].bit[17] = 7;
1895 Tuner->CH_Ctrl[15].val[17] = 1;
1896
1897 Tuner->CH_Ctrl[16].Ctrl_Num = RFSYN_LPF_R ;
1898 Tuner->CH_Ctrl[16].size = 5 ;
1899 Tuner->CH_Ctrl[16].addr[0] = 112;
1900 Tuner->CH_Ctrl[16].bit[0] = 0;
1901 Tuner->CH_Ctrl[16].val[0] = 0;
1902 Tuner->CH_Ctrl[16].addr[1] = 112;
1903 Tuner->CH_Ctrl[16].bit[1] = 1;
1904 Tuner->CH_Ctrl[16].val[1] = 0;
1905 Tuner->CH_Ctrl[16].addr[2] = 112;
1906 Tuner->CH_Ctrl[16].bit[2] = 2;
1907 Tuner->CH_Ctrl[16].val[2] = 0;
1908 Tuner->CH_Ctrl[16].addr[3] = 112;
1909 Tuner->CH_Ctrl[16].bit[3] = 3;
1910 Tuner->CH_Ctrl[16].val[3] = 0;
1911 Tuner->CH_Ctrl[16].addr[4] = 112;
1912 Tuner->CH_Ctrl[16].bit[4] = 4;
1913 Tuner->CH_Ctrl[16].val[4] = 1;
1914
1915 Tuner->CH_Ctrl[17].Ctrl_Num = CHCAL_EN_INT_RF ;
1916 Tuner->CH_Ctrl[17].size = 1 ;
1917 Tuner->CH_Ctrl[17].addr[0] = 14;
1918 Tuner->CH_Ctrl[17].bit[0] = 7;
1919 Tuner->CH_Ctrl[17].val[0] = 0;
1920
1921 Tuner->CH_Ctrl[18].Ctrl_Num = TG_LO_DIVVAL ;
1922 Tuner->CH_Ctrl[18].size = 4 ;
1923 Tuner->CH_Ctrl[18].addr[0] = 107;
1924 Tuner->CH_Ctrl[18].bit[0] = 3;
1925 Tuner->CH_Ctrl[18].val[0] = 0;
1926 Tuner->CH_Ctrl[18].addr[1] = 107;
1927 Tuner->CH_Ctrl[18].bit[1] = 4;
1928 Tuner->CH_Ctrl[18].val[1] = 0;
1929 Tuner->CH_Ctrl[18].addr[2] = 107;
1930 Tuner->CH_Ctrl[18].bit[2] = 5;
1931 Tuner->CH_Ctrl[18].val[2] = 0;
1932 Tuner->CH_Ctrl[18].addr[3] = 107;
1933 Tuner->CH_Ctrl[18].bit[3] = 6;
1934 Tuner->CH_Ctrl[18].val[3] = 0;
1935
1936 Tuner->CH_Ctrl[19].Ctrl_Num = TG_LO_SELVAL ;
1937 Tuner->CH_Ctrl[19].size = 3 ;
1938 Tuner->CH_Ctrl[19].addr[0] = 107;
1939 Tuner->CH_Ctrl[19].bit[0] = 7;
1940 Tuner->CH_Ctrl[19].val[0] = 1;
1941 Tuner->CH_Ctrl[19].addr[1] = 106;
1942 Tuner->CH_Ctrl[19].bit[1] = 0;
1943 Tuner->CH_Ctrl[19].val[1] = 1;
1944 Tuner->CH_Ctrl[19].addr[2] = 106;
1945 Tuner->CH_Ctrl[19].bit[2] = 1;
1946 Tuner->CH_Ctrl[19].val[2] = 1;
1947
1948 Tuner->CH_Ctrl[20].Ctrl_Num = TG_DIV_VAL ;
1949 Tuner->CH_Ctrl[20].size = 11 ;
1950 Tuner->CH_Ctrl[20].addr[0] = 109;
1951 Tuner->CH_Ctrl[20].bit[0] = 2;
1952 Tuner->CH_Ctrl[20].val[0] = 0;
1953 Tuner->CH_Ctrl[20].addr[1] = 109;
1954 Tuner->CH_Ctrl[20].bit[1] = 3;
1955 Tuner->CH_Ctrl[20].val[1] = 0;
1956 Tuner->CH_Ctrl[20].addr[2] = 109;
1957 Tuner->CH_Ctrl[20].bit[2] = 4;
1958 Tuner->CH_Ctrl[20].val[2] = 0;
1959 Tuner->CH_Ctrl[20].addr[3] = 109;
1960 Tuner->CH_Ctrl[20].bit[3] = 5;
1961 Tuner->CH_Ctrl[20].val[3] = 0;
1962 Tuner->CH_Ctrl[20].addr[4] = 109;
1963 Tuner->CH_Ctrl[20].bit[4] = 6;
1964 Tuner->CH_Ctrl[20].val[4] = 0;
1965 Tuner->CH_Ctrl[20].addr[5] = 109;
1966 Tuner->CH_Ctrl[20].bit[5] = 7;
1967 Tuner->CH_Ctrl[20].val[5] = 0;
1968 Tuner->CH_Ctrl[20].addr[6] = 108;
1969 Tuner->CH_Ctrl[20].bit[6] = 0;
1970 Tuner->CH_Ctrl[20].val[6] = 0;
1971 Tuner->CH_Ctrl[20].addr[7] = 108;
1972 Tuner->CH_Ctrl[20].bit[7] = 1;
1973 Tuner->CH_Ctrl[20].val[7] = 0;
1974 Tuner->CH_Ctrl[20].addr[8] = 108;
1975 Tuner->CH_Ctrl[20].bit[8] = 2;
1976 Tuner->CH_Ctrl[20].val[8] = 1;
1977 Tuner->CH_Ctrl[20].addr[9] = 108;
1978 Tuner->CH_Ctrl[20].bit[9] = 3;
1979 Tuner->CH_Ctrl[20].val[9] = 1;
1980 Tuner->CH_Ctrl[20].addr[10] = 108;
1981 Tuner->CH_Ctrl[20].bit[10] = 4;
1982 Tuner->CH_Ctrl[20].val[10] = 1;
1983
1984 Tuner->CH_Ctrl[21].Ctrl_Num = TG_VCO_BIAS ;
1985 Tuner->CH_Ctrl[21].size = 6 ;
1986 Tuner->CH_Ctrl[21].addr[0] = 106;
1987 Tuner->CH_Ctrl[21].bit[0] = 2;
1988 Tuner->CH_Ctrl[21].val[0] = 0;
1989 Tuner->CH_Ctrl[21].addr[1] = 106;
1990 Tuner->CH_Ctrl[21].bit[1] = 3;
1991 Tuner->CH_Ctrl[21].val[1] = 0;
1992 Tuner->CH_Ctrl[21].addr[2] = 106;
1993 Tuner->CH_Ctrl[21].bit[2] = 4;
1994 Tuner->CH_Ctrl[21].val[2] = 0;
1995 Tuner->CH_Ctrl[21].addr[3] = 106;
1996 Tuner->CH_Ctrl[21].bit[3] = 5;
1997 Tuner->CH_Ctrl[21].val[3] = 0;
1998 Tuner->CH_Ctrl[21].addr[4] = 106;
1999 Tuner->CH_Ctrl[21].bit[4] = 6;
2000 Tuner->CH_Ctrl[21].val[4] = 0;
2001 Tuner->CH_Ctrl[21].addr[5] = 106;
2002 Tuner->CH_Ctrl[21].bit[5] = 7;
2003 Tuner->CH_Ctrl[21].val[5] = 1;
2004
2005 Tuner->CH_Ctrl[22].Ctrl_Num = SEQ_EXTPOWERUP ;
2006 Tuner->CH_Ctrl[22].size = 1 ;
2007 Tuner->CH_Ctrl[22].addr[0] = 138;
2008 Tuner->CH_Ctrl[22].bit[0] = 4;
2009 Tuner->CH_Ctrl[22].val[0] = 1;
2010
2011 Tuner->CH_Ctrl[23].Ctrl_Num = OVERRIDE_2 ;
2012 Tuner->CH_Ctrl[23].size = 1 ;
2013 Tuner->CH_Ctrl[23].addr[0] = 17;
2014 Tuner->CH_Ctrl[23].bit[0] = 5;
2015 Tuner->CH_Ctrl[23].val[0] = 0;
2016
2017 Tuner->CH_Ctrl[24].Ctrl_Num = OVERRIDE_3 ;
2018 Tuner->CH_Ctrl[24].size = 1 ;
2019 Tuner->CH_Ctrl[24].addr[0] = 111;
2020 Tuner->CH_Ctrl[24].bit[0] = 3;
2021 Tuner->CH_Ctrl[24].val[0] = 0;
2022
2023 Tuner->CH_Ctrl[25].Ctrl_Num = OVERRIDE_4 ;
2024 Tuner->CH_Ctrl[25].size = 1 ;
2025 Tuner->CH_Ctrl[25].addr[0] = 112;
2026 Tuner->CH_Ctrl[25].bit[0] = 7;
2027 Tuner->CH_Ctrl[25].val[0] = 0;
2028
2029 Tuner->CH_Ctrl[26].Ctrl_Num = SEQ_FSM_PULSE ;
2030 Tuner->CH_Ctrl[26].size = 1 ;
2031 Tuner->CH_Ctrl[26].addr[0] = 136;
2032 Tuner->CH_Ctrl[26].bit[0] = 7;
2033 Tuner->CH_Ctrl[26].val[0] = 0;
2034
2035 Tuner->CH_Ctrl[27].Ctrl_Num = GPIO_4B ;
2036 Tuner->CH_Ctrl[27].size = 1 ;
2037 Tuner->CH_Ctrl[27].addr[0] = 149;
2038 Tuner->CH_Ctrl[27].bit[0] = 7;
2039 Tuner->CH_Ctrl[27].val[0] = 0;
2040
2041 Tuner->CH_Ctrl[28].Ctrl_Num = GPIO_3B ;
2042 Tuner->CH_Ctrl[28].size = 1 ;
2043 Tuner->CH_Ctrl[28].addr[0] = 149;
2044 Tuner->CH_Ctrl[28].bit[0] = 6;
2045 Tuner->CH_Ctrl[28].val[0] = 0;
2046
2047 Tuner->CH_Ctrl[29].Ctrl_Num = GPIO_4 ;
2048 Tuner->CH_Ctrl[29].size = 1 ;
2049 Tuner->CH_Ctrl[29].addr[0] = 149;
2050 Tuner->CH_Ctrl[29].bit[0] = 5;
2051 Tuner->CH_Ctrl[29].val[0] = 1;
2052
2053 Tuner->CH_Ctrl[30].Ctrl_Num = GPIO_3 ;
2054 Tuner->CH_Ctrl[30].size = 1 ;
2055 Tuner->CH_Ctrl[30].addr[0] = 149;
2056 Tuner->CH_Ctrl[30].bit[0] = 4;
2057 Tuner->CH_Ctrl[30].val[0] = 1;
2058
2059 Tuner->CH_Ctrl[31].Ctrl_Num = GPIO_1B ;
2060 Tuner->CH_Ctrl[31].size = 1 ;
2061 Tuner->CH_Ctrl[31].addr[0] = 149;
2062 Tuner->CH_Ctrl[31].bit[0] = 3;
2063 Tuner->CH_Ctrl[31].val[0] = 0;
2064
2065 Tuner->CH_Ctrl[32].Ctrl_Num = DAC_A_ENABLE ;
2066 Tuner->CH_Ctrl[32].size = 1 ;
2067 Tuner->CH_Ctrl[32].addr[0] = 93;
2068 Tuner->CH_Ctrl[32].bit[0] = 1;
2069 Tuner->CH_Ctrl[32].val[0] = 0;
2070
2071 Tuner->CH_Ctrl[33].Ctrl_Num = DAC_B_ENABLE ;
2072 Tuner->CH_Ctrl[33].size = 1 ;
2073 Tuner->CH_Ctrl[33].addr[0] = 93;
2074 Tuner->CH_Ctrl[33].bit[0] = 0;
2075 Tuner->CH_Ctrl[33].val[0] = 0;
2076
2077 Tuner->CH_Ctrl[34].Ctrl_Num = DAC_DIN_A ;
2078 Tuner->CH_Ctrl[34].size = 6 ;
2079 Tuner->CH_Ctrl[34].addr[0] = 92;
2080 Tuner->CH_Ctrl[34].bit[0] = 2;
2081 Tuner->CH_Ctrl[34].val[0] = 0;
2082 Tuner->CH_Ctrl[34].addr[1] = 92;
2083 Tuner->CH_Ctrl[34].bit[1] = 3;
2084 Tuner->CH_Ctrl[34].val[1] = 0;
2085 Tuner->CH_Ctrl[34].addr[2] = 92;
2086 Tuner->CH_Ctrl[34].bit[2] = 4;
2087 Tuner->CH_Ctrl[34].val[2] = 0;
2088 Tuner->CH_Ctrl[34].addr[3] = 92;
2089 Tuner->CH_Ctrl[34].bit[3] = 5;
2090 Tuner->CH_Ctrl[34].val[3] = 0;
2091 Tuner->CH_Ctrl[34].addr[4] = 92;
2092 Tuner->CH_Ctrl[34].bit[4] = 6;
2093 Tuner->CH_Ctrl[34].val[4] = 0;
2094 Tuner->CH_Ctrl[34].addr[5] = 92;
2095 Tuner->CH_Ctrl[34].bit[5] = 7;
2096 Tuner->CH_Ctrl[34].val[5] = 0;
2097
2098 Tuner->CH_Ctrl[35].Ctrl_Num = DAC_DIN_B ;
2099 Tuner->CH_Ctrl[35].size = 6 ;
2100 Tuner->CH_Ctrl[35].addr[0] = 93;
2101 Tuner->CH_Ctrl[35].bit[0] = 2;
2102 Tuner->CH_Ctrl[35].val[0] = 0;
2103 Tuner->CH_Ctrl[35].addr[1] = 93;
2104 Tuner->CH_Ctrl[35].bit[1] = 3;
2105 Tuner->CH_Ctrl[35].val[1] = 0;
2106 Tuner->CH_Ctrl[35].addr[2] = 93;
2107 Tuner->CH_Ctrl[35].bit[2] = 4;
2108 Tuner->CH_Ctrl[35].val[2] = 0;
2109 Tuner->CH_Ctrl[35].addr[3] = 93;
2110 Tuner->CH_Ctrl[35].bit[3] = 5;
2111 Tuner->CH_Ctrl[35].val[3] = 0;
2112 Tuner->CH_Ctrl[35].addr[4] = 93;
2113 Tuner->CH_Ctrl[35].bit[4] = 6;
2114 Tuner->CH_Ctrl[35].val[4] = 0;
2115 Tuner->CH_Ctrl[35].addr[5] = 93;
2116 Tuner->CH_Ctrl[35].bit[5] = 7;
2117 Tuner->CH_Ctrl[35].val[5] = 0;
2118
2119#ifdef _MXL_PRODUCTION
2120 Tuner->CH_Ctrl[36].Ctrl_Num = RFSYN_EN_DIV ;
2121 Tuner->CH_Ctrl[36].size = 1 ;
2122 Tuner->CH_Ctrl[36].addr[0] = 109;
2123 Tuner->CH_Ctrl[36].bit[0] = 1;
2124 Tuner->CH_Ctrl[36].val[0] = 1;
2125
2126 Tuner->CH_Ctrl[37].Ctrl_Num = RFSYN_DIVM ;
2127 Tuner->CH_Ctrl[37].size = 2 ;
2128 Tuner->CH_Ctrl[37].addr[0] = 112;
2129 Tuner->CH_Ctrl[37].bit[0] = 5;
2130 Tuner->CH_Ctrl[37].val[0] = 0;
2131 Tuner->CH_Ctrl[37].addr[1] = 112;
2132 Tuner->CH_Ctrl[37].bit[1] = 6;
2133 Tuner->CH_Ctrl[37].val[1] = 0;
2134
2135 Tuner->CH_Ctrl[38].Ctrl_Num = DN_BYPASS_AGC_I2C ;
2136 Tuner->CH_Ctrl[38].size = 1 ;
2137 Tuner->CH_Ctrl[38].addr[0] = 65;
2138 Tuner->CH_Ctrl[38].bit[0] = 1;
2139 Tuner->CH_Ctrl[38].val[0] = 0;
2140#endif
2141
2142 return 0 ;
2143}
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159// MaxLinear source code - MXL5005_c.cpp
2160
2161
2162
2163// MXL5005.cpp : Defines the initialization routines for the DLL.
2164// 2.6.12
2165
2166
2167//#ifdef _MXL_HEADER
2168//#include "stdafx.h"
2169//#endif
2170//#include "MXL5005_c.h"
2171
2172
2173void InitTunerControls(Tuner_struct *Tuner)
2174{
2175 MXL5005_RegisterInit(Tuner) ;
2176 MXL5005_ControlInit(Tuner) ;
2177#ifdef _MXL_INTERNAL
2178 MXL5005_MXLControlInit(Tuner) ;
2179#endif
2180}
2181
2182
2183
2184///////////////////////////////////////////////////////////////////////////////
2185// //
2186// Function: MXL_ConfigTuner //
2187// //
2188// Description: Configure MXL5005Tuner structure for desired //
2189// Channel Bandwidth/Channel Frequency //
2190// //
2191// //
2192// Functions used: //
2193// MXL_SynthIFLO_Calc //
2194// //
2195// Inputs: //
2196// Tuner_struct: structure defined at higher level //
2197// Mode: Tuner Mode (Analog/Digital) //
2198// IF_Mode: IF Mode ( Zero/Low ) //
2199// Bandwidth: Filter Channel Bandwidth (in Hz) //
2200// IF_out: Desired IF out Frequency (in Hz) //
2201// Fxtal: Crystal Frerquency (in Hz) //
2202// TOP: 0: Dual AGC; Value: take over point //
2203// IF_OUT_LOAD: IF out load resistor (200/300 Ohms) //
2204// CLOCK_OUT: 0: Turn off clock out; 1: turn on clock out //
2205// DIV_OUT: 0: Div-1; 1: Div-4 //
2206// CAPSELECT: 0: Disable On-chip pulling cap; 1: Enable //
2207// EN_RSSI: 0: Disable RSSI; 1: Enable RSSI //
2208// //
2209// Outputs: //
2210// Tuner //
2211// //
2212// Return: //
2213// 0 : Successful //
2214// > 0 : Failed //
2215// //
2216///////////////////////////////////////////////////////////////////////////////
2217_u16 MXL5005_TunerConfig(Tuner_struct *Tuner,
2218 _u8 Mode, // 0: Analog Mode ; 1: Digital Mode
2219 _u8 IF_mode, // for Analog Mode, 0: zero IF; 1: low IF
2220 _u32 Bandwidth, // filter channel bandwidth (6, 7, 8)
2221 _u32 IF_out, // Desired IF Out Frequency
2222 _u32 Fxtal, // XTAL Frequency
2223 _u8 AGC_Mode, // AGC Mode - Dual AGC: 0, Single AGC: 1
2224 _u16 TOP, // 0: Dual AGC; Value: take over point
2225 _u16 IF_OUT_LOAD, // IF Out Load Resistor (200 / 300 Ohms)
2226 _u8 CLOCK_OUT, // 0: turn off clock out; 1: turn on clock out
2227 _u8 DIV_OUT, // 0: Div-1; 1: Div-4
2228 _u8 CAPSELECT, // 0: disable On-Chip pulling cap; 1: enable
2229 _u8 EN_RSSI, // 0: disable RSSI; 1: enable RSSI
2230 _u8 Mod_Type, // Modulation Type;
2231 // 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable
2232 _u8 TF_Type // Tracking Filter
2233 // 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H
2234 )
2235{
2236 _u16 status = 0 ;
2237
2238 Tuner->Mode = Mode ;
2239 Tuner->IF_Mode = IF_mode ;
2240 Tuner->Chan_Bandwidth = Bandwidth ;
2241 Tuner->IF_OUT = IF_out ;
2242 Tuner->Fxtal = Fxtal ;
2243 Tuner->AGC_Mode = AGC_Mode ;
2244 Tuner->TOP = TOP ;
2245 Tuner->IF_OUT_LOAD = IF_OUT_LOAD ;
2246 Tuner->CLOCK_OUT = CLOCK_OUT ;
2247 Tuner->DIV_OUT = DIV_OUT ;
2248 Tuner->CAPSELECT = CAPSELECT ;
2249 Tuner->EN_RSSI = EN_RSSI ;
2250 Tuner->Mod_Type = Mod_Type ;
2251 Tuner->TF_Type = TF_Type ;
2252
2253
2254
2255 //
2256 // Initialize all the controls and registers
2257 //
2258 InitTunerControls (Tuner) ;
2259 //
2260 // Synthesizer LO frequency calculation
2261 //
2262 MXL_SynthIFLO_Calc( Tuner ) ;
2263
2264 return status ;
2265}
2266
2267///////////////////////////////////////////////////////////////////////////////
2268// //
2269// Function: MXL_SynthIFLO_Calc //
2270// //
2271// Description: Calculate Internal IF-LO Frequency //
2272// //
2273// Globals: //
2274// NONE //
2275// //
2276// Functions used: //
2277// NONE //
2278// //
2279// Inputs: //
2280// Tuner_struct: structure defined at higher level //
2281// //
2282// Outputs: //
2283// Tuner //
2284// //
2285// Return: //
2286// 0 : Successful //
2287// > 0 : Failed //
2288// //
2289///////////////////////////////////////////////////////////////////////////////
2290void MXL_SynthIFLO_Calc(Tuner_struct *Tuner)
2291{
2292 if (Tuner->Mode == 1) // Digital Mode
2293 {
2294 Tuner->IF_LO = Tuner->IF_OUT ;
2295 }
2296 else // Analog Mode
2297 {
2298 if(Tuner->IF_Mode == 0) // Analog Zero IF mode
2299 {
2300 Tuner->IF_LO = Tuner->IF_OUT + 400000 ;
2301 }
2302 else // Analog Low IF mode
2303 {
2304 Tuner->IF_LO = Tuner->IF_OUT + Tuner->Chan_Bandwidth/2 ;
2305 }
2306 }
2307}
2308
2309///////////////////////////////////////////////////////////////////////////////
2310// //
2311// Function: MXL_SynthRFTGLO_Calc //
2312// //
2313// Description: Calculate Internal RF-LO frequency and //
2314// internal Tone-Gen(TG)-LO frequency //
2315// //
2316// Globals: //
2317// NONE //
2318// //
2319// Functions used: //
2320// NONE //
2321// //
2322// Inputs: //
2323// Tuner_struct: structure defined at higher level //
2324// //
2325// Outputs: //
2326// Tuner //
2327// //
2328// Return: //
2329// 0 : Successful //
2330// > 0 : Failed //
2331// //
2332///////////////////////////////////////////////////////////////////////////////
2333void MXL_SynthRFTGLO_Calc(Tuner_struct *Tuner)
2334{
2335 if (Tuner->Mode == 1) // Digital Mode
2336 {
2337 //remove 20.48MHz setting for 2.6.10
2338 Tuner->RF_LO = Tuner->RF_IN ;
2339 Tuner->TG_LO = Tuner->RF_IN - 750000 ; //change for 2.6.6
2340 }
2341 else // Analog Mode
2342 {
2343 if(Tuner->IF_Mode == 0) // Analog Zero IF mode
2344 {
2345 Tuner->RF_LO = Tuner->RF_IN - 400000 ;
2346 Tuner->TG_LO = Tuner->RF_IN - 1750000 ;
2347 }
2348 else // Analog Low IF mode
2349 {
2350 Tuner->RF_LO = Tuner->RF_IN - Tuner->Chan_Bandwidth/2 ;
2351 Tuner->TG_LO = Tuner->RF_IN - Tuner->Chan_Bandwidth + 500000 ;
2352 }
2353 }
2354}
2355
2356///////////////////////////////////////////////////////////////////////////////
2357// //
2358// Function: MXL_OverwriteICDefault //
2359// //
2360// Description: Overwrite the Default Register Setting //
2361// //
2362// //
2363// Functions used: //
2364// //
2365// Inputs: //
2366// Tuner_struct: structure defined at higher level //
2367// Outputs: //
2368// Tuner //
2369// //
2370// Return: //
2371// 0 : Successful //
2372// > 0 : Failed //
2373// //
2374///////////////////////////////////////////////////////////////////////////////
2375_u16 MXL_OverwriteICDefault( Tuner_struct *Tuner)
2376{
2377 _u16 status = 0 ;
2378
2379 status += MXL_ControlWrite(Tuner, OVERRIDE_1, 1) ;
2380 status += MXL_ControlWrite(Tuner, OVERRIDE_2, 1) ;
2381 status += MXL_ControlWrite(Tuner, OVERRIDE_3, 1) ;
2382 status += MXL_ControlWrite(Tuner, OVERRIDE_4, 1) ;
2383
2384 return status ;
2385}
2386
2387///////////////////////////////////////////////////////////////////////////////
2388// //
2389// Function: MXL_BlockInit //
2390// //
2391// Description: Tuner Initialization as a function of 'User Settings' //
2392// * User settings in Tuner strcuture must be assigned //
2393// first //
2394// //
2395// Globals: //
2396// NONE //
2397// //
2398// Functions used: //
2399// Tuner_struct: structure defined at higher level //
2400// //
2401// Inputs: //
2402// Tuner : Tuner structure defined at higher level //
2403// //
2404// Outputs: //
2405// Tuner //
2406// //
2407// Return: //
2408// 0 : Successful //
2409// > 0 : Failed //
2410// //
2411///////////////////////////////////////////////////////////////////////////////
2412_u16 MXL_BlockInit( Tuner_struct *Tuner )
2413{
2414 _u16 status = 0 ;
2415
2416 status += MXL_OverwriteICDefault(Tuner) ;
2417
2418 //
2419 // Downconverter Control
2420 // Dig Ana
2421 status += MXL_ControlWrite(Tuner, DN_IQTN_AMP_CUT, Tuner->Mode ? 1 : 0) ;
2422
2423 //
2424 // Filter Control
2425 // Dig Ana
2426 status += MXL_ControlWrite(Tuner, BB_MODE, Tuner->Mode ? 0 : 1) ;
2427 status += MXL_ControlWrite(Tuner, BB_BUF, Tuner->Mode ? 3 : 2) ;
2428 status += MXL_ControlWrite(Tuner, BB_BUF_OA, Tuner->Mode ? 1 : 0) ;
2429
2430 status += MXL_ControlWrite(Tuner, BB_IQSWAP, Tuner->Mode ? 0 : 1) ;
2431 status += MXL_ControlWrite(Tuner, BB_INITSTATE_DLPF_TUNE, 0) ;
2432
2433 // Initialize Low-Pass Filter
2434 if (Tuner->Mode) { // Digital Mode
2435 switch (Tuner->Chan_Bandwidth) {
2436 case 8000000:
2437 status += MXL_ControlWrite(Tuner, BB_DLPF_BANDSEL, 0) ;
2438 break ;
2439 case 7000000:
2440 status += MXL_ControlWrite(Tuner, BB_DLPF_BANDSEL, 2) ;
2441 break ;
2442 case 6000000:
2443 status += MXL_ControlWrite(Tuner, BB_DLPF_BANDSEL, 3) ;
2444 break ;
2445 }
2446 } else { // Analog Mode
2447 switch (Tuner->Chan_Bandwidth) {
2448 case 8000000: // Low Zero
2449 status += MXL_ControlWrite(Tuner, BB_ALPF_BANDSELECT, (Tuner->IF_Mode ? 0 : 3)) ;
2450 break ;
2451 case 7000000:
2452 status += MXL_ControlWrite(Tuner, BB_ALPF_BANDSELECT, (Tuner->IF_Mode ? 1 : 4)) ;
2453 break ;
2454 case 6000000:
2455 status += MXL_ControlWrite(Tuner, BB_ALPF_BANDSELECT, (Tuner->IF_Mode ? 2 : 5)) ;
2456 break ;
2457 }
2458 }
2459
2460 //
2461 // Charge Pump Control
2462 // Dig Ana
2463 status += MXL_ControlWrite(Tuner, RFSYN_CHP_GAIN, Tuner->Mode ? 5 : 8) ;
2464 status += MXL_ControlWrite(Tuner, RFSYN_EN_CHP_HIGAIN, Tuner->Mode ? 1 : 1) ;
2465 status += MXL_ControlWrite(Tuner, EN_CHP_LIN_B, Tuner->Mode ? 0 : 0) ;
2466
2467 //
2468 // AGC TOP Control
2469 //
2470 if (Tuner->AGC_Mode == 0) // Dual AGC
2471 {
2472 status += MXL_ControlWrite(Tuner, AGC_IF, 15) ;
2473 status += MXL_ControlWrite(Tuner, AGC_RF, 15) ;
2474 }
2475 else // Single AGC Mode Dig Ana
2476 status += MXL_ControlWrite(Tuner, AGC_RF, Tuner->Mode? 15 : 12) ;
2477
2478
2479 if (Tuner->TOP == 55) // TOP == 5.5
2480 status += MXL_ControlWrite(Tuner, AGC_IF, 0x0) ;
2481
2482 if (Tuner->TOP == 72) // TOP == 7.2
2483 status += MXL_ControlWrite(Tuner, AGC_IF, 0x1) ;
2484
2485 if (Tuner->TOP == 92) // TOP == 9.2
2486 status += MXL_ControlWrite(Tuner, AGC_IF, 0x2) ;
2487
2488 if (Tuner->TOP == 110) // TOP == 11.0
2489 status += MXL_ControlWrite(Tuner, AGC_IF, 0x3) ;
2490
2491 if (Tuner->TOP == 129) // TOP == 12.9
2492 status += MXL_ControlWrite(Tuner, AGC_IF, 0x4) ;
2493
2494 if (Tuner->TOP == 147) // TOP == 14.7
2495 status += MXL_ControlWrite(Tuner, AGC_IF, 0x5) ;
2496
2497 if (Tuner->TOP == 168) // TOP == 16.8
2498 status += MXL_ControlWrite(Tuner, AGC_IF, 0x6) ;
2499
2500 if (Tuner->TOP == 194) // TOP == 19.4
2501 status += MXL_ControlWrite(Tuner, AGC_IF, 0x7) ;
2502
2503 if (Tuner->TOP == 212) // TOP == 21.2
2504 status += MXL_ControlWrite(Tuner, AGC_IF, 0x9) ;
2505
2506 if (Tuner->TOP == 232) // TOP == 23.2
2507 status += MXL_ControlWrite(Tuner, AGC_IF, 0xA) ;
2508
2509 if (Tuner->TOP == 252) // TOP == 25.2
2510 status += MXL_ControlWrite(Tuner, AGC_IF, 0xB) ;
2511
2512 if (Tuner->TOP == 271) // TOP == 27.1
2513 status += MXL_ControlWrite(Tuner, AGC_IF, 0xC) ;
2514
2515 if (Tuner->TOP == 292) // TOP == 29.2
2516 status += MXL_ControlWrite(Tuner, AGC_IF, 0xD) ;
2517
2518 if (Tuner->TOP == 317) // TOP == 31.7
2519 status += MXL_ControlWrite(Tuner, AGC_IF, 0xE) ;
2520
2521 if (Tuner->TOP == 349) // TOP == 34.9
2522 status += MXL_ControlWrite(Tuner, AGC_IF, 0xF) ;
2523
2524 //
2525 // IF Synthesizer Control
2526 //
2527 status += MXL_IFSynthInit( Tuner ) ;
2528
2529 //
2530 // IF UpConverter Control
2531 if (Tuner->IF_OUT_LOAD == 200)
2532 {
2533 status += MXL_ControlWrite(Tuner, DRV_RES_SEL, 6) ;
2534 status += MXL_ControlWrite(Tuner, I_DRIVER, 2) ;
2535 }
2536 if (Tuner->IF_OUT_LOAD == 300)
2537 {
2538 status += MXL_ControlWrite(Tuner, DRV_RES_SEL, 4) ;
2539 status += MXL_ControlWrite(Tuner, I_DRIVER, 1) ;
2540 }
2541
2542 //
2543 // Anti-Alias Filtering Control
2544 //
2545 // initialise Anti-Aliasing Filter
2546 if (Tuner->Mode) {// Digital Mode
2547 if (Tuner->IF_OUT >= 4000000UL && Tuner->IF_OUT <= 6280000UL) {
2548 status += MXL_ControlWrite(Tuner, EN_AAF, 1) ;
2549 status += MXL_ControlWrite(Tuner, EN_3P, 1) ;
2550 status += MXL_ControlWrite(Tuner, EN_AUX_3P, 1) ;
2551 status += MXL_ControlWrite(Tuner, SEL_AAF_BAND, 0) ;
2552 }
2553 if ((Tuner->IF_OUT == 36125000UL) || (Tuner->IF_OUT == 36150000UL)) {
2554 status += MXL_ControlWrite(Tuner, EN_AAF, 1) ;
2555 status += MXL_ControlWrite(Tuner, EN_3P, 1) ;
2556 status += MXL_ControlWrite(Tuner, EN_AUX_3P, 1) ;
2557 status += MXL_ControlWrite(Tuner, SEL_AAF_BAND, 1) ;
2558 }
2559 if (Tuner->IF_OUT > 36150000UL) {
2560 status += MXL_ControlWrite(Tuner, EN_AAF, 0) ;
2561 status += MXL_ControlWrite(Tuner, EN_3P, 1) ;
2562 status += MXL_ControlWrite(Tuner, EN_AUX_3P, 1) ;
2563 status += MXL_ControlWrite(Tuner, SEL_AAF_BAND, 1) ;
2564 }
2565 } else { // Analog Mode
2566 if (Tuner->IF_OUT >= 4000000UL && Tuner->IF_OUT <= 5000000UL)
2567 {
2568 status += MXL_ControlWrite(Tuner, EN_AAF, 1) ;
2569 status += MXL_ControlWrite(Tuner, EN_3P, 1) ;
2570 status += MXL_ControlWrite(Tuner, EN_AUX_3P, 1) ;
2571 status += MXL_ControlWrite(Tuner, SEL_AAF_BAND, 0) ;
2572 }
2573 if (Tuner->IF_OUT > 5000000UL)
2574 {
2575 status += MXL_ControlWrite(Tuner, EN_AAF, 0) ;
2576 status += MXL_ControlWrite(Tuner, EN_3P, 0) ;
2577 status += MXL_ControlWrite(Tuner, EN_AUX_3P, 0) ;
2578 status += MXL_ControlWrite(Tuner, SEL_AAF_BAND, 0) ;
2579 }
2580 }
2581
2582 //
2583 // Demod Clock Out
2584 //
2585 if (Tuner->CLOCK_OUT)
2586 status += MXL_ControlWrite(Tuner, SEQ_ENCLK16_CLK_OUT, 1) ;
2587 else
2588 status += MXL_ControlWrite(Tuner, SEQ_ENCLK16_CLK_OUT, 0) ;
2589
2590 if (Tuner->DIV_OUT == 1)
2591 status += MXL_ControlWrite(Tuner, SEQ_SEL4_16B, 1) ;
2592 if (Tuner->DIV_OUT == 0)
2593 status += MXL_ControlWrite(Tuner, SEQ_SEL4_16B, 0) ;
2594
2595 //
2596 // Crystal Control
2597 //
2598 if (Tuner->CAPSELECT)
2599 status += MXL_ControlWrite(Tuner, XTAL_CAPSELECT, 1) ;
2600 else
2601 status += MXL_ControlWrite(Tuner, XTAL_CAPSELECT, 0) ;
2602
2603 if (Tuner->Fxtal >= 12000000UL && Tuner->Fxtal <= 16000000UL)
2604 status += MXL_ControlWrite(Tuner, IF_SEL_DBL, 1) ;
2605 if (Tuner->Fxtal > 16000000UL && Tuner->Fxtal <= 32000000UL)
2606 status += MXL_ControlWrite(Tuner, IF_SEL_DBL, 0) ;
2607
2608 if (Tuner->Fxtal >= 12000000UL && Tuner->Fxtal <= 22000000UL)
2609 status += MXL_ControlWrite(Tuner, RFSYN_R_DIV, 3) ;
2610 if (Tuner->Fxtal > 22000000UL && Tuner->Fxtal <= 32000000UL)
2611 status += MXL_ControlWrite(Tuner, RFSYN_R_DIV, 0) ;
2612
2613 //
2614 // Misc Controls
2615 //
2616 if (Tuner->Mode == 0 && Tuner->IF_Mode == 1) // Analog LowIF mode
2617 status += MXL_ControlWrite(Tuner, SEQ_EXTIQFSMPULSE, 0);
2618 else
2619 status += MXL_ControlWrite(Tuner, SEQ_EXTIQFSMPULSE, 1);
2620
2621// status += MXL_ControlRead(Tuner, IF_DIVVAL, &IF_DIVVAL_Val) ;
2622
2623 // Set TG_R_DIV
2624 status += MXL_ControlWrite(Tuner, TG_R_DIV, MXL_Ceiling(Tuner->Fxtal, 1000000)) ;
2625
2626 //
2627 // Apply Default value to BB_INITSTATE_DLPF_TUNE
2628 //
2629
2630
2631
2632 //
2633 // RSSI Control
2634 //
2635 if(Tuner->EN_RSSI)
2636 {
2637 status += MXL_ControlWrite(Tuner, SEQ_EXTSYNTHCALIF, 1) ;
2638 status += MXL_ControlWrite(Tuner, SEQ_EXTDCCAL, 1) ;
2639 status += MXL_ControlWrite(Tuner, AGC_EN_RSSI, 1) ;
2640 status += MXL_ControlWrite(Tuner, RFA_ENCLKRFAGC, 1) ;
2641 // RSSI reference point
2642 status += MXL_ControlWrite(Tuner, RFA_RSSI_REF, 2) ;
2643 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFH, 3) ;
2644 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFL, 1) ;
2645 // TOP point
2646 status += MXL_ControlWrite(Tuner, RFA_FLR, 0) ;
2647 status += MXL_ControlWrite(Tuner, RFA_CEIL, 12) ;
2648 }
2649
2650 //
2651 // Modulation type bit settings
2652 // Override the control values preset
2653 //
2654 if (Tuner->Mod_Type == MXL_DVBT) // DVB-T Mode
2655 {
2656 Tuner->AGC_Mode = 1 ; // Single AGC Mode
2657
2658 // Enable RSSI
2659 status += MXL_ControlWrite(Tuner, SEQ_EXTSYNTHCALIF, 1) ;
2660 status += MXL_ControlWrite(Tuner, SEQ_EXTDCCAL, 1) ;
2661 status += MXL_ControlWrite(Tuner, AGC_EN_RSSI, 1) ;
2662 status += MXL_ControlWrite(Tuner, RFA_ENCLKRFAGC, 1) ;
2663 // RSSI reference point
2664 status += MXL_ControlWrite(Tuner, RFA_RSSI_REF, 3) ;
2665 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFH, 5) ;
2666 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFL, 1) ;
2667 // TOP point
2668 status += MXL_ControlWrite(Tuner, RFA_FLR, 2) ;
2669 status += MXL_ControlWrite(Tuner, RFA_CEIL, 13) ;
2670 if (Tuner->IF_OUT <= 6280000UL) // Low IF
2671 status += MXL_ControlWrite(Tuner, BB_IQSWAP, 0) ;
2672 else // High IF
2673 status += MXL_ControlWrite(Tuner, BB_IQSWAP, 1) ;
2674
2675 }
2676 if (Tuner->Mod_Type == MXL_ATSC) // ATSC Mode
2677 {
2678 Tuner->AGC_Mode = 1 ; // Single AGC Mode
2679
2680 // Enable RSSI
2681 status += MXL_ControlWrite(Tuner, SEQ_EXTSYNTHCALIF, 1) ;
2682 status += MXL_ControlWrite(Tuner, SEQ_EXTDCCAL, 1) ;
2683 status += MXL_ControlWrite(Tuner, AGC_EN_RSSI, 1) ;
2684 status += MXL_ControlWrite(Tuner, RFA_ENCLKRFAGC, 1) ;
2685 // RSSI reference point
2686 status += MXL_ControlWrite(Tuner, RFA_RSSI_REF, 2) ;
2687 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFH, 4) ;
2688 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFL, 1) ;
2689 // TOP point
2690 status += MXL_ControlWrite(Tuner, RFA_FLR, 2) ;
2691 status += MXL_ControlWrite(Tuner, RFA_CEIL, 13) ;
2692
2693 status += MXL_ControlWrite(Tuner, BB_INITSTATE_DLPF_TUNE, 1) ;
2694 status += MXL_ControlWrite(Tuner, RFSYN_CHP_GAIN, 5) ; // Low Zero
2695 if (Tuner->IF_OUT <= 6280000UL) // Low IF
2696 status += MXL_ControlWrite(Tuner, BB_IQSWAP, 0) ;
2697 else // High IF
2698 status += MXL_ControlWrite(Tuner, BB_IQSWAP, 1) ;
2699 }
2700 if (Tuner->Mod_Type == MXL_QAM) // QAM Mode
2701 {
2702 Tuner->Mode = MXL_DIGITAL_MODE;
2703
2704 //Tuner->AGC_Mode = 1 ; // Single AGC Mode
2705
2706 // Disable RSSI //change here for v2.6.5
2707 status += MXL_ControlWrite(Tuner, SEQ_EXTSYNTHCALIF, 1) ;
2708 status += MXL_ControlWrite(Tuner, SEQ_EXTDCCAL, 1) ;
2709 status += MXL_ControlWrite(Tuner, AGC_EN_RSSI, 0) ;
2710 status += MXL_ControlWrite(Tuner, RFA_ENCLKRFAGC, 1) ;
2711
2712 // RSSI reference point
2713 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFH, 5) ;
2714 status += MXL_ControlWrite(Tuner, RFA_RSSI_REF, 3) ;
2715 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFL, 2) ;
2716
2717 status += MXL_ControlWrite(Tuner, RFSYN_CHP_GAIN, 3) ; //change here for v2.6.5
2718
2719 if (Tuner->IF_OUT <= 6280000UL) // Low IF
2720 status += MXL_ControlWrite(Tuner, BB_IQSWAP, 0) ;
2721 else // High IF
2722 status += MXL_ControlWrite(Tuner, BB_IQSWAP, 1) ;
2723 }
2724 if (Tuner->Mod_Type == MXL_ANALOG_CABLE) // Analog Cable Mode
2725 {
2726 //Tuner->Mode = MXL_DIGITAL_MODE ;
2727 Tuner->AGC_Mode = 1 ; // Single AGC Mode
2728
2729 // Disable RSSI
2730 status += MXL_ControlWrite(Tuner, SEQ_EXTSYNTHCALIF, 1) ;
2731 status += MXL_ControlWrite(Tuner, SEQ_EXTDCCAL, 1) ;
2732 status += MXL_ControlWrite(Tuner, AGC_EN_RSSI, 0) ;
2733 status += MXL_ControlWrite(Tuner, RFA_ENCLKRFAGC, 1) ;
2734
2735 status += MXL_ControlWrite(Tuner, AGC_IF, 1) ; //change for 2.6.3
2736 status += MXL_ControlWrite(Tuner, AGC_RF, 15) ;
2737
2738 status += MXL_ControlWrite(Tuner, BB_IQSWAP, 1) ;
2739 }
2740
2741 if (Tuner->Mod_Type == MXL_ANALOG_OTA) //Analog OTA Terrestrial mode add for 2.6.7
2742 {
2743 //Tuner->Mode = MXL_ANALOG_MODE;
2744
2745 // Enable RSSI
2746 status += MXL_ControlWrite(Tuner, SEQ_EXTSYNTHCALIF, 1) ;
2747 status += MXL_ControlWrite(Tuner, SEQ_EXTDCCAL, 1) ;
2748 status += MXL_ControlWrite(Tuner, AGC_EN_RSSI, 1) ;
2749 status += MXL_ControlWrite(Tuner, RFA_ENCLKRFAGC, 1) ;
2750
2751 // RSSI reference point
2752 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFH, 5) ;
2753 status += MXL_ControlWrite(Tuner, RFA_RSSI_REF, 3) ;
2754 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFL, 2) ;
2755
2756 status += MXL_ControlWrite(Tuner, RFSYN_CHP_GAIN, 3) ;
2757
2758 status += MXL_ControlWrite(Tuner, BB_IQSWAP, 1) ;
2759 }
2760
2761 // RSSI disable
2762 if(Tuner->EN_RSSI==0)
2763 {
2764 status += MXL_ControlWrite(Tuner, SEQ_EXTSYNTHCALIF, 1) ;
2765 status += MXL_ControlWrite(Tuner, SEQ_EXTDCCAL, 1) ;
2766 status += MXL_ControlWrite(Tuner, AGC_EN_RSSI, 0) ;
2767 status += MXL_ControlWrite(Tuner, RFA_ENCLKRFAGC, 1) ;
2768 }
2769
2770 return status ;
2771}
2772
2773///////////////////////////////////////////////////////////////////////////////
2774// //
2775// Function: MXL_IFSynthInit //
2776// //
2777// Description: Tuner IF Synthesizer related register initialization //
2778// //
2779// Globals: //
2780// NONE //
2781// //
2782// Functions used: //
2783// Tuner_struct: structure defined at higher level //
2784// //
2785// Inputs: //
2786// Tuner : Tuner structure defined at higher level //
2787// //
2788// Outputs: //
2789// Tuner //
2790// //
2791// Return: //
2792// 0 : Successful //
2793// > 0 : Failed //
2794// //
2795///////////////////////////////////////////////////////////////////////////////
2796_u16 MXL_IFSynthInit( Tuner_struct * Tuner )
2797{
2798 _u16 status = 0 ;
2799 // Declare Local Variables
2800 _u32 Fref = 0 ;
2801 _u32 Kdbl, intModVal ;
2802 _u32 fracModVal ;
2803 Kdbl = 2 ;
2804
2805 if (Tuner->Fxtal >= 12000000UL && Tuner->Fxtal <= 16000000UL)
2806 Kdbl = 2 ;
2807 if (Tuner->Fxtal > 16000000UL && Tuner->Fxtal <= 32000000UL)
2808 Kdbl = 1 ;
2809
2810 //
2811 // IF Synthesizer Control
2812 //
2813 if (Tuner->Mode == 0 && Tuner->IF_Mode == 1) // Analog Low IF mode
2814 {
2815 if (Tuner->IF_LO == 41000000UL) {
2816 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2817 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x0C) ;
2818 Fref = 328000000UL ;
2819 }
2820 if (Tuner->IF_LO == 47000000UL) {
2821 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2822 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2823 Fref = 376000000UL ;
2824 }
2825 if (Tuner->IF_LO == 54000000UL) {
2826 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x10) ;
2827 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x0C) ;
2828 Fref = 324000000UL ;
2829 }
2830 if (Tuner->IF_LO == 60000000UL) {
2831 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x10) ;
2832 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2833 Fref = 360000000UL ;
2834 }
2835 if (Tuner->IF_LO == 39250000UL) {
2836 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2837 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x0C) ;
2838 Fref = 314000000UL ;
2839 }
2840 if (Tuner->IF_LO == 39650000UL) {
2841 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2842 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x0C) ;
2843 Fref = 317200000UL ;
2844 }
2845 if (Tuner->IF_LO == 40150000UL) {
2846 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2847 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x0C) ;
2848 Fref = 321200000UL ;
2849 }
2850 if (Tuner->IF_LO == 40650000UL) {
2851 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2852 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x0C) ;
2853 Fref = 325200000UL ;
2854 }
2855 }
2856
2857 if (Tuner->Mode || (Tuner->Mode == 0 && Tuner->IF_Mode == 0))
2858 {
2859 if (Tuner->IF_LO == 57000000UL) {
2860 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x10) ;
2861 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2862 Fref = 342000000UL ;
2863 }
2864 if (Tuner->IF_LO == 44000000UL) {
2865 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2866 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2867 Fref = 352000000UL ;
2868 }
2869 if (Tuner->IF_LO == 43750000UL) {
2870 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2871 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2872 Fref = 350000000UL ;
2873 }
2874 if (Tuner->IF_LO == 36650000UL) {
2875 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x04) ;
2876 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2877 Fref = 366500000UL ;
2878 }
2879 if (Tuner->IF_LO == 36150000UL) {
2880 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x04) ;
2881 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2882 Fref = 361500000UL ;
2883 }
2884 if (Tuner->IF_LO == 36000000UL) {
2885 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x04) ;
2886 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2887 Fref = 360000000UL ;
2888 }
2889 if (Tuner->IF_LO == 35250000UL) {
2890 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x04) ;
2891 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2892 Fref = 352500000UL ;
2893 }
2894 if (Tuner->IF_LO == 34750000UL) {
2895 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x04) ;
2896 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2897 Fref = 347500000UL ;
2898 }
2899 if (Tuner->IF_LO == 6280000UL) {
2900 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x07) ;
2901 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2902 Fref = 376800000UL ;
2903 }
2904 if (Tuner->IF_LO == 5000000UL) {
2905 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x09) ;
2906 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2907 Fref = 360000000UL ;
2908 }
2909 if (Tuner->IF_LO == 4500000UL) {
2910 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x06) ;
2911 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2912 Fref = 360000000UL ;
2913 }
2914 if (Tuner->IF_LO == 4570000UL) {
2915 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x06) ;
2916 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2917 Fref = 365600000UL ;
2918 }
2919 if (Tuner->IF_LO == 4000000UL) {
2920 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x05) ;
2921 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2922 Fref = 360000000UL ;
2923 }
2924 if (Tuner->IF_LO == 57400000UL)
2925 {
2926 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x10) ;
2927 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2928 Fref = 344400000UL ;
2929 }
2930 if (Tuner->IF_LO == 44400000UL)
2931 {
2932 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2933 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2934 Fref = 355200000UL ;
2935 }
2936 if (Tuner->IF_LO == 44150000UL)
2937 {
2938 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x08) ;
2939 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2940 Fref = 353200000UL ;
2941 }
2942 if (Tuner->IF_LO == 37050000UL)
2943 {
2944 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x04) ;
2945 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2946 Fref = 370500000UL ;
2947 }
2948 if (Tuner->IF_LO == 36550000UL)
2949 {
2950 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x04) ;
2951 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2952 Fref = 365500000UL ;
2953 }
2954 if (Tuner->IF_LO == 36125000UL) {
2955 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x04) ;
2956 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2957 Fref = 361250000UL ;
2958 }
2959 if (Tuner->IF_LO == 6000000UL) {
2960 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x07) ;
2961 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2962 Fref = 360000000UL ;
2963 }
2964 if (Tuner->IF_LO == 5400000UL)
2965 {
2966 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x07) ;
2967 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x0C) ;
2968 Fref = 324000000UL ;
2969 }
2970 if (Tuner->IF_LO == 5380000UL) {
2971 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x07) ;
2972 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x0C) ;
2973 Fref = 322800000UL ;
2974 }
2975 if (Tuner->IF_LO == 5200000UL) {
2976 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x09) ;
2977 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2978 Fref = 374400000UL ;
2979 }
2980 if (Tuner->IF_LO == 4900000UL)
2981 {
2982 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x09) ;
2983 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2984 Fref = 352800000UL ;
2985 }
2986 if (Tuner->IF_LO == 4400000UL)
2987 {
2988 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x06) ;
2989 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2990 Fref = 352000000UL ;
2991 }
2992 if (Tuner->IF_LO == 4063000UL) //add for 2.6.8
2993 {
2994 status += MXL_ControlWrite(Tuner, IF_DIVVAL, 0x05) ;
2995 status += MXL_ControlWrite(Tuner, IF_VCO_BIAS, 0x08) ;
2996 Fref = 365670000UL ;
2997 }
2998 }
2999 // CHCAL_INT_MOD_IF
3000 // CHCAL_FRAC_MOD_IF
3001 intModVal = Fref / (Tuner->Fxtal * Kdbl/2) ;
3002 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_IF, intModVal ) ;
3003
3004 fracModVal = (2<<15)*(Fref/1000 - (Tuner->Fxtal/1000 * Kdbl/2) * intModVal);
3005 fracModVal = fracModVal / ((Tuner->Fxtal * Kdbl/2)/1000) ;
3006 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_IF, fracModVal) ;
3007
3008
3009
3010 return status ;
3011}
3012
3013///////////////////////////////////////////////////////////////////////////////
3014// //
3015// Function: MXL_GetXtalInt //
3016// //
3017// Description: return the Crystal Integration Value for //
3018// TG_VCO_BIAS calculation //
3019// //
3020// Globals: //
3021// NONE //
3022// //
3023// Functions used: //
3024// NONE //
3025// //
3026// Inputs: //
3027// Crystal Frequency Value in Hz //
3028// //
3029// Outputs: //
3030// Calculated Crystal Frequency Integration Value //
3031// //
3032// Return: //
3033// 0 : Successful //
3034// > 0 : Failed //
3035// //
3036///////////////////////////////////////////////////////////////////////////////
3037_u32 MXL_GetXtalInt(_u32 Xtal_Freq)
3038{
3039 if ((Xtal_Freq % 1000000) == 0)
3040 return (Xtal_Freq / 10000) ;
3041 else
3042 return (((Xtal_Freq / 1000000) + 1)*100) ;
3043}
3044
3045///////////////////////////////////////////////////////////////////////////////
3046// //
3047// Function: MXL5005_TuneRF //
3048// //
3049// Description: Set control names to tune to requested RF_IN frequency //
3050// //
3051// Globals: //
3052// None //
3053// //
3054// Functions used: //
3055// MXL_SynthRFTGLO_Calc //
3056// MXL5005_ControlWrite //
3057// MXL_GetXtalInt //
3058// //
3059// Inputs: //
3060// Tuner : Tuner structure defined at higher level //
3061// //
3062// Outputs: //
3063// Tuner //
3064// //
3065// Return: //
3066// 0 : Successful //
3067// 1 : Unsuccessful //
3068///////////////////////////////////////////////////////////////////////////////
3069_u16 MXL_TuneRF(Tuner_struct *Tuner, _u32 RF_Freq)
3070{
3071 // Declare Local Variables
3072 _u16 status = 0 ;
3073 _u32 divider_val, E3, E4, E5, E5A ;
3074 _u32 Fmax, Fmin, FmaxBin, FminBin ;
3075 _u32 Kdbl_RF = 2;
3076 _u32 tg_divval ;
3077 _u32 tg_lo ;
3078 _u32 Xtal_Int ;
3079
3080 _u32 Fref_TG;
3081 _u32 Fvco;
3082// _u32 temp;
3083
3084
3085 Xtal_Int = MXL_GetXtalInt(Tuner->Fxtal ) ;
3086
3087 Tuner->RF_IN = RF_Freq ;
3088
3089 MXL_SynthRFTGLO_Calc( Tuner ) ;
3090
3091 if (Tuner->Fxtal >= 12000000UL && Tuner->Fxtal <= 22000000UL)
3092 Kdbl_RF = 2 ;
3093 if (Tuner->Fxtal > 22000000 && Tuner->Fxtal <= 32000000)
3094 Kdbl_RF = 1 ;
3095
3096 //
3097 // Downconverter Controls
3098 //
3099 // Look-Up Table Implementation for:
3100 // DN_POLY
3101 // DN_RFGAIN
3102 // DN_CAP_RFLPF
3103 // DN_EN_VHFUHFBAR
3104 // DN_GAIN_ADJUST
3105 // Change the boundary reference from RF_IN to RF_LO
3106 if (Tuner->RF_LO < 40000000UL) {
3107 return -1;
3108 }
3109 if (Tuner->RF_LO >= 40000000UL && Tuner->RF_LO <= 75000000UL) {
3110 // Look-Up Table implementation
3111 status += MXL_ControlWrite(Tuner, DN_POLY, 2) ;
3112 status += MXL_ControlWrite(Tuner, DN_RFGAIN, 3) ;
3113 status += MXL_ControlWrite(Tuner, DN_CAP_RFLPF, 423) ;
3114 status += MXL_ControlWrite(Tuner, DN_EN_VHFUHFBAR, 1) ;
3115 status += MXL_ControlWrite(Tuner, DN_GAIN_ADJUST, 1) ;
3116 }
3117 if (Tuner->RF_LO > 75000000UL && Tuner->RF_LO <= 100000000UL) {
3118 // Look-Up Table implementation
3119 status += MXL_ControlWrite(Tuner, DN_POLY, 3) ;
3120 status += MXL_ControlWrite(Tuner, DN_RFGAIN, 3) ;
3121 status += MXL_ControlWrite(Tuner, DN_CAP_RFLPF, 222) ;
3122 status += MXL_ControlWrite(Tuner, DN_EN_VHFUHFBAR, 1) ;
3123 status += MXL_ControlWrite(Tuner, DN_GAIN_ADJUST, 1) ;
3124 }
3125 if (Tuner->RF_LO > 100000000UL && Tuner->RF_LO <= 150000000UL) {
3126 // Look-Up Table implementation
3127 status += MXL_ControlWrite(Tuner, DN_POLY, 3) ;
3128 status += MXL_ControlWrite(Tuner, DN_RFGAIN, 3) ;
3129 status += MXL_ControlWrite(Tuner, DN_CAP_RFLPF, 147) ;
3130 status += MXL_ControlWrite(Tuner, DN_EN_VHFUHFBAR, 1) ;
3131 status += MXL_ControlWrite(Tuner, DN_GAIN_ADJUST, 2) ;
3132 }
3133 if (Tuner->RF_LO > 150000000UL && Tuner->RF_LO <= 200000000UL) {
3134 // Look-Up Table implementation
3135 status += MXL_ControlWrite(Tuner, DN_POLY, 3) ;
3136 status += MXL_ControlWrite(Tuner, DN_RFGAIN, 3) ;
3137 status += MXL_ControlWrite(Tuner, DN_CAP_RFLPF, 9) ;
3138 status += MXL_ControlWrite(Tuner, DN_EN_VHFUHFBAR, 1) ;
3139 status += MXL_ControlWrite(Tuner, DN_GAIN_ADJUST, 2) ;
3140 }
3141 if (Tuner->RF_LO > 200000000UL && Tuner->RF_LO <= 300000000UL) {
3142 // Look-Up Table implementation
3143 status += MXL_ControlWrite(Tuner, DN_POLY, 3) ;
3144 status += MXL_ControlWrite(Tuner, DN_RFGAIN, 3) ;
3145 status += MXL_ControlWrite(Tuner, DN_CAP_RFLPF, 0) ;
3146 status += MXL_ControlWrite(Tuner, DN_EN_VHFUHFBAR, 1) ;
3147 status += MXL_ControlWrite(Tuner, DN_GAIN_ADJUST, 3) ;
3148 }
3149 if (Tuner->RF_LO > 300000000UL && Tuner->RF_LO <= 650000000UL) {
3150 // Look-Up Table implementation
3151 status += MXL_ControlWrite(Tuner, DN_POLY, 3) ;
3152 status += MXL_ControlWrite(Tuner, DN_RFGAIN, 1) ;
3153 status += MXL_ControlWrite(Tuner, DN_CAP_RFLPF, 0) ;
3154 status += MXL_ControlWrite(Tuner, DN_EN_VHFUHFBAR, 0) ;
3155 status += MXL_ControlWrite(Tuner, DN_GAIN_ADJUST, 3) ;
3156 }
3157 if (Tuner->RF_LO > 650000000UL && Tuner->RF_LO <= 900000000UL) {
3158 // Look-Up Table implementation
3159 status += MXL_ControlWrite(Tuner, DN_POLY, 3) ;
3160 status += MXL_ControlWrite(Tuner, DN_RFGAIN, 2) ;
3161 status += MXL_ControlWrite(Tuner, DN_CAP_RFLPF, 0) ;
3162 status += MXL_ControlWrite(Tuner, DN_EN_VHFUHFBAR, 0) ;
3163 status += MXL_ControlWrite(Tuner, DN_GAIN_ADJUST, 3) ;
3164 }
3165 if (Tuner->RF_LO > 900000000UL) {
3166 return -1;
3167 }
3168 // DN_IQTNBUF_AMP
3169 // DN_IQTNGNBFBIAS_BST
3170 if (Tuner->RF_LO >= 40000000UL && Tuner->RF_LO <= 75000000UL) {
3171 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3172 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3173 }
3174 if (Tuner->RF_LO > 75000000UL && Tuner->RF_LO <= 100000000UL) {
3175 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3176 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3177 }
3178 if (Tuner->RF_LO > 100000000UL && Tuner->RF_LO <= 150000000UL) {
3179 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3180 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3181 }
3182 if (Tuner->RF_LO > 150000000UL && Tuner->RF_LO <= 200000000UL) {
3183 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3184 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3185 }
3186 if (Tuner->RF_LO > 200000000UL && Tuner->RF_LO <= 300000000UL) {
3187 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3188 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3189 }
3190 if (Tuner->RF_LO > 300000000UL && Tuner->RF_LO <= 400000000UL) {
3191 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3192 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3193 }
3194 if (Tuner->RF_LO > 400000000UL && Tuner->RF_LO <= 450000000UL) {
3195 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3196 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3197 }
3198 if (Tuner->RF_LO > 450000000UL && Tuner->RF_LO <= 500000000UL) {
3199 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3200 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3201 }
3202 if (Tuner->RF_LO > 500000000UL && Tuner->RF_LO <= 550000000UL) {
3203 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3204 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3205 }
3206 if (Tuner->RF_LO > 550000000UL && Tuner->RF_LO <= 600000000UL) {
3207 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3208 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3209 }
3210 if (Tuner->RF_LO > 600000000UL && Tuner->RF_LO <= 650000000UL) {
3211 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3212 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3213 }
3214 if (Tuner->RF_LO > 650000000UL && Tuner->RF_LO <= 700000000UL) {
3215 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3216 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3217 }
3218 if (Tuner->RF_LO > 700000000UL && Tuner->RF_LO <= 750000000UL) {
3219 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3220 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3221 }
3222 if (Tuner->RF_LO > 750000000UL && Tuner->RF_LO <= 800000000UL) {
3223 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 1) ;
3224 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 0) ;
3225 }
3226 if (Tuner->RF_LO > 800000000UL && Tuner->RF_LO <= 850000000UL) {
3227 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 10) ;
3228 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 1) ;
3229 }
3230 if (Tuner->RF_LO > 850000000UL && Tuner->RF_LO <= 900000000UL) {
3231 status += MXL_ControlWrite(Tuner, DN_IQTNBUF_AMP, 10) ;
3232 status += MXL_ControlWrite(Tuner, DN_IQTNGNBFBIAS_BST, 1) ;
3233 }
3234
3235 //
3236 // Set RF Synth and LO Path Control
3237 //
3238 // Look-Up table implementation for:
3239 // RFSYN_EN_OUTMUX
3240 // RFSYN_SEL_VCO_OUT
3241 // RFSYN_SEL_VCO_HI
3242 // RFSYN_SEL_DIVM
3243 // RFSYN_RF_DIV_BIAS
3244 // DN_SEL_FREQ
3245 //
3246 // Set divider_val, Fmax, Fmix to use in Equations
3247 FminBin = 28000000UL ;
3248 FmaxBin = 42500000UL ;
3249 if (Tuner->RF_LO >= 40000000UL && Tuner->RF_LO <= FmaxBin) {
3250 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 1) ;
3251 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 0) ;
3252 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0) ;
3253 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0) ;
3254 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3255 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 1) ;
3256 divider_val = 64 ;
3257 Fmax = FmaxBin ;
3258 Fmin = FminBin ;
3259 }
3260 FminBin = 42500000UL ;
3261 FmaxBin = 56000000UL ;
3262 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3263 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 1) ;
3264 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 0) ;
3265 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1) ;
3266 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0) ;
3267 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3268 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 1) ;
3269 divider_val = 64 ;
3270 Fmax = FmaxBin ;
3271 Fmin = FminBin ;
3272 }
3273 FminBin = 56000000UL ;
3274 FmaxBin = 85000000UL ;
3275 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3276 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0) ;
3277 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1) ;
3278 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0) ;
3279 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0) ;
3280 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3281 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 1) ;
3282 divider_val = 32 ;
3283 Fmax = FmaxBin ;
3284 Fmin = FminBin ;
3285 }
3286 FminBin = 85000000UL ;
3287 FmaxBin = 112000000UL ;
3288 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3289 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0) ;
3290 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1) ;
3291 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1) ;
3292 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0) ;
3293 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3294 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 1) ;
3295 divider_val = 32 ;
3296 Fmax = FmaxBin ;
3297 Fmin = FminBin ;
3298 }
3299 FminBin = 112000000UL ;
3300 FmaxBin = 170000000UL ;
3301 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3302 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0) ;
3303 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1) ;
3304 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0) ;
3305 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0) ;
3306 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3307 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 2) ;
3308 divider_val = 16 ;
3309 Fmax = FmaxBin ;
3310 Fmin = FminBin ;
3311 }
3312 FminBin = 170000000UL ;
3313 FmaxBin = 225000000UL ;
3314 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3315 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0) ;
3316 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1) ;
3317 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1) ;
3318 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0) ;
3319 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3320 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 2) ;
3321 divider_val = 16 ;
3322 Fmax = FmaxBin ;
3323 Fmin = FminBin ;
3324 }
3325 FminBin = 225000000UL ;
3326 FmaxBin = 300000000UL ;
3327 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3328 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0) ;
3329 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1) ;
3330 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0) ;
3331 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0) ;
3332 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3333 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 4) ;
3334 divider_val = 8 ;
3335 Fmax = 340000000UL ;
3336 Fmin = FminBin ;
3337 }
3338 FminBin = 300000000UL ;
3339 FmaxBin = 340000000UL ;
3340 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3341 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 1) ;
3342 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 0) ;
3343 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0) ;
3344 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0) ;
3345 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3346 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 0) ;
3347 divider_val = 8 ;
3348 Fmax = FmaxBin ;
3349 Fmin = 225000000UL ;
3350 }
3351 FminBin = 340000000UL ;
3352 FmaxBin = 450000000UL ;
3353 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3354 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 1) ;
3355 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 0) ;
3356 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1) ;
3357 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0) ;
3358 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 2) ;
3359 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 0) ;
3360 divider_val = 8 ;
3361 Fmax = FmaxBin ;
3362 Fmin = FminBin ;
3363 }
3364 FminBin = 450000000UL ;
3365 FmaxBin = 680000000UL ;
3366 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3367 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0) ;
3368 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1) ;
3369 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0) ;
3370 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 1) ;
3371 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3372 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 0) ;
3373 divider_val = 4 ;
3374 Fmax = FmaxBin ;
3375 Fmin = FminBin ;
3376 }
3377 FminBin = 680000000UL ;
3378 FmaxBin = 900000000UL ;
3379 if (Tuner->RF_LO > FminBin && Tuner->RF_LO <= FmaxBin) {
3380 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0) ;
3381 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1) ;
3382 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1) ;
3383 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 1) ;
3384 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1) ;
3385 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 0) ;
3386 divider_val = 4 ;
3387 Fmax = FmaxBin ;
3388 Fmin = FminBin ;
3389 }
3390
3391 // CHCAL_INT_MOD_RF
3392 // CHCAL_FRAC_MOD_RF
3393 // RFSYN_LPF_R
3394 // CHCAL_EN_INT_RF
3395
3396 // Equation E3
3397 // RFSYN_VCO_BIAS
3398 E3 = (((Fmax-Tuner->RF_LO)/1000)*32)/((Fmax-Fmin)/1000) + 8 ;
3399 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, E3) ;
3400
3401 // Equation E4
3402 // CHCAL_INT_MOD_RF
3403 E4 = (Tuner->RF_LO*divider_val/1000)/(2*Tuner->Fxtal*Kdbl_RF/1000) ;
3404 MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, E4) ;
3405
3406 // Equation E5
3407 // CHCAL_FRAC_MOD_RF
3408 // CHCAL_EN_INT_RF
3409 E5 = ((2<<17)*(Tuner->RF_LO/10000*divider_val - (E4*(2*Tuner->Fxtal*Kdbl_RF)/10000)))/(2*Tuner->Fxtal*Kdbl_RF/10000) ;
3410 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, E5) ;
3411
3412 // Equation E5A
3413 // RFSYN_LPF_R
3414 E5A = (((Fmax - Tuner->RF_LO)/1000)*4/((Fmax-Fmin)/1000)) + 1 ;
3415 status += MXL_ControlWrite(Tuner, RFSYN_LPF_R, E5A) ;
3416
3417 // Euqation E5B
3418 // CHCAL_EN_INIT_RF
3419 status += MXL_ControlWrite(Tuner, CHCAL_EN_INT_RF, ((E5 == 0) ? 1 : 0));
3420 //if (E5 == 0)
3421 // status += MXL_ControlWrite(Tuner, CHCAL_EN_INT_RF, 1);
3422 //else
3423 // status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, E5) ;
3424
3425 //
3426 // Set TG Synth
3427 //
3428 // Look-Up table implementation for:
3429 // TG_LO_DIVVAL
3430 // TG_LO_SELVAL
3431 //
3432 // Set divider_val, Fmax, Fmix to use in Equations
3433 if (Tuner->TG_LO < 33000000UL) {
3434 return -1;
3435 }
3436 FminBin = 33000000UL ;
3437 FmaxBin = 50000000UL ;
3438 if (Tuner->TG_LO >= FminBin && Tuner->TG_LO <= FmaxBin) {
3439 status += MXL_ControlWrite(Tuner, TG_LO_DIVVAL, 0x6) ;
3440 status += MXL_ControlWrite(Tuner, TG_LO_SELVAL, 0x0) ;
3441 divider_val = 36 ;
3442 Fmax = FmaxBin ;
3443 Fmin = FminBin ;
3444 }
3445 FminBin = 50000000UL ;
3446 FmaxBin = 67000000UL ;
3447 if (Tuner->TG_LO > FminBin && Tuner->TG_LO <= FmaxBin) {
3448 status += MXL_ControlWrite(Tuner, TG_LO_DIVVAL, 0x1) ;
3449 status += MXL_ControlWrite(Tuner, TG_LO_SELVAL, 0x0) ;
3450 divider_val = 24 ;
3451 Fmax = FmaxBin ;
3452 Fmin = FminBin ;
3453 }
3454 FminBin = 67000000UL ;
3455 FmaxBin = 100000000UL ;
3456 if (Tuner->TG_LO > FminBin && Tuner->TG_LO <= FmaxBin) {
3457 status += MXL_ControlWrite(Tuner, TG_LO_DIVVAL, 0xC) ;
3458 status += MXL_ControlWrite(Tuner, TG_LO_SELVAL, 0x2) ;
3459 divider_val = 18 ;
3460 Fmax = FmaxBin ;
3461 Fmin = FminBin ;
3462 }
3463 FminBin = 100000000UL ;
3464 FmaxBin = 150000000UL ;
3465 if (Tuner->TG_LO > FminBin && Tuner->TG_LO <= FmaxBin) {
3466 status += MXL_ControlWrite(Tuner, TG_LO_DIVVAL, 0x8) ;
3467 status += MXL_ControlWrite(Tuner, TG_LO_SELVAL, 0x2) ;
3468 divider_val = 12 ;
3469 Fmax = FmaxBin ;
3470 Fmin = FminBin ;
3471 }
3472 FminBin = 150000000UL ;
3473 FmaxBin = 200000000UL ;
3474 if (Tuner->TG_LO > FminBin && Tuner->TG_LO <= FmaxBin) {
3475 status += MXL_ControlWrite(Tuner, TG_LO_DIVVAL, 0x0) ;
3476 status += MXL_ControlWrite(Tuner, TG_LO_SELVAL, 0x2) ;
3477 divider_val = 8 ;
3478 Fmax = FmaxBin ;
3479 Fmin = FminBin ;
3480 }
3481 FminBin = 200000000UL ;
3482 FmaxBin = 300000000UL ;
3483 if (Tuner->TG_LO > FminBin && Tuner->TG_LO <= FmaxBin) {
3484 status += MXL_ControlWrite(Tuner, TG_LO_DIVVAL, 0x8) ;
3485 status += MXL_ControlWrite(Tuner, TG_LO_SELVAL, 0x3) ;
3486 divider_val = 6 ;
3487 Fmax = FmaxBin ;
3488 Fmin = FminBin ;
3489 }
3490 FminBin = 300000000UL ;
3491 FmaxBin = 400000000UL ;
3492 if (Tuner->TG_LO > FminBin && Tuner->TG_LO <= FmaxBin) {
3493 status += MXL_ControlWrite(Tuner, TG_LO_DIVVAL, 0x0) ;
3494 status += MXL_ControlWrite(Tuner, TG_LO_SELVAL, 0x3) ;
3495 divider_val = 4 ;
3496 Fmax = FmaxBin ;
3497 Fmin = FminBin ;
3498 }
3499 FminBin = 400000000UL ;
3500 FmaxBin = 600000000UL ;
3501 if (Tuner->TG_LO > FminBin && Tuner->TG_LO <= FmaxBin) {
3502 status += MXL_ControlWrite(Tuner, TG_LO_DIVVAL, 0x8) ;
3503 status += MXL_ControlWrite(Tuner, TG_LO_SELVAL, 0x7) ;
3504 divider_val = 3 ;
3505 Fmax = FmaxBin ;
3506 Fmin = FminBin ;
3507 }
3508 FminBin = 600000000UL ;
3509 FmaxBin = 900000000UL ;
3510 if (Tuner->TG_LO > FminBin && Tuner->TG_LO <= FmaxBin) {
3511 status += MXL_ControlWrite(Tuner, TG_LO_DIVVAL, 0x0) ;
3512 status += MXL_ControlWrite(Tuner, TG_LO_SELVAL, 0x7) ;
3513 divider_val = 2 ;
3514 Fmax = FmaxBin ;
3515 Fmin = FminBin ;
3516 }
3517
3518 // TG_DIV_VAL
3519 tg_divval = (Tuner->TG_LO*divider_val/100000)
3520 *(MXL_Ceiling(Tuner->Fxtal,1000000) * 100) / (Tuner->Fxtal/1000) ;
3521 status += MXL_ControlWrite(Tuner, TG_DIV_VAL, tg_divval) ;
3522
3523 if (Tuner->TG_LO > 600000000UL)
3524 status += MXL_ControlWrite(Tuner, TG_DIV_VAL, tg_divval + 1 ) ;
3525
3526 Fmax = 1800000000UL ;
3527 Fmin = 1200000000UL ;
3528
3529
3530
3531 // to prevent overflow of 32 bit unsigned integer, use following equation. Edit for v2.6.4
3532 Fref_TG = (Tuner->Fxtal/1000)/ MXL_Ceiling(Tuner->Fxtal, 1000000) ; // Fref_TF = Fref_TG*1000
3533
3534 Fvco = (Tuner->TG_LO/10000) * divider_val * Fref_TG; //Fvco = Fvco/10
3535
3536 tg_lo = (((Fmax/10 - Fvco)/100)*32) / ((Fmax-Fmin)/1000)+8;
3537
3538 //below equation is same as above but much harder to debug.
3539 //tg_lo = ( ((Fmax/10000 * Xtal_Int)/100) - ((Tuner->TG_LO/10000)*divider_val*(Tuner->Fxtal/10000)/100) )*32/((Fmax-Fmin)/10000 * Xtal_Int/100) + 8 ;
3540
3541
3542 status += MXL_ControlWrite(Tuner, TG_VCO_BIAS , tg_lo) ;
3543
3544
3545
3546 //add for 2.6.5
3547 //Special setting for QAM
3548 if(Tuner ->Mod_Type == MXL_QAM)
3549 {
3550 if(Tuner->RF_IN < 680000000)
3551 status += MXL_ControlWrite(Tuner, RFSYN_CHP_GAIN, 3) ;
3552 else
3553 status += MXL_ControlWrite(Tuner, RFSYN_CHP_GAIN, 2) ;
3554 }
3555
3556
3557 //remove 20.48MHz setting for 2.6.10
3558
3559 //
3560 // Off Chip Tracking Filter Control
3561 //
3562 if (Tuner->TF_Type == MXL_TF_OFF) // Tracking Filter Off State; turn off all the banks
3563 {
3564 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ;
3565 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ;
3566
3567 status += MXL_SetGPIO(Tuner, 3, 1) ; // turn off Bank 1
3568 status += MXL_SetGPIO(Tuner, 1, 1) ; // turn off Bank 2
3569 status += MXL_SetGPIO(Tuner, 4, 1) ; // turn off Bank 3
3570 }
3571
3572 if (Tuner->TF_Type == MXL_TF_C) // Tracking Filter type C
3573 {
3574 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ;
3575 status += MXL_ControlWrite(Tuner, DAC_DIN_A, 0) ;
3576
3577 if (Tuner->RF_IN >= 43000000 && Tuner->RF_IN < 150000000)
3578 {
3579
3580 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3581 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3582 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank1 On
3583 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3584 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank3 Off
3585 }
3586 if (Tuner->RF_IN >= 150000000 && Tuner->RF_IN < 280000000)
3587 {
3588 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3589 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3590 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank1 Off
3591 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3592 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank3 Off
3593 }
3594 if (Tuner->RF_IN >= 280000000 && Tuner->RF_IN < 360000000)
3595 {
3596 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3597 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3598 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank1 Off
3599 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3600 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank3 On
3601 }
3602 if (Tuner->RF_IN >= 360000000 && Tuner->RF_IN < 560000000)
3603 {
3604 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3605 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3606 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank1 Off
3607 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3608 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank3 On
3609 }
3610 if (Tuner->RF_IN >= 560000000 && Tuner->RF_IN < 580000000)
3611 {
3612 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3613 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 29) ;
3614 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank1 Off
3615 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3616 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank3 On
3617 }
3618 if (Tuner->RF_IN >= 580000000 && Tuner->RF_IN < 630000000)
3619 {
3620 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3621 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3622 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank1 Off
3623 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3624 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank3 On
3625 }
3626 if (Tuner->RF_IN >= 630000000 && Tuner->RF_IN < 700000000)
3627 {
3628 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3629 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 16) ;
3630 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank1 Off
3631 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3632 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank3 Off
3633 }
3634 if (Tuner->RF_IN >= 700000000 && Tuner->RF_IN < 760000000)
3635 {
3636 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3637 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 7) ;
3638 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank1 Off
3639 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3640 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank3 Off
3641 }
3642 if (Tuner->RF_IN >= 760000000 && Tuner->RF_IN <= 900000000)
3643 {
3644 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3645 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3646 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank1 Off
3647 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3648 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank3 Off
3649 }
3650 }
3651
3652 if (Tuner->TF_Type == MXL_TF_C_H) // Tracking Filter type C-H for Hauppauge only
3653 {
3654 status += MXL_ControlWrite(Tuner, DAC_DIN_A, 0) ;
3655
3656 if (Tuner->RF_IN >= 43000000 && Tuner->RF_IN < 150000000)
3657 {
3658
3659 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3660 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
3661 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank2 Off
3662 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank3 Off
3663 }
3664 if (Tuner->RF_IN >= 150000000 && Tuner->RF_IN < 280000000)
3665 {
3666 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3667 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3668 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank2 On
3669 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank3 Off
3670 }
3671 if (Tuner->RF_IN >= 280000000 && Tuner->RF_IN < 360000000)
3672 {
3673 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3674 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3675 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank2 On
3676 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank3 On
3677 }
3678 if (Tuner->RF_IN >= 360000000 && Tuner->RF_IN < 560000000)
3679 {
3680 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3681 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3682 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank2 Off
3683 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank3 On
3684 }
3685 if (Tuner->RF_IN >= 560000000 && Tuner->RF_IN < 580000000)
3686 {
3687 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3688 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3689 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank2 Off
3690 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank3 On
3691 }
3692 if (Tuner->RF_IN >= 580000000 && Tuner->RF_IN < 630000000)
3693 {
3694 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3695 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3696 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank2 Off
3697 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank3 On
3698 }
3699 if (Tuner->RF_IN >= 630000000 && Tuner->RF_IN < 700000000)
3700 {
3701 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3702 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3703 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank2 Off
3704 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank3 Off
3705 }
3706 if (Tuner->RF_IN >= 700000000 && Tuner->RF_IN < 760000000)
3707 {
3708 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3709 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3710 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank2 Off
3711 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank3 Off
3712 }
3713 if (Tuner->RF_IN >= 760000000 && Tuner->RF_IN <= 900000000)
3714 {
3715 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3716 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3717 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank2 Off
3718 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank3 Off
3719 }
3720 }
3721
3722 if (Tuner->TF_Type == MXL_TF_D) // Tracking Filter type D
3723 {
3724 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3725
3726 if (Tuner->RF_IN >= 43000000 && Tuner->RF_IN < 174000000)
3727 {
3728
3729 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3730 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
3731 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3732 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3733 }
3734 if (Tuner->RF_IN >= 174000000 && Tuner->RF_IN < 250000000)
3735 {
3736 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3737 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
3738 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3739 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3740 }
3741 if (Tuner->RF_IN >= 250000000 && Tuner->RF_IN < 310000000)
3742 {
3743 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3744 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3745 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3746 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3747 }
3748 if (Tuner->RF_IN >= 310000000 && Tuner->RF_IN < 360000000)
3749 {
3750 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3751 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3752 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3753 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
3754 }
3755 if (Tuner->RF_IN >= 360000000 && Tuner->RF_IN < 470000000)
3756 {
3757 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3758 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3759 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3760 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
3761 }
3762 if (Tuner->RF_IN >= 470000000 && Tuner->RF_IN < 640000000)
3763 {
3764 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
3765 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3766 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3767 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
3768 }
3769 if (Tuner->RF_IN >= 640000000 && Tuner->RF_IN <= 900000000)
3770 {
3771 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
3772 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3773 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3774 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3775 }
3776 }
3777
3778
3779 if (Tuner->TF_Type == MXL_TF_D_L) // Tracking Filter type D-L for Lumanate ONLY change for 2.6.3
3780 {
3781 status += MXL_ControlWrite(Tuner, DAC_DIN_A, 0) ;
3782
3783 if (Tuner->RF_IN >= 471000000 && (Tuner->RF_IN - 471000000)%6000000 != 0) // if UHF and terrestrial => Turn off Tracking Filter
3784 {
3785 // Turn off all the banks
3786 status += MXL_SetGPIO(Tuner, 3, 1) ;
3787 status += MXL_SetGPIO(Tuner, 1, 1) ;
3788 status += MXL_SetGPIO(Tuner, 4, 1) ;
3789 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ;
3790
3791 status += MXL_ControlWrite(Tuner, AGC_IF, 10) ;
3792 }
3793
3794 else // if VHF or cable => Turn on Tracking Filter
3795 {
3796 if (Tuner->RF_IN >= 43000000 && Tuner->RF_IN < 140000000)
3797 {
3798
3799 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3800 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 On
3801 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3802 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 Off
3803 }
3804 if (Tuner->RF_IN >= 140000000 && Tuner->RF_IN < 240000000)
3805 {
3806 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3807 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 On
3808 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3809 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 Off
3810 }
3811 if (Tuner->RF_IN >= 240000000 && Tuner->RF_IN < 340000000)
3812 {
3813 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3814 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 Off
3815 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 On
3816 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 Off
3817 }
3818 if (Tuner->RF_IN >= 340000000 && Tuner->RF_IN < 430000000)
3819 {
3820 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 Off
3821 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 Off
3822 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3823 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 On
3824 }
3825 if (Tuner->RF_IN >= 430000000 && Tuner->RF_IN < 470000000)
3826 {
3827 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 Off
3828 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3829 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 Off
3830 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 On
3831 }
3832 if (Tuner->RF_IN >= 470000000 && Tuner->RF_IN < 570000000)
3833 {
3834 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3835 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 Off
3836 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 Off
3837 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 On
3838 }
3839 if (Tuner->RF_IN >= 570000000 && Tuner->RF_IN < 620000000)
3840 {
3841 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 0) ; // Bank4 On
3842 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 Off
3843 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3844 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Offq
3845 }
3846 if (Tuner->RF_IN >= 620000000 && Tuner->RF_IN < 760000000)
3847 {
3848 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3849 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 Off
3850 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3851 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3852 }
3853 if (Tuner->RF_IN >= 760000000 && Tuner->RF_IN <= 900000000)
3854 {
3855 status += MXL_ControlWrite(Tuner, DAC_A_ENABLE, 1) ; // Bank4 On
3856 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3857 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3858 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3859 }
3860 }
3861 }
3862
3863 if (Tuner->TF_Type == MXL_TF_E) // Tracking Filter type E
3864 {
3865 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3866
3867 if (Tuner->RF_IN >= 43000000 && Tuner->RF_IN < 174000000)
3868 {
3869
3870 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3871 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
3872 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3873 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3874 }
3875 if (Tuner->RF_IN >= 174000000 && Tuner->RF_IN < 250000000)
3876 {
3877 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3878 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
3879 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3880 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3881 }
3882 if (Tuner->RF_IN >= 250000000 && Tuner->RF_IN < 310000000)
3883 {
3884 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3885 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3886 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3887 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3888 }
3889 if (Tuner->RF_IN >= 310000000 && Tuner->RF_IN < 360000000)
3890 {
3891 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3892 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3893 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3894 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
3895 }
3896 if (Tuner->RF_IN >= 360000000 && Tuner->RF_IN < 470000000)
3897 {
3898 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3899 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3900 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3901 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
3902 }
3903 if (Tuner->RF_IN >= 470000000 && Tuner->RF_IN < 640000000)
3904 {
3905 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
3906 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3907 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3908 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
3909 }
3910 if (Tuner->RF_IN >= 640000000 && Tuner->RF_IN <= 900000000)
3911 {
3912 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
3913 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3914 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3915 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3916 }
3917 }
3918
3919 if (Tuner->TF_Type == MXL_TF_F) // Tracking Filter type F
3920 {
3921 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3922
3923 if (Tuner->RF_IN >= 43000000 && Tuner->RF_IN < 160000000)
3924 {
3925
3926 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3927 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
3928 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3929 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3930 }
3931 if (Tuner->RF_IN >= 160000000 && Tuner->RF_IN < 210000000)
3932 {
3933 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3934 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
3935 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3936 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3937 }
3938 if (Tuner->RF_IN >= 210000000 && Tuner->RF_IN < 300000000)
3939 {
3940 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3941 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3942 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3943 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3944 }
3945 if (Tuner->RF_IN >= 300000000 && Tuner->RF_IN < 390000000)
3946 {
3947 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3948 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3949 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3950 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
3951 }
3952 if (Tuner->RF_IN >= 390000000 && Tuner->RF_IN < 515000000)
3953 {
3954 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3955 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3956 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3957 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
3958 }
3959 if (Tuner->RF_IN >= 515000000 && Tuner->RF_IN < 650000000)
3960 {
3961 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
3962 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3963 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3964 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
3965 }
3966 if (Tuner->RF_IN >= 650000000 && Tuner->RF_IN <= 900000000)
3967 {
3968 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
3969 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3970 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3971 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3972 }
3973 }
3974
3975 if (Tuner->TF_Type == MXL_TF_E_2) // Tracking Filter type E_2
3976 {
3977 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
3978
3979 if (Tuner->RF_IN >= 43000000 && Tuner->RF_IN < 174000000)
3980 {
3981
3982 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3983 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
3984 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
3985 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3986 }
3987 if (Tuner->RF_IN >= 174000000 && Tuner->RF_IN < 250000000)
3988 {
3989 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3990 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
3991 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3992 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
3993 }
3994 if (Tuner->RF_IN >= 250000000 && Tuner->RF_IN < 350000000)
3995 {
3996 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
3997 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
3998 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
3999 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4000 }
4001 if (Tuner->RF_IN >= 350000000 && Tuner->RF_IN < 400000000)
4002 {
4003 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4004 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4005 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
4006 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
4007 }
4008 if (Tuner->RF_IN >= 400000000 && Tuner->RF_IN < 570000000)
4009 {
4010 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4011 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4012 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4013 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
4014 }
4015 if (Tuner->RF_IN >= 570000000 && Tuner->RF_IN < 770000000)
4016 {
4017 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
4018 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4019 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4020 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
4021 }
4022 if (Tuner->RF_IN >= 770000000 && Tuner->RF_IN <= 900000000)
4023 {
4024 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
4025 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4026 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4027 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4028 }
4029 }
4030
4031 if (Tuner->TF_Type == MXL_TF_G) // Tracking Filter type G add for v2.6.8
4032 {
4033 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
4034
4035 if (Tuner->RF_IN >= 50000000 && Tuner->RF_IN < 190000000)
4036 {
4037
4038 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4039 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
4040 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4041 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4042 }
4043 if (Tuner->RF_IN >= 190000000 && Tuner->RF_IN < 280000000)
4044 {
4045 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4046 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
4047 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
4048 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4049 }
4050 if (Tuner->RF_IN >= 280000000 && Tuner->RF_IN < 350000000)
4051 {
4052 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4053 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4054 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
4055 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4056 }
4057 if (Tuner->RF_IN >= 350000000 && Tuner->RF_IN < 400000000)
4058 {
4059 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4060 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4061 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
4062 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
4063 }
4064 if (Tuner->RF_IN >= 400000000 && Tuner->RF_IN < 470000000) //modified for 2.6.11
4065 {
4066 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
4067 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 On
4068 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 Off
4069 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4070 }
4071 if (Tuner->RF_IN >= 470000000 && Tuner->RF_IN < 640000000)
4072 {
4073 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4074 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4075 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4076 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
4077 }
4078 if (Tuner->RF_IN >= 640000000 && Tuner->RF_IN < 820000000)
4079 {
4080 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
4081 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4082 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4083 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
4084 }
4085 if (Tuner->RF_IN >= 820000000 && Tuner->RF_IN <= 900000000)
4086 {
4087 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
4088 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4089 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4090 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4091 }
4092 }
4093
4094 if (Tuner->TF_Type == MXL_TF_E_NA) // Tracking Filter type E-NA for Empia ONLY change for 2.6.8
4095 {
4096 status += MXL_ControlWrite(Tuner, DAC_DIN_B, 0) ;
4097
4098 if (Tuner->RF_IN >= 471000000 && (Tuner->RF_IN - 471000000)%6000000 != 0) //if UHF and terrestrial=> Turn off Tracking Filter
4099 {
4100 // Turn off all the banks
4101 status += MXL_SetGPIO(Tuner, 3, 1) ;
4102 status += MXL_SetGPIO(Tuner, 1, 1) ;
4103 status += MXL_SetGPIO(Tuner, 4, 1) ;
4104 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ;
4105
4106 //2.6.12
4107 //Turn on RSSI
4108 status += MXL_ControlWrite(Tuner, SEQ_EXTSYNTHCALIF, 1) ;
4109 status += MXL_ControlWrite(Tuner, SEQ_EXTDCCAL, 1) ;
4110 status += MXL_ControlWrite(Tuner, AGC_EN_RSSI, 1) ;
4111 status += MXL_ControlWrite(Tuner, RFA_ENCLKRFAGC, 1) ;
4112
4113 // RSSI reference point
4114 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFH, 5) ;
4115 status += MXL_ControlWrite(Tuner, RFA_RSSI_REF, 3) ;
4116 status += MXL_ControlWrite(Tuner, RFA_RSSI_REFL, 2) ;
4117
4118
4119 //status += MXL_ControlWrite(Tuner, AGC_IF, 10) ; //doesn't matter since RSSI is turn on
4120
4121 //following parameter is from analog OTA mode, can be change to seek better performance
4122 status += MXL_ControlWrite(Tuner, RFSYN_CHP_GAIN, 3) ;
4123 }
4124
4125 else //if VHF or Cable => Turn on Tracking Filter
4126 {
4127 //2.6.12
4128 //Turn off RSSI
4129 status += MXL_ControlWrite(Tuner, AGC_EN_RSSI, 0) ;
4130
4131 //change back from above condition
4132 status += MXL_ControlWrite(Tuner, RFSYN_CHP_GAIN, 5) ;
4133
4134
4135 if (Tuner->RF_IN >= 43000000 && Tuner->RF_IN < 174000000)
4136 {
4137
4138 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4139 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
4140 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4141 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4142 }
4143 if (Tuner->RF_IN >= 174000000 && Tuner->RF_IN < 250000000)
4144 {
4145 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4146 status += MXL_SetGPIO(Tuner, 4, 0) ; // Bank1 On
4147 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
4148 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4149 }
4150 if (Tuner->RF_IN >= 250000000 && Tuner->RF_IN < 350000000)
4151 {
4152 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4153 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4154 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
4155 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4156 }
4157 if (Tuner->RF_IN >= 350000000 && Tuner->RF_IN < 400000000)
4158 {
4159 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4160 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4161 status += MXL_SetGPIO(Tuner, 1, 0) ; // Bank2 On
4162 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
4163 }
4164 if (Tuner->RF_IN >= 400000000 && Tuner->RF_IN < 570000000)
4165 {
4166 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 0) ; // Bank4 Off
4167 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4168 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4169 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
4170 }
4171 if (Tuner->RF_IN >= 570000000 && Tuner->RF_IN < 770000000)
4172 {
4173 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
4174 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4175 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4176 status += MXL_SetGPIO(Tuner, 3, 0) ; // Bank3 On
4177 }
4178 if (Tuner->RF_IN >= 770000000 && Tuner->RF_IN <= 900000000)
4179 {
4180 status += MXL_ControlWrite(Tuner, DAC_B_ENABLE, 1) ; // Bank4 On
4181 status += MXL_SetGPIO(Tuner, 4, 1) ; // Bank1 Off
4182 status += MXL_SetGPIO(Tuner, 1, 1) ; // Bank2 Off
4183 status += MXL_SetGPIO(Tuner, 3, 1) ; // Bank3 Off
4184 }
4185 }
4186 }
4187 return status ;
4188}
4189
4190_u16 MXL_SetGPIO(Tuner_struct *Tuner, _u8 GPIO_Num, _u8 GPIO_Val)
4191{
4192 _u16 status = 0 ;
4193
4194 if (GPIO_Num == 1)
4195 status += MXL_ControlWrite(Tuner, GPIO_1B, GPIO_Val ? 0 : 1) ;
4196 // GPIO2 is not available
4197 if (GPIO_Num == 3)
4198 {
4199 if (GPIO_Val == 1) {
4200 status += MXL_ControlWrite(Tuner, GPIO_3, 0) ;
4201 status += MXL_ControlWrite(Tuner, GPIO_3B, 0) ;
4202 }
4203 if (GPIO_Val == 0) {
4204 status += MXL_ControlWrite(Tuner, GPIO_3, 1) ;
4205 status += MXL_ControlWrite(Tuner, GPIO_3B, 1) ;
4206 }
4207 if (GPIO_Val == 3) { // tri-state
4208 status += MXL_ControlWrite(Tuner, GPIO_3, 0) ;
4209 status += MXL_ControlWrite(Tuner, GPIO_3B, 1) ;
4210 }
4211 }
4212 if (GPIO_Num == 4)
4213 {
4214 if (GPIO_Val == 1) {
4215 status += MXL_ControlWrite(Tuner, GPIO_4, 0) ;
4216 status += MXL_ControlWrite(Tuner, GPIO_4B, 0) ;
4217 }
4218 if (GPIO_Val == 0) {
4219 status += MXL_ControlWrite(Tuner, GPIO_4, 1) ;
4220 status += MXL_ControlWrite(Tuner, GPIO_4B, 1) ;
4221 }
4222 if (GPIO_Val == 3) { // tri-state
4223 status += MXL_ControlWrite(Tuner, GPIO_4, 0) ;
4224 status += MXL_ControlWrite(Tuner, GPIO_4B, 1) ;
4225 }
4226 }
4227
4228 return status ;
4229}
4230
4231///////////////////////////////////////////////////////////////////////////////
4232// //
4233// Function: MXL_ControlWrite //
4234// //
4235// Description: Update control name value //
4236// //
4237// Globals: //
4238// NONE //
4239// //
4240// Functions used: //
4241// MXL_ControlWrite( Tuner, controlName, value, Group ) //
4242// //
4243// Inputs: //
4244// Tuner : Tuner structure //
4245// ControlName : Control name to be updated //
4246// value : Value to be written //
4247// //
4248// Outputs: //
4249// Tuner : Tuner structure defined at higher level //
4250// //
4251// Return: //
4252// 0 : Successful write //
4253// >0 : Value exceed maximum allowed for control number //
4254// //
4255///////////////////////////////////////////////////////////////////////////////
4256_u16 MXL_ControlWrite(Tuner_struct *Tuner, _u16 ControlNum, _u32 value)
4257{
4258 _u16 status = 0 ;
4259 // Will write ALL Matching Control Name
4260 status += MXL_ControlWrite_Group( Tuner, ControlNum, value, 1 ) ; // Write Matching INIT Control
4261 status += MXL_ControlWrite_Group( Tuner, ControlNum, value, 2 ) ; // Write Matching CH Control
4262#ifdef _MXL_INTERNAL
4263 status += MXL_ControlWrite_Group( Tuner, ControlNum, value, 3 ) ; // Write Matching MXL Control
4264#endif
4265
4266 return status ;
4267}
4268
4269///////////////////////////////////////////////////////////////////////////////
4270// //
4271// Function: MXL_ControlWrite //
4272// //
4273// Description: Update control name value //
4274// //
4275// Globals: //
4276// NONE //
4277// //
4278// Functions used: //
4279// strcmp //
4280// //
4281// Inputs: //
4282// Tuner_struct: structure defined at higher level //
4283// ControlName : Control Name //
4284// value : Value Assigned to Control Name //
4285// controlGroup : Control Register Group //
4286// //
4287// Outputs: //
4288// NONE //
4289// //
4290// Return: //
4291// 0 : Successful write //
4292// 1 : Value exceed maximum allowed for control name //
4293// 2 : Control name not found //
4294// //
4295///////////////////////////////////////////////////////////////////////////////
4296_u16 MXL_ControlWrite_Group(Tuner_struct *Tuner, _u16 controlNum, _u32 value, _u16 controlGroup)
4297{
4298 _u16 i, j, k ;
4299 _u32 highLimit ;
4300 _u32 ctrlVal ;
4301
4302 if( controlGroup == 1) // Initial Control
4303 {
4304 for (i=0; i<Tuner->Init_Ctrl_Num ; i++)
4305 {
4306 if ( controlNum == Tuner->Init_Ctrl[i].Ctrl_Num )
4307 { // find the control Name
4308 highLimit = 1 << Tuner->Init_Ctrl[i].size ;
4309 if ( value < highLimit)
4310 {
4311 for( j=0; j<Tuner->Init_Ctrl[i].size; j++)
4312 {
4313 Tuner->Init_Ctrl[i].val[j] = (_u8)((value >> j) & 0x01) ;
4314 // change the register map accordingly
4315 MXL_RegWriteBit( Tuner, (_u8)(Tuner->Init_Ctrl[i].addr[j]),
4316 (_u8)(Tuner->Init_Ctrl[i].bit[j]),
4317 (_u8)((value>>j) & 0x01) ) ;
4318 }
4319 ctrlVal = 0 ;
4320 for(k=0; k<Tuner->Init_Ctrl[i].size; k++)
4321 {
4322 ctrlVal += Tuner->Init_Ctrl[i].val[k] * (1 << k) ;
4323 }
4324 }
4325 else
4326 {
4327 return -1 ;
4328 }
4329 }
4330 }
4331 }
4332 if ( controlGroup == 2) // Chan change Control
4333 {
4334 for (i=0; i<Tuner->CH_Ctrl_Num; i++)
4335 {
4336 if ( controlNum == Tuner->CH_Ctrl[i].Ctrl_Num )
4337 { // find the control Name
4338 highLimit = 1 << Tuner->CH_Ctrl[i].size ;
4339 if ( value < highLimit)
4340 {
4341 for( j=0; j<Tuner->CH_Ctrl[i].size; j++)
4342 {
4343 Tuner->CH_Ctrl[i].val[j] = (_u8)((value >> j) & 0x01) ;
4344 // change the register map accordingly
4345 MXL_RegWriteBit( Tuner, (_u8)(Tuner->CH_Ctrl[i].addr[j]),
4346 (_u8)(Tuner->CH_Ctrl[i].bit[j]),
4347 (_u8)((value>>j) & 0x01) ) ;
4348 }
4349 ctrlVal = 0 ;
4350 for(k=0; k<Tuner->CH_Ctrl[i].size; k++)
4351 {
4352 ctrlVal += Tuner->CH_Ctrl[i].val[k] * (1 << k) ;
4353 }
4354 }
4355 else
4356 {
4357 return -1 ;
4358 }
4359 }
4360 }
4361 }
4362#ifdef _MXL_INTERNAL
4363 if ( controlGroup == 3) // Maxlinear Control
4364 {
4365 for (i=0; i<Tuner->MXL_Ctrl_Num; i++)
4366 {
4367 if ( controlNum == Tuner->MXL_Ctrl[i].Ctrl_Num )
4368 { // find the control Name
4369 highLimit = (1 << Tuner->MXL_Ctrl[i].size) ;
4370 if ( value < highLimit)
4371 {
4372 for( j=0; j<Tuner->MXL_Ctrl[i].size; j++)
4373 {
4374 Tuner->MXL_Ctrl[i].val[j] = (_u8)((value >> j) & 0x01) ;
4375 // change the register map accordingly
4376 MXL_RegWriteBit( Tuner, (_u8)(Tuner->MXL_Ctrl[i].addr[j]),
4377 (_u8)(Tuner->MXL_Ctrl[i].bit[j]),
4378 (_u8)((value>>j) & 0x01) ) ;
4379 }
4380 ctrlVal = 0 ;
4381 for(k=0; k<Tuner->MXL_Ctrl[i].size; k++)
4382 {
4383 ctrlVal += Tuner->MXL_Ctrl[i].val[k] * (1 << k) ;
4384 }
4385 }
4386 else
4387 {
4388 return -1 ;
4389 }
4390 }
4391 }
4392 }
4393#endif
4394 return 0 ; // successful return
4395}
4396
4397///////////////////////////////////////////////////////////////////////////////
4398// //
4399// Function: MXL_RegWrite //
4400// //
4401// Description: Update tuner register value //
4402// //
4403// Globals: //
4404// NONE //
4405// //
4406// Functions used: //
4407// NONE //
4408// //
4409// Inputs: //
4410// Tuner_struct: structure defined at higher level //
4411// RegNum : Register address to be assigned a value //
4412// RegVal : Register value to write //
4413// //
4414// Outputs: //
4415// NONE //
4416// //
4417// Return: //
4418// 0 : Successful write //
4419// -1 : Invalid Register Address //
4420// //
4421///////////////////////////////////////////////////////////////////////////////
4422_u16 MXL_RegWrite(Tuner_struct *Tuner, _u8 RegNum, _u8 RegVal)
4423{
4424 int i ;
4425
4426 for (i=0; i<104; i++)
4427 {
4428 if (RegNum == Tuner->TunerRegs[i].Reg_Num )
4429 {
4430 Tuner->TunerRegs[i].Reg_Val = RegVal ;
4431 return 0 ;
4432 }
4433 }
4434
4435 return 1 ;
4436}
4437
4438///////////////////////////////////////////////////////////////////////////////
4439// //
4440// Function: MXL_RegRead //
4441// //
4442// Description: Retrieve tuner register value //
4443// //
4444// Globals: //
4445// NONE //
4446// //
4447// Functions used: //
4448// NONE //
4449// //
4450// Inputs: //
4451// Tuner_struct: structure defined at higher level //
4452// RegNum : Register address to be assigned a value //
4453// //
4454// Outputs: //
4455// RegVal : Retrieved register value //
4456// //
4457// Return: //
4458// 0 : Successful read //
4459// -1 : Invalid Register Address //
4460// //
4461///////////////////////////////////////////////////////////////////////////////
4462_u16 MXL_RegRead(Tuner_struct *Tuner, _u8 RegNum, _u8 *RegVal)
4463{
4464 int i ;
4465
4466 for (i=0; i<104; i++)
4467 {
4468 if (RegNum == Tuner->TunerRegs[i].Reg_Num )
4469 {
4470 *RegVal = (_u8)(Tuner->TunerRegs[i].Reg_Val) ;
4471 return 0 ;
4472 }
4473 }
4474
4475 return 1 ;
4476}
4477
4478///////////////////////////////////////////////////////////////////////////////
4479// //
4480// Function: MXL_ControlRead //
4481// //
4482// Description: Retrieve the control value based on the control name //
4483// //
4484// Globals: //
4485// NONE //
4486// //
4487// Inputs: //
4488// Tuner_struct : structure defined at higher level //
4489// ControlName : Control Name //
4490// //
4491// Outputs: //
4492// value : returned control value //
4493// //
4494// Return: //
4495// 0 : Successful read //
4496// -1 : Invalid control name //
4497// //
4498///////////////////////////////////////////////////////////////////////////////
4499_u16 MXL_ControlRead(Tuner_struct *Tuner, _u16 controlNum, _u32 * value)
4500{
4501 _u32 ctrlVal ;
4502 _u16 i, k ;
4503
4504 for (i=0; i<Tuner->Init_Ctrl_Num ; i++)
4505 {
4506 if ( controlNum == Tuner->Init_Ctrl[i].Ctrl_Num )
4507 {
4508 ctrlVal = 0 ;
4509 for(k=0; k<Tuner->Init_Ctrl[i].size; k++)
4510 ctrlVal += Tuner->Init_Ctrl[i].val[k] * (1 << k) ;
4511 *value = ctrlVal ;
4512 return 0 ;
4513 }
4514 }
4515 for (i=0; i<Tuner->CH_Ctrl_Num ; i++)
4516 {
4517 if ( controlNum == Tuner->CH_Ctrl[i].Ctrl_Num )
4518 {
4519 ctrlVal = 0 ;
4520 for(k=0; k<Tuner->CH_Ctrl[i].size; k++)
4521 ctrlVal += Tuner->CH_Ctrl[i].val[k] * (1 << k) ;
4522 *value = ctrlVal ;
4523 return 0 ;
4524 }
4525 }
4526
4527#ifdef _MXL_INTERNAL
4528 for (i=0; i<Tuner->MXL_Ctrl_Num ; i++)
4529 {
4530 if ( controlNum == Tuner->MXL_Ctrl[i].Ctrl_Num )
4531 {
4532 ctrlVal = 0 ;
4533 for(k=0; k<Tuner->MXL_Ctrl[i].size; k++)
4534 ctrlVal += Tuner->MXL_Ctrl[i].val[k] * (1<<k) ;
4535 *value = ctrlVal ;
4536 return 0 ;
4537 }
4538 }
4539#endif
4540 return 1 ;
4541}
4542
4543///////////////////////////////////////////////////////////////////////////////
4544// //
4545// Function: MXL_ControlRegRead //
4546// //
4547// Description: Retrieve the register addresses and count related to a //
4548// a specific control name //
4549// //
4550// Globals: //
4551// NONE //
4552// //
4553// Inputs: //
4554// Tuner_struct : structure defined at higher level //
4555// ControlName : Control Name //
4556// //
4557// Outputs: //
4558// RegNum : returned register address array //
4559// count : returned register count related to a control //
4560// //
4561// Return: //
4562// 0 : Successful read //
4563// -1 : Invalid control name //
4564// //
4565///////////////////////////////////////////////////////////////////////////////
4566_u16 MXL_ControlRegRead(Tuner_struct *Tuner, _u16 controlNum, _u8 *RegNum, int * count)
4567{
4568 _u16 i, j, k ;
4569 _u16 Count ;
4570
4571 for (i=0; i<Tuner->Init_Ctrl_Num ; i++)
4572 {
4573 if ( controlNum == Tuner->Init_Ctrl[i].Ctrl_Num )
4574 {
4575 Count = 1 ;
4576 RegNum[0] = (_u8)(Tuner->Init_Ctrl[i].addr[0]) ;
4577
4578 for(k=1; k<Tuner->Init_Ctrl[i].size; k++)
4579 {
4580 for (j= 0; j<Count; j++)
4581 {
4582 if (Tuner->Init_Ctrl[i].addr[k] != RegNum[j])
4583 {
4584 Count ++ ;
4585 RegNum[Count-1] = (_u8)(Tuner->Init_Ctrl[i].addr[k]) ;
4586 }
4587 }
4588
4589 }
4590 *count = Count ;
4591 return 0 ;
4592 }
4593 }
4594 for (i=0; i<Tuner->CH_Ctrl_Num ; i++)
4595 {
4596 if ( controlNum == Tuner->CH_Ctrl[i].Ctrl_Num )
4597 {
4598 Count = 1 ;
4599 RegNum[0] = (_u8)(Tuner->CH_Ctrl[i].addr[0]) ;
4600
4601 for(k=1; k<Tuner->CH_Ctrl[i].size; k++)
4602 {
4603 for (j= 0; j<Count; j++)
4604 {
4605 if (Tuner->CH_Ctrl[i].addr[k] != RegNum[j])
4606 {
4607 Count ++ ;
4608 RegNum[Count-1] = (_u8)(Tuner->CH_Ctrl[i].addr[k]) ;
4609 }
4610 }
4611 }
4612 *count = Count ;
4613 return 0 ;
4614 }
4615 }
4616#ifdef _MXL_INTERNAL
4617 for (i=0; i<Tuner->MXL_Ctrl_Num ; i++)
4618 {
4619 if ( controlNum == Tuner->MXL_Ctrl[i].Ctrl_Num )
4620 {
4621 Count = 1 ;
4622 RegNum[0] = (_u8)(Tuner->MXL_Ctrl[i].addr[0]) ;
4623
4624 for(k=1; k<Tuner->MXL_Ctrl[i].size; k++)
4625 {
4626 for (j= 0; j<Count; j++)
4627 {
4628 if (Tuner->MXL_Ctrl[i].addr[k] != RegNum[j])
4629 {
4630 Count ++ ;
4631 RegNum[Count-1] = (_u8)Tuner->MXL_Ctrl[i].addr[k] ;
4632 }
4633 }
4634 }
4635 *count = Count ;
4636 return 0 ;
4637 }
4638 }
4639#endif
4640 *count = 0 ;
4641 return 1 ;
4642}
4643
4644///////////////////////////////////////////////////////////////////////////////
4645// //
4646// Function: MXL_RegWriteBit //
4647// //
4648// Description: Write a register for specified register address, //
4649// register bit and register bit value //
4650// //
4651// Globals: //
4652// NONE //
4653// //
4654// Inputs: //
4655// Tuner_struct : structure defined at higher level //
4656// address : register address //
4657// bit : register bit number //
4658// bitVal : register bit value //
4659// //
4660// Outputs: //
4661// NONE //
4662// //
4663// Return: //
4664// NONE //
4665// //
4666///////////////////////////////////////////////////////////////////////////////
4667
4668void MXL_RegWriteBit(Tuner_struct *Tuner, _u8 address, _u8 bit, _u8 bitVal)
4669{
4670 int i ;
4671
4672 // Declare Local Constants
4673 const _u8 AND_MAP[8] = {
4674 0xFE, 0xFD, 0xFB, 0xF7,
4675 0xEF, 0xDF, 0xBF, 0x7F } ;
4676
4677 const _u8 OR_MAP[8] = {
4678 0x01, 0x02, 0x04, 0x08,
4679 0x10, 0x20, 0x40, 0x80 } ;
4680
4681 for(i=0; i<Tuner->TunerRegs_Num; i++) {
4682 if ( Tuner->TunerRegs[i].Reg_Num == address ) {
4683 if (bitVal)
4684 Tuner->TunerRegs[i].Reg_Val |= OR_MAP[bit] ;
4685 else
4686 Tuner->TunerRegs[i].Reg_Val &= AND_MAP[bit] ;
4687 break ;
4688 }
4689 }
4690} ;
4691
4692
4693///////////////////////////////////////////////////////////////////////////////
4694// //
4695// Function: MXL_Ceiling //
4696// //
4697// Description: Complete to closest increment of resolution //
4698// //
4699// Globals: //
4700// NONE //
4701// //
4702// Functions used: //
4703// NONE //
4704// //
4705// Inputs: //
4706// value : Input number to compute //
4707// resolution : Increment step //
4708// //
4709// Outputs: //
4710// NONE //
4711// //
4712// Return: //
4713// Computed value //
4714// //
4715///////////////////////////////////////////////////////////////////////////////
4716_u32 MXL_Ceiling( _u32 value, _u32 resolution )
4717{
4718 return (value/resolution + (value%resolution > 0 ? 1 : 0)) ;
4719};
4720
4721//
4722// Retrieve the Initialzation Registers
4723//
4724_u16 MXL_GetInitRegister(Tuner_struct *Tuner, _u8 * RegNum, _u8 *RegVal, int *count)
4725{
4726 _u16 status = 0;
4727 int i ;
4728
4729 _u8 RegAddr[] = {11, 12, 13, 22, 32, 43, 44, 53, 56, 59, 73,
4730 76, 77, 91, 134, 135, 137, 147,
4731 156, 166, 167, 168, 25 } ;
4732 *count = sizeof(RegAddr) / sizeof(_u8) ;
4733
4734 status += MXL_BlockInit(Tuner) ;
4735
4736 for (i=0 ; i< *count; i++)
4737 {
4738 RegNum[i] = RegAddr[i] ;
4739 status += MXL_RegRead(Tuner, RegNum[i], &RegVal[i]) ;
4740 }
4741
4742 return status ;
4743}
4744
4745_u16 MXL_GetCHRegister(Tuner_struct *Tuner, _u8 * RegNum, _u8 *RegVal, int *count)
4746{
4747 _u16 status = 0;
4748 int i ;
4749
4750//add 77, 166, 167, 168 register for 2.6.12
4751#ifdef _MXL_PRODUCTION
4752 _u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 65, 68, 69, 70, 73, 92, 93, 106,
4753 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
4754#else
4755 _u8 RegAddr[] = {14, 15, 16, 17, 22, 43, 68, 69, 70, 73, 92, 93, 106,
4756 107, 108, 109, 110, 111, 112, 136, 138, 149, 77, 166, 167, 168 } ;
4757 //_u8 RegAddr[171];
4758 //for (i=0; i<=170; i++)
4759 // RegAddr[i] = i;
4760#endif
4761
4762 *count = sizeof(RegAddr) / sizeof(_u8) ;
4763
4764 for (i=0 ; i< *count; i++)
4765 {
4766 RegNum[i] = RegAddr[i] ;
4767 status += MXL_RegRead(Tuner, RegNum[i], &RegVal[i]) ;
4768 }
4769
4770 return status ;
4771
4772}
4773
4774_u16 MXL_GetCHRegister_ZeroIF(Tuner_struct *Tuner, _u8 * RegNum, _u8 *RegVal, int *count)
4775{
4776 _u16 status = 0 ;
4777 int i ;
4778
4779 _u8 RegAddr[] = {43, 136} ;
4780
4781 *count = sizeof(RegAddr) / sizeof(_u8) ;
4782
4783 for (i=0; i<*count; i++)
4784 {
4785 RegNum[i] = RegAddr[i] ;
4786 status += MXL_RegRead(Tuner, RegNum[i], &RegVal[i]) ;
4787 }
4788 return status ;
4789
4790}
4791
4792_u16 MXL_GetCHRegister_LowIF(Tuner_struct *Tuner, _u8 * RegNum, _u8 *RegVal, int *count)
4793{
4794 _u16 status = 0 ;
4795 int i ;
4796
4797 _u8 RegAddr[] = {138} ;
4798
4799 *count = sizeof(RegAddr) / sizeof(_u8) ;
4800
4801 for (i=0; i<*count; i++)
4802 {
4803 RegNum[i] = RegAddr[i] ;
4804 status += MXL_RegRead(Tuner, RegNum[i], &RegVal[i]) ;
4805 }
4806 return status ;
4807
4808}
4809
4810_u16 MXL_GetMasterControl(_u8 *MasterReg, int state)
4811{
4812 if (state == 1) // Load_Start
4813 *MasterReg = 0xF3 ;
4814 if (state == 2) // Power_Down
4815 *MasterReg = 0x41 ;
4816 if (state == 3) // Synth_Reset
4817 *MasterReg = 0xB1 ;
4818 if (state == 4) // Seq_Off
4819 *MasterReg = 0xF1 ;
4820
4821 return 0 ;
4822}
4823
4824#ifdef _MXL_PRODUCTION
4825_u16 MXL_VCORange_Test(Tuner_struct *Tuner, int VCO_Range)
4826{
4827 _u16 status = 0 ;
4828
4829 if (VCO_Range == 1) {
4830 status += MXL_ControlWrite(Tuner, RFSYN_EN_DIV, 1) ;
4831 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0 ) ;
4832 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0 ) ;
4833 status += MXL_ControlWrite(Tuner, RFSYN_DIVM, 1 ) ;
4834 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1 ) ;
4835 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1 ) ;
4836 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 0 ) ;
4837 if (Tuner->Mode == 0 && Tuner->IF_Mode == 1) // Analog Low IF Mode
4838 {
4839 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1 ) ;
4840 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 8 ) ;
4841 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 56 ) ;
4842 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 180224 ) ;
4843 }
4844 if (Tuner->Mode == 0 && Tuner->IF_Mode == 0) // Analog Zero IF Mode
4845 {
4846 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1 ) ;
4847 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 8 ) ;
4848 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 56 ) ;
4849 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 222822 ) ;
4850 }
4851 if (Tuner->Mode == 1) // Digital Mode
4852 {
4853 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1 ) ;
4854 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 8 ) ;
4855 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 56 ) ;
4856 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 229376 ) ;
4857 }
4858 }
4859
4860 if (VCO_Range == 2) {
4861 status += MXL_ControlWrite(Tuner, RFSYN_EN_DIV, 1) ;
4862 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0 ) ;
4863 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0 ) ;
4864 status += MXL_ControlWrite(Tuner, RFSYN_DIVM, 1 ) ;
4865 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1 ) ;
4866 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1 ) ;
4867 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 0 ) ;
4868 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1 ) ;
4869 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 40 ) ;
4870 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 41 ) ;
4871 if (Tuner->Mode == 0 && Tuner->IF_Mode == 1) // Analog Low IF Mode
4872 {
4873 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1 ) ;
4874 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 40 ) ;
4875 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 42 ) ;
4876 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 206438 ) ;
4877 }
4878 if (Tuner->Mode == 0 && Tuner->IF_Mode == 0) // Analog Zero IF Mode
4879 {
4880 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1 ) ;
4881 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 40 ) ;
4882 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 42 ) ;
4883 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 206438 ) ;
4884 }
4885 if (Tuner->Mode == 1) // Digital Mode
4886 {
4887 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 1 ) ;
4888 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 40 ) ;
4889 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 41 ) ;
4890 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 16384 ) ;
4891 }
4892 }
4893
4894 if (VCO_Range == 3) {
4895 status += MXL_ControlWrite(Tuner, RFSYN_EN_DIV, 1) ;
4896 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0 ) ;
4897 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0 ) ;
4898 status += MXL_ControlWrite(Tuner, RFSYN_DIVM, 1 ) ;
4899 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1 ) ;
4900 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1 ) ;
4901 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 0 ) ;
4902 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0 ) ;
4903 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 8 ) ;
4904 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 42 ) ;
4905 if (Tuner->Mode == 0 && Tuner->IF_Mode == 1) // Analog Low IF Mode
4906 {
4907 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0 ) ;
4908 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 8 ) ;
4909 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 44 ) ;
4910 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 173670 ) ;
4911 }
4912 if (Tuner->Mode == 0 && Tuner->IF_Mode == 0) // Analog Zero IF Mode
4913 {
4914 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0 ) ;
4915 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 8 ) ;
4916 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 44 ) ;
4917 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 173670 ) ;
4918 }
4919 if (Tuner->Mode == 1) // Digital Mode
4920 {
4921 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0 ) ;
4922 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 8 ) ;
4923 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 42 ) ;
4924 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 245760 ) ;
4925 }
4926 }
4927
4928 if (VCO_Range == 4) {
4929 status += MXL_ControlWrite(Tuner, RFSYN_EN_DIV, 1) ;
4930 status += MXL_ControlWrite(Tuner, RFSYN_EN_OUTMUX, 0 ) ;
4931 status += MXL_ControlWrite(Tuner, RFSYN_SEL_DIVM, 0 ) ;
4932 status += MXL_ControlWrite(Tuner, RFSYN_DIVM, 1 ) ;
4933 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_OUT, 1 ) ;
4934 status += MXL_ControlWrite(Tuner, RFSYN_RF_DIV_BIAS, 1 ) ;
4935 status += MXL_ControlWrite(Tuner, DN_SEL_FREQ, 0 ) ;
4936 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0 ) ;
4937 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 40 ) ;
4938 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 27 ) ;
4939 if (Tuner->Mode == 0 && Tuner->IF_Mode == 1) // Analog Low IF Mode
4940 {
4941 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0 ) ;
4942 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 40 ) ;
4943 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 27 ) ;
4944 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 206438 ) ;
4945 }
4946 if (Tuner->Mode == 0 && Tuner->IF_Mode == 0) // Analog Zero IF Mode
4947 {
4948 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0 ) ;
4949 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 40 ) ;
4950 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 27 ) ;
4951 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 206438 ) ;
4952 }
4953 if (Tuner->Mode == 1) // Digital Mode
4954 {
4955 status += MXL_ControlWrite(Tuner, RFSYN_SEL_VCO_HI, 0 ) ;
4956 status += MXL_ControlWrite(Tuner, RFSYN_VCO_BIAS, 40 ) ;
4957 status += MXL_ControlWrite(Tuner, CHCAL_INT_MOD_RF, 27 ) ;
4958 status += MXL_ControlWrite(Tuner, CHCAL_FRAC_MOD_RF, 212992 ) ;
4959 }
4960 }
4961
4962 return status ;
4963}
4964
4965_u16 MXL_Hystersis_Test(Tuner_struct *Tuner, int Hystersis)
4966{
4967 _u16 status = 0 ;
4968
4969 if (Hystersis == 1)
4970 status += MXL_ControlWrite(Tuner, DN_BYPASS_AGC_I2C, 1) ;
4971
4972 return status ;
4973}
4974#endif
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
diff --git a/drivers/media/common/tuners/mxl5005s.h b/drivers/media/common/tuners/mxl5005s.h
new file mode 100644
index 000000000000..8542fc10a9bb
--- /dev/null
+++ b/drivers/media/common/tuners/mxl5005s.h
@@ -0,0 +1,718 @@
1/*
2 * For the Realtek RTL chip RTL2831U
3 * Realtek Release Date: 2008-03-14, ver 080314
4 * Realtek version RTL2831 Linux driver version 080314
5 * ver 080314
6 *
7 * for linux kernel version 2.6.21.4 - 2.6.22-14
8 * support MXL5005s and MT2060 tuners (support tuner auto-detecting)
9 * support two IR types -- RC5 and NEC
10 *
11 * Known boards with Realtek RTL chip RTL2821U
12 * Freecom USB stick 14aa:0160 (version 4)
13 * Conceptronic CTVDIGRCU
14 *
15 * Copyright (c) 2008 Realtek
16 * Copyright (c) 2008 Jan Hoogenraad, Barnaby Shearer, Andy Hasper
17 * This code is placed under the terms of the GNU General Public License
18 *
19 * Released by Realtek under GPLv2.
20 * Thanks to Realtek for a lot of support we received !
21 *
22 * Revision: 080314 - original version
23 */
24
25
26#ifndef __TUNER_MXL5005S_H
27#define __TUNER_MXL5005S_H
28
29
30
31// The following context is source code provided by MaxLinear.
32
33
34// MaxLinear source code - Common.h
35
36
37
38//#pragma once
39
40typedef unsigned char _u8; // At least 1 Byte
41typedef unsigned short _u16; // At least 2 Bytes
42typedef signed short _s16;
43typedef unsigned long _u32; // At least 4 Bytes
44typedef void * HANDLE; // Pointer to memory location
45
46#define TUNER_REGS_NUM 104
47#define INITCTRL_NUM 40
48#ifdef _MXL_PRODUCTION
49#define CHCTRL_NUM 39
50#else
51#define CHCTRL_NUM 36
52#endif
53
54#define MXLCTRL_NUM 189
55
56#define MASTER_CONTROL_ADDR 9
57
58
59
60
61// Enumeration of AGC Mode
62typedef enum
63{
64 MXL_DUAL_AGC = 0 ,
65 MXL_SINGLE_AGC
66} AGC_Mode ;
67
68//
69// Enumeration of Master Control Register State
70//
71typedef enum
72{
73 MC_LOAD_START = 1 ,
74 MC_POWER_DOWN ,
75 MC_SYNTH_RESET ,
76 MC_SEQ_OFF
77} Master_Control_State ;
78
79//
80// Enumeration of MXL5005 Tuner Mode
81//
82typedef enum
83{
84 MXL_ANALOG_MODE = 0 ,
85 MXL_DIGITAL_MODE
86
87} Tuner_Mode ;
88
89//
90// Enumeration of MXL5005 Tuner IF Mode
91//
92typedef enum
93{
94 MXL_ZERO_IF = 0 ,
95 MXL_LOW_IF
96
97} Tuner_IF_Mode ;
98
99//
100// Enumeration of MXL5005 Tuner Clock Out Mode
101//
102typedef enum
103{
104 MXL_CLOCK_OUT_DISABLE = 0 ,
105 MXL_CLOCK_OUT_ENABLE
106} Tuner_Clock_Out ;
107
108//
109// Enumeration of MXL5005 Tuner Div Out Mode
110//
111typedef enum
112{
113 MXL_DIV_OUT_1 = 0 ,
114 MXL_DIV_OUT_4
115
116} Tuner_Div_Out ;
117
118//
119// Enumeration of MXL5005 Tuner Pull-up Cap Select Mode
120//
121typedef enum
122{
123 MXL_CAP_SEL_DISABLE = 0 ,
124 MXL_CAP_SEL_ENABLE
125
126} Tuner_Cap_Select ;
127
128//
129// Enumeration of MXL5005 Tuner RSSI Mode
130//
131typedef enum
132{
133 MXL_RSSI_DISABLE = 0 ,
134 MXL_RSSI_ENABLE
135
136} Tuner_RSSI ;
137
138//
139// Enumeration of MXL5005 Tuner Modulation Type
140//
141typedef enum
142{
143 MXL_DEFAULT_MODULATION = 0 ,
144 MXL_DVBT,
145 MXL_ATSC,
146 MXL_QAM,
147 MXL_ANALOG_CABLE,
148 MXL_ANALOG_OTA
149
150} Tuner_Modu_Type ;
151
152//
153// Enumeration of MXL5005 Tuner Tracking Filter Type
154//
155typedef enum
156{
157 MXL_TF_DEFAULT = 0 ,
158 MXL_TF_OFF,
159 MXL_TF_C,
160 MXL_TF_C_H,
161 MXL_TF_D,
162 MXL_TF_D_L,
163 MXL_TF_E,
164 MXL_TF_F,
165 MXL_TF_E_2,
166 MXL_TF_E_NA,
167 MXL_TF_G
168
169
170} Tuner_TF_Type ;
171
172
173//
174// MXL5005 Tuner Register Struct
175//
176typedef struct _TunerReg_struct
177{
178 _u16 Reg_Num ; // Tuner Register Address
179 _u16 Reg_Val ; // Current sofware programmed value waiting to be writen
180} TunerReg_struct ;
181
182//
183// MXL5005 Tuner Control Struct
184//
185typedef struct _TunerControl_struct {
186 _u16 Ctrl_Num ; // Control Number
187 _u16 size ; // Number of bits to represent Value
188 _u16 addr[25] ; // Array of Tuner Register Address for each bit position
189 _u16 bit[25] ; // Array of bit position in Register Address for each bit position
190 _u16 val[25] ; // Binary representation of Value
191} TunerControl_struct ;
192
193//
194// MXL5005 Tuner Struct
195//
196typedef struct _Tuner_struct
197{
198 _u8 Mode ; // 0: Analog Mode ; 1: Digital Mode
199 _u8 IF_Mode ; // for Analog Mode, 0: zero IF; 1: low IF
200 _u32 Chan_Bandwidth ; // filter channel bandwidth (6, 7, 8)
201 _u32 IF_OUT ; // Desired IF Out Frequency
202 _u16 IF_OUT_LOAD ; // IF Out Load Resistor (200/300 Ohms)
203 _u32 RF_IN ; // RF Input Frequency
204 _u32 Fxtal ; // XTAL Frequency
205 _u8 AGC_Mode ; // AGC Mode 0: Dual AGC; 1: Single AGC
206 _u16 TOP ; // Value: take over point
207 _u8 CLOCK_OUT ; // 0: turn off clock out; 1: turn on clock out
208 _u8 DIV_OUT ; // 4MHz or 16MHz
209 _u8 CAPSELECT ; // 0: disable On-Chip pulling cap; 1: enable
210 _u8 EN_RSSI ; // 0: disable RSSI; 1: enable RSSI
211 _u8 Mod_Type ; // Modulation Type;
212 // 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable
213 _u8 TF_Type ; // Tracking Filter Type
214 // 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H
215
216 // Calculated Settings
217 _u32 RF_LO ; // Synth RF LO Frequency
218 _u32 IF_LO ; // Synth IF LO Frequency
219 _u32 TG_LO ; // Synth TG_LO Frequency
220
221 // Pointers to ControlName Arrays
222 _u16 Init_Ctrl_Num ; // Number of INIT Control Names
223 TunerControl_struct Init_Ctrl[INITCTRL_NUM] ; // INIT Control Names Array Pointer
224 _u16 CH_Ctrl_Num ; // Number of CH Control Names
225 TunerControl_struct CH_Ctrl[CHCTRL_NUM] ; // CH Control Name Array Pointer
226 _u16 MXL_Ctrl_Num ; // Number of MXL Control Names
227 TunerControl_struct MXL_Ctrl[MXLCTRL_NUM] ; // MXL Control Name Array Pointer
228
229 // Pointer to Tuner Register Array
230 _u16 TunerRegs_Num ; // Number of Tuner Registers
231 TunerReg_struct TunerRegs[TUNER_REGS_NUM] ; // Tuner Register Array Pointer
232} Tuner_struct ;
233
234
235
236typedef enum
237{
238 //
239 // Initialization Control Names
240 //
241 DN_IQTN_AMP_CUT = 1 , // 1
242 BB_MODE , // 2
243 BB_BUF , // 3
244 BB_BUF_OA , // 4
245 BB_ALPF_BANDSELECT , // 5
246 BB_IQSWAP , // 6
247 BB_DLPF_BANDSEL , // 7
248 RFSYN_CHP_GAIN , // 8
249 RFSYN_EN_CHP_HIGAIN , // 9
250 AGC_IF , // 10
251 AGC_RF , // 11
252 IF_DIVVAL , // 12
253 IF_VCO_BIAS , // 13
254 CHCAL_INT_MOD_IF , // 14
255 CHCAL_FRAC_MOD_IF , // 15
256 DRV_RES_SEL , // 16
257 I_DRIVER , // 17
258 EN_AAF , // 18
259 EN_3P , // 19
260 EN_AUX_3P , // 20
261 SEL_AAF_BAND , // 21
262 SEQ_ENCLK16_CLK_OUT , // 22
263 SEQ_SEL4_16B , // 23
264 XTAL_CAPSELECT , // 24
265 IF_SEL_DBL , // 25
266 RFSYN_R_DIV , // 26
267 SEQ_EXTSYNTHCALIF , // 27
268 SEQ_EXTDCCAL , // 28
269 AGC_EN_RSSI , // 29
270 RFA_ENCLKRFAGC , // 30
271 RFA_RSSI_REFH , // 31
272 RFA_RSSI_REF , // 32
273 RFA_RSSI_REFL , // 33
274 RFA_FLR , // 34
275 RFA_CEIL , // 35
276 SEQ_EXTIQFSMPULSE , // 36
277 OVERRIDE_1 , // 37
278 BB_INITSTATE_DLPF_TUNE, // 38
279 TG_R_DIV, // 39
280 EN_CHP_LIN_B , // 40
281
282 //
283 // Channel Change Control Names
284 //
285 DN_POLY = 51 , // 51
286 DN_RFGAIN , // 52
287 DN_CAP_RFLPF , // 53
288 DN_EN_VHFUHFBAR , // 54
289 DN_GAIN_ADJUST , // 55
290 DN_IQTNBUF_AMP , // 56
291 DN_IQTNGNBFBIAS_BST , // 57
292 RFSYN_EN_OUTMUX , // 58
293 RFSYN_SEL_VCO_OUT , // 59
294 RFSYN_SEL_VCO_HI , // 60
295 RFSYN_SEL_DIVM , // 61
296 RFSYN_RF_DIV_BIAS , // 62
297 DN_SEL_FREQ , // 63
298 RFSYN_VCO_BIAS , // 64
299 CHCAL_INT_MOD_RF , // 65
300 CHCAL_FRAC_MOD_RF , // 66
301 RFSYN_LPF_R , // 67
302 CHCAL_EN_INT_RF , // 68
303 TG_LO_DIVVAL , // 69
304 TG_LO_SELVAL , // 70
305 TG_DIV_VAL , // 71
306 TG_VCO_BIAS , // 72
307 SEQ_EXTPOWERUP , // 73
308 OVERRIDE_2 , // 74
309 OVERRIDE_3 , // 75
310 OVERRIDE_4 , // 76
311 SEQ_FSM_PULSE , // 77
312 GPIO_4B, // 78
313 GPIO_3B, // 79
314 GPIO_4, // 80
315 GPIO_3, // 81
316 GPIO_1B, // 82
317 DAC_A_ENABLE , // 83
318 DAC_B_ENABLE , // 84
319 DAC_DIN_A , // 85
320 DAC_DIN_B , // 86
321#ifdef _MXL_PRODUCTION
322 RFSYN_EN_DIV, // 87
323 RFSYN_DIVM, // 88
324 DN_BYPASS_AGC_I2C // 89
325#endif
326
327} MXL5005_ControlName ;
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343// MaxLinear source code - MXL5005_c.h
344
345
346
347// MXL5005.h : main header file for the MXL5005 DLL
348//
349//#pragma once
350
351//#include "Common.h"
352#ifdef _MXL_INTERNAL
353#include "Common_MXL.h"
354#endif
355
356void InitTunerControls( Tuner_struct *Tuner) ;
357
358_u16 MXL_BlockInit( Tuner_struct *Tuner ) ;
359
360_u16 MXL5005_RegisterInit (Tuner_struct * Tuner) ;
361_u16 MXL5005_ControlInit (Tuner_struct *Tuner) ;
362
363#ifdef _MXL_INTERNAL
364 _u16 MXL5005_MXLControlInit(Tuner_struct *Tuner) ;
365#endif
366
367_u16 MXL5005_TunerConfig(Tuner_struct *Tuner,
368 _u8 Mode, // 0: Analog Mode ; 1: Digital Mode
369 _u8 IF_mode, // for Analog Mode, 0: zero IF; 1: low IF
370 _u32 Bandwidth, // filter channel bandwidth (6, 7, 8)
371 _u32 IF_out, // Desired IF Out Frequency
372 _u32 Fxtal, // XTAL Frequency
373 _u8 AGC_Mode, // AGC Mode - Dual AGC: 0, Single AGC: 1
374 _u16 TOP, // 0: Dual AGC; Value: take over point
375 _u16 IF_OUT_LOAD,// IF Out Load Resistor (200 / 300 Ohms)
376 _u8 CLOCK_OUT, // 0: turn off clock out; 1: turn on clock out
377 _u8 DIV_OUT, // 4MHz or 16MHz
378 _u8 CAPSELECT, // 0: disable On-Chip pulling cap; 1: enable
379 _u8 EN_RSSI, // 0: disable RSSI; 1: enable RSSI
380 _u8 Mod_Type, // Modulation Type;
381 // 0 - Default; 1 - DVB-T; 2 - ATSC; 3 - QAM; 4 - Analog Cable
382 _u8 TF_Type // Tracking Filter Type
383 // 0 - Default; 1 - Off; 2 - Type C; 3 - Type C-H
384 ) ;
385
386void MXL_SynthIFLO_Calc(Tuner_struct *Tuner) ;
387void MXL_SynthRFTGLO_Calc(Tuner_struct *Tuner) ;
388_u16 MXL_RegWrite(Tuner_struct *Tuner, _u8 RegNum, _u8 RegVal) ;
389_u16 MXL_RegRead(Tuner_struct *Tuner, _u8 RegNum, _u8 *RegVal) ;
390_u16 MXL_ControlWrite(Tuner_struct *Tuner, _u16 ControlNum, _u32 value) ;
391_u16 MXL_ControlWrite_Group(Tuner_struct *Tuner, _u16 ControlNum, _u32 value, _u16 controlGroup) ;
392_u16 MXL_ControlRead(Tuner_struct *Tuner, _u16 ControlNum, _u32 * value) ;
393_u16 MXL_ControlRegRead(Tuner_struct *Tuner, _u16 ControlNum, _u8 *RegNum, int * count) ;
394void MXL_RegWriteBit(Tuner_struct *Tuner, _u8 address, _u8 bit, _u8 bitVal);
395_u16 MXL_IFSynthInit( Tuner_struct * Tuner ) ;
396_u16 MXL_TuneRF(Tuner_struct *Tuner, _u32 RF_Freq) ;
397_u16 MXL_OverwriteICDefault( Tuner_struct *Tuner) ;
398_u16 MXL_SetGPIO(Tuner_struct *Tuner, _u8 GPIO_Num, _u8 GPIO_Val) ;
399_u32 MXL_Ceiling( _u32 value, _u32 resolution ) ;
400_u32 MXL_GetXtalInt(_u32 Xtal_Freq) ;
401
402_u16 MXL_GetInitRegister(Tuner_struct *Tuner, _u8 * RegNum, _u8 *RegVal, int *count) ;
403_u16 MXL_GetCHRegister(Tuner_struct *Tuner, _u8 * RegNum, _u8 *RegVal, int *count) ;
404_u16 MXL_GetCHRegister_ZeroIF(Tuner_struct *Tuner, _u8 * RegNum, _u8 *RegVal, int *count) ;
405_u16 MXL_GetCHRegister_LowIF(Tuner_struct *Tuner, _u8 * RegNum, _u8 *RegVal, int *count) ;
406_u16 MXL_GetMasterControl(_u8 *MasterReg, int state) ;
407
408#ifdef _MXL_PRODUCTION
409_u16 MXL_VCORange_Test(Tuner_struct *Tuner, int VCO_Range) ;
410_u16 MXL_Hystersis_Test(Tuner_struct *Tuner, int Hystersis) ;
411#endif
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435// The following context is MxL5005S tuner API source code
436
437
438
439
440
441/**
442
443@file
444
445@brief MxL5005S tuner module declaration
446
447One can manipulate MxL5005S tuner through MxL5005S module.
448MxL5005S module is derived from tuner module.
449
450*/
451
452
453
454#include "tuner_base.h"
455
456
457
458
459
460// Definitions
461
462// Constants
463#define MXL5005S_REG_WRITING_TABLE_LEN_MAX 104
464#define MXL5005S_LATCH_BYTE 0xfe
465
466// Register address, MSB, and LSB
467#define MXL5005S_BB_IQSWAP_ADDR 59
468#define MXL5005S_BB_IQSWAP_MSB 0
469#define MXL5005S_BB_IQSWAP_LSB 0
470
471#define MXL5005S_BB_DLPF_BANDSEL_ADDR 53
472#define MXL5005S_BB_DLPF_BANDSEL_MSB 4
473#define MXL5005S_BB_DLPF_BANDSEL_LSB 3
474
475
476
477// Standard modes
478enum
479{
480 MXL5005S_STANDARD_DVBT,
481 MXL5005S_STANDARD_ATSC,
482};
483#define MXL5005S_STANDARD_MODE_NUM 2
484
485
486// Bandwidth modes
487enum
488{
489 MXL5005S_BANDWIDTH_6MHZ = 6000000,
490 MXL5005S_BANDWIDTH_7MHZ = 7000000,
491 MXL5005S_BANDWIDTH_8MHZ = 8000000,
492};
493#define MXL5005S_BANDWIDTH_MODE_NUM 3
494
495
496// Top modes
497enum
498{
499 MXL5005S_TOP_5P5 = 55,
500 MXL5005S_TOP_7P2 = 72,
501 MXL5005S_TOP_9P2 = 92,
502 MXL5005S_TOP_11P0 = 110,
503 MXL5005S_TOP_12P9 = 129,
504 MXL5005S_TOP_14P7 = 147,
505 MXL5005S_TOP_16P8 = 168,
506 MXL5005S_TOP_19P4 = 194,
507 MXL5005S_TOP_21P2 = 212,
508 MXL5005S_TOP_23P2 = 232,
509 MXL5005S_TOP_25P2 = 252,
510 MXL5005S_TOP_27P1 = 271,
511 MXL5005S_TOP_29P2 = 292,
512 MXL5005S_TOP_31P7 = 317,
513 MXL5005S_TOP_34P9 = 349,
514};
515
516
517// IF output load
518enum
519{
520 MXL5005S_IF_OUTPUT_LOAD_200_OHM = 200,
521 MXL5005S_IF_OUTPUT_LOAD_300_OHM = 300,
522};
523
524
525
526
527
528/// MxL5005S extra module alias
529typedef struct MXL5005S_EXTRA_MODULE_TAG MXL5005S_EXTRA_MODULE;
530
531
532
533
534
535// MxL5005S register setting function pointer
536typedef int
537(*MXL5005S_FP_SET_REGS_WITH_TABLE)(
538 struct dvb_usb_device* dib,
539 TUNER_MODULE *pTuner,
540 unsigned char *pAddrTable,
541 unsigned char *pByteTable,
542 int TableLen
543 );
544
545
546// MxL5005S register mask bits setting function pointer
547typedef int
548(*MXL5005S_FP_SET_REG_MASK_BITS)(
549 struct dvb_usb_device* dib,
550 TUNER_MODULE *pTuner,
551 unsigned char RegAddr,
552 unsigned char Msb,
553 unsigned char Lsb,
554 const unsigned char WritingValue
555 );
556
557
558// MxL5005S spectrum mode setting function pointer
559typedef int
560(*MXL5005S_FP_SET_SPECTRUM_MODE)(
561 struct dvb_usb_device* dib,
562 TUNER_MODULE *pTuner,
563 int SpectrumMode
564 );
565
566
567// MxL5005S bandwidth setting function pointer
568typedef int
569(*MXL5005S_FP_SET_BANDWIDTH_HZ)(
570 struct dvb_usb_device* dib,
571 TUNER_MODULE *pTuner,
572 unsigned long BandwidthHz
573 );
574
575
576
577
578
579// MxL5005S extra module
580struct MXL5005S_EXTRA_MODULE_TAG
581{
582 // MxL5005S function pointers
583 MXL5005S_FP_SET_REGS_WITH_TABLE SetRegsWithTable;
584 MXL5005S_FP_SET_REG_MASK_BITS SetRegMaskBits;
585 MXL5005S_FP_SET_SPECTRUM_MODE SetSpectrumMode;
586 MXL5005S_FP_SET_BANDWIDTH_HZ SetBandwidthHz;
587
588
589 // MxL5005S extra data
590 unsigned char AgcMasterByte; // Variable name in MaxLinear source code: AGC_MASTER_BYTE
591
592 // MaxLinear defined struct
593 Tuner_struct MxlDefinedTunerStructure;
594};
595
596
597
598
599
600// Builder
601void
602BuildMxl5005sModule(
603 TUNER_MODULE **ppTuner,
604 TUNER_MODULE *pTunerModuleMemory,
605 MXL5005S_EXTRA_MODULE *pMxl5005sExtraModuleMemory,
606 BASE_INTERFACE_MODULE *pBaseInterfaceModuleMemory,
607 I2C_BRIDGE_MODULE *pI2cBridgeModuleMemory,
608 unsigned char DeviceAddr,
609 int StandardMode
610 );
611
612
613
614
615
616// Manipulaing functions
617void
618mxl5005s_SetDeviceAddr(
619 TUNER_MODULE *pTuner,
620 unsigned char DeviceAddr
621 );
622
623void
624mxl5005s_GetTunerType(
625 TUNER_MODULE *pTuner,
626 int *pTunerType
627 );
628
629int
630mxl5005s_GetDeviceAddr(
631 TUNER_MODULE *pTuner,
632 unsigned char *pDeviceAddr
633 );
634
635int
636mxl5005s_Initialize(
637 struct dvb_usb_device* dib,
638 TUNER_MODULE *pTuner
639 );
640
641int
642mxl5005s_SetRfFreqHz(
643 struct dvb_usb_device* dib,
644 TUNER_MODULE *pTuner,
645 unsigned long RfFreqHz
646 );
647
648int
649mxl5005s_GetRfFreqHz(
650 struct dvb_usb_device* dib,
651 TUNER_MODULE *pTuner,
652 unsigned long *pRfFreqHz
653 );
654
655
656
657
658
659// Extra manipulaing functions
660int
661mxl5005s_SetRegsWithTable(
662 struct dvb_usb_device* dib,
663 TUNER_MODULE *pTuner,
664 unsigned char *pAddrTable,
665 unsigned char *pByteTable,
666 int TableLen
667 );
668
669int
670mxl5005s_SetRegMaskBits(
671 struct dvb_usb_device* dib,
672 TUNER_MODULE *pTuner,
673 unsigned char RegAddr,
674 unsigned char Msb,
675 unsigned char Lsb,
676 const unsigned char WritingValue
677 );
678
679int
680mxl5005s_SetSpectrumMode(
681 struct dvb_usb_device* dib,
682 TUNER_MODULE *pTuner,
683 int SpectrumMode
684 );
685
686int
687mxl5005s_SetBandwidthHz(
688 struct dvb_usb_device* dib,
689 TUNER_MODULE *pTuner,
690 unsigned long BandwidthHz
691 );
692
693
694
695
696
697// I2C birdge module demod argument setting
698void
699mxl5005s_SetI2cBridgeModuleTunerArg(
700 TUNER_MODULE *pTuner
701 );
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717#endif
718