blob: 80af9afc69b0fe61ce7980fe08a845620b857c6f [file] [log] [blame]
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -03001#ifndef __MT2063_H__
2#define __MT2063_H__
3
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -03004#include "dvb_frontend.h"
5
Mauro Carvalho Chehabb6756682011-07-20 20:58:25 -03006enum Bool_t {
7 FALSE = 0,
8 TRUE
9};
10
11typedef unsigned long u32_t;
12
13#define DVBFE_TUNER_OPEN 99
14#define DVBFE_TUNER_SOFTWARE_SHUTDOWN 100
15#define DVBFE_TUNER_CLEAR_POWER_MASKBITS 101
16
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030017#define MT2063_ERROR (1 << 31)
18#define MT2063_USER_ERROR (1 << 30)
19
20/* Macro to be used to check for errors */
21#define MT2063_IS_ERROR(s) (((s) >> 30) != 0)
22#define MT2063_NO_ERROR(s) (((s) >> 30) == 0)
23
24#define MT2063_OK (0x00000000)
25
26/* Unknown error */
27#define MT2063_UNKNOWN (0x80000001)
28
29/* Error: Upconverter PLL is not locked */
30#define MT2063_UPC_UNLOCK (0x80000002)
31
32/* Error: Downconverter PLL is not locked */
33#define MT2063_DNC_UNLOCK (0x80000004)
34
35/* Error: Two-wire serial bus communications error */
36#define MT2063_COMM_ERR (0x80000008)
37
38/* Error: Tuner handle passed to function was invalid */
39#define MT2063_INV_HANDLE (0x80000010)
40
41/* Error: Function argument is invalid (out of range) */
42#define MT2063_ARG_RANGE (0x80000020)
43
44/* Error: Function argument (ptr to return value) was NULL */
45#define MT2063_ARG_NULL (0x80000040)
46
47/* Error: Attempt to open more than MT_TUNER_CNT tuners */
48#define MT2063_TUNER_CNT_ERR (0x80000080)
49
50/* Error: Tuner Part Code / Rev Code mismatches expected value */
51#define MT2063_TUNER_ID_ERR (0x80000100)
52
53/* Error: Tuner Initialization failure */
54#define MT2063_TUNER_INIT_ERR (0x80000200)
55
56#define MT2063_TUNER_OPEN_ERR (0x80000400)
57
58/* User-definable fields (see mt_userdef.h) */
59#define MT2063_USER_DEFINED1 (0x00001000)
60#define MT2063_USER_DEFINED2 (0x00002000)
61#define MT2063_USER_DEFINED3 (0x00004000)
62#define MT2063_USER_DEFINED4 (0x00008000)
63#define MT2063_USER_MASK (0x4000f000)
64#define MT2063_USER_SHIFT (12)
65
66/* Info: Mask of bits used for # of LO-related spurs that were avoided during tuning */
67#define MT2063_SPUR_CNT_MASK (0x001f0000)
68#define MT2063_SPUR_SHIFT (16)
69
70/* Info: Tuner timeout waiting for condition */
71#define MT2063_TUNER_TIMEOUT (0x00400000)
72
73/* Info: Unavoidable LO-related spur may be present in the output */
74#define MT2063_SPUR_PRESENT_ERR (0x00800000)
75
76/* Info: Tuner input frequency is out of range */
77#define MT2063_FIN_RANGE (0x01000000)
78
79/* Info: Tuner output frequency is out of range */
80#define MT2063_FOUT_RANGE (0x02000000)
81
82/* Info: Upconverter frequency is out of range (may be reason for MT_UPC_UNLOCK) */
83#define MT2063_UPC_RANGE (0x04000000)
84
85/* Info: Downconverter frequency is out of range (may be reason for MT_DPC_UNLOCK) */
86#define MT2063_DNC_RANGE (0x08000000)
87
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030088/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -030089 * Data Types
90 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030091#define MT2060_CNT 10
92
93typedef unsigned char U8Data; /* type corresponds to 8 bits */
94typedef unsigned int UData_t; /* type must be at least 32 bits */
95typedef int SData_t; /* type must be at least 32 bits */
96typedef void *Handle_t; /* memory pointer type */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -030097
98#define MAX_UDATA (4294967295) /* max value storable in UData_t */
99
100/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300101 * Define an MTxxxx_CNT macro for each type of tuner that will be built
102 * into your application (e.g., MT2121, MT2060). MT_TUNER_CNT
103 * must be set to the SUM of all of the MTxxxx_CNT macros.
104 *
105 * #define MT2050_CNT (1)
106 * #define MT2060_CNT (1)
107 * #define MT2111_CNT (1)
108 * #define MT2121_CNT (3)
109 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300110
111#define MT2063_CNT (1)
112
113#if !defined( MT2063_TUNER_CNT )
114#define MT2063_TUNER_CNT (1) /* total num of MicroTuner tuners */
115#endif
116#define MT2063_I2C (0xC0)
117
118UData_t MT2063_WriteSub(Handle_t hUserData,
119 UData_t addr,
120 U8Data subAddress, U8Data * pData, UData_t cnt);
121
122UData_t MT2063_ReadSub(Handle_t hUserData,
123 UData_t addr,
124 U8Data subAddress, U8Data * pData, UData_t cnt);
125
126void MT2063_Sleep(Handle_t hUserData, UData_t nMinDelayTime);
127
128#if defined(MT2060_CNT)
129#if MT2060_CNT > 0
130UData_t MT2060_TunerGain(Handle_t hUserData, SData_t * pMeas);
131#endif
132#endif
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300133
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300134/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300135 * Constant defining the version of the following structure
136 * and therefore the API for this code.
137 *
138 * When compiling the tuner driver, the preprocessor will
139 * check against this version number to make sure that
140 * it matches the version that the tuner driver knows about.
141 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300142/* Version 010201 => 1.21 */
143#define MT2063_AVOID_SPURS_INFO_VERSION 010201
144
145/* DECT Frequency Avoidance */
146#define MT2063_DECT_AVOID_US_FREQS 0x00000001
147
148#define MT2063_DECT_AVOID_EURO_FREQS 0x00000002
149
150#define MT2063_EXCLUDE_US_DECT_FREQUENCIES(s) (((s) & MT2063_DECT_AVOID_US_FREQS) != 0)
151
152#define MT2063_EXCLUDE_EURO_DECT_FREQUENCIES(s) (((s) & MT2063_DECT_AVOID_EURO_FREQS) != 0)
153
154enum MT2063_DECT_Avoid_Type {
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300155 MT2063_NO_DECT_AVOIDANCE = 0, /* Do not create DECT exclusion zones. */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300156 MT2063_AVOID_US_DECT = MT2063_DECT_AVOID_US_FREQS, /* Avoid US DECT frequencies. */
157 MT2063_AVOID_EURO_DECT = MT2063_DECT_AVOID_EURO_FREQS, /* Avoid European DECT frequencies. */
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300158 MT2063_AVOID_BOTH /* Avoid both regions. Not typically used. */
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300159};
160
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300161#define MT2063_MAX_ZONES 48
162
163struct MT2063_ExclZone_t;
164
165struct MT2063_ExclZone_t {
166 UData_t min_;
167 UData_t max_;
168 struct MT2063_ExclZone_t *next_;
169};
170
171/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300172 * Structure of data needed for Spur Avoidance
173 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300174struct MT2063_AvoidSpursData_t {
175 UData_t nAS_Algorithm;
176 UData_t f_ref;
177 UData_t f_in;
178 UData_t f_LO1;
179 UData_t f_if1_Center;
180 UData_t f_if1_Request;
181 UData_t f_if1_bw;
182 UData_t f_LO2;
183 UData_t f_out;
184 UData_t f_out_bw;
185 UData_t f_LO1_Step;
186 UData_t f_LO2_Step;
187 UData_t f_LO1_FracN_Avoid;
188 UData_t f_LO2_FracN_Avoid;
189 UData_t f_zif_bw;
190 UData_t f_min_LO_Separation;
191 UData_t maxH1;
192 UData_t maxH2;
193 enum MT2063_DECT_Avoid_Type avoidDECT;
194 UData_t bSpurPresent;
195 UData_t bSpurAvoided;
196 UData_t nSpursFound;
197 UData_t nZones;
198 struct MT2063_ExclZone_t *freeZones;
199 struct MT2063_ExclZone_t *usedZones;
200 struct MT2063_ExclZone_t MT2063_ExclZones[MT2063_MAX_ZONES];
201};
202
203UData_t MT2063_RegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info);
204
205void MT2063_UnRegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info);
206
207void MT2063_ResetExclZones(struct MT2063_AvoidSpursData_t *pAS_Info);
208
209void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info,
210 UData_t f_min, UData_t f_max);
211
212UData_t MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info);
213
214UData_t MT2063_AvoidSpurs(Handle_t h, struct MT2063_AvoidSpursData_t *pAS_Info);
215
216UData_t MT2063_AvoidSpursVersion(void);
217
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300218
219/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300220 * Values returned by the MT2063's on-chip temperature sensor
221 * to be read/written.
222 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300223enum MT2063_Temperature {
224 MT2063_T_0C = 0, /* Temperature approx 0C */
225 MT2063_T_10C, /* Temperature approx 10C */
226 MT2063_T_20C, /* Temperature approx 20C */
227 MT2063_T_30C, /* Temperature approx 30C */
228 MT2063_T_40C, /* Temperature approx 40C */
229 MT2063_T_50C, /* Temperature approx 50C */
230 MT2063_T_60C, /* Temperature approx 60C */
231 MT2063_T_70C, /* Temperature approx 70C */
232 MT2063_T_80C, /* Temperature approx 80C */
233 MT2063_T_90C, /* Temperature approx 90C */
234 MT2063_T_100C, /* Temperature approx 100C */
235 MT2063_T_110C, /* Temperature approx 110C */
236 MT2063_T_120C, /* Temperature approx 120C */
237 MT2063_T_130C, /* Temperature approx 130C */
238 MT2063_T_140C, /* Temperature approx 140C */
239 MT2063_T_150C, /* Temperature approx 150C */
240};
241
242/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300243 * Parameters for selecting GPIO bits
244 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300245enum MT2063_GPIO_Attr {
246 MT2063_GPIO_IN,
247 MT2063_GPIO_DIR,
248 MT2063_GPIO_OUT,
249};
250
251enum MT2063_GPIO_ID {
252 MT2063_GPIO0,
253 MT2063_GPIO1,
254 MT2063_GPIO2,
255};
256
257/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300258 * Parameter for function MT2063_SetExtSRO that specifies the external
259 * SRO drive frequency.
260 *
261 * MT2063_EXT_SRO_OFF is the power-up default value.
262 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300263enum MT2063_Ext_SRO {
264 MT2063_EXT_SRO_OFF, /* External SRO drive off */
265 MT2063_EXT_SRO_BY_4, /* External SRO drive divide by 4 */
266 MT2063_EXT_SRO_BY_2, /* External SRO drive divide by 2 */
267 MT2063_EXT_SRO_BY_1 /* External SRO drive divide by 1 */
268};
269
270/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300271 * Parameter for function MT2063_SetPowerMask that specifies the power down
272 * of various sections of the MT2063.
273 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300274enum MT2063_Mask_Bits {
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300275 MT2063_REG_SD = 0x0040, /* Shutdown regulator */
276 MT2063_SRO_SD = 0x0020, /* Shutdown SRO */
277 MT2063_AFC_SD = 0x0010, /* Shutdown AFC A/D */
278 MT2063_PD_SD = 0x0002, /* Enable power detector shutdown */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300279 MT2063_PDADC_SD = 0x0001, /* Enable power detector A/D shutdown */
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300280 MT2063_VCO_SD = 0x8000, /* Enable VCO shutdown */
281 MT2063_LTX_SD = 0x4000, /* Enable LTX shutdown */
282 MT2063_LT1_SD = 0x2000, /* Enable LT1 shutdown */
283 MT2063_LNA_SD = 0x1000, /* Enable LNA shutdown */
284 MT2063_UPC_SD = 0x0800, /* Enable upconverter shutdown */
285 MT2063_DNC_SD = 0x0400, /* Enable downconverter shutdown */
286 MT2063_VGA_SD = 0x0200, /* Enable VGA shutdown */
287 MT2063_AMP_SD = 0x0100, /* Enable AMP shutdown */
288 MT2063_ALL_SD = 0xFF73, /* All shutdown bits for this tuner */
289 MT2063_NONE_SD = 0x0000 /* No shutdown bits */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300290};
291
292/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300293 * Parameter for function MT2063_GetParam & MT2063_SetParam that
294 * specifies the tuning algorithm parameter to be read/written.
295 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300296enum MT2063_Param {
297 /* tuner address set by MT2063_Open() */
298 MT2063_IC_ADDR,
299
300 /* max number of MT2063 tuners set by MT_TUNER_CNT in mt_userdef.h */
301 MT2063_MAX_OPEN,
302
303 /* current number of open MT2063 tuners set by MT2063_Open() */
304 MT2063_NUM_OPEN,
305
306 /* crystal frequency (default: 16000000 Hz) */
307 MT2063_SRO_FREQ,
308
309 /* min tuning step size (default: 50000 Hz) */
310 MT2063_STEPSIZE,
311
312 /* input center frequency set by MT2063_Tune() */
313 MT2063_INPUT_FREQ,
314
315 /* LO1 Frequency set by MT2063_Tune() */
316 MT2063_LO1_FREQ,
317
318 /* LO1 minimum step size (default: 250000 Hz) */
319 MT2063_LO1_STEPSIZE,
320
321 /* LO1 FracN keep-out region (default: 999999 Hz) */
322 MT2063_LO1_FRACN_AVOID_PARAM,
323
324 /* Current 1st IF in use set by MT2063_Tune() */
325 MT2063_IF1_ACTUAL,
326
327 /* Requested 1st IF set by MT2063_Tune() */
328 MT2063_IF1_REQUEST,
329
330 /* Center of 1st IF SAW filter (default: 1218000000 Hz) */
331 MT2063_IF1_CENTER,
332
333 /* Bandwidth of 1st IF SAW filter (default: 20000000 Hz) */
334 MT2063_IF1_BW,
335
336 /* zero-IF bandwidth (default: 2000000 Hz) */
337 MT2063_ZIF_BW,
338
339 /* LO2 Frequency set by MT2063_Tune() */
340 MT2063_LO2_FREQ,
341
342 /* LO2 minimum step size (default: 50000 Hz) */
343 MT2063_LO2_STEPSIZE,
344
345 /* LO2 FracN keep-out region (default: 374999 Hz) */
346 MT2063_LO2_FRACN_AVOID,
347
348 /* output center frequency set by MT2063_Tune() */
349 MT2063_OUTPUT_FREQ,
350
351 /* output bandwidth set by MT2063_Tune() */
352 MT2063_OUTPUT_BW,
353
354 /* min inter-tuner LO separation (default: 1000000 Hz) */
355 MT2063_LO_SEPARATION,
356
357 /* ID of avoid-spurs algorithm in use compile-time constant */
358 MT2063_AS_ALG,
359
360 /* max # of intra-tuner harmonics (default: 15) */
361 MT2063_MAX_HARM1,
362
363 /* max # of inter-tuner harmonics (default: 7) */
364 MT2063_MAX_HARM2,
365
366 /* # of 1st IF exclusion zones used set by MT2063_Tune() */
367 MT2063_EXCL_ZONES,
368
369 /* # of spurs found/avoided set by MT2063_Tune() */
370 MT2063_NUM_SPURS,
371
372 /* >0 spurs avoided set by MT2063_Tune() */
373 MT2063_SPUR_AVOIDED,
374
375 /* >0 spurs in output (mathematically) set by MT2063_Tune() */
376 MT2063_SPUR_PRESENT,
377
378 /* Receiver Mode for some parameters. 1 is DVB-T */
379 MT2063_RCVR_MODE,
380
381 /* directly set LNA attenuation, parameter is value to set */
382 MT2063_ACLNA,
383
384 /* maximum LNA attenuation, parameter is value to set */
385 MT2063_ACLNA_MAX,
386
387 /* directly set ATN attenuation. Paremeter is value to set. */
388 MT2063_ACRF,
389
390 /* maxium ATN attenuation. Paremeter is value to set. */
391 MT2063_ACRF_MAX,
392
393 /* directly set FIF attenuation. Paremeter is value to set. */
394 MT2063_ACFIF,
395
396 /* maxium FIF attenuation. Paremeter is value to set. */
397 MT2063_ACFIF_MAX,
398
399 /* LNA Rin */
400 MT2063_LNA_RIN,
401
402 /* Power Detector LNA level target */
403 MT2063_LNA_TGT,
404
405 /* Power Detector 1 level */
406 MT2063_PD1,
407
408 /* Power Detector 1 level target */
409 MT2063_PD1_TGT,
410
411 /* Power Detector 2 level */
412 MT2063_PD2,
413
414 /* Power Detector 2 level target */
415 MT2063_PD2_TGT,
416
417 /* Selects, which DNC is activ */
418 MT2063_DNC_OUTPUT_ENABLE,
419
420 /* VGA gain code */
421 MT2063_VGAGC,
422
423 /* VGA bias current */
424 MT2063_VGAOI,
425
426 /* TAGC, determins the speed of the AGC */
427 MT2063_TAGC,
428
429 /* AMP gain code */
430 MT2063_AMPGC,
431
432 /* Control setting to avoid DECT freqs (default: MT_AVOID_BOTH) */
433 MT2063_AVOID_DECT,
434
435 /* Cleartune filter selection: 0 - by IC (default), 1 - by software */
436 MT2063_CTFILT_SW,
437
438 MT2063_EOP /* last entry in enumerated list */
439};
440
441/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300442 * Parameter for selecting tuner mode
443 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300444enum MT2063_RCVR_MODES {
445 MT2063_CABLE_QAM = 0, /* Digital cable */
446 MT2063_CABLE_ANALOG, /* Analog cable */
447 MT2063_OFFAIR_COFDM, /* Digital offair */
448 MT2063_OFFAIR_COFDM_SAWLESS, /* Digital offair without SAW */
449 MT2063_OFFAIR_ANALOG, /* Analog offair */
450 MT2063_OFFAIR_8VSB, /* Analog offair */
451 MT2063_NUM_RCVR_MODES
452};
453
454/*
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300455 * Possible values for MT2063_DNC_OUTPUT
456 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300457enum MT2063_DNC_Output_Enable {
458 MT2063_DNC_NONE = 0,
459 MT2063_DNC_1,
460 MT2063_DNC_2,
461 MT2063_DNC_BOTH
462};
463
464/*
465** Two-wire serial bus subaddresses of the tuner registers.
466** Also known as the tuner's register addresses.
467*/
468enum MT2063_Register_Offsets {
469 MT2063_REG_PART_REV = 0, /* 0x00: Part/Rev Code */
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300470 MT2063_REG_LO1CQ_1, /* 0x01: LO1C Queued Byte 1 */
471 MT2063_REG_LO1CQ_2, /* 0x02: LO1C Queued Byte 2 */
472 MT2063_REG_LO2CQ_1, /* 0x03: LO2C Queued Byte 1 */
473 MT2063_REG_LO2CQ_2, /* 0x04: LO2C Queued Byte 2 */
474 MT2063_REG_LO2CQ_3, /* 0x05: LO2C Queued Byte 3 */
475 MT2063_REG_RSVD_06, /* 0x06: Reserved */
476 MT2063_REG_LO_STATUS, /* 0x07: LO Status */
477 MT2063_REG_FIFFC, /* 0x08: FIFF Center */
478 MT2063_REG_CLEARTUNE, /* 0x09: ClearTune Filter */
479 MT2063_REG_ADC_OUT, /* 0x0A: ADC_OUT */
480 MT2063_REG_LO1C_1, /* 0x0B: LO1C Byte 1 */
481 MT2063_REG_LO1C_2, /* 0x0C: LO1C Byte 2 */
482 MT2063_REG_LO2C_1, /* 0x0D: LO2C Byte 1 */
483 MT2063_REG_LO2C_2, /* 0x0E: LO2C Byte 2 */
484 MT2063_REG_LO2C_3, /* 0x0F: LO2C Byte 3 */
485 MT2063_REG_RSVD_10, /* 0x10: Reserved */
486 MT2063_REG_PWR_1, /* 0x11: PWR Byte 1 */
487 MT2063_REG_PWR_2, /* 0x12: PWR Byte 2 */
488 MT2063_REG_TEMP_STATUS, /* 0x13: Temp Status */
489 MT2063_REG_XO_STATUS, /* 0x14: Crystal Status */
490 MT2063_REG_RF_STATUS, /* 0x15: RF Attn Status */
491 MT2063_REG_FIF_STATUS, /* 0x16: FIF Attn Status */
492 MT2063_REG_LNA_OV, /* 0x17: LNA Attn Override */
493 MT2063_REG_RF_OV, /* 0x18: RF Attn Override */
494 MT2063_REG_FIF_OV, /* 0x19: FIF Attn Override */
495 MT2063_REG_LNA_TGT, /* 0x1A: Reserved */
496 MT2063_REG_PD1_TGT, /* 0x1B: Pwr Det 1 Target */
497 MT2063_REG_PD2_TGT, /* 0x1C: Pwr Det 2 Target */
498 MT2063_REG_RSVD_1D, /* 0x1D: Reserved */
499 MT2063_REG_RSVD_1E, /* 0x1E: Reserved */
500 MT2063_REG_RSVD_1F, /* 0x1F: Reserved */
501 MT2063_REG_RSVD_20, /* 0x20: Reserved */
502 MT2063_REG_BYP_CTRL, /* 0x21: Bypass Control */
503 MT2063_REG_RSVD_22, /* 0x22: Reserved */
504 MT2063_REG_RSVD_23, /* 0x23: Reserved */
505 MT2063_REG_RSVD_24, /* 0x24: Reserved */
506 MT2063_REG_RSVD_25, /* 0x25: Reserved */
507 MT2063_REG_RSVD_26, /* 0x26: Reserved */
508 MT2063_REG_RSVD_27, /* 0x27: Reserved */
509 MT2063_REG_FIFF_CTRL, /* 0x28: FIFF Control */
510 MT2063_REG_FIFF_OFFSET, /* 0x29: FIFF Offset */
511 MT2063_REG_CTUNE_CTRL, /* 0x2A: Reserved */
512 MT2063_REG_CTUNE_OV, /* 0x2B: Reserved */
513 MT2063_REG_CTRL_2C, /* 0x2C: Reserved */
514 MT2063_REG_FIFF_CTRL2, /* 0x2D: Fiff Control */
515 MT2063_REG_RSVD_2E, /* 0x2E: Reserved */
516 MT2063_REG_DNC_GAIN, /* 0x2F: DNC Control */
517 MT2063_REG_VGA_GAIN, /* 0x30: VGA Gain Ctrl */
518 MT2063_REG_RSVD_31, /* 0x31: Reserved */
519 MT2063_REG_TEMP_SEL, /* 0x32: Temperature Selection */
520 MT2063_REG_RSVD_33, /* 0x33: Reserved */
521 MT2063_REG_RSVD_34, /* 0x34: Reserved */
522 MT2063_REG_RSVD_35, /* 0x35: Reserved */
523 MT2063_REG_RSVD_36, /* 0x36: Reserved */
524 MT2063_REG_RSVD_37, /* 0x37: Reserved */
525 MT2063_REG_RSVD_38, /* 0x38: Reserved */
526 MT2063_REG_RSVD_39, /* 0x39: Reserved */
527 MT2063_REG_RSVD_3A, /* 0x3A: Reserved */
528 MT2063_REG_RSVD_3B, /* 0x3B: Reserved */
529 MT2063_REG_RSVD_3C, /* 0x3C: Reserved */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300530 MT2063_REG_END_REGS
531};
532
533struct MT2063_Info_t {
534 Handle_t handle;
535 Handle_t hUserData;
536 UData_t address;
537 UData_t version;
538 UData_t tuner_id;
539 struct MT2063_AvoidSpursData_t AS_Data;
540 UData_t f_IF1_actual;
541 UData_t rcvr_mode;
542 UData_t ctfilt_sw;
543 UData_t CTFiltMax[31];
544 UData_t num_regs;
545 U8Data reg[MT2063_REG_END_REGS];
546};
547typedef struct MT2063_Info_t *pMT2063_Info_t;
548
549enum MTTune_atv_standard {
550 MTTUNEA_UNKNOWN = 0,
551 MTTUNEA_PAL_B,
552 MTTUNEA_PAL_G,
553 MTTUNEA_PAL_I,
554 MTTUNEA_PAL_L,
555 MTTUNEA_PAL_MN,
556 MTTUNEA_PAL_DK,
557 MTTUNEA_DIGITAL,
558 MTTUNEA_FMRADIO,
559 MTTUNEA_DVBC,
560 MTTUNEA_DVBT
561};
562
563/* ====== Functions which are declared in MT2063.c File ======= */
564
565UData_t MT2063_Open(UData_t MT2063_Addr,
566 Handle_t * hMT2063, Handle_t hUserData);
567
568UData_t MT2063_Close(Handle_t hMT2063);
569
570UData_t MT2063_Tune(Handle_t h, UData_t f_in); /* RF input center frequency */
571
572UData_t MT2063_GetGPIO(Handle_t h, enum MT2063_GPIO_ID gpio_id,
573 enum MT2063_GPIO_Attr attr, UData_t * value);
574
575UData_t MT2063_GetLocked(Handle_t h);
576
577UData_t MT2063_GetParam(Handle_t h, enum MT2063_Param param, UData_t * pValue);
578
579UData_t MT2063_GetReg(Handle_t h, U8Data reg, U8Data * val);
580
581UData_t MT2063_GetTemp(Handle_t h, enum MT2063_Temperature *value);
582
583UData_t MT2063_GetUserData(Handle_t h, Handle_t * hUserData);
584
585UData_t MT2063_ReInit(Handle_t h);
586
587UData_t MT2063_SetGPIO(Handle_t h, enum MT2063_GPIO_ID gpio_id,
588 enum MT2063_GPIO_Attr attr, UData_t value);
589
590UData_t MT2063_SetParam(Handle_t h, enum MT2063_Param param, UData_t nValue);
591
592UData_t MT2063_SetPowerMaskBits(Handle_t h, enum MT2063_Mask_Bits Bits);
593
594UData_t MT2063_ClearPowerMaskBits(Handle_t h, enum MT2063_Mask_Bits Bits);
595
596UData_t MT2063_GetPowerMaskBits(Handle_t h, enum MT2063_Mask_Bits *Bits);
597
598UData_t MT2063_EnableExternalShutdown(Handle_t h, U8Data Enabled);
599
600UData_t MT2063_SoftwareShutdown(Handle_t h, U8Data Shutdown);
601
602UData_t MT2063_SetExtSRO(Handle_t h, enum MT2063_Ext_SRO Ext_SRO_Setting);
603
604UData_t MT2063_SetReg(Handle_t h, U8Data reg, U8Data val);
605
606UData_t MT_Tune_atv(Handle_t h, UData_t f_in, UData_t bw_in,
607 enum MTTune_atv_standard tv_type);
608
609struct mt2063_config {
610 u8 tuner_address;
611 u32 refclock;
612};
613
614struct mt2063_state {
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300615 struct i2c_adapter *i2c;
616
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300617 const struct mt2063_config *config;
618 struct dvb_tuner_ops ops;
619 struct dvb_frontend *frontend;
620 struct tuner_state status;
621 const struct MT2063_Info_t *MT2063_ht;
622 enum Bool_t MT2063_init;
623
624 enum MTTune_atv_standard tv_type;
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300625 u32 frequency;
626 u32 srate;
627 u32 bandwidth;
628 u32 reference;
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300629};
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300630
Mauro Carvalho Chehabb6756682011-07-20 20:58:25 -0300631#if defined(CONFIG_MEDIA_TUNER_MT2063) || (defined(CONFIG_MEDIA_TUNER_MT2063_MODULE) && defined(MODULE))
632struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
633 struct mt2063_config *config,
634 struct i2c_adapter *i2c);
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300635
636#else
637
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300638static inline struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
Mauro Carvalho Chehabb6756682011-07-20 20:58:25 -0300639 struct mt2063_config *config,
640 struct i2c_adapter *i2c)
Mauro Carvalho Chehab223c7b02011-07-20 19:48:59 -0300641{
642 printk(KERN_WARNING "%s: Driver disabled by Kconfig\n", __func__);
643 return NULL;
644}
645
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300646#endif /* CONFIG_DVB_MT2063 */
Mauro Carvalho Chehab0e301442011-07-20 19:52:49 -0300647
Mauro Carvalho Chehab4dca4ef2011-07-20 20:15:01 -0300648#endif /* __MT2063_H__ */