blob: 4eff1ca8593cd9398fd15ce06d2e0c02ddf71d09 [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"
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -030036#include <dvb_frontend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030038#include "mt352.h"
39#include "mt352_priv.h" /* FIXME */
40#include "tda1004x.h"
41#include "nxt200x.h"
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -030042#include "tuner-xc2028.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030044#include "tda10086.h"
45#include "tda826x.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030046#include "tda827x.h"
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030047#include "isl6421.h"
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -030048#include "isl6405.h"
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -030049#include "lnbp21.h"
Michael Krufkycb89cd332008-04-22 14:46:16 -030050#include "tuner-simple.h"
Michael Krufky3abdedd2009-01-19 01:10:49 -030051#include "tda18271.h"
52#include "lgdt3305.h"
53#include "tda8290.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030054
Dmitri Belimov47aeba52008-12-23 03:53:03 -030055#include "zl10353.h"
56
Matthias Schwarzott04574182009-02-24 12:35:16 -030057#include "zl10036.h"
58#include "mt312.h"
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
61MODULE_LICENSE("GPL");
62
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030063static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070064
Linus Torvalds1da177e2005-04-16 15:20:36 -070065module_param(antenna_pwr, int, 0444);
66MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
67
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030068static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030069module_param(use_frontend, int, 0644);
70MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030071
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030072static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030073module_param(debug, int, 0644);
74MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
75
Janne Grunau78e92002008-04-09 19:13:13 -030076DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
77
Trent Piephocf3c34c2007-03-07 18:19:48 -030078#define dprintk(fmt, arg...) do { if (debug) \
79 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
80
81/* Print a warning */
82#define wprintk(fmt, arg...) \
83 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030084
85/* ------------------------------------------------------------------
86 * mt352 based DVB-T cards
87 */
88
Linus Torvalds1da177e2005-04-16 15:20:36 -070089static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
90{
91 u32 ok;
92
93 if (!on) {
94 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
95 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
96 return 0;
97 }
98
99 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
100 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
101 udelay(10);
102
103 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
104 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
105 udelay(10);
106 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
107 udelay(10);
108 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300109 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
111 if (!ok)
112 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
113 return ok;
114}
115
116static int mt352_pinnacle_init(struct dvb_frontend* fe)
117{
118 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
119 static u8 reset [] = { RESET, 0x80 };
120 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
121 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
122 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
123 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
124 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
125 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
126 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
127 struct saa7134_dev *dev= fe->dvb->priv;
128
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300129 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
131 mt352_write(fe, clock_config, sizeof(clock_config));
132 udelay(200);
133 mt352_write(fe, reset, sizeof(reset));
134 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
135 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
136 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
137 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
138
139 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
140 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
141 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 return 0;
144}
145
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200146static int mt352_aver777_init(struct dvb_frontend* fe)
147{
148 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
149 static u8 reset [] = { RESET, 0x80 };
150 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
151 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
152 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
153
154 mt352_write(fe, clock_config, sizeof(clock_config));
155 udelay(200);
156 mt352_write(fe, reset, sizeof(reset));
157 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
158 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
159 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
160
161 return 0;
162}
163
Tim Farrington6e501a32008-06-15 13:33:42 -0300164static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300165{
Tim Farrington6e501a32008-06-15 13:33:42 -0300166 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
167 static u8 reset [] = { RESET, 0x80 };
168 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
169 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300170 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
171
172 mt352_write(fe, clock_config, sizeof(clock_config));
173 udelay(200);
174 mt352_write(fe, reset, sizeof(reset));
175 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
176 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
177 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300178 return 0;
179}
180
Andrew de Quincey0463f122006-05-16 17:22:02 -0300181static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
182 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300184 u8 off[] = { 0x00, 0xf1};
185 u8 on[] = { 0x00, 0x71};
186 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
187
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 struct saa7134_dev *dev = fe->dvb->priv;
189 struct v4l2_frequency f;
190
191 /* set frequency (mt2050) */
192 f.tuner = 0;
193 f.type = V4L2_TUNER_DIGITAL_TV;
194 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300195 if (fe->ops.i2c_gate_ctrl)
196 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300197 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300198 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300199 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300200 if (fe->ops.i2c_gate_ctrl)
201 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300202 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
204 pinnacle_antenna_pwr(dev, antenna_pwr);
205
206 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300207 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208}
209
210static struct mt352_config pinnacle_300i = {
211 .demod_address = 0x3c >> 1,
212 .adc_clock = 20333,
213 .if2 = 36150,
214 .no_tuner = 1,
215 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200217
218static struct mt352_config avermedia_777 = {
219 .demod_address = 0xf,
220 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200221};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
Tim Farrington6e501a32008-06-15 13:33:42 -0300223static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300224 .demod_address = (0x1e >> 1),
225 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300226 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300227};
228
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300229/* ==================================================================
230 * tda1004x based DVB-T cards, helper functions
231 */
232
233static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
234 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700235{
236 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300237 return request_firmware(fw, name, &dev->pci->dev);
238}
239
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300240/* ------------------------------------------------------------------
241 * these tuners are tu1216, td1316(a)
242 */
243
244static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
245{
246 struct saa7134_dev *dev = fe->dvb->priv;
247 struct tda1004x_state *state = fe->demodulator_priv;
248 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700249 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800250 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700251 sizeof(tuner_buf) };
252 int tuner_frequency = 0;
253 u8 band, cp, filter;
254
255 /* determine charge pump */
256 tuner_frequency = params->frequency + 36166000;
257 if (tuner_frequency < 87000000)
258 return -EINVAL;
259 else if (tuner_frequency < 130000000)
260 cp = 3;
261 else if (tuner_frequency < 160000000)
262 cp = 5;
263 else if (tuner_frequency < 200000000)
264 cp = 6;
265 else if (tuner_frequency < 290000000)
266 cp = 3;
267 else if (tuner_frequency < 420000000)
268 cp = 5;
269 else if (tuner_frequency < 480000000)
270 cp = 6;
271 else if (tuner_frequency < 620000000)
272 cp = 3;
273 else if (tuner_frequency < 830000000)
274 cp = 5;
275 else if (tuner_frequency < 895000000)
276 cp = 7;
277 else
278 return -EINVAL;
279
280 /* determine band */
281 if (params->frequency < 49000000)
282 return -EINVAL;
283 else if (params->frequency < 161000000)
284 band = 1;
285 else if (params->frequency < 444000000)
286 band = 2;
287 else if (params->frequency < 861000000)
288 band = 4;
289 else
290 return -EINVAL;
291
292 /* setup PLL filter */
293 switch (params->u.ofdm.bandwidth) {
294 case BANDWIDTH_6_MHZ:
295 filter = 0;
296 break;
297
298 case BANDWIDTH_7_MHZ:
299 filter = 0;
300 break;
301
302 case BANDWIDTH_8_MHZ:
303 filter = 1;
304 break;
305
306 default:
307 return -EINVAL;
308 }
309
310 /* calculate divisor
311 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
312 */
313 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
314
315 /* setup tuner buffer */
316 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
317 tuner_buf[1] = tuner_frequency & 0xff;
318 tuner_buf[2] = 0xca;
319 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
320
Patrick Boettcherdea74862006-05-14 05:01:31 -0300321 if (fe->ops.i2c_gate_ctrl)
322 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300323 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300324 wprintk("could not write to tuner at addr: 0x%02x\n",
325 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700326 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300327 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700328 msleep(1);
329 return 0;
330}
331
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300332static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800333{
334 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300335 struct tda1004x_state *state = fe->demodulator_priv;
336 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800337 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
338 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
339
340 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300341 if (fe->ops.i2c_gate_ctrl)
342 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800343 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
344 return -EIO;
345 msleep(1);
346
347 return 0;
348}
349
350/* ------------------------------------------------------------------ */
351
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800352static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700353 .demod_address = 0x8,
354 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800355 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700356 .xtal_freq = TDA10046_XTAL_4M,
357 .agc_config = TDA10046_AGC_DEFAULT,
358 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300359 .tuner_address = 0x60,
360 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361};
362
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800363static struct tda1004x_config philips_tu1216_61_config = {
364
365 .demod_address = 0x8,
366 .invert = 1,
367 .invert_oclk = 0,
368 .xtal_freq = TDA10046_XTAL_4M,
369 .agc_config = TDA10046_AGC_DEFAULT,
370 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300371 .tuner_address = 0x61,
372 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800373};
374
375/* ------------------------------------------------------------------ */
376
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300377static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800378{
379 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300380 struct tda1004x_state *state = fe->demodulator_priv;
381 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800382 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300383 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800384
385 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300386 if (fe->ops.i2c_gate_ctrl)
387 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800388 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
389 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800390 return 0;
391}
392
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300393static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800394{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300395 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800396}
397
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300398static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
399{
400 struct saa7134_dev *dev = fe->dvb->priv;
401 struct tda1004x_state *state = fe->demodulator_priv;
402 u8 addr = state->config->tuner_address;
403 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
404 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
405
406 /* switch the tuner to analog mode */
407 if (fe->ops.i2c_gate_ctrl)
408 fe->ops.i2c_gate_ctrl(fe, 1);
409 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
410 return -EIO;
411 return 0;
412}
413
414/* ------------------------------------------------------------------ */
415
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300416static int philips_europa_tuner_init(struct dvb_frontend *fe)
417{
418 struct saa7134_dev *dev = fe->dvb->priv;
419 static u8 msg[] = { 0x00, 0x40};
420 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
421
422
423 if (philips_td1316_tuner_init(fe))
424 return -EIO;
425 msleep(1);
426 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
427 return -EIO;
428
429 return 0;
430}
431
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300432static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800433{
434 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800435
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300436 static u8 msg[] = { 0x00, 0x14 };
437 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
438
439 if (philips_td1316_tuner_sleep(fe))
440 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800441
442 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300443 if (fe->ops.i2c_gate_ctrl)
444 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800445 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300446 return 0;
447}
448
449static int philips_europa_demod_sleep(struct dvb_frontend *fe)
450{
451 struct saa7134_dev *dev = fe->dvb->priv;
452
453 if (dev->original_demod_sleep)
454 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300455 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300456 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800457}
458
459static struct tda1004x_config philips_europa_config = {
460
461 .demod_address = 0x8,
462 .invert = 0,
463 .invert_oclk = 0,
464 .xtal_freq = TDA10046_XTAL_4M,
465 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
466 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300467 .tuner_address = 0x61,
468 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800469};
470
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700471static struct tda1004x_config medion_cardbus = {
472 .demod_address = 0x08,
473 .invert = 1,
474 .invert_oclk = 0,
475 .xtal_freq = TDA10046_XTAL_16M,
476 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
477 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300478 .tuner_address = 0x61,
479 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700480};
481
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300482/* ------------------------------------------------------------------
483 * tda 1004x based cards with philips silicon tuner
484 */
485
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300486static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
487{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300488 struct tda1004x_state *state = fe->demodulator_priv;
489
490 u8 addr = state->config->i2c_gate;
491 static u8 tda8290_close[] = { 0x21, 0xc0};
492 static u8 tda8290_open[] = { 0x21, 0x80};
493 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
494 if (enable) {
495 tda8290_msg.buf = tda8290_close;
496 } else {
497 tda8290_msg.buf = tda8290_open;
498 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300499 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300500 struct saa7134_dev *dev = fe->dvb->priv;
501 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300502 return -EIO;
503 }
504 msleep(20);
505 return 0;
506}
507
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300508static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300509{
510 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300511 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300512
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300513 switch (state->config->antenna_switch) {
514 case 0: break;
515 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
516 saa7134_set_gpio(dev, 21, 0);
517 break;
518 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
519 saa7134_set_gpio(dev, 21, 1);
520 break;
521 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300522 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800523}
524
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300525static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
526{
527 struct saa7134_dev *dev = fe->dvb->priv;
528 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300529
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300530 switch (state->config->antenna_switch) {
531 case 0: break;
532 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
533 saa7134_set_gpio(dev, 21, 1);
534 break;
535 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
536 saa7134_set_gpio(dev, 21, 0);
537 break;
538 }
539 return 0;
540}
541
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300542static int configure_tda827x_fe(struct saa7134_dev *dev,
543 struct tda1004x_config *cdec_conf,
544 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300545{
Steven Toth363c35f2008-10-11 11:05:50 -0300546 struct videobuf_dvb_frontend *fe0;
547
Darron Broad92abe9e2008-10-11 11:18:53 -0300548 /* Get the first frontend */
549 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300550
551 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
552 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300553 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300554 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
555 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300556 cdec_conf->tuner_address,
557 &dev->i2c_adap, tuner_conf))
558 return 0;
559
560 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300561 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300562 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300563 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300564}
565
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800566/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300567
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300568static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300569 .init = philips_tda827x_tuner_init,
570 .sleep = philips_tda827x_tuner_sleep,
571 .config = 0,
572 .switch_addr = 0
573};
574
575static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300576 .init = philips_tda827x_tuner_init,
577 .sleep = philips_tda827x_tuner_sleep,
578 .config = 1,
579 .switch_addr = 0x4b
580};
581
582static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300583 .init = philips_tda827x_tuner_init,
584 .sleep = philips_tda827x_tuner_sleep,
585 .config = 2,
586 .switch_addr = 0x4b
587};
588
589static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300590 .init = philips_tda827x_tuner_init,
591 .sleep = philips_tda827x_tuner_sleep,
592 .config = 2,
593 .switch_addr = 0x42
594};
595
596/* ------------------------------------------------------------------ */
597
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300598static struct tda1004x_config tda827x_lifeview_config = {
599 .demod_address = 0x08,
600 .invert = 1,
601 .invert_oclk = 0,
602 .xtal_freq = TDA10046_XTAL_16M,
603 .agc_config = TDA10046_AGC_TDA827X,
604 .gpio_config = TDA10046_GP11_I,
605 .if_freq = TDA10046_FREQ_045,
606 .tuner_address = 0x60,
607 .request_firmware = philips_tda1004x_request_firmware
608};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800609
610static struct tda1004x_config philips_tiger_config = {
611 .demod_address = 0x08,
612 .invert = 1,
613 .invert_oclk = 0,
614 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300615 .agc_config = TDA10046_AGC_TDA827X,
616 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300617 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300618 .i2c_gate = 0x4b,
619 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300620 .antenna_switch= 1,
621 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300622};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300623
624static struct tda1004x_config cinergy_ht_config = {
625 .demod_address = 0x08,
626 .invert = 1,
627 .invert_oclk = 0,
628 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300629 .agc_config = TDA10046_AGC_TDA827X,
630 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800631 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300632 .i2c_gate = 0x4b,
633 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300634 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800635};
636
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300637static struct tda1004x_config cinergy_ht_pci_config = {
638 .demod_address = 0x08,
639 .invert = 1,
640 .invert_oclk = 0,
641 .xtal_freq = TDA10046_XTAL_16M,
642 .agc_config = TDA10046_AGC_TDA827X,
643 .gpio_config = TDA10046_GP01_I,
644 .if_freq = TDA10046_FREQ_045,
645 .i2c_gate = 0x4b,
646 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300647 .request_firmware = philips_tda1004x_request_firmware
648};
649
650static struct tda1004x_config philips_tiger_s_config = {
651 .demod_address = 0x08,
652 .invert = 1,
653 .invert_oclk = 0,
654 .xtal_freq = TDA10046_XTAL_16M,
655 .agc_config = TDA10046_AGC_TDA827X,
656 .gpio_config = TDA10046_GP01_I,
657 .if_freq = TDA10046_FREQ_045,
658 .i2c_gate = 0x4b,
659 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300660 .antenna_switch= 1,
661 .request_firmware = philips_tda1004x_request_firmware
662};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200663
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300664static struct tda1004x_config pinnacle_pctv_310i_config = {
665 .demod_address = 0x08,
666 .invert = 1,
667 .invert_oclk = 0,
668 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300669 .agc_config = TDA10046_AGC_TDA827X,
670 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300671 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300672 .i2c_gate = 0x4b,
673 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300674 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300675};
676
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300677static struct tda1004x_config hauppauge_hvr_1110_config = {
678 .demod_address = 0x08,
679 .invert = 1,
680 .invert_oclk = 0,
681 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300682 .agc_config = TDA10046_AGC_TDA827X,
683 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300684 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300685 .i2c_gate = 0x4b,
686 .tuner_address = 0x61,
687 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300688};
689
Hartmut Hackmann83646812006-10-12 20:38:51 -0300690static struct tda1004x_config asus_p7131_dual_config = {
691 .demod_address = 0x08,
692 .invert = 1,
693 .invert_oclk = 0,
694 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300695 .agc_config = TDA10046_AGC_TDA827X,
696 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300697 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300698 .i2c_gate = 0x4b,
699 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300700 .antenna_switch= 2,
701 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300702};
703
Nico Sabbi420f32f2006-03-03 12:11:28 -0300704static struct tda1004x_config lifeview_trio_config = {
705 .demod_address = 0x09,
706 .invert = 1,
707 .invert_oclk = 0,
708 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300709 .agc_config = TDA10046_AGC_TDA827X,
710 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300711 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300712 .tuner_address = 0x60,
713 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300714};
715
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300716static struct tda1004x_config tevion_dvbt220rf_config = {
717 .demod_address = 0x08,
718 .invert = 1,
719 .invert_oclk = 0,
720 .xtal_freq = TDA10046_XTAL_16M,
721 .agc_config = TDA10046_AGC_TDA827X,
722 .gpio_config = TDA10046_GP11_I,
723 .if_freq = TDA10046_FREQ_045,
724 .tuner_address = 0x60,
725 .request_firmware = philips_tda1004x_request_firmware
726};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300727
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300728static struct tda1004x_config md8800_dvbt_config = {
729 .demod_address = 0x08,
730 .invert = 1,
731 .invert_oclk = 0,
732 .xtal_freq = TDA10046_XTAL_16M,
733 .agc_config = TDA10046_AGC_TDA827X,
734 .gpio_config = TDA10046_GP01_I,
735 .if_freq = TDA10046_FREQ_045,
736 .i2c_gate = 0x4b,
737 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300738 .request_firmware = philips_tda1004x_request_firmware
739};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200740
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300741static struct tda1004x_config asus_p7131_4871_config = {
742 .demod_address = 0x08,
743 .invert = 1,
744 .invert_oclk = 0,
745 .xtal_freq = TDA10046_XTAL_16M,
746 .agc_config = TDA10046_AGC_TDA827X,
747 .gpio_config = TDA10046_GP01_I,
748 .if_freq = TDA10046_FREQ_045,
749 .i2c_gate = 0x4b,
750 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300751 .antenna_switch= 2,
752 .request_firmware = philips_tda1004x_request_firmware
753};
754
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300755static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300756 .demod_address = 0x08,
757 .invert = 1,
758 .invert_oclk = 0,
759 .xtal_freq = TDA10046_XTAL_16M,
760 .agc_config = TDA10046_AGC_TDA827X,
761 .gpio_config = TDA10046_GP11_I,
762 .if_freq = TDA10046_FREQ_045,
763 .i2c_gate = 0x4b,
764 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300765 .antenna_switch= 2,
766 .request_firmware = philips_tda1004x_request_firmware
767};
Edgar Simo261f5082007-08-20 14:06:00 -0300768
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300769static struct tda1004x_config kworld_dvb_t_210_config = {
770 .demod_address = 0x08,
771 .invert = 1,
772 .invert_oclk = 0,
773 .xtal_freq = TDA10046_XTAL_16M,
774 .agc_config = TDA10046_AGC_TDA827X,
775 .gpio_config = TDA10046_GP11_I,
776 .if_freq = TDA10046_FREQ_045,
777 .i2c_gate = 0x4b,
778 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300779 .antenna_switch= 1,
780 .request_firmware = philips_tda1004x_request_firmware
781};
Edgar Simo261f5082007-08-20 14:06:00 -0300782
Edgar Simod90d9f52007-08-20 14:14:50 -0300783static struct tda1004x_config avermedia_super_007_config = {
784 .demod_address = 0x08,
785 .invert = 1,
786 .invert_oclk = 0,
787 .xtal_freq = TDA10046_XTAL_16M,
788 .agc_config = TDA10046_AGC_TDA827X,
789 .gpio_config = TDA10046_GP01_I,
790 .if_freq = TDA10046_FREQ_045,
791 .i2c_gate = 0x4b,
792 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300793 .antenna_switch= 1,
794 .request_firmware = philips_tda1004x_request_firmware
795};
796
Hermann Pitton4ba24372008-01-20 19:27:51 -0300797static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
798 .demod_address = 0x08,
799 .invert = 1,
800 .invert_oclk = 0,
801 .xtal_freq = TDA10046_XTAL_16M,
802 .agc_config = TDA10046_AGC_TDA827X,
803 .gpio_config = TDA10046_GP01_I,
804 .if_freq = TDA10046_FREQ_045,
805 .i2c_gate = 0x42,
806 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300807 .antenna_switch = 1,
808 .request_firmware = philips_tda1004x_request_firmware
809};
810
hermann pitton301e9d62008-09-14 17:49:14 -0300811static struct tda1004x_config asus_tiger_3in1_config = {
812 .demod_address = 0x0b,
813 .invert = 1,
814 .invert_oclk = 0,
815 .xtal_freq = TDA10046_XTAL_16M,
816 .agc_config = TDA10046_AGC_TDA827X,
817 .gpio_config = TDA10046_GP11_I,
818 .if_freq = TDA10046_FREQ_045,
819 .i2c_gate = 0x4b,
820 .tuner_address = 0x61,
821 .antenna_switch = 1,
822 .request_firmware = philips_tda1004x_request_firmware
823};
824
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300825/* ------------------------------------------------------------------
826 * special case: this card uses saa713x GPIO22 for the mode switch
827 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200828
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300829static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200830{
831 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300832 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200833 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300834 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200835 return 0;
836}
837
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300838static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200839{
840 struct saa7134_dev *dev = fe->dvb->priv;
841 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300842 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300843 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300844 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200845}
846
Michael Krufky8ce47da2007-04-27 12:31:14 -0300847static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300848 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300849 .sleep = ads_duo_tuner_sleep,
850 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300851};
852
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200853static struct tda1004x_config ads_tech_duo_config = {
854 .demod_address = 0x08,
855 .invert = 1,
856 .invert_oclk = 0,
857 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300858 .agc_config = TDA10046_AGC_TDA827X,
859 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200860 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300861 .tuner_address = 0x61,
862 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200863};
864
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300865static struct zl10353_config behold_h6_config = {
866 .demod_address = 0x1e>>1,
867 .no_tuner = 1,
868 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300869 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300870};
871
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300872/* ==================================================================
873 * tda10086 based DVB-S cards, helper functions
874 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300875
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300876static struct tda10086_config flydvbs = {
877 .demod_address = 0x0e,
878 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300879 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300880 .xtal_freq = TDA10086_XTAL_16M,
881};
882
883static struct tda10086_config sd1878_4m = {
884 .demod_address = 0x0e,
885 .invert = 0,
886 .diseqc_tone = 0,
887 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300888};
889
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300890/* ------------------------------------------------------------------
891 * special case: lnb supply is connected to the gated i2c
892 */
893
894static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
895{
896 int res = -EIO;
897 struct saa7134_dev *dev = fe->dvb->priv;
898 if (fe->ops.i2c_gate_ctrl) {
899 fe->ops.i2c_gate_ctrl(fe, 1);
900 if (dev->original_set_voltage)
901 res = dev->original_set_voltage(fe, voltage);
902 fe->ops.i2c_gate_ctrl(fe, 0);
903 }
904 return res;
905};
906
907static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
908{
909 int res = -EIO;
910 struct saa7134_dev *dev = fe->dvb->priv;
911 if (fe->ops.i2c_gate_ctrl) {
912 fe->ops.i2c_gate_ctrl(fe, 1);
913 if (dev->original_set_high_voltage)
914 res = dev->original_set_high_voltage(fe, arg);
915 fe->ops.i2c_gate_ctrl(fe, 0);
916 }
917 return res;
918};
919
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300920static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
921{
922 struct saa7134_dev *dev = fe->dvb->priv;
923 u8 wbuf[2] = { 0x1f, 00 };
924 u8 rbuf;
925 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
926 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
927
928 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
929 return -EIO;
930 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
931 if (voltage == SEC_VOLTAGE_18)
932 wbuf[1] = rbuf | 0x10;
933 else
934 wbuf[1] = rbuf & 0xef;
935 msg[0].len = 2;
936 i2c_transfer(&dev->i2c_adap, msg, 1);
937 return 0;
938}
939
940static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
941{
942 struct saa7134_dev *dev = fe->dvb->priv;
943 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
944 return -EIO;
945}
946
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300947/* ==================================================================
948 * nxt200x based ATSC cards, helper functions
949 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800950
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800951static struct nxt200x_config avertvhda180 = {
952 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800953};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300954
955static struct nxt200x_config kworldatsc110 = {
956 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300957};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800958
Matthias Schwarzott04574182009-02-24 12:35:16 -0300959/* ------------------------------------------------------------------ */
960
961static struct mt312_config avertv_a700_mt312 = {
962 .demod_address = 0x0e,
963 .voltage_inverted = 1,
964};
965
966static struct zl10036_config avertv_a700_tuner = {
967 .tuner_address = 0x60,
968};
969
Michael Krufky3abdedd2009-01-19 01:10:49 -0300970static struct lgdt3305_config hcw_lgdt3305_config = {
971 .i2c_addr = 0x0e,
972 .mpeg_mode = LGDT3305_MPEG_SERIAL,
973 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
974 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
975 .deny_i2c_rptr = 1,
976 .spectral_inversion = 1,
977 .qam_if_khz = 4000,
978 .vsb_if_khz = 3250,
979};
980
981static struct tda18271_std_map hauppauge_tda18271_std_map = {
982 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
983 .if_lvl = 1, .rfagc_top = 0x58, },
984 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
985 .if_lvl = 1, .rfagc_top = 0x58, },
986};
987
988static struct tda18271_config hcw_tda18271_config = {
989 .std_map = &hauppauge_tda18271_std_map,
990 .gate = TDA18271_GATE_ANALOG,
991 .config = 3,
992};
993
994static struct tda829x_config tda829x_no_probe = {
995 .probe_tuner = TDA829X_DONT_PROBE,
996};
997
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300998/* ==================================================================
999 * Core code
1000 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001001
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002static int dvb_init(struct saa7134_dev *dev)
1003{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001004 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001005 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001006 struct videobuf_dvb_frontend *fe0;
1007
Darron Broadf972e0b2008-10-11 11:24:30 -03001008 /* FIXME: add support for multi-frontend */
1009 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001010 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -03001011
1012 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001013 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1014 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -03001015 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1016 return -ENOMEM;
1017 }
1018
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019 /* init struct videobuf_dvb */
1020 dev->ts.nr_bufs = 32;
1021 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001022 fe0->dvb.name = dev->name;
1023 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001024 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1026 V4L2_FIELD_ALTERNATE,
1027 sizeof(struct saa7134_buf),
1028 dev);
1029
1030 switch (dev->board) {
1031 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001032 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001033 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001034 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001035 if (fe0->dvb.frontend) {
1036 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001037 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001039 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001040 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001041 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001042 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001043 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001044 if (fe0->dvb.frontend) {
1045 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001046 &dev->i2c_adap, 0x61,
1047 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001048 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001049 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001050 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001051 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001052 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001053 &avermedia_xc3028_mt352_dev,
1054 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001055 attach_xc3028 = 1;
1056 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001058 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001059 &medion_cardbus,
1060 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001061 if (fe0->dvb.frontend) {
1062 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd332008-04-22 14:46:16 -03001063 &dev->i2c_adap, medion_cardbus.tuner_address,
1064 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001065 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001067 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001068 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001069 &philips_tu1216_60_config,
1070 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001071 if (fe0->dvb.frontend) {
1072 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1073 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001074 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001075 break;
1076 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001077 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001078 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1079 &tda827x_cfg_0) < 0)
1080 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001081 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001082 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001083 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Steven Toth363c35f2008-10-11 11:05:50 -03001084 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001085 &philips_europa_config,
1086 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001087 if (fe0->dvb.frontend) {
1088 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1089 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1090 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1091 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1092 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001093 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001094 break;
1095 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001096 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001097 &philips_tu1216_61_config,
1098 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001099 if (fe0->dvb.frontend) {
1100 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1101 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001102 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001103 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001104 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001105 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1106 &tda827x_cfg_2) < 0)
1107 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001108 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001109 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001110 if (configure_tda827x_fe(dev, &philips_tiger_config,
1111 &tda827x_cfg_0) < 0)
1112 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001113 break;
1114 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001115 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1116 &tda827x_cfg_1) < 0)
1117 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001118 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001119 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001120 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1121 &tda827x_cfg_1) < 0)
1122 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001123 break;
Michael Krufky3abdedd2009-01-19 01:10:49 -03001124 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1125 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1126 &hcw_lgdt3305_config,
1127 &dev->i2c_adap);
1128 if (fe0->dvb.frontend) {
1129 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1130 &dev->i2c_adap, 0x4b,
1131 &tda829x_no_probe);
1132 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1133 0x60, &dev->i2c_adap,
1134 &hcw_tda18271_config);
1135 }
1136 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001137 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001138 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1139 &tda827x_cfg_0) < 0)
1140 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001141 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001142 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001143 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1144 &tda827x_cfg_0) < 0)
1145 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001146 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001147 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001148 if (!use_frontend) { /* terrestrial */
1149 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1150 &tda827x_cfg_0) < 0)
1151 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001152 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001153 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1154 if (fe0->dvb.frontend) {
1155 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001156 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001157 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001158 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001159 }
Steven Toth363c35f2008-10-11 11:05:50 -03001160 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001161 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001162 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001163 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001164 }
1165 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001166 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001167 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001168 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001169 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001170 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001171 &ads_tech_duo_config,
1172 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001173 if (fe0->dvb.frontend) {
1174 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001175 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1176 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001177 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001178 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001179 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001180 }
Mauro Carvalho Chehabbc36ec72008-06-14 10:44:04 -03001181 } else
1182 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001183 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001184 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001185 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1186 &tda827x_cfg_0) < 0)
1187 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001188 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001189 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001190 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001191 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1192 &tda827x_cfg_0) < 0)
1193 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001194 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001195 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001196 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001197 if (fe0->dvb.frontend) {
1198 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001199 u8 dev_id = dev->eedata[2];
1200 u8 data = 0xc4;
1201 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1202
Steven Toth363c35f2008-10-11 11:05:50 -03001203 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001204 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001205 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001206 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001207 goto dettach_frontend;
1208 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001209 if (dev_id != 0x08) {
1210 /* we need to open the i2c gate (we know it exists) */
1211 fe->ops.i2c_gate_ctrl(fe, 1);
1212 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001213 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001214 wprintk("%s: Medion Quadro, no ISL6405 "
1215 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001216 goto dettach_frontend;
1217 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001218 if (dev_id == 0x07) {
1219 /* fire up the 2nd section of the LNB supply since
1220 we can't do this from the other section */
1221 msg.buf = &data;
1222 i2c_transfer(&dev->i2c_adap, &msg, 1);
1223 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001224 fe->ops.i2c_gate_ctrl(fe, 0);
1225 dev->original_set_voltage = fe->ops.set_voltage;
1226 fe->ops.set_voltage = md8800_set_voltage;
1227 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1228 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1229 } else {
1230 fe->ops.set_voltage = md8800_set_voltage2;
1231 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1232 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001233 }
1234 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001235 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001236 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001237 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001238 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001239 if (fe0->dvb.frontend)
1240 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001241 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001242 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001243 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001244 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001245 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001246 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001247 if (fe0->dvb.frontend)
1248 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001249 &dev->i2c_adap, 0x61,
1250 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001251 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001252 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001253 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001254 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001255 if (fe0->dvb.frontend) {
1256 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001257 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001258 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001259 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001260 }
Steven Toth363c35f2008-10-11 11:05:50 -03001261 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001262 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001263 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001264 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001265 }
1266 }
1267 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001268 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001269 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001270 &medion_cardbus,
1271 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001272 if (fe0->dvb.frontend) {
1273 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1274 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001275
Steven Toth363c35f2008-10-11 11:05:50 -03001276 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd332008-04-22 14:46:16 -03001277 &dev->i2c_adap, medion_cardbus.tuner_address,
1278 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001279 }
1280 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001281 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001282 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001283 &philips_europa_config,
1284 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001285 if (fe0->dvb.frontend) {
1286 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1287 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001288 }
1289 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001290 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001291 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1292 &tda827x_cfg_0) < 0)
1293 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001294 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001295 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001296 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1297 &tda827x_cfg_0) < 0)
1298 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001299 break;
1300 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001301 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1302 &tda827x_cfg_2) < 0)
1303 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001304 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001305 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001306 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1307 &tda827x_cfg_2) < 0)
1308 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001309 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001310 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001311 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1312 &tda827x_cfg_2) < 0)
1313 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001314 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001315 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001316 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1317 &tda827x_cfg_0) < 0)
1318 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001319 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001320 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001321 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1322 &tda827x_cfg_2_sw42) < 0)
1323 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001324 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001325 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001326 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001327 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001328 if (fe0->dvb.frontend) {
1329 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001330 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001331 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001332 goto dettach_frontend;
1333 }
Steven Toth363c35f2008-10-11 11:05:50 -03001334 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001335 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001336 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001337 goto dettach_frontend;
1338 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001339 }
1340 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001341 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001342 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1343 &tda827x_cfg_0) < 0)
1344 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001345 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001346 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001347 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1348 &tda827x_cfg_2) < 0)
1349 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001350 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001351 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001352 dprintk("AverMedia E506R dvb setup\n");
1353 saa7134_set_gpio(dev, 25, 0);
1354 msleep(10);
1355 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001356 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001357 &avermedia_xc3028_mt352_dev,
1358 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001359 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001360 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001361 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001362 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001363 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001364 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001365 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001366 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001367 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001368 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001369 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001370 goto dettach_frontend;
1371 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001372 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001373 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001374 fe->ops.i2c_gate_ctrl(fe, 1);
1375 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001376 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001377 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001378 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001379 goto dettach_frontend;
1380 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001381 fe->ops.i2c_gate_ctrl(fe, 0);
1382 dev->original_set_voltage = fe->ops.set_voltage;
1383 fe->ops.set_voltage = md8800_set_voltage;
1384 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1385 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1386 }
1387 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001388 case SAA7134_BOARD_AVERMEDIA_M103:
1389 saa7134_set_gpio(dev, 25, 0);
1390 msleep(10);
1391 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001392 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001393 &avermedia_xc3028_mt352_dev,
1394 &dev->i2c_adap);
1395 attach_xc3028 = 1;
1396 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001397 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1398 if (!use_frontend) { /* terrestrial */
1399 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1400 &tda827x_cfg_2) < 0)
1401 goto dettach_frontend;
1402 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001403 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001404 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001405 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001406 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001407 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001408 &dev->i2c_adap, 0) == NULL) {
1409 wprintk("%s: Asus Tiger 3in1, no "
1410 "tda826x found!\n", __func__);
1411 goto dettach_frontend;
1412 }
Steven Toth363c35f2008-10-11 11:05:50 -03001413 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001414 &dev->i2c_adap, 0, 0) == NULL) {
1415 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1416 " found!\n", __func__);
1417 goto dettach_frontend;
1418 }
1419 }
1420 }
1421 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001422 case SAA7134_BOARD_ASUSTeK_TIGER:
1423 if (configure_tda827x_fe(dev, &philips_tiger_config,
1424 &tda827x_cfg_0) < 0)
1425 goto dettach_frontend;
1426 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001427 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001428 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001429 &behold_h6_config,
1430 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001431 if (fe0->dvb.frontend) {
1432 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001433 &dev->i2c_adap, 0x61,
1434 TUNER_PHILIPS_FMD1216ME_MK3);
1435 }
1436 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001437 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1438 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1439 /* Zarlink ZL10313 */
1440 fe0->dvb.frontend = dvb_attach(mt312_attach,
1441 &avertv_a700_mt312, &dev->i2c_adap);
1442 if (fe0->dvb.frontend) {
1443 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1444 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1445 wprintk("%s: No zl10036 found!\n",
1446 __func__);
1447 }
1448 }
1449 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001451 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 break;
1453 }
1454
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001455 if (attach_xc3028) {
1456 struct dvb_frontend *fe;
1457 struct xc2028_config cfg = {
1458 .i2c_adap = &dev->i2c_adap,
1459 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001460 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001461
Steven Toth363c35f2008-10-11 11:05:50 -03001462 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001463 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001464
Steven Toth363c35f2008-10-11 11:05:50 -03001465 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001466 if (!fe) {
1467 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1468 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001469 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001470 }
1471 }
1472
Steven Toth363c35f2008-10-11 11:05:50 -03001473 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001474 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001475 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001477 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001478 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479
1480 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001481 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Darron Broad59b18422008-10-11 11:44:05 -03001482 &dev->pci->dev, adapter_nr, 0);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001483
1484 /* this sequence is necessary to make the tda1004x load its firmware
1485 * and to enter analog mode of hybrid boards
1486 */
1487 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001488 if (fe0->dvb.frontend->ops.init)
1489 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1490 if (fe0->dvb.frontend->ops.sleep)
1491 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1492 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1493 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001494 }
1495 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001496
1497dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001498 videobuf_dvb_dealloc_frontends(&dev->frontends);
1499 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500}
1501
1502static int dvb_fini(struct saa7134_dev *dev)
1503{
Steven Toth363c35f2008-10-11 11:05:50 -03001504 struct videobuf_dvb_frontend *fe0;
1505
1506 /* Get the first frontend */
1507 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1508 if (!fe0)
1509 return -EINVAL;
1510
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001511 /* FIXME: I suspect that this code is bogus, since the entry for
1512 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1513 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1514 */
1515 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1516 struct v4l2_priv_tun_config tda9887_cfg;
1517 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001519 tda9887_cfg.tuner = TUNER_TDA9887;
1520 tda9887_cfg.priv = &on;
1521
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001523 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001524 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001525 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001526 /* turn off the 2nd lnb supply */
1527 u8 data = 0x80;
1528 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1529 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001530 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001531 if (fe->ops.i2c_gate_ctrl) {
1532 fe->ops.i2c_gate_ctrl(fe, 1);
1533 i2c_transfer(&dev->i2c_adap, &msg, 1);
1534 fe->ops.i2c_gate_ctrl(fe, 0);
1535 }
1536 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001537 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001538 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 return 0;
1540}
1541
1542static struct saa7134_mpeg_ops dvb_ops = {
1543 .type = SAA7134_MPEG_DVB,
1544 .init = dvb_init,
1545 .fini = dvb_fini,
1546};
1547
1548static int __init dvb_register(void)
1549{
1550 return saa7134_ts_register(&dvb_ops);
1551}
1552
1553static void __exit dvb_unregister(void)
1554{
1555 saa7134_ts_unregister(&dvb_ops);
1556}
1557
1558module_init(dvb_register);
1559module_exit(dvb_unregister);
1560
1561/* ------------------------------------------------------------------ */
1562/*
1563 * Local variables:
1564 * c-basic-offset: 8
1565 * End:
1566 */