2 * Realtek RTL2832 DVB-T demodulator driver
4 * Copyright (C) 2012 Thomas Mair <thomas.mair86@gmail.com>
5 * Copyright (C) 2012-2014 Antti Palosaari <crope@iki.fi>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 #ifndef RTL2832_PRIV_H
23 #define RTL2832_PRIV_H
25 #include <linux/regmap.h>
26 #include <linux/math64.h>
27 #include <linux/bitops.h>
29 #include "dvb_frontend.h"
34 struct rtl2832_platform_data
*pdata
;
35 struct i2c_client
*client
;
36 struct mutex regmap_mutex
;
37 struct regmap_config regmap_config
;
38 struct regmap
*regmap
;
39 struct i2c_adapter
*i2c_adapter_tuner
;
40 struct dvb_frontend fe
;
41 struct delayed_work stat_work
;
42 enum fe_status fe_status
;
43 u64 post_bit_error_prev
; /* for old DVBv3 read_ber() calculation */
47 struct delayed_work i2c_gate_work
;
48 unsigned long filters
; /* PID filter */
51 struct rtl2832_reg_entry
{
57 struct rtl2832_reg_value
{
62 /* Demod register bit names */
63 enum DVBT_REG_BIT_NAME
{
67 DVBT_RSD_BER_FAIL_VAL
,
128 DVBT_CFREQ_OFF_RATIO
,
163 DVBT_AGC_TARG_VAL_8_1
,
194 DVBT_MPEG_IO_OPT_2_2
,
195 DVBT_MPEG_IO_OPT_1_0
,
252 DVBT_REG_BIT_NAME_ITEM_TERMINATOR
,
255 static const struct rtl2832_reg_value rtl2832_tuner_init_fc2580
[] = {
256 {DVBT_DAGC_TRG_VAL
, 0x39},
257 {DVBT_AGC_TARG_VAL_0
, 0x0},
258 {DVBT_AGC_TARG_VAL_8_1
, 0x5a},
259 {DVBT_AAGC_LOOP_GAIN
, 0x16},
260 {DVBT_LOOP_GAIN2_3_0
, 0x6},
261 {DVBT_LOOP_GAIN2_4
, 0x1},
262 {DVBT_LOOP_GAIN3
, 0x16},
270 {DVBT_IF_AGC_MIN
, 0x80},
271 {DVBT_IF_AGC_MAX
, 0x7f},
272 {DVBT_RF_AGC_MIN
, 0x9c},
273 {DVBT_RF_AGC_MAX
, 0x7f},
274 {DVBT_POLAR_RF_AGC
, 0x0},
275 {DVBT_POLAR_IF_AGC
, 0x0},
276 {DVBT_AD7_SETTING
, 0xe9f4},
279 static const struct rtl2832_reg_value rtl2832_tuner_init_tua9001
[] = {
280 {DVBT_DAGC_TRG_VAL
, 0x39},
281 {DVBT_AGC_TARG_VAL_0
, 0x0},
282 {DVBT_AGC_TARG_VAL_8_1
, 0x5a},
283 {DVBT_AAGC_LOOP_GAIN
, 0x16},
284 {DVBT_LOOP_GAIN2_3_0
, 0x6},
285 {DVBT_LOOP_GAIN2_4
, 0x1},
286 {DVBT_LOOP_GAIN3
, 0x16},
294 {DVBT_IF_AGC_MIN
, 0x80},
295 {DVBT_IF_AGC_MAX
, 0x7f},
296 {DVBT_RF_AGC_MIN
, 0x9c},
297 {DVBT_RF_AGC_MAX
, 0x7f},
298 {DVBT_POLAR_RF_AGC
, 0x0},
299 {DVBT_POLAR_IF_AGC
, 0x0},
300 {DVBT_AD7_SETTING
, 0xe9f4},
301 {DVBT_OPT_ADC_IQ
, 0x1},
304 {DVBT_SPEC_INV
, 0x0},
307 static const struct rtl2832_reg_value rtl2832_tuner_init_fc0012
[] = {
308 {DVBT_DAGC_TRG_VAL
, 0x5a},
309 {DVBT_AGC_TARG_VAL_0
, 0x0},
310 {DVBT_AGC_TARG_VAL_8_1
, 0x5a},
311 {DVBT_AAGC_LOOP_GAIN
, 0x16},
312 {DVBT_LOOP_GAIN2_3_0
, 0x6},
313 {DVBT_LOOP_GAIN2_4
, 0x1},
314 {DVBT_LOOP_GAIN3
, 0x16},
322 {DVBT_IF_AGC_MIN
, 0x80},
323 {DVBT_IF_AGC_MAX
, 0x7f},
324 {DVBT_RF_AGC_MIN
, 0x80},
325 {DVBT_RF_AGC_MAX
, 0x7f},
326 {DVBT_POLAR_RF_AGC
, 0x0},
327 {DVBT_POLAR_IF_AGC
, 0x0},
328 {DVBT_AD7_SETTING
, 0xe9bf},
329 {DVBT_EN_GI_PGA
, 0x0},
330 {DVBT_THD_LOCK_UP
, 0x0},
331 {DVBT_THD_LOCK_DW
, 0x0},
332 {DVBT_THD_UP1
, 0x11},
333 {DVBT_THD_DW1
, 0xef},
334 {DVBT_INTER_CNT_LEN
, 0xc},
335 {DVBT_GI_PGA_STATE
, 0x0},
336 {DVBT_EN_AGC_PGA
, 0x1},
337 {DVBT_IF_AGC_MAN
, 0x0},
338 {DVBT_SPEC_INV
, 0x0},
341 static const struct rtl2832_reg_value rtl2832_tuner_init_e4000
[] = {
342 {DVBT_DAGC_TRG_VAL
, 0x5a},
343 {DVBT_AGC_TARG_VAL_0
, 0x0},
344 {DVBT_AGC_TARG_VAL_8_1
, 0x5a},
345 {DVBT_AAGC_LOOP_GAIN
, 0x18},
346 {DVBT_LOOP_GAIN2_3_0
, 0x8},
347 {DVBT_LOOP_GAIN2_4
, 0x1},
348 {DVBT_LOOP_GAIN3
, 0x18},
356 {DVBT_IF_AGC_MIN
, 0x80},
357 {DVBT_IF_AGC_MAX
, 0x7f},
358 {DVBT_RF_AGC_MIN
, 0x80},
359 {DVBT_RF_AGC_MAX
, 0x7f},
360 {DVBT_POLAR_RF_AGC
, 0x0},
361 {DVBT_POLAR_IF_AGC
, 0x0},
362 {DVBT_AD7_SETTING
, 0xe9d4},
363 {DVBT_EN_GI_PGA
, 0x0},
364 {DVBT_THD_LOCK_UP
, 0x0},
365 {DVBT_THD_LOCK_DW
, 0x0},
366 {DVBT_THD_UP1
, 0x14},
367 {DVBT_THD_DW1
, 0xec},
368 {DVBT_INTER_CNT_LEN
, 0xc},
369 {DVBT_GI_PGA_STATE
, 0x0},
370 {DVBT_EN_AGC_PGA
, 0x1},
373 {DVBT_REG_MONSEL
, 0x1},
375 {DVBT_REG_4MSEL
, 0x0},
376 {DVBT_SPEC_INV
, 0x0},
379 static const struct rtl2832_reg_value rtl2832_tuner_init_r820t
[] = {
380 {DVBT_DAGC_TRG_VAL
, 0x39},
381 {DVBT_AGC_TARG_VAL_0
, 0x0},
382 {DVBT_AGC_TARG_VAL_8_1
, 0x40},
383 {DVBT_AAGC_LOOP_GAIN
, 0x16},
384 {DVBT_LOOP_GAIN2_3_0
, 0x8},
385 {DVBT_LOOP_GAIN2_4
, 0x1},
386 {DVBT_LOOP_GAIN3
, 0x18},
394 {DVBT_IF_AGC_MIN
, 0x80},
395 {DVBT_IF_AGC_MAX
, 0x7f},
396 {DVBT_RF_AGC_MIN
, 0x80},
397 {DVBT_RF_AGC_MAX
, 0x7f},
398 {DVBT_POLAR_RF_AGC
, 0x0},
399 {DVBT_POLAR_IF_AGC
, 0x0},
400 {DVBT_AD7_SETTING
, 0xe9f4},
401 {DVBT_SPEC_INV
, 0x1},
404 static const struct rtl2832_reg_value rtl2832_tuner_init_si2157
[] = {
405 {DVBT_DAGC_TRG_VAL
, 0x39},
406 {DVBT_AGC_TARG_VAL_0
, 0x0},
407 {DVBT_AGC_TARG_VAL_8_1
, 0x40},
408 {DVBT_AAGC_LOOP_GAIN
, 0x16},
409 {DVBT_LOOP_GAIN2_3_0
, 0x8},
410 {DVBT_LOOP_GAIN2_4
, 0x1},
411 {DVBT_LOOP_GAIN3
, 0x18},
419 {DVBT_IF_AGC_MIN
, 0x80},
420 {DVBT_IF_AGC_MAX
, 0x7f},
421 {DVBT_RF_AGC_MIN
, 0x80},
422 {DVBT_RF_AGC_MAX
, 0x7f},
423 {DVBT_POLAR_RF_AGC
, 0x0},
424 {DVBT_POLAR_IF_AGC
, 0x0},
425 {DVBT_AD7_SETTING
, 0xe9f4},
426 {DVBT_SPEC_INV
, 0x0},
429 #endif /* RTL2832_PRIV_H */