2 * Rafael Micro R820T driver
4 * Copyright (C) 2013 Mauro Carvalho Chehab <mchehab@redhat.com>
6 * This driver was written from scratch, based on an existing driver
7 * that it is part of rtl-sdr git tree, released under GPLv2:
8 * https://groups.google.com/forum/#!topic/ultra-cheap-sdr/Y3rBEOFtHug
9 * https://github.com/n1gp/gr-baz
11 * From what I understood from the threads, the original driver was converted
12 * to userspace from a Realtek tree. I couldn't find the original tree.
13 * However, the original driver look awkward on my eyes. So, I decided to
14 * write a new version from it from the scratch, while trying to reproduce
15 * everything found there.
18 * After locking, the original driver seems to have some routines to
19 * improve reception. This was not implemented here yet.
21 * RF Gain set/get is not implemented.
23 * This program is free software; you can redistribute it and/or modify
24 * it under the terms of the GNU General Public License as published by
25 * the Free Software Foundation; either version 2 of the License, or
26 * (at your option) any later version.
28 * This program is distributed in the hope that it will be useful,
29 * but WITHOUT ANY WARRANTY; without even the implied warranty of
30 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 * GNU General Public License for more details.
35 #include <linux/videodev2.h>
36 #include <linux/mutex.h>
37 #include <linux/slab.h>
38 #include <linux/bitrev.h>
39 #include <asm/div64.h>
41 #include "tuner-i2c.h"
45 * FIXME: I think that there are only 32 registers, but better safe than
46 * sorry. After finishing the driver, we may review it.
48 #define REG_SHADOW_START 5
54 module_param(debug
, int, 0644);
55 MODULE_PARM_DESC(debug
, "enable verbose debug messages");
58 * enums and structures
70 struct list_head hybrid_tuner_instance_list
;
71 const struct r820t_config
*cfg
;
72 struct tuner_i2c_props i2c_props
;
77 enum xtal_cap_value xtal_cap_sel
;
83 /* Store current mode */
85 enum v4l2_tuner_type type
;
92 struct r820t_freq_range
{
100 u8 imr_mem
; /* Not used, currently */
103 #define VCO_POWER_REF 0x02
104 #define DIP_FREQ 32000000
110 static LIST_HEAD(hybrid_tuner_instance_list
);
111 static DEFINE_MUTEX(r820t_list_mutex
);
113 /* Those initial values start from REG_SHADOW_START */
114 static const u8 r820t_init_array
[NUM_REGS
] = {
115 0x83, 0x32, 0x75, /* 05 to 07 */
116 0xc0, 0x40, 0xd6, 0x6c, /* 08 to 0b */
117 0xf5, 0x63, 0x75, 0x68, /* 0c to 0f */
118 0x6c, 0x83, 0x80, 0x00, /* 10 to 13 */
119 0x0f, 0x00, 0xc0, 0x30, /* 14 to 17 */
120 0x48, 0xcc, 0x60, 0x00, /* 18 to 1b */
121 0x54, 0xae, 0x4a, 0xc0 /* 1c to 1f */
124 /* Tuner frequency ranges */
125 static const struct r820t_freq_range freq_ranges
[] = {
128 .open_d
= 0x08, /* low */
129 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
130 .tf_c
= 0xdf, /* R27[7:0] band2,band0 */
131 .xtal_cap20p
= 0x02, /* R16[1:0] 20pF (10) */
136 .freq
= 50, /* Start freq, in MHz */
137 .open_d
= 0x08, /* low */
138 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
139 .tf_c
= 0xbe, /* R27[7:0] band4,band1 */
140 .xtal_cap20p
= 0x02, /* R16[1:0] 20pF (10) */
145 .freq
= 55, /* Start freq, in MHz */
146 .open_d
= 0x08, /* low */
147 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
148 .tf_c
= 0x8b, /* R27[7:0] band7,band4 */
149 .xtal_cap20p
= 0x02, /* R16[1:0] 20pF (10) */
154 .freq
= 60, /* Start freq, in MHz */
155 .open_d
= 0x08, /* low */
156 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
157 .tf_c
= 0x7b, /* R27[7:0] band8,band4 */
158 .xtal_cap20p
= 0x02, /* R16[1:0] 20pF (10) */
163 .freq
= 65, /* Start freq, in MHz */
164 .open_d
= 0x08, /* low */
165 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
166 .tf_c
= 0x69, /* R27[7:0] band9,band6 */
167 .xtal_cap20p
= 0x02, /* R16[1:0] 20pF (10) */
172 .freq
= 70, /* Start freq, in MHz */
173 .open_d
= 0x08, /* low */
174 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
175 .tf_c
= 0x58, /* R27[7:0] band10,band7 */
176 .xtal_cap20p
= 0x02, /* R16[1:0] 20pF (10) */
181 .freq
= 75, /* Start freq, in MHz */
182 .open_d
= 0x00, /* high */
183 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
184 .tf_c
= 0x44, /* R27[7:0] band11,band11 */
185 .xtal_cap20p
= 0x02, /* R16[1:0] 20pF (10) */
190 .freq
= 80, /* Start freq, in MHz */
191 .open_d
= 0x00, /* high */
192 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
193 .tf_c
= 0x44, /* R27[7:0] band11,band11 */
194 .xtal_cap20p
= 0x02, /* R16[1:0] 20pF (10) */
199 .freq
= 90, /* Start freq, in MHz */
200 .open_d
= 0x00, /* high */
201 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
202 .tf_c
= 0x34, /* R27[7:0] band12,band11 */
203 .xtal_cap20p
= 0x01, /* R16[1:0] 10pF (01) */
208 .freq
= 100, /* Start freq, in MHz */
209 .open_d
= 0x00, /* high */
210 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
211 .tf_c
= 0x34, /* R27[7:0] band12,band11 */
212 .xtal_cap20p
= 0x01, /* R16[1:0] 10pF (01) */
217 .freq
= 110, /* Start freq, in MHz */
218 .open_d
= 0x00, /* high */
219 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
220 .tf_c
= 0x24, /* R27[7:0] band13,band11 */
221 .xtal_cap20p
= 0x01, /* R16[1:0] 10pF (01) */
226 .freq
= 120, /* Start freq, in MHz */
227 .open_d
= 0x00, /* high */
228 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
229 .tf_c
= 0x24, /* R27[7:0] band13,band11 */
230 .xtal_cap20p
= 0x01, /* R16[1:0] 10pF (01) */
235 .freq
= 140, /* Start freq, in MHz */
236 .open_d
= 0x00, /* high */
237 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
238 .tf_c
= 0x14, /* R27[7:0] band14,band11 */
239 .xtal_cap20p
= 0x01, /* R16[1:0] 10pF (01) */
244 .freq
= 180, /* Start freq, in MHz */
245 .open_d
= 0x00, /* high */
246 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
247 .tf_c
= 0x13, /* R27[7:0] band14,band12 */
248 .xtal_cap20p
= 0x00, /* R16[1:0] 0pF (00) */
253 .freq
= 220, /* Start freq, in MHz */
254 .open_d
= 0x00, /* high */
255 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
256 .tf_c
= 0x13, /* R27[7:0] band14,band12 */
257 .xtal_cap20p
= 0x00, /* R16[1:0] 0pF (00) */
262 .freq
= 250, /* Start freq, in MHz */
263 .open_d
= 0x00, /* high */
264 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
265 .tf_c
= 0x11, /* R27[7:0] highest,highest */
266 .xtal_cap20p
= 0x00, /* R16[1:0] 0pF (00) */
271 .freq
= 280, /* Start freq, in MHz */
272 .open_d
= 0x00, /* high */
273 .rf_mux_ploy
= 0x02, /* R26[7:6]=0 (LPF) R26[1:0]=2 (low) */
274 .tf_c
= 0x00, /* R27[7:0] highest,highest */
275 .xtal_cap20p
= 0x00, /* R16[1:0] 0pF (00) */
280 .freq
= 310, /* Start freq, in MHz */
281 .open_d
= 0x00, /* high */
282 .rf_mux_ploy
= 0x41, /* R26[7:6]=1 (bypass) R26[1:0]=1 (middle) */
283 .tf_c
= 0x00, /* R27[7:0] highest,highest */
284 .xtal_cap20p
= 0x00, /* R16[1:0] 0pF (00) */
289 .freq
= 450, /* Start freq, in MHz */
290 .open_d
= 0x00, /* high */
291 .rf_mux_ploy
= 0x41, /* R26[7:6]=1 (bypass) R26[1:0]=1 (middle) */
292 .tf_c
= 0x00, /* R27[7:0] highest,highest */
293 .xtal_cap20p
= 0x00, /* R16[1:0] 0pF (00) */
298 .freq
= 588, /* Start freq, in MHz */
299 .open_d
= 0x00, /* high */
300 .rf_mux_ploy
= 0x40, /* R26[7:6]=1 (bypass) R26[1:0]=0 (highest) */
301 .tf_c
= 0x00, /* R27[7:0] highest,highest */
302 .xtal_cap20p
= 0x00, /* R16[1:0] 0pF (00) */
307 .freq
= 650, /* Start freq, in MHz */
308 .open_d
= 0x00, /* high */
309 .rf_mux_ploy
= 0x40, /* R26[7:6]=1 (bypass) R26[1:0]=0 (highest) */
310 .tf_c
= 0x00, /* R27[7:0] highest,highest */
311 .xtal_cap20p
= 0x00, /* R16[1:0] 0pF (00) */
318 static int r820t_xtal_capacitor
[][2] = {
319 { 0x0b, XTAL_LOW_CAP_30P
},
320 { 0x02, XTAL_LOW_CAP_20P
},
321 { 0x01, XTAL_LOW_CAP_10P
},
322 { 0x00, XTAL_LOW_CAP_0P
},
323 { 0x10, XTAL_HIGH_CAP_0P
},
327 * measured with a Racal 6103E GSM test set at 928 MHz with -60 dBm
328 * input power, for raw results see:
329 * http://steve-m.de/projects/rtl-sdr/gain_measurement/r820t/
332 static const int r820t_lna_gain_steps
[] = {
333 0, 9, 13, 40, 38, 13, 31, 22, 26, 31, 26, 14, 19, 5, 35, 13
336 static const int r820t_mixer_gain_steps
[] = {
337 0, 5, 10, 10, 19, 9, 10, 25, 17, 10, 8, 16, 13, 6, 3, -8
341 * I2C read/write code and shadow registers logic
343 static void shadow_store(struct r820t_priv
*priv
, u8 reg
, const u8
*val
,
346 int r
= reg
- REG_SHADOW_START
;
357 tuner_dbg("%s: prev reg=%02x len=%d: %*ph\n",
358 __func__
, r
+ REG_SHADOW_START
, len
, len
, val
);
360 memcpy(&priv
->regs
[r
], val
, len
);
363 static int r820t_write(struct r820t_priv
*priv
, u8 reg
, const u8
*val
,
366 int rc
, size
, pos
= 0;
368 /* Store the shadow registers */
369 shadow_store(priv
, reg
, val
, len
);
372 if (len
> priv
->cfg
->max_i2c_msg_len
- 1)
373 size
= priv
->cfg
->max_i2c_msg_len
- 1;
377 /* Fill I2C buffer */
379 memcpy(&priv
->buf
[1], &val
[pos
], size
);
381 rc
= tuner_i2c_xfer_send(&priv
->i2c_props
, priv
->buf
, size
+ 1);
382 if (rc
!= size
+ 1) {
383 tuner_info("%s: i2c wr failed=%d reg=%02x len=%d: %*ph\n",
384 __func__
, rc
, reg
, size
, size
, &priv
->buf
[1]);
389 tuner_dbg("%s: i2c wr reg=%02x len=%d: %*ph\n",
390 __func__
, reg
, size
, size
, &priv
->buf
[1]);
400 static int r820t_write_reg(struct r820t_priv
*priv
, u8 reg
, u8 val
)
402 return r820t_write(priv
, reg
, &val
, 1);
405 static int r820t_read_cache_reg(struct r820t_priv
*priv
, int reg
)
407 reg
-= REG_SHADOW_START
;
409 if (reg
>= 0 && reg
< NUM_REGS
)
410 return priv
->regs
[reg
];
415 static int r820t_write_reg_mask(struct r820t_priv
*priv
, u8 reg
, u8 val
,
418 int rc
= r820t_read_cache_reg(priv
, reg
);
423 val
= (rc
& ~bit_mask
) | (val
& bit_mask
);
425 return r820t_write(priv
, reg
, &val
, 1);
428 static int r820_read(struct r820t_priv
*priv
, u8 reg
, u8
*val
, int len
)
431 u8
*p
= &priv
->buf
[1];
435 rc
= tuner_i2c_xfer_send_recv(&priv
->i2c_props
, priv
->buf
, 1, p
, len
);
437 tuner_info("%s: i2c rd failed=%d reg=%02x len=%d: %*ph\n",
438 __func__
, rc
, reg
, len
, len
, p
);
444 /* Copy data to the output buffer */
445 for (i
= 0; i
< len
; i
++)
446 val
[i
] = bitrev8(p
[i
]);
448 tuner_dbg("%s: i2c rd reg=%02x len=%d: %*ph\n",
449 __func__
, reg
, len
, len
, val
);
458 static int r820t_set_mux(struct r820t_priv
*priv
, u32 freq
)
460 const struct r820t_freq_range
*range
;
464 /* Get the proper frequency range */
465 freq
= freq
/ 1000000;
466 for (i
= 0; i
< ARRAY_SIZE(freq_ranges
) - 1; i
++) {
467 if (freq
< freq_ranges
[i
+ 1].freq
)
470 range
= &freq_ranges
[i
];
472 tuner_dbg("set r820t range#%d for frequency %d MHz\n", i
, freq
);
475 rc
= r820t_write_reg_mask(priv
, 0x17, range
->open_d
, 0x08);
480 rc
= r820t_write_reg_mask(priv
, 0x1a, range
->rf_mux_ploy
, 0xc3);
485 rc
= r820t_write_reg(priv
, 0x1b, range
->tf_c
);
489 /* XTAL CAP & Drive */
490 switch (priv
->xtal_cap_sel
) {
491 case XTAL_LOW_CAP_30P
:
492 case XTAL_LOW_CAP_20P
:
493 val
= range
->xtal_cap20p
| 0x08;
495 case XTAL_LOW_CAP_10P
:
496 val
= range
->xtal_cap10p
| 0x08;
498 case XTAL_HIGH_CAP_0P
:
499 val
= range
->xtal_cap0p
| 0x00;
502 case XTAL_LOW_CAP_0P
:
503 val
= range
->xtal_cap0p
| 0x08;
506 rc
= r820t_write_reg_mask(priv
, 0x10, val
, 0x0b);
511 * FIXME: the original driver has a logic there with preserves
512 * gain/phase from registers 8 and 9 reading the data from the
513 * registers before writing, if "IMF done". That code was sort of
514 * commented there, as the flag is always false.
516 rc
= r820t_write_reg_mask(priv
, 0x08, 0, 0x3f);
520 rc
= r820t_write_reg_mask(priv
, 0x09, 0, 0x3f);
525 static int r820t_set_pll(struct r820t_priv
*priv
, u32 freq
)
529 u32 vco_fra
; /* VCO contribution by SDM (kHz) */
530 u32 vco_min
= 1770000;
531 u32 vco_max
= vco_min
* 2;
538 u8 ni
, si
, nint
, vco_fine_tune
, val
;
541 freq
= freq
/ 1000; /* Frequency in kHz */
543 pll_ref
= priv
->cfg
->xtal
/ 1000;
545 tuner_dbg("set r820t pll for frequency %d kHz = %d\n", freq
, pll_ref
);
547 /* FIXME: this seems to be a hack - probably it can be removed */
548 rc
= r820t_write_reg_mask(priv
, 0x10, 0x00, 0x00);
552 /* set pll autotune = 128kHz */
553 rc
= r820t_write_reg_mask(priv
, 0x1a, 0x00, 0x0c);
557 /* set VCO current = 100 */
558 rc
= r820t_write_reg_mask(priv
, 0x12, 0x80, 0xe0);
562 /* Calculate divider */
563 while (mix_div
<= 64) {
564 if (((freq
* mix_div
) >= vco_min
) &&
565 ((freq
* mix_div
) < vco_max
)) {
567 while (div_buf
> 2) {
568 div_buf
= div_buf
>> 1;
573 mix_div
= mix_div
<< 1;
576 rc
= r820_read(priv
, 0x00, data
, sizeof(data
));
580 vco_fine_tune
= (data
[4] & 0x30) >> 4;
582 if (vco_fine_tune
> VCO_POWER_REF
)
583 div_num
= div_num
- 1;
584 else if (vco_fine_tune
< VCO_POWER_REF
)
585 div_num
= div_num
+ 1;
587 rc
= r820t_write_reg_mask(priv
, 0x10, div_num
<< 5, 0xe0);
591 vco_freq
= (u64
)(freq
* (u64
)mix_div
);
594 do_div(tmp64
, 2 * pll_ref
);
597 tmp64
= vco_freq
- ((u64
)2) * pll_ref
* nint
;
599 vco_fra
= (u16
)(tmp64
);
603 /* boundary spur prevention */
604 if (vco_fra
< pll_ref
/ 64) {
606 } else if (vco_fra
> pll_ref
* 127 / 64) {
609 } else if ((vco_fra
> pll_ref
* 127 / 128) && (vco_fra
< pll_ref
)) {
610 vco_fra
= pll_ref
* 127 / 128;
611 } else if ((vco_fra
> pll_ref
) && (vco_fra
< pll_ref
* 129 / 128)) {
612 vco_fra
= pll_ref
* 129 / 128;
616 tuner_info("No valid PLL values for %u kHz!\n", freq
);
620 ni
= (nint
- 13) / 4;
621 si
= nint
- 4 * ni
- 13;
623 rc
= r820t_write_reg(priv
, 0x14, ni
+ (si
<< 6));
633 rc
= r820t_write_reg_mask(priv
, 0x12, val
, 0x08);
638 while (vco_fra
> 1) {
639 if (vco_fra
> (2 * pll_ref
/ n_sdm
)) {
640 sdm
= sdm
+ 32768 / (n_sdm
/ 2);
641 vco_fra
= vco_fra
- 2 * pll_ref
/ n_sdm
;
648 rc
= r820t_write_reg_mask(priv
, 0x16, sdm
>> 8, 0x08);
651 rc
= r820t_write_reg_mask(priv
, 0x15, sdm
& 0xff, 0x08);
655 for (i
= 0; i
< 2; i
++) {
657 * FIXME: Rafael chips R620D, R828D and R828 seems to
658 * need 20 ms for analog TV
662 /* Check if PLL has locked */
663 rc
= r820_read(priv
, 0x00, data
, 3);
670 /* Didn't lock. Increase VCO current */
671 rc
= r820t_write_reg_mask(priv
, 0x12, 0x60, 0xe0);
677 if (!(data
[2] & 0x40)) {
678 priv
->has_lock
= false;
682 priv
->has_lock
= true;
683 tuner_dbg("tuner has lock at frequency %d kHz\n", freq
);
685 /* set pll autotune = 8kHz */
686 rc
= r820t_write_reg_mask(priv
, 0x1a, 0x08, 0x08);
691 static int r820t_sysfreq_sel(struct r820t_priv
*priv
, u32 freq
,
692 enum v4l2_tuner_type type
,
697 u8 mixer_top
, lna_top
, cp_cur
, div_buf_cur
, lna_vth_l
, mixer_vth_l
;
698 u8 air_cable1_in
, cable2_in
, pre_dect
, lna_discharge
, filter_cur
;
700 tuner_dbg("adjusting tuner parameters for the standard\n");
704 if ((freq
== 506000000) || (freq
== 666000000) ||
705 (freq
== 818000000)) {
706 mixer_top
= 0x14; /* mixer top:14 , top-1, low-discharge */
707 lna_top
= 0xe5; /* detect bw 3, lna top:4, predet top:2 */
708 cp_cur
= 0x28; /* 101, 0.2 */
709 div_buf_cur
= 0x20; /* 10, 200u */
711 mixer_top
= 0x24; /* mixer top:13 , top-1, low-discharge */
712 lna_top
= 0xe5; /* detect bw 3, lna top:4, predet top:2 */
713 cp_cur
= 0x38; /* 111, auto */
714 div_buf_cur
= 0x30; /* 11, 150u */
716 lna_vth_l
= 0x53; /* lna vth 0.84 , vtl 0.64 */
717 mixer_vth_l
= 0x75; /* mixer vth 1.04, vtl 0.84 */
718 air_cable1_in
= 0x00;
722 filter_cur
= 0x40; /* 10, low */
725 mixer_top
= 0x24; /* mixer top:13 , top-1, low-discharge */
726 lna_top
= 0xe5; /* detect bw 3, lna top:4, predet top:2 */
727 lna_vth_l
= 0x53; /* lna vth 0.84 , vtl 0.64 */
728 mixer_vth_l
= 0x75; /* mixer vth 1.04, vtl 0.84 */
729 air_cable1_in
= 0x00;
733 cp_cur
= 0x38; /* 111, auto */
734 div_buf_cur
= 0x30; /* 11, 150u */
735 filter_cur
= 0x40; /* 10, low */
738 mixer_top
= 0x24; /* mixer top:13 , top-1, low-discharge */
739 lna_top
= 0xe5; /* detect bw 3, lna top:4, predet top:2 */
740 lna_vth_l
= 0x75; /* lna vth 1.04 , vtl 0.84 */
741 mixer_vth_l
= 0x75; /* mixer vth 1.04, vtl 0.84 */
742 air_cable1_in
= 0x00;
746 cp_cur
= 0x38; /* 111, auto */
747 div_buf_cur
= 0x30; /* 11, 150u */
748 filter_cur
= 0x40; /* 10, low */
750 default: /* DVB-T 8M */
751 mixer_top
= 0x24; /* mixer top:13 , top-1, low-discharge */
752 lna_top
= 0xe5; /* detect bw 3, lna top:4, predet top:2 */
753 lna_vth_l
= 0x53; /* lna vth 0.84 , vtl 0.64 */
754 mixer_vth_l
= 0x75; /* mixer vth 1.04, vtl 0.84 */
755 air_cable1_in
= 0x00;
759 cp_cur
= 0x38; /* 111, auto */
760 div_buf_cur
= 0x30; /* 11, 150u */
761 filter_cur
= 0x40; /* 10, low */
765 if (priv
->cfg
->use_diplexer
&&
766 ((priv
->cfg
->rafael_chip
== CHIP_R820T
) ||
767 (priv
->cfg
->rafael_chip
== CHIP_R828S
) ||
768 (priv
->cfg
->rafael_chip
== CHIP_R820C
))) {
770 air_cable1_in
= 0x00;
772 air_cable1_in
= 0x60;
776 rc
= r820t_write_reg_mask(priv
, 0x1d, lna_top
, 0xc7);
779 rc
= r820t_write_reg_mask(priv
, 0x1c, mixer_top
, 0xf8);
782 rc
= r820t_write_reg(priv
, 0x0d, lna_vth_l
);
785 rc
= r820t_write_reg(priv
, 0x0e, mixer_vth_l
);
789 /* Air-IN only for Astrometa */
790 rc
= r820t_write_reg_mask(priv
, 0x05, air_cable1_in
, 0x60);
793 rc
= r820t_write_reg_mask(priv
, 0x06, cable2_in
, 0x08);
797 rc
= r820t_write_reg_mask(priv
, 0x11, cp_cur
, 0x38);
800 rc
= r820t_write_reg_mask(priv
, 0x17, div_buf_cur
, 0x30);
803 rc
= r820t_write_reg_mask(priv
, 0x0a, filter_cur
, 0x60);
807 * Original driver initializes regs 0x05 and 0x06 with the
808 * same value again on this point. Probably, it is just an
816 tuner_dbg("adjusting LNA parameters\n");
817 if (type
!= V4L2_TUNER_ANALOG_TV
) {
818 /* LNA TOP: lowest */
819 rc
= r820t_write_reg_mask(priv
, 0x1d, 0, 0x38);
824 rc
= r820t_write_reg_mask(priv
, 0x1c, 0, 0x04);
828 /* 0: PRE_DECT off */
829 rc
= r820t_write_reg_mask(priv
, 0x06, 0, 0x40);
834 rc
= r820t_write_reg_mask(priv
, 0x1a, 0x30, 0x30);
840 /* write LNA TOP = 3 */
841 rc
= r820t_write_reg_mask(priv
, 0x1d, 0x18, 0x38);
846 * write discharge mode
847 * FIXME: IMHO, the mask here is wrong, but it matches
848 * what's there at the original driver
850 rc
= r820t_write_reg_mask(priv
, 0x1c, mixer_top
, 0x04);
854 /* LNA discharge current */
855 rc
= r820t_write_reg_mask(priv
, 0x1e, lna_discharge
, 0x1f);
860 rc
= r820t_write_reg_mask(priv
, 0x1a, 0x20, 0x30);
865 rc
= r820t_write_reg_mask(priv
, 0x06, 0, 0x40);
870 rc
= r820t_write_reg_mask(priv
, 0x1d, lna_top
, 0x38);
875 * write discharge mode
876 * FIXME: IMHO, the mask here is wrong, but it matches
877 * what's there at the original driver
879 rc
= r820t_write_reg_mask(priv
, 0x1c, mixer_top
, 0x04);
883 /* LNA discharge current */
884 rc
= r820t_write_reg_mask(priv
, 0x1e, lna_discharge
, 0x1f);
888 /* agc clk 1Khz, external det1 cap 1u */
889 rc
= r820t_write_reg_mask(priv
, 0x1a, 0x00, 0x30);
893 rc
= r820t_write_reg_mask(priv
, 0x10, 0x00, 0x04);
900 static int r820t_set_tv_standard(struct r820t_priv
*priv
,
902 enum v4l2_tuner_type type
,
903 v4l2_std_id std
, u32 delsys
)
907 u32 if_khz
, filt_cal_lo
;
909 u8 filt_gain
, img_r
, filt_q
, hp_cor
, ext_enable
, loop_through
;
910 u8 lt_att
, flt_ext_widest
, polyfil_cur
;
911 bool need_calibration
;
913 tuner_dbg("selecting the delivery system\n");
915 if (delsys
== SYS_ISDBT
) {
918 filt_gain
= 0x10; /* +3db, 6mhz on */
919 img_r
= 0x00; /* image negative */
920 filt_q
= 0x10; /* r10[4]:low q(1'b1) */
921 hp_cor
= 0x6a; /* 1.7m disable, +2cap, 1.25mhz */
922 ext_enable
= 0x40; /* r30[6], ext enable; r30[5]:0 ext at lna max */
923 loop_through
= 0x00; /* r5[7], lt on */
924 lt_att
= 0x00; /* r31[7], lt att enable */
925 flt_ext_widest
= 0x00; /* r15[7]: flt_ext_wide off */
926 polyfil_cur
= 0x60; /* r25[6:5]:min */
930 filt_cal_lo
= 56000; /* 52000->56000 */
931 filt_gain
= 0x10; /* +3db, 6mhz on */
932 img_r
= 0x00; /* image negative */
933 filt_q
= 0x10; /* r10[4]:low q(1'b1) */
934 hp_cor
= 0x6b; /* 1.7m disable, +2cap, 1.0mhz */
935 ext_enable
= 0x60; /* r30[6]=1 ext enable; r30[5]:1 ext at lna max-1 */
936 loop_through
= 0x00; /* r5[7], lt on */
937 lt_att
= 0x00; /* r31[7], lt att enable */
938 flt_ext_widest
= 0x00; /* r15[7]: flt_ext_wide off */
939 polyfil_cur
= 0x60; /* r25[6:5]:min */
940 } else if (bw
== 7) {
943 * There are two 7 MHz tables defined on the original
944 * driver, but just the second one seems to be visible
945 * by rtl2832. Keep this one here commented, as it
946 * might be needed in the future
951 filt_gain
= 0x10; /* +3db, 6mhz on */
952 img_r
= 0x00; /* image negative */
953 filt_q
= 0x10; /* r10[4]:low q(1'b1) */
954 hp_cor
= 0x2b; /* 1.7m disable, +1cap, 1.0mhz */
955 ext_enable
= 0x60; /* r30[6]=1 ext enable; r30[5]:1 ext at lna max-1 */
956 loop_through
= 0x00; /* r5[7], lt on */
957 lt_att
= 0x00; /* r31[7], lt att enable */
958 flt_ext_widest
= 0x00; /* r15[7]: flt_ext_wide off */
959 polyfil_cur
= 0x60; /* r25[6:5]:min */
961 /* 7 MHz, second table */
964 filt_gain
= 0x10; /* +3db, 6mhz on */
965 img_r
= 0x00; /* image negative */
966 filt_q
= 0x10; /* r10[4]:low q(1'b1) */
967 hp_cor
= 0x2a; /* 1.7m disable, +1cap, 1.25mhz */
968 ext_enable
= 0x60; /* r30[6]=1 ext enable; r30[5]:1 ext at lna max-1 */
969 loop_through
= 0x00; /* r5[7], lt on */
970 lt_att
= 0x00; /* r31[7], lt att enable */
971 flt_ext_widest
= 0x00; /* r15[7]: flt_ext_wide off */
972 polyfil_cur
= 0x60; /* r25[6:5]:min */
976 filt_gain
= 0x10; /* +3db, 6mhz on */
977 img_r
= 0x00; /* image negative */
978 filt_q
= 0x10; /* r10[4]:low q(1'b1) */
979 hp_cor
= 0x0b; /* 1.7m disable, +0cap, 1.0mhz */
980 ext_enable
= 0x60; /* r30[6]=1 ext enable; r30[5]:1 ext at lna max-1 */
981 loop_through
= 0x00; /* r5[7], lt on */
982 lt_att
= 0x00; /* r31[7], lt att enable */
983 flt_ext_widest
= 0x00; /* r15[7]: flt_ext_wide off */
984 polyfil_cur
= 0x60; /* r25[6:5]:min */
988 /* Initialize the shadow registers */
989 memcpy(priv
->regs
, r820t_init_array
, sizeof(r820t_init_array
));
991 /* Init Flag & Xtal_check Result */
993 val
= 1 | priv
->xtal_cap_sel
<< 1;
996 rc
= r820t_write_reg_mask(priv
, 0x0c, val
, 0x0f);
1001 rc
= r820t_write_reg_mask(priv
, 0x13, VER_NUM
, 0x3f);
1005 /* for LT Gain test */
1006 if (type
!= V4L2_TUNER_ANALOG_TV
) {
1007 rc
= r820t_write_reg_mask(priv
, 0x1d, 0x00, 0x38);
1012 priv
->int_freq
= if_khz
* 1000;
1014 /* Check if standard changed. If so, filter calibration is needed */
1015 if (type
!= priv
->type
)
1016 need_calibration
= true;
1017 else if ((type
== V4L2_TUNER_ANALOG_TV
) && (std
!= priv
->std
))
1018 need_calibration
= true;
1019 else if ((type
== V4L2_TUNER_DIGITAL_TV
) &&
1020 ((delsys
!= priv
->delsys
) || bw
!= priv
->bw
))
1021 need_calibration
= true;
1023 need_calibration
= false;
1025 if (need_calibration
) {
1026 tuner_dbg("calibrating the tuner\n");
1027 for (i
= 0; i
< 2; i
++) {
1029 rc
= r820t_write_reg_mask(priv
, 0x0b, hp_cor
, 0x60);
1033 /* set cali clk =on */
1034 rc
= r820t_write_reg_mask(priv
, 0x0f, 0x04, 0x04);
1038 /* X'tal cap 0pF for PLL */
1039 rc
= r820t_write_reg_mask(priv
, 0x10, 0x00, 0x03);
1043 rc
= r820t_set_pll(priv
, filt_cal_lo
);
1044 if (rc
< 0 || !priv
->has_lock
)
1048 rc
= r820t_write_reg_mask(priv
, 0x0b, 0x10, 0x10);
1055 rc
= r820t_write_reg_mask(priv
, 0x0b, 0x00, 0x10);
1059 /* set cali clk =off */
1060 rc
= r820t_write_reg_mask(priv
, 0x0f, 0x00, 0x04);
1064 /* Check if calibration worked */
1065 rc
= r820_read(priv
, 0x00, data
, sizeof(data
));
1069 priv
->fil_cal_code
= data
[4] & 0x0f;
1070 if (priv
->fil_cal_code
&& priv
->fil_cal_code
!= 0x0f)
1074 if (priv
->fil_cal_code
== 0x0f)
1075 priv
->fil_cal_code
= 0;
1078 rc
= r820t_write_reg_mask(priv
, 0x0a,
1079 filt_q
| priv
->fil_cal_code
, 0x1f);
1083 /* Set BW, Filter_gain, & HP corner */
1084 rc
= r820t_write_reg_mask(priv
, 0x0b, hp_cor
, 0x10);
1090 rc
= r820t_write_reg_mask(priv
, 0x07, img_r
, 0x80);
1094 /* Set filt_3dB, V6MHz */
1095 rc
= r820t_write_reg_mask(priv
, 0x06, filt_gain
, 0x30);
1099 /* channel filter extension */
1100 rc
= r820t_write_reg_mask(priv
, 0x1e, ext_enable
, 0x60);
1105 rc
= r820t_write_reg_mask(priv
, 0x05, loop_through
, 0x80);
1109 /* Loop through attenuation */
1110 rc
= r820t_write_reg_mask(priv
, 0x1f, lt_att
, 0x80);
1114 /* filter extension widest */
1115 rc
= r820t_write_reg_mask(priv
, 0x0f, flt_ext_widest
, 0x80);
1119 /* RF poly filter current */
1120 rc
= r820t_write_reg_mask(priv
, 0x19, polyfil_cur
, 0x60);
1124 /* Store current standard. If it changes, re-calibrate the tuner */
1125 priv
->delsys
= delsys
;
1133 static int r820t_read_gain(struct r820t_priv
*priv
)
1138 rc
= r820_read(priv
, 0x00, data
, sizeof(data
));
1142 return ((data
[3] & 0x0f) << 1) + ((data
[3] & 0xf0) >> 4);
1145 static int r820t_set_gain_mode(struct r820t_priv
*priv
,
1146 bool set_manual_gain
,
1151 if (set_manual_gain
) {
1152 int i
, total_gain
= 0;
1153 uint8_t mix_index
= 0, lna_index
= 0;
1157 rc
= r820t_write_reg_mask(priv
, 0x05, 0x10, 0x10);
1161 /* Mixer auto off */
1162 rc
= r820t_write_reg_mask(priv
, 0x07, 0, 0x10);
1166 rc
= r820_read(priv
, 0x00, data
, sizeof(data
));
1170 /* set fixed VGA gain for now (16.3 dB) */
1171 rc
= r820t_write_reg_mask(priv
, 0x0c, 0x08, 0x9f);
1175 for (i
= 0; i
< 15; i
++) {
1176 if (total_gain
>= gain
)
1179 total_gain
+= r820t_lna_gain_steps
[++lna_index
];
1181 if (total_gain
>= gain
)
1184 total_gain
+= r820t_mixer_gain_steps
[++mix_index
];
1188 rc
= r820t_write_reg_mask(priv
, 0x05, lna_index
, 0x0f);
1192 /* set Mixer gain */
1193 rc
= r820t_write_reg_mask(priv
, 0x07, mix_index
, 0x0f);
1198 rc
= r820t_write_reg_mask(priv
, 0x05, 0, 0xef);
1203 rc
= r820t_write_reg_mask(priv
, 0x07, 0x10, 0xef);
1207 /* set fixed VGA gain for now (26.5 dB) */
1208 rc
= r820t_write_reg_mask(priv
, 0x0c, 0x0b, 0x9f);
1217 static int generic_set_freq(struct dvb_frontend
*fe
,
1218 u32 freq
/* in HZ */,
1220 enum v4l2_tuner_type type
,
1221 v4l2_std_id std
, u32 delsys
)
1223 struct r820t_priv
*priv
= fe
->tuner_priv
;
1227 tuner_dbg("should set frequency to %d kHz, bw %d MHz\n",
1230 rc
= r820t_set_tv_standard(priv
, bw
, type
, std
, delsys
);
1234 if ((type
== V4L2_TUNER_ANALOG_TV
) && (std
== V4L2_STD_SECAM_LC
))
1235 lo_freq
= freq
- priv
->int_freq
;
1237 lo_freq
= freq
+ priv
->int_freq
;
1239 rc
= r820t_set_mux(priv
, lo_freq
);
1243 rc
= r820t_set_gain_mode(priv
, true, 0);
1247 rc
= r820t_set_pll(priv
, lo_freq
);
1248 if (rc
< 0 || !priv
->has_lock
)
1251 rc
= r820t_sysfreq_sel(priv
, freq
, type
, std
, delsys
);
1255 tuner_dbg("%s: PLL locked on frequency %d Hz, gain=%d\n",
1256 __func__
, freq
, r820t_read_gain(priv
));
1261 tuner_dbg("%s: failed=%d\n", __func__
, rc
);
1266 * r820t standby logic
1269 static int r820t_standby(struct r820t_priv
*priv
)
1273 rc
= r820t_write_reg(priv
, 0x06, 0xb1);
1276 rc
= r820t_write_reg(priv
, 0x05, 0x03);
1279 rc
= r820t_write_reg(priv
, 0x07, 0x3a);
1282 rc
= r820t_write_reg(priv
, 0x08, 0x40);
1285 rc
= r820t_write_reg(priv
, 0x09, 0xc0);
1288 rc
= r820t_write_reg(priv
, 0x0a, 0x36);
1291 rc
= r820t_write_reg(priv
, 0x0c, 0x35);
1294 rc
= r820t_write_reg(priv
, 0x0f, 0x68);
1297 rc
= r820t_write_reg(priv
, 0x11, 0x03);
1300 rc
= r820t_write_reg(priv
, 0x17, 0xf4);
1303 rc
= r820t_write_reg(priv
, 0x19, 0x0c);
1305 /* Force initial calibration */
1312 * r820t device init logic
1315 static int r820t_xtal_check(struct r820t_priv
*priv
)
1320 /* Initialize the shadow registers */
1321 memcpy(priv
->regs
, r820t_init_array
, sizeof(r820t_init_array
));
1323 /* cap 30pF & Drive Low */
1324 rc
= r820t_write_reg_mask(priv
, 0x10, 0x0b, 0x0b);
1328 /* set pll autotune = 128kHz */
1329 rc
= r820t_write_reg_mask(priv
, 0x1a, 0x00, 0x0c);
1333 /* set manual initial reg = 111111; */
1334 rc
= r820t_write_reg_mask(priv
, 0x13, 0x7f, 0x7f);
1339 rc
= r820t_write_reg_mask(priv
, 0x13, 0x00, 0x40);
1343 /* Try several xtal capacitor alternatives */
1344 for (i
= 0; i
< ARRAY_SIZE(r820t_xtal_capacitor
); i
++) {
1345 rc
= r820t_write_reg_mask(priv
, 0x10,
1346 r820t_xtal_capacitor
[i
][0], 0x1b);
1352 rc
= r820_read(priv
, 0x00, data
, sizeof(data
));
1355 if ((!data
[2]) & 0x40)
1358 val
= data
[2] & 0x3f;
1360 if (priv
->cfg
->xtal
== 16000000 && (val
> 29 || val
< 23))
1367 if (i
== ARRAY_SIZE(r820t_xtal_capacitor
))
1370 return r820t_xtal_capacitor
[i
][1];
1374 * r820t frontend operations and tuner attach code
1376 * All driver locks and i2c control are only in this part of the code
1379 static int r820t_init(struct dvb_frontend
*fe
)
1381 struct r820t_priv
*priv
= fe
->tuner_priv
;
1385 tuner_dbg("%s:\n", __func__
);
1387 mutex_lock(&priv
->lock
);
1388 if (fe
->ops
.i2c_gate_ctrl
)
1389 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1391 if ((priv
->cfg
->rafael_chip
== CHIP_R820T
) ||
1392 (priv
->cfg
->rafael_chip
== CHIP_R828S
) ||
1393 (priv
->cfg
->rafael_chip
== CHIP_R820C
)) {
1394 priv
->xtal_cap_sel
= XTAL_HIGH_CAP_0P
;
1396 for (i
= 0; i
< 3; i
++) {
1397 rc
= r820t_xtal_check(priv
);
1400 if (!i
|| rc
> xtal_cap
)
1403 priv
->xtal_cap_sel
= xtal_cap
;
1406 /* Initialize registers */
1407 rc
= r820t_write(priv
, 0x05,
1408 r820t_init_array
, sizeof(r820t_init_array
));
1411 if (fe
->ops
.i2c_gate_ctrl
)
1412 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1413 mutex_unlock(&priv
->lock
);
1416 tuner_dbg("%s: failed=%d\n", __func__
, rc
);
1420 static int r820t_sleep(struct dvb_frontend
*fe
)
1422 struct r820t_priv
*priv
= fe
->tuner_priv
;
1425 tuner_dbg("%s:\n", __func__
);
1427 mutex_lock(&priv
->lock
);
1428 if (fe
->ops
.i2c_gate_ctrl
)
1429 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1431 rc
= r820t_standby(priv
);
1433 if (fe
->ops
.i2c_gate_ctrl
)
1434 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1435 mutex_unlock(&priv
->lock
);
1437 tuner_dbg("%s: failed=%d\n", __func__
, rc
);
1441 static int r820t_set_analog_freq(struct dvb_frontend
*fe
,
1442 struct analog_parameters
*p
)
1444 struct r820t_priv
*priv
= fe
->tuner_priv
;
1448 tuner_dbg("%s called\n", __func__
);
1450 /* if std is not defined, choose one */
1452 p
->std
= V4L2_STD_MN
;
1454 if ((p
->std
== V4L2_STD_PAL_M
) || (p
->std
== V4L2_STD_NTSC
))
1459 mutex_lock(&priv
->lock
);
1460 if (fe
->ops
.i2c_gate_ctrl
)
1461 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1463 rc
= generic_set_freq(fe
, 62500l * p
->frequency
, bw
,
1464 V4L2_TUNER_ANALOG_TV
, p
->std
, SYS_UNDEFINED
);
1466 if (fe
->ops
.i2c_gate_ctrl
)
1467 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1468 mutex_unlock(&priv
->lock
);
1473 static int r820t_set_params(struct dvb_frontend
*fe
)
1475 struct r820t_priv
*priv
= fe
->tuner_priv
;
1476 struct dtv_frontend_properties
*c
= &fe
->dtv_property_cache
;
1480 tuner_dbg("%s: delivery_system=%d frequency=%d bandwidth_hz=%d\n",
1481 __func__
, c
->delivery_system
, c
->frequency
, c
->bandwidth_hz
);
1483 mutex_lock(&priv
->lock
);
1484 if (fe
->ops
.i2c_gate_ctrl
)
1485 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1487 bw
= (c
->bandwidth_hz
+ 500000) / 1000000;
1491 rc
= generic_set_freq(fe
, c
->frequency
, bw
,
1492 V4L2_TUNER_DIGITAL_TV
, 0, c
->delivery_system
);
1494 if (fe
->ops
.i2c_gate_ctrl
)
1495 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1496 mutex_unlock(&priv
->lock
);
1499 tuner_dbg("%s: failed=%d\n", __func__
, rc
);
1503 static int r820t_signal(struct dvb_frontend
*fe
, u16
*strength
)
1505 struct r820t_priv
*priv
= fe
->tuner_priv
;
1508 mutex_lock(&priv
->lock
);
1509 if (fe
->ops
.i2c_gate_ctrl
)
1510 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1512 if (priv
->has_lock
) {
1513 rc
= r820t_read_gain(priv
);
1517 /* A higher gain at LNA means a lower signal strength */
1518 *strength
= (45 - rc
) << 4 | 0xff;
1519 if (*strength
== 0xff)
1526 if (fe
->ops
.i2c_gate_ctrl
)
1527 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1528 mutex_unlock(&priv
->lock
);
1530 tuner_dbg("%s: %s, gain=%d strength=%d\n",
1532 priv
->has_lock
? "PLL locked" : "no signal",
1538 static int r820t_get_if_frequency(struct dvb_frontend
*fe
, u32
*frequency
)
1540 struct r820t_priv
*priv
= fe
->tuner_priv
;
1542 tuner_dbg("%s:\n", __func__
);
1544 *frequency
= priv
->int_freq
;
1549 static int r820t_release(struct dvb_frontend
*fe
)
1551 struct r820t_priv
*priv
= fe
->tuner_priv
;
1553 tuner_dbg("%s:\n", __func__
);
1555 mutex_lock(&r820t_list_mutex
);
1558 hybrid_tuner_release_state(priv
);
1560 mutex_unlock(&r820t_list_mutex
);
1562 fe
->tuner_priv
= NULL
;
1564 kfree(fe
->tuner_priv
);
1569 static const struct dvb_tuner_ops r820t_tuner_ops
= {
1571 .name
= "Rafael Micro R820T",
1572 .frequency_min
= 42000000,
1573 .frequency_max
= 1002000000,
1576 .release
= r820t_release
,
1577 .sleep
= r820t_sleep
,
1578 .set_params
= r820t_set_params
,
1579 .set_analog_params
= r820t_set_analog_freq
,
1580 .get_if_frequency
= r820t_get_if_frequency
,
1581 .get_rf_strength
= r820t_signal
,
1584 struct dvb_frontend
*r820t_attach(struct dvb_frontend
*fe
,
1585 struct i2c_adapter
*i2c
,
1586 const struct r820t_config
*cfg
)
1588 struct r820t_priv
*priv
;
1593 mutex_lock(&r820t_list_mutex
);
1595 instance
= hybrid_tuner_request_state(struct r820t_priv
, priv
,
1596 hybrid_tuner_instance_list
,
1601 /* memory allocation failure */
1605 /* new tuner instance */
1608 mutex_init(&priv
->lock
);
1610 fe
->tuner_priv
= priv
;
1613 /* existing tuner instance */
1614 fe
->tuner_priv
= priv
;
1618 memcpy(&fe
->ops
.tuner_ops
, &r820t_tuner_ops
, sizeof(r820t_tuner_ops
));
1620 if (fe
->ops
.i2c_gate_ctrl
)
1621 fe
->ops
.i2c_gate_ctrl(fe
, 1);
1623 /* check if the tuner is there */
1624 rc
= r820_read(priv
, 0x00, data
, sizeof(data
));
1628 rc
= r820t_sleep(fe
);
1632 tuner_info("Rafael Micro r820t successfully identified\n");
1634 fe
->tuner_priv
= priv
;
1635 memcpy(&fe
->ops
.tuner_ops
, &r820t_tuner_ops
,
1636 sizeof(struct dvb_tuner_ops
));
1638 if (fe
->ops
.i2c_gate_ctrl
)
1639 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1641 mutex_unlock(&r820t_list_mutex
);
1645 if (fe
->ops
.i2c_gate_ctrl
)
1646 fe
->ops
.i2c_gate_ctrl(fe
, 0);
1649 mutex_unlock(&r820t_list_mutex
);
1651 tuner_info("%s: failed=%d\n", __func__
, rc
);
1655 EXPORT_SYMBOL_GPL(r820t_attach
);
1657 MODULE_DESCRIPTION("Rafael Micro r820t silicon tuner driver");
1658 MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
1659 MODULE_LICENSE("GPL");