blob: 1e4ef16698879f5904fd7b378a4883f48b987640 [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"
Carlos Corbachodbe87402011-06-25 10:24:28 -030059#include "qt1010.h"
Dmitri Belimov47aeba52008-12-23 03:53:03 -030060
Matthias Schwarzott04574182009-02-24 12:35:16 -030061#include "zl10036.h"
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -030062#include "zl10039.h"
Matthias Schwarzott04574182009-02-24 12:35:16 -030063#include "mt312.h"
64
Linus Torvalds1da177e2005-04-16 15:20:36 -070065MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
66MODULE_LICENSE("GPL");
67
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030068static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070069
Linus Torvalds1da177e2005-04-16 15:20:36 -070070module_param(antenna_pwr, int, 0444);
71MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
72
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030073static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030074module_param(use_frontend, int, 0644);
75MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030076
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030077static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030078module_param(debug, int, 0644);
79MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
80
Janne Grunau78e92002008-04-09 19:13:13 -030081DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
82
Trent Piephocf3c34c2007-03-07 18:19:48 -030083#define dprintk(fmt, arg...) do { if (debug) \
84 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
85
86/* Print a warning */
87#define wprintk(fmt, arg...) \
88 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030089
90/* ------------------------------------------------------------------
91 * mt352 based DVB-T cards
92 */
93
Linus Torvalds1da177e2005-04-16 15:20:36 -070094static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
95{
96 u32 ok;
97
98 if (!on) {
99 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
100 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
101 return 0;
102 }
103
104 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
105 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
106 udelay(10);
107
108 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
109 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
110 udelay(10);
111 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
112 udelay(10);
113 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300114 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116 if (!ok)
117 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
118 return ok;
119}
120
121static int mt352_pinnacle_init(struct dvb_frontend* fe)
122{
123 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
124 static u8 reset [] = { RESET, 0x80 };
125 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
126 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
127 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
128 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
129 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
130 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
131 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
132 struct saa7134_dev *dev= fe->dvb->priv;
133
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300134 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
136 mt352_write(fe, clock_config, sizeof(clock_config));
137 udelay(200);
138 mt352_write(fe, reset, sizeof(reset));
139 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
140 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
141 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
142 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
143
144 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
145 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
146 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 return 0;
149}
150
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200151static int mt352_aver777_init(struct dvb_frontend* fe)
152{
153 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
154 static u8 reset [] = { RESET, 0x80 };
155 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
156 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
157 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
158
159 mt352_write(fe, clock_config, sizeof(clock_config));
160 udelay(200);
161 mt352_write(fe, reset, sizeof(reset));
162 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
163 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
164 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
165
166 return 0;
167}
168
Tim Farrington6e501a32008-06-15 13:33:42 -0300169static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300170{
Tim Farrington6e501a32008-06-15 13:33:42 -0300171 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
172 static u8 reset [] = { RESET, 0x80 };
173 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
174 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300175 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
176
177 mt352_write(fe, clock_config, sizeof(clock_config));
178 udelay(200);
179 mt352_write(fe, reset, sizeof(reset));
180 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
181 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
182 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300183 return 0;
184}
185
Andrew de Quincey0463f122006-05-16 17:22:02 -0300186static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
187 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300189 u8 off[] = { 0x00, 0xf1};
190 u8 on[] = { 0x00, 0x71};
191 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
192
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 struct saa7134_dev *dev = fe->dvb->priv;
194 struct v4l2_frequency f;
195
196 /* set frequency (mt2050) */
197 f.tuner = 0;
198 f.type = V4L2_TUNER_DIGITAL_TV;
199 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300200 if (fe->ops.i2c_gate_ctrl)
201 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300202 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300203 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300204 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300205 if (fe->ops.i2c_gate_ctrl)
206 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300207 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
209 pinnacle_antenna_pwr(dev, antenna_pwr);
210
211 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300212 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213}
214
215static struct mt352_config pinnacle_300i = {
216 .demod_address = 0x3c >> 1,
217 .adc_clock = 20333,
218 .if2 = 36150,
219 .no_tuner = 1,
220 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200222
223static struct mt352_config avermedia_777 = {
224 .demod_address = 0xf,
225 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200226};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
Tim Farrington6e501a32008-06-15 13:33:42 -0300228static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300229 .demod_address = (0x1e >> 1),
230 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300231 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300232};
233
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300234static struct tda18271_std_map mb86a20s_tda18271_std_map = {
235 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
236 .if_lvl = 7, .rfagc_top = 0x37, },
237};
238
239static struct tda18271_config kworld_tda18271_config = {
240 .std_map = &mb86a20s_tda18271_std_map,
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -0300241 .gate = TDA18271_GATE_DIGITAL,
Mauro Carvalho Chehabecb71d22011-01-14 12:03:03 -0300242 .config = 3, /* Use tuner callback for AGC */
243
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300244};
245
246static const struct mb86a20s_config kworld_mb86a20s_config = {
247 .demod_address = 0x10,
248};
249
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -0300250static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
251{
252 struct saa7134_dev *dev = fe->dvb->priv;
253
254 unsigned char initmsg[] = {0x45, 0x97};
255 unsigned char msg_enable[] = {0x45, 0xc1};
256 unsigned char msg_disable[] = {0x45, 0x81};
257 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
258
259 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
260 wprintk("could not access the I2C gate\n");
261 return -EIO;
262 }
263 if (enable)
264 msg.buf = msg_enable;
265 else
266 msg.buf = msg_disable;
267 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
268 wprintk("could not access the I2C gate\n");
269 return -EIO;
270 }
271 msleep(20);
272 return 0;
273}
274
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300275/* ==================================================================
276 * tda1004x based DVB-T cards, helper functions
277 */
278
279static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
280 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700281{
282 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300283 return request_firmware(fw, name, &dev->pci->dev);
284}
285
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300286/* ------------------------------------------------------------------
287 * these tuners are tu1216, td1316(a)
288 */
289
290static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
291{
292 struct saa7134_dev *dev = fe->dvb->priv;
293 struct tda1004x_state *state = fe->demodulator_priv;
294 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700295 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800296 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700297 sizeof(tuner_buf) };
298 int tuner_frequency = 0;
299 u8 band, cp, filter;
300
301 /* determine charge pump */
302 tuner_frequency = params->frequency + 36166000;
303 if (tuner_frequency < 87000000)
304 return -EINVAL;
305 else if (tuner_frequency < 130000000)
306 cp = 3;
307 else if (tuner_frequency < 160000000)
308 cp = 5;
309 else if (tuner_frequency < 200000000)
310 cp = 6;
311 else if (tuner_frequency < 290000000)
312 cp = 3;
313 else if (tuner_frequency < 420000000)
314 cp = 5;
315 else if (tuner_frequency < 480000000)
316 cp = 6;
317 else if (tuner_frequency < 620000000)
318 cp = 3;
319 else if (tuner_frequency < 830000000)
320 cp = 5;
321 else if (tuner_frequency < 895000000)
322 cp = 7;
323 else
324 return -EINVAL;
325
326 /* determine band */
327 if (params->frequency < 49000000)
328 return -EINVAL;
329 else if (params->frequency < 161000000)
330 band = 1;
331 else if (params->frequency < 444000000)
332 band = 2;
333 else if (params->frequency < 861000000)
334 band = 4;
335 else
336 return -EINVAL;
337
338 /* setup PLL filter */
339 switch (params->u.ofdm.bandwidth) {
340 case BANDWIDTH_6_MHZ:
341 filter = 0;
342 break;
343
344 case BANDWIDTH_7_MHZ:
345 filter = 0;
346 break;
347
348 case BANDWIDTH_8_MHZ:
349 filter = 1;
350 break;
351
352 default:
353 return -EINVAL;
354 }
355
356 /* calculate divisor
357 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
358 */
359 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
360
361 /* setup tuner buffer */
362 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
363 tuner_buf[1] = tuner_frequency & 0xff;
364 tuner_buf[2] = 0xca;
365 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
366
Patrick Boettcherdea74862006-05-14 05:01:31 -0300367 if (fe->ops.i2c_gate_ctrl)
368 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300369 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300370 wprintk("could not write to tuner at addr: 0x%02x\n",
371 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700372 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300373 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700374 msleep(1);
375 return 0;
376}
377
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300378static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800379{
380 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300381 struct tda1004x_state *state = fe->demodulator_priv;
382 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800383 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
384 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
385
386 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300387 if (fe->ops.i2c_gate_ctrl)
388 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800389 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
390 return -EIO;
391 msleep(1);
392
393 return 0;
394}
395
396/* ------------------------------------------------------------------ */
397
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800398static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700399 .demod_address = 0x8,
400 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800401 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700402 .xtal_freq = TDA10046_XTAL_4M,
403 .agc_config = TDA10046_AGC_DEFAULT,
404 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300405 .tuner_address = 0x60,
406 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407};
408
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800409static struct tda1004x_config philips_tu1216_61_config = {
410
411 .demod_address = 0x8,
412 .invert = 1,
413 .invert_oclk = 0,
414 .xtal_freq = TDA10046_XTAL_4M,
415 .agc_config = TDA10046_AGC_DEFAULT,
416 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300417 .tuner_address = 0x61,
418 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800419};
420
421/* ------------------------------------------------------------------ */
422
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300423static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800424{
425 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300426 struct tda1004x_state *state = fe->demodulator_priv;
427 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800428 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300429 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800430
431 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300432 if (fe->ops.i2c_gate_ctrl)
433 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800434 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
435 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800436 return 0;
437}
438
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300439static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800440{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300441 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800442}
443
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300444static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
445{
446 struct saa7134_dev *dev = fe->dvb->priv;
447 struct tda1004x_state *state = fe->demodulator_priv;
448 u8 addr = state->config->tuner_address;
449 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
450 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
451
452 /* switch the tuner to analog mode */
453 if (fe->ops.i2c_gate_ctrl)
454 fe->ops.i2c_gate_ctrl(fe, 1);
455 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
456 return -EIO;
457 return 0;
458}
459
460/* ------------------------------------------------------------------ */
461
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300462static int philips_europa_tuner_init(struct dvb_frontend *fe)
463{
464 struct saa7134_dev *dev = fe->dvb->priv;
465 static u8 msg[] = { 0x00, 0x40};
466 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
467
468
469 if (philips_td1316_tuner_init(fe))
470 return -EIO;
471 msleep(1);
472 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
473 return -EIO;
474
475 return 0;
476}
477
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300478static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800479{
480 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800481
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300482 static u8 msg[] = { 0x00, 0x14 };
483 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
484
485 if (philips_td1316_tuner_sleep(fe))
486 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800487
488 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300489 if (fe->ops.i2c_gate_ctrl)
490 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800491 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300492 return 0;
493}
494
495static int philips_europa_demod_sleep(struct dvb_frontend *fe)
496{
497 struct saa7134_dev *dev = fe->dvb->priv;
498
499 if (dev->original_demod_sleep)
500 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300501 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300502 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800503}
504
505static struct tda1004x_config philips_europa_config = {
506
507 .demod_address = 0x8,
508 .invert = 0,
509 .invert_oclk = 0,
510 .xtal_freq = TDA10046_XTAL_4M,
511 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
512 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300513 .tuner_address = 0x61,
514 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800515};
516
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700517static struct tda1004x_config medion_cardbus = {
518 .demod_address = 0x08,
519 .invert = 1,
520 .invert_oclk = 0,
521 .xtal_freq = TDA10046_XTAL_16M,
522 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
523 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300524 .tuner_address = 0x61,
525 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700526};
527
Vadim Catana128fe952010-05-29 12:49:16 -0300528static struct tda1004x_config technotrend_budget_t3000_config = {
529 .demod_address = 0x8,
530 .invert = 1,
531 .invert_oclk = 0,
532 .xtal_freq = TDA10046_XTAL_4M,
533 .agc_config = TDA10046_AGC_DEFAULT,
534 .if_freq = TDA10046_FREQ_3617,
535 .tuner_address = 0x63,
536 .request_firmware = philips_tda1004x_request_firmware
537};
538
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300539/* ------------------------------------------------------------------
540 * tda 1004x based cards with philips silicon tuner
541 */
542
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300543static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
544{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300545 struct tda1004x_state *state = fe->demodulator_priv;
546
547 u8 addr = state->config->i2c_gate;
548 static u8 tda8290_close[] = { 0x21, 0xc0};
549 static u8 tda8290_open[] = { 0x21, 0x80};
550 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
551 if (enable) {
552 tda8290_msg.buf = tda8290_close;
553 } else {
554 tda8290_msg.buf = tda8290_open;
555 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300556 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300557 struct saa7134_dev *dev = fe->dvb->priv;
558 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300559 return -EIO;
560 }
561 msleep(20);
562 return 0;
563}
564
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300565static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300566{
567 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300568 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300569
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300570 switch (state->config->antenna_switch) {
571 case 0: break;
572 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
573 saa7134_set_gpio(dev, 21, 0);
574 break;
575 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
576 saa7134_set_gpio(dev, 21, 1);
577 break;
578 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300579 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800580}
581
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300582static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
583{
584 struct saa7134_dev *dev = fe->dvb->priv;
585 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300586
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300587 switch (state->config->antenna_switch) {
588 case 0: break;
589 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
590 saa7134_set_gpio(dev, 21, 1);
591 break;
592 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
593 saa7134_set_gpio(dev, 21, 0);
594 break;
595 }
596 return 0;
597}
598
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300599static int configure_tda827x_fe(struct saa7134_dev *dev,
600 struct tda1004x_config *cdec_conf,
601 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300602{
Steven Toth363c35f2008-10-11 11:05:50 -0300603 struct videobuf_dvb_frontend *fe0;
604
Darron Broad92abe9e2008-10-11 11:18:53 -0300605 /* Get the first frontend */
606 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300607
608 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
609 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300610 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300611 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
612 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300613 cdec_conf->tuner_address,
614 &dev->i2c_adap, tuner_conf))
615 return 0;
616
617 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300618 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300619 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300620 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300621}
622
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800623/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300624
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300625static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300626 .init = philips_tda827x_tuner_init,
627 .sleep = philips_tda827x_tuner_sleep,
628 .config = 0,
629 .switch_addr = 0
630};
631
632static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300633 .init = philips_tda827x_tuner_init,
634 .sleep = philips_tda827x_tuner_sleep,
635 .config = 1,
636 .switch_addr = 0x4b
637};
638
639static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300640 .init = philips_tda827x_tuner_init,
641 .sleep = philips_tda827x_tuner_sleep,
642 .config = 2,
643 .switch_addr = 0x4b
644};
645
646static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300647 .init = philips_tda827x_tuner_init,
648 .sleep = philips_tda827x_tuner_sleep,
649 .config = 2,
650 .switch_addr = 0x42
651};
652
653/* ------------------------------------------------------------------ */
654
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300655static struct tda1004x_config tda827x_lifeview_config = {
656 .demod_address = 0x08,
657 .invert = 1,
658 .invert_oclk = 0,
659 .xtal_freq = TDA10046_XTAL_16M,
660 .agc_config = TDA10046_AGC_TDA827X,
661 .gpio_config = TDA10046_GP11_I,
662 .if_freq = TDA10046_FREQ_045,
663 .tuner_address = 0x60,
664 .request_firmware = philips_tda1004x_request_firmware
665};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800666
667static struct tda1004x_config philips_tiger_config = {
668 .demod_address = 0x08,
669 .invert = 1,
670 .invert_oclk = 0,
671 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300672 .agc_config = TDA10046_AGC_TDA827X,
673 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300674 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300675 .i2c_gate = 0x4b,
676 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300677 .antenna_switch= 1,
678 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300679};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300680
681static struct tda1004x_config cinergy_ht_config = {
682 .demod_address = 0x08,
683 .invert = 1,
684 .invert_oclk = 0,
685 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300686 .agc_config = TDA10046_AGC_TDA827X,
687 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800688 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300689 .i2c_gate = 0x4b,
690 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300691 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800692};
693
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300694static struct tda1004x_config cinergy_ht_pci_config = {
695 .demod_address = 0x08,
696 .invert = 1,
697 .invert_oclk = 0,
698 .xtal_freq = TDA10046_XTAL_16M,
699 .agc_config = TDA10046_AGC_TDA827X,
700 .gpio_config = TDA10046_GP01_I,
701 .if_freq = TDA10046_FREQ_045,
702 .i2c_gate = 0x4b,
703 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300704 .request_firmware = philips_tda1004x_request_firmware
705};
706
707static struct tda1004x_config philips_tiger_s_config = {
708 .demod_address = 0x08,
709 .invert = 1,
710 .invert_oclk = 0,
711 .xtal_freq = TDA10046_XTAL_16M,
712 .agc_config = TDA10046_AGC_TDA827X,
713 .gpio_config = TDA10046_GP01_I,
714 .if_freq = TDA10046_FREQ_045,
715 .i2c_gate = 0x4b,
716 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300717 .antenna_switch= 1,
718 .request_firmware = philips_tda1004x_request_firmware
719};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200720
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300721static struct tda1004x_config pinnacle_pctv_310i_config = {
722 .demod_address = 0x08,
723 .invert = 1,
724 .invert_oclk = 0,
725 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300726 .agc_config = TDA10046_AGC_TDA827X,
727 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300728 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300729 .i2c_gate = 0x4b,
730 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300731 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300732};
733
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300734static struct tda1004x_config hauppauge_hvr_1110_config = {
735 .demod_address = 0x08,
736 .invert = 1,
737 .invert_oclk = 0,
738 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300739 .agc_config = TDA10046_AGC_TDA827X,
740 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300741 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300742 .i2c_gate = 0x4b,
743 .tuner_address = 0x61,
744 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300745};
746
Hartmut Hackmann83646812006-10-12 20:38:51 -0300747static struct tda1004x_config asus_p7131_dual_config = {
748 .demod_address = 0x08,
749 .invert = 1,
750 .invert_oclk = 0,
751 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300752 .agc_config = TDA10046_AGC_TDA827X,
753 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300754 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300755 .i2c_gate = 0x4b,
756 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300757 .antenna_switch= 2,
758 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300759};
760
Nico Sabbi420f32f2006-03-03 12:11:28 -0300761static struct tda1004x_config lifeview_trio_config = {
762 .demod_address = 0x09,
763 .invert = 1,
764 .invert_oclk = 0,
765 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300766 .agc_config = TDA10046_AGC_TDA827X,
767 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300768 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300769 .tuner_address = 0x60,
770 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300771};
772
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300773static struct tda1004x_config tevion_dvbt220rf_config = {
774 .demod_address = 0x08,
775 .invert = 1,
776 .invert_oclk = 0,
777 .xtal_freq = TDA10046_XTAL_16M,
778 .agc_config = TDA10046_AGC_TDA827X,
779 .gpio_config = TDA10046_GP11_I,
780 .if_freq = TDA10046_FREQ_045,
781 .tuner_address = 0x60,
782 .request_firmware = philips_tda1004x_request_firmware
783};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300784
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300785static struct tda1004x_config md8800_dvbt_config = {
786 .demod_address = 0x08,
787 .invert = 1,
788 .invert_oclk = 0,
789 .xtal_freq = TDA10046_XTAL_16M,
790 .agc_config = TDA10046_AGC_TDA827X,
791 .gpio_config = TDA10046_GP01_I,
792 .if_freq = TDA10046_FREQ_045,
793 .i2c_gate = 0x4b,
794 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300795 .request_firmware = philips_tda1004x_request_firmware
796};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200797
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300798static struct tda1004x_config asus_p7131_4871_config = {
799 .demod_address = 0x08,
800 .invert = 1,
801 .invert_oclk = 0,
802 .xtal_freq = TDA10046_XTAL_16M,
803 .agc_config = TDA10046_AGC_TDA827X,
804 .gpio_config = TDA10046_GP01_I,
805 .if_freq = TDA10046_FREQ_045,
806 .i2c_gate = 0x4b,
807 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300808 .antenna_switch= 2,
809 .request_firmware = philips_tda1004x_request_firmware
810};
811
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300812static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300813 .demod_address = 0x08,
814 .invert = 1,
815 .invert_oclk = 0,
816 .xtal_freq = TDA10046_XTAL_16M,
817 .agc_config = TDA10046_AGC_TDA827X,
818 .gpio_config = TDA10046_GP11_I,
819 .if_freq = TDA10046_FREQ_045,
820 .i2c_gate = 0x4b,
821 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300822 .antenna_switch= 2,
823 .request_firmware = philips_tda1004x_request_firmware
824};
Edgar Simo261f5082007-08-20 14:06:00 -0300825
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300826static struct tda1004x_config kworld_dvb_t_210_config = {
827 .demod_address = 0x08,
828 .invert = 1,
829 .invert_oclk = 0,
830 .xtal_freq = TDA10046_XTAL_16M,
831 .agc_config = TDA10046_AGC_TDA827X,
832 .gpio_config = TDA10046_GP11_I,
833 .if_freq = TDA10046_FREQ_045,
834 .i2c_gate = 0x4b,
835 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300836 .antenna_switch= 1,
837 .request_firmware = philips_tda1004x_request_firmware
838};
Edgar Simo261f5082007-08-20 14:06:00 -0300839
Edgar Simod90d9f52007-08-20 14:14:50 -0300840static struct tda1004x_config avermedia_super_007_config = {
841 .demod_address = 0x08,
842 .invert = 1,
843 .invert_oclk = 0,
844 .xtal_freq = TDA10046_XTAL_16M,
845 .agc_config = TDA10046_AGC_TDA827X,
846 .gpio_config = TDA10046_GP01_I,
847 .if_freq = TDA10046_FREQ_045,
848 .i2c_gate = 0x4b,
849 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300850 .antenna_switch= 1,
851 .request_firmware = philips_tda1004x_request_firmware
852};
853
Hermann Pitton4ba24372008-01-20 19:27:51 -0300854static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
855 .demod_address = 0x08,
856 .invert = 1,
857 .invert_oclk = 0,
858 .xtal_freq = TDA10046_XTAL_16M,
859 .agc_config = TDA10046_AGC_TDA827X,
860 .gpio_config = TDA10046_GP01_I,
861 .if_freq = TDA10046_FREQ_045,
862 .i2c_gate = 0x42,
863 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300864 .antenna_switch = 1,
865 .request_firmware = philips_tda1004x_request_firmware
866};
867
hermann pitton301e9d62008-09-14 17:49:14 -0300868static struct tda1004x_config asus_tiger_3in1_config = {
869 .demod_address = 0x0b,
870 .invert = 1,
871 .invert_oclk = 0,
872 .xtal_freq = TDA10046_XTAL_16M,
873 .agc_config = TDA10046_AGC_TDA827X,
874 .gpio_config = TDA10046_GP11_I,
875 .if_freq = TDA10046_FREQ_045,
876 .i2c_gate = 0x4b,
877 .tuner_address = 0x61,
878 .antenna_switch = 1,
879 .request_firmware = philips_tda1004x_request_firmware
880};
881
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300882/* ------------------------------------------------------------------
883 * special case: this card uses saa713x GPIO22 for the mode switch
884 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200885
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300886static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200887{
888 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300889 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200890 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300891 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200892 return 0;
893}
894
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300895static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200896{
897 struct saa7134_dev *dev = fe->dvb->priv;
898 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300899 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300900 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300901 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200902}
903
Michael Krufky8ce47da2007-04-27 12:31:14 -0300904static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300905 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300906 .sleep = ads_duo_tuner_sleep,
907 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300908};
909
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200910static struct tda1004x_config ads_tech_duo_config = {
911 .demod_address = 0x08,
912 .invert = 1,
913 .invert_oclk = 0,
914 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300915 .agc_config = TDA10046_AGC_TDA827X,
916 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200917 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300918 .tuner_address = 0x61,
919 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200920};
921
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300922static struct zl10353_config behold_h6_config = {
923 .demod_address = 0x1e>>1,
924 .no_tuner = 1,
925 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300926 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300927};
928
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300929static struct xc5000_config behold_x7_tunerconfig = {
930 .i2c_address = 0xc2>>1,
931 .if_khz = 4560,
Devin Heitmueller2a0d0562009-09-30 23:04:39 -0300932 .radio_input = XC5000_RADIO_FM1,
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300933};
934
935static struct zl10353_config behold_x7_config = {
936 .demod_address = 0x1e>>1,
937 .if2 = 45600,
938 .no_tuner = 1,
939 .parallel_ts = 1,
940 .disable_i2c_gate_ctrl = 1,
941};
942
Carlos Corbachodbe87402011-06-25 10:24:28 -0300943static struct zl10353_config videomate_t750_zl10353_config = {
944 .demod_address = 0x0f,
945 .no_tuner = 1,
946 .parallel_ts = 1,
947 .disable_i2c_gate_ctrl = 1,
948};
949
950static struct qt1010_config videomate_t750_qt1010_config = {
951 .i2c_address = 0x62
952};
953
954
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300955/* ==================================================================
956 * tda10086 based DVB-S cards, helper functions
957 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300958
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300959static struct tda10086_config flydvbs = {
960 .demod_address = 0x0e,
961 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300962 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300963 .xtal_freq = TDA10086_XTAL_16M,
964};
965
966static struct tda10086_config sd1878_4m = {
967 .demod_address = 0x0e,
968 .invert = 0,
969 .diseqc_tone = 0,
970 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300971};
972
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300973/* ------------------------------------------------------------------
974 * special case: lnb supply is connected to the gated i2c
975 */
976
977static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
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_voltage)
984 res = dev->original_set_voltage(fe, voltage);
985 fe->ops.i2c_gate_ctrl(fe, 0);
986 }
987 return res;
988};
989
990static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
991{
992 int res = -EIO;
993 struct saa7134_dev *dev = fe->dvb->priv;
994 if (fe->ops.i2c_gate_ctrl) {
995 fe->ops.i2c_gate_ctrl(fe, 1);
996 if (dev->original_set_high_voltage)
997 res = dev->original_set_high_voltage(fe, arg);
998 fe->ops.i2c_gate_ctrl(fe, 0);
999 }
1000 return res;
1001};
1002
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001003static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
1004{
1005 struct saa7134_dev *dev = fe->dvb->priv;
1006 u8 wbuf[2] = { 0x1f, 00 };
1007 u8 rbuf;
1008 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
1009 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
1010
1011 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
1012 return -EIO;
1013 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1014 if (voltage == SEC_VOLTAGE_18)
1015 wbuf[1] = rbuf | 0x10;
1016 else
1017 wbuf[1] = rbuf & 0xef;
1018 msg[0].len = 2;
1019 i2c_transfer(&dev->i2c_adap, msg, 1);
1020 return 0;
1021}
1022
1023static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1024{
1025 struct saa7134_dev *dev = fe->dvb->priv;
1026 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
1027 return -EIO;
1028}
1029
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001030/* ==================================================================
1031 * nxt200x based ATSC cards, helper functions
1032 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001033
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001034static struct nxt200x_config avertvhda180 = {
1035 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001036};
Andrew Burri3e1410a2006-02-27 00:08:23 -03001037
1038static struct nxt200x_config kworldatsc110 = {
1039 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -03001040};
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001041
Matthias Schwarzott04574182009-02-24 12:35:16 -03001042/* ------------------------------------------------------------------ */
1043
1044static struct mt312_config avertv_a700_mt312 = {
1045 .demod_address = 0x0e,
1046 .voltage_inverted = 1,
1047};
1048
1049static struct zl10036_config avertv_a700_tuner = {
1050 .tuner_address = 0x60,
1051};
1052
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001053static struct mt312_config zl10313_compro_s350_config = {
1054 .demod_address = 0x0e,
1055};
1056
Michael Krufky3abdedd2009-01-19 01:10:49 -03001057static struct lgdt3305_config hcw_lgdt3305_config = {
1058 .i2c_addr = 0x0e,
1059 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1060 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1061 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1062 .deny_i2c_rptr = 1,
1063 .spectral_inversion = 1,
1064 .qam_if_khz = 4000,
1065 .vsb_if_khz = 3250,
1066};
1067
Michael Krufky1bc7f512009-01-19 01:10:49 -03001068static struct tda10048_config hcw_tda10048_config = {
1069 .demod_address = 0x10 >> 1,
1070 .output_mode = TDA10048_SERIAL_OUTPUT,
1071 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1072 .inversion = TDA10048_INVERSION_ON,
1073 .dtv6_if_freq_khz = TDA10048_IF_3300,
1074 .dtv7_if_freq_khz = TDA10048_IF_3500,
1075 .dtv8_if_freq_khz = TDA10048_IF_4000,
1076 .clk_freq_khz = TDA10048_CLK_16000,
1077 .disable_gate_access = 1,
1078};
1079
Michael Krufky3abdedd2009-01-19 01:10:49 -03001080static struct tda18271_std_map hauppauge_tda18271_std_map = {
1081 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1082 .if_lvl = 1, .rfagc_top = 0x58, },
1083 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1084 .if_lvl = 1, .rfagc_top = 0x58, },
1085};
1086
1087static struct tda18271_config hcw_tda18271_config = {
1088 .std_map = &hauppauge_tda18271_std_map,
1089 .gate = TDA18271_GATE_ANALOG,
1090 .config = 3,
Michael Krufky542cb052009-08-29 17:45:48 -03001091 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky3abdedd2009-01-19 01:10:49 -03001092};
1093
1094static struct tda829x_config tda829x_no_probe = {
1095 .probe_tuner = TDA829X_DONT_PROBE,
1096};
1097
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001098static struct tda10048_config zolid_tda10048_config = {
1099 .demod_address = 0x10 >> 1,
1100 .output_mode = TDA10048_PARALLEL_OUTPUT,
1101 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1102 .inversion = TDA10048_INVERSION_ON,
1103 .dtv6_if_freq_khz = TDA10048_IF_3300,
1104 .dtv7_if_freq_khz = TDA10048_IF_3500,
1105 .dtv8_if_freq_khz = TDA10048_IF_4000,
1106 .clk_freq_khz = TDA10048_CLK_16000,
1107 .disable_gate_access = 1,
1108};
1109
1110static struct tda18271_config zolid_tda18271_config = {
1111 .gate = TDA18271_GATE_ANALOG,
1112};
1113
Michael Krufky184e7692009-06-05 04:28:28 -03001114static struct tda10048_config dtv1000s_tda10048_config = {
1115 .demod_address = 0x10 >> 1,
1116 .output_mode = TDA10048_PARALLEL_OUTPUT,
1117 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1118 .inversion = TDA10048_INVERSION_ON,
1119 .dtv6_if_freq_khz = TDA10048_IF_3300,
1120 .dtv7_if_freq_khz = TDA10048_IF_3800,
1121 .dtv8_if_freq_khz = TDA10048_IF_4300,
1122 .clk_freq_khz = TDA10048_CLK_16000,
1123 .disable_gate_access = 1,
1124};
1125
1126static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1127 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1128 .if_lvl = 1, .rfagc_top = 0x37, },
1129 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1130 .if_lvl = 1, .rfagc_top = 0x37, },
1131 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1132 .if_lvl = 1, .rfagc_top = 0x37, },
1133};
1134
1135static struct tda18271_config dtv1000s_tda18271_config = {
1136 .std_map = &dtv1000s_tda18271_std_map,
1137 .gate = TDA18271_GATE_ANALOG,
1138};
1139
Timothy Leece027042011-03-25 15:00:33 -03001140static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
1141 .prod = LGS8GXX_PROD_LGS8G75,
1142 .demod_address = 0x1d,
1143 .serial_ts = 0,
1144 .ts_clk_pol = 1,
1145 .ts_clk_gated = 0,
1146 .if_clk_freq = 30400, /* 30.4 MHz */
1147 .if_freq = 4000, /* 4.00 MHz */
1148 .if_neg_center = 0,
1149 .ext_adc = 0,
1150 .adc_signed = 1,
1151 .adc_vpp = 3, /* 2.0 Vpp */
1152 .if_neg_edge = 1,
1153};
1154
1155static struct tda18271_config prohdtv_pro2_tda18271_config = {
1156 .gate = TDA18271_GATE_ANALOG,
1157 .output_opt = TDA18271_OUTPUT_LT_OFF,
1158};
1159
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001160/* ==================================================================
1161 * Core code
1162 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001163
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164static int dvb_init(struct saa7134_dev *dev)
1165{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001166 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001167 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001168 struct videobuf_dvb_frontend *fe0;
1169
Darron Broadf972e0b2008-10-11 11:24:30 -03001170 /* FIXME: add support for multi-frontend */
1171 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001172 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -03001173
1174 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001175 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1176 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -03001177 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1178 return -ENOMEM;
1179 }
1180
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 /* init struct videobuf_dvb */
1182 dev->ts.nr_bufs = 32;
1183 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001184 fe0->dvb.name = dev->name;
1185 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001186 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1188 V4L2_FIELD_ALTERNATE,
1189 sizeof(struct saa7134_buf),
Hans Verkuil08bff032010-09-20 17:39:46 -03001190 dev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191
1192 switch (dev->board) {
1193 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001194 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001195 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001196 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001197 if (fe0->dvb.frontend) {
1198 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001199 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001201 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001202 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001203 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001204 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001205 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001206 if (fe0->dvb.frontend) {
1207 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001208 &dev->i2c_adap, 0x61,
1209 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001210 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001211 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001212 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001213 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001214 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001215 &avermedia_xc3028_mt352_dev,
1216 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001217 attach_xc3028 = 1;
1218 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001220 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001221 &medion_cardbus,
1222 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001223 if (fe0->dvb.frontend) {
1224 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001225 &dev->i2c_adap, medion_cardbus.tuner_address,
1226 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001227 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001229 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001230 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001231 &philips_tu1216_60_config,
1232 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001233 if (fe0->dvb.frontend) {
1234 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1235 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001236 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001237 break;
1238 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001239 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001240 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1241 &tda827x_cfg_0) < 0)
1242 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001243 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001244 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001245 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Danny Woode3c6e1a2009-09-20 12:14:21 -03001246 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001247 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001248 &philips_europa_config,
1249 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001250 if (fe0->dvb.frontend) {
1251 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1252 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1253 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1254 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1255 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001256 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001257 break;
Vadim Catana128fe952010-05-29 12:49:16 -03001258 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1259 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1260 &technotrend_budget_t3000_config,
1261 &dev->i2c_adap);
1262 if (fe0->dvb.frontend) {
1263 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1264 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1265 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1266 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1267 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1268 }
1269 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001270 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001271 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001272 &philips_tu1216_61_config,
1273 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001274 if (fe0->dvb.frontend) {
1275 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1276 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001277 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001278 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001279 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001280 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1281 &tda827x_cfg_2) < 0)
1282 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001283 break;
Michael Krufky0e316ec2009-08-03 16:51:33 -03001284 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
Michael Krufky1bc7f512009-01-19 01:10:49 -03001285 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1286 &hcw_tda10048_config,
1287 &dev->i2c_adap);
1288 if (fe0->dvb.frontend != NULL) {
1289 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1290 &dev->i2c_adap, 0x4b,
1291 &tda829x_no_probe);
1292 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1293 0x60, &dev->i2c_adap,
1294 &hcw_tda18271_config);
1295 }
1296 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001297 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001298 if (configure_tda827x_fe(dev, &philips_tiger_config,
1299 &tda827x_cfg_0) < 0)
1300 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001301 break;
1302 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001303 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1304 &tda827x_cfg_1) < 0)
1305 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001306 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001307 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001308 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1309 &tda827x_cfg_1) < 0)
1310 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001311 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001312 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001313 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1314 &hcw_lgdt3305_config,
1315 &dev->i2c_adap);
1316 if (fe0->dvb.frontend) {
1317 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1318 &dev->i2c_adap, 0x4b,
1319 &tda829x_no_probe);
1320 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1321 0x60, &dev->i2c_adap,
1322 &hcw_tda18271_config);
1323 }
1324 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001325 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001326 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1327 &tda827x_cfg_0) < 0)
1328 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001329 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001330 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001331 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1332 &tda827x_cfg_0) < 0)
1333 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001334 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001335 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001336 if (!use_frontend) { /* terrestrial */
1337 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1338 &tda827x_cfg_0) < 0)
1339 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001340 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001341 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1342 if (fe0->dvb.frontend) {
1343 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001344 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001345 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001346 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001347 }
Steven Toth363c35f2008-10-11 11:05:50 -03001348 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001349 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001350 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001351 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001352 }
1353 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001354 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001355 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001356 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001357 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001358 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001359 &ads_tech_duo_config,
1360 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001361 if (fe0->dvb.frontend) {
1362 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001363 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1364 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001365 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001366 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001367 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001368 }
Mauro Carvalho Chehabbc36ec7462008-06-14 10:44:04 -03001369 } else
1370 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001371 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001372 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001373 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1374 &tda827x_cfg_0) < 0)
1375 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001376 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001377 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001378 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001379 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1380 &tda827x_cfg_0) < 0)
1381 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001382 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001383 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001384 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001385 if (fe0->dvb.frontend) {
1386 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001387 u8 dev_id = dev->eedata[2];
1388 u8 data = 0xc4;
1389 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1390
Steven Toth363c35f2008-10-11 11:05:50 -03001391 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001392 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001393 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001394 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001395 goto dettach_frontend;
1396 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001397 if (dev_id != 0x08) {
1398 /* we need to open the i2c gate (we know it exists) */
1399 fe->ops.i2c_gate_ctrl(fe, 1);
1400 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001401 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001402 wprintk("%s: Medion Quadro, no ISL6405 "
1403 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001404 goto dettach_frontend;
1405 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001406 if (dev_id == 0x07) {
1407 /* fire up the 2nd section of the LNB supply since
1408 we can't do this from the other section */
1409 msg.buf = &data;
1410 i2c_transfer(&dev->i2c_adap, &msg, 1);
1411 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001412 fe->ops.i2c_gate_ctrl(fe, 0);
1413 dev->original_set_voltage = fe->ops.set_voltage;
1414 fe->ops.set_voltage = md8800_set_voltage;
1415 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1416 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1417 } else {
1418 fe->ops.set_voltage = md8800_set_voltage2;
1419 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1420 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001421 }
1422 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001423 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001424 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001425 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001426 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001427 if (fe0->dvb.frontend)
1428 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001429 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001430 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001431 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001432 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001433 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001434 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001435 if (fe0->dvb.frontend)
1436 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001437 &dev->i2c_adap, 0x61,
1438 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001439 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001440 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001441 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001442 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001443 if (fe0->dvb.frontend) {
1444 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001445 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001446 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001447 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001448 }
Steven Toth363c35f2008-10-11 11:05:50 -03001449 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001450 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001451 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001452 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001453 }
1454 }
1455 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001456 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001457 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001458 &medion_cardbus,
1459 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001460 if (fe0->dvb.frontend) {
1461 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1462 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001463
Steven Toth363c35f2008-10-11 11:05:50 -03001464 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001465 &dev->i2c_adap, medion_cardbus.tuner_address,
1466 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001467 }
1468 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001469 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001470 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001471 &philips_europa_config,
1472 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001473 if (fe0->dvb.frontend) {
1474 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1475 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001476 }
1477 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001478 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001479 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1480 &tda827x_cfg_0) < 0)
1481 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001482 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001483 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001484 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1485 &tda827x_cfg_0) < 0)
1486 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001487 break;
1488 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001489 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1490 &tda827x_cfg_2) < 0)
1491 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001492 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001493 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001494 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1495 &tda827x_cfg_2) < 0)
1496 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001497 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001498 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001499 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1500 &tda827x_cfg_2) < 0)
1501 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001502 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001503 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001504 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1505 &tda827x_cfg_0) < 0)
1506 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001507 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001508 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001509 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1510 &tda827x_cfg_2_sw42) < 0)
1511 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001512 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001513 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001514 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001515 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001516 if (fe0->dvb.frontend) {
1517 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001518 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001519 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001520 goto dettach_frontend;
1521 }
Steven Toth363c35f2008-10-11 11:05:50 -03001522 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001523 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001524 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001525 goto dettach_frontend;
1526 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001527 }
1528 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001529 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001530 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1531 &tda827x_cfg_0) < 0)
1532 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001533 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001534 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001535 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1536 &tda827x_cfg_2) < 0)
1537 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001538 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001539 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001540 dprintk("AverMedia E506R dvb setup\n");
1541 saa7134_set_gpio(dev, 25, 0);
1542 msleep(10);
1543 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001544 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001545 &avermedia_xc3028_mt352_dev,
1546 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001547 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001548 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001549 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001550 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001551 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001552 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001553 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001554 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001555 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001556 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001557 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001558 goto dettach_frontend;
1559 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001560 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001561 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001562 fe->ops.i2c_gate_ctrl(fe, 1);
1563 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001564 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001565 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001566 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001567 goto dettach_frontend;
1568 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001569 fe->ops.i2c_gate_ctrl(fe, 0);
1570 dev->original_set_voltage = fe->ops.set_voltage;
1571 fe->ops.set_voltage = md8800_set_voltage;
1572 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1573 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1574 }
1575 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001576 case SAA7134_BOARD_AVERMEDIA_M103:
1577 saa7134_set_gpio(dev, 25, 0);
1578 msleep(10);
1579 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001580 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001581 &avermedia_xc3028_mt352_dev,
1582 &dev->i2c_adap);
1583 attach_xc3028 = 1;
1584 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001585 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1586 if (!use_frontend) { /* terrestrial */
1587 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1588 &tda827x_cfg_2) < 0)
1589 goto dettach_frontend;
1590 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001591 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001592 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001593 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001594 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001595 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001596 &dev->i2c_adap, 0) == NULL) {
1597 wprintk("%s: Asus Tiger 3in1, no "
1598 "tda826x found!\n", __func__);
1599 goto dettach_frontend;
1600 }
Steven Toth363c35f2008-10-11 11:05:50 -03001601 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001602 &dev->i2c_adap, 0, 0) == NULL) {
1603 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1604 " found!\n", __func__);
1605 goto dettach_frontend;
1606 }
1607 }
1608 }
1609 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001610 case SAA7134_BOARD_ASUSTeK_TIGER:
1611 if (configure_tda827x_fe(dev, &philips_tiger_config,
1612 &tda827x_cfg_0) < 0)
1613 goto dettach_frontend;
1614 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001615 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001616 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001617 &behold_h6_config,
1618 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001619 if (fe0->dvb.frontend) {
1620 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001621 &dev->i2c_adap, 0x61,
Beholder Intl. Ltd. Dmitry Belimov4786dd62009-08-04 20:07:42 -03001622 TUNER_PHILIPS_FMD1216MEX_MK3);
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001623 }
1624 break;
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -03001625 case SAA7134_BOARD_BEHOLD_X7:
1626 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1627 &behold_x7_config,
1628 &dev->i2c_adap);
1629 if (fe0->dvb.frontend) {
1630 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1631 &dev->i2c_adap, &behold_x7_tunerconfig);
1632 }
1633 break;
Dmitri Belimov0faa2ed2010-04-06 01:00:05 -03001634 case SAA7134_BOARD_BEHOLD_H7:
1635 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1636 &behold_x7_config,
1637 &dev->i2c_adap);
1638 if (fe0->dvb.frontend) {
1639 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1640 &dev->i2c_adap, &behold_x7_tunerconfig);
1641 }
1642 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001643 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1644 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1645 /* Zarlink ZL10313 */
1646 fe0->dvb.frontend = dvb_attach(mt312_attach,
1647 &avertv_a700_mt312, &dev->i2c_adap);
1648 if (fe0->dvb.frontend) {
1649 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1650 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1651 wprintk("%s: No zl10036 found!\n",
1652 __func__);
1653 }
1654 }
1655 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001656 case SAA7134_BOARD_VIDEOMATE_S350:
1657 fe0->dvb.frontend = dvb_attach(mt312_attach,
1658 &zl10313_compro_s350_config, &dev->i2c_adap);
1659 if (fe0->dvb.frontend)
1660 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1661 0x60, &dev->i2c_adap) == NULL)
1662 wprintk("%s: No zl10039 found!\n",
1663 __func__);
1664
1665 break;
Carlos Corbachodbe87402011-06-25 10:24:28 -03001666 case SAA7134_BOARD_VIDEOMATE_T750:
1667 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1668 &videomate_t750_zl10353_config,
1669 &dev->i2c_adap);
1670 if (fe0->dvb.frontend != NULL) {
1671 if (dvb_attach(qt1010_attach,
1672 fe0->dvb.frontend,
1673 &dev->i2c_adap,
1674 &videomate_t750_qt1010_config) == NULL)
1675 wprintk("error attaching QT1010\n");
1676 }
1677 break;
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001678 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1679 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1680 &zolid_tda10048_config,
1681 &dev->i2c_adap);
1682 if (fe0->dvb.frontend != NULL) {
1683 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1684 &dev->i2c_adap, 0x4b,
1685 &tda829x_no_probe);
1686 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1687 0x60, &dev->i2c_adap,
1688 &zolid_tda18271_config);
1689 }
1690 break;
Michael Krufky184e7692009-06-05 04:28:28 -03001691 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1692 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1693 &dtv1000s_tda10048_config,
1694 &dev->i2c_adap);
1695 if (fe0->dvb.frontend != NULL) {
1696 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1697 &dev->i2c_adap, 0x4b,
1698 &tda829x_no_probe);
1699 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1700 0x60, &dev->i2c_adap,
1701 &dtv1000s_tda18271_config);
1702 }
1703 break;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001704 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
Mauro Carvalho Chehabecb71d22011-01-14 12:03:03 -03001705 /* Switch to digital mode */
1706 saa7134_tuner_callback(dev, 0,
1707 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001708 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1709 &kworld_mb86a20s_config,
1710 &dev->i2c_adap);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001711 if (fe0->dvb.frontend != NULL) {
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001712 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1713 &dev->i2c_adap, 0x4b,
1714 &tda829x_no_probe);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001715 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1716 0x60, &dev->i2c_adap,
1717 &kworld_tda18271_config);
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001718 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001719 }
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001720
1721 /* mb86a20s need to use the I2C gateway */
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001722 break;
Timothy Leece027042011-03-25 15:00:33 -03001723 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
1724 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1725 &prohdtv_pro2_lgs8g75_config,
1726 &dev->i2c_adap);
1727 if (fe0->dvb.frontend != NULL) {
1728 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1729 &dev->i2c_adap, 0x4b,
1730 &tda829x_no_probe);
1731 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1732 0x60, &dev->i2c_adap,
1733 &prohdtv_pro2_tda18271_config);
1734 }
1735 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001737 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 break;
1739 }
1740
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001741 if (attach_xc3028) {
1742 struct dvb_frontend *fe;
1743 struct xc2028_config cfg = {
1744 .i2c_adap = &dev->i2c_adap,
1745 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001746 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001747
Steven Toth363c35f2008-10-11 11:05:50 -03001748 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001749 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001750
Steven Toth363c35f2008-10-11 11:05:50 -03001751 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001752 if (!fe) {
1753 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1754 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001755 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001756 }
1757 }
1758
Steven Toth363c35f2008-10-11 11:05:50 -03001759 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001760 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001761 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001763 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001764 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765
1766 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001767 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001768 &dev->pci->dev, adapter_nr, 0, NULL);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001769
1770 /* this sequence is necessary to make the tda1004x load its firmware
1771 * and to enter analog mode of hybrid boards
1772 */
1773 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001774 if (fe0->dvb.frontend->ops.init)
1775 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1776 if (fe0->dvb.frontend->ops.sleep)
1777 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1778 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1779 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001780 }
1781 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001782
1783dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001784 videobuf_dvb_dealloc_frontends(&dev->frontends);
1785 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001786}
1787
1788static int dvb_fini(struct saa7134_dev *dev)
1789{
Steven Toth363c35f2008-10-11 11:05:50 -03001790 struct videobuf_dvb_frontend *fe0;
1791
1792 /* Get the first frontend */
1793 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1794 if (!fe0)
1795 return -EINVAL;
1796
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001797 /* FIXME: I suspect that this code is bogus, since the entry for
1798 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1799 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1800 */
1801 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1802 struct v4l2_priv_tun_config tda9887_cfg;
1803 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001804
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001805 tda9887_cfg.tuner = TUNER_TDA9887;
1806 tda9887_cfg.priv = &on;
1807
Linus Torvalds1da177e2005-04-16 15:20:36 -07001808 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001809 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001810 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001811 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001812 /* turn off the 2nd lnb supply */
1813 u8 data = 0x80;
1814 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1815 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001816 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001817 if (fe->ops.i2c_gate_ctrl) {
1818 fe->ops.i2c_gate_ctrl(fe, 1);
1819 i2c_transfer(&dev->i2c_adap, &msg, 1);
1820 fe->ops.i2c_gate_ctrl(fe, 0);
1821 }
1822 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001823 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001824 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825 return 0;
1826}
1827
1828static struct saa7134_mpeg_ops dvb_ops = {
1829 .type = SAA7134_MPEG_DVB,
1830 .init = dvb_init,
1831 .fini = dvb_fini,
1832};
1833
1834static int __init dvb_register(void)
1835{
1836 return saa7134_ts_register(&dvb_ops);
1837}
1838
1839static void __exit dvb_unregister(void)
1840{
1841 saa7134_ts_unregister(&dvb_ops);
1842}
1843
1844module_init(dvb_register);
1845module_exit(dvb_unregister);
1846
1847/* ------------------------------------------------------------------ */
1848/*
1849 * Local variables:
1850 * c-basic-offset: 8
1851 * End:
1852 */