blob: f65cad287b83e198eacd21ff4b30f279f2783bb3 [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 Chehabecb71d22011-01-14 12:03:03 -0300240 .config = 3, /* Use tuner callback for AGC */
241
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300242};
243
244static const struct mb86a20s_config kworld_mb86a20s_config = {
245 .demod_address = 0x10,
246};
247
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -0300248static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
249{
250 struct saa7134_dev *dev = fe->dvb->priv;
251
252 unsigned char initmsg[] = {0x45, 0x97};
253 unsigned char msg_enable[] = {0x45, 0xc1};
254 unsigned char msg_disable[] = {0x45, 0x81};
255 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
256
257 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
258 wprintk("could not access the I2C gate\n");
259 return -EIO;
260 }
261 if (enable)
262 msg.buf = msg_enable;
263 else
264 msg.buf = msg_disable;
265 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
266 wprintk("could not access the I2C gate\n");
267 return -EIO;
268 }
269 msleep(20);
270 return 0;
271}
272
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300273/* ==================================================================
274 * tda1004x based DVB-T cards, helper functions
275 */
276
277static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
278 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700279{
280 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300281 return request_firmware(fw, name, &dev->pci->dev);
282}
283
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300284/* ------------------------------------------------------------------
285 * these tuners are tu1216, td1316(a)
286 */
287
288static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
289{
290 struct saa7134_dev *dev = fe->dvb->priv;
291 struct tda1004x_state *state = fe->demodulator_priv;
292 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700293 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800294 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700295 sizeof(tuner_buf) };
296 int tuner_frequency = 0;
297 u8 band, cp, filter;
298
299 /* determine charge pump */
300 tuner_frequency = params->frequency + 36166000;
301 if (tuner_frequency < 87000000)
302 return -EINVAL;
303 else if (tuner_frequency < 130000000)
304 cp = 3;
305 else if (tuner_frequency < 160000000)
306 cp = 5;
307 else if (tuner_frequency < 200000000)
308 cp = 6;
309 else if (tuner_frequency < 290000000)
310 cp = 3;
311 else if (tuner_frequency < 420000000)
312 cp = 5;
313 else if (tuner_frequency < 480000000)
314 cp = 6;
315 else if (tuner_frequency < 620000000)
316 cp = 3;
317 else if (tuner_frequency < 830000000)
318 cp = 5;
319 else if (tuner_frequency < 895000000)
320 cp = 7;
321 else
322 return -EINVAL;
323
324 /* determine band */
325 if (params->frequency < 49000000)
326 return -EINVAL;
327 else if (params->frequency < 161000000)
328 band = 1;
329 else if (params->frequency < 444000000)
330 band = 2;
331 else if (params->frequency < 861000000)
332 band = 4;
333 else
334 return -EINVAL;
335
336 /* setup PLL filter */
337 switch (params->u.ofdm.bandwidth) {
338 case BANDWIDTH_6_MHZ:
339 filter = 0;
340 break;
341
342 case BANDWIDTH_7_MHZ:
343 filter = 0;
344 break;
345
346 case BANDWIDTH_8_MHZ:
347 filter = 1;
348 break;
349
350 default:
351 return -EINVAL;
352 }
353
354 /* calculate divisor
355 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
356 */
357 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
358
359 /* setup tuner buffer */
360 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
361 tuner_buf[1] = tuner_frequency & 0xff;
362 tuner_buf[2] = 0xca;
363 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
364
Patrick Boettcherdea74862006-05-14 05:01:31 -0300365 if (fe->ops.i2c_gate_ctrl)
366 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300367 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300368 wprintk("could not write to tuner at addr: 0x%02x\n",
369 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700370 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300371 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700372 msleep(1);
373 return 0;
374}
375
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300376static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800377{
378 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300379 struct tda1004x_state *state = fe->demodulator_priv;
380 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800381 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
382 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
383
384 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300385 if (fe->ops.i2c_gate_ctrl)
386 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800387 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
388 return -EIO;
389 msleep(1);
390
391 return 0;
392}
393
394/* ------------------------------------------------------------------ */
395
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800396static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700397 .demod_address = 0x8,
398 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800399 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700400 .xtal_freq = TDA10046_XTAL_4M,
401 .agc_config = TDA10046_AGC_DEFAULT,
402 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300403 .tuner_address = 0x60,
404 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405};
406
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800407static struct tda1004x_config philips_tu1216_61_config = {
408
409 .demod_address = 0x8,
410 .invert = 1,
411 .invert_oclk = 0,
412 .xtal_freq = TDA10046_XTAL_4M,
413 .agc_config = TDA10046_AGC_DEFAULT,
414 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300415 .tuner_address = 0x61,
416 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800417};
418
419/* ------------------------------------------------------------------ */
420
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300421static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800422{
423 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300424 struct tda1004x_state *state = fe->demodulator_priv;
425 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800426 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300427 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800428
429 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300430 if (fe->ops.i2c_gate_ctrl)
431 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800432 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
433 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800434 return 0;
435}
436
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300437static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800438{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300439 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800440}
441
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300442static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
443{
444 struct saa7134_dev *dev = fe->dvb->priv;
445 struct tda1004x_state *state = fe->demodulator_priv;
446 u8 addr = state->config->tuner_address;
447 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
448 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
449
450 /* switch the tuner to analog mode */
451 if (fe->ops.i2c_gate_ctrl)
452 fe->ops.i2c_gate_ctrl(fe, 1);
453 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
454 return -EIO;
455 return 0;
456}
457
458/* ------------------------------------------------------------------ */
459
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300460static int philips_europa_tuner_init(struct dvb_frontend *fe)
461{
462 struct saa7134_dev *dev = fe->dvb->priv;
463 static u8 msg[] = { 0x00, 0x40};
464 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
465
466
467 if (philips_td1316_tuner_init(fe))
468 return -EIO;
469 msleep(1);
470 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
471 return -EIO;
472
473 return 0;
474}
475
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300476static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800477{
478 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800479
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300480 static u8 msg[] = { 0x00, 0x14 };
481 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
482
483 if (philips_td1316_tuner_sleep(fe))
484 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800485
486 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300487 if (fe->ops.i2c_gate_ctrl)
488 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800489 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300490 return 0;
491}
492
493static int philips_europa_demod_sleep(struct dvb_frontend *fe)
494{
495 struct saa7134_dev *dev = fe->dvb->priv;
496
497 if (dev->original_demod_sleep)
498 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300499 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300500 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800501}
502
503static struct tda1004x_config philips_europa_config = {
504
505 .demod_address = 0x8,
506 .invert = 0,
507 .invert_oclk = 0,
508 .xtal_freq = TDA10046_XTAL_4M,
509 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
510 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300511 .tuner_address = 0x61,
512 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800513};
514
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700515static struct tda1004x_config medion_cardbus = {
516 .demod_address = 0x08,
517 .invert = 1,
518 .invert_oclk = 0,
519 .xtal_freq = TDA10046_XTAL_16M,
520 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
521 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300522 .tuner_address = 0x61,
523 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700524};
525
Vadim Catana128fe952010-05-29 12:49:16 -0300526static struct tda1004x_config technotrend_budget_t3000_config = {
527 .demod_address = 0x8,
528 .invert = 1,
529 .invert_oclk = 0,
530 .xtal_freq = TDA10046_XTAL_4M,
531 .agc_config = TDA10046_AGC_DEFAULT,
532 .if_freq = TDA10046_FREQ_3617,
533 .tuner_address = 0x63,
534 .request_firmware = philips_tda1004x_request_firmware
535};
536
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300537/* ------------------------------------------------------------------
538 * tda 1004x based cards with philips silicon tuner
539 */
540
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300541static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
542{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300543 struct tda1004x_state *state = fe->demodulator_priv;
544
545 u8 addr = state->config->i2c_gate;
546 static u8 tda8290_close[] = { 0x21, 0xc0};
547 static u8 tda8290_open[] = { 0x21, 0x80};
548 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
549 if (enable) {
550 tda8290_msg.buf = tda8290_close;
551 } else {
552 tda8290_msg.buf = tda8290_open;
553 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300554 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300555 struct saa7134_dev *dev = fe->dvb->priv;
556 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300557 return -EIO;
558 }
559 msleep(20);
560 return 0;
561}
562
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300563static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300564{
565 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300566 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300567
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300568 switch (state->config->antenna_switch) {
569 case 0: break;
570 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
571 saa7134_set_gpio(dev, 21, 0);
572 break;
573 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
574 saa7134_set_gpio(dev, 21, 1);
575 break;
576 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300577 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800578}
579
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300580static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
581{
582 struct saa7134_dev *dev = fe->dvb->priv;
583 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300584
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300585 switch (state->config->antenna_switch) {
586 case 0: break;
587 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
588 saa7134_set_gpio(dev, 21, 1);
589 break;
590 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
591 saa7134_set_gpio(dev, 21, 0);
592 break;
593 }
594 return 0;
595}
596
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300597static int configure_tda827x_fe(struct saa7134_dev *dev,
598 struct tda1004x_config *cdec_conf,
599 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300600{
Steven Toth363c35f2008-10-11 11:05:50 -0300601 struct videobuf_dvb_frontend *fe0;
602
Darron Broad92abe9e2008-10-11 11:18:53 -0300603 /* Get the first frontend */
604 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300605
606 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
607 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300608 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300609 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
610 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300611 cdec_conf->tuner_address,
612 &dev->i2c_adap, tuner_conf))
613 return 0;
614
615 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300616 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300617 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300618 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300619}
620
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800621/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300622
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300623static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300624 .init = philips_tda827x_tuner_init,
625 .sleep = philips_tda827x_tuner_sleep,
626 .config = 0,
627 .switch_addr = 0
628};
629
630static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300631 .init = philips_tda827x_tuner_init,
632 .sleep = philips_tda827x_tuner_sleep,
633 .config = 1,
634 .switch_addr = 0x4b
635};
636
637static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300638 .init = philips_tda827x_tuner_init,
639 .sleep = philips_tda827x_tuner_sleep,
640 .config = 2,
641 .switch_addr = 0x4b
642};
643
644static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300645 .init = philips_tda827x_tuner_init,
646 .sleep = philips_tda827x_tuner_sleep,
647 .config = 2,
648 .switch_addr = 0x42
649};
650
651/* ------------------------------------------------------------------ */
652
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300653static struct tda1004x_config tda827x_lifeview_config = {
654 .demod_address = 0x08,
655 .invert = 1,
656 .invert_oclk = 0,
657 .xtal_freq = TDA10046_XTAL_16M,
658 .agc_config = TDA10046_AGC_TDA827X,
659 .gpio_config = TDA10046_GP11_I,
660 .if_freq = TDA10046_FREQ_045,
661 .tuner_address = 0x60,
662 .request_firmware = philips_tda1004x_request_firmware
663};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800664
665static struct tda1004x_config philips_tiger_config = {
666 .demod_address = 0x08,
667 .invert = 1,
668 .invert_oclk = 0,
669 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300670 .agc_config = TDA10046_AGC_TDA827X,
671 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300672 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300673 .i2c_gate = 0x4b,
674 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300675 .antenna_switch= 1,
676 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300677};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300678
679static struct tda1004x_config cinergy_ht_config = {
680 .demod_address = 0x08,
681 .invert = 1,
682 .invert_oclk = 0,
683 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300684 .agc_config = TDA10046_AGC_TDA827X,
685 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800686 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300687 .i2c_gate = 0x4b,
688 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300689 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800690};
691
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300692static struct tda1004x_config cinergy_ht_pci_config = {
693 .demod_address = 0x08,
694 .invert = 1,
695 .invert_oclk = 0,
696 .xtal_freq = TDA10046_XTAL_16M,
697 .agc_config = TDA10046_AGC_TDA827X,
698 .gpio_config = TDA10046_GP01_I,
699 .if_freq = TDA10046_FREQ_045,
700 .i2c_gate = 0x4b,
701 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300702 .request_firmware = philips_tda1004x_request_firmware
703};
704
705static struct tda1004x_config philips_tiger_s_config = {
706 .demod_address = 0x08,
707 .invert = 1,
708 .invert_oclk = 0,
709 .xtal_freq = TDA10046_XTAL_16M,
710 .agc_config = TDA10046_AGC_TDA827X,
711 .gpio_config = TDA10046_GP01_I,
712 .if_freq = TDA10046_FREQ_045,
713 .i2c_gate = 0x4b,
714 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300715 .antenna_switch= 1,
716 .request_firmware = philips_tda1004x_request_firmware
717};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200718
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300719static struct tda1004x_config pinnacle_pctv_310i_config = {
720 .demod_address = 0x08,
721 .invert = 1,
722 .invert_oclk = 0,
723 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300724 .agc_config = TDA10046_AGC_TDA827X,
725 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300726 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300727 .i2c_gate = 0x4b,
728 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300729 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300730};
731
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300732static struct tda1004x_config hauppauge_hvr_1110_config = {
733 .demod_address = 0x08,
734 .invert = 1,
735 .invert_oclk = 0,
736 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300737 .agc_config = TDA10046_AGC_TDA827X,
738 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300739 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300740 .i2c_gate = 0x4b,
741 .tuner_address = 0x61,
742 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300743};
744
Hartmut Hackmann83646812006-10-12 20:38:51 -0300745static struct tda1004x_config asus_p7131_dual_config = {
746 .demod_address = 0x08,
747 .invert = 1,
748 .invert_oclk = 0,
749 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300750 .agc_config = TDA10046_AGC_TDA827X,
751 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300752 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300753 .i2c_gate = 0x4b,
754 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300755 .antenna_switch= 2,
756 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300757};
758
Nico Sabbi420f32f2006-03-03 12:11:28 -0300759static struct tda1004x_config lifeview_trio_config = {
760 .demod_address = 0x09,
761 .invert = 1,
762 .invert_oclk = 0,
763 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300764 .agc_config = TDA10046_AGC_TDA827X,
765 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300766 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300767 .tuner_address = 0x60,
768 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300769};
770
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300771static struct tda1004x_config tevion_dvbt220rf_config = {
772 .demod_address = 0x08,
773 .invert = 1,
774 .invert_oclk = 0,
775 .xtal_freq = TDA10046_XTAL_16M,
776 .agc_config = TDA10046_AGC_TDA827X,
777 .gpio_config = TDA10046_GP11_I,
778 .if_freq = TDA10046_FREQ_045,
779 .tuner_address = 0x60,
780 .request_firmware = philips_tda1004x_request_firmware
781};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300782
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300783static struct tda1004x_config md8800_dvbt_config = {
784 .demod_address = 0x08,
785 .invert = 1,
786 .invert_oclk = 0,
787 .xtal_freq = TDA10046_XTAL_16M,
788 .agc_config = TDA10046_AGC_TDA827X,
789 .gpio_config = TDA10046_GP01_I,
790 .if_freq = TDA10046_FREQ_045,
791 .i2c_gate = 0x4b,
792 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300793 .request_firmware = philips_tda1004x_request_firmware
794};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200795
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300796static struct tda1004x_config asus_p7131_4871_config = {
797 .demod_address = 0x08,
798 .invert = 1,
799 .invert_oclk = 0,
800 .xtal_freq = TDA10046_XTAL_16M,
801 .agc_config = TDA10046_AGC_TDA827X,
802 .gpio_config = TDA10046_GP01_I,
803 .if_freq = TDA10046_FREQ_045,
804 .i2c_gate = 0x4b,
805 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300806 .antenna_switch= 2,
807 .request_firmware = philips_tda1004x_request_firmware
808};
809
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300810static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300811 .demod_address = 0x08,
812 .invert = 1,
813 .invert_oclk = 0,
814 .xtal_freq = TDA10046_XTAL_16M,
815 .agc_config = TDA10046_AGC_TDA827X,
816 .gpio_config = TDA10046_GP11_I,
817 .if_freq = TDA10046_FREQ_045,
818 .i2c_gate = 0x4b,
819 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300820 .antenna_switch= 2,
821 .request_firmware = philips_tda1004x_request_firmware
822};
Edgar Simo261f5082007-08-20 14:06:00 -0300823
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300824static struct tda1004x_config kworld_dvb_t_210_config = {
825 .demod_address = 0x08,
826 .invert = 1,
827 .invert_oclk = 0,
828 .xtal_freq = TDA10046_XTAL_16M,
829 .agc_config = TDA10046_AGC_TDA827X,
830 .gpio_config = TDA10046_GP11_I,
831 .if_freq = TDA10046_FREQ_045,
832 .i2c_gate = 0x4b,
833 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300834 .antenna_switch= 1,
835 .request_firmware = philips_tda1004x_request_firmware
836};
Edgar Simo261f5082007-08-20 14:06:00 -0300837
Edgar Simod90d9f52007-08-20 14:14:50 -0300838static struct tda1004x_config avermedia_super_007_config = {
839 .demod_address = 0x08,
840 .invert = 1,
841 .invert_oclk = 0,
842 .xtal_freq = TDA10046_XTAL_16M,
843 .agc_config = TDA10046_AGC_TDA827X,
844 .gpio_config = TDA10046_GP01_I,
845 .if_freq = TDA10046_FREQ_045,
846 .i2c_gate = 0x4b,
847 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300848 .antenna_switch= 1,
849 .request_firmware = philips_tda1004x_request_firmware
850};
851
Hermann Pitton4ba24372008-01-20 19:27:51 -0300852static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
853 .demod_address = 0x08,
854 .invert = 1,
855 .invert_oclk = 0,
856 .xtal_freq = TDA10046_XTAL_16M,
857 .agc_config = TDA10046_AGC_TDA827X,
858 .gpio_config = TDA10046_GP01_I,
859 .if_freq = TDA10046_FREQ_045,
860 .i2c_gate = 0x42,
861 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300862 .antenna_switch = 1,
863 .request_firmware = philips_tda1004x_request_firmware
864};
865
hermann pitton301e9d62008-09-14 17:49:14 -0300866static struct tda1004x_config asus_tiger_3in1_config = {
867 .demod_address = 0x0b,
868 .invert = 1,
869 .invert_oclk = 0,
870 .xtal_freq = TDA10046_XTAL_16M,
871 .agc_config = TDA10046_AGC_TDA827X,
872 .gpio_config = TDA10046_GP11_I,
873 .if_freq = TDA10046_FREQ_045,
874 .i2c_gate = 0x4b,
875 .tuner_address = 0x61,
876 .antenna_switch = 1,
877 .request_firmware = philips_tda1004x_request_firmware
878};
879
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300880/* ------------------------------------------------------------------
881 * special case: this card uses saa713x GPIO22 for the mode switch
882 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200883
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300884static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200885{
886 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300887 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200888 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300889 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200890 return 0;
891}
892
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300893static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200894{
895 struct saa7134_dev *dev = fe->dvb->priv;
896 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300897 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300898 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300899 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200900}
901
Michael Krufky8ce47da2007-04-27 12:31:14 -0300902static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300903 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300904 .sleep = ads_duo_tuner_sleep,
905 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300906};
907
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200908static struct tda1004x_config ads_tech_duo_config = {
909 .demod_address = 0x08,
910 .invert = 1,
911 .invert_oclk = 0,
912 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300913 .agc_config = TDA10046_AGC_TDA827X,
914 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200915 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300916 .tuner_address = 0x61,
917 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200918};
919
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300920static struct zl10353_config behold_h6_config = {
921 .demod_address = 0x1e>>1,
922 .no_tuner = 1,
923 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300924 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300925};
926
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300927static struct xc5000_config behold_x7_tunerconfig = {
928 .i2c_address = 0xc2>>1,
929 .if_khz = 4560,
Devin Heitmueller2a0d0562009-09-30 23:04:39 -0300930 .radio_input = XC5000_RADIO_FM1,
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300931};
932
933static struct zl10353_config behold_x7_config = {
934 .demod_address = 0x1e>>1,
935 .if2 = 45600,
936 .no_tuner = 1,
937 .parallel_ts = 1,
938 .disable_i2c_gate_ctrl = 1,
939};
940
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300941/* ==================================================================
942 * tda10086 based DVB-S cards, helper functions
943 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300944
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300945static struct tda10086_config flydvbs = {
946 .demod_address = 0x0e,
947 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300948 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300949 .xtal_freq = TDA10086_XTAL_16M,
950};
951
952static struct tda10086_config sd1878_4m = {
953 .demod_address = 0x0e,
954 .invert = 0,
955 .diseqc_tone = 0,
956 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300957};
958
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300959/* ------------------------------------------------------------------
960 * special case: lnb supply is connected to the gated i2c
961 */
962
963static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
964{
965 int res = -EIO;
966 struct saa7134_dev *dev = fe->dvb->priv;
967 if (fe->ops.i2c_gate_ctrl) {
968 fe->ops.i2c_gate_ctrl(fe, 1);
969 if (dev->original_set_voltage)
970 res = dev->original_set_voltage(fe, voltage);
971 fe->ops.i2c_gate_ctrl(fe, 0);
972 }
973 return res;
974};
975
976static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
977{
978 int res = -EIO;
979 struct saa7134_dev *dev = fe->dvb->priv;
980 if (fe->ops.i2c_gate_ctrl) {
981 fe->ops.i2c_gate_ctrl(fe, 1);
982 if (dev->original_set_high_voltage)
983 res = dev->original_set_high_voltage(fe, arg);
984 fe->ops.i2c_gate_ctrl(fe, 0);
985 }
986 return res;
987};
988
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300989static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
990{
991 struct saa7134_dev *dev = fe->dvb->priv;
992 u8 wbuf[2] = { 0x1f, 00 };
993 u8 rbuf;
994 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
995 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
996
997 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
998 return -EIO;
999 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1000 if (voltage == SEC_VOLTAGE_18)
1001 wbuf[1] = rbuf | 0x10;
1002 else
1003 wbuf[1] = rbuf & 0xef;
1004 msg[0].len = 2;
1005 i2c_transfer(&dev->i2c_adap, msg, 1);
1006 return 0;
1007}
1008
1009static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1010{
1011 struct saa7134_dev *dev = fe->dvb->priv;
1012 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
1013 return -EIO;
1014}
1015
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001016/* ==================================================================
1017 * nxt200x based ATSC cards, helper functions
1018 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001019
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001020static struct nxt200x_config avertvhda180 = {
1021 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001022};
Andrew Burri3e1410a2006-02-27 00:08:23 -03001023
1024static struct nxt200x_config kworldatsc110 = {
1025 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -03001026};
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001027
Matthias Schwarzott04574182009-02-24 12:35:16 -03001028/* ------------------------------------------------------------------ */
1029
1030static struct mt312_config avertv_a700_mt312 = {
1031 .demod_address = 0x0e,
1032 .voltage_inverted = 1,
1033};
1034
1035static struct zl10036_config avertv_a700_tuner = {
1036 .tuner_address = 0x60,
1037};
1038
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001039static struct mt312_config zl10313_compro_s350_config = {
1040 .demod_address = 0x0e,
1041};
1042
Michael Krufky3abdedd2009-01-19 01:10:49 -03001043static struct lgdt3305_config hcw_lgdt3305_config = {
1044 .i2c_addr = 0x0e,
1045 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1046 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1047 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1048 .deny_i2c_rptr = 1,
1049 .spectral_inversion = 1,
1050 .qam_if_khz = 4000,
1051 .vsb_if_khz = 3250,
1052};
1053
Michael Krufky1bc7f512009-01-19 01:10:49 -03001054static struct tda10048_config hcw_tda10048_config = {
1055 .demod_address = 0x10 >> 1,
1056 .output_mode = TDA10048_SERIAL_OUTPUT,
1057 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1058 .inversion = TDA10048_INVERSION_ON,
1059 .dtv6_if_freq_khz = TDA10048_IF_3300,
1060 .dtv7_if_freq_khz = TDA10048_IF_3500,
1061 .dtv8_if_freq_khz = TDA10048_IF_4000,
1062 .clk_freq_khz = TDA10048_CLK_16000,
1063 .disable_gate_access = 1,
1064};
1065
Michael Krufky3abdedd2009-01-19 01:10:49 -03001066static struct tda18271_std_map hauppauge_tda18271_std_map = {
1067 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1068 .if_lvl = 1, .rfagc_top = 0x58, },
1069 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1070 .if_lvl = 1, .rfagc_top = 0x58, },
1071};
1072
1073static struct tda18271_config hcw_tda18271_config = {
1074 .std_map = &hauppauge_tda18271_std_map,
1075 .gate = TDA18271_GATE_ANALOG,
1076 .config = 3,
Michael Krufky542cb052009-08-29 17:45:48 -03001077 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky3abdedd2009-01-19 01:10:49 -03001078};
1079
1080static struct tda829x_config tda829x_no_probe = {
1081 .probe_tuner = TDA829X_DONT_PROBE,
1082};
1083
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001084static struct tda10048_config zolid_tda10048_config = {
1085 .demod_address = 0x10 >> 1,
1086 .output_mode = TDA10048_PARALLEL_OUTPUT,
1087 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1088 .inversion = TDA10048_INVERSION_ON,
1089 .dtv6_if_freq_khz = TDA10048_IF_3300,
1090 .dtv7_if_freq_khz = TDA10048_IF_3500,
1091 .dtv8_if_freq_khz = TDA10048_IF_4000,
1092 .clk_freq_khz = TDA10048_CLK_16000,
1093 .disable_gate_access = 1,
1094};
1095
1096static struct tda18271_config zolid_tda18271_config = {
1097 .gate = TDA18271_GATE_ANALOG,
1098};
1099
Michael Krufky184e7692009-06-05 04:28:28 -03001100static struct tda10048_config dtv1000s_tda10048_config = {
1101 .demod_address = 0x10 >> 1,
1102 .output_mode = TDA10048_PARALLEL_OUTPUT,
1103 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1104 .inversion = TDA10048_INVERSION_ON,
1105 .dtv6_if_freq_khz = TDA10048_IF_3300,
1106 .dtv7_if_freq_khz = TDA10048_IF_3800,
1107 .dtv8_if_freq_khz = TDA10048_IF_4300,
1108 .clk_freq_khz = TDA10048_CLK_16000,
1109 .disable_gate_access = 1,
1110};
1111
1112static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1113 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1114 .if_lvl = 1, .rfagc_top = 0x37, },
1115 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1116 .if_lvl = 1, .rfagc_top = 0x37, },
1117 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1118 .if_lvl = 1, .rfagc_top = 0x37, },
1119};
1120
1121static struct tda18271_config dtv1000s_tda18271_config = {
1122 .std_map = &dtv1000s_tda18271_std_map,
1123 .gate = TDA18271_GATE_ANALOG,
1124};
1125
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001126/* ==================================================================
1127 * Core code
1128 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001129
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130static int dvb_init(struct saa7134_dev *dev)
1131{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001132 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001133 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001134 struct videobuf_dvb_frontend *fe0;
1135
Darron Broadf972e0bd2008-10-11 11:24:30 -03001136 /* FIXME: add support for multi-frontend */
1137 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001138 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0bd2008-10-11 11:24:30 -03001139
1140 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001141 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1142 if (!fe0) {
Darron Broadf972e0bd2008-10-11 11:24:30 -03001143 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1144 return -ENOMEM;
1145 }
1146
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 /* init struct videobuf_dvb */
1148 dev->ts.nr_bufs = 32;
1149 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001150 fe0->dvb.name = dev->name;
1151 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001152 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1154 V4L2_FIELD_ALTERNATE,
1155 sizeof(struct saa7134_buf),
Hans Verkuil08bff032010-09-20 17:39:46 -03001156 dev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157
1158 switch (dev->board) {
1159 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001160 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001161 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001162 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001163 if (fe0->dvb.frontend) {
1164 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001165 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001167 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001168 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001169 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001170 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001171 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001172 if (fe0->dvb.frontend) {
1173 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001174 &dev->i2c_adap, 0x61,
1175 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001176 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001177 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001178 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001179 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001180 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001181 &avermedia_xc3028_mt352_dev,
1182 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001183 attach_xc3028 = 1;
1184 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001186 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001187 &medion_cardbus,
1188 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001189 if (fe0->dvb.frontend) {
1190 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001191 &dev->i2c_adap, medion_cardbus.tuner_address,
1192 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001193 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001195 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001196 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001197 &philips_tu1216_60_config,
1198 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001199 if (fe0->dvb.frontend) {
1200 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1201 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001202 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001203 break;
1204 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001205 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001206 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1207 &tda827x_cfg_0) < 0)
1208 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001209 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001210 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001211 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Danny Woode3c6e1a2009-09-20 12:14:21 -03001212 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001213 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001214 &philips_europa_config,
1215 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001216 if (fe0->dvb.frontend) {
1217 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1218 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1219 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1220 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1221 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001222 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001223 break;
Vadim Catana128fe952010-05-29 12:49:16 -03001224 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1225 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1226 &technotrend_budget_t3000_config,
1227 &dev->i2c_adap);
1228 if (fe0->dvb.frontend) {
1229 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1230 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1231 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1232 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1233 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1234 }
1235 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001236 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001237 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001238 &philips_tu1216_61_config,
1239 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001240 if (fe0->dvb.frontend) {
1241 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1242 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001243 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001244 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001245 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001246 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1247 &tda827x_cfg_2) < 0)
1248 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001249 break;
Michael Krufky0e316ec2009-08-03 16:51:33 -03001250 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
Michael Krufky1bc7f512009-01-19 01:10:49 -03001251 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1252 &hcw_tda10048_config,
1253 &dev->i2c_adap);
1254 if (fe0->dvb.frontend != NULL) {
1255 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1256 &dev->i2c_adap, 0x4b,
1257 &tda829x_no_probe);
1258 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1259 0x60, &dev->i2c_adap,
1260 &hcw_tda18271_config);
1261 }
1262 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001263 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001264 if (configure_tda827x_fe(dev, &philips_tiger_config,
1265 &tda827x_cfg_0) < 0)
1266 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001267 break;
1268 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001269 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1270 &tda827x_cfg_1) < 0)
1271 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001272 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001273 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001274 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1275 &tda827x_cfg_1) < 0)
1276 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001277 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001278 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001279 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1280 &hcw_lgdt3305_config,
1281 &dev->i2c_adap);
1282 if (fe0->dvb.frontend) {
1283 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1284 &dev->i2c_adap, 0x4b,
1285 &tda829x_no_probe);
1286 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1287 0x60, &dev->i2c_adap,
1288 &hcw_tda18271_config);
1289 }
1290 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001291 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001292 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1293 &tda827x_cfg_0) < 0)
1294 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001295 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001296 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001297 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1298 &tda827x_cfg_0) < 0)
1299 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001300 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001301 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001302 if (!use_frontend) { /* terrestrial */
1303 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1304 &tda827x_cfg_0) < 0)
1305 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001306 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001307 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1308 if (fe0->dvb.frontend) {
1309 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001310 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001311 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001312 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001313 }
Steven Toth363c35f2008-10-11 11:05:50 -03001314 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001315 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001316 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001317 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001318 }
1319 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001320 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001321 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001322 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001323 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001324 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001325 &ads_tech_duo_config,
1326 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001327 if (fe0->dvb.frontend) {
1328 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001329 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1330 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001331 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001332 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001333 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001334 }
Mauro Carvalho Chehabbc36ec72008-06-14 10:44:04 -03001335 } else
1336 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001337 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001338 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001339 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1340 &tda827x_cfg_0) < 0)
1341 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001342 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001343 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001344 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001345 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1346 &tda827x_cfg_0) < 0)
1347 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001348 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001349 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001350 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001351 if (fe0->dvb.frontend) {
1352 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001353 u8 dev_id = dev->eedata[2];
1354 u8 data = 0xc4;
1355 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1356
Steven Toth363c35f2008-10-11 11:05:50 -03001357 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001358 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001359 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001360 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001361 goto dettach_frontend;
1362 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001363 if (dev_id != 0x08) {
1364 /* we need to open the i2c gate (we know it exists) */
1365 fe->ops.i2c_gate_ctrl(fe, 1);
1366 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001367 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001368 wprintk("%s: Medion Quadro, no ISL6405 "
1369 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001370 goto dettach_frontend;
1371 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001372 if (dev_id == 0x07) {
1373 /* fire up the 2nd section of the LNB supply since
1374 we can't do this from the other section */
1375 msg.buf = &data;
1376 i2c_transfer(&dev->i2c_adap, &msg, 1);
1377 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001378 fe->ops.i2c_gate_ctrl(fe, 0);
1379 dev->original_set_voltage = fe->ops.set_voltage;
1380 fe->ops.set_voltage = md8800_set_voltage;
1381 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1382 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1383 } else {
1384 fe->ops.set_voltage = md8800_set_voltage2;
1385 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1386 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001387 }
1388 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001389 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001390 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001391 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001392 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001393 if (fe0->dvb.frontend)
1394 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001395 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001396 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001397 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001398 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001399 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001400 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001401 if (fe0->dvb.frontend)
1402 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff817a2008-04-22 14:46:17 -03001403 &dev->i2c_adap, 0x61,
1404 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001405 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001406 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001407 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001408 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001409 if (fe0->dvb.frontend) {
1410 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001411 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001412 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001413 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001414 }
Steven Toth363c35f2008-10-11 11:05:50 -03001415 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001416 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001417 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001418 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001419 }
1420 }
1421 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001422 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001423 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001424 &medion_cardbus,
1425 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001426 if (fe0->dvb.frontend) {
1427 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1428 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001429
Steven Toth363c35f2008-10-11 11:05:50 -03001430 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001431 &dev->i2c_adap, medion_cardbus.tuner_address,
1432 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001433 }
1434 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001435 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001436 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001437 &philips_europa_config,
1438 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001439 if (fe0->dvb.frontend) {
1440 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1441 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001442 }
1443 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001444 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001445 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1446 &tda827x_cfg_0) < 0)
1447 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001448 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001449 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001450 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1451 &tda827x_cfg_0) < 0)
1452 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001453 break;
1454 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001455 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1456 &tda827x_cfg_2) < 0)
1457 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001458 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001459 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001460 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1461 &tda827x_cfg_2) < 0)
1462 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001463 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001464 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001465 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1466 &tda827x_cfg_2) < 0)
1467 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001468 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001469 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001470 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1471 &tda827x_cfg_0) < 0)
1472 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001473 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001474 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001475 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1476 &tda827x_cfg_2_sw42) < 0)
1477 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001478 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001479 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001480 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001481 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001482 if (fe0->dvb.frontend) {
1483 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001484 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001485 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001486 goto dettach_frontend;
1487 }
Steven Toth363c35f2008-10-11 11:05:50 -03001488 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001489 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001490 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001491 goto dettach_frontend;
1492 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001493 }
1494 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001495 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001496 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1497 &tda827x_cfg_0) < 0)
1498 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001499 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001500 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001501 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1502 &tda827x_cfg_2) < 0)
1503 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001504 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001505 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001506 dprintk("AverMedia E506R dvb setup\n");
1507 saa7134_set_gpio(dev, 25, 0);
1508 msleep(10);
1509 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001510 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001511 &avermedia_xc3028_mt352_dev,
1512 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001513 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001514 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001515 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001516 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001517 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001518 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001519 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001520 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001521 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001522 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001523 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001524 goto dettach_frontend;
1525 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001526 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001527 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001528 fe->ops.i2c_gate_ctrl(fe, 1);
1529 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001530 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001531 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001532 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001533 goto dettach_frontend;
1534 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001535 fe->ops.i2c_gate_ctrl(fe, 0);
1536 dev->original_set_voltage = fe->ops.set_voltage;
1537 fe->ops.set_voltage = md8800_set_voltage;
1538 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1539 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1540 }
1541 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001542 case SAA7134_BOARD_AVERMEDIA_M103:
1543 saa7134_set_gpio(dev, 25, 0);
1544 msleep(10);
1545 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001546 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001547 &avermedia_xc3028_mt352_dev,
1548 &dev->i2c_adap);
1549 attach_xc3028 = 1;
1550 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001551 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1552 if (!use_frontend) { /* terrestrial */
1553 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1554 &tda827x_cfg_2) < 0)
1555 goto dettach_frontend;
1556 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001557 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001558 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001559 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001560 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001561 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001562 &dev->i2c_adap, 0) == NULL) {
1563 wprintk("%s: Asus Tiger 3in1, no "
1564 "tda826x found!\n", __func__);
1565 goto dettach_frontend;
1566 }
Steven Toth363c35f2008-10-11 11:05:50 -03001567 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001568 &dev->i2c_adap, 0, 0) == NULL) {
1569 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1570 " found!\n", __func__);
1571 goto dettach_frontend;
1572 }
1573 }
1574 }
1575 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001576 case SAA7134_BOARD_ASUSTeK_TIGER:
1577 if (configure_tda827x_fe(dev, &philips_tiger_config,
1578 &tda827x_cfg_0) < 0)
1579 goto dettach_frontend;
1580 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001581 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001582 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001583 &behold_h6_config,
1584 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001585 if (fe0->dvb.frontend) {
1586 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001587 &dev->i2c_adap, 0x61,
Beholder Intl. Ltd. Dmitry Belimov4786dd62009-08-04 20:07:42 -03001588 TUNER_PHILIPS_FMD1216MEX_MK3);
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001589 }
1590 break;
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -03001591 case SAA7134_BOARD_BEHOLD_X7:
1592 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1593 &behold_x7_config,
1594 &dev->i2c_adap);
1595 if (fe0->dvb.frontend) {
1596 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1597 &dev->i2c_adap, &behold_x7_tunerconfig);
1598 }
1599 break;
Dmitri Belimov0faa2ed2010-04-06 01:00:05 -03001600 case SAA7134_BOARD_BEHOLD_H7:
1601 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1602 &behold_x7_config,
1603 &dev->i2c_adap);
1604 if (fe0->dvb.frontend) {
1605 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1606 &dev->i2c_adap, &behold_x7_tunerconfig);
1607 }
1608 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001609 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1610 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1611 /* Zarlink ZL10313 */
1612 fe0->dvb.frontend = dvb_attach(mt312_attach,
1613 &avertv_a700_mt312, &dev->i2c_adap);
1614 if (fe0->dvb.frontend) {
1615 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1616 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1617 wprintk("%s: No zl10036 found!\n",
1618 __func__);
1619 }
1620 }
1621 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001622 case SAA7134_BOARD_VIDEOMATE_S350:
1623 fe0->dvb.frontend = dvb_attach(mt312_attach,
1624 &zl10313_compro_s350_config, &dev->i2c_adap);
1625 if (fe0->dvb.frontend)
1626 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1627 0x60, &dev->i2c_adap) == NULL)
1628 wprintk("%s: No zl10039 found!\n",
1629 __func__);
1630
1631 break;
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001632 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1633 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1634 &zolid_tda10048_config,
1635 &dev->i2c_adap);
1636 if (fe0->dvb.frontend != NULL) {
1637 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1638 &dev->i2c_adap, 0x4b,
1639 &tda829x_no_probe);
1640 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1641 0x60, &dev->i2c_adap,
1642 &zolid_tda18271_config);
1643 }
1644 break;
Michael Krufky184e7692009-06-05 04:28:28 -03001645 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1646 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1647 &dtv1000s_tda10048_config,
1648 &dev->i2c_adap);
1649 if (fe0->dvb.frontend != NULL) {
1650 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1651 &dev->i2c_adap, 0x4b,
1652 &tda829x_no_probe);
1653 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1654 0x60, &dev->i2c_adap,
1655 &dtv1000s_tda18271_config);
1656 }
1657 break;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001658 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
Mauro Carvalho Chehabecb71d22011-01-14 12:03:03 -03001659 /* Switch to digital mode */
1660 saa7134_tuner_callback(dev, 0,
1661 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001662 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1663 &kworld_mb86a20s_config,
1664 &dev->i2c_adap);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001665 if (fe0->dvb.frontend != NULL) {
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001666 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1667 &dev->i2c_adap, 0x4b,
1668 &tda829x_no_probe);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001669 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1670 0x60, &dev->i2c_adap,
1671 &kworld_tda18271_config);
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001672 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001673 }
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001674
1675 /* mb86a20s need to use the I2C gateway */
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001676 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001678 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679 break;
1680 }
1681
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001682 if (attach_xc3028) {
1683 struct dvb_frontend *fe;
1684 struct xc2028_config cfg = {
1685 .i2c_adap = &dev->i2c_adap,
1686 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001687 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001688
Steven Toth363c35f2008-10-11 11:05:50 -03001689 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001690 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001691
Steven Toth363c35f2008-10-11 11:05:50 -03001692 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001693 if (!fe) {
1694 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1695 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001696 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001697 }
1698 }
1699
Steven Toth363c35f2008-10-11 11:05:50 -03001700 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001701 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001702 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001704 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001705 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706
1707 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001708 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001709 &dev->pci->dev, adapter_nr, 0, NULL);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001710
1711 /* this sequence is necessary to make the tda1004x load its firmware
1712 * and to enter analog mode of hybrid boards
1713 */
1714 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001715 if (fe0->dvb.frontend->ops.init)
1716 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1717 if (fe0->dvb.frontend->ops.sleep)
1718 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1719 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1720 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001721 }
1722 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001723
1724dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001725 videobuf_dvb_dealloc_frontends(&dev->frontends);
1726 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727}
1728
1729static int dvb_fini(struct saa7134_dev *dev)
1730{
Steven Toth363c35f2008-10-11 11:05:50 -03001731 struct videobuf_dvb_frontend *fe0;
1732
1733 /* Get the first frontend */
1734 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1735 if (!fe0)
1736 return -EINVAL;
1737
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001738 /* FIXME: I suspect that this code is bogus, since the entry for
1739 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1740 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1741 */
1742 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1743 struct v4l2_priv_tun_config tda9887_cfg;
1744 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001746 tda9887_cfg.tuner = TUNER_TDA9887;
1747 tda9887_cfg.priv = &on;
1748
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001750 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001751 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001752 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001753 /* turn off the 2nd lnb supply */
1754 u8 data = 0x80;
1755 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1756 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001757 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001758 if (fe->ops.i2c_gate_ctrl) {
1759 fe->ops.i2c_gate_ctrl(fe, 1);
1760 i2c_transfer(&dev->i2c_adap, &msg, 1);
1761 fe->ops.i2c_gate_ctrl(fe, 0);
1762 }
1763 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001764 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001765 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001766 return 0;
1767}
1768
1769static struct saa7134_mpeg_ops dvb_ops = {
1770 .type = SAA7134_MPEG_DVB,
1771 .init = dvb_init,
1772 .fini = dvb_fini,
1773};
1774
1775static int __init dvb_register(void)
1776{
1777 return saa7134_ts_register(&dvb_ops);
1778}
1779
1780static void __exit dvb_unregister(void)
1781{
1782 saa7134_ts_unregister(&dvb_ops);
1783}
1784
1785module_init(dvb_register);
1786module_exit(dvb_unregister);
1787
1788/* ------------------------------------------------------------------ */
1789/*
1790 * Local variables:
1791 * c-basic-offset: 8
1792 * End:
1793 */