2 * qt1010.h - DVB-T Tuner support
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 /* Not actual hw limits. */
25 #define QT1010_MIN_STEP 2000000
26 #define QT1010_MIN_FREQ 48000000
28 static int qt1010_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
34 } rd[46] = { { QT1010_W, 0x01, 0x80 },
35 { QT1010_W, 0x02, 0x3f },
36 { QT1010_W, 0x05, 0xff }, /* c */
37 { QT1010_W, 0x06, 0x44 },
38 { QT1010_W, 0x07, 0xff }, /* c */
39 { QT1010_W, 0x08, 0x08 },
40 { QT1010_W, 0x09, 0xff }, /* c */
41 { QT1010_W, 0x0a, 0xff }, /* c */
42 { QT1010_W, 0x0b, 0xff }, /* c */
43 { QT1010_W, 0x0c, 0xe1 },
44 { QT1010_W, 0x1a, 0xff }, /* 10 c */
45 { QT1010_W, 0x1b, 0x00 },
46 { QT1010_W, 0x1c, 0x89 },
47 { QT1010_W, 0x11, 0xff }, /* c */
48 { QT1010_W, 0x12, 0x91 },
49 { QT1010_W, 0x22, 0xff }, /* c */
50 { QT1010_W, 0x1e, 0x00 },
51 { QT1010_W, 0x1e, 0xd0 },
52 { QT1010_R, 0x22, 0xff }, /* c read */
53 { QT1010_W, 0x1e, 0x00 },
54 { QT1010_R, 0x05, 0xff }, /* 20 c read */
55 { QT1010_R, 0x22, 0xff }, /* c read */
56 { QT1010_W, 0x23, 0xd0 },
57 { QT1010_W, 0x1e, 0x00 },
58 { QT1010_W, 0x1e, 0xe0 },
59 { QT1010_R, 0x23, 0xff }, /* c read */
60 { QT1010_W, 0x1e, 0x00 },
61 { QT1010_W, 0x24, 0xd0 },
62 { QT1010_W, 0x1e, 0x00 },
63 { QT1010_W, 0x1e, 0xf0 },
64 { QT1010_R, 0x24, 0xff }, /* 30 c read */
65 { QT1010_W, 0x1e, 0x00 },
66 { QT1010_W, 0x14, 0x7f },
67 { QT1010_W, 0x15, 0x7f },
68 { QT1010_W, 0x05, 0xff }, /* c */
69 { QT1010_W, 0x06, 0x00 },
70 { QT1010_W, 0x15, 0x1f },
71 { QT1010_W, 0x16, 0xff },
72 { QT1010_W, 0x18, 0xff },
73 { QT1010_W, 0x1f, 0xff }, /* c */
74 { QT1010_W, 0x20, 0xff }, /* 40 c */
75 { QT1010_W, 0x21, 0x53 },
76 { QT1010_W, 0x25, 0xbd },
77 { QT1010_W, 0x26, 0x15 },
78 { QT1010_W, 0x02, 0x00 },
79 { QT1010_W, 0x01, 0x00 },
82 struct dvb_usb_adapter *adap = fe->dvb->priv;
83 unsigned long freq = params->frequency;
85 if (freq % QT1010_MIN_STEP)
86 printk("frequency not supported.\n");
88 div = (freq - QT1010_MIN_FREQ) / QT1010_MIN_STEP;
89 mod = (div + 16 - 9) % 16;
102 rd[4].value = (((freq - QT1010_MIN_FREQ) / 1000000) * 9975 + 12960000) / 320000;
200 for (i = 0; i < sizeof(rd) / sizeof(*rd); i++) {
206 msg.addr = adap->dev->adapter[0].pll_addr;
207 msg.buf = &rd[i].reg;
209 if (i2c_transfer(&adap->dev->i2c_adap, &msg, 1) != 1) {
210 printk("tuner write failed\n");
218 static int qt1010_tuner_attach(struct dvb_usb_adapter *adap)
220 adap->pll_addr = 0xc4;
221 adap->pll_desc = NULL;
222 adap->fe->ops.tuner_ops.set_params = qt1010_set_params;