blob: d2a12df28af099d3cf5a093eed94243a92ef78c0 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
4 *
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07005 * Extended 3 / 2005 by Hartmut Hackmann to support various
6 * cards with the tda10046 DVB-T channel decoder
7 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <linux/init.h>
24#include <linux/list.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/delay.h>
28#include <linux/kthread.h>
29#include <linux/suspend.h>
30
31#include "saa7134-reg.h"
32#include "saa7134.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020033#include <media/v4l2-common.h>
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -020034#include "dvb-pll.h"
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -030035#include <dvb_frontend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030037#include "mt352.h"
38#include "mt352_priv.h" /* FIXME */
39#include "tda1004x.h"
40#include "nxt200x.h"
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -030041#include "tuner-xc2028.h"
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -030042#include "xc5000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030044#include "tda10086.h"
45#include "tda826x.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030046#include "tda827x.h"
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030047#include "isl6421.h"
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -030048#include "isl6405.h"
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -030049#include "lnbp21.h"
Michael Krufkycb89cd32008-04-22 14:46:16 -030050#include "tuner-simple.h"
Michael Krufky1bc7f512009-01-19 01:10:49 -030051#include "tda10048.h"
Michael Krufky3abdedd2009-01-19 01:10:49 -030052#include "tda18271.h"
53#include "lgdt3305.h"
54#include "tda8290.h"
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -030055#include "mb86a20s.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030056
Dmitri Belimov47aeba52008-12-23 03:53:03 -030057#include "zl10353.h"
58
Matthias Schwarzott04574182009-02-24 12:35:16 -030059#include "zl10036.h"
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -030060#include "zl10039.h"
Matthias Schwarzott04574182009-02-24 12:35:16 -030061#include "mt312.h"
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
64MODULE_LICENSE("GPL");
65
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030066static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070067
Linus Torvalds1da177e2005-04-16 15:20:36 -070068module_param(antenna_pwr, int, 0444);
69MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
70
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030071static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030072module_param(use_frontend, int, 0644);
73MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030074
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030075static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030076module_param(debug, int, 0644);
77MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
78
Janne Grunau78e92002008-04-09 19:13:13 -030079DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
80
Trent Piephocf3c34c2007-03-07 18:19:48 -030081#define dprintk(fmt, arg...) do { if (debug) \
82 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
83
84/* Print a warning */
85#define wprintk(fmt, arg...) \
86 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030087
88/* ------------------------------------------------------------------
89 * mt352 based DVB-T cards
90 */
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
93{
94 u32 ok;
95
96 if (!on) {
97 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
98 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
99 return 0;
100 }
101
102 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
103 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
104 udelay(10);
105
106 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
107 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
108 udelay(10);
109 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
110 udelay(10);
111 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300112 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
114 if (!ok)
115 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
116 return ok;
117}
118
119static int mt352_pinnacle_init(struct dvb_frontend* fe)
120{
121 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
122 static u8 reset [] = { RESET, 0x80 };
123 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
124 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
125 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
126 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
127 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
128 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
129 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
130 struct saa7134_dev *dev= fe->dvb->priv;
131
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300132 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
134 mt352_write(fe, clock_config, sizeof(clock_config));
135 udelay(200);
136 mt352_write(fe, reset, sizeof(reset));
137 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
138 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
139 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
140 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
141
142 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
143 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
144 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 return 0;
147}
148
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200149static int mt352_aver777_init(struct dvb_frontend* fe)
150{
151 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
152 static u8 reset [] = { RESET, 0x80 };
153 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
154 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
155 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
156
157 mt352_write(fe, clock_config, sizeof(clock_config));
158 udelay(200);
159 mt352_write(fe, reset, sizeof(reset));
160 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
161 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
162 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
163
164 return 0;
165}
166
Tim Farrington6e501a32008-06-15 13:33:42 -0300167static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300168{
Tim Farrington6e501a32008-06-15 13:33:42 -0300169 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
170 static u8 reset [] = { RESET, 0x80 };
171 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
172 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300173 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
174
175 mt352_write(fe, clock_config, sizeof(clock_config));
176 udelay(200);
177 mt352_write(fe, reset, sizeof(reset));
178 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
179 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
180 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300181 return 0;
182}
183
Andrew de Quincey0463f122006-05-16 17:22:02 -0300184static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
185 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300187 u8 off[] = { 0x00, 0xf1};
188 u8 on[] = { 0x00, 0x71};
189 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 struct saa7134_dev *dev = fe->dvb->priv;
192 struct v4l2_frequency f;
193
194 /* set frequency (mt2050) */
195 f.tuner = 0;
196 f.type = V4L2_TUNER_DIGITAL_TV;
197 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300198 if (fe->ops.i2c_gate_ctrl)
199 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300200 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300201 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300202 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300203 if (fe->ops.i2c_gate_ctrl)
204 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300205 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207 pinnacle_antenna_pwr(dev, antenna_pwr);
208
209 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300210 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211}
212
213static struct mt352_config pinnacle_300i = {
214 .demod_address = 0x3c >> 1,
215 .adc_clock = 20333,
216 .if2 = 36150,
217 .no_tuner = 1,
218 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200220
221static struct mt352_config avermedia_777 = {
222 .demod_address = 0xf,
223 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200224};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
Tim Farrington6e501a32008-06-15 13:33:42 -0300226static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300227 .demod_address = (0x1e >> 1),
228 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300229 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300230};
231
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300232static struct tda18271_std_map mb86a20s_tda18271_std_map = {
233 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
234 .if_lvl = 7, .rfagc_top = 0x37, },
235};
236
237static struct tda18271_config kworld_tda18271_config = {
238 .std_map = &mb86a20s_tda18271_std_map,
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -0300239 .gate = TDA18271_GATE_DIGITAL,
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300240};
241
242static const struct mb86a20s_config kworld_mb86a20s_config = {
243 .demod_address = 0x10,
244};
245
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -0300246static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
247{
248 struct saa7134_dev *dev = fe->dvb->priv;
249
250 unsigned char initmsg[] = {0x45, 0x97};
251 unsigned char msg_enable[] = {0x45, 0xc1};
252 unsigned char msg_disable[] = {0x45, 0x81};
253 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
254
255 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
256 wprintk("could not access the I2C gate\n");
257 return -EIO;
258 }
259 if (enable)
260 msg.buf = msg_enable;
261 else
262 msg.buf = msg_disable;
263 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
264 wprintk("could not access the I2C gate\n");
265 return -EIO;
266 }
267 msleep(20);
268 return 0;
269}
270
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300271/* ==================================================================
272 * tda1004x based DVB-T cards, helper functions
273 */
274
275static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
276 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700277{
278 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300279 return request_firmware(fw, name, &dev->pci->dev);
280}
281
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300282/* ------------------------------------------------------------------
283 * these tuners are tu1216, td1316(a)
284 */
285
286static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
287{
288 struct saa7134_dev *dev = fe->dvb->priv;
289 struct tda1004x_state *state = fe->demodulator_priv;
290 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700291 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800292 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700293 sizeof(tuner_buf) };
294 int tuner_frequency = 0;
295 u8 band, cp, filter;
296
297 /* determine charge pump */
298 tuner_frequency = params->frequency + 36166000;
299 if (tuner_frequency < 87000000)
300 return -EINVAL;
301 else if (tuner_frequency < 130000000)
302 cp = 3;
303 else if (tuner_frequency < 160000000)
304 cp = 5;
305 else if (tuner_frequency < 200000000)
306 cp = 6;
307 else if (tuner_frequency < 290000000)
308 cp = 3;
309 else if (tuner_frequency < 420000000)
310 cp = 5;
311 else if (tuner_frequency < 480000000)
312 cp = 6;
313 else if (tuner_frequency < 620000000)
314 cp = 3;
315 else if (tuner_frequency < 830000000)
316 cp = 5;
317 else if (tuner_frequency < 895000000)
318 cp = 7;
319 else
320 return -EINVAL;
321
322 /* determine band */
323 if (params->frequency < 49000000)
324 return -EINVAL;
325 else if (params->frequency < 161000000)
326 band = 1;
327 else if (params->frequency < 444000000)
328 band = 2;
329 else if (params->frequency < 861000000)
330 band = 4;
331 else
332 return -EINVAL;
333
334 /* setup PLL filter */
335 switch (params->u.ofdm.bandwidth) {
336 case BANDWIDTH_6_MHZ:
337 filter = 0;
338 break;
339
340 case BANDWIDTH_7_MHZ:
341 filter = 0;
342 break;
343
344 case BANDWIDTH_8_MHZ:
345 filter = 1;
346 break;
347
348 default:
349 return -EINVAL;
350 }
351
352 /* calculate divisor
353 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
354 */
355 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
356
357 /* setup tuner buffer */
358 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
359 tuner_buf[1] = tuner_frequency & 0xff;
360 tuner_buf[2] = 0xca;
361 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
362
Patrick Boettcherdea74862006-05-14 05:01:31 -0300363 if (fe->ops.i2c_gate_ctrl)
364 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300365 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300366 wprintk("could not write to tuner at addr: 0x%02x\n",
367 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700368 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300369 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700370 msleep(1);
371 return 0;
372}
373
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300374static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800375{
376 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300377 struct tda1004x_state *state = fe->demodulator_priv;
378 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800379 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
380 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
381
382 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300383 if (fe->ops.i2c_gate_ctrl)
384 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800385 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
386 return -EIO;
387 msleep(1);
388
389 return 0;
390}
391
392/* ------------------------------------------------------------------ */
393
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800394static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700395 .demod_address = 0x8,
396 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800397 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700398 .xtal_freq = TDA10046_XTAL_4M,
399 .agc_config = TDA10046_AGC_DEFAULT,
400 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300401 .tuner_address = 0x60,
402 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403};
404
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800405static struct tda1004x_config philips_tu1216_61_config = {
406
407 .demod_address = 0x8,
408 .invert = 1,
409 .invert_oclk = 0,
410 .xtal_freq = TDA10046_XTAL_4M,
411 .agc_config = TDA10046_AGC_DEFAULT,
412 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300413 .tuner_address = 0x61,
414 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800415};
416
417/* ------------------------------------------------------------------ */
418
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300419static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800420{
421 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300422 struct tda1004x_state *state = fe->demodulator_priv;
423 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800424 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300425 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800426
427 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300428 if (fe->ops.i2c_gate_ctrl)
429 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800430 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
431 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800432 return 0;
433}
434
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300435static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800436{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300437 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800438}
439
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300440static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
441{
442 struct saa7134_dev *dev = fe->dvb->priv;
443 struct tda1004x_state *state = fe->demodulator_priv;
444 u8 addr = state->config->tuner_address;
445 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
446 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
447
448 /* switch the tuner to analog mode */
449 if (fe->ops.i2c_gate_ctrl)
450 fe->ops.i2c_gate_ctrl(fe, 1);
451 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
452 return -EIO;
453 return 0;
454}
455
456/* ------------------------------------------------------------------ */
457
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300458static int philips_europa_tuner_init(struct dvb_frontend *fe)
459{
460 struct saa7134_dev *dev = fe->dvb->priv;
461 static u8 msg[] = { 0x00, 0x40};
462 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
463
464
465 if (philips_td1316_tuner_init(fe))
466 return -EIO;
467 msleep(1);
468 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
469 return -EIO;
470
471 return 0;
472}
473
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300474static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800475{
476 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800477
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300478 static u8 msg[] = { 0x00, 0x14 };
479 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
480
481 if (philips_td1316_tuner_sleep(fe))
482 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800483
484 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300485 if (fe->ops.i2c_gate_ctrl)
486 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800487 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300488 return 0;
489}
490
491static int philips_europa_demod_sleep(struct dvb_frontend *fe)
492{
493 struct saa7134_dev *dev = fe->dvb->priv;
494
495 if (dev->original_demod_sleep)
496 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300497 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300498 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800499}
500
501static struct tda1004x_config philips_europa_config = {
502
503 .demod_address = 0x8,
504 .invert = 0,
505 .invert_oclk = 0,
506 .xtal_freq = TDA10046_XTAL_4M,
507 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
508 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300509 .tuner_address = 0x61,
510 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800511};
512
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700513static struct tda1004x_config medion_cardbus = {
514 .demod_address = 0x08,
515 .invert = 1,
516 .invert_oclk = 0,
517 .xtal_freq = TDA10046_XTAL_16M,
518 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
519 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300520 .tuner_address = 0x61,
521 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700522};
523
Vadim Catana128fe952010-05-29 12:49:16 -0300524static struct tda1004x_config technotrend_budget_t3000_config = {
525 .demod_address = 0x8,
526 .invert = 1,
527 .invert_oclk = 0,
528 .xtal_freq = TDA10046_XTAL_4M,
529 .agc_config = TDA10046_AGC_DEFAULT,
530 .if_freq = TDA10046_FREQ_3617,
531 .tuner_address = 0x63,
532 .request_firmware = philips_tda1004x_request_firmware
533};
534
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300535/* ------------------------------------------------------------------
536 * tda 1004x based cards with philips silicon tuner
537 */
538
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300539static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
540{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300541 struct tda1004x_state *state = fe->demodulator_priv;
542
543 u8 addr = state->config->i2c_gate;
544 static u8 tda8290_close[] = { 0x21, 0xc0};
545 static u8 tda8290_open[] = { 0x21, 0x80};
546 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
547 if (enable) {
548 tda8290_msg.buf = tda8290_close;
549 } else {
550 tda8290_msg.buf = tda8290_open;
551 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300552 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300553 struct saa7134_dev *dev = fe->dvb->priv;
554 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300555 return -EIO;
556 }
557 msleep(20);
558 return 0;
559}
560
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300561static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300562{
563 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300564 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300565
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300566 switch (state->config->antenna_switch) {
567 case 0: break;
568 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
569 saa7134_set_gpio(dev, 21, 0);
570 break;
571 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
572 saa7134_set_gpio(dev, 21, 1);
573 break;
574 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300575 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800576}
577
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300578static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
579{
580 struct saa7134_dev *dev = fe->dvb->priv;
581 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300582
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300583 switch (state->config->antenna_switch) {
584 case 0: break;
585 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
586 saa7134_set_gpio(dev, 21, 1);
587 break;
588 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
589 saa7134_set_gpio(dev, 21, 0);
590 break;
591 }
592 return 0;
593}
594
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300595static int configure_tda827x_fe(struct saa7134_dev *dev,
596 struct tda1004x_config *cdec_conf,
597 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300598{
Steven Toth363c35f2008-10-11 11:05:50 -0300599 struct videobuf_dvb_frontend *fe0;
600
Darron Broad92abe9e2008-10-11 11:18:53 -0300601 /* Get the first frontend */
602 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300603
604 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
605 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300606 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300607 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
608 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300609 cdec_conf->tuner_address,
610 &dev->i2c_adap, tuner_conf))
611 return 0;
612
613 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300614 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300615 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300616 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300617}
618
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800619/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300620
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300621static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300622 .init = philips_tda827x_tuner_init,
623 .sleep = philips_tda827x_tuner_sleep,
624 .config = 0,
625 .switch_addr = 0
626};
627
628static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300629 .init = philips_tda827x_tuner_init,
630 .sleep = philips_tda827x_tuner_sleep,
631 .config = 1,
632 .switch_addr = 0x4b
633};
634
635static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300636 .init = philips_tda827x_tuner_init,
637 .sleep = philips_tda827x_tuner_sleep,
638 .config = 2,
639 .switch_addr = 0x4b
640};
641
642static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300643 .init = philips_tda827x_tuner_init,
644 .sleep = philips_tda827x_tuner_sleep,
645 .config = 2,
646 .switch_addr = 0x42
647};
648
649/* ------------------------------------------------------------------ */
650
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300651static struct tda1004x_config tda827x_lifeview_config = {
652 .demod_address = 0x08,
653 .invert = 1,
654 .invert_oclk = 0,
655 .xtal_freq = TDA10046_XTAL_16M,
656 .agc_config = TDA10046_AGC_TDA827X,
657 .gpio_config = TDA10046_GP11_I,
658 .if_freq = TDA10046_FREQ_045,
659 .tuner_address = 0x60,
660 .request_firmware = philips_tda1004x_request_firmware
661};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800662
663static struct tda1004x_config philips_tiger_config = {
664 .demod_address = 0x08,
665 .invert = 1,
666 .invert_oclk = 0,
667 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300668 .agc_config = TDA10046_AGC_TDA827X,
669 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300670 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300671 .i2c_gate = 0x4b,
672 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300673 .antenna_switch= 1,
674 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300675};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300676
677static struct tda1004x_config cinergy_ht_config = {
678 .demod_address = 0x08,
679 .invert = 1,
680 .invert_oclk = 0,
681 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300682 .agc_config = TDA10046_AGC_TDA827X,
683 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800684 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300685 .i2c_gate = 0x4b,
686 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300687 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800688};
689
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300690static struct tda1004x_config cinergy_ht_pci_config = {
691 .demod_address = 0x08,
692 .invert = 1,
693 .invert_oclk = 0,
694 .xtal_freq = TDA10046_XTAL_16M,
695 .agc_config = TDA10046_AGC_TDA827X,
696 .gpio_config = TDA10046_GP01_I,
697 .if_freq = TDA10046_FREQ_045,
698 .i2c_gate = 0x4b,
699 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300700 .request_firmware = philips_tda1004x_request_firmware
701};
702
703static struct tda1004x_config philips_tiger_s_config = {
704 .demod_address = 0x08,
705 .invert = 1,
706 .invert_oclk = 0,
707 .xtal_freq = TDA10046_XTAL_16M,
708 .agc_config = TDA10046_AGC_TDA827X,
709 .gpio_config = TDA10046_GP01_I,
710 .if_freq = TDA10046_FREQ_045,
711 .i2c_gate = 0x4b,
712 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300713 .antenna_switch= 1,
714 .request_firmware = philips_tda1004x_request_firmware
715};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200716
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300717static struct tda1004x_config pinnacle_pctv_310i_config = {
718 .demod_address = 0x08,
719 .invert = 1,
720 .invert_oclk = 0,
721 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300722 .agc_config = TDA10046_AGC_TDA827X,
723 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300724 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300725 .i2c_gate = 0x4b,
726 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300727 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300728};
729
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300730static struct tda1004x_config hauppauge_hvr_1110_config = {
731 .demod_address = 0x08,
732 .invert = 1,
733 .invert_oclk = 0,
734 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300735 .agc_config = TDA10046_AGC_TDA827X,
736 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300737 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300738 .i2c_gate = 0x4b,
739 .tuner_address = 0x61,
740 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300741};
742
Hartmut Hackmann83646812006-10-12 20:38:51 -0300743static struct tda1004x_config asus_p7131_dual_config = {
744 .demod_address = 0x08,
745 .invert = 1,
746 .invert_oclk = 0,
747 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300748 .agc_config = TDA10046_AGC_TDA827X,
749 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300750 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300751 .i2c_gate = 0x4b,
752 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300753 .antenna_switch= 2,
754 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300755};
756
Nico Sabbi420f32f2006-03-03 12:11:28 -0300757static struct tda1004x_config lifeview_trio_config = {
758 .demod_address = 0x09,
759 .invert = 1,
760 .invert_oclk = 0,
761 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300762 .agc_config = TDA10046_AGC_TDA827X,
763 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300764 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300765 .tuner_address = 0x60,
766 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300767};
768
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300769static struct tda1004x_config tevion_dvbt220rf_config = {
770 .demod_address = 0x08,
771 .invert = 1,
772 .invert_oclk = 0,
773 .xtal_freq = TDA10046_XTAL_16M,
774 .agc_config = TDA10046_AGC_TDA827X,
775 .gpio_config = TDA10046_GP11_I,
776 .if_freq = TDA10046_FREQ_045,
777 .tuner_address = 0x60,
778 .request_firmware = philips_tda1004x_request_firmware
779};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300780
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300781static struct tda1004x_config md8800_dvbt_config = {
782 .demod_address = 0x08,
783 .invert = 1,
784 .invert_oclk = 0,
785 .xtal_freq = TDA10046_XTAL_16M,
786 .agc_config = TDA10046_AGC_TDA827X,
787 .gpio_config = TDA10046_GP01_I,
788 .if_freq = TDA10046_FREQ_045,
789 .i2c_gate = 0x4b,
790 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300791 .request_firmware = philips_tda1004x_request_firmware
792};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200793
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300794static struct tda1004x_config asus_p7131_4871_config = {
795 .demod_address = 0x08,
796 .invert = 1,
797 .invert_oclk = 0,
798 .xtal_freq = TDA10046_XTAL_16M,
799 .agc_config = TDA10046_AGC_TDA827X,
800 .gpio_config = TDA10046_GP01_I,
801 .if_freq = TDA10046_FREQ_045,
802 .i2c_gate = 0x4b,
803 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300804 .antenna_switch= 2,
805 .request_firmware = philips_tda1004x_request_firmware
806};
807
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300808static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300809 .demod_address = 0x08,
810 .invert = 1,
811 .invert_oclk = 0,
812 .xtal_freq = TDA10046_XTAL_16M,
813 .agc_config = TDA10046_AGC_TDA827X,
814 .gpio_config = TDA10046_GP11_I,
815 .if_freq = TDA10046_FREQ_045,
816 .i2c_gate = 0x4b,
817 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300818 .antenna_switch= 2,
819 .request_firmware = philips_tda1004x_request_firmware
820};
Edgar Simo261f5082007-08-20 14:06:00 -0300821
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300822static struct tda1004x_config kworld_dvb_t_210_config = {
823 .demod_address = 0x08,
824 .invert = 1,
825 .invert_oclk = 0,
826 .xtal_freq = TDA10046_XTAL_16M,
827 .agc_config = TDA10046_AGC_TDA827X,
828 .gpio_config = TDA10046_GP11_I,
829 .if_freq = TDA10046_FREQ_045,
830 .i2c_gate = 0x4b,
831 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300832 .antenna_switch= 1,
833 .request_firmware = philips_tda1004x_request_firmware
834};
Edgar Simo261f5082007-08-20 14:06:00 -0300835
Edgar Simod90d9f52007-08-20 14:14:50 -0300836static struct tda1004x_config avermedia_super_007_config = {
837 .demod_address = 0x08,
838 .invert = 1,
839 .invert_oclk = 0,
840 .xtal_freq = TDA10046_XTAL_16M,
841 .agc_config = TDA10046_AGC_TDA827X,
842 .gpio_config = TDA10046_GP01_I,
843 .if_freq = TDA10046_FREQ_045,
844 .i2c_gate = 0x4b,
845 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300846 .antenna_switch= 1,
847 .request_firmware = philips_tda1004x_request_firmware
848};
849
Hermann Pitton4ba24372008-01-20 19:27:51 -0300850static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
851 .demod_address = 0x08,
852 .invert = 1,
853 .invert_oclk = 0,
854 .xtal_freq = TDA10046_XTAL_16M,
855 .agc_config = TDA10046_AGC_TDA827X,
856 .gpio_config = TDA10046_GP01_I,
857 .if_freq = TDA10046_FREQ_045,
858 .i2c_gate = 0x42,
859 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300860 .antenna_switch = 1,
861 .request_firmware = philips_tda1004x_request_firmware
862};
863
hermann pitton301e9d62008-09-14 17:49:14 -0300864static struct tda1004x_config asus_tiger_3in1_config = {
865 .demod_address = 0x0b,
866 .invert = 1,
867 .invert_oclk = 0,
868 .xtal_freq = TDA10046_XTAL_16M,
869 .agc_config = TDA10046_AGC_TDA827X,
870 .gpio_config = TDA10046_GP11_I,
871 .if_freq = TDA10046_FREQ_045,
872 .i2c_gate = 0x4b,
873 .tuner_address = 0x61,
874 .antenna_switch = 1,
875 .request_firmware = philips_tda1004x_request_firmware
876};
877
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300878/* ------------------------------------------------------------------
879 * special case: this card uses saa713x GPIO22 for the mode switch
880 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200881
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300882static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200883{
884 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300885 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200886 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300887 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200888 return 0;
889}
890
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300891static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200892{
893 struct saa7134_dev *dev = fe->dvb->priv;
894 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300895 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300896 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300897 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200898}
899
Michael Krufky8ce47da2007-04-27 12:31:14 -0300900static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300901 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300902 .sleep = ads_duo_tuner_sleep,
903 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300904};
905
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200906static struct tda1004x_config ads_tech_duo_config = {
907 .demod_address = 0x08,
908 .invert = 1,
909 .invert_oclk = 0,
910 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300911 .agc_config = TDA10046_AGC_TDA827X,
912 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200913 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300914 .tuner_address = 0x61,
915 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200916};
917
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300918static struct zl10353_config behold_h6_config = {
919 .demod_address = 0x1e>>1,
920 .no_tuner = 1,
921 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300922 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300923};
924
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300925static struct xc5000_config behold_x7_tunerconfig = {
926 .i2c_address = 0xc2>>1,
927 .if_khz = 4560,
Devin Heitmueller2a0d0562009-09-30 23:04:39 -0300928 .radio_input = XC5000_RADIO_FM1,
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300929};
930
931static struct zl10353_config behold_x7_config = {
932 .demod_address = 0x1e>>1,
933 .if2 = 45600,
934 .no_tuner = 1,
935 .parallel_ts = 1,
936 .disable_i2c_gate_ctrl = 1,
937};
938
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300939/* ==================================================================
940 * tda10086 based DVB-S cards, helper functions
941 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300942
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300943static struct tda10086_config flydvbs = {
944 .demod_address = 0x0e,
945 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300946 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300947 .xtal_freq = TDA10086_XTAL_16M,
948};
949
950static struct tda10086_config sd1878_4m = {
951 .demod_address = 0x0e,
952 .invert = 0,
953 .diseqc_tone = 0,
954 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300955};
956
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300957/* ------------------------------------------------------------------
958 * special case: lnb supply is connected to the gated i2c
959 */
960
961static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
962{
963 int res = -EIO;
964 struct saa7134_dev *dev = fe->dvb->priv;
965 if (fe->ops.i2c_gate_ctrl) {
966 fe->ops.i2c_gate_ctrl(fe, 1);
967 if (dev->original_set_voltage)
968 res = dev->original_set_voltage(fe, voltage);
969 fe->ops.i2c_gate_ctrl(fe, 0);
970 }
971 return res;
972};
973
974static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
975{
976 int res = -EIO;
977 struct saa7134_dev *dev = fe->dvb->priv;
978 if (fe->ops.i2c_gate_ctrl) {
979 fe->ops.i2c_gate_ctrl(fe, 1);
980 if (dev->original_set_high_voltage)
981 res = dev->original_set_high_voltage(fe, arg);
982 fe->ops.i2c_gate_ctrl(fe, 0);
983 }
984 return res;
985};
986
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300987static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
988{
989 struct saa7134_dev *dev = fe->dvb->priv;
990 u8 wbuf[2] = { 0x1f, 00 };
991 u8 rbuf;
992 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
993 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
994
995 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
996 return -EIO;
997 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
998 if (voltage == SEC_VOLTAGE_18)
999 wbuf[1] = rbuf | 0x10;
1000 else
1001 wbuf[1] = rbuf & 0xef;
1002 msg[0].len = 2;
1003 i2c_transfer(&dev->i2c_adap, msg, 1);
1004 return 0;
1005}
1006
1007static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1008{
1009 struct saa7134_dev *dev = fe->dvb->priv;
1010 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
1011 return -EIO;
1012}
1013
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001014/* ==================================================================
1015 * nxt200x based ATSC cards, helper functions
1016 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001017
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001018static struct nxt200x_config avertvhda180 = {
1019 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001020};
Andrew Burri3e1410a2006-02-27 00:08:23 -03001021
1022static struct nxt200x_config kworldatsc110 = {
1023 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -03001024};
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001025
Matthias Schwarzott04574182009-02-24 12:35:16 -03001026/* ------------------------------------------------------------------ */
1027
1028static struct mt312_config avertv_a700_mt312 = {
1029 .demod_address = 0x0e,
1030 .voltage_inverted = 1,
1031};
1032
1033static struct zl10036_config avertv_a700_tuner = {
1034 .tuner_address = 0x60,
1035};
1036
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001037static struct mt312_config zl10313_compro_s350_config = {
1038 .demod_address = 0x0e,
1039};
1040
Michael Krufky3abdedd2009-01-19 01:10:49 -03001041static struct lgdt3305_config hcw_lgdt3305_config = {
1042 .i2c_addr = 0x0e,
1043 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1044 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1045 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1046 .deny_i2c_rptr = 1,
1047 .spectral_inversion = 1,
1048 .qam_if_khz = 4000,
1049 .vsb_if_khz = 3250,
1050};
1051
Michael Krufky1bc7f512009-01-19 01:10:49 -03001052static struct tda10048_config hcw_tda10048_config = {
1053 .demod_address = 0x10 >> 1,
1054 .output_mode = TDA10048_SERIAL_OUTPUT,
1055 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1056 .inversion = TDA10048_INVERSION_ON,
1057 .dtv6_if_freq_khz = TDA10048_IF_3300,
1058 .dtv7_if_freq_khz = TDA10048_IF_3500,
1059 .dtv8_if_freq_khz = TDA10048_IF_4000,
1060 .clk_freq_khz = TDA10048_CLK_16000,
1061 .disable_gate_access = 1,
1062};
1063
Michael Krufky3abdedd2009-01-19 01:10:49 -03001064static struct tda18271_std_map hauppauge_tda18271_std_map = {
1065 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1066 .if_lvl = 1, .rfagc_top = 0x58, },
1067 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1068 .if_lvl = 1, .rfagc_top = 0x58, },
1069};
1070
1071static struct tda18271_config hcw_tda18271_config = {
1072 .std_map = &hauppauge_tda18271_std_map,
1073 .gate = TDA18271_GATE_ANALOG,
1074 .config = 3,
Michael Krufky542cb052009-08-29 17:45:48 -03001075 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky3abdedd2009-01-19 01:10:49 -03001076};
1077
1078static struct tda829x_config tda829x_no_probe = {
1079 .probe_tuner = TDA829X_DONT_PROBE,
1080};
1081
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001082static struct tda10048_config zolid_tda10048_config = {
1083 .demod_address = 0x10 >> 1,
1084 .output_mode = TDA10048_PARALLEL_OUTPUT,
1085 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1086 .inversion = TDA10048_INVERSION_ON,
1087 .dtv6_if_freq_khz = TDA10048_IF_3300,
1088 .dtv7_if_freq_khz = TDA10048_IF_3500,
1089 .dtv8_if_freq_khz = TDA10048_IF_4000,
1090 .clk_freq_khz = TDA10048_CLK_16000,
1091 .disable_gate_access = 1,
1092};
1093
1094static struct tda18271_config zolid_tda18271_config = {
1095 .gate = TDA18271_GATE_ANALOG,
1096};
1097
Michael Krufky184e7692009-06-05 04:28:28 -03001098static struct tda10048_config dtv1000s_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_3800,
1105 .dtv8_if_freq_khz = TDA10048_IF_4300,
1106 .clk_freq_khz = TDA10048_CLK_16000,
1107 .disable_gate_access = 1,
1108};
1109
1110static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1111 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1112 .if_lvl = 1, .rfagc_top = 0x37, },
1113 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1114 .if_lvl = 1, .rfagc_top = 0x37, },
1115 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1116 .if_lvl = 1, .rfagc_top = 0x37, },
1117};
1118
1119static struct tda18271_config dtv1000s_tda18271_config = {
1120 .std_map = &dtv1000s_tda18271_std_map,
1121 .gate = TDA18271_GATE_ANALOG,
1122};
1123
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001124/* ==================================================================
1125 * Core code
1126 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001127
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128static int dvb_init(struct saa7134_dev *dev)
1129{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001130 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001131 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001132 struct videobuf_dvb_frontend *fe0;
1133
Darron Broadf972e0b2008-10-11 11:24:30 -03001134 /* FIXME: add support for multi-frontend */
1135 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001136 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -03001137
1138 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001139 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1140 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -03001141 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1142 return -ENOMEM;
1143 }
1144
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 /* init struct videobuf_dvb */
1146 dev->ts.nr_bufs = 32;
1147 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001148 fe0->dvb.name = dev->name;
1149 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001150 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1152 V4L2_FIELD_ALTERNATE,
1153 sizeof(struct saa7134_buf),
Hans Verkuil08bff032010-09-20 17:39:46 -03001154 dev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155
1156 switch (dev->board) {
1157 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001158 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001159 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001160 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001161 if (fe0->dvb.frontend) {
1162 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001163 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001165 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001166 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001167 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001168 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001169 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001170 if (fe0->dvb.frontend) {
1171 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001172 &dev->i2c_adap, 0x61,
1173 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001174 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001175 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001176 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001177 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001178 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001179 &avermedia_xc3028_mt352_dev,
1180 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001181 attach_xc3028 = 1;
1182 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001184 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001185 &medion_cardbus,
1186 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001187 if (fe0->dvb.frontend) {
1188 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001189 &dev->i2c_adap, medion_cardbus.tuner_address,
1190 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001191 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001193 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001194 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001195 &philips_tu1216_60_config,
1196 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001197 if (fe0->dvb.frontend) {
1198 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1199 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001200 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001201 break;
1202 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001203 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001204 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1205 &tda827x_cfg_0) < 0)
1206 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001207 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001208 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001209 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Danny Woode3c6e1a2009-09-20 12:14:21 -03001210 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001211 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001212 &philips_europa_config,
1213 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001214 if (fe0->dvb.frontend) {
1215 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1216 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1217 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1218 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1219 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001220 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001221 break;
Vadim Catana128fe952010-05-29 12:49:16 -03001222 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1223 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1224 &technotrend_budget_t3000_config,
1225 &dev->i2c_adap);
1226 if (fe0->dvb.frontend) {
1227 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1228 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1229 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1230 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1231 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1232 }
1233 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001234 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001235 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001236 &philips_tu1216_61_config,
1237 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001238 if (fe0->dvb.frontend) {
1239 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1240 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001241 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001242 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001243 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001244 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1245 &tda827x_cfg_2) < 0)
1246 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001247 break;
Michael Krufky0e316ec2009-08-03 16:51:33 -03001248 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
Michael Krufky1bc7f512009-01-19 01:10:49 -03001249 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1250 &hcw_tda10048_config,
1251 &dev->i2c_adap);
1252 if (fe0->dvb.frontend != NULL) {
1253 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1254 &dev->i2c_adap, 0x4b,
1255 &tda829x_no_probe);
1256 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1257 0x60, &dev->i2c_adap,
1258 &hcw_tda18271_config);
1259 }
1260 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001261 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001262 if (configure_tda827x_fe(dev, &philips_tiger_config,
1263 &tda827x_cfg_0) < 0)
1264 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001265 break;
1266 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001267 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1268 &tda827x_cfg_1) < 0)
1269 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001270 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001271 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001272 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1273 &tda827x_cfg_1) < 0)
1274 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001275 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001276 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001277 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1278 &hcw_lgdt3305_config,
1279 &dev->i2c_adap);
1280 if (fe0->dvb.frontend) {
1281 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1282 &dev->i2c_adap, 0x4b,
1283 &tda829x_no_probe);
1284 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1285 0x60, &dev->i2c_adap,
1286 &hcw_tda18271_config);
1287 }
1288 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001289 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001290 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1291 &tda827x_cfg_0) < 0)
1292 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001293 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001294 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001295 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1296 &tda827x_cfg_0) < 0)
1297 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001298 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001299 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001300 if (!use_frontend) { /* terrestrial */
1301 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1302 &tda827x_cfg_0) < 0)
1303 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001304 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001305 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1306 if (fe0->dvb.frontend) {
1307 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001308 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001309 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001310 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001311 }
Steven Toth363c35f2008-10-11 11:05:50 -03001312 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001313 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001314 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001315 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001316 }
1317 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001318 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001319 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001320 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001321 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001322 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001323 &ads_tech_duo_config,
1324 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001325 if (fe0->dvb.frontend) {
1326 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001327 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1328 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001329 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001330 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001331 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001332 }
Mauro Carvalho Chehabbc36ec7462008-06-14 10:44:04 -03001333 } else
1334 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001335 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001336 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001337 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1338 &tda827x_cfg_0) < 0)
1339 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001340 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001341 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001342 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001343 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1344 &tda827x_cfg_0) < 0)
1345 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001346 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001347 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001348 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001349 if (fe0->dvb.frontend) {
1350 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001351 u8 dev_id = dev->eedata[2];
1352 u8 data = 0xc4;
1353 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1354
Steven Toth363c35f2008-10-11 11:05:50 -03001355 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001356 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001357 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001358 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001359 goto dettach_frontend;
1360 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001361 if (dev_id != 0x08) {
1362 /* we need to open the i2c gate (we know it exists) */
1363 fe->ops.i2c_gate_ctrl(fe, 1);
1364 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001365 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001366 wprintk("%s: Medion Quadro, no ISL6405 "
1367 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001368 goto dettach_frontend;
1369 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001370 if (dev_id == 0x07) {
1371 /* fire up the 2nd section of the LNB supply since
1372 we can't do this from the other section */
1373 msg.buf = &data;
1374 i2c_transfer(&dev->i2c_adap, &msg, 1);
1375 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001376 fe->ops.i2c_gate_ctrl(fe, 0);
1377 dev->original_set_voltage = fe->ops.set_voltage;
1378 fe->ops.set_voltage = md8800_set_voltage;
1379 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1380 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1381 } else {
1382 fe->ops.set_voltage = md8800_set_voltage2;
1383 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1384 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001385 }
1386 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001387 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001388 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001389 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001390 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001391 if (fe0->dvb.frontend)
1392 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001393 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001394 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001395 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001396 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001397 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001398 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001399 if (fe0->dvb.frontend)
1400 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001401 &dev->i2c_adap, 0x61,
1402 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001403 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001404 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001405 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001406 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001407 if (fe0->dvb.frontend) {
1408 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001409 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001410 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001411 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001412 }
Steven Toth363c35f2008-10-11 11:05:50 -03001413 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001414 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001415 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001416 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001417 }
1418 }
1419 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001420 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001421 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001422 &medion_cardbus,
1423 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001424 if (fe0->dvb.frontend) {
1425 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1426 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001427
Steven Toth363c35f2008-10-11 11:05:50 -03001428 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001429 &dev->i2c_adap, medion_cardbus.tuner_address,
1430 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001431 }
1432 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001433 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001434 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001435 &philips_europa_config,
1436 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001437 if (fe0->dvb.frontend) {
1438 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1439 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001440 }
1441 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001442 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001443 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1444 &tda827x_cfg_0) < 0)
1445 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001446 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001447 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001448 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1449 &tda827x_cfg_0) < 0)
1450 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001451 break;
1452 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001453 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1454 &tda827x_cfg_2) < 0)
1455 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001456 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001457 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001458 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1459 &tda827x_cfg_2) < 0)
1460 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001461 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001462 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001463 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1464 &tda827x_cfg_2) < 0)
1465 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001466 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001467 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001468 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1469 &tda827x_cfg_0) < 0)
1470 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001471 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001472 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001473 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1474 &tda827x_cfg_2_sw42) < 0)
1475 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001476 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001477 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001478 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001479 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001480 if (fe0->dvb.frontend) {
1481 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001482 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001483 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001484 goto dettach_frontend;
1485 }
Steven Toth363c35f2008-10-11 11:05:50 -03001486 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001487 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001488 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001489 goto dettach_frontend;
1490 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001491 }
1492 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001493 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001494 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1495 &tda827x_cfg_0) < 0)
1496 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001497 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001498 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001499 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1500 &tda827x_cfg_2) < 0)
1501 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001502 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001503 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001504 dprintk("AverMedia E506R dvb setup\n");
1505 saa7134_set_gpio(dev, 25, 0);
1506 msleep(10);
1507 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001508 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001509 &avermedia_xc3028_mt352_dev,
1510 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001511 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001512 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001513 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001514 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001515 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001516 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001517 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001518 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001519 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001520 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001521 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001522 goto dettach_frontend;
1523 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001524 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001525 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001526 fe->ops.i2c_gate_ctrl(fe, 1);
1527 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001528 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001529 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001530 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001531 goto dettach_frontend;
1532 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001533 fe->ops.i2c_gate_ctrl(fe, 0);
1534 dev->original_set_voltage = fe->ops.set_voltage;
1535 fe->ops.set_voltage = md8800_set_voltage;
1536 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1537 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1538 }
1539 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001540 case SAA7134_BOARD_AVERMEDIA_M103:
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,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001545 &avermedia_xc3028_mt352_dev,
1546 &dev->i2c_adap);
1547 attach_xc3028 = 1;
1548 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001549 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1550 if (!use_frontend) { /* terrestrial */
1551 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1552 &tda827x_cfg_2) < 0)
1553 goto dettach_frontend;
1554 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001555 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001556 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001557 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001558 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001559 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001560 &dev->i2c_adap, 0) == NULL) {
1561 wprintk("%s: Asus Tiger 3in1, no "
1562 "tda826x found!\n", __func__);
1563 goto dettach_frontend;
1564 }
Steven Toth363c35f2008-10-11 11:05:50 -03001565 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001566 &dev->i2c_adap, 0, 0) == NULL) {
1567 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1568 " found!\n", __func__);
1569 goto dettach_frontend;
1570 }
1571 }
1572 }
1573 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001574 case SAA7134_BOARD_ASUSTeK_TIGER:
1575 if (configure_tda827x_fe(dev, &philips_tiger_config,
1576 &tda827x_cfg_0) < 0)
1577 goto dettach_frontend;
1578 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001579 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001580 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001581 &behold_h6_config,
1582 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001583 if (fe0->dvb.frontend) {
1584 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001585 &dev->i2c_adap, 0x61,
Beholder Intl. Ltd. Dmitry Belimov4786dd62009-08-04 20:07:42 -03001586 TUNER_PHILIPS_FMD1216MEX_MK3);
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001587 }
1588 break;
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -03001589 case SAA7134_BOARD_BEHOLD_X7:
1590 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1591 &behold_x7_config,
1592 &dev->i2c_adap);
1593 if (fe0->dvb.frontend) {
1594 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1595 &dev->i2c_adap, &behold_x7_tunerconfig);
1596 }
1597 break;
Dmitri Belimov0faa2ed2010-04-06 01:00:05 -03001598 case SAA7134_BOARD_BEHOLD_H7:
1599 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1600 &behold_x7_config,
1601 &dev->i2c_adap);
1602 if (fe0->dvb.frontend) {
1603 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1604 &dev->i2c_adap, &behold_x7_tunerconfig);
1605 }
1606 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001607 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1608 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1609 /* Zarlink ZL10313 */
1610 fe0->dvb.frontend = dvb_attach(mt312_attach,
1611 &avertv_a700_mt312, &dev->i2c_adap);
1612 if (fe0->dvb.frontend) {
1613 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1614 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1615 wprintk("%s: No zl10036 found!\n",
1616 __func__);
1617 }
1618 }
1619 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001620 case SAA7134_BOARD_VIDEOMATE_S350:
1621 fe0->dvb.frontend = dvb_attach(mt312_attach,
1622 &zl10313_compro_s350_config, &dev->i2c_adap);
1623 if (fe0->dvb.frontend)
1624 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1625 0x60, &dev->i2c_adap) == NULL)
1626 wprintk("%s: No zl10039 found!\n",
1627 __func__);
1628
1629 break;
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001630 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1631 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1632 &zolid_tda10048_config,
1633 &dev->i2c_adap);
1634 if (fe0->dvb.frontend != NULL) {
1635 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1636 &dev->i2c_adap, 0x4b,
1637 &tda829x_no_probe);
1638 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1639 0x60, &dev->i2c_adap,
1640 &zolid_tda18271_config);
1641 }
1642 break;
Michael Krufky184e7692009-06-05 04:28:28 -03001643 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1644 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1645 &dtv1000s_tda10048_config,
1646 &dev->i2c_adap);
1647 if (fe0->dvb.frontend != NULL) {
1648 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1649 &dev->i2c_adap, 0x4b,
1650 &tda829x_no_probe);
1651 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1652 0x60, &dev->i2c_adap,
1653 &dtv1000s_tda18271_config);
1654 }
1655 break;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001656 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001657 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x14000);
1658 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x14000);
1659 msleep(20);
1660 saa_writel(SAA7134_GPIO_GPMODE0 >> 2, 0x54000);
1661 saa_writel(SAA7134_GPIO_GPSTATUS0 >> 2, 0x54000);
1662 msleep(20);
1663 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1664 &kworld_mb86a20s_config,
1665 &dev->i2c_adap);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001666 if (fe0->dvb.frontend != NULL) {
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001667#if 0
1668 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1669 &dev->i2c_adap, 0x4b,
1670 &tda829x_no_probe);
1671#else
1672 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1673 &dev->i2c_adap, 0x4b, NULL);
1674#endif
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001675 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1676 0x60, &dev->i2c_adap,
1677 &kworld_tda18271_config);
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001678 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001679 }
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001680
1681 /* mb86a20s need to use the I2C gateway */
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001682 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001684 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 break;
1686 }
1687
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001688 if (attach_xc3028) {
1689 struct dvb_frontend *fe;
1690 struct xc2028_config cfg = {
1691 .i2c_adap = &dev->i2c_adap,
1692 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001693 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001694
Steven Toth363c35f2008-10-11 11:05:50 -03001695 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001696 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001697
Steven Toth363c35f2008-10-11 11:05:50 -03001698 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001699 if (!fe) {
1700 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1701 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001702 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001703 }
1704 }
1705
Steven Toth363c35f2008-10-11 11:05:50 -03001706 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001707 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001708 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001710 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001711 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712
1713 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001714 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001715 &dev->pci->dev, adapter_nr, 0, NULL);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001716
1717 /* this sequence is necessary to make the tda1004x load its firmware
1718 * and to enter analog mode of hybrid boards
1719 */
1720 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001721 if (fe0->dvb.frontend->ops.init)
1722 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1723 if (fe0->dvb.frontend->ops.sleep)
1724 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1725 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1726 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001727 }
1728 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001729
1730dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001731 videobuf_dvb_dealloc_frontends(&dev->frontends);
1732 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733}
1734
1735static int dvb_fini(struct saa7134_dev *dev)
1736{
Steven Toth363c35f2008-10-11 11:05:50 -03001737 struct videobuf_dvb_frontend *fe0;
1738
1739 /* Get the first frontend */
1740 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1741 if (!fe0)
1742 return -EINVAL;
1743
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001744 /* FIXME: I suspect that this code is bogus, since the entry for
1745 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1746 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1747 */
1748 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1749 struct v4l2_priv_tun_config tda9887_cfg;
1750 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001752 tda9887_cfg.tuner = TUNER_TDA9887;
1753 tda9887_cfg.priv = &on;
1754
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001756 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001757 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001758 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001759 /* turn off the 2nd lnb supply */
1760 u8 data = 0x80;
1761 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1762 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001763 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001764 if (fe->ops.i2c_gate_ctrl) {
1765 fe->ops.i2c_gate_ctrl(fe, 1);
1766 i2c_transfer(&dev->i2c_adap, &msg, 1);
1767 fe->ops.i2c_gate_ctrl(fe, 0);
1768 }
1769 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001770 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001771 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001772 return 0;
1773}
1774
1775static struct saa7134_mpeg_ops dvb_ops = {
1776 .type = SAA7134_MPEG_DVB,
1777 .init = dvb_init,
1778 .fini = dvb_fini,
1779};
1780
1781static int __init dvb_register(void)
1782{
1783 return saa7134_ts_register(&dvb_ops);
1784}
1785
1786static void __exit dvb_unregister(void)
1787{
1788 saa7134_ts_unregister(&dvb_ops);
1789}
1790
1791module_init(dvb_register);
1792module_exit(dvb_unregister);
1793
1794/* ------------------------------------------------------------------ */
1795/*
1796 * Local variables:
1797 * c-basic-offset: 8
1798 * End:
1799 */