blob: 80ad96ad8939ec4a492bdaf30954d125d8fb97e3 [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
Dmitri Belimov47aeba52008-12-23 03:53:03 -030052#include "zl10353.h"
53
Matthias Schwarzott04574182009-02-24 12:35:16 -030054#include "zl10036.h"
55#include "mt312.h"
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
58MODULE_LICENSE("GPL");
59
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030060static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070061
Linus Torvalds1da177e2005-04-16 15:20:36 -070062module_param(antenna_pwr, int, 0444);
63MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
64
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030065static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030066module_param(use_frontend, int, 0644);
67MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030068
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030069static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030070module_param(debug, int, 0644);
71MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
72
Janne Grunau78e92002008-04-09 19:13:13 -030073DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
74
Trent Piephocf3c34c2007-03-07 18:19:48 -030075#define dprintk(fmt, arg...) do { if (debug) \
76 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
77
78/* Print a warning */
79#define wprintk(fmt, arg...) \
80 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030081
82/* ------------------------------------------------------------------
83 * mt352 based DVB-T cards
84 */
85
Linus Torvalds1da177e2005-04-16 15:20:36 -070086static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
87{
88 u32 ok;
89
90 if (!on) {
91 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
92 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
93 return 0;
94 }
95
96 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
97 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
98 udelay(10);
99
100 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
101 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
102 udelay(10);
103 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
104 udelay(10);
105 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300106 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108 if (!ok)
109 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
110 return ok;
111}
112
113static int mt352_pinnacle_init(struct dvb_frontend* fe)
114{
115 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
116 static u8 reset [] = { RESET, 0x80 };
117 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
118 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
119 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
120 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
121 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
122 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
123 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
124 struct saa7134_dev *dev= fe->dvb->priv;
125
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300126 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127
128 mt352_write(fe, clock_config, sizeof(clock_config));
129 udelay(200);
130 mt352_write(fe, reset, sizeof(reset));
131 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
132 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
133 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
134 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
135
136 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
137 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
138 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 return 0;
141}
142
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200143static int mt352_aver777_init(struct dvb_frontend* fe)
144{
145 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
146 static u8 reset [] = { RESET, 0x80 };
147 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
148 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
149 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
150
151 mt352_write(fe, clock_config, sizeof(clock_config));
152 udelay(200);
153 mt352_write(fe, reset, sizeof(reset));
154 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
155 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
156 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
157
158 return 0;
159}
160
Tim Farrington6e501a32008-06-15 13:33:42 -0300161static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300162{
Tim Farrington6e501a32008-06-15 13:33:42 -0300163 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
164 static u8 reset [] = { RESET, 0x80 };
165 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
166 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300167 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
168
169 mt352_write(fe, clock_config, sizeof(clock_config));
170 udelay(200);
171 mt352_write(fe, reset, sizeof(reset));
172 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
173 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
174 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300175 return 0;
176}
177
Andrew de Quincey0463f122006-05-16 17:22:02 -0300178static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
179 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300181 u8 off[] = { 0x00, 0xf1};
182 u8 on[] = { 0x00, 0x71};
183 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185 struct saa7134_dev *dev = fe->dvb->priv;
186 struct v4l2_frequency f;
187
188 /* set frequency (mt2050) */
189 f.tuner = 0;
190 f.type = V4L2_TUNER_DIGITAL_TV;
191 f.frequency = params->frequency / 1000 * 16 / 1000;
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);
Hans Verkuilfac69862009-01-17 12:17:14 -0300195 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300196 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300197 if (fe->ops.i2c_gate_ctrl)
198 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300199 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200
201 pinnacle_antenna_pwr(dev, antenna_pwr);
202
203 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300204 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205}
206
207static struct mt352_config pinnacle_300i = {
208 .demod_address = 0x3c >> 1,
209 .adc_clock = 20333,
210 .if2 = 36150,
211 .no_tuner = 1,
212 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200214
215static struct mt352_config avermedia_777 = {
216 .demod_address = 0xf,
217 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200218};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219
Tim Farrington6e501a32008-06-15 13:33:42 -0300220static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300221 .demod_address = (0x1e >> 1),
222 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300223 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300224};
225
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300226/* ==================================================================
227 * tda1004x based DVB-T cards, helper functions
228 */
229
230static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
231 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700232{
233 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300234 return request_firmware(fw, name, &dev->pci->dev);
235}
236
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300237/* ------------------------------------------------------------------
238 * these tuners are tu1216, td1316(a)
239 */
240
241static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
242{
243 struct saa7134_dev *dev = fe->dvb->priv;
244 struct tda1004x_state *state = fe->demodulator_priv;
245 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700246 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800247 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700248 sizeof(tuner_buf) };
249 int tuner_frequency = 0;
250 u8 band, cp, filter;
251
252 /* determine charge pump */
253 tuner_frequency = params->frequency + 36166000;
254 if (tuner_frequency < 87000000)
255 return -EINVAL;
256 else if (tuner_frequency < 130000000)
257 cp = 3;
258 else if (tuner_frequency < 160000000)
259 cp = 5;
260 else if (tuner_frequency < 200000000)
261 cp = 6;
262 else if (tuner_frequency < 290000000)
263 cp = 3;
264 else if (tuner_frequency < 420000000)
265 cp = 5;
266 else if (tuner_frequency < 480000000)
267 cp = 6;
268 else if (tuner_frequency < 620000000)
269 cp = 3;
270 else if (tuner_frequency < 830000000)
271 cp = 5;
272 else if (tuner_frequency < 895000000)
273 cp = 7;
274 else
275 return -EINVAL;
276
277 /* determine band */
278 if (params->frequency < 49000000)
279 return -EINVAL;
280 else if (params->frequency < 161000000)
281 band = 1;
282 else if (params->frequency < 444000000)
283 band = 2;
284 else if (params->frequency < 861000000)
285 band = 4;
286 else
287 return -EINVAL;
288
289 /* setup PLL filter */
290 switch (params->u.ofdm.bandwidth) {
291 case BANDWIDTH_6_MHZ:
292 filter = 0;
293 break;
294
295 case BANDWIDTH_7_MHZ:
296 filter = 0;
297 break;
298
299 case BANDWIDTH_8_MHZ:
300 filter = 1;
301 break;
302
303 default:
304 return -EINVAL;
305 }
306
307 /* calculate divisor
308 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
309 */
310 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
311
312 /* setup tuner buffer */
313 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
314 tuner_buf[1] = tuner_frequency & 0xff;
315 tuner_buf[2] = 0xca;
316 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
317
Patrick Boettcherdea74862006-05-14 05:01:31 -0300318 if (fe->ops.i2c_gate_ctrl)
319 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300320 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300321 wprintk("could not write to tuner at addr: 0x%02x\n",
322 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700323 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300324 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700325 msleep(1);
326 return 0;
327}
328
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300329static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800330{
331 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300332 struct tda1004x_state *state = fe->demodulator_priv;
333 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800334 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
335 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
336
337 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300338 if (fe->ops.i2c_gate_ctrl)
339 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800340 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
341 return -EIO;
342 msleep(1);
343
344 return 0;
345}
346
347/* ------------------------------------------------------------------ */
348
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800349static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700350 .demod_address = 0x8,
351 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800352 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700353 .xtal_freq = TDA10046_XTAL_4M,
354 .agc_config = TDA10046_AGC_DEFAULT,
355 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300356 .tuner_address = 0x60,
357 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358};
359
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800360static struct tda1004x_config philips_tu1216_61_config = {
361
362 .demod_address = 0x8,
363 .invert = 1,
364 .invert_oclk = 0,
365 .xtal_freq = TDA10046_XTAL_4M,
366 .agc_config = TDA10046_AGC_DEFAULT,
367 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300368 .tuner_address = 0x61,
369 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800370};
371
372/* ------------------------------------------------------------------ */
373
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300374static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800375{
376 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300377 struct tda1004x_state *state = fe->demodulator_priv;
378 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800379 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300380 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800381
382 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300383 if (fe->ops.i2c_gate_ctrl)
384 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800385 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
386 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800387 return 0;
388}
389
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300390static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800391{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300392 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800393}
394
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300395static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
396{
397 struct saa7134_dev *dev = fe->dvb->priv;
398 struct tda1004x_state *state = fe->demodulator_priv;
399 u8 addr = state->config->tuner_address;
400 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
401 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
402
403 /* switch the tuner to analog mode */
404 if (fe->ops.i2c_gate_ctrl)
405 fe->ops.i2c_gate_ctrl(fe, 1);
406 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
407 return -EIO;
408 return 0;
409}
410
411/* ------------------------------------------------------------------ */
412
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300413static int philips_europa_tuner_init(struct dvb_frontend *fe)
414{
415 struct saa7134_dev *dev = fe->dvb->priv;
416 static u8 msg[] = { 0x00, 0x40};
417 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
418
419
420 if (philips_td1316_tuner_init(fe))
421 return -EIO;
422 msleep(1);
423 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
424 return -EIO;
425
426 return 0;
427}
428
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300429static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800430{
431 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800432
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300433 static u8 msg[] = { 0x00, 0x14 };
434 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
435
436 if (philips_td1316_tuner_sleep(fe))
437 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800438
439 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300440 if (fe->ops.i2c_gate_ctrl)
441 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800442 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300443 return 0;
444}
445
446static int philips_europa_demod_sleep(struct dvb_frontend *fe)
447{
448 struct saa7134_dev *dev = fe->dvb->priv;
449
450 if (dev->original_demod_sleep)
451 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300452 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300453 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800454}
455
456static struct tda1004x_config philips_europa_config = {
457
458 .demod_address = 0x8,
459 .invert = 0,
460 .invert_oclk = 0,
461 .xtal_freq = TDA10046_XTAL_4M,
462 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
463 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300464 .tuner_address = 0x61,
465 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800466};
467
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700468static struct tda1004x_config medion_cardbus = {
469 .demod_address = 0x08,
470 .invert = 1,
471 .invert_oclk = 0,
472 .xtal_freq = TDA10046_XTAL_16M,
473 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
474 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300475 .tuner_address = 0x61,
476 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700477};
478
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300479/* ------------------------------------------------------------------
480 * tda 1004x based cards with philips silicon tuner
481 */
482
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300483static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
484{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300485 struct tda1004x_state *state = fe->demodulator_priv;
486
487 u8 addr = state->config->i2c_gate;
488 static u8 tda8290_close[] = { 0x21, 0xc0};
489 static u8 tda8290_open[] = { 0x21, 0x80};
490 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
491 if (enable) {
492 tda8290_msg.buf = tda8290_close;
493 } else {
494 tda8290_msg.buf = tda8290_open;
495 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300496 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300497 struct saa7134_dev *dev = fe->dvb->priv;
498 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300499 return -EIO;
500 }
501 msleep(20);
502 return 0;
503}
504
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300505static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300506{
507 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300508 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300509
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300510 switch (state->config->antenna_switch) {
511 case 0: break;
512 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
513 saa7134_set_gpio(dev, 21, 0);
514 break;
515 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
516 saa7134_set_gpio(dev, 21, 1);
517 break;
518 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300519 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800520}
521
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300522static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
523{
524 struct saa7134_dev *dev = fe->dvb->priv;
525 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300526
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300527 switch (state->config->antenna_switch) {
528 case 0: break;
529 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
530 saa7134_set_gpio(dev, 21, 1);
531 break;
532 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
533 saa7134_set_gpio(dev, 21, 0);
534 break;
535 }
536 return 0;
537}
538
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300539static int configure_tda827x_fe(struct saa7134_dev *dev,
540 struct tda1004x_config *cdec_conf,
541 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300542{
Steven Toth363c35f2008-10-11 11:05:50 -0300543 struct videobuf_dvb_frontend *fe0;
544
Darron Broad92abe9e2008-10-11 11:18:53 -0300545 /* Get the first frontend */
546 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300547
548 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
549 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300550 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300551 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
552 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300553 cdec_conf->tuner_address,
554 &dev->i2c_adap, tuner_conf))
555 return 0;
556
557 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300558 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300559 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300560 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300561}
562
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800563/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300564
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300565static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300566 .init = philips_tda827x_tuner_init,
567 .sleep = philips_tda827x_tuner_sleep,
568 .config = 0,
569 .switch_addr = 0
570};
571
572static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300573 .init = philips_tda827x_tuner_init,
574 .sleep = philips_tda827x_tuner_sleep,
575 .config = 1,
576 .switch_addr = 0x4b
577};
578
579static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300580 .init = philips_tda827x_tuner_init,
581 .sleep = philips_tda827x_tuner_sleep,
582 .config = 2,
583 .switch_addr = 0x4b
584};
585
586static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300587 .init = philips_tda827x_tuner_init,
588 .sleep = philips_tda827x_tuner_sleep,
589 .config = 2,
590 .switch_addr = 0x42
591};
592
593/* ------------------------------------------------------------------ */
594
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300595static struct tda1004x_config tda827x_lifeview_config = {
596 .demod_address = 0x08,
597 .invert = 1,
598 .invert_oclk = 0,
599 .xtal_freq = TDA10046_XTAL_16M,
600 .agc_config = TDA10046_AGC_TDA827X,
601 .gpio_config = TDA10046_GP11_I,
602 .if_freq = TDA10046_FREQ_045,
603 .tuner_address = 0x60,
604 .request_firmware = philips_tda1004x_request_firmware
605};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800606
607static struct tda1004x_config philips_tiger_config = {
608 .demod_address = 0x08,
609 .invert = 1,
610 .invert_oclk = 0,
611 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300612 .agc_config = TDA10046_AGC_TDA827X,
613 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300614 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300615 .i2c_gate = 0x4b,
616 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300617 .antenna_switch= 1,
618 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300619};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300620
621static struct tda1004x_config cinergy_ht_config = {
622 .demod_address = 0x08,
623 .invert = 1,
624 .invert_oclk = 0,
625 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300626 .agc_config = TDA10046_AGC_TDA827X,
627 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800628 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300629 .i2c_gate = 0x4b,
630 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300631 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800632};
633
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300634static struct tda1004x_config cinergy_ht_pci_config = {
635 .demod_address = 0x08,
636 .invert = 1,
637 .invert_oclk = 0,
638 .xtal_freq = TDA10046_XTAL_16M,
639 .agc_config = TDA10046_AGC_TDA827X,
640 .gpio_config = TDA10046_GP01_I,
641 .if_freq = TDA10046_FREQ_045,
642 .i2c_gate = 0x4b,
643 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300644 .request_firmware = philips_tda1004x_request_firmware
645};
646
647static struct tda1004x_config philips_tiger_s_config = {
648 .demod_address = 0x08,
649 .invert = 1,
650 .invert_oclk = 0,
651 .xtal_freq = TDA10046_XTAL_16M,
652 .agc_config = TDA10046_AGC_TDA827X,
653 .gpio_config = TDA10046_GP01_I,
654 .if_freq = TDA10046_FREQ_045,
655 .i2c_gate = 0x4b,
656 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300657 .antenna_switch= 1,
658 .request_firmware = philips_tda1004x_request_firmware
659};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200660
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300661static struct tda1004x_config pinnacle_pctv_310i_config = {
662 .demod_address = 0x08,
663 .invert = 1,
664 .invert_oclk = 0,
665 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300666 .agc_config = TDA10046_AGC_TDA827X,
667 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300668 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300669 .i2c_gate = 0x4b,
670 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300671 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300672};
673
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300674static struct tda1004x_config hauppauge_hvr_1110_config = {
675 .demod_address = 0x08,
676 .invert = 1,
677 .invert_oclk = 0,
678 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300679 .agc_config = TDA10046_AGC_TDA827X,
680 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300681 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300682 .i2c_gate = 0x4b,
683 .tuner_address = 0x61,
684 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300685};
686
Hartmut Hackmann83646812006-10-12 20:38:51 -0300687static struct tda1004x_config asus_p7131_dual_config = {
688 .demod_address = 0x08,
689 .invert = 1,
690 .invert_oclk = 0,
691 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300692 .agc_config = TDA10046_AGC_TDA827X,
693 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300694 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300695 .i2c_gate = 0x4b,
696 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300697 .antenna_switch= 2,
698 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300699};
700
Nico Sabbi420f32f2006-03-03 12:11:28 -0300701static struct tda1004x_config lifeview_trio_config = {
702 .demod_address = 0x09,
703 .invert = 1,
704 .invert_oclk = 0,
705 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300706 .agc_config = TDA10046_AGC_TDA827X,
707 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300708 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300709 .tuner_address = 0x60,
710 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300711};
712
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300713static struct tda1004x_config tevion_dvbt220rf_config = {
714 .demod_address = 0x08,
715 .invert = 1,
716 .invert_oclk = 0,
717 .xtal_freq = TDA10046_XTAL_16M,
718 .agc_config = TDA10046_AGC_TDA827X,
719 .gpio_config = TDA10046_GP11_I,
720 .if_freq = TDA10046_FREQ_045,
721 .tuner_address = 0x60,
722 .request_firmware = philips_tda1004x_request_firmware
723};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300724
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300725static struct tda1004x_config md8800_dvbt_config = {
726 .demod_address = 0x08,
727 .invert = 1,
728 .invert_oclk = 0,
729 .xtal_freq = TDA10046_XTAL_16M,
730 .agc_config = TDA10046_AGC_TDA827X,
731 .gpio_config = TDA10046_GP01_I,
732 .if_freq = TDA10046_FREQ_045,
733 .i2c_gate = 0x4b,
734 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300735 .request_firmware = philips_tda1004x_request_firmware
736};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200737
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300738static struct tda1004x_config asus_p7131_4871_config = {
739 .demod_address = 0x08,
740 .invert = 1,
741 .invert_oclk = 0,
742 .xtal_freq = TDA10046_XTAL_16M,
743 .agc_config = TDA10046_AGC_TDA827X,
744 .gpio_config = TDA10046_GP01_I,
745 .if_freq = TDA10046_FREQ_045,
746 .i2c_gate = 0x4b,
747 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300748 .antenna_switch= 2,
749 .request_firmware = philips_tda1004x_request_firmware
750};
751
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300752static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300753 .demod_address = 0x08,
754 .invert = 1,
755 .invert_oclk = 0,
756 .xtal_freq = TDA10046_XTAL_16M,
757 .agc_config = TDA10046_AGC_TDA827X,
758 .gpio_config = TDA10046_GP11_I,
759 .if_freq = TDA10046_FREQ_045,
760 .i2c_gate = 0x4b,
761 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300762 .antenna_switch= 2,
763 .request_firmware = philips_tda1004x_request_firmware
764};
Edgar Simo261f5082007-08-20 14:06:00 -0300765
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300766static struct tda1004x_config kworld_dvb_t_210_config = {
767 .demod_address = 0x08,
768 .invert = 1,
769 .invert_oclk = 0,
770 .xtal_freq = TDA10046_XTAL_16M,
771 .agc_config = TDA10046_AGC_TDA827X,
772 .gpio_config = TDA10046_GP11_I,
773 .if_freq = TDA10046_FREQ_045,
774 .i2c_gate = 0x4b,
775 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300776 .antenna_switch= 1,
777 .request_firmware = philips_tda1004x_request_firmware
778};
Edgar Simo261f5082007-08-20 14:06:00 -0300779
Edgar Simod90d9f52007-08-20 14:14:50 -0300780static struct tda1004x_config avermedia_super_007_config = {
781 .demod_address = 0x08,
782 .invert = 1,
783 .invert_oclk = 0,
784 .xtal_freq = TDA10046_XTAL_16M,
785 .agc_config = TDA10046_AGC_TDA827X,
786 .gpio_config = TDA10046_GP01_I,
787 .if_freq = TDA10046_FREQ_045,
788 .i2c_gate = 0x4b,
789 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300790 .antenna_switch= 1,
791 .request_firmware = philips_tda1004x_request_firmware
792};
793
Hermann Pitton4ba24372008-01-20 19:27:51 -0300794static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
795 .demod_address = 0x08,
796 .invert = 1,
797 .invert_oclk = 0,
798 .xtal_freq = TDA10046_XTAL_16M,
799 .agc_config = TDA10046_AGC_TDA827X,
800 .gpio_config = TDA10046_GP01_I,
801 .if_freq = TDA10046_FREQ_045,
802 .i2c_gate = 0x42,
803 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300804 .antenna_switch = 1,
805 .request_firmware = philips_tda1004x_request_firmware
806};
807
hermann pitton301e9d62008-09-14 17:49:14 -0300808static struct tda1004x_config asus_tiger_3in1_config = {
809 .demod_address = 0x0b,
810 .invert = 1,
811 .invert_oclk = 0,
812 .xtal_freq = TDA10046_XTAL_16M,
813 .agc_config = TDA10046_AGC_TDA827X,
814 .gpio_config = TDA10046_GP11_I,
815 .if_freq = TDA10046_FREQ_045,
816 .i2c_gate = 0x4b,
817 .tuner_address = 0x61,
818 .antenna_switch = 1,
819 .request_firmware = philips_tda1004x_request_firmware
820};
821
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300822/* ------------------------------------------------------------------
823 * special case: this card uses saa713x GPIO22 for the mode switch
824 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200825
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300826static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200827{
828 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300829 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200830 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300831 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200832 return 0;
833}
834
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300835static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200836{
837 struct saa7134_dev *dev = fe->dvb->priv;
838 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300839 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300840 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300841 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200842}
843
Michael Krufky8ce47da2007-04-27 12:31:14 -0300844static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300845 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300846 .sleep = ads_duo_tuner_sleep,
847 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300848};
849
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200850static struct tda1004x_config ads_tech_duo_config = {
851 .demod_address = 0x08,
852 .invert = 1,
853 .invert_oclk = 0,
854 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300855 .agc_config = TDA10046_AGC_TDA827X,
856 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200857 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300858 .tuner_address = 0x61,
859 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200860};
861
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300862static struct zl10353_config behold_h6_config = {
863 .demod_address = 0x1e>>1,
864 .no_tuner = 1,
865 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300866 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300867};
868
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300869/* ==================================================================
870 * tda10086 based DVB-S cards, helper functions
871 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300872
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300873static struct tda10086_config flydvbs = {
874 .demod_address = 0x0e,
875 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300876 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300877 .xtal_freq = TDA10086_XTAL_16M,
878};
879
880static struct tda10086_config sd1878_4m = {
881 .demod_address = 0x0e,
882 .invert = 0,
883 .diseqc_tone = 0,
884 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300885};
886
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300887/* ------------------------------------------------------------------
888 * special case: lnb supply is connected to the gated i2c
889 */
890
891static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
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_voltage)
898 res = dev->original_set_voltage(fe, voltage);
899 fe->ops.i2c_gate_ctrl(fe, 0);
900 }
901 return res;
902};
903
904static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
905{
906 int res = -EIO;
907 struct saa7134_dev *dev = fe->dvb->priv;
908 if (fe->ops.i2c_gate_ctrl) {
909 fe->ops.i2c_gate_ctrl(fe, 1);
910 if (dev->original_set_high_voltage)
911 res = dev->original_set_high_voltage(fe, arg);
912 fe->ops.i2c_gate_ctrl(fe, 0);
913 }
914 return res;
915};
916
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300917static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
918{
919 struct saa7134_dev *dev = fe->dvb->priv;
920 u8 wbuf[2] = { 0x1f, 00 };
921 u8 rbuf;
922 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
923 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
924
925 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
926 return -EIO;
927 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
928 if (voltage == SEC_VOLTAGE_18)
929 wbuf[1] = rbuf | 0x10;
930 else
931 wbuf[1] = rbuf & 0xef;
932 msg[0].len = 2;
933 i2c_transfer(&dev->i2c_adap, msg, 1);
934 return 0;
935}
936
937static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
938{
939 struct saa7134_dev *dev = fe->dvb->priv;
940 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
941 return -EIO;
942}
943
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300944/* ==================================================================
945 * nxt200x based ATSC cards, helper functions
946 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800947
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800948static struct nxt200x_config avertvhda180 = {
949 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800950};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300951
952static struct nxt200x_config kworldatsc110 = {
953 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300954};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800955
Matthias Schwarzott04574182009-02-24 12:35:16 -0300956/* ------------------------------------------------------------------ */
957
958static struct mt312_config avertv_a700_mt312 = {
959 .demod_address = 0x0e,
960 .voltage_inverted = 1,
961};
962
963static struct zl10036_config avertv_a700_tuner = {
964 .tuner_address = 0x60,
965};
966
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300967/* ==================================================================
968 * Core code
969 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700970
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971static int dvb_init(struct saa7134_dev *dev)
972{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -0300973 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300974 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300975 struct videobuf_dvb_frontend *fe0;
976
Darron Broadf972e0b2008-10-11 11:24:30 -0300977 /* FIXME: add support for multi-frontend */
978 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -0300979 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -0300980
981 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -0300982 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
983 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -0300984 printk(KERN_ERR "%s() failed to alloc\n", __func__);
985 return -ENOMEM;
986 }
987
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 /* init struct videobuf_dvb */
989 dev->ts.nr_bufs = 32;
990 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -0300991 fe0->dvb.name = dev->name;
992 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -0300993 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 V4L2_BUF_TYPE_VIDEO_CAPTURE,
995 V4L2_FIELD_ALTERNATE,
996 sizeof(struct saa7134_buf),
997 dev);
998
999 switch (dev->board) {
1000 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001001 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001002 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001003 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001004 if (fe0->dvb.frontend) {
1005 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001006 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001008 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001009 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001010 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001011 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001012 &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 Krufkyfb147e92008-04-22 14:46:16 -03001015 &dev->i2c_adap, 0x61,
1016 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001017 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001018 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001019 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001020 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001021 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001022 &avermedia_xc3028_mt352_dev,
1023 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001024 attach_xc3028 = 1;
1025 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001027 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001028 &medion_cardbus,
1029 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001030 if (fe0->dvb.frontend) {
1031 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001032 &dev->i2c_adap, medion_cardbus.tuner_address,
1033 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001034 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001036 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001037 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001038 &philips_tu1216_60_config,
1039 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001040 if (fe0->dvb.frontend) {
1041 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1042 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001043 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001044 break;
1045 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001046 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001047 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1048 &tda827x_cfg_0) < 0)
1049 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001050 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001051 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001052 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Steven Toth363c35f2008-10-11 11:05:50 -03001053 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001054 &philips_europa_config,
1055 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001056 if (fe0->dvb.frontend) {
1057 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1058 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1059 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1060 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1061 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001062 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001063 break;
1064 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001065 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001066 &philips_tu1216_61_config,
1067 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001068 if (fe0->dvb.frontend) {
1069 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1070 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001071 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001072 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001073 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001074 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1075 &tda827x_cfg_2) < 0)
1076 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001077 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001078 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001079 if (configure_tda827x_fe(dev, &philips_tiger_config,
1080 &tda827x_cfg_0) < 0)
1081 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001082 break;
1083 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001084 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1085 &tda827x_cfg_1) < 0)
1086 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001087 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001088 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001089 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1090 &tda827x_cfg_1) < 0)
1091 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001092 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001093 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001094 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1095 &tda827x_cfg_0) < 0)
1096 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001097 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001098 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001099 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1100 &tda827x_cfg_0) < 0)
1101 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001102 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001103 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001104 if (!use_frontend) { /* terrestrial */
1105 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1106 &tda827x_cfg_0) < 0)
1107 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001108 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001109 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1110 if (fe0->dvb.frontend) {
1111 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001112 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001113 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001114 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001115 }
Steven Toth363c35f2008-10-11 11:05:50 -03001116 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001117 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001118 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001119 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001120 }
1121 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001122 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001123 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001124 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001125 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001126 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001127 &ads_tech_duo_config,
1128 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001129 if (fe0->dvb.frontend) {
1130 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001131 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1132 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001133 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001134 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001135 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001136 }
Mauro Carvalho Chehabbc36ec7462008-06-14 10:44:04 -03001137 } else
1138 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001139 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001140 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001141 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1142 &tda827x_cfg_0) < 0)
1143 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001144 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001145 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001146 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001147 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1148 &tda827x_cfg_0) < 0)
1149 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001150 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001151 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001152 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001153 if (fe0->dvb.frontend) {
1154 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001155 u8 dev_id = dev->eedata[2];
1156 u8 data = 0xc4;
1157 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1158
Steven Toth363c35f2008-10-11 11:05:50 -03001159 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001160 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001161 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001162 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001163 goto dettach_frontend;
1164 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001165 if (dev_id != 0x08) {
1166 /* we need to open the i2c gate (we know it exists) */
1167 fe->ops.i2c_gate_ctrl(fe, 1);
1168 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001169 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001170 wprintk("%s: Medion Quadro, no ISL6405 "
1171 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001172 goto dettach_frontend;
1173 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001174 if (dev_id == 0x07) {
1175 /* fire up the 2nd section of the LNB supply since
1176 we can't do this from the other section */
1177 msg.buf = &data;
1178 i2c_transfer(&dev->i2c_adap, &msg, 1);
1179 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001180 fe->ops.i2c_gate_ctrl(fe, 0);
1181 dev->original_set_voltage = fe->ops.set_voltage;
1182 fe->ops.set_voltage = md8800_set_voltage;
1183 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1184 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1185 } else {
1186 fe->ops.set_voltage = md8800_set_voltage2;
1187 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1188 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001189 }
1190 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001191 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001192 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001193 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001194 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001195 if (fe0->dvb.frontend)
1196 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001197 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001198 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001199 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001200 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001201 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001202 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001203 if (fe0->dvb.frontend)
1204 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001205 &dev->i2c_adap, 0x61,
1206 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001207 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001208 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001209 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001210 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001211 if (fe0->dvb.frontend) {
1212 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001213 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001214 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001215 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001216 }
Steven Toth363c35f2008-10-11 11:05:50 -03001217 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001218 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001219 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001220 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001221 }
1222 }
1223 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001224 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001225 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001226 &medion_cardbus,
1227 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001228 if (fe0->dvb.frontend) {
1229 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1230 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001231
Steven Toth363c35f2008-10-11 11:05:50 -03001232 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001233 &dev->i2c_adap, medion_cardbus.tuner_address,
1234 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001235 }
1236 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001237 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001238 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001239 &philips_europa_config,
1240 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001241 if (fe0->dvb.frontend) {
1242 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1243 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001244 }
1245 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001246 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001247 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1248 &tda827x_cfg_0) < 0)
1249 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001250 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001251 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001252 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1253 &tda827x_cfg_0) < 0)
1254 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001255 break;
1256 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001257 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1258 &tda827x_cfg_2) < 0)
1259 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001260 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001261 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001262 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1263 &tda827x_cfg_2) < 0)
1264 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001265 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001266 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001267 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1268 &tda827x_cfg_2) < 0)
1269 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001270 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001271 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001272 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1273 &tda827x_cfg_0) < 0)
1274 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001275 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001276 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001277 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1278 &tda827x_cfg_2_sw42) < 0)
1279 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001280 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001281 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001282 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001283 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001284 if (fe0->dvb.frontend) {
1285 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001286 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001287 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001288 goto dettach_frontend;
1289 }
Steven Toth363c35f2008-10-11 11:05:50 -03001290 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001291 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001292 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001293 goto dettach_frontend;
1294 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001295 }
1296 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001297 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001298 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1299 &tda827x_cfg_0) < 0)
1300 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001301 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001302 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001303 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1304 &tda827x_cfg_2) < 0)
1305 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001306 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001307 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001308 dprintk("AverMedia E506R dvb setup\n");
1309 saa7134_set_gpio(dev, 25, 0);
1310 msleep(10);
1311 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001312 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001313 &avermedia_xc3028_mt352_dev,
1314 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001315 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001316 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001317 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001318 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001319 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001320 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001321 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001322 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001323 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001324 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001325 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001326 goto dettach_frontend;
1327 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001328 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001329 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001330 fe->ops.i2c_gate_ctrl(fe, 1);
1331 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001332 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001333 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001334 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001335 goto dettach_frontend;
1336 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001337 fe->ops.i2c_gate_ctrl(fe, 0);
1338 dev->original_set_voltage = fe->ops.set_voltage;
1339 fe->ops.set_voltage = md8800_set_voltage;
1340 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1341 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1342 }
1343 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001344 case SAA7134_BOARD_AVERMEDIA_M103:
1345 saa7134_set_gpio(dev, 25, 0);
1346 msleep(10);
1347 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001348 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001349 &avermedia_xc3028_mt352_dev,
1350 &dev->i2c_adap);
1351 attach_xc3028 = 1;
1352 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001353 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1354 if (!use_frontend) { /* terrestrial */
1355 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1356 &tda827x_cfg_2) < 0)
1357 goto dettach_frontend;
1358 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001359 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001360 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001361 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001362 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001363 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001364 &dev->i2c_adap, 0) == NULL) {
1365 wprintk("%s: Asus Tiger 3in1, no "
1366 "tda826x found!\n", __func__);
1367 goto dettach_frontend;
1368 }
Steven Toth363c35f2008-10-11 11:05:50 -03001369 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001370 &dev->i2c_adap, 0, 0) == NULL) {
1371 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1372 " found!\n", __func__);
1373 goto dettach_frontend;
1374 }
1375 }
1376 }
1377 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001378 case SAA7134_BOARD_ASUSTeK_TIGER:
1379 if (configure_tda827x_fe(dev, &philips_tiger_config,
1380 &tda827x_cfg_0) < 0)
1381 goto dettach_frontend;
1382 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001383 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001384 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001385 &behold_h6_config,
1386 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001387 if (fe0->dvb.frontend) {
1388 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001389 &dev->i2c_adap, 0x61,
1390 TUNER_PHILIPS_FMD1216ME_MK3);
1391 }
1392 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001393 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1394 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1395 /* Zarlink ZL10313 */
1396 fe0->dvb.frontend = dvb_attach(mt312_attach,
1397 &avertv_a700_mt312, &dev->i2c_adap);
1398 if (fe0->dvb.frontend) {
1399 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1400 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1401 wprintk("%s: No zl10036 found!\n",
1402 __func__);
1403 }
1404 }
1405 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001407 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408 break;
1409 }
1410
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001411 if (attach_xc3028) {
1412 struct dvb_frontend *fe;
1413 struct xc2028_config cfg = {
1414 .i2c_adap = &dev->i2c_adap,
1415 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001416 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001417
Steven Toth363c35f2008-10-11 11:05:50 -03001418 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001419 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001420
Steven Toth363c35f2008-10-11 11:05:50 -03001421 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001422 if (!fe) {
1423 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1424 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001425 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001426 }
1427 }
1428
Steven Toth363c35f2008-10-11 11:05:50 -03001429 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001430 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001431 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001433 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001434 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435
1436 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001437 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Darron Broad59b18422008-10-11 11:44:05 -03001438 &dev->pci->dev, adapter_nr, 0);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001439
1440 /* this sequence is necessary to make the tda1004x load its firmware
1441 * and to enter analog mode of hybrid boards
1442 */
1443 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001444 if (fe0->dvb.frontend->ops.init)
1445 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1446 if (fe0->dvb.frontend->ops.sleep)
1447 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1448 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1449 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001450 }
1451 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001452
1453dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001454 videobuf_dvb_dealloc_frontends(&dev->frontends);
1455 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456}
1457
1458static int dvb_fini(struct saa7134_dev *dev)
1459{
Steven Toth363c35f2008-10-11 11:05:50 -03001460 struct videobuf_dvb_frontend *fe0;
1461
1462 /* Get the first frontend */
1463 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1464 if (!fe0)
1465 return -EINVAL;
1466
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001467 /* FIXME: I suspect that this code is bogus, since the entry for
1468 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1469 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1470 */
1471 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1472 struct v4l2_priv_tun_config tda9887_cfg;
1473 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001475 tda9887_cfg.tuner = TUNER_TDA9887;
1476 tda9887_cfg.priv = &on;
1477
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001479 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001480 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001481 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001482 /* turn off the 2nd lnb supply */
1483 u8 data = 0x80;
1484 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1485 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001486 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001487 if (fe->ops.i2c_gate_ctrl) {
1488 fe->ops.i2c_gate_ctrl(fe, 1);
1489 i2c_transfer(&dev->i2c_adap, &msg, 1);
1490 fe->ops.i2c_gate_ctrl(fe, 0);
1491 }
1492 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001493 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001494 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 return 0;
1496}
1497
1498static struct saa7134_mpeg_ops dvb_ops = {
1499 .type = SAA7134_MPEG_DVB,
1500 .init = dvb_init,
1501 .fini = dvb_fini,
1502};
1503
1504static int __init dvb_register(void)
1505{
1506 return saa7134_ts_register(&dvb_ops);
1507}
1508
1509static void __exit dvb_unregister(void)
1510{
1511 saa7134_ts_unregister(&dvb_ops);
1512}
1513
1514module_init(dvb_register);
1515module_exit(dvb_unregister);
1516
1517/* ------------------------------------------------------------------ */
1518/*
1519 * Local variables:
1520 * c-basic-offset: 8
1521 * End:
1522 */