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 
49cd7a67a4SMauro Carvalho Chehab enum operation_mode {
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 
57cd7a67a4SMauro Carvalho Chehab enum drx_power_mode {
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 
8057b8b003SMauro Carvalho Chehab /* 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 
8557b8b003SMauro Carvalho Chehab /* 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 
9057b8b003SMauro Carvalho Chehab /* 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 
96d5687ab5SMauro Carvalho Chehab enum agc_ctrl_mode {
97d5687ab5SMauro Carvalho Chehab 	DRXK_AGC_CTRL_AUTO = 0,
98d5687ab5SMauro Carvalho Chehab 	DRXK_AGC_CTRL_USER,
99d5687ab5SMauro Carvalho Chehab 	DRXK_AGC_CTRL_OFF
100d5687ab5SMauro Carvalho Chehab };
101d5687ab5SMauro Carvalho Chehab 
102cd7a67a4SMauro Carvalho Chehab enum e_drxk_state {
1039a0bf528SMauro Carvalho Chehab 	DRXK_UNINITIALIZED = 0,
1049a0bf528SMauro Carvalho Chehab 	DRXK_STOPPED,
1059a0bf528SMauro Carvalho Chehab 	DRXK_DTV_STARTED,
1069a0bf528SMauro Carvalho Chehab 	DRXK_ATV_STARTED,
1079a0bf528SMauro Carvalho Chehab 	DRXK_POWERED_DOWN,
1089a0bf528SMauro Carvalho Chehab 	DRXK_NO_DEV			/* If drxk init failed */
1099a0bf528SMauro Carvalho Chehab };
1109a0bf528SMauro Carvalho Chehab 
111cd7a67a4SMauro Carvalho Chehab enum e_drxk_coef_array_index {
1129a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_MN = 0,
1139a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_FM    ,
1149a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_L     ,
1159a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_LP    ,
1169a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_BG    ,
1179a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_DK    ,
1189a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_I     ,
1199a0bf528SMauro Carvalho Chehab 	DRXK_COEF_IDX_MAX
1209a0bf528SMauro Carvalho Chehab };
121cd7a67a4SMauro Carvalho Chehab enum e_drxk_sif_attenuation {
1229a0bf528SMauro Carvalho Chehab 	DRXK_SIF_ATTENUATION_0DB,
1239a0bf528SMauro Carvalho Chehab 	DRXK_SIF_ATTENUATION_3DB,
1249a0bf528SMauro Carvalho Chehab 	DRXK_SIF_ATTENUATION_6DB,
1259a0bf528SMauro Carvalho Chehab 	DRXK_SIF_ATTENUATION_9DB
1269a0bf528SMauro Carvalho Chehab };
127cd7a67a4SMauro Carvalho Chehab enum e_drxk_constellation {
1289a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_BPSK = 0,
1299a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QPSK,
1309a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_PSK8,
1319a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM16,
1329a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM32,
1339a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM64,
1349a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM128,
1359a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM256,
1369a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM512,
1379a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_QAM1024,
1389a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_UNKNOWN = DRX_UNKNOWN,
1399a0bf528SMauro Carvalho Chehab 	DRX_CONSTELLATION_AUTO    = DRX_AUTO
1409a0bf528SMauro Carvalho Chehab };
141cd7a67a4SMauro Carvalho Chehab enum e_drxk_interleave_mode {
1429a0bf528SMauro Carvalho Chehab 	DRXK_QAM_I12_J17    = 16,
1439a0bf528SMauro Carvalho Chehab 	DRXK_QAM_I_UNKNOWN  = DRX_UNKNOWN
1449a0bf528SMauro Carvalho Chehab };
1459a0bf528SMauro Carvalho Chehab enum {
1469a0bf528SMauro Carvalho Chehab 	DRXK_SPIN_A1 = 0,
1479a0bf528SMauro Carvalho Chehab 	DRXK_SPIN_A2,
1489a0bf528SMauro Carvalho Chehab 	DRXK_SPIN_A3,
1499a0bf528SMauro Carvalho Chehab 	DRXK_SPIN_UNKNOWN
1509a0bf528SMauro Carvalho Chehab };
1519a0bf528SMauro Carvalho Chehab 
152cd7a67a4SMauro Carvalho Chehab enum drxk_cfg_dvbt_sqi_speed {
1539a0bf528SMauro Carvalho Chehab 	DRXK_DVBT_SQI_SPEED_FAST = 0,
1549a0bf528SMauro Carvalho Chehab 	DRXK_DVBT_SQI_SPEED_MEDIUM,
1559a0bf528SMauro Carvalho Chehab 	DRXK_DVBT_SQI_SPEED_SLOW,
1569a0bf528SMauro Carvalho Chehab 	DRXK_DVBT_SQI_SPEED_UNKNOWN = DRX_UNKNOWN
1579a0bf528SMauro Carvalho Chehab } ;
1589a0bf528SMauro Carvalho Chehab 
159cd7a67a4SMauro Carvalho Chehab enum drx_fftmode_t {
1609a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_2K = 0,
1619a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_4K,
1629a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_8K,
1639a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_UNKNOWN = DRX_UNKNOWN,
1649a0bf528SMauro Carvalho Chehab 	DRX_FFTMODE_AUTO    = DRX_AUTO
1659a0bf528SMauro Carvalho Chehab };
1669a0bf528SMauro Carvalho Chehab 
167cd7a67a4SMauro Carvalho Chehab enum drxmpeg_str_width_t {
1689a0bf528SMauro Carvalho Chehab 	DRX_MPEG_STR_WIDTH_1,
1699a0bf528SMauro Carvalho Chehab 	DRX_MPEG_STR_WIDTH_8
1709a0bf528SMauro Carvalho Chehab };
1719a0bf528SMauro Carvalho Chehab 
172cd7a67a4SMauro Carvalho Chehab enum drx_qam_lock_range_t {
1739a0bf528SMauro Carvalho Chehab 	DRX_QAM_LOCKRANGE_NORMAL,
1749a0bf528SMauro Carvalho Chehab 	DRX_QAM_LOCKRANGE_EXTENDED
1759a0bf528SMauro Carvalho Chehab };
1769a0bf528SMauro Carvalho Chehab 
177cd7a67a4SMauro Carvalho Chehab struct drxk_cfg_dvbt_echo_thres_t {
1789a0bf528SMauro Carvalho Chehab 	u16             threshold;
179cd7a67a4SMauro Carvalho Chehab 	enum drx_fftmode_t      fft_mode;
1809a0bf528SMauro Carvalho Chehab } ;
1819a0bf528SMauro Carvalho Chehab 
182cd7a67a4SMauro Carvalho Chehab struct s_cfg_agc {
183cd7a67a4SMauro Carvalho Chehab 	enum agc_ctrl_mode     ctrl_mode;        /* off, user, auto */
184cd7a67a4SMauro Carvalho Chehab 	u16            output_level;     /* range dependent on AGC */
185cd7a67a4SMauro Carvalho Chehab 	u16            min_output_level;  /* range dependent on AGC */
186cd7a67a4SMauro Carvalho Chehab 	u16            max_output_level;  /* range dependent on AGC */
1879a0bf528SMauro Carvalho Chehab 	u16            speed;           /* range dependent on AGC */
1889a0bf528SMauro Carvalho Chehab 	u16            top;             /* rf-agc take over point */
189cd7a67a4SMauro Carvalho Chehab 	u16            cut_off_current;   /* rf-agc is accelerated if output current
1909a0bf528SMauro Carvalho Chehab 					   is below cut-off current */
191cd7a67a4SMauro Carvalho Chehab 	u16            ingain_tgt_max;
192cd7a67a4SMauro Carvalho Chehab 	u16            fast_clip_ctrl_delay;
1939a0bf528SMauro Carvalho Chehab };
1949a0bf528SMauro Carvalho Chehab 
195cd7a67a4SMauro Carvalho Chehab struct s_cfg_pre_saw {
1969a0bf528SMauro Carvalho Chehab 	u16        reference; /* pre SAW reference value, range 0 .. 31 */
197cd7a67a4SMauro Carvalho Chehab 	bool          use_pre_saw; /* TRUE algorithms must use pre SAW sense */
1989a0bf528SMauro Carvalho Chehab };
1999a0bf528SMauro Carvalho Chehab 
200cd7a67a4SMauro Carvalho Chehab struct drxk_ofdm_sc_cmd_t {
20157b8b003SMauro Carvalho Chehab 	u16 cmd;        /* Command number */
20257b8b003SMauro Carvalho Chehab 	u16 subcmd;     /* Sub-command parameter*/
20357b8b003SMauro Carvalho Chehab 	u16 param0;     /* General purpous param */
20457b8b003SMauro Carvalho Chehab 	u16 param1;     /* General purpous param */
20557b8b003SMauro Carvalho Chehab 	u16 param2;     /* General purpous param */
20657b8b003SMauro Carvalho Chehab 	u16 param3;     /* General purpous param */
20757b8b003SMauro Carvalho Chehab 	u16 param4;     /* General purpous param */
2089a0bf528SMauro Carvalho Chehab };
2099a0bf528SMauro Carvalho Chehab 
2109a0bf528SMauro Carvalho Chehab struct drxk_state {
2119a0bf528SMauro Carvalho Chehab 	struct dvb_frontend frontend;
2129a0bf528SMauro Carvalho Chehab 	struct dtv_frontend_properties props;
2139a0bf528SMauro Carvalho Chehab 	struct device *dev;
2149a0bf528SMauro Carvalho Chehab 
2159a0bf528SMauro Carvalho Chehab 	struct i2c_adapter *i2c;
2169a0bf528SMauro Carvalho Chehab 	u8     demod_address;
2179a0bf528SMauro Carvalho Chehab 	void  *priv;
2189a0bf528SMauro Carvalho Chehab 
2199a0bf528SMauro Carvalho Chehab 	struct mutex mutex;
2209a0bf528SMauro Carvalho Chehab 
22157b8b003SMauro Carvalho Chehab 	u32    m_instance;           /* Channel 1,2,3 or 4 */
2229a0bf528SMauro Carvalho Chehab 
223cd7a67a4SMauro Carvalho Chehab 	int    m_chunk_size;
224cd7a67a4SMauro Carvalho Chehab 	u8 chunk[256];
2259a0bf528SMauro Carvalho Chehab 
226cd7a67a4SMauro Carvalho Chehab 	bool   m_has_lna;
227cd7a67a4SMauro Carvalho Chehab 	bool   m_has_dvbt;
228cd7a67a4SMauro Carvalho Chehab 	bool   m_has_dvbc;
229cd7a67a4SMauro Carvalho Chehab 	bool   m_has_audio;
230cd7a67a4SMauro Carvalho Chehab 	bool   m_has_atv;
231cd7a67a4SMauro Carvalho Chehab 	bool   m_has_oob;
232cd7a67a4SMauro Carvalho Chehab 	bool   m_has_sawsw;         /* TRUE if mat_tx is available */
233cd7a67a4SMauro Carvalho Chehab 	bool   m_has_gpio1;         /* TRUE if mat_rx is available */
234cd7a67a4SMauro Carvalho Chehab 	bool   m_has_gpio2;         /* TRUE if GPIO is available */
235cd7a67a4SMauro Carvalho Chehab 	bool   m_has_irqn;          /* TRUE if IRQN is available */
236cd7a67a4SMauro Carvalho Chehab 	u16    m_osc_clock_freq;
237cd7a67a4SMauro Carvalho Chehab 	u16    m_hi_cfg_timing_div;
238cd7a67a4SMauro Carvalho Chehab 	u16    m_hi_cfg_bridge_delay;
239cd7a67a4SMauro Carvalho Chehab 	u16    m_hi_cfg_wake_up_key;
240cd7a67a4SMauro Carvalho Chehab 	u16    m_hi_cfg_timeout;
241cd7a67a4SMauro Carvalho Chehab 	u16    m_hi_cfg_ctrl;
24257b8b003SMauro Carvalho Chehab 	s32    m_sys_clock_freq;      /* system clock frequency in kHz */
2439a0bf528SMauro Carvalho Chehab 
24457b8b003SMauro Carvalho Chehab 	enum e_drxk_state    m_drxk_state;      /* State of Drxk (init,stopped,started) */
24557b8b003SMauro Carvalho Chehab 	enum operation_mode m_operation_mode;  /* digital standards */
24657b8b003SMauro Carvalho Chehab 	struct s_cfg_agc     m_vsb_rf_agc_cfg;    /* settings for VSB RF-AGC */
24757b8b003SMauro Carvalho Chehab 	struct s_cfg_agc     m_vsb_if_agc_cfg;    /* settings for VSB IF-AGC */
24857b8b003SMauro Carvalho Chehab 	u16                m_vsb_pga_cfg;      /* settings for VSB PGA */
24957b8b003SMauro Carvalho Chehab 	struct s_cfg_pre_saw  m_vsb_pre_saw_cfg;   /* settings for pre SAW sense */
25057b8b003SMauro Carvalho Chehab 	s32    m_Quality83percent;  /* MER level (*0.1 dB) for 83% quality indication */
25157b8b003SMauro Carvalho Chehab 	s32    m_Quality93percent;  /* MER level (*0.1 dB) for 93% quality indication */
252cd7a67a4SMauro Carvalho Chehab 	bool   m_smart_ant_inverted;
253cd7a67a4SMauro Carvalho Chehab 	bool   m_b_debug_enable_bridge;
25457b8b003SMauro Carvalho Chehab 	bool   m_b_p_down_open_bridge;  /* only open DRXK bridge before power-down once it has been accessed */
25557b8b003SMauro Carvalho Chehab 	bool   m_b_power_down;        /* Power down when not used */
2569a0bf528SMauro Carvalho Chehab 
25757b8b003SMauro Carvalho Chehab 	u32    m_iqm_fs_rate_ofs;      /* frequency shift as written to DRXK register (28bit fixpoint) */
2589a0bf528SMauro Carvalho Chehab 
25957b8b003SMauro Carvalho Chehab 	bool   m_enable_mpeg_output;  /* If TRUE, enable MPEG output */
26057b8b003SMauro Carvalho Chehab 	bool   m_insert_rs_byte;      /* If TRUE, insert RS byte */
26157b8b003SMauro Carvalho Chehab 	bool   m_enable_parallel;    /* If TRUE, parallel out otherwise serial */
26257b8b003SMauro Carvalho Chehab 	bool   m_invert_data;        /* If TRUE, invert DATA signals */
26357b8b003SMauro Carvalho Chehab 	bool   m_invert_err;         /* If TRUE, invert ERR signal */
26457b8b003SMauro Carvalho Chehab 	bool   m_invert_str;         /* If TRUE, invert STR signals */
26557b8b003SMauro Carvalho Chehab 	bool   m_invert_val;         /* If TRUE, invert VAL signals */
26657b8b003SMauro Carvalho Chehab 	bool   m_invert_clk;         /* If TRUE, invert CLK signals */
267cd7a67a4SMauro Carvalho Chehab 	bool   m_dvbc_static_clk;
26857b8b003SMauro Carvalho Chehab 	bool   m_dvbt_static_clk;     /* If TRUE, static MPEG clockrate will
2699a0bf528SMauro Carvalho Chehab 					 be used, otherwise clockrate will
2709a0bf528SMauro Carvalho Chehab 					 adapt to the bitrate of the TS */
271cd7a67a4SMauro Carvalho Chehab 	u32    m_dvbt_bitrate;
272cd7a67a4SMauro Carvalho Chehab 	u32    m_dvbc_bitrate;
2739a0bf528SMauro Carvalho Chehab 
274cd7a67a4SMauro Carvalho Chehab 	u8     m_ts_data_strength;
275cd7a67a4SMauro Carvalho Chehab 	u8     m_ts_clockk_strength;
2769a0bf528SMauro Carvalho Chehab 
2779a0bf528SMauro Carvalho Chehab 	bool   m_itut_annex_c;      /* If true, uses ITU-T DVB-C Annex C, instead of Annex A */
2789a0bf528SMauro Carvalho Chehab 
27957b8b003SMauro Carvalho Chehab 	enum drxmpeg_str_width_t  m_width_str;    /* MPEG start width */
28057b8b003SMauro Carvalho Chehab 	u32    m_mpeg_ts_static_bitrate;          /* Maximum bitrate in b/s in case
2819a0bf528SMauro Carvalho Chehab 						    static clockrate is selected */
2829a0bf528SMauro Carvalho Chehab 
28357b8b003SMauro Carvalho Chehab 	/* LARGE_INTEGER   m_startTime; */     /* Contains the time of the last demod start */
28457b8b003SMauro Carvalho Chehab 	s32    m_mpeg_lock_time_out;      /* WaitForLockStatus Timeout (counts from start time) */
28557b8b003SMauro Carvalho Chehab 	s32    m_demod_lock_time_out;     /* WaitForLockStatus Timeout (counts from start time) */
2869a0bf528SMauro Carvalho Chehab 
287cd7a67a4SMauro Carvalho Chehab 	bool   m_disable_te_ihandling;
2889a0bf528SMauro Carvalho Chehab 
289cd7a67a4SMauro Carvalho Chehab 	bool   m_rf_agc_pol;
290cd7a67a4SMauro Carvalho Chehab 	bool   m_if_agc_pol;
2919a0bf528SMauro Carvalho Chehab 
29257b8b003SMauro Carvalho Chehab 	struct s_cfg_agc    m_atv_rf_agc_cfg;  /* settings for ATV RF-AGC */
29357b8b003SMauro Carvalho Chehab 	struct s_cfg_agc    m_atv_if_agc_cfg;  /* settings for ATV IF-AGC */
29457b8b003SMauro Carvalho Chehab 	struct s_cfg_pre_saw m_atv_pre_saw_cfg; /* settings for ATV pre SAW sense */
295cd7a67a4SMauro Carvalho Chehab 	bool              m_phase_correction_bypass;
296cd7a67a4SMauro Carvalho Chehab 	s16               m_atv_top_vid_peak;
297cd7a67a4SMauro Carvalho Chehab 	u16               m_atv_top_noise_th;
298cd7a67a4SMauro Carvalho Chehab 	enum e_drxk_sif_attenuation m_sif_attenuation;
299cd7a67a4SMauro Carvalho Chehab 	bool              m_enable_cvbs_output;
300cd7a67a4SMauro Carvalho Chehab 	bool              m_enable_sif_output;
301cd7a67a4SMauro Carvalho Chehab 	bool              m_b_mirror_freq_spect;
30257b8b003SMauro Carvalho Chehab 	enum e_drxk_constellation  m_constellation; /* constellation type of the channel */
30357b8b003SMauro Carvalho Chehab 	u32               m_curr_symbol_rate;       /* Current QAM symbol rate */
30457b8b003SMauro Carvalho Chehab 	struct s_cfg_agc    m_qam_rf_agc_cfg;          /* settings for QAM RF-AGC */
30557b8b003SMauro Carvalho Chehab 	struct s_cfg_agc    m_qam_if_agc_cfg;          /* settings for QAM IF-AGC */
30657b8b003SMauro Carvalho Chehab 	u16               m_qam_pga_cfg;            /* settings for QAM PGA */
30757b8b003SMauro Carvalho Chehab 	struct s_cfg_pre_saw m_qam_pre_saw_cfg;         /* settings for QAM pre SAW sense */
30857b8b003SMauro Carvalho Chehab 	enum e_drxk_interleave_mode m_qam_interleave_mode; /* QAM Interleave mode */
309cd7a67a4SMauro Carvalho Chehab 	u16               m_fec_rs_plen;
310cd7a67a4SMauro Carvalho Chehab 	u16               m_fec_rs_prescale;
3119a0bf528SMauro Carvalho Chehab 
312cd7a67a4SMauro Carvalho Chehab 	enum drxk_cfg_dvbt_sqi_speed m_sqi_speed;
3139a0bf528SMauro Carvalho Chehab 
314cd7a67a4SMauro Carvalho Chehab 	u16               m_gpio;
315cd7a67a4SMauro Carvalho Chehab 	u16               m_gpio_cfg;
3169a0bf528SMauro Carvalho Chehab 
31757b8b003SMauro Carvalho Chehab 	struct s_cfg_agc    m_dvbt_rf_agc_cfg;     /* settings for QAM RF-AGC */
31857b8b003SMauro Carvalho Chehab 	struct s_cfg_agc    m_dvbt_if_agc_cfg;     /* settings for QAM IF-AGC */
31957b8b003SMauro Carvalho Chehab 	struct s_cfg_pre_saw m_dvbt_pre_saw_cfg;    /* settings for QAM pre SAW sense */
3209a0bf528SMauro Carvalho Chehab 
321cd7a67a4SMauro Carvalho Chehab 	u16               m_agcfast_clip_ctrl_delay;
322cd7a67a4SMauro Carvalho Chehab 	bool              m_adc_comp_passed;
3239a0bf528SMauro Carvalho Chehab 	u16               m_adcCompCoef[64];
324cd7a67a4SMauro Carvalho Chehab 	u16               m_adc_state;
3259a0bf528SMauro Carvalho Chehab 
3269a0bf528SMauro Carvalho Chehab 	u8               *m_microcode;
3279a0bf528SMauro Carvalho Chehab 	int               m_microcode_length;
328cd7a67a4SMauro Carvalho Chehab 	bool		  m_drxk_a3_rom_code;
329cd7a67a4SMauro Carvalho Chehab 	bool              m_drxk_a3_patch_code;
3309a0bf528SMauro Carvalho Chehab 
3319a0bf528SMauro Carvalho Chehab 	bool              m_rfmirror;
332cd7a67a4SMauro Carvalho Chehab 	u8                m_device_spin;
333cd7a67a4SMauro Carvalho Chehab 	u32               m_iqm_rc_rate;
3349a0bf528SMauro Carvalho Chehab 
335cd7a67a4SMauro Carvalho Chehab 	enum drx_power_mode m_current_power_mode;
3369a0bf528SMauro Carvalho Chehab 
3379a0bf528SMauro Carvalho Chehab 	/* when true, avoids other devices to use the I2C bus */
3389a0bf528SMauro Carvalho Chehab 	bool		  drxk_i2c_exclusive_lock;
3399a0bf528SMauro Carvalho Chehab 
3409a0bf528SMauro Carvalho Chehab 	/*
3419a0bf528SMauro Carvalho Chehab 	 * Configurable parameters at the driver. They stores the values found
3429a0bf528SMauro Carvalho Chehab 	 * at struct drxk_config.
3439a0bf528SMauro Carvalho Chehab 	 */
3449a0bf528SMauro Carvalho Chehab 
345cd7a67a4SMauro Carvalho Chehab 	u16	uio_mask;	/* Bits used by UIO */
3469a0bf528SMauro Carvalho Chehab 
3479a0bf528SMauro Carvalho Chehab 	bool	enable_merr_cfg;
3489a0bf528SMauro Carvalho Chehab 	bool	single_master;
3499a0bf528SMauro Carvalho Chehab 	bool	no_i2c_bridge;
3509a0bf528SMauro Carvalho Chehab 	bool	antenna_dvbt;
3519a0bf528SMauro Carvalho Chehab 	u16	antenna_gpio;
3529a0bf528SMauro Carvalho Chehab 
3538f3741e0SMauro Carvalho Chehab 	fe_status_t fe_status;
3548f3741e0SMauro Carvalho Chehab 
3559a0bf528SMauro Carvalho Chehab 	/* Firmware */
3569a0bf528SMauro Carvalho Chehab 	const char *microcode_name;
3579a0bf528SMauro Carvalho Chehab 	struct completion fw_wait_load;
3589a0bf528SMauro Carvalho Chehab 	const struct firmware *fw;
3599a0bf528SMauro Carvalho Chehab 	int qam_demod_parameter_count;
3609a0bf528SMauro Carvalho Chehab };
3619a0bf528SMauro Carvalho Chehab 
3629a0bf528SMauro Carvalho Chehab #define NEVER_LOCK 0
3639a0bf528SMauro Carvalho Chehab #define NOT_LOCKED 1
3649a0bf528SMauro Carvalho Chehab #define DEMOD_LOCK 2
3659a0bf528SMauro Carvalho Chehab #define FEC_LOCK   3
3669a0bf528SMauro Carvalho Chehab #define MPEG_LOCK  4
3679a0bf528SMauro Carvalho Chehab 
368