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