19a0bf528SMauro Carvalho Chehab #include "drxk_map.h"
29a0bf528SMauro Carvalho Chehab 
39a0bf528SMauro Carvalho Chehab #define DRXK_VERSION_MAJOR 0
49a0bf528SMauro Carvalho Chehab #define DRXK_VERSION_MINOR 9
59a0bf528SMauro Carvalho Chehab #define DRXK_VERSION_PATCH 4300
69a0bf528SMauro Carvalho Chehab 
79a0bf528SMauro Carvalho Chehab #define HI_I2C_DELAY        42
89a0bf528SMauro Carvalho Chehab #define HI_I2C_BRIDGE_DELAY 350
99a0bf528SMauro Carvalho Chehab #define DRXK_MAX_RETRIES    100
109a0bf528SMauro Carvalho Chehab 
119a0bf528SMauro Carvalho Chehab #define DRIVER_4400 1
129a0bf528SMauro Carvalho Chehab 
139a0bf528SMauro Carvalho Chehab #define DRXX_JTAGID   0x039210D9
149a0bf528SMauro Carvalho Chehab #define DRXX_J_JTAGID 0x239310D9
159a0bf528SMauro Carvalho Chehab #define DRXX_K_JTAGID 0x039210D9
169a0bf528SMauro Carvalho Chehab 
179a0bf528SMauro Carvalho Chehab #define DRX_UNKNOWN     254
189a0bf528SMauro Carvalho Chehab #define DRX_AUTO        255
199a0bf528SMauro Carvalho Chehab 
209a0bf528SMauro Carvalho Chehab #define DRX_SCU_READY   0
219a0bf528SMauro Carvalho Chehab #define DRXK_MAX_WAITTIME (200)
229a0bf528SMauro Carvalho Chehab #define SCU_RESULT_OK      0
239a0bf528SMauro Carvalho Chehab #define SCU_RESULT_SIZE   -4
249a0bf528SMauro Carvalho Chehab #define SCU_RESULT_INVPAR -3
259a0bf528SMauro Carvalho Chehab #define SCU_RESULT_UNKSTD -2
269a0bf528SMauro Carvalho Chehab #define SCU_RESULT_UNKCMD -1
279a0bf528SMauro Carvalho Chehab 
289a0bf528SMauro Carvalho Chehab #ifndef DRXK_OFDM_TR_SHUTDOWN_TIMEOUT
299a0bf528SMauro Carvalho Chehab #define DRXK_OFDM_TR_SHUTDOWN_TIMEOUT (200)
309a0bf528SMauro Carvalho Chehab #endif
319a0bf528SMauro Carvalho Chehab 
329a0bf528SMauro Carvalho Chehab #define DRXK_8VSB_MPEG_BIT_RATE     19392658UL  /*bps*/
339a0bf528SMauro Carvalho Chehab #define DRXK_DVBT_MPEG_BIT_RATE     32000000UL  /*bps*/
349a0bf528SMauro Carvalho Chehab #define DRXK_QAM16_MPEG_BIT_RATE    27000000UL  /*bps*/
359a0bf528SMauro Carvalho Chehab #define DRXK_QAM32_MPEG_BIT_RATE    33000000UL  /*bps*/
369a0bf528SMauro Carvalho Chehab #define DRXK_QAM64_MPEG_BIT_RATE    40000000UL  /*bps*/
379a0bf528SMauro Carvalho Chehab #define DRXK_QAM128_MPEG_BIT_RATE   46000000UL  /*bps*/
389a0bf528SMauro Carvalho Chehab #define DRXK_QAM256_MPEG_BIT_RATE   52000000UL  /*bps*/
399a0bf528SMauro Carvalho Chehab #define DRXK_MAX_MPEG_BIT_RATE      52000000UL  /*bps*/
409a0bf528SMauro Carvalho Chehab 
419a0bf528SMauro Carvalho Chehab #define   IQM_CF_OUT_ENA_OFDM__M                                            0x4
429a0bf528SMauro Carvalho Chehab #define     IQM_FS_ADJ_SEL_B_QAM                                            0x1
439a0bf528SMauro Carvalho Chehab #define     IQM_FS_ADJ_SEL_B_OFF                                            0x0
449a0bf528SMauro Carvalho Chehab #define     IQM_FS_ADJ_SEL_B_VSB                                            0x2
459a0bf528SMauro Carvalho Chehab #define     IQM_RC_ADJ_SEL_B_OFF                                            0x0
469a0bf528SMauro Carvalho Chehab #define     IQM_RC_ADJ_SEL_B_QAM                                            0x1
479a0bf528SMauro Carvalho Chehab #define     IQM_RC_ADJ_SEL_B_VSB                                            0x2
489a0bf528SMauro Carvalho Chehab 
499a0bf528SMauro Carvalho Chehab enum OperationMode {
509a0bf528SMauro Carvalho Chehab 	OM_NONE,
519a0bf528SMauro Carvalho Chehab 	OM_QAM_ITU_A,
529a0bf528SMauro Carvalho Chehab 	OM_QAM_ITU_B,
539a0bf528SMauro Carvalho Chehab 	OM_QAM_ITU_C,
549a0bf528SMauro Carvalho Chehab 	OM_DVBT
559a0bf528SMauro Carvalho Chehab };
569a0bf528SMauro Carvalho Chehab 
579a0bf528SMauro Carvalho Chehab enum DRXPowerMode {
589a0bf528SMauro Carvalho Chehab 	DRX_POWER_UP = 0,
599a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_1,
609a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_2,
619a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_3,
629a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_4,
639a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_5,
649a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_6,
659a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_7,
669a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_8,
679a0bf528SMauro Carvalho Chehab 
689a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_9,
699a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_10,
709a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_11,
719a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_12,
729a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_13,
739a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_14,
749a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_15,
759a0bf528SMauro Carvalho Chehab 	DRX_POWER_MODE_16,
769a0bf528SMauro Carvalho Chehab 	DRX_POWER_DOWN = 255
779a0bf528SMauro Carvalho Chehab };
789a0bf528SMauro Carvalho Chehab 
799a0bf528SMauro Carvalho Chehab 
809a0bf528SMauro Carvalho Chehab /** /brief Intermediate power mode for DRXK, power down OFDM clock domain */
819a0bf528SMauro Carvalho Chehab #ifndef DRXK_POWER_DOWN_OFDM
829a0bf528SMauro Carvalho Chehab #define DRXK_POWER_DOWN_OFDM        DRX_POWER_MODE_1
839a0bf528SMauro Carvalho Chehab #endif
849a0bf528SMauro Carvalho Chehab 
859a0bf528SMauro Carvalho Chehab /** /brief Intermediate power mode for DRXK, power down core (sysclk) */
869a0bf528SMauro Carvalho Chehab #ifndef DRXK_POWER_DOWN_CORE
879a0bf528SMauro Carvalho Chehab #define DRXK_POWER_DOWN_CORE        DRX_POWER_MODE_9
889a0bf528SMauro Carvalho Chehab #endif
899a0bf528SMauro Carvalho Chehab 
909a0bf528SMauro Carvalho Chehab /** /brief Intermediate power mode for DRXK, power down pll (only osc runs) */
919a0bf528SMauro Carvalho Chehab #ifndef DRXK_POWER_DOWN_PLL
929a0bf528SMauro Carvalho Chehab #define DRXK_POWER_DOWN_PLL         DRX_POWER_MODE_10
939a0bf528SMauro Carvalho Chehab #endif
949a0bf528SMauro Carvalho Chehab 
959a0bf528SMauro Carvalho Chehab 
969a0bf528SMauro Carvalho Chehab enum AGC_CTRL_MODE { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF };
979a0bf528SMauro Carvalho Chehab enum EDrxkState {
989a0bf528SMauro Carvalho Chehab 	DRXK_UNINITIALIZED = 0,
999a0bf528SMauro Carvalho Chehab 	DRXK_STOPPED,
1009a0bf528SMauro Carvalho Chehab 	DRXK_DTV_STARTED,
1019a0bf528SMauro Carvalho Chehab 	DRXK_ATV_STARTED,
1029a0bf528SMauro Carvalho Chehab 	DRXK_POWERED_DOWN,
1039a0bf528SMauro Carvalho Chehab 	DRXK_NO_DEV			/* If drxk init failed */
1049a0bf528SMauro Carvalho Chehab };
1059a0bf528SMauro Carvalho Chehab 
1069a0bf528SMauro Carvalho Chehab enum EDrxkCoefArrayIndex {
1079a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_MN = 0,
1089a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_FM    ,
1099a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_L     ,
1109a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_LP    ,
1119a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_BG    ,
1129a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_DK    ,
1139a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_I     ,
1149a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_MAX
1159a0bf528SMauro Carvalho Chehab };
1169a0bf528SMauro Carvalho Chehab enum EDrxkSifAttenuation {
1179a0bf528SMauro Carvalho Chehab 	DRXK_SIF_ATTENUATION_0DB,
1189a0bf528SMauro Carvalho Chehab 	DRXK_SIF_ATTENUATION_3DB,
1199a0bf528SMauro Carvalho Chehab 	DRXK_SIF_ATTENUATION_6DB,
1209a0bf528SMauro Carvalho Chehab 	DRXK_SIF_ATTENUATION_9DB
1219a0bf528SMauro Carvalho Chehab };
1229a0bf528SMauro Carvalho Chehab enum EDrxkConstellation {
1239a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_BPSK = 0,
1249a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QPSK,
1259a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_PSK8,
1269a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM16,
1279a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM32,
1289a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM64,
1299a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM128,
1309a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM256,
1319a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM512,
1329a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM1024,
1339a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_UNKNOWN = DRX_UNKNOWN,
1349a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_AUTO    = DRX_AUTO
1359a0bf528SMauro Carvalho Chehab };
1369a0bf528SMauro Carvalho Chehab enum EDrxkInterleaveMode {
1379a0bf528SMauro Carvalho Chehab 	DRXK_QAM_I12_J17    = 16,
1389a0bf528SMauro Carvalho Chehab 	DRXK_QAM_I_UNKNOWN  = DRX_UNKNOWN
1399a0bf528SMauro Carvalho Chehab };
1409a0bf528SMauro Carvalho Chehab enum {
1419a0bf528SMauro Carvalho Chehab 	DRXK_SPIN_A1 = 0,
1429a0bf528SMauro Carvalho Chehab 	DRXK_SPIN_A2,
1439a0bf528SMauro Carvalho Chehab 	DRXK_SPIN_A3,
1449a0bf528SMauro Carvalho Chehab 	DRXK_SPIN_UNKNOWN
1459a0bf528SMauro Carvalho Chehab };
1469a0bf528SMauro Carvalho Chehab 
1479a0bf528SMauro Carvalho Chehab enum DRXKCfgDvbtSqiSpeed {
1489a0bf528SMauro Carvalho Chehab 	DRXK_DVBT_SQI_SPEED_FAST = 0,
1499a0bf528SMauro Carvalho Chehab 	DRXK_DVBT_SQI_SPEED_MEDIUM,
1509a0bf528SMauro Carvalho Chehab 	DRXK_DVBT_SQI_SPEED_SLOW,
1519a0bf528SMauro Carvalho Chehab 	DRXK_DVBT_SQI_SPEED_UNKNOWN = DRX_UNKNOWN
1529a0bf528SMauro Carvalho Chehab } ;
1539a0bf528SMauro Carvalho Chehab 
1549a0bf528SMauro Carvalho Chehab enum DRXFftmode_t {
1559a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_2K = 0,
1569a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_4K,
1579a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_8K,
1589a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_UNKNOWN = DRX_UNKNOWN,
1599a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_AUTO    = DRX_AUTO
1609a0bf528SMauro Carvalho Chehab };
1619a0bf528SMauro Carvalho Chehab 
1629a0bf528SMauro Carvalho Chehab enum DRXMPEGStrWidth_t {
1639a0bf528SMauro Carvalho Chehab 	DRX_MPEG_STR_WIDTH_1,
1649a0bf528SMauro Carvalho Chehab 	DRX_MPEG_STR_WIDTH_8
1659a0bf528SMauro Carvalho Chehab };
1669a0bf528SMauro Carvalho Chehab 
1679a0bf528SMauro Carvalho Chehab enum DRXQamLockRange_t {
1689a0bf528SMauro Carvalho Chehab 	DRX_QAM_LOCKRANGE_NORMAL,
1699a0bf528SMauro Carvalho Chehab 	DRX_QAM_LOCKRANGE_EXTENDED
1709a0bf528SMauro Carvalho Chehab };
1719a0bf528SMauro Carvalho Chehab 
1729a0bf528SMauro Carvalho Chehab struct DRXKCfgDvbtEchoThres_t {
1739a0bf528SMauro Carvalho Chehab 	u16             threshold;
1749a0bf528SMauro Carvalho Chehab 	enum DRXFftmode_t      fftMode;
1759a0bf528SMauro Carvalho Chehab } ;
1769a0bf528SMauro Carvalho Chehab 
1779a0bf528SMauro Carvalho Chehab struct SCfgAgc {
1789a0bf528SMauro Carvalho Chehab 	enum AGC_CTRL_MODE     ctrlMode;        /* off, user, auto */
1799a0bf528SMauro Carvalho Chehab 	u16            outputLevel;     /* range dependent on AGC */
1809a0bf528SMauro Carvalho Chehab 	u16            minOutputLevel;  /* range dependent on AGC */
1819a0bf528SMauro Carvalho Chehab 	u16            maxOutputLevel;  /* range dependent on AGC */
1829a0bf528SMauro Carvalho Chehab 	u16            speed;           /* range dependent on AGC */
1839a0bf528SMauro Carvalho Chehab 	u16            top;             /* rf-agc take over point */
1849a0bf528SMauro Carvalho Chehab 	u16            cutOffCurrent;   /* rf-agc is accelerated if output current
1859a0bf528SMauro Carvalho Chehab 					   is below cut-off current */
1869a0bf528SMauro Carvalho Chehab 	u16            IngainTgtMax;
1879a0bf528SMauro Carvalho Chehab 	u16            FastClipCtrlDelay;
1889a0bf528SMauro Carvalho Chehab };
1899a0bf528SMauro Carvalho Chehab 
1909a0bf528SMauro Carvalho Chehab struct SCfgPreSaw {
1919a0bf528SMauro Carvalho Chehab 	u16        reference; /* pre SAW reference value, range 0 .. 31 */
1929a0bf528SMauro Carvalho Chehab 	bool          usePreSaw; /* TRUE algorithms must use pre SAW sense */
1939a0bf528SMauro Carvalho Chehab };
1949a0bf528SMauro Carvalho Chehab 
1959a0bf528SMauro Carvalho Chehab struct DRXKOfdmScCmd_t {
1969a0bf528SMauro Carvalho Chehab 	u16 cmd;        /**< Command number */
1979a0bf528SMauro Carvalho Chehab 	u16 subcmd;     /**< Sub-command parameter*/
1989a0bf528SMauro Carvalho Chehab 	u16 param0;     /**< General purpous param */
1999a0bf528SMauro Carvalho Chehab 	u16 param1;     /**< General purpous param */
2009a0bf528SMauro Carvalho Chehab 	u16 param2;     /**< General purpous param */
2019a0bf528SMauro Carvalho Chehab 	u16 param3;     /**< General purpous param */
2029a0bf528SMauro Carvalho Chehab 	u16 param4;     /**< General purpous param */
2039a0bf528SMauro Carvalho Chehab };
2049a0bf528SMauro Carvalho Chehab 
2059a0bf528SMauro Carvalho Chehab struct drxk_state {
2069a0bf528SMauro Carvalho Chehab 	struct dvb_frontend frontend;
2079a0bf528SMauro Carvalho Chehab 	struct dtv_frontend_properties props;
2089a0bf528SMauro Carvalho Chehab 	struct device *dev;
2099a0bf528SMauro Carvalho Chehab 
2109a0bf528SMauro Carvalho Chehab 	struct i2c_adapter *i2c;
2119a0bf528SMauro Carvalho Chehab 	u8     demod_address;
2129a0bf528SMauro Carvalho Chehab 	void  *priv;
2139a0bf528SMauro Carvalho Chehab 
2149a0bf528SMauro Carvalho Chehab 	struct mutex mutex;
2159a0bf528SMauro Carvalho Chehab 
2169a0bf528SMauro Carvalho Chehab 	u32    m_Instance;           /**< Channel 1,2,3 or 4 */
2179a0bf528SMauro Carvalho Chehab 
2189a0bf528SMauro Carvalho Chehab 	int    m_ChunkSize;
2199a0bf528SMauro Carvalho Chehab 	u8 Chunk[256];
2209a0bf528SMauro Carvalho Chehab 
2219a0bf528SMauro Carvalho Chehab 	bool   m_hasLNA;
2229a0bf528SMauro Carvalho Chehab 	bool   m_hasDVBT;
2239a0bf528SMauro Carvalho Chehab 	bool   m_hasDVBC;
2249a0bf528SMauro Carvalho Chehab 	bool   m_hasAudio;
2259a0bf528SMauro Carvalho Chehab 	bool   m_hasATV;
2269a0bf528SMauro Carvalho Chehab 	bool   m_hasOOB;
2279a0bf528SMauro Carvalho Chehab 	bool   m_hasSAWSW;         /**< TRUE if mat_tx is available */
2289a0bf528SMauro Carvalho Chehab 	bool   m_hasGPIO1;         /**< TRUE if mat_rx is available */
2299a0bf528SMauro Carvalho Chehab 	bool   m_hasGPIO2;         /**< TRUE if GPIO is available */
2309a0bf528SMauro Carvalho Chehab 	bool   m_hasIRQN;          /**< TRUE if IRQN is available */
2319a0bf528SMauro Carvalho Chehab 	u16    m_oscClockFreq;
2329a0bf528SMauro Carvalho Chehab 	u16    m_HICfgTimingDiv;
2339a0bf528SMauro Carvalho Chehab 	u16    m_HICfgBridgeDelay;
2349a0bf528SMauro Carvalho Chehab 	u16    m_HICfgWakeUpKey;
2359a0bf528SMauro Carvalho Chehab 	u16    m_HICfgTimeout;
2369a0bf528SMauro Carvalho Chehab 	u16    m_HICfgCtrl;
2379a0bf528SMauro Carvalho Chehab 	s32    m_sysClockFreq;      /**< system clock frequency in kHz */
2389a0bf528SMauro Carvalho Chehab 
2399a0bf528SMauro Carvalho Chehab 	enum EDrxkState    m_DrxkState;      /**< State of Drxk (init,stopped,started) */
2409a0bf528SMauro Carvalho Chehab 	enum OperationMode m_OperationMode;  /**< digital standards */
2419a0bf528SMauro Carvalho Chehab 	struct SCfgAgc     m_vsbRfAgcCfg;    /**< settings for VSB RF-AGC */
2429a0bf528SMauro Carvalho Chehab 	struct SCfgAgc     m_vsbIfAgcCfg;    /**< settings for VSB IF-AGC */
2439a0bf528SMauro Carvalho Chehab 	u16                m_vsbPgaCfg;      /**< settings for VSB PGA */
2449a0bf528SMauro Carvalho Chehab 	struct SCfgPreSaw  m_vsbPreSawCfg;   /**< settings for pre SAW sense */
2459a0bf528SMauro Carvalho Chehab 	s32    m_Quality83percent;  /**< MER level (*0.1 dB) for 83% quality indication */
2469a0bf528SMauro Carvalho Chehab 	s32    m_Quality93percent;  /**< MER level (*0.1 dB) for 93% quality indication */
2479a0bf528SMauro Carvalho Chehab 	bool   m_smartAntInverted;
2489a0bf528SMauro Carvalho Chehab 	bool   m_bDebugEnableBridge;
2499a0bf528SMauro Carvalho Chehab 	bool   m_bPDownOpenBridge;  /**< only open DRXK bridge before power-down once it has been accessed */
2509a0bf528SMauro Carvalho Chehab 	bool   m_bPowerDown;        /**< Power down when not used */
2519a0bf528SMauro Carvalho Chehab 
2529a0bf528SMauro Carvalho Chehab 	u32    m_IqmFsRateOfs;      /**< frequency shift as written to DRXK register (28bit fixpoint) */
2539a0bf528SMauro Carvalho Chehab 
2549a0bf528SMauro Carvalho Chehab 	bool   m_enableMPEGOutput;  /**< If TRUE, enable MPEG output */
2559a0bf528SMauro Carvalho Chehab 	bool   m_insertRSByte;      /**< If TRUE, insert RS byte */
2569a0bf528SMauro Carvalho Chehab 	bool   m_enableParallel;    /**< If TRUE, parallel out otherwise serial */
2579a0bf528SMauro Carvalho Chehab 	bool   m_invertDATA;        /**< If TRUE, invert DATA signals */
2589a0bf528SMauro Carvalho Chehab 	bool   m_invertERR;         /**< If TRUE, invert ERR signal */
2599a0bf528SMauro Carvalho Chehab 	bool   m_invertSTR;         /**< If TRUE, invert STR signals */
2609a0bf528SMauro Carvalho Chehab 	bool   m_invertVAL;         /**< If TRUE, invert VAL signals */
2619a0bf528SMauro Carvalho Chehab 	bool   m_invertCLK;         /**< If TRUE, invert CLK signals */
2629a0bf528SMauro Carvalho Chehab 	bool   m_DVBCStaticCLK;
2639a0bf528SMauro Carvalho Chehab 	bool   m_DVBTStaticCLK;     /**< If TRUE, static MPEG clockrate will
2649a0bf528SMauro Carvalho Chehab 					 be used, otherwise clockrate will
2659a0bf528SMauro Carvalho Chehab 					 adapt to the bitrate of the TS */
2669a0bf528SMauro Carvalho Chehab 	u32    m_DVBTBitrate;
2679a0bf528SMauro Carvalho Chehab 	u32    m_DVBCBitrate;
2689a0bf528SMauro Carvalho Chehab 
2699a0bf528SMauro Carvalho Chehab 	u8     m_TSDataStrength;
2709a0bf528SMauro Carvalho Chehab 	u8     m_TSClockkStrength;
2719a0bf528SMauro Carvalho Chehab 
2729a0bf528SMauro Carvalho Chehab 	bool   m_itut_annex_c;      /* If true, uses ITU-T DVB-C Annex C, instead of Annex A */
2739a0bf528SMauro Carvalho Chehab 
2749a0bf528SMauro Carvalho Chehab 	enum DRXMPEGStrWidth_t  m_widthSTR;    /**< MPEG start width */
2759a0bf528SMauro Carvalho Chehab 	u32    m_mpegTsStaticBitrate;          /**< Maximum bitrate in b/s in case
2769a0bf528SMauro Carvalho Chehab 						    static clockrate is selected */
2779a0bf528SMauro Carvalho Chehab 
2789a0bf528SMauro Carvalho Chehab 	/* LARGE_INTEGER   m_StartTime; */     /**< Contains the time of the last demod start */
2799a0bf528SMauro Carvalho Chehab 	s32    m_MpegLockTimeOut;      /**< WaitForLockStatus Timeout (counts from start time) */
2809a0bf528SMauro Carvalho Chehab 	s32    m_DemodLockTimeOut;     /**< WaitForLockStatus Timeout (counts from start time) */
2819a0bf528SMauro Carvalho Chehab 
2829a0bf528SMauro Carvalho Chehab 	bool   m_disableTEIhandling;
2839a0bf528SMauro Carvalho Chehab 
2849a0bf528SMauro Carvalho Chehab 	bool   m_RfAgcPol;
2859a0bf528SMauro Carvalho Chehab 	bool   m_IfAgcPol;
2869a0bf528SMauro Carvalho Chehab 
2879a0bf528SMauro Carvalho Chehab 	struct SCfgAgc    m_atvRfAgcCfg;  /**< settings for ATV RF-AGC */
2889a0bf528SMauro Carvalho Chehab 	struct SCfgAgc    m_atvIfAgcCfg;  /**< settings for ATV IF-AGC */
2899a0bf528SMauro Carvalho Chehab 	struct SCfgPreSaw m_atvPreSawCfg; /**< settings for ATV pre SAW sense */
2909a0bf528SMauro Carvalho Chehab 	bool              m_phaseCorrectionBypass;
2919a0bf528SMauro Carvalho Chehab 	s16               m_atvTopVidPeak;
2929a0bf528SMauro Carvalho Chehab 	u16               m_atvTopNoiseTh;
2939a0bf528SMauro Carvalho Chehab 	enum EDrxkSifAttenuation m_sifAttenuation;
2949a0bf528SMauro Carvalho Chehab 	bool              m_enableCVBSOutput;
2959a0bf528SMauro Carvalho Chehab 	bool              m_enableSIFOutput;
2969a0bf528SMauro Carvalho Chehab 	bool              m_bMirrorFreqSpect;
2979a0bf528SMauro Carvalho Chehab 	enum EDrxkConstellation  m_Constellation; /**< Constellation type of the channel */
2989a0bf528SMauro Carvalho Chehab 	u32               m_CurrSymbolRate;       /**< Current QAM symbol rate */
2999a0bf528SMauro Carvalho Chehab 	struct SCfgAgc    m_qamRfAgcCfg;          /**< settings for QAM RF-AGC */
3009a0bf528SMauro Carvalho Chehab 	struct SCfgAgc    m_qamIfAgcCfg;          /**< settings for QAM IF-AGC */
3019a0bf528SMauro Carvalho Chehab 	u16               m_qamPgaCfg;            /**< settings for QAM PGA */
3029a0bf528SMauro Carvalho Chehab 	struct SCfgPreSaw m_qamPreSawCfg;         /**< settings for QAM pre SAW sense */
3039a0bf528SMauro Carvalho Chehab 	enum EDrxkInterleaveMode m_qamInterleaveMode; /**< QAM Interleave mode */
3049a0bf528SMauro Carvalho Chehab 	u16               m_fecRsPlen;
3059a0bf528SMauro Carvalho Chehab 	u16               m_fecRsPrescale;
3069a0bf528SMauro Carvalho Chehab 
3079a0bf528SMauro Carvalho Chehab 	enum DRXKCfgDvbtSqiSpeed m_sqiSpeed;
3089a0bf528SMauro Carvalho Chehab 
3099a0bf528SMauro Carvalho Chehab 	u16               m_GPIO;
3109a0bf528SMauro Carvalho Chehab 	u16               m_GPIOCfg;
3119a0bf528SMauro Carvalho Chehab 
3129a0bf528SMauro Carvalho Chehab 	struct SCfgAgc    m_dvbtRfAgcCfg;     /**< settings for QAM RF-AGC */
3139a0bf528SMauro Carvalho Chehab 	struct SCfgAgc    m_dvbtIfAgcCfg;     /**< settings for QAM IF-AGC */
3149a0bf528SMauro Carvalho Chehab 	struct SCfgPreSaw m_dvbtPreSawCfg;    /**< settings for QAM pre SAW sense */
3159a0bf528SMauro Carvalho Chehab 
3169a0bf528SMauro Carvalho Chehab 	u16               m_agcFastClipCtrlDelay;
3179a0bf528SMauro Carvalho Chehab 	bool              m_adcCompPassed;
3189a0bf528SMauro Carvalho Chehab 	u16               m_adcCompCoef[64];
3199a0bf528SMauro Carvalho Chehab 	u16               m_adcState;
3209a0bf528SMauro Carvalho Chehab 
3219a0bf528SMauro Carvalho Chehab 	u8               *m_microcode;
3229a0bf528SMauro Carvalho Chehab 	int               m_microcode_length;
3239a0bf528SMauro Carvalho Chehab 	bool              m_DRXK_A1_PATCH_CODE;
3249a0bf528SMauro Carvalho Chehab 	bool              m_DRXK_A1_ROM_CODE;
3259a0bf528SMauro Carvalho Chehab 	bool              m_DRXK_A2_ROM_CODE;
3269a0bf528SMauro Carvalho Chehab 	bool              m_DRXK_A3_ROM_CODE;
3279a0bf528SMauro Carvalho Chehab 	bool              m_DRXK_A2_PATCH_CODE;
3289a0bf528SMauro Carvalho Chehab 	bool              m_DRXK_A3_PATCH_CODE;
3299a0bf528SMauro Carvalho Chehab 
3309a0bf528SMauro Carvalho Chehab 	bool              m_rfmirror;
3319a0bf528SMauro Carvalho Chehab 	u8                m_deviceSpin;
3329a0bf528SMauro Carvalho Chehab 	u32               m_iqmRcRate;
3339a0bf528SMauro Carvalho Chehab 
3349a0bf528SMauro Carvalho Chehab 	enum DRXPowerMode m_currentPowerMode;
3359a0bf528SMauro Carvalho Chehab 
3369a0bf528SMauro Carvalho Chehab 	/* when true, avoids other devices to use the I2C bus */
3379a0bf528SMauro Carvalho Chehab 	bool		  drxk_i2c_exclusive_lock;
3389a0bf528SMauro Carvalho Chehab 
3399a0bf528SMauro Carvalho Chehab 	/*
3409a0bf528SMauro Carvalho Chehab 	 * Configurable parameters at the driver. They stores the values found
3419a0bf528SMauro Carvalho Chehab 	 * at struct drxk_config.
3429a0bf528SMauro Carvalho Chehab 	 */
3439a0bf528SMauro Carvalho Chehab 
3449a0bf528SMauro Carvalho Chehab 	u16	UIO_mask;	/* Bits used by UIO */
3459a0bf528SMauro Carvalho Chehab 
3469a0bf528SMauro Carvalho Chehab 	bool	enable_merr_cfg;
3479a0bf528SMauro Carvalho Chehab 	bool	single_master;
3489a0bf528SMauro Carvalho Chehab 	bool	no_i2c_bridge;
3499a0bf528SMauro Carvalho Chehab 	bool	antenna_dvbt;
3509a0bf528SMauro Carvalho Chehab 	u16	antenna_gpio;
3519a0bf528SMauro Carvalho Chehab 
3529a0bf528SMauro Carvalho Chehab 	/* Firmware */
3539a0bf528SMauro Carvalho Chehab 	const char *microcode_name;
3549a0bf528SMauro Carvalho Chehab 	struct completion fw_wait_load;
3559a0bf528SMauro Carvalho Chehab 	const struct firmware *fw;
3569a0bf528SMauro Carvalho Chehab 	int qam_demod_parameter_count;
3579a0bf528SMauro Carvalho Chehab };
3589a0bf528SMauro Carvalho Chehab 
3599a0bf528SMauro Carvalho Chehab #define NEVER_LOCK 0
3609a0bf528SMauro Carvalho Chehab #define NOT_LOCKED 1
3619a0bf528SMauro Carvalho Chehab #define DEMOD_LOCK 2
3629a0bf528SMauro Carvalho Chehab #define FEC_LOCK   3
3639a0bf528SMauro Carvalho Chehab #define MPEG_LOCK  4
3649a0bf528SMauro Carvalho Chehab 
365