blob: 7d95a6928772c6ba5ca9b4ffc070949e58edda65 [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 Krufky8ce47da2007-04-27 12:31:14 -030051
Linus Torvalds1da177e2005-04-16 15:20:36 -070052MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
53MODULE_LICENSE("GPL");
54
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030055static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070056
Linus Torvalds1da177e2005-04-16 15:20:36 -070057module_param(antenna_pwr, int, 0444);
58MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
59
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030060static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030061module_param(use_frontend, int, 0644);
62MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030063
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030064static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030065module_param(debug, int, 0644);
66MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
67
Janne Grunau78e92002008-04-09 19:13:13 -030068DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
69
Trent Piephocf3c34c2007-03-07 18:19:48 -030070#define dprintk(fmt, arg...) do { if (debug) \
71 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
72
73/* Print a warning */
74#define wprintk(fmt, arg...) \
75 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030076
77/* ------------------------------------------------------------------
78 * mt352 based DVB-T cards
79 */
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
82{
83 u32 ok;
84
85 if (!on) {
86 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
87 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
88 return 0;
89 }
90
91 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
92 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
93 udelay(10);
94
95 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
96 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
97 udelay(10);
98 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
99 udelay(10);
100 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300101 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
103 if (!ok)
104 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
105 return ok;
106}
107
108static int mt352_pinnacle_init(struct dvb_frontend* fe)
109{
110 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
111 static u8 reset [] = { RESET, 0x80 };
112 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
113 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
114 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
115 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
116 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
117 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
118 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
119 struct saa7134_dev *dev= fe->dvb->priv;
120
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300121 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
123 mt352_write(fe, clock_config, sizeof(clock_config));
124 udelay(200);
125 mt352_write(fe, reset, sizeof(reset));
126 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
127 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
128 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
129 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
130
131 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
132 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
133 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 return 0;
136}
137
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200138static int mt352_aver777_init(struct dvb_frontend* fe)
139{
140 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
141 static u8 reset [] = { RESET, 0x80 };
142 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
143 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
144 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
145
146 mt352_write(fe, clock_config, sizeof(clock_config));
147 udelay(200);
148 mt352_write(fe, reset, sizeof(reset));
149 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
150 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
151 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
152
153 return 0;
154}
155
Tim Farrington6e501a32008-06-15 13:33:42 -0300156static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300157{
Tim Farrington6e501a32008-06-15 13:33:42 -0300158 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
159 static u8 reset [] = { RESET, 0x80 };
160 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
161 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300162 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
163
164 mt352_write(fe, clock_config, sizeof(clock_config));
165 udelay(200);
166 mt352_write(fe, reset, sizeof(reset));
167 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
168 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
169 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300170 return 0;
171}
172
Andrew de Quincey0463f122006-05-16 17:22:02 -0300173static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
174 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300176 u8 off[] = { 0x00, 0xf1};
177 u8 on[] = { 0x00, 0x71};
178 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
179
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 struct saa7134_dev *dev = fe->dvb->priv;
181 struct v4l2_frequency f;
182
183 /* set frequency (mt2050) */
184 f.tuner = 0;
185 f.type = V4L2_TUNER_DIGITAL_TV;
186 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300187 if (fe->ops.i2c_gate_ctrl)
188 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300189 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300191 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300192 if (fe->ops.i2c_gate_ctrl)
193 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300194 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
196 pinnacle_antenna_pwr(dev, antenna_pwr);
197
198 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300199 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200}
201
202static struct mt352_config pinnacle_300i = {
203 .demod_address = 0x3c >> 1,
204 .adc_clock = 20333,
205 .if2 = 36150,
206 .no_tuner = 1,
207 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200209
210static struct mt352_config avermedia_777 = {
211 .demod_address = 0xf,
212 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200213};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214
Tim Farrington6e501a32008-06-15 13:33:42 -0300215static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300216 .demod_address = (0x1e >> 1),
217 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300218 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300219};
220
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300221/* ==================================================================
222 * tda1004x based DVB-T cards, helper functions
223 */
224
225static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
226 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700227{
228 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300229 return request_firmware(fw, name, &dev->pci->dev);
230}
231
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300232/* ------------------------------------------------------------------
233 * these tuners are tu1216, td1316(a)
234 */
235
236static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
237{
238 struct saa7134_dev *dev = fe->dvb->priv;
239 struct tda1004x_state *state = fe->demodulator_priv;
240 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700241 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800242 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700243 sizeof(tuner_buf) };
244 int tuner_frequency = 0;
245 u8 band, cp, filter;
246
247 /* determine charge pump */
248 tuner_frequency = params->frequency + 36166000;
249 if (tuner_frequency < 87000000)
250 return -EINVAL;
251 else if (tuner_frequency < 130000000)
252 cp = 3;
253 else if (tuner_frequency < 160000000)
254 cp = 5;
255 else if (tuner_frequency < 200000000)
256 cp = 6;
257 else if (tuner_frequency < 290000000)
258 cp = 3;
259 else if (tuner_frequency < 420000000)
260 cp = 5;
261 else if (tuner_frequency < 480000000)
262 cp = 6;
263 else if (tuner_frequency < 620000000)
264 cp = 3;
265 else if (tuner_frequency < 830000000)
266 cp = 5;
267 else if (tuner_frequency < 895000000)
268 cp = 7;
269 else
270 return -EINVAL;
271
272 /* determine band */
273 if (params->frequency < 49000000)
274 return -EINVAL;
275 else if (params->frequency < 161000000)
276 band = 1;
277 else if (params->frequency < 444000000)
278 band = 2;
279 else if (params->frequency < 861000000)
280 band = 4;
281 else
282 return -EINVAL;
283
284 /* setup PLL filter */
285 switch (params->u.ofdm.bandwidth) {
286 case BANDWIDTH_6_MHZ:
287 filter = 0;
288 break;
289
290 case BANDWIDTH_7_MHZ:
291 filter = 0;
292 break;
293
294 case BANDWIDTH_8_MHZ:
295 filter = 1;
296 break;
297
298 default:
299 return -EINVAL;
300 }
301
302 /* calculate divisor
303 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
304 */
305 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
306
307 /* setup tuner buffer */
308 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
309 tuner_buf[1] = tuner_frequency & 0xff;
310 tuner_buf[2] = 0xca;
311 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
312
Patrick Boettcherdea74862006-05-14 05:01:31 -0300313 if (fe->ops.i2c_gate_ctrl)
314 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300315 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300316 wprintk("could not write to tuner at addr: 0x%02x\n",
317 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700318 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300319 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700320 msleep(1);
321 return 0;
322}
323
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300324static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800325{
326 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300327 struct tda1004x_state *state = fe->demodulator_priv;
328 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800329 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
330 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
331
332 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300333 if (fe->ops.i2c_gate_ctrl)
334 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800335 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
336 return -EIO;
337 msleep(1);
338
339 return 0;
340}
341
342/* ------------------------------------------------------------------ */
343
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800344static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700345 .demod_address = 0x8,
346 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800347 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700348 .xtal_freq = TDA10046_XTAL_4M,
349 .agc_config = TDA10046_AGC_DEFAULT,
350 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300351 .tuner_address = 0x60,
352 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353};
354
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800355static struct tda1004x_config philips_tu1216_61_config = {
356
357 .demod_address = 0x8,
358 .invert = 1,
359 .invert_oclk = 0,
360 .xtal_freq = TDA10046_XTAL_4M,
361 .agc_config = TDA10046_AGC_DEFAULT,
362 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300363 .tuner_address = 0x61,
364 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800365};
366
367/* ------------------------------------------------------------------ */
368
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300369static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800370{
371 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300372 struct tda1004x_state *state = fe->demodulator_priv;
373 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800374 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300375 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800376
377 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300378 if (fe->ops.i2c_gate_ctrl)
379 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800380 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
381 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800382 return 0;
383}
384
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300385static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800386{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300387 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800388}
389
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300390static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
391{
392 struct saa7134_dev *dev = fe->dvb->priv;
393 struct tda1004x_state *state = fe->demodulator_priv;
394 u8 addr = state->config->tuner_address;
395 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
396 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
397
398 /* switch the tuner to analog mode */
399 if (fe->ops.i2c_gate_ctrl)
400 fe->ops.i2c_gate_ctrl(fe, 1);
401 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
402 return -EIO;
403 return 0;
404}
405
406/* ------------------------------------------------------------------ */
407
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300408static int philips_europa_tuner_init(struct dvb_frontend *fe)
409{
410 struct saa7134_dev *dev = fe->dvb->priv;
411 static u8 msg[] = { 0x00, 0x40};
412 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
413
414
415 if (philips_td1316_tuner_init(fe))
416 return -EIO;
417 msleep(1);
418 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
419 return -EIO;
420
421 return 0;
422}
423
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300424static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800425{
426 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800427
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300428 static u8 msg[] = { 0x00, 0x14 };
429 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
430
431 if (philips_td1316_tuner_sleep(fe))
432 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800433
434 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300435 if (fe->ops.i2c_gate_ctrl)
436 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800437 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300438 return 0;
439}
440
441static int philips_europa_demod_sleep(struct dvb_frontend *fe)
442{
443 struct saa7134_dev *dev = fe->dvb->priv;
444
445 if (dev->original_demod_sleep)
446 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300447 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300448 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800449}
450
451static struct tda1004x_config philips_europa_config = {
452
453 .demod_address = 0x8,
454 .invert = 0,
455 .invert_oclk = 0,
456 .xtal_freq = TDA10046_XTAL_4M,
457 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
458 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300459 .tuner_address = 0x61,
460 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800461};
462
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700463static struct tda1004x_config medion_cardbus = {
464 .demod_address = 0x08,
465 .invert = 1,
466 .invert_oclk = 0,
467 .xtal_freq = TDA10046_XTAL_16M,
468 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
469 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300470 .tuner_address = 0x61,
471 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700472};
473
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300474/* ------------------------------------------------------------------
475 * tda 1004x based cards with philips silicon tuner
476 */
477
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300478static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
479{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300480 struct tda1004x_state *state = fe->demodulator_priv;
481
482 u8 addr = state->config->i2c_gate;
483 static u8 tda8290_close[] = { 0x21, 0xc0};
484 static u8 tda8290_open[] = { 0x21, 0x80};
485 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
486 if (enable) {
487 tda8290_msg.buf = tda8290_close;
488 } else {
489 tda8290_msg.buf = tda8290_open;
490 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300491 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300492 struct saa7134_dev *dev = fe->dvb->priv;
493 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300494 return -EIO;
495 }
496 msleep(20);
497 return 0;
498}
499
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300500static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300501{
502 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300503 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300504
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300505 switch (state->config->antenna_switch) {
506 case 0: break;
507 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
508 saa7134_set_gpio(dev, 21, 0);
509 break;
510 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
511 saa7134_set_gpio(dev, 21, 1);
512 break;
513 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300514 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800515}
516
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300517static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
518{
519 struct saa7134_dev *dev = fe->dvb->priv;
520 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300521
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300522 switch (state->config->antenna_switch) {
523 case 0: break;
524 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
525 saa7134_set_gpio(dev, 21, 1);
526 break;
527 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
528 saa7134_set_gpio(dev, 21, 0);
529 break;
530 }
531 return 0;
532}
533
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300534static int configure_tda827x_fe(struct saa7134_dev *dev,
535 struct tda1004x_config *cdec_conf,
536 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300537{
Steven Toth363c35f2008-10-11 11:05:50 -0300538 struct videobuf_dvb_frontend *fe0;
539
Darron Broad92abe9e2008-10-11 11:18:53 -0300540 /* Get the first frontend */
541 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300542
543 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
544 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300545 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300546 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
547 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300548 cdec_conf->tuner_address,
549 &dev->i2c_adap, tuner_conf))
550 return 0;
551
552 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300553 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300554 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300555 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300556}
557
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800558/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300559
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300560static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300561 .init = philips_tda827x_tuner_init,
562 .sleep = philips_tda827x_tuner_sleep,
563 .config = 0,
564 .switch_addr = 0
565};
566
567static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300568 .init = philips_tda827x_tuner_init,
569 .sleep = philips_tda827x_tuner_sleep,
570 .config = 1,
571 .switch_addr = 0x4b
572};
573
574static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300575 .init = philips_tda827x_tuner_init,
576 .sleep = philips_tda827x_tuner_sleep,
577 .config = 2,
578 .switch_addr = 0x4b
579};
580
581static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300582 .init = philips_tda827x_tuner_init,
583 .sleep = philips_tda827x_tuner_sleep,
584 .config = 2,
585 .switch_addr = 0x42
586};
587
588/* ------------------------------------------------------------------ */
589
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300590static struct tda1004x_config tda827x_lifeview_config = {
591 .demod_address = 0x08,
592 .invert = 1,
593 .invert_oclk = 0,
594 .xtal_freq = TDA10046_XTAL_16M,
595 .agc_config = TDA10046_AGC_TDA827X,
596 .gpio_config = TDA10046_GP11_I,
597 .if_freq = TDA10046_FREQ_045,
598 .tuner_address = 0x60,
599 .request_firmware = philips_tda1004x_request_firmware
600};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800601
602static struct tda1004x_config philips_tiger_config = {
603 .demod_address = 0x08,
604 .invert = 1,
605 .invert_oclk = 0,
606 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300607 .agc_config = TDA10046_AGC_TDA827X,
608 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300609 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300610 .i2c_gate = 0x4b,
611 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300612 .antenna_switch= 1,
613 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300614};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300615
616static struct tda1004x_config cinergy_ht_config = {
617 .demod_address = 0x08,
618 .invert = 1,
619 .invert_oclk = 0,
620 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300621 .agc_config = TDA10046_AGC_TDA827X,
622 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800623 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300624 .i2c_gate = 0x4b,
625 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300626 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800627};
628
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300629static struct tda1004x_config cinergy_ht_pci_config = {
630 .demod_address = 0x08,
631 .invert = 1,
632 .invert_oclk = 0,
633 .xtal_freq = TDA10046_XTAL_16M,
634 .agc_config = TDA10046_AGC_TDA827X,
635 .gpio_config = TDA10046_GP01_I,
636 .if_freq = TDA10046_FREQ_045,
637 .i2c_gate = 0x4b,
638 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300639 .request_firmware = philips_tda1004x_request_firmware
640};
641
642static struct tda1004x_config philips_tiger_s_config = {
643 .demod_address = 0x08,
644 .invert = 1,
645 .invert_oclk = 0,
646 .xtal_freq = TDA10046_XTAL_16M,
647 .agc_config = TDA10046_AGC_TDA827X,
648 .gpio_config = TDA10046_GP01_I,
649 .if_freq = TDA10046_FREQ_045,
650 .i2c_gate = 0x4b,
651 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300652 .antenna_switch= 1,
653 .request_firmware = philips_tda1004x_request_firmware
654};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200655
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300656static struct tda1004x_config pinnacle_pctv_310i_config = {
657 .demod_address = 0x08,
658 .invert = 1,
659 .invert_oclk = 0,
660 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300661 .agc_config = TDA10046_AGC_TDA827X,
662 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300663 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300664 .i2c_gate = 0x4b,
665 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300666 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300667};
668
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300669static struct tda1004x_config hauppauge_hvr_1110_config = {
670 .demod_address = 0x08,
671 .invert = 1,
672 .invert_oclk = 0,
673 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300674 .agc_config = TDA10046_AGC_TDA827X,
675 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300676 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300677 .i2c_gate = 0x4b,
678 .tuner_address = 0x61,
679 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300680};
681
Hartmut Hackmann83646812006-10-12 20:38:51 -0300682static struct tda1004x_config asus_p7131_dual_config = {
683 .demod_address = 0x08,
684 .invert = 1,
685 .invert_oclk = 0,
686 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300687 .agc_config = TDA10046_AGC_TDA827X,
688 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300689 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300690 .i2c_gate = 0x4b,
691 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300692 .antenna_switch= 2,
693 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300694};
695
Nico Sabbi420f32f2006-03-03 12:11:28 -0300696static struct tda1004x_config lifeview_trio_config = {
697 .demod_address = 0x09,
698 .invert = 1,
699 .invert_oclk = 0,
700 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300701 .agc_config = TDA10046_AGC_TDA827X,
702 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300703 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300704 .tuner_address = 0x60,
705 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300706};
707
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300708static struct tda1004x_config tevion_dvbt220rf_config = {
709 .demod_address = 0x08,
710 .invert = 1,
711 .invert_oclk = 0,
712 .xtal_freq = TDA10046_XTAL_16M,
713 .agc_config = TDA10046_AGC_TDA827X,
714 .gpio_config = TDA10046_GP11_I,
715 .if_freq = TDA10046_FREQ_045,
716 .tuner_address = 0x60,
717 .request_firmware = philips_tda1004x_request_firmware
718};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300719
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300720static struct tda1004x_config md8800_dvbt_config = {
721 .demod_address = 0x08,
722 .invert = 1,
723 .invert_oclk = 0,
724 .xtal_freq = TDA10046_XTAL_16M,
725 .agc_config = TDA10046_AGC_TDA827X,
726 .gpio_config = TDA10046_GP01_I,
727 .if_freq = TDA10046_FREQ_045,
728 .i2c_gate = 0x4b,
729 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300730 .request_firmware = philips_tda1004x_request_firmware
731};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200732
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300733static struct tda1004x_config asus_p7131_4871_config = {
734 .demod_address = 0x08,
735 .invert = 1,
736 .invert_oclk = 0,
737 .xtal_freq = TDA10046_XTAL_16M,
738 .agc_config = TDA10046_AGC_TDA827X,
739 .gpio_config = TDA10046_GP01_I,
740 .if_freq = TDA10046_FREQ_045,
741 .i2c_gate = 0x4b,
742 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300743 .antenna_switch= 2,
744 .request_firmware = philips_tda1004x_request_firmware
745};
746
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300747static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300748 .demod_address = 0x08,
749 .invert = 1,
750 .invert_oclk = 0,
751 .xtal_freq = TDA10046_XTAL_16M,
752 .agc_config = TDA10046_AGC_TDA827X,
753 .gpio_config = TDA10046_GP11_I,
754 .if_freq = TDA10046_FREQ_045,
755 .i2c_gate = 0x4b,
756 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300757 .antenna_switch= 2,
758 .request_firmware = philips_tda1004x_request_firmware
759};
Edgar Simo261f5082007-08-20 14:06:00 -0300760
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300761static struct tda1004x_config kworld_dvb_t_210_config = {
762 .demod_address = 0x08,
763 .invert = 1,
764 .invert_oclk = 0,
765 .xtal_freq = TDA10046_XTAL_16M,
766 .agc_config = TDA10046_AGC_TDA827X,
767 .gpio_config = TDA10046_GP11_I,
768 .if_freq = TDA10046_FREQ_045,
769 .i2c_gate = 0x4b,
770 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300771 .antenna_switch= 1,
772 .request_firmware = philips_tda1004x_request_firmware
773};
Edgar Simo261f5082007-08-20 14:06:00 -0300774
Edgar Simod90d9f52007-08-20 14:14:50 -0300775static struct tda1004x_config avermedia_super_007_config = {
776 .demod_address = 0x08,
777 .invert = 1,
778 .invert_oclk = 0,
779 .xtal_freq = TDA10046_XTAL_16M,
780 .agc_config = TDA10046_AGC_TDA827X,
781 .gpio_config = TDA10046_GP01_I,
782 .if_freq = TDA10046_FREQ_045,
783 .i2c_gate = 0x4b,
784 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300785 .antenna_switch= 1,
786 .request_firmware = philips_tda1004x_request_firmware
787};
788
Hermann Pitton4ba24372008-01-20 19:27:51 -0300789static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
790 .demod_address = 0x08,
791 .invert = 1,
792 .invert_oclk = 0,
793 .xtal_freq = TDA10046_XTAL_16M,
794 .agc_config = TDA10046_AGC_TDA827X,
795 .gpio_config = TDA10046_GP01_I,
796 .if_freq = TDA10046_FREQ_045,
797 .i2c_gate = 0x42,
798 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300799 .antenna_switch = 1,
800 .request_firmware = philips_tda1004x_request_firmware
801};
802
hermann pitton301e9d62008-09-14 17:49:14 -0300803static struct tda1004x_config asus_tiger_3in1_config = {
804 .demod_address = 0x0b,
805 .invert = 1,
806 .invert_oclk = 0,
807 .xtal_freq = TDA10046_XTAL_16M,
808 .agc_config = TDA10046_AGC_TDA827X,
809 .gpio_config = TDA10046_GP11_I,
810 .if_freq = TDA10046_FREQ_045,
811 .i2c_gate = 0x4b,
812 .tuner_address = 0x61,
813 .antenna_switch = 1,
814 .request_firmware = philips_tda1004x_request_firmware
815};
816
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300817/* ------------------------------------------------------------------
818 * special case: this card uses saa713x GPIO22 for the mode switch
819 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200820
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300821static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200822{
823 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300824 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200825 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300826 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200827 return 0;
828}
829
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300830static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200831{
832 struct saa7134_dev *dev = fe->dvb->priv;
833 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300834 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300835 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300836 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200837}
838
Michael Krufky8ce47da2007-04-27 12:31:14 -0300839static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300840 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300841 .sleep = ads_duo_tuner_sleep,
842 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300843};
844
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200845static struct tda1004x_config ads_tech_duo_config = {
846 .demod_address = 0x08,
847 .invert = 1,
848 .invert_oclk = 0,
849 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300850 .agc_config = TDA10046_AGC_TDA827X,
851 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200852 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300853 .tuner_address = 0x61,
854 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200855};
856
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300857/* ==================================================================
858 * tda10086 based DVB-S cards, helper functions
859 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300860
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300861static struct tda10086_config flydvbs = {
862 .demod_address = 0x0e,
863 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300864 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300865 .xtal_freq = TDA10086_XTAL_16M,
866};
867
868static struct tda10086_config sd1878_4m = {
869 .demod_address = 0x0e,
870 .invert = 0,
871 .diseqc_tone = 0,
872 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300873};
874
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300875/* ------------------------------------------------------------------
876 * special case: lnb supply is connected to the gated i2c
877 */
878
879static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
880{
881 int res = -EIO;
882 struct saa7134_dev *dev = fe->dvb->priv;
883 if (fe->ops.i2c_gate_ctrl) {
884 fe->ops.i2c_gate_ctrl(fe, 1);
885 if (dev->original_set_voltage)
886 res = dev->original_set_voltage(fe, voltage);
887 fe->ops.i2c_gate_ctrl(fe, 0);
888 }
889 return res;
890};
891
892static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
893{
894 int res = -EIO;
895 struct saa7134_dev *dev = fe->dvb->priv;
896 if (fe->ops.i2c_gate_ctrl) {
897 fe->ops.i2c_gate_ctrl(fe, 1);
898 if (dev->original_set_high_voltage)
899 res = dev->original_set_high_voltage(fe, arg);
900 fe->ops.i2c_gate_ctrl(fe, 0);
901 }
902 return res;
903};
904
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300905static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
906{
907 struct saa7134_dev *dev = fe->dvb->priv;
908 u8 wbuf[2] = { 0x1f, 00 };
909 u8 rbuf;
910 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
911 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
912
913 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
914 return -EIO;
915 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
916 if (voltage == SEC_VOLTAGE_18)
917 wbuf[1] = rbuf | 0x10;
918 else
919 wbuf[1] = rbuf & 0xef;
920 msg[0].len = 2;
921 i2c_transfer(&dev->i2c_adap, msg, 1);
922 return 0;
923}
924
925static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
926{
927 struct saa7134_dev *dev = fe->dvb->priv;
928 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
929 return -EIO;
930}
931
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300932/* ==================================================================
933 * nxt200x based ATSC cards, helper functions
934 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800935
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800936static struct nxt200x_config avertvhda180 = {
937 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800938};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300939
940static struct nxt200x_config kworldatsc110 = {
941 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300942};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800943
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300944/* ==================================================================
945 * Core code
946 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700947
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948static int dvb_init(struct saa7134_dev *dev)
949{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -0300950 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300951 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300952 struct videobuf_dvb_frontend *fe0;
953
Darron Broadf972e0b2008-10-11 11:24:30 -0300954 /* FIXME: add support for multi-frontend */
955 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -0300956 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -0300957 dev->frontends.active_fe_id = 0;
958
959 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
960
961 if (videobuf_dvb_alloc_frontend(dev, &dev->frontends, 1) == NULL) {
962 printk(KERN_ERR "%s() failed to alloc\n", __func__);
963 return -ENOMEM;
964 }
965
Steven Toth363c35f2008-10-11 11:05:50 -0300966 /* Get the first frontend */
Darron Broad92abe9e2008-10-11 11:18:53 -0300967 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300968 if (!fe0)
969 return -EINVAL;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300970
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971 /* init struct videobuf_dvb */
972 dev->ts.nr_bufs = 32;
973 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -0300974 fe0->dvb.name = dev->name;
975 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -0300976 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 V4L2_BUF_TYPE_VIDEO_CAPTURE,
978 V4L2_FIELD_ALTERNATE,
979 sizeof(struct saa7134_buf),
980 dev);
981
982 switch (dev->board) {
983 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300984 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -0300985 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300986 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300987 if (fe0->dvb.frontend) {
988 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300989 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200991 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -0300992 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300993 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -0300994 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300995 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300996 if (fe0->dvb.frontend) {
997 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -0300998 &dev->i2c_adap, 0x61,
999 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001000 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001001 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001002 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001003 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001004 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001005 &avermedia_xc3028_mt352_dev,
1006 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001007 attach_xc3028 = 1;
1008 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001010 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001011 &medion_cardbus,
1012 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001013 if (fe0->dvb.frontend) {
1014 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd332008-04-22 14:46:16 -03001015 &dev->i2c_adap, medion_cardbus.tuner_address,
1016 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001017 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001019 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001020 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001021 &philips_tu1216_60_config,
1022 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001023 if (fe0->dvb.frontend) {
1024 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1025 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001026 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001027 break;
1028 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001029 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001030 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1031 &tda827x_cfg_0) < 0)
1032 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001033 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001034 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001035 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Steven Toth363c35f2008-10-11 11:05:50 -03001036 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001037 &philips_europa_config,
1038 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001039 if (fe0->dvb.frontend) {
1040 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1041 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1042 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1043 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1044 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001045 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001046 break;
1047 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001048 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001049 &philips_tu1216_61_config,
1050 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001051 if (fe0->dvb.frontend) {
1052 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1053 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001054 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001055 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001056 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001057 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1058 &tda827x_cfg_2) < 0)
1059 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001060 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001061 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001062 if (configure_tda827x_fe(dev, &philips_tiger_config,
1063 &tda827x_cfg_0) < 0)
1064 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001065 break;
1066 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001067 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1068 &tda827x_cfg_1) < 0)
1069 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001070 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001071 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001072 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1073 &tda827x_cfg_1) < 0)
1074 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001075 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001076 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001077 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1078 &tda827x_cfg_0) < 0)
1079 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001080 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001081 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001082 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1083 &tda827x_cfg_0) < 0)
1084 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001085 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001086 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001087 if (!use_frontend) { /* terrestrial */
1088 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1089 &tda827x_cfg_0) < 0)
1090 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001091 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001092 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1093 if (fe0->dvb.frontend) {
1094 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001095 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001096 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001097 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001098 }
Steven Toth363c35f2008-10-11 11:05:50 -03001099 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001100 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001101 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001102 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001103 }
1104 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001105 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001106 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001107 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001108 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001109 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001110 &ads_tech_duo_config,
1111 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001112 if (fe0->dvb.frontend) {
1113 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001114 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1115 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001116 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001117 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001118 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001119 }
Mauro Carvalho Chehabbc36ec72008-06-14 10:44:04 -03001120 } else
1121 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001122 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001123 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001124 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1125 &tda827x_cfg_0) < 0)
1126 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001127 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001128 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001129 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001130 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1131 &tda827x_cfg_0) < 0)
1132 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001133 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001134 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001135 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001136 if (fe0->dvb.frontend) {
1137 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001138 u8 dev_id = dev->eedata[2];
1139 u8 data = 0xc4;
1140 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1141
Steven Toth363c35f2008-10-11 11:05:50 -03001142 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001143 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001144 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001145 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001146 goto dettach_frontend;
1147 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001148 if (dev_id != 0x08) {
1149 /* we need to open the i2c gate (we know it exists) */
1150 fe->ops.i2c_gate_ctrl(fe, 1);
1151 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001152 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001153 wprintk("%s: Medion Quadro, no ISL6405 "
1154 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001155 goto dettach_frontend;
1156 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001157 if (dev_id == 0x07) {
1158 /* fire up the 2nd section of the LNB supply since
1159 we can't do this from the other section */
1160 msg.buf = &data;
1161 i2c_transfer(&dev->i2c_adap, &msg, 1);
1162 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001163 fe->ops.i2c_gate_ctrl(fe, 0);
1164 dev->original_set_voltage = fe->ops.set_voltage;
1165 fe->ops.set_voltage = md8800_set_voltage;
1166 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1167 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1168 } else {
1169 fe->ops.set_voltage = md8800_set_voltage2;
1170 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1171 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001172 }
1173 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001174 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001175 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001176 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001177 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001178 if (fe0->dvb.frontend)
1179 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001180 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001181 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001182 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001183 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001184 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001185 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001186 if (fe0->dvb.frontend)
1187 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001188 &dev->i2c_adap, 0x61,
1189 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001190 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001191 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001192 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001193 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001194 if (fe0->dvb.frontend) {
1195 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001196 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001197 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001198 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001199 }
Steven Toth363c35f2008-10-11 11:05:50 -03001200 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001201 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001202 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001203 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001204 }
1205 }
1206 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001207 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001208 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001209 &medion_cardbus,
1210 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001211 if (fe0->dvb.frontend) {
1212 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1213 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001214
Steven Toth363c35f2008-10-11 11:05:50 -03001215 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd332008-04-22 14:46:16 -03001216 &dev->i2c_adap, medion_cardbus.tuner_address,
1217 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001218 }
1219 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001220 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001221 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001222 &philips_europa_config,
1223 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001224 if (fe0->dvb.frontend) {
1225 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1226 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001227 }
1228 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001229 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001230 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1231 &tda827x_cfg_0) < 0)
1232 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001233 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001234 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001235 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1236 &tda827x_cfg_0) < 0)
1237 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001238 break;
1239 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001240 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1241 &tda827x_cfg_2) < 0)
1242 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001243 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001244 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001245 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1246 &tda827x_cfg_2) < 0)
1247 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001248 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001249 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001250 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1251 &tda827x_cfg_2) < 0)
1252 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001253 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001254 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001255 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1256 &tda827x_cfg_0) < 0)
1257 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001258 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001259 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001260 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1261 &tda827x_cfg_2_sw42) < 0)
1262 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001263 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001264 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001265 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001266 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001267 if (fe0->dvb.frontend) {
1268 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001269 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001270 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001271 goto dettach_frontend;
1272 }
Steven Toth363c35f2008-10-11 11:05:50 -03001273 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001274 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001275 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001276 goto dettach_frontend;
1277 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001278 }
1279 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001280 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001281 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1282 &tda827x_cfg_0) < 0)
1283 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001284 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001285 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001286 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1287 &tda827x_cfg_2) < 0)
1288 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001289 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001290 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001291 dprintk("AverMedia E506R dvb setup\n");
1292 saa7134_set_gpio(dev, 25, 0);
1293 msleep(10);
1294 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001295 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001296 &avermedia_xc3028_mt352_dev,
1297 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001298 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001299 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001300 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001301 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001302 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001303 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001304 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001305 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001306 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001307 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001308 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001309 goto dettach_frontend;
1310 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001311 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001312 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001313 fe->ops.i2c_gate_ctrl(fe, 1);
1314 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001315 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001316 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001317 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001318 goto dettach_frontend;
1319 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001320 fe->ops.i2c_gate_ctrl(fe, 0);
1321 dev->original_set_voltage = fe->ops.set_voltage;
1322 fe->ops.set_voltage = md8800_set_voltage;
1323 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1324 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1325 }
1326 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001327 case SAA7134_BOARD_AVERMEDIA_M103:
1328 saa7134_set_gpio(dev, 25, 0);
1329 msleep(10);
1330 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001331 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001332 &avermedia_xc3028_mt352_dev,
1333 &dev->i2c_adap);
1334 attach_xc3028 = 1;
1335 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001336 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1337 if (!use_frontend) { /* terrestrial */
1338 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1339 &tda827x_cfg_2) < 0)
1340 goto dettach_frontend;
1341 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001342 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001343 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001344 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001345 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001346 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001347 &dev->i2c_adap, 0) == NULL) {
1348 wprintk("%s: Asus Tiger 3in1, no "
1349 "tda826x found!\n", __func__);
1350 goto dettach_frontend;
1351 }
Steven Toth363c35f2008-10-11 11:05:50 -03001352 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001353 &dev->i2c_adap, 0, 0) == NULL) {
1354 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1355 " found!\n", __func__);
1356 goto dettach_frontend;
1357 }
1358 }
1359 }
1360 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001361 case SAA7134_BOARD_ASUSTeK_TIGER:
1362 if (configure_tda827x_fe(dev, &philips_tiger_config,
1363 &tda827x_cfg_0) < 0)
1364 goto dettach_frontend;
1365 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001367 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368 break;
1369 }
1370
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001371 if (attach_xc3028) {
1372 struct dvb_frontend *fe;
1373 struct xc2028_config cfg = {
1374 .i2c_adap = &dev->i2c_adap,
1375 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001376 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001377
Steven Toth363c35f2008-10-11 11:05:50 -03001378 if (!fe0->dvb.frontend)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001379 return -1;
1380
Steven Toth363c35f2008-10-11 11:05:50 -03001381 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001382 if (!fe) {
1383 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1384 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001385 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001386 }
1387 }
1388
Steven Toth363c35f2008-10-11 11:05:50 -03001389 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001390 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 return -1;
1392 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001393 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001394 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395
1396 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001397 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Darron Broad59b18422008-10-11 11:44:05 -03001398 &dev->pci->dev, adapter_nr, 0);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001399
1400 /* this sequence is necessary to make the tda1004x load its firmware
1401 * and to enter analog mode of hybrid boards
1402 */
1403 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001404 if (fe0->dvb.frontend->ops.init)
1405 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1406 if (fe0->dvb.frontend->ops.sleep)
1407 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1408 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1409 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001410 }
1411 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001412
1413dettach_frontend:
Steven Toth363c35f2008-10-11 11:05:50 -03001414 if (fe0->dvb.frontend)
1415 dvb_frontend_detach(fe0->dvb.frontend);
1416 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001417
1418 return -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419}
1420
1421static int dvb_fini(struct saa7134_dev *dev)
1422{
Steven Toth363c35f2008-10-11 11:05:50 -03001423 struct videobuf_dvb_frontend *fe0;
1424
1425 /* Get the first frontend */
1426 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1427 if (!fe0)
1428 return -EINVAL;
1429
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001430 /* FIXME: I suspect that this code is bogus, since the entry for
1431 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1432 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1433 */
1434 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1435 struct v4l2_priv_tun_config tda9887_cfg;
1436 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001438 tda9887_cfg.tuner = TUNER_TDA9887;
1439 tda9887_cfg.priv = &on;
1440
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 /* otherwise we don't detect the tuner on next insmod */
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001442 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001443 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001444 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001445 /* turn off the 2nd lnb supply */
1446 u8 data = 0x80;
1447 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1448 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001449 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001450 if (fe->ops.i2c_gate_ctrl) {
1451 fe->ops.i2c_gate_ctrl(fe, 1);
1452 i2c_transfer(&dev->i2c_adap, &msg, 1);
1453 fe->ops.i2c_gate_ctrl(fe, 0);
1454 }
1455 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001456 }
Steven Toth363c35f2008-10-11 11:05:50 -03001457 if (fe0->dvb.frontend)
1458 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 return 0;
1460}
1461
1462static struct saa7134_mpeg_ops dvb_ops = {
1463 .type = SAA7134_MPEG_DVB,
1464 .init = dvb_init,
1465 .fini = dvb_fini,
1466};
1467
1468static int __init dvb_register(void)
1469{
1470 return saa7134_ts_register(&dvb_ops);
1471}
1472
1473static void __exit dvb_unregister(void)
1474{
1475 saa7134_ts_unregister(&dvb_ops);
1476}
1477
1478module_init(dvb_register);
1479module_exit(dvb_unregister);
1480
1481/* ------------------------------------------------------------------ */
1482/*
1483 * Local variables:
1484 * c-basic-offset: 8
1485 * End:
1486 */