blob: 8ada0497fa03e003b546f4a89925d370cd32165a [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 Krufkycb89cd32008-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
540 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 0);
541
542 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
543 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300544 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300545 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
546 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300547 cdec_conf->tuner_address,
548 &dev->i2c_adap, tuner_conf))
549 return 0;
550
551 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300552 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300553 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300554 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300555}
556
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800557/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300558
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300559static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300560 .init = philips_tda827x_tuner_init,
561 .sleep = philips_tda827x_tuner_sleep,
562 .config = 0,
563 .switch_addr = 0
564};
565
566static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300567 .init = philips_tda827x_tuner_init,
568 .sleep = philips_tda827x_tuner_sleep,
569 .config = 1,
570 .switch_addr = 0x4b
571};
572
573static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300574 .init = philips_tda827x_tuner_init,
575 .sleep = philips_tda827x_tuner_sleep,
576 .config = 2,
577 .switch_addr = 0x4b
578};
579
580static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300581 .init = philips_tda827x_tuner_init,
582 .sleep = philips_tda827x_tuner_sleep,
583 .config = 2,
584 .switch_addr = 0x42
585};
586
587/* ------------------------------------------------------------------ */
588
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300589static struct tda1004x_config tda827x_lifeview_config = {
590 .demod_address = 0x08,
591 .invert = 1,
592 .invert_oclk = 0,
593 .xtal_freq = TDA10046_XTAL_16M,
594 .agc_config = TDA10046_AGC_TDA827X,
595 .gpio_config = TDA10046_GP11_I,
596 .if_freq = TDA10046_FREQ_045,
597 .tuner_address = 0x60,
598 .request_firmware = philips_tda1004x_request_firmware
599};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800600
601static struct tda1004x_config philips_tiger_config = {
602 .demod_address = 0x08,
603 .invert = 1,
604 .invert_oclk = 0,
605 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300606 .agc_config = TDA10046_AGC_TDA827X,
607 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300608 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300609 .i2c_gate = 0x4b,
610 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300611 .antenna_switch= 1,
612 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300613};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300614
615static struct tda1004x_config cinergy_ht_config = {
616 .demod_address = 0x08,
617 .invert = 1,
618 .invert_oclk = 0,
619 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300620 .agc_config = TDA10046_AGC_TDA827X,
621 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800622 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300623 .i2c_gate = 0x4b,
624 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300625 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800626};
627
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300628static struct tda1004x_config cinergy_ht_pci_config = {
629 .demod_address = 0x08,
630 .invert = 1,
631 .invert_oclk = 0,
632 .xtal_freq = TDA10046_XTAL_16M,
633 .agc_config = TDA10046_AGC_TDA827X,
634 .gpio_config = TDA10046_GP01_I,
635 .if_freq = TDA10046_FREQ_045,
636 .i2c_gate = 0x4b,
637 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300638 .request_firmware = philips_tda1004x_request_firmware
639};
640
641static struct tda1004x_config philips_tiger_s_config = {
642 .demod_address = 0x08,
643 .invert = 1,
644 .invert_oclk = 0,
645 .xtal_freq = TDA10046_XTAL_16M,
646 .agc_config = TDA10046_AGC_TDA827X,
647 .gpio_config = TDA10046_GP01_I,
648 .if_freq = TDA10046_FREQ_045,
649 .i2c_gate = 0x4b,
650 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300651 .antenna_switch= 1,
652 .request_firmware = philips_tda1004x_request_firmware
653};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200654
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300655static struct tda1004x_config pinnacle_pctv_310i_config = {
656 .demod_address = 0x08,
657 .invert = 1,
658 .invert_oclk = 0,
659 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300660 .agc_config = TDA10046_AGC_TDA827X,
661 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300662 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300663 .i2c_gate = 0x4b,
664 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300665 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300666};
667
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300668static struct tda1004x_config hauppauge_hvr_1110_config = {
669 .demod_address = 0x08,
670 .invert = 1,
671 .invert_oclk = 0,
672 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300673 .agc_config = TDA10046_AGC_TDA827X,
674 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300675 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300676 .i2c_gate = 0x4b,
677 .tuner_address = 0x61,
678 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300679};
680
Hartmut Hackmann83646812006-10-12 20:38:51 -0300681static struct tda1004x_config asus_p7131_dual_config = {
682 .demod_address = 0x08,
683 .invert = 1,
684 .invert_oclk = 0,
685 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300686 .agc_config = TDA10046_AGC_TDA827X,
687 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300688 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300689 .i2c_gate = 0x4b,
690 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300691 .antenna_switch= 2,
692 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300693};
694
Nico Sabbi420f32f2006-03-03 12:11:28 -0300695static struct tda1004x_config lifeview_trio_config = {
696 .demod_address = 0x09,
697 .invert = 1,
698 .invert_oclk = 0,
699 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300700 .agc_config = TDA10046_AGC_TDA827X,
701 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300702 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300703 .tuner_address = 0x60,
704 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300705};
706
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300707static struct tda1004x_config tevion_dvbt220rf_config = {
708 .demod_address = 0x08,
709 .invert = 1,
710 .invert_oclk = 0,
711 .xtal_freq = TDA10046_XTAL_16M,
712 .agc_config = TDA10046_AGC_TDA827X,
713 .gpio_config = TDA10046_GP11_I,
714 .if_freq = TDA10046_FREQ_045,
715 .tuner_address = 0x60,
716 .request_firmware = philips_tda1004x_request_firmware
717};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300718
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300719static struct tda1004x_config md8800_dvbt_config = {
720 .demod_address = 0x08,
721 .invert = 1,
722 .invert_oclk = 0,
723 .xtal_freq = TDA10046_XTAL_16M,
724 .agc_config = TDA10046_AGC_TDA827X,
725 .gpio_config = TDA10046_GP01_I,
726 .if_freq = TDA10046_FREQ_045,
727 .i2c_gate = 0x4b,
728 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300729 .request_firmware = philips_tda1004x_request_firmware
730};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200731
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300732static struct tda1004x_config asus_p7131_4871_config = {
733 .demod_address = 0x08,
734 .invert = 1,
735 .invert_oclk = 0,
736 .xtal_freq = TDA10046_XTAL_16M,
737 .agc_config = TDA10046_AGC_TDA827X,
738 .gpio_config = TDA10046_GP01_I,
739 .if_freq = TDA10046_FREQ_045,
740 .i2c_gate = 0x4b,
741 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300742 .antenna_switch= 2,
743 .request_firmware = philips_tda1004x_request_firmware
744};
745
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300746static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300747 .demod_address = 0x08,
748 .invert = 1,
749 .invert_oclk = 0,
750 .xtal_freq = TDA10046_XTAL_16M,
751 .agc_config = TDA10046_AGC_TDA827X,
752 .gpio_config = TDA10046_GP11_I,
753 .if_freq = TDA10046_FREQ_045,
754 .i2c_gate = 0x4b,
755 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300756 .antenna_switch= 2,
757 .request_firmware = philips_tda1004x_request_firmware
758};
Edgar Simo261f5082007-08-20 14:06:00 -0300759
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300760static struct tda1004x_config kworld_dvb_t_210_config = {
761 .demod_address = 0x08,
762 .invert = 1,
763 .invert_oclk = 0,
764 .xtal_freq = TDA10046_XTAL_16M,
765 .agc_config = TDA10046_AGC_TDA827X,
766 .gpio_config = TDA10046_GP11_I,
767 .if_freq = TDA10046_FREQ_045,
768 .i2c_gate = 0x4b,
769 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300770 .antenna_switch= 1,
771 .request_firmware = philips_tda1004x_request_firmware
772};
Edgar Simo261f5082007-08-20 14:06:00 -0300773
Edgar Simod90d9f52007-08-20 14:14:50 -0300774static struct tda1004x_config avermedia_super_007_config = {
775 .demod_address = 0x08,
776 .invert = 1,
777 .invert_oclk = 0,
778 .xtal_freq = TDA10046_XTAL_16M,
779 .agc_config = TDA10046_AGC_TDA827X,
780 .gpio_config = TDA10046_GP01_I,
781 .if_freq = TDA10046_FREQ_045,
782 .i2c_gate = 0x4b,
783 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300784 .antenna_switch= 1,
785 .request_firmware = philips_tda1004x_request_firmware
786};
787
Hermann Pitton4ba24372008-01-20 19:27:51 -0300788static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
789 .demod_address = 0x08,
790 .invert = 1,
791 .invert_oclk = 0,
792 .xtal_freq = TDA10046_XTAL_16M,
793 .agc_config = TDA10046_AGC_TDA827X,
794 .gpio_config = TDA10046_GP01_I,
795 .if_freq = TDA10046_FREQ_045,
796 .i2c_gate = 0x42,
797 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300798 .antenna_switch = 1,
799 .request_firmware = philips_tda1004x_request_firmware
800};
801
hermann pitton301e9d62008-09-14 17:49:14 -0300802static struct tda1004x_config asus_tiger_3in1_config = {
803 .demod_address = 0x0b,
804 .invert = 1,
805 .invert_oclk = 0,
806 .xtal_freq = TDA10046_XTAL_16M,
807 .agc_config = TDA10046_AGC_TDA827X,
808 .gpio_config = TDA10046_GP11_I,
809 .if_freq = TDA10046_FREQ_045,
810 .i2c_gate = 0x4b,
811 .tuner_address = 0x61,
812 .antenna_switch = 1,
813 .request_firmware = philips_tda1004x_request_firmware
814};
815
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300816/* ------------------------------------------------------------------
817 * special case: this card uses saa713x GPIO22 for the mode switch
818 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200819
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300820static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200821{
822 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300823 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200824 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300825 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200826 return 0;
827}
828
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300829static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200830{
831 struct saa7134_dev *dev = fe->dvb->priv;
832 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300833 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300834 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300835 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200836}
837
Michael Krufky8ce47da2007-04-27 12:31:14 -0300838static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300839 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300840 .sleep = ads_duo_tuner_sleep,
841 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300842};
843
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200844static struct tda1004x_config ads_tech_duo_config = {
845 .demod_address = 0x08,
846 .invert = 1,
847 .invert_oclk = 0,
848 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300849 .agc_config = TDA10046_AGC_TDA827X,
850 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200851 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300852 .tuner_address = 0x61,
853 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200854};
855
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300856/* ==================================================================
857 * tda10086 based DVB-S cards, helper functions
858 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300859
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300860static struct tda10086_config flydvbs = {
861 .demod_address = 0x0e,
862 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300863 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300864 .xtal_freq = TDA10086_XTAL_16M,
865};
866
867static struct tda10086_config sd1878_4m = {
868 .demod_address = 0x0e,
869 .invert = 0,
870 .diseqc_tone = 0,
871 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300872};
873
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300874/* ------------------------------------------------------------------
875 * special case: lnb supply is connected to the gated i2c
876 */
877
878static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
879{
880 int res = -EIO;
881 struct saa7134_dev *dev = fe->dvb->priv;
882 if (fe->ops.i2c_gate_ctrl) {
883 fe->ops.i2c_gate_ctrl(fe, 1);
884 if (dev->original_set_voltage)
885 res = dev->original_set_voltage(fe, voltage);
886 fe->ops.i2c_gate_ctrl(fe, 0);
887 }
888 return res;
889};
890
891static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
892{
893 int res = -EIO;
894 struct saa7134_dev *dev = fe->dvb->priv;
895 if (fe->ops.i2c_gate_ctrl) {
896 fe->ops.i2c_gate_ctrl(fe, 1);
897 if (dev->original_set_high_voltage)
898 res = dev->original_set_high_voltage(fe, arg);
899 fe->ops.i2c_gate_ctrl(fe, 0);
900 }
901 return res;
902};
903
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300904static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
905{
906 struct saa7134_dev *dev = fe->dvb->priv;
907 u8 wbuf[2] = { 0x1f, 00 };
908 u8 rbuf;
909 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
910 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
911
912 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
913 return -EIO;
914 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
915 if (voltage == SEC_VOLTAGE_18)
916 wbuf[1] = rbuf | 0x10;
917 else
918 wbuf[1] = rbuf & 0xef;
919 msg[0].len = 2;
920 i2c_transfer(&dev->i2c_adap, msg, 1);
921 return 0;
922}
923
924static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
925{
926 struct saa7134_dev *dev = fe->dvb->priv;
927 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
928 return -EIO;
929}
930
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300931/* ==================================================================
932 * nxt200x based ATSC cards, helper functions
933 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800934
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800935static struct nxt200x_config avertvhda180 = {
936 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800937};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300938
939static struct nxt200x_config kworldatsc110 = {
940 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300941};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800942
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300943/* ==================================================================
944 * Core code
945 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700946
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947static int dvb_init(struct saa7134_dev *dev)
948{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -0300949 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300950 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300951 struct videobuf_dvb_frontend *fe0;
952
953 /* Get the first frontend */
954 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 0);
955 if (!fe0)
956 return -EINVAL;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300957
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958 /* init struct videobuf_dvb */
959 dev->ts.nr_bufs = 32;
960 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -0300961 fe0->dvb.name = dev->name;
962 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -0300963 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 V4L2_BUF_TYPE_VIDEO_CAPTURE,
965 V4L2_FIELD_ALTERNATE,
966 sizeof(struct saa7134_buf),
967 dev);
968
969 switch (dev->board) {
970 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300971 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -0300972 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300973 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300974 if (fe0->dvb.frontend) {
975 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300976 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200978 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -0300979 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300980 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -0300981 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300982 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300983 if (fe0->dvb.frontend) {
984 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -0300985 &dev->i2c_adap, 0x61,
986 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300987 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200988 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300989 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -0300990 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -0300991 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -0300992 &avermedia_xc3028_mt352_dev,
993 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300994 attach_xc3028 = 1;
995 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -0300997 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300998 &medion_cardbus,
999 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001000 if (fe0->dvb.frontend) {
1001 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001002 &dev->i2c_adap, medion_cardbus.tuner_address,
1003 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001004 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001006 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001007 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001008 &philips_tu1216_60_config,
1009 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001010 if (fe0->dvb.frontend) {
1011 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1012 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001013 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001014 break;
1015 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001016 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001017 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1018 &tda827x_cfg_0) < 0)
1019 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001020 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001021 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001022 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Steven Toth363c35f2008-10-11 11:05:50 -03001023 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001024 &philips_europa_config,
1025 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001026 if (fe0->dvb.frontend) {
1027 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1028 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1029 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1030 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1031 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001032 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001033 break;
1034 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001035 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001036 &philips_tu1216_61_config,
1037 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001038 if (fe0->dvb.frontend) {
1039 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1040 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001041 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001042 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001043 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001044 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1045 &tda827x_cfg_2) < 0)
1046 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001047 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001048 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001049 if (configure_tda827x_fe(dev, &philips_tiger_config,
1050 &tda827x_cfg_0) < 0)
1051 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001052 break;
1053 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001054 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1055 &tda827x_cfg_1) < 0)
1056 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001057 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001058 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001059 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1060 &tda827x_cfg_1) < 0)
1061 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001062 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001063 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001064 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1065 &tda827x_cfg_0) < 0)
1066 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001067 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001068 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001069 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1070 &tda827x_cfg_0) < 0)
1071 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001072 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001073 case SAA7134_BOARD_FLYDVB_TRIO: // XXXXXX multifrontend
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001074 if (!use_frontend) { /* terrestrial */
1075 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1076 &tda827x_cfg_0) < 0)
1077 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001078 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001079 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1080 if (fe0->dvb.frontend) {
1081 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001082 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001083 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001084 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001085 }
Steven Toth363c35f2008-10-11 11:05:50 -03001086 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001087 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001088 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001089 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001090 }
1091 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001092 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001093 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001094 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001095 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001096 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001097 &ads_tech_duo_config,
1098 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001099 if (fe0->dvb.frontend) {
1100 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001101 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1102 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001103 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001104 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001105 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001106 }
Mauro Carvalho Chehabbc36ec7462008-06-14 10:44:04 -03001107 } else
1108 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001109 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001110 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001111 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1112 &tda827x_cfg_0) < 0)
1113 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001114 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001115 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001116 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001117 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1118 &tda827x_cfg_0) < 0)
1119 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001120 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001121 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001122 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001123 if (fe0->dvb.frontend) {
1124 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001125 u8 dev_id = dev->eedata[2];
1126 u8 data = 0xc4;
1127 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1128
Steven Toth363c35f2008-10-11 11:05:50 -03001129 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001130 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001131 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001132 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001133 goto dettach_frontend;
1134 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001135 if (dev_id != 0x08) {
1136 /* we need to open the i2c gate (we know it exists) */
1137 fe->ops.i2c_gate_ctrl(fe, 1);
1138 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001139 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001140 wprintk("%s: Medion Quadro, no ISL6405 "
1141 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001142 goto dettach_frontend;
1143 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001144 if (dev_id == 0x07) {
1145 /* fire up the 2nd section of the LNB supply since
1146 we can't do this from the other section */
1147 msg.buf = &data;
1148 i2c_transfer(&dev->i2c_adap, &msg, 1);
1149 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001150 fe->ops.i2c_gate_ctrl(fe, 0);
1151 dev->original_set_voltage = fe->ops.set_voltage;
1152 fe->ops.set_voltage = md8800_set_voltage;
1153 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1154 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1155 } else {
1156 fe->ops.set_voltage = md8800_set_voltage2;
1157 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1158 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001159 }
1160 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001161 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001162 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001163 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001164 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001165 if (fe0->dvb.frontend)
1166 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001167 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001168 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001169 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001170 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001171 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001172 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001173 if (fe0->dvb.frontend)
1174 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001175 &dev->i2c_adap, 0x61,
1176 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001177 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001178 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001179 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001180 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001181 if (fe0->dvb.frontend) {
1182 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001183 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001184 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001185 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001186 }
Steven Toth363c35f2008-10-11 11:05:50 -03001187 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001188 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001189 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001190 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001191 }
1192 }
1193 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001194 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001195 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001196 &medion_cardbus,
1197 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001198 if (fe0->dvb.frontend) {
1199 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1200 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001201
Steven Toth363c35f2008-10-11 11:05:50 -03001202 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001203 &dev->i2c_adap, medion_cardbus.tuner_address,
1204 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001205 }
1206 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001207 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001208 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001209 &philips_europa_config,
1210 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001211 if (fe0->dvb.frontend) {
1212 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1213 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001214 }
1215 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001216 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001217 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1218 &tda827x_cfg_0) < 0)
1219 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001220 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001221 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001222 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1223 &tda827x_cfg_0) < 0)
1224 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001225 break;
1226 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001227 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1228 &tda827x_cfg_2) < 0)
1229 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001230 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001231 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001232 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1233 &tda827x_cfg_2) < 0)
1234 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001235 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001236 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001237 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1238 &tda827x_cfg_2) < 0)
1239 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001240 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001241 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001242 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1243 &tda827x_cfg_0) < 0)
1244 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001245 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001246 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001247 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1248 &tda827x_cfg_2_sw42) < 0)
1249 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001250 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001251 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001252 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001253 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001254 if (fe0->dvb.frontend) {
1255 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001256 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001257 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001258 goto dettach_frontend;
1259 }
Steven Toth363c35f2008-10-11 11:05:50 -03001260 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001261 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001262 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001263 goto dettach_frontend;
1264 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001265 }
1266 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001267 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001268 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1269 &tda827x_cfg_0) < 0)
1270 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001271 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001272 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001273 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1274 &tda827x_cfg_2) < 0)
1275 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001276 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001277 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001278 dprintk("AverMedia E506R dvb setup\n");
1279 saa7134_set_gpio(dev, 25, 0);
1280 msleep(10);
1281 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001282 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001283 &avermedia_xc3028_mt352_dev,
1284 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001285 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001286 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001287 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001288 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001289 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001290 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001291 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001292 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001293 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001294 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001295 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001296 goto dettach_frontend;
1297 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001298 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001299 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001300 fe->ops.i2c_gate_ctrl(fe, 1);
1301 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001302 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001303 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001304 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001305 goto dettach_frontend;
1306 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001307 fe->ops.i2c_gate_ctrl(fe, 0);
1308 dev->original_set_voltage = fe->ops.set_voltage;
1309 fe->ops.set_voltage = md8800_set_voltage;
1310 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1311 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1312 }
1313 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001314 case SAA7134_BOARD_AVERMEDIA_M103:
1315 saa7134_set_gpio(dev, 25, 0);
1316 msleep(10);
1317 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001318 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001319 &avermedia_xc3028_mt352_dev,
1320 &dev->i2c_adap);
1321 attach_xc3028 = 1;
1322 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001323 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1324 if (!use_frontend) { /* terrestrial */
1325 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1326 &tda827x_cfg_2) < 0)
1327 goto dettach_frontend;
1328 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001329 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001330 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001331 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001332 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001333 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001334 &dev->i2c_adap, 0) == NULL) {
1335 wprintk("%s: Asus Tiger 3in1, no "
1336 "tda826x found!\n", __func__);
1337 goto dettach_frontend;
1338 }
Steven Toth363c35f2008-10-11 11:05:50 -03001339 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001340 &dev->i2c_adap, 0, 0) == NULL) {
1341 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1342 " found!\n", __func__);
1343 goto dettach_frontend;
1344 }
1345 }
1346 }
1347 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001348 case SAA7134_BOARD_ASUSTeK_TIGER:
1349 if (configure_tda827x_fe(dev, &philips_tiger_config,
1350 &tda827x_cfg_0) < 0)
1351 goto dettach_frontend;
1352 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001354 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 break;
1356 }
1357
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001358 if (attach_xc3028) {
1359 struct dvb_frontend *fe;
1360 struct xc2028_config cfg = {
1361 .i2c_adap = &dev->i2c_adap,
1362 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001363 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001364
Steven Toth363c35f2008-10-11 11:05:50 -03001365 if (!fe0->dvb.frontend)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001366 return -1;
1367
Steven Toth363c35f2008-10-11 11:05:50 -03001368 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001369 if (!fe) {
1370 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1371 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001372 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001373 }
1374 }
1375
Steven Toth363c35f2008-10-11 11:05:50 -03001376 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001377 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378 return -1;
1379 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001380 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001381 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001382
1383 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001384 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1385 &dev->pci->dev, adapter_nr);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001386
1387 /* this sequence is necessary to make the tda1004x load its firmware
1388 * and to enter analog mode of hybrid boards
1389 */
1390 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001391 if (fe0->dvb.frontend->ops.init)
1392 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1393 if (fe0->dvb.frontend->ops.sleep)
1394 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1395 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1396 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001397 }
1398 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001399
1400dettach_frontend:
Steven Toth363c35f2008-10-11 11:05:50 -03001401 if (fe0->dvb.frontend)
1402 dvb_frontend_detach(fe0->dvb.frontend);
1403 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001404
1405 return -1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406}
1407
1408static int dvb_fini(struct saa7134_dev *dev)
1409{
Steven Toth363c35f2008-10-11 11:05:50 -03001410 struct videobuf_dvb_frontend *fe0;
1411
1412 /* Get the first frontend */
1413 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1414 if (!fe0)
1415 return -EINVAL;
1416
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001417 /* FIXME: I suspect that this code is bogus, since the entry for
1418 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1419 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1420 */
1421 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1422 struct v4l2_priv_tun_config tda9887_cfg;
1423 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001425 tda9887_cfg.tuner = TUNER_TDA9887;
1426 tda9887_cfg.priv = &on;
1427
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428 /* otherwise we don't detect the tuner on next insmod */
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001429 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001430 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001431 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001432 /* turn off the 2nd lnb supply */
1433 u8 data = 0x80;
1434 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1435 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001436 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001437 if (fe->ops.i2c_gate_ctrl) {
1438 fe->ops.i2c_gate_ctrl(fe, 1);
1439 i2c_transfer(&dev->i2c_adap, &msg, 1);
1440 fe->ops.i2c_gate_ctrl(fe, 0);
1441 }
1442 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001443 }
Steven Toth363c35f2008-10-11 11:05:50 -03001444 if (fe0->dvb.frontend)
1445 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001446 return 0;
1447}
1448
1449static struct saa7134_mpeg_ops dvb_ops = {
1450 .type = SAA7134_MPEG_DVB,
1451 .init = dvb_init,
1452 .fini = dvb_fini,
1453};
1454
1455static int __init dvb_register(void)
1456{
1457 return saa7134_ts_register(&dvb_ops);
1458}
1459
1460static void __exit dvb_unregister(void)
1461{
1462 saa7134_ts_unregister(&dvb_ops);
1463}
1464
1465module_init(dvb_register);
1466module_exit(dvb_unregister);
1467
1468/* ------------------------------------------------------------------ */
1469/*
1470 * Local variables:
1471 * c-basic-offset: 8
1472 * End:
1473 */