blob: fdd1bb51e807e6630a2aec9df9dbccaac5cb544e [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
4 *
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07005 * Extended 3 / 2005 by Hartmut Hackmann to support various
6 * cards with the tda10046 DVB-T channel decoder
7 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <linux/init.h>
24#include <linux/list.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/slab.h>
28#include <linux/delay.h>
29#include <linux/kthread.h>
30#include <linux/suspend.h>
31
32#include "saa7134-reg.h"
33#include "saa7134.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020034#include <media/v4l2-common.h>
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -020035#include "dvb-pll.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030037#include "mt352.h"
38#include "mt352_priv.h" /* FIXME */
39#include "tda1004x.h"
40#include "nxt200x.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
42MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
43MODULE_LICENSE("GPL");
44
45static unsigned int antenna_pwr = 0;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070046
Linus Torvalds1da177e2005-04-16 15:20:36 -070047module_param(antenna_pwr, int, 0444);
48MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
49
50/* ------------------------------------------------------------------ */
Linus Torvalds1da177e2005-04-16 15:20:36 -070051static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
52{
53 u32 ok;
54
55 if (!on) {
56 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
57 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
58 return 0;
59 }
60
61 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
62 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
63 udelay(10);
64
65 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
66 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
67 udelay(10);
68 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
69 udelay(10);
70 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
71 printk("%s: %s %s\n", dev->name, __FUNCTION__,
72 ok ? "on" : "off");
73
74 if (!ok)
75 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
76 return ok;
77}
78
79static int mt352_pinnacle_init(struct dvb_frontend* fe)
80{
81 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
82 static u8 reset [] = { RESET, 0x80 };
83 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
84 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
85 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
86 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
87 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
88 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
89 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
90 struct saa7134_dev *dev= fe->dvb->priv;
91
92 printk("%s: %s called\n",dev->name,__FUNCTION__);
93
94 mt352_write(fe, clock_config, sizeof(clock_config));
95 udelay(200);
96 mt352_write(fe, reset, sizeof(reset));
97 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
98 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
99 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
100 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
101
102 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
103 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
104 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 return 0;
107}
108
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200109static int mt352_aver777_init(struct dvb_frontend* fe)
110{
111 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
112 static u8 reset [] = { RESET, 0x80 };
113 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
114 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
115 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
116
117 mt352_write(fe, clock_config, sizeof(clock_config));
118 udelay(200);
119 mt352_write(fe, reset, sizeof(reset));
120 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
121 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
122 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
123
124 return 0;
125}
126
Andrew de Quincey0463f122006-05-16 17:22:02 -0300127static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
128 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300130 u8 off[] = { 0x00, 0xf1};
131 u8 on[] = { 0x00, 0x71};
132 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
133
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134 struct saa7134_dev *dev = fe->dvb->priv;
135 struct v4l2_frequency f;
136
137 /* set frequency (mt2050) */
138 f.tuner = 0;
139 f.type = V4L2_TUNER_DIGITAL_TV;
140 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300141 if (fe->ops.i2c_gate_ctrl)
142 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300143 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300145 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300146 if (fe->ops.i2c_gate_ctrl)
147 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300148 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
150 pinnacle_antenna_pwr(dev, antenna_pwr);
151
152 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300153 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154}
155
Andrew de Quinceybd4956b2006-04-18 21:38:49 -0300156static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200157{
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300158 if (buf_len < 5)
159 return -EINVAL;
160
161 pllbuf[0] = 0x61;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200162 dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1,
163 params->frequency,
164 params->u.ofdm.bandwidth);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300165 return 5;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200166}
167
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168static struct mt352_config pinnacle_300i = {
169 .demod_address = 0x3c >> 1,
170 .adc_clock = 20333,
171 .if2 = 36150,
172 .no_tuner = 1,
173 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200175
176static struct mt352_config avermedia_777 = {
177 .demod_address = 0xf,
178 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200179};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180
181/* ------------------------------------------------------------------ */
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800182static int philips_tda6651_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700183{
184 struct saa7134_dev *dev = fe->dvb->priv;
185 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800186 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700187 sizeof(tuner_buf) };
188 int tuner_frequency = 0;
189 u8 band, cp, filter;
190
191 /* determine charge pump */
192 tuner_frequency = params->frequency + 36166000;
193 if (tuner_frequency < 87000000)
194 return -EINVAL;
195 else if (tuner_frequency < 130000000)
196 cp = 3;
197 else if (tuner_frequency < 160000000)
198 cp = 5;
199 else if (tuner_frequency < 200000000)
200 cp = 6;
201 else if (tuner_frequency < 290000000)
202 cp = 3;
203 else if (tuner_frequency < 420000000)
204 cp = 5;
205 else if (tuner_frequency < 480000000)
206 cp = 6;
207 else if (tuner_frequency < 620000000)
208 cp = 3;
209 else if (tuner_frequency < 830000000)
210 cp = 5;
211 else if (tuner_frequency < 895000000)
212 cp = 7;
213 else
214 return -EINVAL;
215
216 /* determine band */
217 if (params->frequency < 49000000)
218 return -EINVAL;
219 else if (params->frequency < 161000000)
220 band = 1;
221 else if (params->frequency < 444000000)
222 band = 2;
223 else if (params->frequency < 861000000)
224 band = 4;
225 else
226 return -EINVAL;
227
228 /* setup PLL filter */
229 switch (params->u.ofdm.bandwidth) {
230 case BANDWIDTH_6_MHZ:
231 filter = 0;
232 break;
233
234 case BANDWIDTH_7_MHZ:
235 filter = 0;
236 break;
237
238 case BANDWIDTH_8_MHZ:
239 filter = 1;
240 break;
241
242 default:
243 return -EINVAL;
244 }
245
246 /* calculate divisor
247 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
248 */
249 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
250
251 /* setup tuner buffer */
252 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
253 tuner_buf[1] = tuner_frequency & 0xff;
254 tuner_buf[2] = 0xca;
255 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
256
Patrick Boettcherdea74862006-05-14 05:01:31 -0300257 if (fe->ops.i2c_gate_ctrl)
258 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700259 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
260 return -EIO;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700261 msleep(1);
262 return 0;
263}
264
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800265static int philips_tda6651_pll_init(u8 addr, struct dvb_frontend *fe)
266{
267 struct saa7134_dev *dev = fe->dvb->priv;
268 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
269 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
270
271 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300272 if (fe->ops.i2c_gate_ctrl)
273 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800274 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
275 return -EIO;
276 msleep(1);
277
278 return 0;
279}
280
281/* ------------------------------------------------------------------ */
282
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300283static int philips_tu1216_tuner_60_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800284{
285 return philips_tda6651_pll_init(0x60, fe);
286}
287
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300288static int philips_tu1216_tuner_60_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800289{
290 return philips_tda6651_pll_set(0x60, fe, params);
291}
292
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700293static int philips_tu1216_request_firmware(struct dvb_frontend *fe,
294 const struct firmware **fw, char *name)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295{
296 struct saa7134_dev *dev = fe->dvb->priv;
297 return request_firmware(fw, name, &dev->pci->dev);
298}
299
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800300static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700301
302 .demod_address = 0x8,
303 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800304 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700305 .xtal_freq = TDA10046_XTAL_4M,
306 .agc_config = TDA10046_AGC_DEFAULT,
307 .if_freq = TDA10046_FREQ_3617,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700308 .request_firmware = philips_tu1216_request_firmware,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309};
310
311/* ------------------------------------------------------------------ */
312
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300313static int philips_tu1216_tuner_61_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800314{
315 return philips_tda6651_pll_init(0x61, fe);
316}
317
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300318static int philips_tu1216_tuner_61_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800319{
320 return philips_tda6651_pll_set(0x61, fe, params);
321}
322
323static struct tda1004x_config philips_tu1216_61_config = {
324
325 .demod_address = 0x8,
326 .invert = 1,
327 .invert_oclk = 0,
328 .xtal_freq = TDA10046_XTAL_4M,
329 .agc_config = TDA10046_AGC_DEFAULT,
330 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800331 .request_firmware = philips_tu1216_request_firmware,
332};
333
334/* ------------------------------------------------------------------ */
335
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300336static int philips_europa_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800337{
338 struct saa7134_dev *dev = fe->dvb->priv;
339 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
340 struct i2c_msg init_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
341
342 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300343 if (fe->ops.i2c_gate_ctrl)
344 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800345 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
346 return -EIO;
347 msleep(1);
348
349 /* switch the board to dvb mode */
350 init_msg.addr = 0x43;
351 init_msg.len = 0x02;
352 msg[0] = 0x00;
353 msg[1] = 0x40;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300354 if (fe->ops.i2c_gate_ctrl)
355 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800356 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
357 return -EIO;
358
359 return 0;
360}
361
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300362static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800363{
364 return philips_tda6651_pll_set(0x61, fe, params);
365}
366
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300367static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800368{
369 struct saa7134_dev *dev = fe->dvb->priv;
370 /* this message actually turns the tuner back to analog mode */
371 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
372 struct i2c_msg analog_msg = {.addr = 0x61,.flags = 0,.buf = msg,.len = sizeof(msg) };
373
374 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
375 msleep(1);
376
377 /* switch the board to analog mode */
378 analog_msg.addr = 0x43;
379 analog_msg.len = 0x02;
380 msg[0] = 0x00;
381 msg[1] = 0x14;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300382 if (fe->ops.i2c_gate_ctrl)
383 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800384 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300385 return 0;
386}
387
388static int philips_europa_demod_sleep(struct dvb_frontend *fe)
389{
390 struct saa7134_dev *dev = fe->dvb->priv;
391
392 if (dev->original_demod_sleep)
393 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300394 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300395 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800396}
397
398static struct tda1004x_config philips_europa_config = {
399
400 .demod_address = 0x8,
401 .invert = 0,
402 .invert_oclk = 0,
403 .xtal_freq = TDA10046_XTAL_4M,
404 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
405 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800406 .request_firmware = NULL,
407};
408
409/* ------------------------------------------------------------------ */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700410
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300411static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700412{
413 struct saa7134_dev *dev = fe->dvb->priv;
414 /* this message is to set up ATC and ALC */
415 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
416 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
417
Patrick Boettcherdea74862006-05-14 05:01:31 -0300418 if (fe->ops.i2c_gate_ctrl)
419 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700420 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
421 return -EIO;
422 msleep(1);
423
424 return 0;
425}
426
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300427static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700428{
429 struct saa7134_dev *dev = fe->dvb->priv;
430 /* this message actually turns the tuner back to analog mode */
431 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
432 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
433
Patrick Boettcherdea74862006-05-14 05:01:31 -0300434 if (fe->ops.i2c_gate_ctrl)
435 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700436 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
437 msleep(1);
438 fmd1216_init[2] = 0x86;
439 fmd1216_init[3] = 0x54;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300440 if (fe->ops.i2c_gate_ctrl)
441 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700442 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
443 msleep(1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300444 return 0;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700445}
446
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300447static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700448{
449 struct saa7134_dev *dev = fe->dvb->priv;
450 u8 tuner_buf[4];
451 struct i2c_msg tuner_msg = {.addr = 0x61,.flags = 0,.buf = tuner_buf,.len =
452 sizeof(tuner_buf) };
453 int tuner_frequency = 0;
454 int divider = 0;
455 u8 band, mode, cp;
456
457 /* determine charge pump */
458 tuner_frequency = params->frequency + 36130000;
459 if (tuner_frequency < 87000000)
460 return -EINVAL;
461 /* low band */
462 else if (tuner_frequency < 180000000) {
463 band = 1;
464 mode = 7;
465 cp = 0;
466 } else if (tuner_frequency < 195000000) {
467 band = 1;
468 mode = 6;
469 cp = 1;
470 /* mid band */
471 } else if (tuner_frequency < 366000000) {
472 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
473 band = 10;
474 } else {
475 band = 2;
476 }
477 mode = 7;
478 cp = 0;
479 } else if (tuner_frequency < 478000000) {
480 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
481 band = 10;
482 } else {
483 band = 2;
484 }
485 mode = 6;
486 cp = 1;
487 /* high band */
488 } else if (tuner_frequency < 662000000) {
489 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
490 band = 12;
491 } else {
492 band = 4;
493 }
494 mode = 7;
495 cp = 0;
496 } else if (tuner_frequency < 840000000) {
497 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
498 band = 12;
499 } else {
500 band = 4;
501 }
502 mode = 6;
503 cp = 1;
504 } else {
505 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
506 band = 12;
507 } else {
508 band = 4;
509 }
510 mode = 7;
511 cp = 1;
512
513 }
514 /* calculate divisor */
515 /* ((36166000 + Finput) / 166666) rounded! */
516 divider = (tuner_frequency + 83333) / 166667;
517
518 /* setup tuner buffer */
519 tuner_buf[0] = (divider >> 8) & 0x7f;
520 tuner_buf[1] = divider & 0xff;
521 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
522 tuner_buf[3] = 0x40 | band;
523
Patrick Boettcherdea74862006-05-14 05:01:31 -0300524 if (fe->ops.i2c_gate_ctrl)
525 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700526 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
527 return -EIO;
528 return 0;
529}
530
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700531static struct tda1004x_config medion_cardbus = {
532 .demod_address = 0x08,
533 .invert = 1,
534 .invert_oclk = 0,
535 .xtal_freq = TDA10046_XTAL_16M,
536 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
537 .if_freq = TDA10046_FREQ_3613,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700538 .request_firmware = NULL,
539};
540
541/* ------------------------------------------------------------------ */
542
543struct tda827x_data {
544 u32 lomax;
545 u8 spd;
546 u8 bs;
547 u8 bp;
548 u8 cp;
549 u8 gc3;
550 u8 div1p5;
551};
552
553static struct tda827x_data tda827x_dvbt[] = {
554 { .lomax = 62000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
555 { .lomax = 66000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 1},
556 { .lomax = 76000000, .spd = 3, .bs = 1, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
557 { .lomax = 84000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 3, .div1p5 = 0},
558 { .lomax = 93000000, .spd = 3, .bs = 2, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
559 { .lomax = 98000000, .spd = 3, .bs = 3, .bp = 0, .cp = 0, .gc3 = 1, .div1p5 = 0},
560 { .lomax = 109000000, .spd = 3, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
561 { .lomax = 123000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
562 { .lomax = 133000000, .spd = 2, .bs = 3, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 1},
563 { .lomax = 151000000, .spd = 2, .bs = 1, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
564 { .lomax = 154000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 1, .div1p5 = 0},
565 { .lomax = 181000000, .spd = 2, .bs = 2, .bp = 1, .cp = 0, .gc3 = 0, .div1p5 = 0},
566 { .lomax = 185000000, .spd = 2, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
567 { .lomax = 217000000, .spd = 2, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
568 { .lomax = 244000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
569 { .lomax = 265000000, .spd = 1, .bs = 3, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 1},
570 { .lomax = 302000000, .spd = 1, .bs = 1, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
571 { .lomax = 324000000, .spd = 1, .bs = 2, .bp = 2, .cp = 0, .gc3 = 1, .div1p5 = 0},
572 { .lomax = 370000000, .spd = 1, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
573 { .lomax = 454000000, .spd = 1, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
574 { .lomax = 493000000, .spd = 0, .bs = 2, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
575 { .lomax = 530000000, .spd = 0, .bs = 3, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 1},
576 { .lomax = 554000000, .spd = 0, .bs = 1, .bp = 3, .cp = 0, .gc3 = 1, .div1p5 = 0},
577 { .lomax = 604000000, .spd = 0, .bs = 1, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
578 { .lomax = 696000000, .spd = 0, .bs = 2, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
579 { .lomax = 740000000, .spd = 0, .bs = 2, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
580 { .lomax = 820000000, .spd = 0, .bs = 3, .bp = 4, .cp = 0, .gc3 = 0, .div1p5 = 0},
581 { .lomax = 865000000, .spd = 0, .bs = 3, .bp = 4, .cp = 1, .gc3 = 0, .div1p5 = 0},
582 { .lomax = 0, .spd = 0, .bs = 0, .bp = 0, .cp = 0, .gc3 = 0, .div1p5 = 0}
583};
584
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300585static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700586{
587 return 0;
588}
589
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300590static int philips_tda827x_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700591{
592 struct saa7134_dev *dev = fe->dvb->priv;
593 u8 tuner_buf[14];
594
595 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tuner_buf,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800596 .len = sizeof(tuner_buf) };
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700597 int i, tuner_freq, if_freq;
598 u32 N;
599 switch (params->u.ofdm.bandwidth) {
600 case BANDWIDTH_6_MHZ:
601 if_freq = 4000000;
602 break;
603 case BANDWIDTH_7_MHZ:
604 if_freq = 4500000;
605 break;
606 default: /* 8 MHz or Auto */
607 if_freq = 5000000;
608 break;
609 }
610 tuner_freq = params->frequency + if_freq;
611
612 i = 0;
613 while (tda827x_dvbt[i].lomax < tuner_freq) {
614 if(tda827x_dvbt[i + 1].lomax == 0)
615 break;
616 i++;
617 }
618
619 N = ((tuner_freq + 125000) / 250000) << (tda827x_dvbt[i].spd + 2);
620 tuner_buf[0] = 0;
621 tuner_buf[1] = (N>>8) | 0x40;
622 tuner_buf[2] = N & 0xff;
623 tuner_buf[3] = 0;
624 tuner_buf[4] = 0x52;
625 tuner_buf[5] = (tda827x_dvbt[i].spd << 6) + (tda827x_dvbt[i].div1p5 << 5) +
626 (tda827x_dvbt[i].bs << 3) + tda827x_dvbt[i].bp;
627 tuner_buf[6] = (tda827x_dvbt[i].gc3 << 4) + 0x8f;
628 tuner_buf[7] = 0xbf;
629 tuner_buf[8] = 0x2a;
630 tuner_buf[9] = 0x05;
631 tuner_buf[10] = 0xff;
632 tuner_buf[11] = 0x00;
633 tuner_buf[12] = 0x00;
634 tuner_buf[13] = 0x40;
635
636 tuner_msg.len = 14;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300637 if (fe->ops.i2c_gate_ctrl)
638 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700639 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
640 return -EIO;
641
642 msleep(500);
643 /* correct CP value */
644 tuner_buf[0] = 0x30;
645 tuner_buf[1] = 0x50 + tda827x_dvbt[i].cp;
646 tuner_msg.len = 2;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300647 if (fe->ops.i2c_gate_ctrl)
648 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700649 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
650
651 return 0;
652}
653
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300654static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700655{
656 struct saa7134_dev *dev = fe->dvb->priv;
657 static u8 tda827x_sleep[] = { 0x30, 0xd0};
658 struct i2c_msg tuner_msg = {.addr = 0x60,.flags = 0,.buf = tda827x_sleep,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800659 .len = sizeof(tda827x_sleep) };
Patrick Boettcherdea74862006-05-14 05:01:31 -0300660 if (fe->ops.i2c_gate_ctrl)
661 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700662 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300663 return 0;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700664}
665
666static struct tda1004x_config tda827x_lifeview_config = {
667 .demod_address = 0x08,
668 .invert = 1,
669 .invert_oclk = 0,
670 .xtal_freq = TDA10046_XTAL_16M,
671 .agc_config = TDA10046_AGC_TDA827X,
672 .if_freq = TDA10046_FREQ_045,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700673 .request_firmware = NULL,
674};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800675
676/* ------------------------------------------------------------------ */
677
678struct tda827xa_data {
679 u32 lomax;
680 u8 svco;
681 u8 spd;
682 u8 scr;
683 u8 sbs;
684 u8 gc3;
685};
686
687static struct tda827xa_data tda827xa_dvbt[] = {
688 { .lomax = 56875000, .svco = 3, .spd = 4, .scr = 0, .sbs = 0, .gc3 = 1},
689 { .lomax = 67250000, .svco = 0, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
690 { .lomax = 81250000, .svco = 1, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
691 { .lomax = 97500000, .svco = 2, .spd = 3, .scr = 0, .sbs = 0, .gc3 = 1},
692 { .lomax = 113750000, .svco = 3, .spd = 3, .scr = 0, .sbs = 1, .gc3 = 1},
693 { .lomax = 134500000, .svco = 0, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
694 { .lomax = 154000000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
695 { .lomax = 162500000, .svco = 1, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
696 { .lomax = 183000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 1, .gc3 = 1},
697 { .lomax = 195000000, .svco = 2, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
698 { .lomax = 227500000, .svco = 3, .spd = 2, .scr = 0, .sbs = 2, .gc3 = 1},
699 { .lomax = 269000000, .svco = 0, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
700 { .lomax = 290000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 2, .gc3 = 1},
701 { .lomax = 325000000, .svco = 1, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
702 { .lomax = 390000000, .svco = 2, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
703 { .lomax = 455000000, .svco = 3, .spd = 1, .scr = 0, .sbs = 3, .gc3 = 1},
704 { .lomax = 520000000, .svco = 0, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
705 { .lomax = 538000000, .svco = 0, .spd = 0, .scr = 1, .sbs = 3, .gc3 = 1},
706 { .lomax = 550000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 3, .gc3 = 1},
707 { .lomax = 620000000, .svco = 1, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
708 { .lomax = 650000000, .svco = 1, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
709 { .lomax = 700000000, .svco = 2, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
710 { .lomax = 780000000, .svco = 2, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
711 { .lomax = 820000000, .svco = 3, .spd = 0, .scr = 0, .sbs = 4, .gc3 = 0},
712 { .lomax = 870000000, .svco = 3, .spd = 0, .scr = 1, .sbs = 4, .gc3 = 0},
713 { .lomax = 911000000, .svco = 3, .spd = 0, .scr = 2, .sbs = 4, .gc3 = 0},
714 { .lomax = 0, .svco = 0, .spd = 0, .scr = 0, .sbs = 0, .gc3 = 0}};
715
716
717static int philips_tda827xa_pll_set(u8 addr, struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
718{
719 struct saa7134_dev *dev = fe->dvb->priv;
720 u8 tuner_buf[14];
721 unsigned char reg2[2];
722
723 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = tuner_buf};
724 int i, tuner_freq, if_freq;
725 u32 N;
726
727 switch (params->u.ofdm.bandwidth) {
728 case BANDWIDTH_6_MHZ:
729 if_freq = 4000000;
730 break;
731 case BANDWIDTH_7_MHZ:
732 if_freq = 4500000;
733 break;
734 default: /* 8 MHz or Auto */
735 if_freq = 5000000;
736 break;
737 }
738 tuner_freq = params->frequency + if_freq;
739
740 i = 0;
741 while (tda827xa_dvbt[i].lomax < tuner_freq) {
742 if(tda827xa_dvbt[i + 1].lomax == 0)
743 break;
744 i++;
745 }
746
747 N = ((tuner_freq + 31250) / 62500) << tda827xa_dvbt[i].spd;
748 tuner_buf[0] = 0; // subaddress
749 tuner_buf[1] = N >> 8;
750 tuner_buf[2] = N & 0xff;
751 tuner_buf[3] = 0;
752 tuner_buf[4] = 0x16;
753 tuner_buf[5] = (tda827xa_dvbt[i].spd << 5) + (tda827xa_dvbt[i].svco << 3) +
754 tda827xa_dvbt[i].sbs;
755 tuner_buf[6] = 0x4b + (tda827xa_dvbt[i].gc3 << 4);
756 tuner_buf[7] = 0x0c;
757 tuner_buf[8] = 0x06;
758 tuner_buf[9] = 0x24;
759 tuner_buf[10] = 0xff;
760 tuner_buf[11] = 0x60;
761 tuner_buf[12] = 0x00;
762 tuner_buf[13] = 0x39; // lpsel
763 msg.len = 14;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300764 if (fe->ops.i2c_gate_ctrl)
765 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800766 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
767 return -EIO;
768
769 msg.buf= reg2;
770 msg.len = 2;
771 reg2[0] = 0x60;
772 reg2[1] = 0x3c;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300773 if (fe->ops.i2c_gate_ctrl)
774 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800775 i2c_transfer(&dev->i2c_adap, &msg, 1);
776
777 reg2[0] = 0xa0;
778 reg2[1] = 0x40;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300779 if (fe->ops.i2c_gate_ctrl)
780 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800781 i2c_transfer(&dev->i2c_adap, &msg, 1);
782
783 msleep(2);
784 /* correct CP value */
785 reg2[0] = 0x30;
786 reg2[1] = 0x10 + tda827xa_dvbt[i].scr;
787 msg.len = 2;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300788 if (fe->ops.i2c_gate_ctrl)
789 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800790 i2c_transfer(&dev->i2c_adap, &msg, 1);
791
792 msleep(550);
793 reg2[0] = 0x50;
794 reg2[1] = 0x4f + (tda827xa_dvbt[i].gc3 << 4);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300795 if (fe->ops.i2c_gate_ctrl)
796 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800797 i2c_transfer(&dev->i2c_adap, &msg, 1);
798
799 return 0;
800
801}
802
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300803static int philips_tda827xa_tuner_sleep(u8 addr, struct dvb_frontend *fe)
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800804{
805 struct saa7134_dev *dev = fe->dvb->priv;
806 static u8 tda827xa_sleep[] = { 0x30, 0x90};
807 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tda827xa_sleep,
Tyler Traffordf1bcef82005-11-08 21:38:46 -0800808 .len = sizeof(tda827xa_sleep) };
Patrick Boettcherdea74862006-05-14 05:01:31 -0300809 if (fe->ops.i2c_gate_ctrl)
810 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800811 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300812 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800813}
814
815/* ------------------------------------------------------------------ */
816
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300817static int philips_tiger_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800818{
819 int ret;
820 struct saa7134_dev *dev = fe->dvb->priv;
821 static u8 tda8290_close[] = { 0x21, 0xc0};
822 static u8 tda8290_open[] = { 0x21, 0x80};
823 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300824
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800825 /* close tda8290 i2c bridge */
826 tda8290_msg.buf = tda8290_close;
827 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
828 if (ret != 1)
829 return -EIO;
830 msleep(20);
831 ret = philips_tda827xa_pll_set(0x61, fe, params);
832 if (ret != 0)
833 return ret;
834 /* open tda8290 i2c bridge */
835 tda8290_msg.buf = tda8290_open;
836 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
837 return ret;
Hartmut Hackmann2d6b5f62006-02-27 21:14:36 -0300838}
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800839
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300840static int philips_tiger_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800841{
842 struct saa7134_dev *dev = fe->dvb->priv;
843 static u8 data[] = { 0x3c, 0x33, 0x6a};
844 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
845
846 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1)
847 return -EIO;
848 return 0;
849}
850
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300851static int philips_tiger_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800852{
853 struct saa7134_dev *dev = fe->dvb->priv;
854 static u8 data[] = { 0x3c, 0x33, 0x68};
855 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
856
857 i2c_transfer(&dev->i2c_adap, &msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300858 philips_tda827xa_tuner_sleep( 0x61, fe);
859 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800860}
861
862static struct tda1004x_config philips_tiger_config = {
863 .demod_address = 0x08,
864 .invert = 1,
865 .invert_oclk = 0,
866 .xtal_freq = TDA10046_XTAL_16M,
867 .agc_config = TDA10046_AGC_TDA827X,
868 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800869 .request_firmware = NULL,
870};
871
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200872/* ------------------------------------------------------------------ */
873
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300874static int lifeview_trio_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Nico Sabbi420f32f2006-03-03 12:11:28 -0300875{
876 int ret;
877
878 ret = philips_tda827xa_pll_set(0x60, fe, params);
879 return ret;
880}
881
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300882static int lifeview_trio_tuner_sleep(struct dvb_frontend *fe)
Nico Sabbi420f32f2006-03-03 12:11:28 -0300883{
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300884 philips_tda827xa_tuner_sleep(0x60, fe);
Nico Sabbi420f32f2006-03-03 12:11:28 -0300885 return 0;
886}
887
Nico Sabbi420f32f2006-03-03 12:11:28 -0300888static struct tda1004x_config lifeview_trio_config = {
889 .demod_address = 0x09,
890 .invert = 1,
891 .invert_oclk = 0,
892 .xtal_freq = TDA10046_XTAL_16M,
893 .agc_config = TDA10046_AGC_TDA827X_GPL,
894 .if_freq = TDA10046_FREQ_045,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300895 .request_firmware = NULL,
896};
897
898/* ------------------------------------------------------------------ */
899
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300900static int ads_duo_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200901{
902 int ret;
903
904 ret = philips_tda827xa_pll_set(0x61, fe, params);
905 return ret;
Hartmut Hackmann2d6b5f62006-02-27 21:14:36 -0300906}
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200907
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300908static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200909{
910 struct saa7134_dev *dev = fe->dvb->priv;
911 /* route TDA8275a AGC input to the channel decoder */
912 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x60);
913 return 0;
914}
915
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300916static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200917{
918 struct saa7134_dev *dev = fe->dvb->priv;
919 /* route TDA8275a AGC input to the analog IF chip*/
920 saa_writeb(SAA7134_GPIO_GPSTATUS2, 0x20);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300921 philips_tda827xa_tuner_sleep( 0x61, fe);
922 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200923}
924
925static struct tda1004x_config ads_tech_duo_config = {
926 .demod_address = 0x08,
927 .invert = 1,
928 .invert_oclk = 0,
929 .xtal_freq = TDA10046_XTAL_16M,
930 .agc_config = TDA10046_AGC_TDA827X_GPL,
931 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200932 .request_firmware = NULL,
933};
934
Peter Hartshorn3dfb7292006-02-07 06:49:13 -0200935/* ------------------------------------------------------------------ */
936
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300937static int tevion_dvb220rf_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Peter Hartshorn3dfb7292006-02-07 06:49:13 -0200938{
939 int ret;
940 ret = philips_tda827xa_pll_set(0x60, fe, params);
941 return ret;
942}
943
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300944static int tevion_dvb220rf_tuner_sleep(struct dvb_frontend *fe)
Peter Hartshorn3dfb7292006-02-07 06:49:13 -0200945{
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300946 philips_tda827xa_tuner_sleep( 0x61, fe);
Peter Hartshorn3dfb7292006-02-07 06:49:13 -0200947 return 0;
948}
949
Peter Hartshorn3dfb7292006-02-07 06:49:13 -0200950static struct tda1004x_config tevion_dvbt220rf_config = {
951 .demod_address = 0x08,
952 .invert = 1,
953 .invert_oclk = 0,
954 .xtal_freq = TDA10046_XTAL_16M,
955 .agc_config = TDA10046_AGC_TDA827X,
956 .if_freq = TDA10046_FREQ_045,
Peter Hartshorn3dfb7292006-02-07 06:49:13 -0200957 .request_firmware = NULL,
958};
959
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300960/* ------------------------------------------------------------------ */
961
962static int md8800_dvbt_analog_mode(struct dvb_frontend *fe)
963{
964 struct saa7134_dev *dev = fe->dvb->priv;
965 static u8 data[] = { 0x3c, 0x33, 0x68};
966 struct i2c_msg msg = {.addr=0x08, .flags=0, .buf=data, .len = sizeof(data)};
967
968 i2c_transfer(&dev->i2c_adap, &msg, 1);
969 philips_tda827xa_tuner_sleep( 0x61, fe);
970 return 0;
971}
972
973static int md8800_dvbt_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
974{
975 int ret;
976 struct saa7134_dev *dev = fe->dvb->priv;
977 static u8 tda8290_close[] = { 0x21, 0xc0};
978 static u8 tda8290_open[] = { 0x21, 0x80};
979 struct i2c_msg tda8290_msg = {.addr = 0x4b,.flags = 0, .len = 2};
980 /* close tda8290 i2c bridge */
981 tda8290_msg.buf = tda8290_close;
982 ret = i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
983 if (ret != 1)
984 return -EIO;
985 msleep(20);
986 ret = philips_tda827xa_pll_set(0x60, fe, params);
987 if (ret != 0)
988 return ret;
989 /* open tda8290 i2c bridge */
990 tda8290_msg.buf = tda8290_open;
991 i2c_transfer(&dev->i2c_adap, &tda8290_msg, 1);
992 return ret;
993}
994
995static struct tda1004x_config md8800_dvbt_config = {
996 .demod_address = 0x08,
997 .invert = 1,
998 .invert_oclk = 0,
999 .xtal_freq = TDA10046_XTAL_16M,
1000 .agc_config = TDA10046_AGC_TDA827X,
1001 .if_freq = TDA10046_FREQ_045,
1002 .request_firmware = NULL,
1003};
1004
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001005/* ------------------------------------------------------------------ */
1006
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001007static struct nxt200x_config avertvhda180 = {
1008 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001009};
Andrew Burri3e1410a2006-02-27 00:08:23 -03001010
Curt Meyersfbc81c02006-02-27 00:08:27 -03001011static int nxt200x_set_pll_input(u8 *buf, int input)
1012{
1013 if (input)
1014 buf[3] |= 0x08;
1015 else
1016 buf[3] &= ~0x08;
1017 return 0;
1018}
1019
Andrew Burri3e1410a2006-02-27 00:08:23 -03001020static struct nxt200x_config kworldatsc110 = {
1021 .demod_address = 0x0a,
Curt Meyersfbc81c02006-02-27 00:08:27 -03001022 .set_pll_input = nxt200x_set_pll_input,
Andrew Burri3e1410a2006-02-27 00:08:23 -03001023};
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001024
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001025/* ------------------------------------------------------------------ */
1026
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027static int dvb_init(struct saa7134_dev *dev)
1028{
1029 /* init struct videobuf_dvb */
1030 dev->ts.nr_bufs = 32;
1031 dev->ts.nr_packets = 32*4;
1032 dev->dvb.name = dev->name;
1033 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
1034 dev->pci, &dev->slock,
1035 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1036 V4L2_FIELD_ALTERNATE,
1037 sizeof(struct saa7134_buf),
1038 dev);
1039
1040 switch (dev->board) {
1041 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1042 printk("%s: pinnacle 300i dvb setup\n",dev->name);
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001043 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001045 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001046 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001047 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001049 case SAA7134_BOARD_AVERMEDIA_777:
1050 printk("%s: avertv 777 dvb setup\n",dev->name);
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001051 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001052 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001053 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001054 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001055 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001056 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057 case SAA7134_BOARD_MD7134:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001058 dev->dvb.frontend = dvb_attach(tda10046_attach, &medion_cardbus,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001060 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001061 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1062 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1063 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001064 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001066 case SAA7134_BOARD_PHILIPS_TOUGH:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001067 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_tu1216_60_config,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001068 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001069 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001070 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_60_init;
1071 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_60_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001072 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001073 break;
1074 case SAA7134_BOARD_FLYDVBTDUO:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001075 dev->dvb.frontend = dvb_attach(tda10046_attach, &tda827x_lifeview_config,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001076 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001077 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001078 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1079 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1080 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001081 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001082 break;
Peter Missel10b7a902006-01-23 17:11:06 -02001083 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001084 dev->dvb.frontend = dvb_attach(tda10046_attach, &tda827x_lifeview_config,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001085 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001086 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001087 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1088 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1089 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001090 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001091 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001092 case SAA7134_BOARD_PHILIPS_EUROPA:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001093 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_europa_config,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001094 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001095 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001096 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1097 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1098 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1099 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1100 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001101 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001102 break;
1103 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001104 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_europa_config,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001105 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001106 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001107 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1108 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1109 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001110 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001111 break;
1112 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001113 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_tu1216_61_config,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001114 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001115 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001116 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_tuner_61_init;
1117 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tu1216_tuner_61_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001118 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001119 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001120 case SAA7134_BOARD_PHILIPS_TIGER:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001121 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_tiger_config,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001122 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001123 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001124 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1125 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1126 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001127 }
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001128 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001129 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001130 dev->dvb.frontend = dvb_attach(tda10046_attach, &philips_tiger_config,
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001131 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001132 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001133 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1134 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tiger_tuner_sleep;
1135 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tiger_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001136 }
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001137 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001138 case SAA7134_BOARD_FLYDVBT_LR301:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001139 dev->dvb.frontend = dvb_attach(tda10046_attach, &tda827x_lifeview_config,
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001140 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001141 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001142 dev->dvb.frontend->ops.tuner_ops.init = philips_tda827x_tuner_init;
1143 dev->dvb.frontend->ops.tuner_ops.sleep = philips_tda827x_tuner_sleep;
1144 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda827x_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001145 }
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001146 break;
Nico Sabbi420f32f2006-03-03 12:11:28 -03001147 case SAA7134_BOARD_FLYDVB_TRIO:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001148 dev->dvb.frontend = dvb_attach(tda10046_attach, &lifeview_trio_config,
Nico Sabbi420f32f2006-03-03 12:11:28 -03001149 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001150 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001151 dev->dvb.frontend->ops.tuner_ops.sleep = lifeview_trio_tuner_sleep;
1152 dev->dvb.frontend->ops.tuner_ops.set_params = lifeview_trio_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001153 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001154 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001155 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001156 dev->dvb.frontend = dvb_attach(tda10046_attach, &ads_tech_duo_config,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001157 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001158 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001159 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1160 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1161 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001162 }
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001163 break;
Peter Hartshorn3dfb7292006-02-07 06:49:13 -02001164 case SAA7134_BOARD_TEVION_DVBT_220RF:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001165 dev->dvb.frontend = dvb_attach(tda10046_attach, &tevion_dvbt220rf_config,
Peter Hartshorn3dfb7292006-02-07 06:49:13 -02001166 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001167 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001168 dev->dvb.frontend->ops.tuner_ops.sleep = tevion_dvb220rf_tuner_sleep;
1169 dev->dvb.frontend->ops.tuner_ops.set_params = tevion_dvb220rf_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001170 }
Peter Hartshorn3dfb7292006-02-07 06:49:13 -02001171 break;
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001172 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001173 dev->dvb.frontend = dvb_attach(tda10046_attach, &ads_tech_duo_config,
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001174 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001175 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001176 dev->dvb.frontend->ops.tuner_ops.init = ads_duo_tuner_init;
1177 dev->dvb.frontend->ops.tuner_ops.sleep = ads_duo_tuner_sleep;
1178 dev->dvb.frontend->ops.tuner_ops.set_params = ads_duo_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001179 }
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001180 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001181 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
1182 dev->dvb.frontend = tda10046_attach(&md8800_dvbt_config,
1183 &dev->i2c_adap);
1184 if (dev->dvb.frontend) {
1185 dev->dvb.frontend->ops.tuner_ops.init = philips_tiger_tuner_init;
1186 dev->dvb.frontend->ops.tuner_ops.sleep = md8800_dvbt_analog_mode;
1187 dev->dvb.frontend->ops.tuner_ops.set_params = md8800_dvbt_pll_set;
1188 }
1189 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001190 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001191 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180, &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001192 if (dev->dvb.frontend) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001193 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tdhu2);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001194 }
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001195 break;
Andrew Burri3e1410a2006-02-27 00:08:23 -03001196 case SAA7134_BOARD_KWORLD_ATSC110:
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001197 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110, &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001198 if (dev->dvb.frontend) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -03001199 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61, &dev->i2c_adap, &dvb_pll_tuv1236d);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001200 }
Andrew Burri3e1410a2006-02-27 00:08:23 -03001201 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 default:
1203 printk("%s: Huh? unknown DVB card?\n",dev->name);
1204 break;
1205 }
1206
1207 if (NULL == dev->dvb.frontend) {
1208 printk("%s: frontend initialization failed\n",dev->name);
1209 return -1;
1210 }
1211
1212 /* register everything else */
Andrew de Quinceyd09dbf92006-04-10 09:27:37 -03001213 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001214}
1215
1216static int dvb_fini(struct saa7134_dev *dev)
1217{
1218 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1219
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 switch (dev->board) {
1221 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1222 /* otherwise we don't detect the tuner on next insmod */
1223 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1224 break;
1225 };
1226 videobuf_dvb_unregister(&dev->dvb);
1227 return 0;
1228}
1229
1230static struct saa7134_mpeg_ops dvb_ops = {
1231 .type = SAA7134_MPEG_DVB,
1232 .init = dvb_init,
1233 .fini = dvb_fini,
1234};
1235
1236static int __init dvb_register(void)
1237{
1238 return saa7134_ts_register(&dvb_ops);
1239}
1240
1241static void __exit dvb_unregister(void)
1242{
1243 saa7134_ts_unregister(&dvb_ops);
1244}
1245
1246module_init(dvb_register);
1247module_exit(dvb_unregister);
1248
1249/* ------------------------------------------------------------------ */
1250/*
1251 * Local variables:
1252 * c-basic-offset: 8
1253 * End:
1254 */