blob: a20a19d9aff6d2a5df3718f10d1e6fd7c6a27d30 [file] [log] [blame]
Ralph Metzler43dd07f2011-07-03 13:42:18 -03001#include "drxk_map.h"
2
3#define DRXK_VERSION_MAJOR 0
4#define DRXK_VERSION_MINOR 9
5#define DRXK_VERSION_PATCH 4300
6
7#define HI_I2C_DELAY 42
8#define HI_I2C_BRIDGE_DELAY 350
9#define DRXK_MAX_RETRIES 100
10
11#define DRIVER_4400 1
12
13#define DRXX_JTAGID 0x039210D9
14#define DRXX_J_JTAGID 0x239310D9
15#define DRXX_K_JTAGID 0x039210D9
16
17#define DRX_UNKNOWN 254
18#define DRX_AUTO 255
19
20#define DRX_SCU_READY 0
21#define DRXK_MAX_WAITTIME (200)
22#define SCU_RESULT_OK 0
23#define SCU_RESULT_UNKSTD -2
24#define SCU_RESULT_UNKCMD -1
25
26#ifndef DRXK_OFDM_TR_SHUTDOWN_TIMEOUT
27#define DRXK_OFDM_TR_SHUTDOWN_TIMEOUT (200)
28#endif
29
30#define DRXK_8VSB_MPEG_BIT_RATE 19392658UL /*bps*/
31#define DRXK_DVBT_MPEG_BIT_RATE 32000000UL /*bps*/
32#define DRXK_QAM16_MPEG_BIT_RATE 27000000UL /*bps*/
33#define DRXK_QAM32_MPEG_BIT_RATE 33000000UL /*bps*/
34#define DRXK_QAM64_MPEG_BIT_RATE 40000000UL /*bps*/
35#define DRXK_QAM128_MPEG_BIT_RATE 46000000UL /*bps*/
36#define DRXK_QAM256_MPEG_BIT_RATE 52000000UL /*bps*/
37#define DRXK_MAX_MPEG_BIT_RATE 52000000UL /*bps*/
38
39#define IQM_CF_OUT_ENA_OFDM__M 0x4
40#define IQM_FS_ADJ_SEL_B_QAM 0x1
41#define IQM_FS_ADJ_SEL_B_OFF 0x0
42#define IQM_FS_ADJ_SEL_B_VSB 0x2
43#define IQM_RC_ADJ_SEL_B_OFF 0x0
44#define IQM_RC_ADJ_SEL_B_QAM 0x1
45#define IQM_RC_ADJ_SEL_B_VSB 0x2
46
47enum OperationMode {
48 OM_NONE,
49 OM_QAM_ITU_A,
50 OM_QAM_ITU_B,
51 OM_QAM_ITU_C,
52 OM_DVBT
53};
54
Oliver Endrissebc7de22011-07-03 13:49:44 -030055enum DRXPowerMode {
Ralph Metzler43dd07f2011-07-03 13:42:18 -030056 DRX_POWER_UP = 0,
57 DRX_POWER_MODE_1,
58 DRX_POWER_MODE_2,
59 DRX_POWER_MODE_3,
60 DRX_POWER_MODE_4,
61 DRX_POWER_MODE_5,
62 DRX_POWER_MODE_6,
63 DRX_POWER_MODE_7,
64 DRX_POWER_MODE_8,
65
66 DRX_POWER_MODE_9,
67 DRX_POWER_MODE_10,
68 DRX_POWER_MODE_11,
69 DRX_POWER_MODE_12,
70 DRX_POWER_MODE_13,
71 DRX_POWER_MODE_14,
72 DRX_POWER_MODE_15,
73 DRX_POWER_MODE_16,
74 DRX_POWER_DOWN = 255
Oliver Endrissebc7de22011-07-03 13:49:44 -030075};
Ralph Metzler43dd07f2011-07-03 13:42:18 -030076
77
78/** /brief Intermediate power mode for DRXK, power down OFDM clock domain */
79#ifndef DRXK_POWER_DOWN_OFDM
80#define DRXK_POWER_DOWN_OFDM DRX_POWER_MODE_1
81#endif
82
83/** /brief Intermediate power mode for DRXK, power down core (sysclk) */
84#ifndef DRXK_POWER_DOWN_CORE
85#define DRXK_POWER_DOWN_CORE DRX_POWER_MODE_9
86#endif
87
88/** /brief Intermediate power mode for DRXK, power down pll (only osc runs) */
89#ifndef DRXK_POWER_DOWN_PLL
90#define DRXK_POWER_DOWN_PLL DRX_POWER_MODE_10
91#endif
92
93
94enum AGC_CTRL_MODE { DRXK_AGC_CTRL_AUTO = 0, DRXK_AGC_CTRL_USER, DRXK_AGC_CTRL_OFF };
95enum EDrxkState { DRXK_UNINITIALIZED = 0, DRXK_STOPPED, DRXK_DTV_STARTED, DRXK_ATV_STARTED, DRXK_POWERED_DOWN };
96enum EDrxkCoefArrayIndex {
97 DRXK_COEF_IDX_MN = 0,
98 DRXK_COEF_IDX_FM ,
99 DRXK_COEF_IDX_L ,
100 DRXK_COEF_IDX_LP ,
101 DRXK_COEF_IDX_BG ,
102 DRXK_COEF_IDX_DK ,
103 DRXK_COEF_IDX_I ,
104 DRXK_COEF_IDX_MAX
105};
106enum EDrxkSifAttenuation {
107 DRXK_SIF_ATTENUATION_0DB,
108 DRXK_SIF_ATTENUATION_3DB,
109 DRXK_SIF_ATTENUATION_6DB,
110 DRXK_SIF_ATTENUATION_9DB
111};
112enum EDrxkConstellation {
113 DRX_CONSTELLATION_BPSK = 0,
114 DRX_CONSTELLATION_QPSK,
115 DRX_CONSTELLATION_PSK8,
116 DRX_CONSTELLATION_QAM16,
117 DRX_CONSTELLATION_QAM32,
118 DRX_CONSTELLATION_QAM64,
119 DRX_CONSTELLATION_QAM128,
120 DRX_CONSTELLATION_QAM256,
121 DRX_CONSTELLATION_QAM512,
122 DRX_CONSTELLATION_QAM1024,
123 DRX_CONSTELLATION_UNKNOWN = DRX_UNKNOWN,
124 DRX_CONSTELLATION_AUTO = DRX_AUTO
125};
126enum EDrxkInterleaveMode {
127 DRXK_QAM_I12_J17 = 16,
128 DRXK_QAM_I_UNKNOWN = DRX_UNKNOWN
129};
130enum {
131 DRXK_SPIN_A1 = 0,
132 DRXK_SPIN_A2,
133 DRXK_SPIN_A3,
134 DRXK_SPIN_UNKNOWN
135};
136
137enum DRXKCfgDvbtSqiSpeed {
138 DRXK_DVBT_SQI_SPEED_FAST = 0,
139 DRXK_DVBT_SQI_SPEED_MEDIUM,
140 DRXK_DVBT_SQI_SPEED_SLOW,
141 DRXK_DVBT_SQI_SPEED_UNKNOWN = DRX_UNKNOWN
142} ;
143
144enum DRXFftmode_t {
145 DRX_FFTMODE_2K = 0,
146 DRX_FFTMODE_4K,
147 DRX_FFTMODE_8K,
148 DRX_FFTMODE_UNKNOWN = DRX_UNKNOWN,
149 DRX_FFTMODE_AUTO = DRX_AUTO
150};
151
152enum DRXMPEGStrWidth_t {
153 DRX_MPEG_STR_WIDTH_1,
154 DRX_MPEG_STR_WIDTH_8
155};
156
157enum DRXQamLockRange_t {
158 DRX_QAM_LOCKRANGE_NORMAL,
159 DRX_QAM_LOCKRANGE_EXTENDED
160};
161
162struct DRXKCfgDvbtEchoThres_t {
163 u16 threshold;
164 enum DRXFftmode_t fftMode;
165} ;
166
Oliver Endrissebc7de22011-07-03 13:49:44 -0300167struct SCfgAgc {
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300168 enum AGC_CTRL_MODE ctrlMode; /* off, user, auto */
169 u16 outputLevel; /* range dependent on AGC */
170 u16 minOutputLevel; /* range dependent on AGC */
171 u16 maxOutputLevel; /* range dependent on AGC */
172 u16 speed; /* range dependent on AGC */
173 u16 top; /* rf-agc take over point */
174 u16 cutOffCurrent; /* rf-agc is accelerated if output current
Oliver Endrissebc7de22011-07-03 13:49:44 -0300175 is below cut-off current */
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300176 u16 IngainTgtMax;
177 u16 FastClipCtrlDelay;
178};
179
Oliver Endrissebc7de22011-07-03 13:49:44 -0300180struct SCfgPreSaw {
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300181 u16 reference; /* pre SAW reference value, range 0 .. 31 */
182 bool usePreSaw; /* TRUE algorithms must use pre SAW sense */
183};
184
Oliver Endrissebc7de22011-07-03 13:49:44 -0300185struct DRXKOfdmScCmd_t {
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300186 u16 cmd; /**< Command number */
187 u16 subcmd; /**< Sub-command parameter*/
188 u16 param0; /**< General purpous param */
189 u16 param1; /**< General purpous param */
190 u16 param2; /**< General purpous param */
191 u16 param3; /**< General purpous param */
192 u16 param4; /**< General purpous param */
193};
194
195struct drxk_state {
196 struct dvb_frontend c_frontend;
197 struct dvb_frontend t_frontend;
198 struct dvb_frontend_parameters param;
199 struct device *dev;
200
201 struct i2c_adapter *i2c;
202 u8 demod_address;
203 void *priv;
204
205 struct mutex mutex;
206 struct mutex ctlock;
207
Oliver Endrissebc7de22011-07-03 13:49:44 -0300208 u32 m_Instance; /**< Channel 1,2,3 or 4 */
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300209
Oliver Endrissebc7de22011-07-03 13:49:44 -0300210 int m_ChunkSize;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300211 u8 Chunk[256];
212
Oliver Endrissebc7de22011-07-03 13:49:44 -0300213 bool m_hasLNA;
214 bool m_hasDVBT;
215 bool m_hasDVBC;
216 bool m_hasAudio;
217 bool m_hasATV;
218 bool m_hasOOB;
219 bool m_hasSAWSW; /**< TRUE if mat_tx is available */
220 bool m_hasGPIO1; /**< TRUE if mat_rx is available */
221 bool m_hasGPIO2; /**< TRUE if GPIO is available */
222 bool m_hasIRQN; /**< TRUE if IRQN is available */
223 u16 m_oscClockFreq;
224 u16 m_HICfgTimingDiv;
225 u16 m_HICfgBridgeDelay;
226 u16 m_HICfgWakeUpKey;
227 u16 m_HICfgTimeout;
228 u16 m_HICfgCtrl;
229 s32 m_sysClockFreq; /**< system clock frequency in kHz */
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300230
Oliver Endrissebc7de22011-07-03 13:49:44 -0300231 enum EDrxkState m_DrxkState; /**< State of Drxk (init,stopped,started) */
232 enum OperationMode m_OperationMode; /**< digital standards */
233 struct SCfgAgc m_vsbRfAgcCfg; /**< settings for VSB RF-AGC */
234 struct SCfgAgc m_vsbIfAgcCfg; /**< settings for VSB IF-AGC */
235 u16 m_vsbPgaCfg; /**< settings for VSB PGA */
236 struct SCfgPreSaw m_vsbPreSawCfg; /**< settings for pre SAW sense */
237 s32 m_Quality83percent; /**< MER level (*0.1 dB) for 83% quality indication */
238 s32 m_Quality93percent; /**< MER level (*0.1 dB) for 93% quality indication */
239 bool m_smartAntInverted;
240 bool m_bDebugEnableBridge;
241 bool m_bPDownOpenBridge; /**< only open DRXK bridge before power-down once it has been accessed */
242 bool m_bPowerDown; /**< Power down when not used */
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300243
Oliver Endrissebc7de22011-07-03 13:49:44 -0300244 u32 m_IqmFsRateOfs; /**< frequency shift as written to DRXK register (28bit fixpoint) */
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300245
Oliver Endrissebc7de22011-07-03 13:49:44 -0300246 bool m_enableMPEGOutput; /**< If TRUE, enable MPEG output */
247 bool m_insertRSByte; /**< If TRUE, insert RS byte */
248 bool m_enableParallel; /**< If TRUE, parallel out otherwise serial */
249 bool m_invertDATA; /**< If TRUE, invert DATA signals */
250 bool m_invertERR; /**< If TRUE, invert ERR signal */
251 bool m_invertSTR; /**< If TRUE, invert STR signals */
252 bool m_invertVAL; /**< If TRUE, invert VAL signals */
253 bool m_invertCLK; /**< If TRUE, invert CLK signals */
254 bool m_DVBCStaticCLK;
255 bool m_DVBTStaticCLK; /**< If TRUE, static MPEG clockrate will
256 be used, otherwise clockrate will
257 adapt to the bitrate of the TS */
258 u32 m_DVBTBitrate;
259 u32 m_DVBCBitrate;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300260
Oliver Endrissebc7de22011-07-03 13:49:44 -0300261 u8 m_TSDataStrength;
262 u8 m_TSClockkStrength;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300263
Oliver Endrissebc7de22011-07-03 13:49:44 -0300264 enum DRXMPEGStrWidth_t m_widthSTR; /**< MPEG start width */
265 u32 m_mpegTsStaticBitrate; /**< Maximum bitrate in b/s in case
266 static clockrate is selected */
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300267
Oliver Endrissebc7de22011-07-03 13:49:44 -0300268 /* LARGE_INTEGER m_StartTime; */ /**< Contains the time of the last demod start */
269 s32 m_MpegLockTimeOut; /**< WaitForLockStatus Timeout (counts from start time) */
270 s32 m_DemodLockTimeOut; /**< WaitForLockStatus Timeout (counts from start time) */
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300271
Oliver Endrissebc7de22011-07-03 13:49:44 -0300272 bool m_disableTEIhandling;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300273
Oliver Endrissebc7de22011-07-03 13:49:44 -0300274 bool m_RfAgcPol;
275 bool m_IfAgcPol;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300276
Oliver Endrissebc7de22011-07-03 13:49:44 -0300277 struct SCfgAgc m_atvRfAgcCfg; /**< settings for ATV RF-AGC */
278 struct SCfgAgc m_atvIfAgcCfg; /**< settings for ATV IF-AGC */
279 struct SCfgPreSaw m_atvPreSawCfg; /**< settings for ATV pre SAW sense */
280 bool m_phaseCorrectionBypass;
281 s16 m_atvTopVidPeak;
282 u16 m_atvTopNoiseTh;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300283 enum EDrxkSifAttenuation m_sifAttenuation;
Oliver Endrissebc7de22011-07-03 13:49:44 -0300284 bool m_enableCVBSOutput;
285 bool m_enableSIFOutput;
286 bool m_bMirrorFreqSpect;
287 enum EDrxkConstellation m_Constellation; /**< Constellation type of the channel */
288 u32 m_CurrSymbolRate; /**< Current QAM symbol rate */
289 struct SCfgAgc m_qamRfAgcCfg; /**< settings for QAM RF-AGC */
290 struct SCfgAgc m_qamIfAgcCfg; /**< settings for QAM IF-AGC */
291 u16 m_qamPgaCfg; /**< settings for QAM PGA */
292 struct SCfgPreSaw m_qamPreSawCfg; /**< settings for QAM pre SAW sense */
293 enum EDrxkInterleaveMode m_qamInterleaveMode; /**< QAM Interleave mode */
294 u16 m_fecRsPlen;
295 u16 m_fecRsPrescale;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300296
297 enum DRXKCfgDvbtSqiSpeed m_sqiSpeed;
298
Oliver Endrissebc7de22011-07-03 13:49:44 -0300299 u16 m_GPIO;
300 u16 m_GPIOCfg;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300301
Oliver Endrissebc7de22011-07-03 13:49:44 -0300302 struct SCfgAgc m_dvbtRfAgcCfg; /**< settings for QAM RF-AGC */
303 struct SCfgAgc m_dvbtIfAgcCfg; /**< settings for QAM IF-AGC */
304 struct SCfgPreSaw m_dvbtPreSawCfg; /**< settings for QAM pre SAW sense */
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300305
Oliver Endrissebc7de22011-07-03 13:49:44 -0300306 u16 m_agcFastClipCtrlDelay;
307 bool m_adcCompPassed;
308 u16 m_adcCompCoef[64];
309 u16 m_adcState;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300310
Oliver Endrissebc7de22011-07-03 13:49:44 -0300311 u8 *m_microcode;
312 int m_microcode_length;
313 bool m_DRXK_A1_PATCH_CODE;
314 bool m_DRXK_A1_ROM_CODE;
315 bool m_DRXK_A2_ROM_CODE;
316 bool m_DRXK_A3_ROM_CODE;
317 bool m_DRXK_A2_PATCH_CODE;
318 bool m_DRXK_A3_PATCH_CODE;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300319
Oliver Endrissebc7de22011-07-03 13:49:44 -0300320 bool m_rfmirror;
321 u8 m_deviceSpin;
322 u32 m_iqmRcRate;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300323
Oliver Endrissebc7de22011-07-03 13:49:44 -0300324 enum DRXPowerMode m_currentPowerMode;
Mauro Carvalho Chehabe076c922011-07-09 13:06:12 -0300325
Mauro Carvalho Chehab90796ac2011-07-10 09:36:30 -0300326 /*
327 * Configurable parameters at the driver. They stores the values found
328 * at struct drxk_config.
329 */
Mauro Carvalho Chehabe076c922011-07-09 13:06:12 -0300330
Mauro Carvalho Chehab90796ac2011-07-10 09:36:30 -0300331 u16 UIO_mask; /* Bits used by UIO */
Mauro Carvalho Chehab147e1102011-07-10 08:24:26 -0300332
Mauro Carvalho Chehab90796ac2011-07-10 09:36:30 -0300333 bool single_master;
334 bool no_i2c_bridge;
335 bool antenna_dvbt;
336 u16 antenna_gpio;
Mauro Carvalho Chehab147e1102011-07-10 08:24:26 -0300337
Mauro Carvalho Chehabe4f4f872011-07-09 17:35:26 -0300338 const char *microcode_name;
Ralph Metzler43dd07f2011-07-03 13:42:18 -0300339};
340
341#define NEVER_LOCK 0
342#define NOT_LOCKED 1
343#define DEMOD_LOCK 2
344#define FEC_LOCK 3
345#define MPEG_LOCK 4
346