blob: 3315a48a848b682f437c1e500286b655fe7ef15b [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/delay.h>
28#include <linux/kthread.h>
29#include <linux/suspend.h>
30
31#include "saa7134-reg.h"
32#include "saa7134.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020033#include <media/v4l2-common.h>
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -020034#include "dvb-pll.h"
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -030035#include <dvb_frontend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030037#include "mt352.h"
38#include "mt352_priv.h" /* FIXME */
39#include "tda1004x.h"
40#include "nxt200x.h"
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -030041#include "tuner-xc2028.h"
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -030042#include "xc5000.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 Krufky1bc7f512009-01-19 01:10:49 -030051#include "tda10048.h"
Michael Krufky3abdedd2009-01-19 01:10:49 -030052#include "tda18271.h"
53#include "lgdt3305.h"
54#include "tda8290.h"
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -030055#include "mb86a20s.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030056
Dmitri Belimov47aeba52008-12-23 03:53:03 -030057#include "zl10353.h"
58
Matthias Schwarzott04574182009-02-24 12:35:16 -030059#include "zl10036.h"
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -030060#include "zl10039.h"
Matthias Schwarzott04574182009-02-24 12:35:16 -030061#include "mt312.h"
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
64MODULE_LICENSE("GPL");
65
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030066static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070067
Linus Torvalds1da177e2005-04-16 15:20:36 -070068module_param(antenna_pwr, int, 0444);
69MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
70
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030071static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030072module_param(use_frontend, int, 0644);
73MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030074
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030075static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030076module_param(debug, int, 0644);
77MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
78
Janne Grunau78e92002008-04-09 19:13:13 -030079DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
80
Trent Piephocf3c34c2007-03-07 18:19:48 -030081#define dprintk(fmt, arg...) do { if (debug) \
82 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
83
84/* Print a warning */
85#define wprintk(fmt, arg...) \
86 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030087
88/* ------------------------------------------------------------------
89 * mt352 based DVB-T cards
90 */
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
93{
94 u32 ok;
95
96 if (!on) {
97 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
98 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
99 return 0;
100 }
101
102 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
103 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
104 udelay(10);
105
106 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
107 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
108 udelay(10);
109 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
110 udelay(10);
111 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300112 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
114 if (!ok)
115 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
116 return ok;
117}
118
119static int mt352_pinnacle_init(struct dvb_frontend* fe)
120{
121 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
122 static u8 reset [] = { RESET, 0x80 };
123 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
124 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
125 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
126 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
127 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
128 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
129 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
130 struct saa7134_dev *dev= fe->dvb->priv;
131
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300132 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
134 mt352_write(fe, clock_config, sizeof(clock_config));
135 udelay(200);
136 mt352_write(fe, reset, sizeof(reset));
137 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
138 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
139 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
140 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
141
142 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
143 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
144 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 return 0;
147}
148
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200149static int mt352_aver777_init(struct dvb_frontend* fe)
150{
151 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
152 static u8 reset [] = { RESET, 0x80 };
153 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
154 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
155 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
156
157 mt352_write(fe, clock_config, sizeof(clock_config));
158 udelay(200);
159 mt352_write(fe, reset, sizeof(reset));
160 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
161 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
162 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
163
164 return 0;
165}
166
Tim Farrington6e501a32008-06-15 13:33:42 -0300167static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300168{
Tim Farrington6e501a32008-06-15 13:33:42 -0300169 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
170 static u8 reset [] = { RESET, 0x80 };
171 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
172 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300173 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
174
175 mt352_write(fe, clock_config, sizeof(clock_config));
176 udelay(200);
177 mt352_write(fe, reset, sizeof(reset));
178 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
179 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
180 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300181 return 0;
182}
183
Andrew de Quincey0463f122006-05-16 17:22:02 -0300184static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
185 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300187 u8 off[] = { 0x00, 0xf1};
188 u8 on[] = { 0x00, 0x71};
189 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 struct saa7134_dev *dev = fe->dvb->priv;
192 struct v4l2_frequency f;
193
194 /* set frequency (mt2050) */
195 f.tuner = 0;
196 f.type = V4L2_TUNER_DIGITAL_TV;
197 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300198 if (fe->ops.i2c_gate_ctrl)
199 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300200 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300201 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300202 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300203 if (fe->ops.i2c_gate_ctrl)
204 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300205 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207 pinnacle_antenna_pwr(dev, antenna_pwr);
208
209 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300210 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211}
212
213static struct mt352_config pinnacle_300i = {
214 .demod_address = 0x3c >> 1,
215 .adc_clock = 20333,
216 .if2 = 36150,
217 .no_tuner = 1,
218 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200220
221static struct mt352_config avermedia_777 = {
222 .demod_address = 0xf,
223 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200224};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
Tim Farrington6e501a32008-06-15 13:33:42 -0300226static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300227 .demod_address = (0x1e >> 1),
228 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300229 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300230};
231
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300232static struct tda18271_std_map mb86a20s_tda18271_std_map = {
233 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
234 .if_lvl = 7, .rfagc_top = 0x37, },
235};
236
237static struct tda18271_config kworld_tda18271_config = {
238 .std_map = &mb86a20s_tda18271_std_map,
239 .gate = TDA18271_GATE_DIGITAL,
240};
241
242static const struct mb86a20s_config kworld_mb86a20s_config = {
243 .demod_address = 0x10,
244};
245
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300246/* ==================================================================
247 * tda1004x based DVB-T cards, helper functions
248 */
249
250static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
251 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700252{
253 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300254 return request_firmware(fw, name, &dev->pci->dev);
255}
256
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300257/* ------------------------------------------------------------------
258 * these tuners are tu1216, td1316(a)
259 */
260
261static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
262{
263 struct saa7134_dev *dev = fe->dvb->priv;
264 struct tda1004x_state *state = fe->demodulator_priv;
265 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700266 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800267 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700268 sizeof(tuner_buf) };
269 int tuner_frequency = 0;
270 u8 band, cp, filter;
271
272 /* determine charge pump */
273 tuner_frequency = params->frequency + 36166000;
274 if (tuner_frequency < 87000000)
275 return -EINVAL;
276 else if (tuner_frequency < 130000000)
277 cp = 3;
278 else if (tuner_frequency < 160000000)
279 cp = 5;
280 else if (tuner_frequency < 200000000)
281 cp = 6;
282 else if (tuner_frequency < 290000000)
283 cp = 3;
284 else if (tuner_frequency < 420000000)
285 cp = 5;
286 else if (tuner_frequency < 480000000)
287 cp = 6;
288 else if (tuner_frequency < 620000000)
289 cp = 3;
290 else if (tuner_frequency < 830000000)
291 cp = 5;
292 else if (tuner_frequency < 895000000)
293 cp = 7;
294 else
295 return -EINVAL;
296
297 /* determine band */
298 if (params->frequency < 49000000)
299 return -EINVAL;
300 else if (params->frequency < 161000000)
301 band = 1;
302 else if (params->frequency < 444000000)
303 band = 2;
304 else if (params->frequency < 861000000)
305 band = 4;
306 else
307 return -EINVAL;
308
309 /* setup PLL filter */
310 switch (params->u.ofdm.bandwidth) {
311 case BANDWIDTH_6_MHZ:
312 filter = 0;
313 break;
314
315 case BANDWIDTH_7_MHZ:
316 filter = 0;
317 break;
318
319 case BANDWIDTH_8_MHZ:
320 filter = 1;
321 break;
322
323 default:
324 return -EINVAL;
325 }
326
327 /* calculate divisor
328 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
329 */
330 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
331
332 /* setup tuner buffer */
333 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
334 tuner_buf[1] = tuner_frequency & 0xff;
335 tuner_buf[2] = 0xca;
336 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
337
Patrick Boettcherdea74862006-05-14 05:01:31 -0300338 if (fe->ops.i2c_gate_ctrl)
339 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300340 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300341 wprintk("could not write to tuner at addr: 0x%02x\n",
342 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700343 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300344 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700345 msleep(1);
346 return 0;
347}
348
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300349static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800350{
351 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300352 struct tda1004x_state *state = fe->demodulator_priv;
353 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800354 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
355 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
356
357 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300358 if (fe->ops.i2c_gate_ctrl)
359 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800360 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
361 return -EIO;
362 msleep(1);
363
364 return 0;
365}
366
367/* ------------------------------------------------------------------ */
368
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800369static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700370 .demod_address = 0x8,
371 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800372 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700373 .xtal_freq = TDA10046_XTAL_4M,
374 .agc_config = TDA10046_AGC_DEFAULT,
375 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300376 .tuner_address = 0x60,
377 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378};
379
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800380static struct tda1004x_config philips_tu1216_61_config = {
381
382 .demod_address = 0x8,
383 .invert = 1,
384 .invert_oclk = 0,
385 .xtal_freq = TDA10046_XTAL_4M,
386 .agc_config = TDA10046_AGC_DEFAULT,
387 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300388 .tuner_address = 0x61,
389 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800390};
391
392/* ------------------------------------------------------------------ */
393
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300394static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800395{
396 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300397 struct tda1004x_state *state = fe->demodulator_priv;
398 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800399 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300400 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800401
402 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300403 if (fe->ops.i2c_gate_ctrl)
404 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800405 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
406 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800407 return 0;
408}
409
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300410static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800411{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300412 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800413}
414
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300415static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
416{
417 struct saa7134_dev *dev = fe->dvb->priv;
418 struct tda1004x_state *state = fe->demodulator_priv;
419 u8 addr = state->config->tuner_address;
420 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
421 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
422
423 /* switch the tuner to analog mode */
424 if (fe->ops.i2c_gate_ctrl)
425 fe->ops.i2c_gate_ctrl(fe, 1);
426 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
427 return -EIO;
428 return 0;
429}
430
431/* ------------------------------------------------------------------ */
432
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300433static int philips_europa_tuner_init(struct dvb_frontend *fe)
434{
435 struct saa7134_dev *dev = fe->dvb->priv;
436 static u8 msg[] = { 0x00, 0x40};
437 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
438
439
440 if (philips_td1316_tuner_init(fe))
441 return -EIO;
442 msleep(1);
443 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
444 return -EIO;
445
446 return 0;
447}
448
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300449static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800450{
451 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800452
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300453 static u8 msg[] = { 0x00, 0x14 };
454 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
455
456 if (philips_td1316_tuner_sleep(fe))
457 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800458
459 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300460 if (fe->ops.i2c_gate_ctrl)
461 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800462 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300463 return 0;
464}
465
466static int philips_europa_demod_sleep(struct dvb_frontend *fe)
467{
468 struct saa7134_dev *dev = fe->dvb->priv;
469
470 if (dev->original_demod_sleep)
471 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300472 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300473 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800474}
475
476static struct tda1004x_config philips_europa_config = {
477
478 .demod_address = 0x8,
479 .invert = 0,
480 .invert_oclk = 0,
481 .xtal_freq = TDA10046_XTAL_4M,
482 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
483 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300484 .tuner_address = 0x61,
485 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800486};
487
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700488static struct tda1004x_config medion_cardbus = {
489 .demod_address = 0x08,
490 .invert = 1,
491 .invert_oclk = 0,
492 .xtal_freq = TDA10046_XTAL_16M,
493 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
494 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300495 .tuner_address = 0x61,
496 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700497};
498
Vadim Catana128fe952010-05-29 12:49:16 -0300499static struct tda1004x_config technotrend_budget_t3000_config = {
500 .demod_address = 0x8,
501 .invert = 1,
502 .invert_oclk = 0,
503 .xtal_freq = TDA10046_XTAL_4M,
504 .agc_config = TDA10046_AGC_DEFAULT,
505 .if_freq = TDA10046_FREQ_3617,
506 .tuner_address = 0x63,
507 .request_firmware = philips_tda1004x_request_firmware
508};
509
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300510/* ------------------------------------------------------------------
511 * tda 1004x based cards with philips silicon tuner
512 */
513
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300514static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
515{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300516 struct tda1004x_state *state = fe->demodulator_priv;
517
518 u8 addr = state->config->i2c_gate;
519 static u8 tda8290_close[] = { 0x21, 0xc0};
520 static u8 tda8290_open[] = { 0x21, 0x80};
521 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
522 if (enable) {
523 tda8290_msg.buf = tda8290_close;
524 } else {
525 tda8290_msg.buf = tda8290_open;
526 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300527 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300528 struct saa7134_dev *dev = fe->dvb->priv;
529 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300530 return -EIO;
531 }
532 msleep(20);
533 return 0;
534}
535
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300536static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300537{
538 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300539 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300540
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300541 switch (state->config->antenna_switch) {
542 case 0: break;
543 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
544 saa7134_set_gpio(dev, 21, 0);
545 break;
546 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
547 saa7134_set_gpio(dev, 21, 1);
548 break;
549 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300550 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800551}
552
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300553static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
554{
555 struct saa7134_dev *dev = fe->dvb->priv;
556 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300557
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300558 switch (state->config->antenna_switch) {
559 case 0: break;
560 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
561 saa7134_set_gpio(dev, 21, 1);
562 break;
563 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
564 saa7134_set_gpio(dev, 21, 0);
565 break;
566 }
567 return 0;
568}
569
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300570static int configure_tda827x_fe(struct saa7134_dev *dev,
571 struct tda1004x_config *cdec_conf,
572 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300573{
Steven Toth363c35f2008-10-11 11:05:50 -0300574 struct videobuf_dvb_frontend *fe0;
575
Darron Broad92abe9e2008-10-11 11:18:53 -0300576 /* Get the first frontend */
577 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300578
579 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
580 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300581 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300582 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
583 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300584 cdec_conf->tuner_address,
585 &dev->i2c_adap, tuner_conf))
586 return 0;
587
588 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300589 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300590 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300591 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300592}
593
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800594/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300595
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300596static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300597 .init = philips_tda827x_tuner_init,
598 .sleep = philips_tda827x_tuner_sleep,
599 .config = 0,
600 .switch_addr = 0
601};
602
603static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300604 .init = philips_tda827x_tuner_init,
605 .sleep = philips_tda827x_tuner_sleep,
606 .config = 1,
607 .switch_addr = 0x4b
608};
609
610static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300611 .init = philips_tda827x_tuner_init,
612 .sleep = philips_tda827x_tuner_sleep,
613 .config = 2,
614 .switch_addr = 0x4b
615};
616
617static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300618 .init = philips_tda827x_tuner_init,
619 .sleep = philips_tda827x_tuner_sleep,
620 .config = 2,
621 .switch_addr = 0x42
622};
623
624/* ------------------------------------------------------------------ */
625
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300626static int __kworld_sbtvd_i2c_gate_ctrl(struct saa7134_dev *dev, int enable)
627{
628 unsigned char initmsg[] = {0x45, 0x97};
629 unsigned char msg_enable[] = {0x45, 0xc1};
630 unsigned char msg_disable[] = {0x45, 0x81};
631 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
632
633 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
634 wprintk("could not access the I2C gate\n");
635 return -EIO;
636 }
637 if (enable)
638 msg.buf = msg_enable;
639 else
640 msg.buf = msg_disable;
641 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
642 wprintk("could not access the I2C gate\n");
643 return -EIO;
644 }
645 msleep(20);
646 return 0;
647}
648static int kworld_sbtvd_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
649{
650 struct saa7134_dev *dev = fe->dvb->priv;
651
652 return __kworld_sbtvd_i2c_gate_ctrl(dev, enable);
653}
654
655/* ------------------------------------------------------------------ */
656
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300657static struct tda1004x_config tda827x_lifeview_config = {
658 .demod_address = 0x08,
659 .invert = 1,
660 .invert_oclk = 0,
661 .xtal_freq = TDA10046_XTAL_16M,
662 .agc_config = TDA10046_AGC_TDA827X,
663 .gpio_config = TDA10046_GP11_I,
664 .if_freq = TDA10046_FREQ_045,
665 .tuner_address = 0x60,
666 .request_firmware = philips_tda1004x_request_firmware
667};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800668
669static struct tda1004x_config philips_tiger_config = {
670 .demod_address = 0x08,
671 .invert = 1,
672 .invert_oclk = 0,
673 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300674 .agc_config = TDA10046_AGC_TDA827X,
675 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300676 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300677 .i2c_gate = 0x4b,
678 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300679 .antenna_switch= 1,
680 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300681};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300682
683static struct tda1004x_config cinergy_ht_config = {
684 .demod_address = 0x08,
685 .invert = 1,
686 .invert_oclk = 0,
687 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300688 .agc_config = TDA10046_AGC_TDA827X,
689 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800690 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300691 .i2c_gate = 0x4b,
692 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300693 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800694};
695
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300696static struct tda1004x_config cinergy_ht_pci_config = {
697 .demod_address = 0x08,
698 .invert = 1,
699 .invert_oclk = 0,
700 .xtal_freq = TDA10046_XTAL_16M,
701 .agc_config = TDA10046_AGC_TDA827X,
702 .gpio_config = TDA10046_GP01_I,
703 .if_freq = TDA10046_FREQ_045,
704 .i2c_gate = 0x4b,
705 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300706 .request_firmware = philips_tda1004x_request_firmware
707};
708
709static struct tda1004x_config philips_tiger_s_config = {
710 .demod_address = 0x08,
711 .invert = 1,
712 .invert_oclk = 0,
713 .xtal_freq = TDA10046_XTAL_16M,
714 .agc_config = TDA10046_AGC_TDA827X,
715 .gpio_config = TDA10046_GP01_I,
716 .if_freq = TDA10046_FREQ_045,
717 .i2c_gate = 0x4b,
718 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300719 .antenna_switch= 1,
720 .request_firmware = philips_tda1004x_request_firmware
721};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200722
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300723static struct tda1004x_config pinnacle_pctv_310i_config = {
724 .demod_address = 0x08,
725 .invert = 1,
726 .invert_oclk = 0,
727 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300728 .agc_config = TDA10046_AGC_TDA827X,
729 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300730 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300731 .i2c_gate = 0x4b,
732 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300733 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300734};
735
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300736static struct tda1004x_config hauppauge_hvr_1110_config = {
737 .demod_address = 0x08,
738 .invert = 1,
739 .invert_oclk = 0,
740 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300741 .agc_config = TDA10046_AGC_TDA827X,
742 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300743 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300744 .i2c_gate = 0x4b,
745 .tuner_address = 0x61,
746 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300747};
748
Hartmut Hackmann83646812006-10-12 20:38:51 -0300749static struct tda1004x_config asus_p7131_dual_config = {
750 .demod_address = 0x08,
751 .invert = 1,
752 .invert_oclk = 0,
753 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300754 .agc_config = TDA10046_AGC_TDA827X,
755 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300756 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300757 .i2c_gate = 0x4b,
758 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300759 .antenna_switch= 2,
760 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300761};
762
Nico Sabbi420f32f2006-03-03 12:11:28 -0300763static struct tda1004x_config lifeview_trio_config = {
764 .demod_address = 0x09,
765 .invert = 1,
766 .invert_oclk = 0,
767 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300768 .agc_config = TDA10046_AGC_TDA827X,
769 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300770 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300771 .tuner_address = 0x60,
772 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300773};
774
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300775static struct tda1004x_config tevion_dvbt220rf_config = {
776 .demod_address = 0x08,
777 .invert = 1,
778 .invert_oclk = 0,
779 .xtal_freq = TDA10046_XTAL_16M,
780 .agc_config = TDA10046_AGC_TDA827X,
781 .gpio_config = TDA10046_GP11_I,
782 .if_freq = TDA10046_FREQ_045,
783 .tuner_address = 0x60,
784 .request_firmware = philips_tda1004x_request_firmware
785};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300786
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300787static struct tda1004x_config md8800_dvbt_config = {
788 .demod_address = 0x08,
789 .invert = 1,
790 .invert_oclk = 0,
791 .xtal_freq = TDA10046_XTAL_16M,
792 .agc_config = TDA10046_AGC_TDA827X,
793 .gpio_config = TDA10046_GP01_I,
794 .if_freq = TDA10046_FREQ_045,
795 .i2c_gate = 0x4b,
796 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300797 .request_firmware = philips_tda1004x_request_firmware
798};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200799
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300800static struct tda1004x_config asus_p7131_4871_config = {
801 .demod_address = 0x08,
802 .invert = 1,
803 .invert_oclk = 0,
804 .xtal_freq = TDA10046_XTAL_16M,
805 .agc_config = TDA10046_AGC_TDA827X,
806 .gpio_config = TDA10046_GP01_I,
807 .if_freq = TDA10046_FREQ_045,
808 .i2c_gate = 0x4b,
809 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300810 .antenna_switch= 2,
811 .request_firmware = philips_tda1004x_request_firmware
812};
813
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300814static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300815 .demod_address = 0x08,
816 .invert = 1,
817 .invert_oclk = 0,
818 .xtal_freq = TDA10046_XTAL_16M,
819 .agc_config = TDA10046_AGC_TDA827X,
820 .gpio_config = TDA10046_GP11_I,
821 .if_freq = TDA10046_FREQ_045,
822 .i2c_gate = 0x4b,
823 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300824 .antenna_switch= 2,
825 .request_firmware = philips_tda1004x_request_firmware
826};
Edgar Simo261f5082007-08-20 14:06:00 -0300827
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300828static struct tda1004x_config kworld_dvb_t_210_config = {
829 .demod_address = 0x08,
830 .invert = 1,
831 .invert_oclk = 0,
832 .xtal_freq = TDA10046_XTAL_16M,
833 .agc_config = TDA10046_AGC_TDA827X,
834 .gpio_config = TDA10046_GP11_I,
835 .if_freq = TDA10046_FREQ_045,
836 .i2c_gate = 0x4b,
837 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300838 .antenna_switch= 1,
839 .request_firmware = philips_tda1004x_request_firmware
840};
Edgar Simo261f5082007-08-20 14:06:00 -0300841
Edgar Simod90d9f52007-08-20 14:14:50 -0300842static struct tda1004x_config avermedia_super_007_config = {
843 .demod_address = 0x08,
844 .invert = 1,
845 .invert_oclk = 0,
846 .xtal_freq = TDA10046_XTAL_16M,
847 .agc_config = TDA10046_AGC_TDA827X,
848 .gpio_config = TDA10046_GP01_I,
849 .if_freq = TDA10046_FREQ_045,
850 .i2c_gate = 0x4b,
851 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300852 .antenna_switch= 1,
853 .request_firmware = philips_tda1004x_request_firmware
854};
855
Hermann Pitton4ba24372008-01-20 19:27:51 -0300856static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
857 .demod_address = 0x08,
858 .invert = 1,
859 .invert_oclk = 0,
860 .xtal_freq = TDA10046_XTAL_16M,
861 .agc_config = TDA10046_AGC_TDA827X,
862 .gpio_config = TDA10046_GP01_I,
863 .if_freq = TDA10046_FREQ_045,
864 .i2c_gate = 0x42,
865 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300866 .antenna_switch = 1,
867 .request_firmware = philips_tda1004x_request_firmware
868};
869
hermann pitton301e9d62008-09-14 17:49:14 -0300870static struct tda1004x_config asus_tiger_3in1_config = {
871 .demod_address = 0x0b,
872 .invert = 1,
873 .invert_oclk = 0,
874 .xtal_freq = TDA10046_XTAL_16M,
875 .agc_config = TDA10046_AGC_TDA827X,
876 .gpio_config = TDA10046_GP11_I,
877 .if_freq = TDA10046_FREQ_045,
878 .i2c_gate = 0x4b,
879 .tuner_address = 0x61,
880 .antenna_switch = 1,
881 .request_firmware = philips_tda1004x_request_firmware
882};
883
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300884/* ------------------------------------------------------------------
885 * special case: this card uses saa713x GPIO22 for the mode switch
886 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200887
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300888static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200889{
890 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300891 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200892 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300893 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200894 return 0;
895}
896
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300897static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200898{
899 struct saa7134_dev *dev = fe->dvb->priv;
900 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300901 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300902 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300903 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200904}
905
Michael Krufky8ce47da2007-04-27 12:31:14 -0300906static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300907 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300908 .sleep = ads_duo_tuner_sleep,
909 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300910};
911
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200912static struct tda1004x_config ads_tech_duo_config = {
913 .demod_address = 0x08,
914 .invert = 1,
915 .invert_oclk = 0,
916 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300917 .agc_config = TDA10046_AGC_TDA827X,
918 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200919 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300920 .tuner_address = 0x61,
921 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200922};
923
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300924static struct zl10353_config behold_h6_config = {
925 .demod_address = 0x1e>>1,
926 .no_tuner = 1,
927 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300928 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300929};
930
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300931static struct xc5000_config behold_x7_tunerconfig = {
932 .i2c_address = 0xc2>>1,
933 .if_khz = 4560,
Devin Heitmueller2a0d0562009-09-30 23:04:39 -0300934 .radio_input = XC5000_RADIO_FM1,
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300935};
936
937static struct zl10353_config behold_x7_config = {
938 .demod_address = 0x1e>>1,
939 .if2 = 45600,
940 .no_tuner = 1,
941 .parallel_ts = 1,
942 .disable_i2c_gate_ctrl = 1,
943};
944
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300945/* ==================================================================
946 * tda10086 based DVB-S cards, helper functions
947 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300948
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300949static struct tda10086_config flydvbs = {
950 .demod_address = 0x0e,
951 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300952 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300953 .xtal_freq = TDA10086_XTAL_16M,
954};
955
956static struct tda10086_config sd1878_4m = {
957 .demod_address = 0x0e,
958 .invert = 0,
959 .diseqc_tone = 0,
960 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300961};
962
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300963/* ------------------------------------------------------------------
964 * special case: lnb supply is connected to the gated i2c
965 */
966
967static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
968{
969 int res = -EIO;
970 struct saa7134_dev *dev = fe->dvb->priv;
971 if (fe->ops.i2c_gate_ctrl) {
972 fe->ops.i2c_gate_ctrl(fe, 1);
973 if (dev->original_set_voltage)
974 res = dev->original_set_voltage(fe, voltage);
975 fe->ops.i2c_gate_ctrl(fe, 0);
976 }
977 return res;
978};
979
980static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
981{
982 int res = -EIO;
983 struct saa7134_dev *dev = fe->dvb->priv;
984 if (fe->ops.i2c_gate_ctrl) {
985 fe->ops.i2c_gate_ctrl(fe, 1);
986 if (dev->original_set_high_voltage)
987 res = dev->original_set_high_voltage(fe, arg);
988 fe->ops.i2c_gate_ctrl(fe, 0);
989 }
990 return res;
991};
992
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300993static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
994{
995 struct saa7134_dev *dev = fe->dvb->priv;
996 u8 wbuf[2] = { 0x1f, 00 };
997 u8 rbuf;
998 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
999 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
1000
1001 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
1002 return -EIO;
1003 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1004 if (voltage == SEC_VOLTAGE_18)
1005 wbuf[1] = rbuf | 0x10;
1006 else
1007 wbuf[1] = rbuf & 0xef;
1008 msg[0].len = 2;
1009 i2c_transfer(&dev->i2c_adap, msg, 1);
1010 return 0;
1011}
1012
1013static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1014{
1015 struct saa7134_dev *dev = fe->dvb->priv;
1016 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
1017 return -EIO;
1018}
1019
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001020/* ==================================================================
1021 * nxt200x based ATSC cards, helper functions
1022 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001023
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001024static struct nxt200x_config avertvhda180 = {
1025 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001026};
Andrew Burri3e1410a2006-02-27 00:08:23 -03001027
1028static struct nxt200x_config kworldatsc110 = {
1029 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -03001030};
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001031
Matthias Schwarzott04574182009-02-24 12:35:16 -03001032/* ------------------------------------------------------------------ */
1033
1034static struct mt312_config avertv_a700_mt312 = {
1035 .demod_address = 0x0e,
1036 .voltage_inverted = 1,
1037};
1038
1039static struct zl10036_config avertv_a700_tuner = {
1040 .tuner_address = 0x60,
1041};
1042
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001043static struct mt312_config zl10313_compro_s350_config = {
1044 .demod_address = 0x0e,
1045};
1046
Michael Krufky3abdedd2009-01-19 01:10:49 -03001047static struct lgdt3305_config hcw_lgdt3305_config = {
1048 .i2c_addr = 0x0e,
1049 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1050 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1051 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1052 .deny_i2c_rptr = 1,
1053 .spectral_inversion = 1,
1054 .qam_if_khz = 4000,
1055 .vsb_if_khz = 3250,
1056};
1057
Michael Krufky1bc7f512009-01-19 01:10:49 -03001058static struct tda10048_config hcw_tda10048_config = {
1059 .demod_address = 0x10 >> 1,
1060 .output_mode = TDA10048_SERIAL_OUTPUT,
1061 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1062 .inversion = TDA10048_INVERSION_ON,
1063 .dtv6_if_freq_khz = TDA10048_IF_3300,
1064 .dtv7_if_freq_khz = TDA10048_IF_3500,
1065 .dtv8_if_freq_khz = TDA10048_IF_4000,
1066 .clk_freq_khz = TDA10048_CLK_16000,
1067 .disable_gate_access = 1,
1068};
1069
Michael Krufky3abdedd2009-01-19 01:10:49 -03001070static struct tda18271_std_map hauppauge_tda18271_std_map = {
1071 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1072 .if_lvl = 1, .rfagc_top = 0x58, },
1073 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1074 .if_lvl = 1, .rfagc_top = 0x58, },
1075};
1076
1077static struct tda18271_config hcw_tda18271_config = {
1078 .std_map = &hauppauge_tda18271_std_map,
1079 .gate = TDA18271_GATE_ANALOG,
1080 .config = 3,
Michael Krufky542cb052009-08-29 17:45:48 -03001081 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky3abdedd2009-01-19 01:10:49 -03001082};
1083
1084static struct tda829x_config tda829x_no_probe = {
1085 .probe_tuner = TDA829X_DONT_PROBE,
1086};
1087
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001088static struct tda10048_config zolid_tda10048_config = {
1089 .demod_address = 0x10 >> 1,
1090 .output_mode = TDA10048_PARALLEL_OUTPUT,
1091 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1092 .inversion = TDA10048_INVERSION_ON,
1093 .dtv6_if_freq_khz = TDA10048_IF_3300,
1094 .dtv7_if_freq_khz = TDA10048_IF_3500,
1095 .dtv8_if_freq_khz = TDA10048_IF_4000,
1096 .clk_freq_khz = TDA10048_CLK_16000,
1097 .disable_gate_access = 1,
1098};
1099
1100static struct tda18271_config zolid_tda18271_config = {
1101 .gate = TDA18271_GATE_ANALOG,
1102};
1103
Michael Krufky184e7692009-06-05 04:28:28 -03001104static struct tda10048_config dtv1000s_tda10048_config = {
1105 .demod_address = 0x10 >> 1,
1106 .output_mode = TDA10048_PARALLEL_OUTPUT,
1107 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1108 .inversion = TDA10048_INVERSION_ON,
1109 .dtv6_if_freq_khz = TDA10048_IF_3300,
1110 .dtv7_if_freq_khz = TDA10048_IF_3800,
1111 .dtv8_if_freq_khz = TDA10048_IF_4300,
1112 .clk_freq_khz = TDA10048_CLK_16000,
1113 .disable_gate_access = 1,
1114};
1115
1116static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1117 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1118 .if_lvl = 1, .rfagc_top = 0x37, },
1119 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1120 .if_lvl = 1, .rfagc_top = 0x37, },
1121 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1122 .if_lvl = 1, .rfagc_top = 0x37, },
1123};
1124
1125static struct tda18271_config dtv1000s_tda18271_config = {
1126 .std_map = &dtv1000s_tda18271_std_map,
1127 .gate = TDA18271_GATE_ANALOG,
1128};
1129
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001130/* ==================================================================
1131 * Core code
1132 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001133
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134static int dvb_init(struct saa7134_dev *dev)
1135{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001136 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001137 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001138 struct videobuf_dvb_frontend *fe0;
1139
Darron Broadf972e0bd2008-10-11 11:24:30 -03001140 /* FIXME: add support for multi-frontend */
1141 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001142 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0bd2008-10-11 11:24:30 -03001143
1144 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001145 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1146 if (!fe0) {
Darron Broadf972e0bd2008-10-11 11:24:30 -03001147 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1148 return -ENOMEM;
1149 }
1150
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 /* init struct videobuf_dvb */
1152 dev->ts.nr_bufs = 32;
1153 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001154 fe0->dvb.name = dev->name;
1155 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001156 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1158 V4L2_FIELD_ALTERNATE,
1159 sizeof(struct saa7134_buf),
Hans Verkuil08bff032010-09-20 17:39:46 -03001160 dev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161
1162 switch (dev->board) {
1163 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001164 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001165 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001166 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001167 if (fe0->dvb.frontend) {
1168 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001169 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001171 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001172 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001173 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001174 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001175 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001176 if (fe0->dvb.frontend) {
1177 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001178 &dev->i2c_adap, 0x61,
1179 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001180 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001181 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001182 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001183 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001184 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001185 &avermedia_xc3028_mt352_dev,
1186 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001187 attach_xc3028 = 1;
1188 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001190 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001191 &medion_cardbus,
1192 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001193 if (fe0->dvb.frontend) {
1194 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001195 &dev->i2c_adap, medion_cardbus.tuner_address,
1196 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001197 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001199 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001200 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001201 &philips_tu1216_60_config,
1202 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001203 if (fe0->dvb.frontend) {
1204 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1205 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001206 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001207 break;
1208 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001209 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001210 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1211 &tda827x_cfg_0) < 0)
1212 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001213 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001214 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001215 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Danny Woode3c6e1a2009-09-20 12:14:21 -03001216 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001217 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001218 &philips_europa_config,
1219 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001220 if (fe0->dvb.frontend) {
1221 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1222 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1223 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1224 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1225 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001226 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001227 break;
Vadim Catana128fe952010-05-29 12:49:16 -03001228 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1229 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1230 &technotrend_budget_t3000_config,
1231 &dev->i2c_adap);
1232 if (fe0->dvb.frontend) {
1233 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1234 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1235 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1236 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1237 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1238 }
1239 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001240 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001241 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001242 &philips_tu1216_61_config,
1243 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001244 if (fe0->dvb.frontend) {
1245 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1246 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001247 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001248 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001249 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001250 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1251 &tda827x_cfg_2) < 0)
1252 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001253 break;
Michael Krufky0e316ec2009-08-03 16:51:33 -03001254 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
Michael Krufky1bc7f512009-01-19 01:10:49 -03001255 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1256 &hcw_tda10048_config,
1257 &dev->i2c_adap);
1258 if (fe0->dvb.frontend != NULL) {
1259 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1260 &dev->i2c_adap, 0x4b,
1261 &tda829x_no_probe);
1262 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1263 0x60, &dev->i2c_adap,
1264 &hcw_tda18271_config);
1265 }
1266 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001267 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001268 if (configure_tda827x_fe(dev, &philips_tiger_config,
1269 &tda827x_cfg_0) < 0)
1270 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001271 break;
1272 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001273 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1274 &tda827x_cfg_1) < 0)
1275 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001276 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001277 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001278 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1279 &tda827x_cfg_1) < 0)
1280 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001281 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001282 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001283 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1284 &hcw_lgdt3305_config,
1285 &dev->i2c_adap);
1286 if (fe0->dvb.frontend) {
1287 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1288 &dev->i2c_adap, 0x4b,
1289 &tda829x_no_probe);
1290 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1291 0x60, &dev->i2c_adap,
1292 &hcw_tda18271_config);
1293 }
1294 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001295 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001296 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1297 &tda827x_cfg_0) < 0)
1298 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001299 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001300 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001301 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1302 &tda827x_cfg_0) < 0)
1303 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001304 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001305 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001306 if (!use_frontend) { /* terrestrial */
1307 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1308 &tda827x_cfg_0) < 0)
1309 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001310 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001311 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1312 if (fe0->dvb.frontend) {
1313 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001314 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001315 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001316 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001317 }
Steven Toth363c35f2008-10-11 11:05:50 -03001318 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001319 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001320 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001321 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001322 }
1323 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001324 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001325 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001326 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001327 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001328 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001329 &ads_tech_duo_config,
1330 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001331 if (fe0->dvb.frontend) {
1332 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001333 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1334 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001335 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001336 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001337 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001338 }
Mauro Carvalho Chehabbc36ec72008-06-14 10:44:04 -03001339 } else
1340 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001341 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001342 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001343 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1344 &tda827x_cfg_0) < 0)
1345 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001346 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001347 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001348 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001349 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1350 &tda827x_cfg_0) < 0)
1351 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001352 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001353 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001354 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001355 if (fe0->dvb.frontend) {
1356 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001357 u8 dev_id = dev->eedata[2];
1358 u8 data = 0xc4;
1359 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1360
Steven Toth363c35f2008-10-11 11:05:50 -03001361 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001362 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001363 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001364 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001365 goto dettach_frontend;
1366 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001367 if (dev_id != 0x08) {
1368 /* we need to open the i2c gate (we know it exists) */
1369 fe->ops.i2c_gate_ctrl(fe, 1);
1370 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001371 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001372 wprintk("%s: Medion Quadro, no ISL6405 "
1373 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001374 goto dettach_frontend;
1375 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001376 if (dev_id == 0x07) {
1377 /* fire up the 2nd section of the LNB supply since
1378 we can't do this from the other section */
1379 msg.buf = &data;
1380 i2c_transfer(&dev->i2c_adap, &msg, 1);
1381 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001382 fe->ops.i2c_gate_ctrl(fe, 0);
1383 dev->original_set_voltage = fe->ops.set_voltage;
1384 fe->ops.set_voltage = md8800_set_voltage;
1385 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1386 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1387 } else {
1388 fe->ops.set_voltage = md8800_set_voltage2;
1389 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1390 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001391 }
1392 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001393 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001394 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001395 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001396 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001397 if (fe0->dvb.frontend)
1398 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001399 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001400 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001401 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001402 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001403 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001404 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001405 if (fe0->dvb.frontend)
1406 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff817a2008-04-22 14:46:17 -03001407 &dev->i2c_adap, 0x61,
1408 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001409 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001410 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001411 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001412 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001413 if (fe0->dvb.frontend) {
1414 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001415 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001416 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001417 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001418 }
Steven Toth363c35f2008-10-11 11:05:50 -03001419 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001420 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001421 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001422 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001423 }
1424 }
1425 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001426 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001427 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001428 &medion_cardbus,
1429 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001430 if (fe0->dvb.frontend) {
1431 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1432 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001433
Steven Toth363c35f2008-10-11 11:05:50 -03001434 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001435 &dev->i2c_adap, medion_cardbus.tuner_address,
1436 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001437 }
1438 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001439 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001440 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001441 &philips_europa_config,
1442 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001443 if (fe0->dvb.frontend) {
1444 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1445 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001446 }
1447 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001448 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001449 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1450 &tda827x_cfg_0) < 0)
1451 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001452 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001453 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001454 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1455 &tda827x_cfg_0) < 0)
1456 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001457 break;
1458 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001459 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1460 &tda827x_cfg_2) < 0)
1461 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001462 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001463 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001464 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1465 &tda827x_cfg_2) < 0)
1466 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001467 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001468 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001469 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1470 &tda827x_cfg_2) < 0)
1471 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001472 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001473 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001474 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1475 &tda827x_cfg_0) < 0)
1476 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001477 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001478 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001479 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1480 &tda827x_cfg_2_sw42) < 0)
1481 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001482 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001483 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001484 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001485 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001486 if (fe0->dvb.frontend) {
1487 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001488 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001489 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001490 goto dettach_frontend;
1491 }
Steven Toth363c35f2008-10-11 11:05:50 -03001492 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001493 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001494 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001495 goto dettach_frontend;
1496 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001497 }
1498 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001499 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001500 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1501 &tda827x_cfg_0) < 0)
1502 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001503 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001504 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001505 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1506 &tda827x_cfg_2) < 0)
1507 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001508 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001509 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001510 dprintk("AverMedia E506R dvb setup\n");
1511 saa7134_set_gpio(dev, 25, 0);
1512 msleep(10);
1513 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001514 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001515 &avermedia_xc3028_mt352_dev,
1516 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001517 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001518 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001519 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001520 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001521 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001522 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001523 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001524 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001525 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001526 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001527 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001528 goto dettach_frontend;
1529 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001530 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001531 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001532 fe->ops.i2c_gate_ctrl(fe, 1);
1533 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001534 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001535 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001536 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001537 goto dettach_frontend;
1538 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001539 fe->ops.i2c_gate_ctrl(fe, 0);
1540 dev->original_set_voltage = fe->ops.set_voltage;
1541 fe->ops.set_voltage = md8800_set_voltage;
1542 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1543 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1544 }
1545 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001546 case SAA7134_BOARD_AVERMEDIA_M103:
1547 saa7134_set_gpio(dev, 25, 0);
1548 msleep(10);
1549 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001550 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001551 &avermedia_xc3028_mt352_dev,
1552 &dev->i2c_adap);
1553 attach_xc3028 = 1;
1554 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001555 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1556 if (!use_frontend) { /* terrestrial */
1557 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1558 &tda827x_cfg_2) < 0)
1559 goto dettach_frontend;
1560 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001561 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001562 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001563 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001564 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001565 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001566 &dev->i2c_adap, 0) == NULL) {
1567 wprintk("%s: Asus Tiger 3in1, no "
1568 "tda826x found!\n", __func__);
1569 goto dettach_frontend;
1570 }
Steven Toth363c35f2008-10-11 11:05:50 -03001571 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001572 &dev->i2c_adap, 0, 0) == NULL) {
1573 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1574 " found!\n", __func__);
1575 goto dettach_frontend;
1576 }
1577 }
1578 }
1579 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001580 case SAA7134_BOARD_ASUSTeK_TIGER:
1581 if (configure_tda827x_fe(dev, &philips_tiger_config,
1582 &tda827x_cfg_0) < 0)
1583 goto dettach_frontend;
1584 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001585 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001586 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001587 &behold_h6_config,
1588 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001589 if (fe0->dvb.frontend) {
1590 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001591 &dev->i2c_adap, 0x61,
Beholder Intl. Ltd. Dmitry Belimov4786dd62009-08-04 20:07:42 -03001592 TUNER_PHILIPS_FMD1216MEX_MK3);
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001593 }
1594 break;
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -03001595 case SAA7134_BOARD_BEHOLD_X7:
1596 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1597 &behold_x7_config,
1598 &dev->i2c_adap);
1599 if (fe0->dvb.frontend) {
1600 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1601 &dev->i2c_adap, &behold_x7_tunerconfig);
1602 }
1603 break;
Dmitri Belimov0faa2ed2010-04-06 01:00:05 -03001604 case SAA7134_BOARD_BEHOLD_H7:
1605 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1606 &behold_x7_config,
1607 &dev->i2c_adap);
1608 if (fe0->dvb.frontend) {
1609 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1610 &dev->i2c_adap, &behold_x7_tunerconfig);
1611 }
1612 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001613 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1614 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1615 /* Zarlink ZL10313 */
1616 fe0->dvb.frontend = dvb_attach(mt312_attach,
1617 &avertv_a700_mt312, &dev->i2c_adap);
1618 if (fe0->dvb.frontend) {
1619 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1620 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1621 wprintk("%s: No zl10036 found!\n",
1622 __func__);
1623 }
1624 }
1625 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001626 case SAA7134_BOARD_VIDEOMATE_S350:
1627 fe0->dvb.frontend = dvb_attach(mt312_attach,
1628 &zl10313_compro_s350_config, &dev->i2c_adap);
1629 if (fe0->dvb.frontend)
1630 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1631 0x60, &dev->i2c_adap) == NULL)
1632 wprintk("%s: No zl10039 found!\n",
1633 __func__);
1634
1635 break;
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001636 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1637 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1638 &zolid_tda10048_config,
1639 &dev->i2c_adap);
1640 if (fe0->dvb.frontend != NULL) {
1641 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1642 &dev->i2c_adap, 0x4b,
1643 &tda829x_no_probe);
1644 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1645 0x60, &dev->i2c_adap,
1646 &zolid_tda18271_config);
1647 }
1648 break;
Michael Krufky184e7692009-06-05 04:28:28 -03001649 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1650 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1651 &dtv1000s_tda10048_config,
1652 &dev->i2c_adap);
1653 if (fe0->dvb.frontend != NULL) {
1654 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1655 &dev->i2c_adap, 0x4b,
1656 &tda829x_no_probe);
1657 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1658 0x60, &dev->i2c_adap,
1659 &dtv1000s_tda18271_config);
1660 }
1661 break;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001662 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
1663 __kworld_sbtvd_i2c_gate_ctrl(dev, 0);
1664 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x14000);
1665 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x14000);
1666 msleep(20);
1667 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x54000);
1668 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x54000);
1669 msleep(20);
1670 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1671 &kworld_mb86a20s_config,
1672 &dev->i2c_adap);
1673 __kworld_sbtvd_i2c_gate_ctrl(dev, 1);
1674 if (fe0->dvb.frontend != NULL) {
1675 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1676 0x60, &dev->i2c_adap,
1677 &kworld_tda18271_config);
1678 /*
1679 * Only after success, it can initialize the gate, otherwise
1680 * an OOPS will hit, due to kfree(fe0->dvb.frontend)
1681 */
1682 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_i2c_gate_ctrl;
1683 }
1684 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001686 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687 break;
1688 }
1689
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001690 if (attach_xc3028) {
1691 struct dvb_frontend *fe;
1692 struct xc2028_config cfg = {
1693 .i2c_adap = &dev->i2c_adap,
1694 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001695 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001696
Steven Toth363c35f2008-10-11 11:05:50 -03001697 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001698 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001699
Steven Toth363c35f2008-10-11 11:05:50 -03001700 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001701 if (!fe) {
1702 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1703 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001704 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001705 }
1706 }
1707
Steven Toth363c35f2008-10-11 11:05:50 -03001708 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001709 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001710 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001712 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001713 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714
1715 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001716 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001717 &dev->pci->dev, adapter_nr, 0, NULL);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001718
1719 /* this sequence is necessary to make the tda1004x load its firmware
1720 * and to enter analog mode of hybrid boards
1721 */
1722 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001723 if (fe0->dvb.frontend->ops.init)
1724 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1725 if (fe0->dvb.frontend->ops.sleep)
1726 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1727 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1728 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001729 }
1730 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001731
1732dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001733 videobuf_dvb_dealloc_frontends(&dev->frontends);
1734 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735}
1736
1737static int dvb_fini(struct saa7134_dev *dev)
1738{
Steven Toth363c35f2008-10-11 11:05:50 -03001739 struct videobuf_dvb_frontend *fe0;
1740
1741 /* Get the first frontend */
1742 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1743 if (!fe0)
1744 return -EINVAL;
1745
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001746 /* FIXME: I suspect that this code is bogus, since the entry for
1747 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1748 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1749 */
1750 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1751 struct v4l2_priv_tun_config tda9887_cfg;
1752 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001754 tda9887_cfg.tuner = TUNER_TDA9887;
1755 tda9887_cfg.priv = &on;
1756
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001758 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001759 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001760 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001761 /* turn off the 2nd lnb supply */
1762 u8 data = 0x80;
1763 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1764 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001765 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001766 if (fe->ops.i2c_gate_ctrl) {
1767 fe->ops.i2c_gate_ctrl(fe, 1);
1768 i2c_transfer(&dev->i2c_adap, &msg, 1);
1769 fe->ops.i2c_gate_ctrl(fe, 0);
1770 }
1771 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001772 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001773 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774 return 0;
1775}
1776
1777static struct saa7134_mpeg_ops dvb_ops = {
1778 .type = SAA7134_MPEG_DVB,
1779 .init = dvb_init,
1780 .fini = dvb_fini,
1781};
1782
1783static int __init dvb_register(void)
1784{
1785 return saa7134_ts_register(&dvb_ops);
1786}
1787
1788static void __exit dvb_unregister(void)
1789{
1790 saa7134_ts_unregister(&dvb_ops);
1791}
1792
1793module_init(dvb_register);
1794module_exit(dvb_unregister);
1795
1796/* ------------------------------------------------------------------ */
1797/*
1798 * Local variables:
1799 * c-basic-offset: 8
1800 * End:
1801 */