blob: 996a206c6d79749276e8a90cf54cd2ee190903c6 [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"
Timothy Leece027042011-03-25 15:00:33 -030056#include "lgs8gxx.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030057
Dmitri Belimov47aeba52008-12-23 03:53:03 -030058#include "zl10353.h"
59
Matthias Schwarzott04574182009-02-24 12:35:16 -030060#include "zl10036.h"
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -030061#include "zl10039.h"
Matthias Schwarzott04574182009-02-24 12:35:16 -030062#include "mt312.h"
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
65MODULE_LICENSE("GPL");
66
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030067static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069module_param(antenna_pwr, int, 0444);
70MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
71
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030072static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030073module_param(use_frontend, int, 0644);
74MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030075
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030076static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030077module_param(debug, int, 0644);
78MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
79
Janne Grunau78e92002008-04-09 19:13:13 -030080DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
81
Trent Piephocf3c34c2007-03-07 18:19:48 -030082#define dprintk(fmt, arg...) do { if (debug) \
83 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
84
85/* Print a warning */
86#define wprintk(fmt, arg...) \
87 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030088
89/* ------------------------------------------------------------------
90 * mt352 based DVB-T cards
91 */
92
Linus Torvalds1da177e2005-04-16 15:20:36 -070093static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
94{
95 u32 ok;
96
97 if (!on) {
98 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
99 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
100 return 0;
101 }
102
103 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
104 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
105 udelay(10);
106
107 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
108 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
109 udelay(10);
110 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
111 udelay(10);
112 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300113 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
115 if (!ok)
116 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
117 return ok;
118}
119
120static int mt352_pinnacle_init(struct dvb_frontend* fe)
121{
122 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
123 static u8 reset [] = { RESET, 0x80 };
124 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
125 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
126 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
127 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
128 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
129 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
130 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
131 struct saa7134_dev *dev= fe->dvb->priv;
132
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300133 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134
135 mt352_write(fe, clock_config, sizeof(clock_config));
136 udelay(200);
137 mt352_write(fe, reset, sizeof(reset));
138 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
139 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
140 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
141 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
142
143 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
144 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
145 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 return 0;
148}
149
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200150static int mt352_aver777_init(struct dvb_frontend* fe)
151{
152 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
153 static u8 reset [] = { RESET, 0x80 };
154 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
155 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
156 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
157
158 mt352_write(fe, clock_config, sizeof(clock_config));
159 udelay(200);
160 mt352_write(fe, reset, sizeof(reset));
161 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
162 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
163 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
164
165 return 0;
166}
167
Tim Farrington6e501a32008-06-15 13:33:42 -0300168static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300169{
Tim Farrington6e501a32008-06-15 13:33:42 -0300170 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
171 static u8 reset [] = { RESET, 0x80 };
172 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
173 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300174 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
175
176 mt352_write(fe, clock_config, sizeof(clock_config));
177 udelay(200);
178 mt352_write(fe, reset, sizeof(reset));
179 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
180 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
181 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300182 return 0;
183}
184
Andrew de Quincey0463f122006-05-16 17:22:02 -0300185static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
186 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300188 u8 off[] = { 0x00, 0xf1};
189 u8 on[] = { 0x00, 0x71};
190 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
191
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 struct saa7134_dev *dev = fe->dvb->priv;
193 struct v4l2_frequency f;
194
195 /* set frequency (mt2050) */
196 f.tuner = 0;
197 f.type = V4L2_TUNER_DIGITAL_TV;
198 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300199 if (fe->ops.i2c_gate_ctrl)
200 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300201 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300202 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300203 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300204 if (fe->ops.i2c_gate_ctrl)
205 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300206 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207
208 pinnacle_antenna_pwr(dev, antenna_pwr);
209
210 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300211 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212}
213
214static struct mt352_config pinnacle_300i = {
215 .demod_address = 0x3c >> 1,
216 .adc_clock = 20333,
217 .if2 = 36150,
218 .no_tuner = 1,
219 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200221
222static struct mt352_config avermedia_777 = {
223 .demod_address = 0xf,
224 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200225};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
Tim Farrington6e501a32008-06-15 13:33:42 -0300227static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300228 .demod_address = (0x1e >> 1),
229 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300230 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300231};
232
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300233static struct tda18271_std_map mb86a20s_tda18271_std_map = {
234 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
235 .if_lvl = 7, .rfagc_top = 0x37, },
236};
237
238static struct tda18271_config kworld_tda18271_config = {
239 .std_map = &mb86a20s_tda18271_std_map,
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -0300240 .gate = TDA18271_GATE_DIGITAL,
Mauro Carvalho Chehabecb71d22011-01-14 12:03:03 -0300241 .config = 3, /* Use tuner callback for AGC */
242
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300243};
244
245static const struct mb86a20s_config kworld_mb86a20s_config = {
246 .demod_address = 0x10,
247};
248
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -0300249static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
250{
251 struct saa7134_dev *dev = fe->dvb->priv;
252
253 unsigned char initmsg[] = {0x45, 0x97};
254 unsigned char msg_enable[] = {0x45, 0xc1};
255 unsigned char msg_disable[] = {0x45, 0x81};
256 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
257
258 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
259 wprintk("could not access the I2C gate\n");
260 return -EIO;
261 }
262 if (enable)
263 msg.buf = msg_enable;
264 else
265 msg.buf = msg_disable;
266 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
267 wprintk("could not access the I2C gate\n");
268 return -EIO;
269 }
270 msleep(20);
271 return 0;
272}
273
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300274/* ==================================================================
275 * tda1004x based DVB-T cards, helper functions
276 */
277
278static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
279 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700280{
281 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300282 return request_firmware(fw, name, &dev->pci->dev);
283}
284
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300285/* ------------------------------------------------------------------
286 * these tuners are tu1216, td1316(a)
287 */
288
289static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
290{
291 struct saa7134_dev *dev = fe->dvb->priv;
292 struct tda1004x_state *state = fe->demodulator_priv;
293 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700294 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800295 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700296 sizeof(tuner_buf) };
297 int tuner_frequency = 0;
298 u8 band, cp, filter;
299
300 /* determine charge pump */
301 tuner_frequency = params->frequency + 36166000;
302 if (tuner_frequency < 87000000)
303 return -EINVAL;
304 else if (tuner_frequency < 130000000)
305 cp = 3;
306 else if (tuner_frequency < 160000000)
307 cp = 5;
308 else if (tuner_frequency < 200000000)
309 cp = 6;
310 else if (tuner_frequency < 290000000)
311 cp = 3;
312 else if (tuner_frequency < 420000000)
313 cp = 5;
314 else if (tuner_frequency < 480000000)
315 cp = 6;
316 else if (tuner_frequency < 620000000)
317 cp = 3;
318 else if (tuner_frequency < 830000000)
319 cp = 5;
320 else if (tuner_frequency < 895000000)
321 cp = 7;
322 else
323 return -EINVAL;
324
325 /* determine band */
326 if (params->frequency < 49000000)
327 return -EINVAL;
328 else if (params->frequency < 161000000)
329 band = 1;
330 else if (params->frequency < 444000000)
331 band = 2;
332 else if (params->frequency < 861000000)
333 band = 4;
334 else
335 return -EINVAL;
336
337 /* setup PLL filter */
338 switch (params->u.ofdm.bandwidth) {
339 case BANDWIDTH_6_MHZ:
340 filter = 0;
341 break;
342
343 case BANDWIDTH_7_MHZ:
344 filter = 0;
345 break;
346
347 case BANDWIDTH_8_MHZ:
348 filter = 1;
349 break;
350
351 default:
352 return -EINVAL;
353 }
354
355 /* calculate divisor
356 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
357 */
358 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
359
360 /* setup tuner buffer */
361 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
362 tuner_buf[1] = tuner_frequency & 0xff;
363 tuner_buf[2] = 0xca;
364 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
365
Patrick Boettcherdea74862006-05-14 05:01:31 -0300366 if (fe->ops.i2c_gate_ctrl)
367 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300368 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300369 wprintk("could not write to tuner at addr: 0x%02x\n",
370 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700371 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300372 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700373 msleep(1);
374 return 0;
375}
376
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300377static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800378{
379 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300380 struct tda1004x_state *state = fe->demodulator_priv;
381 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800382 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
383 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
384
385 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300386 if (fe->ops.i2c_gate_ctrl)
387 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800388 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
389 return -EIO;
390 msleep(1);
391
392 return 0;
393}
394
395/* ------------------------------------------------------------------ */
396
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800397static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700398 .demod_address = 0x8,
399 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800400 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700401 .xtal_freq = TDA10046_XTAL_4M,
402 .agc_config = TDA10046_AGC_DEFAULT,
403 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300404 .tuner_address = 0x60,
405 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406};
407
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800408static struct tda1004x_config philips_tu1216_61_config = {
409
410 .demod_address = 0x8,
411 .invert = 1,
412 .invert_oclk = 0,
413 .xtal_freq = TDA10046_XTAL_4M,
414 .agc_config = TDA10046_AGC_DEFAULT,
415 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300416 .tuner_address = 0x61,
417 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800418};
419
420/* ------------------------------------------------------------------ */
421
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300422static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800423{
424 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300425 struct tda1004x_state *state = fe->demodulator_priv;
426 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800427 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300428 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800429
430 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300431 if (fe->ops.i2c_gate_ctrl)
432 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800433 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
434 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800435 return 0;
436}
437
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300438static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800439{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300440 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800441}
442
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300443static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
444{
445 struct saa7134_dev *dev = fe->dvb->priv;
446 struct tda1004x_state *state = fe->demodulator_priv;
447 u8 addr = state->config->tuner_address;
448 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
449 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
450
451 /* switch the tuner to analog mode */
452 if (fe->ops.i2c_gate_ctrl)
453 fe->ops.i2c_gate_ctrl(fe, 1);
454 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
455 return -EIO;
456 return 0;
457}
458
459/* ------------------------------------------------------------------ */
460
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300461static int philips_europa_tuner_init(struct dvb_frontend *fe)
462{
463 struct saa7134_dev *dev = fe->dvb->priv;
464 static u8 msg[] = { 0x00, 0x40};
465 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
466
467
468 if (philips_td1316_tuner_init(fe))
469 return -EIO;
470 msleep(1);
471 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
472 return -EIO;
473
474 return 0;
475}
476
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300477static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800478{
479 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800480
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300481 static u8 msg[] = { 0x00, 0x14 };
482 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
483
484 if (philips_td1316_tuner_sleep(fe))
485 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800486
487 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300488 if (fe->ops.i2c_gate_ctrl)
489 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800490 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300491 return 0;
492}
493
494static int philips_europa_demod_sleep(struct dvb_frontend *fe)
495{
496 struct saa7134_dev *dev = fe->dvb->priv;
497
498 if (dev->original_demod_sleep)
499 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300500 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300501 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800502}
503
504static struct tda1004x_config philips_europa_config = {
505
506 .demod_address = 0x8,
507 .invert = 0,
508 .invert_oclk = 0,
509 .xtal_freq = TDA10046_XTAL_4M,
510 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
511 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300512 .tuner_address = 0x61,
513 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800514};
515
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700516static struct tda1004x_config medion_cardbus = {
517 .demod_address = 0x08,
518 .invert = 1,
519 .invert_oclk = 0,
520 .xtal_freq = TDA10046_XTAL_16M,
521 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
522 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300523 .tuner_address = 0x61,
524 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700525};
526
Vadim Catana128fe952010-05-29 12:49:16 -0300527static struct tda1004x_config technotrend_budget_t3000_config = {
528 .demod_address = 0x8,
529 .invert = 1,
530 .invert_oclk = 0,
531 .xtal_freq = TDA10046_XTAL_4M,
532 .agc_config = TDA10046_AGC_DEFAULT,
533 .if_freq = TDA10046_FREQ_3617,
534 .tuner_address = 0x63,
535 .request_firmware = philips_tda1004x_request_firmware
536};
537
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300538/* ------------------------------------------------------------------
539 * tda 1004x based cards with philips silicon tuner
540 */
541
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300542static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
543{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300544 struct tda1004x_state *state = fe->demodulator_priv;
545
546 u8 addr = state->config->i2c_gate;
547 static u8 tda8290_close[] = { 0x21, 0xc0};
548 static u8 tda8290_open[] = { 0x21, 0x80};
549 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
550 if (enable) {
551 tda8290_msg.buf = tda8290_close;
552 } else {
553 tda8290_msg.buf = tda8290_open;
554 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300555 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300556 struct saa7134_dev *dev = fe->dvb->priv;
557 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300558 return -EIO;
559 }
560 msleep(20);
561 return 0;
562}
563
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300564static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300565{
566 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300567 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300568
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300569 switch (state->config->antenna_switch) {
570 case 0: break;
571 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
572 saa7134_set_gpio(dev, 21, 0);
573 break;
574 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
575 saa7134_set_gpio(dev, 21, 1);
576 break;
577 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300578 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800579}
580
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300581static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
582{
583 struct saa7134_dev *dev = fe->dvb->priv;
584 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300585
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300586 switch (state->config->antenna_switch) {
587 case 0: break;
588 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
589 saa7134_set_gpio(dev, 21, 1);
590 break;
591 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
592 saa7134_set_gpio(dev, 21, 0);
593 break;
594 }
595 return 0;
596}
597
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300598static int configure_tda827x_fe(struct saa7134_dev *dev,
599 struct tda1004x_config *cdec_conf,
600 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300601{
Steven Toth363c35f2008-10-11 11:05:50 -0300602 struct videobuf_dvb_frontend *fe0;
603
Darron Broad92abe9e2008-10-11 11:18:53 -0300604 /* Get the first frontend */
605 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300606
607 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
608 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300609 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300610 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
611 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300612 cdec_conf->tuner_address,
613 &dev->i2c_adap, tuner_conf))
614 return 0;
615
616 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300617 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300618 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300619 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300620}
621
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800622/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300623
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300624static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300625 .init = philips_tda827x_tuner_init,
626 .sleep = philips_tda827x_tuner_sleep,
627 .config = 0,
628 .switch_addr = 0
629};
630
631static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300632 .init = philips_tda827x_tuner_init,
633 .sleep = philips_tda827x_tuner_sleep,
634 .config = 1,
635 .switch_addr = 0x4b
636};
637
638static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300639 .init = philips_tda827x_tuner_init,
640 .sleep = philips_tda827x_tuner_sleep,
641 .config = 2,
642 .switch_addr = 0x4b
643};
644
645static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300646 .init = philips_tda827x_tuner_init,
647 .sleep = philips_tda827x_tuner_sleep,
648 .config = 2,
649 .switch_addr = 0x42
650};
651
652/* ------------------------------------------------------------------ */
653
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300654static struct tda1004x_config tda827x_lifeview_config = {
655 .demod_address = 0x08,
656 .invert = 1,
657 .invert_oclk = 0,
658 .xtal_freq = TDA10046_XTAL_16M,
659 .agc_config = TDA10046_AGC_TDA827X,
660 .gpio_config = TDA10046_GP11_I,
661 .if_freq = TDA10046_FREQ_045,
662 .tuner_address = 0x60,
663 .request_firmware = philips_tda1004x_request_firmware
664};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800665
666static struct tda1004x_config philips_tiger_config = {
667 .demod_address = 0x08,
668 .invert = 1,
669 .invert_oclk = 0,
670 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300671 .agc_config = TDA10046_AGC_TDA827X,
672 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300673 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300674 .i2c_gate = 0x4b,
675 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300676 .antenna_switch= 1,
677 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300678};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300679
680static struct tda1004x_config cinergy_ht_config = {
681 .demod_address = 0x08,
682 .invert = 1,
683 .invert_oclk = 0,
684 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300685 .agc_config = TDA10046_AGC_TDA827X,
686 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800687 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300688 .i2c_gate = 0x4b,
689 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300690 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800691};
692
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300693static struct tda1004x_config cinergy_ht_pci_config = {
694 .demod_address = 0x08,
695 .invert = 1,
696 .invert_oclk = 0,
697 .xtal_freq = TDA10046_XTAL_16M,
698 .agc_config = TDA10046_AGC_TDA827X,
699 .gpio_config = TDA10046_GP01_I,
700 .if_freq = TDA10046_FREQ_045,
701 .i2c_gate = 0x4b,
702 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300703 .request_firmware = philips_tda1004x_request_firmware
704};
705
706static struct tda1004x_config philips_tiger_s_config = {
707 .demod_address = 0x08,
708 .invert = 1,
709 .invert_oclk = 0,
710 .xtal_freq = TDA10046_XTAL_16M,
711 .agc_config = TDA10046_AGC_TDA827X,
712 .gpio_config = TDA10046_GP01_I,
713 .if_freq = TDA10046_FREQ_045,
714 .i2c_gate = 0x4b,
715 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300716 .antenna_switch= 1,
717 .request_firmware = philips_tda1004x_request_firmware
718};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200719
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300720static struct tda1004x_config pinnacle_pctv_310i_config = {
721 .demod_address = 0x08,
722 .invert = 1,
723 .invert_oclk = 0,
724 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300725 .agc_config = TDA10046_AGC_TDA827X,
726 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300727 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300728 .i2c_gate = 0x4b,
729 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300730 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300731};
732
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300733static struct tda1004x_config hauppauge_hvr_1110_config = {
734 .demod_address = 0x08,
735 .invert = 1,
736 .invert_oclk = 0,
737 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300738 .agc_config = TDA10046_AGC_TDA827X,
739 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300740 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300741 .i2c_gate = 0x4b,
742 .tuner_address = 0x61,
743 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300744};
745
Hartmut Hackmann83646812006-10-12 20:38:51 -0300746static struct tda1004x_config asus_p7131_dual_config = {
747 .demod_address = 0x08,
748 .invert = 1,
749 .invert_oclk = 0,
750 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300751 .agc_config = TDA10046_AGC_TDA827X,
752 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300753 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300754 .i2c_gate = 0x4b,
755 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300756 .antenna_switch= 2,
757 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300758};
759
Nico Sabbi420f32f2006-03-03 12:11:28 -0300760static struct tda1004x_config lifeview_trio_config = {
761 .demod_address = 0x09,
762 .invert = 1,
763 .invert_oclk = 0,
764 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300765 .agc_config = TDA10046_AGC_TDA827X,
766 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300767 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300768 .tuner_address = 0x60,
769 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300770};
771
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300772static struct tda1004x_config tevion_dvbt220rf_config = {
773 .demod_address = 0x08,
774 .invert = 1,
775 .invert_oclk = 0,
776 .xtal_freq = TDA10046_XTAL_16M,
777 .agc_config = TDA10046_AGC_TDA827X,
778 .gpio_config = TDA10046_GP11_I,
779 .if_freq = TDA10046_FREQ_045,
780 .tuner_address = 0x60,
781 .request_firmware = philips_tda1004x_request_firmware
782};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300783
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300784static struct tda1004x_config md8800_dvbt_config = {
785 .demod_address = 0x08,
786 .invert = 1,
787 .invert_oclk = 0,
788 .xtal_freq = TDA10046_XTAL_16M,
789 .agc_config = TDA10046_AGC_TDA827X,
790 .gpio_config = TDA10046_GP01_I,
791 .if_freq = TDA10046_FREQ_045,
792 .i2c_gate = 0x4b,
793 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300794 .request_firmware = philips_tda1004x_request_firmware
795};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200796
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300797static struct tda1004x_config asus_p7131_4871_config = {
798 .demod_address = 0x08,
799 .invert = 1,
800 .invert_oclk = 0,
801 .xtal_freq = TDA10046_XTAL_16M,
802 .agc_config = TDA10046_AGC_TDA827X,
803 .gpio_config = TDA10046_GP01_I,
804 .if_freq = TDA10046_FREQ_045,
805 .i2c_gate = 0x4b,
806 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300807 .antenna_switch= 2,
808 .request_firmware = philips_tda1004x_request_firmware
809};
810
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300811static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300812 .demod_address = 0x08,
813 .invert = 1,
814 .invert_oclk = 0,
815 .xtal_freq = TDA10046_XTAL_16M,
816 .agc_config = TDA10046_AGC_TDA827X,
817 .gpio_config = TDA10046_GP11_I,
818 .if_freq = TDA10046_FREQ_045,
819 .i2c_gate = 0x4b,
820 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300821 .antenna_switch= 2,
822 .request_firmware = philips_tda1004x_request_firmware
823};
Edgar Simo261f5082007-08-20 14:06:00 -0300824
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300825static struct tda1004x_config kworld_dvb_t_210_config = {
826 .demod_address = 0x08,
827 .invert = 1,
828 .invert_oclk = 0,
829 .xtal_freq = TDA10046_XTAL_16M,
830 .agc_config = TDA10046_AGC_TDA827X,
831 .gpio_config = TDA10046_GP11_I,
832 .if_freq = TDA10046_FREQ_045,
833 .i2c_gate = 0x4b,
834 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300835 .antenna_switch= 1,
836 .request_firmware = philips_tda1004x_request_firmware
837};
Edgar Simo261f5082007-08-20 14:06:00 -0300838
Edgar Simod90d9f52007-08-20 14:14:50 -0300839static struct tda1004x_config avermedia_super_007_config = {
840 .demod_address = 0x08,
841 .invert = 1,
842 .invert_oclk = 0,
843 .xtal_freq = TDA10046_XTAL_16M,
844 .agc_config = TDA10046_AGC_TDA827X,
845 .gpio_config = TDA10046_GP01_I,
846 .if_freq = TDA10046_FREQ_045,
847 .i2c_gate = 0x4b,
848 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300849 .antenna_switch= 1,
850 .request_firmware = philips_tda1004x_request_firmware
851};
852
Hermann Pitton4ba24372008-01-20 19:27:51 -0300853static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
854 .demod_address = 0x08,
855 .invert = 1,
856 .invert_oclk = 0,
857 .xtal_freq = TDA10046_XTAL_16M,
858 .agc_config = TDA10046_AGC_TDA827X,
859 .gpio_config = TDA10046_GP01_I,
860 .if_freq = TDA10046_FREQ_045,
861 .i2c_gate = 0x42,
862 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300863 .antenna_switch = 1,
864 .request_firmware = philips_tda1004x_request_firmware
865};
866
hermann pitton301e9d62008-09-14 17:49:14 -0300867static struct tda1004x_config asus_tiger_3in1_config = {
868 .demod_address = 0x0b,
869 .invert = 1,
870 .invert_oclk = 0,
871 .xtal_freq = TDA10046_XTAL_16M,
872 .agc_config = TDA10046_AGC_TDA827X,
873 .gpio_config = TDA10046_GP11_I,
874 .if_freq = TDA10046_FREQ_045,
875 .i2c_gate = 0x4b,
876 .tuner_address = 0x61,
877 .antenna_switch = 1,
878 .request_firmware = philips_tda1004x_request_firmware
879};
880
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300881/* ------------------------------------------------------------------
882 * special case: this card uses saa713x GPIO22 for the mode switch
883 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200884
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300885static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200886{
887 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300888 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200889 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300890 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200891 return 0;
892}
893
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300894static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200895{
896 struct saa7134_dev *dev = fe->dvb->priv;
897 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300898 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300899 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300900 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200901}
902
Michael Krufky8ce47da2007-04-27 12:31:14 -0300903static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300904 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300905 .sleep = ads_duo_tuner_sleep,
906 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300907};
908
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200909static struct tda1004x_config ads_tech_duo_config = {
910 .demod_address = 0x08,
911 .invert = 1,
912 .invert_oclk = 0,
913 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300914 .agc_config = TDA10046_AGC_TDA827X,
915 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200916 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300917 .tuner_address = 0x61,
918 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200919};
920
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300921static struct zl10353_config behold_h6_config = {
922 .demod_address = 0x1e>>1,
923 .no_tuner = 1,
924 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300925 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300926};
927
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300928static struct xc5000_config behold_x7_tunerconfig = {
929 .i2c_address = 0xc2>>1,
930 .if_khz = 4560,
Devin Heitmueller2a0d0562009-09-30 23:04:39 -0300931 .radio_input = XC5000_RADIO_FM1,
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300932};
933
934static struct zl10353_config behold_x7_config = {
935 .demod_address = 0x1e>>1,
936 .if2 = 45600,
937 .no_tuner = 1,
938 .parallel_ts = 1,
939 .disable_i2c_gate_ctrl = 1,
940};
941
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300942/* ==================================================================
943 * tda10086 based DVB-S cards, helper functions
944 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300945
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300946static struct tda10086_config flydvbs = {
947 .demod_address = 0x0e,
948 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300949 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300950 .xtal_freq = TDA10086_XTAL_16M,
951};
952
953static struct tda10086_config sd1878_4m = {
954 .demod_address = 0x0e,
955 .invert = 0,
956 .diseqc_tone = 0,
957 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300958};
959
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300960/* ------------------------------------------------------------------
961 * special case: lnb supply is connected to the gated i2c
962 */
963
964static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
965{
966 int res = -EIO;
967 struct saa7134_dev *dev = fe->dvb->priv;
968 if (fe->ops.i2c_gate_ctrl) {
969 fe->ops.i2c_gate_ctrl(fe, 1);
970 if (dev->original_set_voltage)
971 res = dev->original_set_voltage(fe, voltage);
972 fe->ops.i2c_gate_ctrl(fe, 0);
973 }
974 return res;
975};
976
977static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
978{
979 int res = -EIO;
980 struct saa7134_dev *dev = fe->dvb->priv;
981 if (fe->ops.i2c_gate_ctrl) {
982 fe->ops.i2c_gate_ctrl(fe, 1);
983 if (dev->original_set_high_voltage)
984 res = dev->original_set_high_voltage(fe, arg);
985 fe->ops.i2c_gate_ctrl(fe, 0);
986 }
987 return res;
988};
989
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300990static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
991{
992 struct saa7134_dev *dev = fe->dvb->priv;
993 u8 wbuf[2] = { 0x1f, 00 };
994 u8 rbuf;
995 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
996 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
997
998 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
999 return -EIO;
1000 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1001 if (voltage == SEC_VOLTAGE_18)
1002 wbuf[1] = rbuf | 0x10;
1003 else
1004 wbuf[1] = rbuf & 0xef;
1005 msg[0].len = 2;
1006 i2c_transfer(&dev->i2c_adap, msg, 1);
1007 return 0;
1008}
1009
1010static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1011{
1012 struct saa7134_dev *dev = fe->dvb->priv;
1013 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
1014 return -EIO;
1015}
1016
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001017/* ==================================================================
1018 * nxt200x based ATSC cards, helper functions
1019 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001020
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001021static struct nxt200x_config avertvhda180 = {
1022 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001023};
Andrew Burri3e1410a2006-02-27 00:08:23 -03001024
1025static struct nxt200x_config kworldatsc110 = {
1026 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -03001027};
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001028
Matthias Schwarzott04574182009-02-24 12:35:16 -03001029/* ------------------------------------------------------------------ */
1030
1031static struct mt312_config avertv_a700_mt312 = {
1032 .demod_address = 0x0e,
1033 .voltage_inverted = 1,
1034};
1035
1036static struct zl10036_config avertv_a700_tuner = {
1037 .tuner_address = 0x60,
1038};
1039
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001040static struct mt312_config zl10313_compro_s350_config = {
1041 .demod_address = 0x0e,
1042};
1043
Michael Krufky3abdedd2009-01-19 01:10:49 -03001044static struct lgdt3305_config hcw_lgdt3305_config = {
1045 .i2c_addr = 0x0e,
1046 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1047 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1048 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1049 .deny_i2c_rptr = 1,
1050 .spectral_inversion = 1,
1051 .qam_if_khz = 4000,
1052 .vsb_if_khz = 3250,
1053};
1054
Michael Krufky1bc7f512009-01-19 01:10:49 -03001055static struct tda10048_config hcw_tda10048_config = {
1056 .demod_address = 0x10 >> 1,
1057 .output_mode = TDA10048_SERIAL_OUTPUT,
1058 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1059 .inversion = TDA10048_INVERSION_ON,
1060 .dtv6_if_freq_khz = TDA10048_IF_3300,
1061 .dtv7_if_freq_khz = TDA10048_IF_3500,
1062 .dtv8_if_freq_khz = TDA10048_IF_4000,
1063 .clk_freq_khz = TDA10048_CLK_16000,
1064 .disable_gate_access = 1,
1065};
1066
Michael Krufky3abdedd2009-01-19 01:10:49 -03001067static struct tda18271_std_map hauppauge_tda18271_std_map = {
1068 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1069 .if_lvl = 1, .rfagc_top = 0x58, },
1070 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1071 .if_lvl = 1, .rfagc_top = 0x58, },
1072};
1073
1074static struct tda18271_config hcw_tda18271_config = {
1075 .std_map = &hauppauge_tda18271_std_map,
1076 .gate = TDA18271_GATE_ANALOG,
1077 .config = 3,
Michael Krufky542cb052009-08-29 17:45:48 -03001078 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky3abdedd2009-01-19 01:10:49 -03001079};
1080
1081static struct tda829x_config tda829x_no_probe = {
1082 .probe_tuner = TDA829X_DONT_PROBE,
1083};
1084
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001085static struct tda10048_config zolid_tda10048_config = {
1086 .demod_address = 0x10 >> 1,
1087 .output_mode = TDA10048_PARALLEL_OUTPUT,
1088 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1089 .inversion = TDA10048_INVERSION_ON,
1090 .dtv6_if_freq_khz = TDA10048_IF_3300,
1091 .dtv7_if_freq_khz = TDA10048_IF_3500,
1092 .dtv8_if_freq_khz = TDA10048_IF_4000,
1093 .clk_freq_khz = TDA10048_CLK_16000,
1094 .disable_gate_access = 1,
1095};
1096
1097static struct tda18271_config zolid_tda18271_config = {
1098 .gate = TDA18271_GATE_ANALOG,
1099};
1100
Michael Krufky184e7692009-06-05 04:28:28 -03001101static struct tda10048_config dtv1000s_tda10048_config = {
1102 .demod_address = 0x10 >> 1,
1103 .output_mode = TDA10048_PARALLEL_OUTPUT,
1104 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1105 .inversion = TDA10048_INVERSION_ON,
1106 .dtv6_if_freq_khz = TDA10048_IF_3300,
1107 .dtv7_if_freq_khz = TDA10048_IF_3800,
1108 .dtv8_if_freq_khz = TDA10048_IF_4300,
1109 .clk_freq_khz = TDA10048_CLK_16000,
1110 .disable_gate_access = 1,
1111};
1112
1113static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1114 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1115 .if_lvl = 1, .rfagc_top = 0x37, },
1116 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1117 .if_lvl = 1, .rfagc_top = 0x37, },
1118 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1119 .if_lvl = 1, .rfagc_top = 0x37, },
1120};
1121
1122static struct tda18271_config dtv1000s_tda18271_config = {
1123 .std_map = &dtv1000s_tda18271_std_map,
1124 .gate = TDA18271_GATE_ANALOG,
1125};
1126
Timothy Leece027042011-03-25 15:00:33 -03001127static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
1128 .prod = LGS8GXX_PROD_LGS8G75,
1129 .demod_address = 0x1d,
1130 .serial_ts = 0,
1131 .ts_clk_pol = 1,
1132 .ts_clk_gated = 0,
1133 .if_clk_freq = 30400, /* 30.4 MHz */
1134 .if_freq = 4000, /* 4.00 MHz */
1135 .if_neg_center = 0,
1136 .ext_adc = 0,
1137 .adc_signed = 1,
1138 .adc_vpp = 3, /* 2.0 Vpp */
1139 .if_neg_edge = 1,
1140};
1141
1142static struct tda18271_config prohdtv_pro2_tda18271_config = {
1143 .gate = TDA18271_GATE_ANALOG,
1144 .output_opt = TDA18271_OUTPUT_LT_OFF,
1145};
1146
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001147/* ==================================================================
1148 * Core code
1149 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001150
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151static int dvb_init(struct saa7134_dev *dev)
1152{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001153 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001154 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001155 struct videobuf_dvb_frontend *fe0;
1156
Darron Broadf972e0b2008-10-11 11:24:30 -03001157 /* FIXME: add support for multi-frontend */
1158 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001159 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -03001160
1161 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001162 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1163 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -03001164 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1165 return -ENOMEM;
1166 }
1167
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 /* init struct videobuf_dvb */
1169 dev->ts.nr_bufs = 32;
1170 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001171 fe0->dvb.name = dev->name;
1172 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001173 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1175 V4L2_FIELD_ALTERNATE,
1176 sizeof(struct saa7134_buf),
Hans Verkuil08bff032010-09-20 17:39:46 -03001177 dev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178
1179 switch (dev->board) {
1180 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001181 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001182 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001183 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001184 if (fe0->dvb.frontend) {
1185 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001186 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001188 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001189 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001190 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001191 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001192 &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 Krufkyfb147e92008-04-22 14:46:16 -03001195 &dev->i2c_adap, 0x61,
1196 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001197 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001198 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001199 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001200 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001201 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001202 &avermedia_xc3028_mt352_dev,
1203 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001204 attach_xc3028 = 1;
1205 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001207 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001208 &medion_cardbus,
1209 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001210 if (fe0->dvb.frontend) {
1211 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001212 &dev->i2c_adap, medion_cardbus.tuner_address,
1213 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001214 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001216 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001217 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001218 &philips_tu1216_60_config,
1219 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001220 if (fe0->dvb.frontend) {
1221 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1222 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001223 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001224 break;
1225 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001226 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001227 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1228 &tda827x_cfg_0) < 0)
1229 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001230 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001231 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001232 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Danny Woode3c6e1a2009-09-20 12:14:21 -03001233 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001234 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001235 &philips_europa_config,
1236 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001237 if (fe0->dvb.frontend) {
1238 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1239 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1240 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1241 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1242 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001243 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001244 break;
Vadim Catana128fe952010-05-29 12:49:16 -03001245 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1246 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1247 &technotrend_budget_t3000_config,
1248 &dev->i2c_adap);
1249 if (fe0->dvb.frontend) {
1250 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1251 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1252 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1253 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1254 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1255 }
1256 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001257 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001258 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001259 &philips_tu1216_61_config,
1260 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001261 if (fe0->dvb.frontend) {
1262 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1263 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001264 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001265 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001266 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001267 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1268 &tda827x_cfg_2) < 0)
1269 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001270 break;
Michael Krufky0e316ec2009-08-03 16:51:33 -03001271 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
Michael Krufky1bc7f512009-01-19 01:10:49 -03001272 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1273 &hcw_tda10048_config,
1274 &dev->i2c_adap);
1275 if (fe0->dvb.frontend != NULL) {
1276 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1277 &dev->i2c_adap, 0x4b,
1278 &tda829x_no_probe);
1279 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1280 0x60, &dev->i2c_adap,
1281 &hcw_tda18271_config);
1282 }
1283 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001284 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001285 if (configure_tda827x_fe(dev, &philips_tiger_config,
1286 &tda827x_cfg_0) < 0)
1287 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001288 break;
1289 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001290 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1291 &tda827x_cfg_1) < 0)
1292 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001293 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001294 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001295 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1296 &tda827x_cfg_1) < 0)
1297 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001298 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001299 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001300 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1301 &hcw_lgdt3305_config,
1302 &dev->i2c_adap);
1303 if (fe0->dvb.frontend) {
1304 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1305 &dev->i2c_adap, 0x4b,
1306 &tda829x_no_probe);
1307 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1308 0x60, &dev->i2c_adap,
1309 &hcw_tda18271_config);
1310 }
1311 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001312 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001313 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1314 &tda827x_cfg_0) < 0)
1315 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001316 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001317 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001318 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1319 &tda827x_cfg_0) < 0)
1320 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001321 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001322 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001323 if (!use_frontend) { /* terrestrial */
1324 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1325 &tda827x_cfg_0) < 0)
1326 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001327 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001328 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1329 if (fe0->dvb.frontend) {
1330 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001331 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001332 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001333 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001334 }
Steven Toth363c35f2008-10-11 11:05:50 -03001335 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001336 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001337 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001338 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001339 }
1340 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001341 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001342 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001343 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001344 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001345 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001346 &ads_tech_duo_config,
1347 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001348 if (fe0->dvb.frontend) {
1349 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001350 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1351 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001352 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001353 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001354 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001355 }
Mauro Carvalho Chehabbc36ec7462008-06-14 10:44:04 -03001356 } else
1357 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001358 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001359 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001360 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1361 &tda827x_cfg_0) < 0)
1362 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001363 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001364 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001365 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001366 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1367 &tda827x_cfg_0) < 0)
1368 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001369 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001370 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001371 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001372 if (fe0->dvb.frontend) {
1373 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001374 u8 dev_id = dev->eedata[2];
1375 u8 data = 0xc4;
1376 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1377
Steven Toth363c35f2008-10-11 11:05:50 -03001378 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001379 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001380 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001381 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001382 goto dettach_frontend;
1383 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001384 if (dev_id != 0x08) {
1385 /* we need to open the i2c gate (we know it exists) */
1386 fe->ops.i2c_gate_ctrl(fe, 1);
1387 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001388 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001389 wprintk("%s: Medion Quadro, no ISL6405 "
1390 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001391 goto dettach_frontend;
1392 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001393 if (dev_id == 0x07) {
1394 /* fire up the 2nd section of the LNB supply since
1395 we can't do this from the other section */
1396 msg.buf = &data;
1397 i2c_transfer(&dev->i2c_adap, &msg, 1);
1398 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001399 fe->ops.i2c_gate_ctrl(fe, 0);
1400 dev->original_set_voltage = fe->ops.set_voltage;
1401 fe->ops.set_voltage = md8800_set_voltage;
1402 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1403 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1404 } else {
1405 fe->ops.set_voltage = md8800_set_voltage2;
1406 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1407 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001408 }
1409 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001410 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001411 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001412 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001413 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001414 if (fe0->dvb.frontend)
1415 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001416 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001417 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001418 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001419 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001420 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001421 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001422 if (fe0->dvb.frontend)
1423 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001424 &dev->i2c_adap, 0x61,
1425 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001426 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001427 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001428 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001429 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001430 if (fe0->dvb.frontend) {
1431 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001432 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001433 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001434 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001435 }
Steven Toth363c35f2008-10-11 11:05:50 -03001436 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001437 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001438 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001439 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001440 }
1441 }
1442 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001443 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001444 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001445 &medion_cardbus,
1446 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001447 if (fe0->dvb.frontend) {
1448 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1449 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001450
Steven Toth363c35f2008-10-11 11:05:50 -03001451 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001452 &dev->i2c_adap, medion_cardbus.tuner_address,
1453 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001454 }
1455 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001456 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001457 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001458 &philips_europa_config,
1459 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001460 if (fe0->dvb.frontend) {
1461 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1462 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001463 }
1464 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001465 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001466 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1467 &tda827x_cfg_0) < 0)
1468 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001469 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001470 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001471 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1472 &tda827x_cfg_0) < 0)
1473 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001474 break;
1475 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001476 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1477 &tda827x_cfg_2) < 0)
1478 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001479 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001480 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001481 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1482 &tda827x_cfg_2) < 0)
1483 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001484 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001485 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001486 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1487 &tda827x_cfg_2) < 0)
1488 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001489 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001490 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001491 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1492 &tda827x_cfg_0) < 0)
1493 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001494 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001495 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001496 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1497 &tda827x_cfg_2_sw42) < 0)
1498 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001499 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001500 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001501 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001502 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001503 if (fe0->dvb.frontend) {
1504 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001505 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001506 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001507 goto dettach_frontend;
1508 }
Steven Toth363c35f2008-10-11 11:05:50 -03001509 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001510 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001511 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001512 goto dettach_frontend;
1513 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001514 }
1515 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001516 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001517 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1518 &tda827x_cfg_0) < 0)
1519 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001520 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001521 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001522 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1523 &tda827x_cfg_2) < 0)
1524 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001525 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001526 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001527 dprintk("AverMedia E506R dvb setup\n");
1528 saa7134_set_gpio(dev, 25, 0);
1529 msleep(10);
1530 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001531 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001532 &avermedia_xc3028_mt352_dev,
1533 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001534 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001535 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001536 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001537 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001538 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001539 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001540 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001541 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001542 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001543 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001544 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001545 goto dettach_frontend;
1546 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001547 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001548 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001549 fe->ops.i2c_gate_ctrl(fe, 1);
1550 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001551 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001552 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001553 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001554 goto dettach_frontend;
1555 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001556 fe->ops.i2c_gate_ctrl(fe, 0);
1557 dev->original_set_voltage = fe->ops.set_voltage;
1558 fe->ops.set_voltage = md8800_set_voltage;
1559 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1560 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1561 }
1562 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001563 case SAA7134_BOARD_AVERMEDIA_M103:
1564 saa7134_set_gpio(dev, 25, 0);
1565 msleep(10);
1566 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001567 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001568 &avermedia_xc3028_mt352_dev,
1569 &dev->i2c_adap);
1570 attach_xc3028 = 1;
1571 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001572 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1573 if (!use_frontend) { /* terrestrial */
1574 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1575 &tda827x_cfg_2) < 0)
1576 goto dettach_frontend;
1577 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001578 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001579 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001580 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001581 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001582 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001583 &dev->i2c_adap, 0) == NULL) {
1584 wprintk("%s: Asus Tiger 3in1, no "
1585 "tda826x found!\n", __func__);
1586 goto dettach_frontend;
1587 }
Steven Toth363c35f2008-10-11 11:05:50 -03001588 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001589 &dev->i2c_adap, 0, 0) == NULL) {
1590 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1591 " found!\n", __func__);
1592 goto dettach_frontend;
1593 }
1594 }
1595 }
1596 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001597 case SAA7134_BOARD_ASUSTeK_TIGER:
1598 if (configure_tda827x_fe(dev, &philips_tiger_config,
1599 &tda827x_cfg_0) < 0)
1600 goto dettach_frontend;
1601 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001602 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001603 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001604 &behold_h6_config,
1605 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001606 if (fe0->dvb.frontend) {
1607 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001608 &dev->i2c_adap, 0x61,
Beholder Intl. Ltd. Dmitry Belimov4786dd62009-08-04 20:07:42 -03001609 TUNER_PHILIPS_FMD1216MEX_MK3);
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001610 }
1611 break;
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -03001612 case SAA7134_BOARD_BEHOLD_X7:
1613 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1614 &behold_x7_config,
1615 &dev->i2c_adap);
1616 if (fe0->dvb.frontend) {
1617 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1618 &dev->i2c_adap, &behold_x7_tunerconfig);
1619 }
1620 break;
Dmitri Belimov0faa2ed2010-04-06 01:00:05 -03001621 case SAA7134_BOARD_BEHOLD_H7:
1622 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1623 &behold_x7_config,
1624 &dev->i2c_adap);
1625 if (fe0->dvb.frontend) {
1626 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1627 &dev->i2c_adap, &behold_x7_tunerconfig);
1628 }
1629 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001630 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1631 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1632 /* Zarlink ZL10313 */
1633 fe0->dvb.frontend = dvb_attach(mt312_attach,
1634 &avertv_a700_mt312, &dev->i2c_adap);
1635 if (fe0->dvb.frontend) {
1636 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1637 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1638 wprintk("%s: No zl10036 found!\n",
1639 __func__);
1640 }
1641 }
1642 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001643 case SAA7134_BOARD_VIDEOMATE_S350:
1644 fe0->dvb.frontend = dvb_attach(mt312_attach,
1645 &zl10313_compro_s350_config, &dev->i2c_adap);
1646 if (fe0->dvb.frontend)
1647 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1648 0x60, &dev->i2c_adap) == NULL)
1649 wprintk("%s: No zl10039 found!\n",
1650 __func__);
1651
1652 break;
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001653 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1654 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1655 &zolid_tda10048_config,
1656 &dev->i2c_adap);
1657 if (fe0->dvb.frontend != NULL) {
1658 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1659 &dev->i2c_adap, 0x4b,
1660 &tda829x_no_probe);
1661 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1662 0x60, &dev->i2c_adap,
1663 &zolid_tda18271_config);
1664 }
1665 break;
Michael Krufky184e7692009-06-05 04:28:28 -03001666 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1667 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1668 &dtv1000s_tda10048_config,
1669 &dev->i2c_adap);
1670 if (fe0->dvb.frontend != NULL) {
1671 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1672 &dev->i2c_adap, 0x4b,
1673 &tda829x_no_probe);
1674 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1675 0x60, &dev->i2c_adap,
1676 &dtv1000s_tda18271_config);
1677 }
1678 break;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001679 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
Mauro Carvalho Chehabecb71d22011-01-14 12:03:03 -03001680 /* Switch to digital mode */
1681 saa7134_tuner_callback(dev, 0,
1682 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001683 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1684 &kworld_mb86a20s_config,
1685 &dev->i2c_adap);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001686 if (fe0->dvb.frontend != NULL) {
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001687 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1688 &dev->i2c_adap, 0x4b,
1689 &tda829x_no_probe);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001690 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1691 0x60, &dev->i2c_adap,
1692 &kworld_tda18271_config);
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001693 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001694 }
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001695
1696 /* mb86a20s need to use the I2C gateway */
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001697 break;
Timothy Leece027042011-03-25 15:00:33 -03001698 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
1699 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1700 &prohdtv_pro2_lgs8g75_config,
1701 &dev->i2c_adap);
1702 if (fe0->dvb.frontend != NULL) {
1703 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1704 &dev->i2c_adap, 0x4b,
1705 &tda829x_no_probe);
1706 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1707 0x60, &dev->i2c_adap,
1708 &prohdtv_pro2_tda18271_config);
1709 }
1710 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001712 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713 break;
1714 }
1715
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001716 if (attach_xc3028) {
1717 struct dvb_frontend *fe;
1718 struct xc2028_config cfg = {
1719 .i2c_adap = &dev->i2c_adap,
1720 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001721 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001722
Steven Toth363c35f2008-10-11 11:05:50 -03001723 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001724 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001725
Steven Toth363c35f2008-10-11 11:05:50 -03001726 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001727 if (!fe) {
1728 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1729 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001730 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001731 }
1732 }
1733
Steven Toth363c35f2008-10-11 11:05:50 -03001734 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001735 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001736 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001738 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001739 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740
1741 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001742 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001743 &dev->pci->dev, adapter_nr, 0, NULL);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001744
1745 /* this sequence is necessary to make the tda1004x load its firmware
1746 * and to enter analog mode of hybrid boards
1747 */
1748 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001749 if (fe0->dvb.frontend->ops.init)
1750 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1751 if (fe0->dvb.frontend->ops.sleep)
1752 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1753 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1754 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001755 }
1756 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001757
1758dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001759 videobuf_dvb_dealloc_frontends(&dev->frontends);
1760 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761}
1762
1763static int dvb_fini(struct saa7134_dev *dev)
1764{
Steven Toth363c35f2008-10-11 11:05:50 -03001765 struct videobuf_dvb_frontend *fe0;
1766
1767 /* Get the first frontend */
1768 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1769 if (!fe0)
1770 return -EINVAL;
1771
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001772 /* FIXME: I suspect that this code is bogus, since the entry for
1773 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1774 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1775 */
1776 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1777 struct v4l2_priv_tun_config tda9887_cfg;
1778 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001779
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001780 tda9887_cfg.tuner = TUNER_TDA9887;
1781 tda9887_cfg.priv = &on;
1782
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001784 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001785 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001786 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001787 /* turn off the 2nd lnb supply */
1788 u8 data = 0x80;
1789 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1790 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001791 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001792 if (fe->ops.i2c_gate_ctrl) {
1793 fe->ops.i2c_gate_ctrl(fe, 1);
1794 i2c_transfer(&dev->i2c_adap, &msg, 1);
1795 fe->ops.i2c_gate_ctrl(fe, 0);
1796 }
1797 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001798 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001799 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001800 return 0;
1801}
1802
1803static struct saa7134_mpeg_ops dvb_ops = {
1804 .type = SAA7134_MPEG_DVB,
1805 .init = dvb_init,
1806 .fini = dvb_fini,
1807};
1808
1809static int __init dvb_register(void)
1810{
1811 return saa7134_ts_register(&dvb_ops);
1812}
1813
1814static void __exit dvb_unregister(void)
1815{
1816 saa7134_ts_unregister(&dvb_ops);
1817}
1818
1819module_init(dvb_register);
1820module_exit(dvb_unregister);
1821
1822/* ------------------------------------------------------------------ */
1823/*
1824 * Local variables:
1825 * c-basic-offset: 8
1826 * End:
1827 */