blob: beb95e21d1096937051823df0d88af1415dad933 [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 Krufkycb89cd332008-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"
Michael Krufky8ce47da2007-04-27 12:31:14 -030055
Dmitri Belimov47aeba52008-12-23 03:53:03 -030056#include "zl10353.h"
57
Matthias Schwarzott04574182009-02-24 12:35:16 -030058#include "zl10036.h"
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -030059#include "zl10039.h"
Matthias Schwarzott04574182009-02-24 12:35:16 -030060#include "mt312.h"
61
Linus Torvalds1da177e2005-04-16 15:20:36 -070062MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
63MODULE_LICENSE("GPL");
64
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030065static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070066
Linus Torvalds1da177e2005-04-16 15:20:36 -070067module_param(antenna_pwr, int, 0444);
68MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
69
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030070static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030071module_param(use_frontend, int, 0644);
72MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030073
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030074static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030075module_param(debug, int, 0644);
76MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
77
Janne Grunau78e92002008-04-09 19:13:13 -030078DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
79
Trent Piephocf3c34c2007-03-07 18:19:48 -030080#define dprintk(fmt, arg...) do { if (debug) \
81 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
82
83/* Print a warning */
84#define wprintk(fmt, arg...) \
85 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030086
87/* ------------------------------------------------------------------
88 * mt352 based DVB-T cards
89 */
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
92{
93 u32 ok;
94
95 if (!on) {
96 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
97 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
98 return 0;
99 }
100
101 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
102 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
103 udelay(10);
104
105 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
106 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
107 udelay(10);
108 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
109 udelay(10);
110 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300111 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113 if (!ok)
114 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
115 return ok;
116}
117
118static int mt352_pinnacle_init(struct dvb_frontend* fe)
119{
120 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
121 static u8 reset [] = { RESET, 0x80 };
122 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
123 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
124 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
125 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
126 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
127 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
128 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
129 struct saa7134_dev *dev= fe->dvb->priv;
130
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300131 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133 mt352_write(fe, clock_config, sizeof(clock_config));
134 udelay(200);
135 mt352_write(fe, reset, sizeof(reset));
136 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
137 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
138 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
139 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
140
141 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
142 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
143 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300144
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 return 0;
146}
147
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200148static int mt352_aver777_init(struct dvb_frontend* fe)
149{
150 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
151 static u8 reset [] = { RESET, 0x80 };
152 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
153 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
154 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
155
156 mt352_write(fe, clock_config, sizeof(clock_config));
157 udelay(200);
158 mt352_write(fe, reset, sizeof(reset));
159 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
160 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
161 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
162
163 return 0;
164}
165
Tim Farrington6e501a32008-06-15 13:33:42 -0300166static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300167{
Tim Farrington6e501a32008-06-15 13:33:42 -0300168 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
169 static u8 reset [] = { RESET, 0x80 };
170 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
171 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300172 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
173
174 mt352_write(fe, clock_config, sizeof(clock_config));
175 udelay(200);
176 mt352_write(fe, reset, sizeof(reset));
177 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
178 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
179 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300180 return 0;
181}
182
Andrew de Quincey0463f122006-05-16 17:22:02 -0300183static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
184 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300186 u8 off[] = { 0x00, 0xf1};
187 u8 on[] = { 0x00, 0x71};
188 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
189
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 struct saa7134_dev *dev = fe->dvb->priv;
191 struct v4l2_frequency f;
192
193 /* set frequency (mt2050) */
194 f.tuner = 0;
195 f.type = V4L2_TUNER_DIGITAL_TV;
196 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300197 if (fe->ops.i2c_gate_ctrl)
198 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300199 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300200 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300201 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300202 if (fe->ops.i2c_gate_ctrl)
203 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300204 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206 pinnacle_antenna_pwr(dev, antenna_pwr);
207
208 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300209 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210}
211
212static struct mt352_config pinnacle_300i = {
213 .demod_address = 0x3c >> 1,
214 .adc_clock = 20333,
215 .if2 = 36150,
216 .no_tuner = 1,
217 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200219
220static struct mt352_config avermedia_777 = {
221 .demod_address = 0xf,
222 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200223};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
Tim Farrington6e501a32008-06-15 13:33:42 -0300225static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300226 .demod_address = (0x1e >> 1),
227 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300228 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300229};
230
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300231/* ==================================================================
232 * tda1004x based DVB-T cards, helper functions
233 */
234
235static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
236 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700237{
238 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300239 return request_firmware(fw, name, &dev->pci->dev);
240}
241
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300242/* ------------------------------------------------------------------
243 * these tuners are tu1216, td1316(a)
244 */
245
246static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
247{
248 struct saa7134_dev *dev = fe->dvb->priv;
249 struct tda1004x_state *state = fe->demodulator_priv;
250 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700251 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800252 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700253 sizeof(tuner_buf) };
254 int tuner_frequency = 0;
255 u8 band, cp, filter;
256
257 /* determine charge pump */
258 tuner_frequency = params->frequency + 36166000;
259 if (tuner_frequency < 87000000)
260 return -EINVAL;
261 else if (tuner_frequency < 130000000)
262 cp = 3;
263 else if (tuner_frequency < 160000000)
264 cp = 5;
265 else if (tuner_frequency < 200000000)
266 cp = 6;
267 else if (tuner_frequency < 290000000)
268 cp = 3;
269 else if (tuner_frequency < 420000000)
270 cp = 5;
271 else if (tuner_frequency < 480000000)
272 cp = 6;
273 else if (tuner_frequency < 620000000)
274 cp = 3;
275 else if (tuner_frequency < 830000000)
276 cp = 5;
277 else if (tuner_frequency < 895000000)
278 cp = 7;
279 else
280 return -EINVAL;
281
282 /* determine band */
283 if (params->frequency < 49000000)
284 return -EINVAL;
285 else if (params->frequency < 161000000)
286 band = 1;
287 else if (params->frequency < 444000000)
288 band = 2;
289 else if (params->frequency < 861000000)
290 band = 4;
291 else
292 return -EINVAL;
293
294 /* setup PLL filter */
295 switch (params->u.ofdm.bandwidth) {
296 case BANDWIDTH_6_MHZ:
297 filter = 0;
298 break;
299
300 case BANDWIDTH_7_MHZ:
301 filter = 0;
302 break;
303
304 case BANDWIDTH_8_MHZ:
305 filter = 1;
306 break;
307
308 default:
309 return -EINVAL;
310 }
311
312 /* calculate divisor
313 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
314 */
315 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
316
317 /* setup tuner buffer */
318 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
319 tuner_buf[1] = tuner_frequency & 0xff;
320 tuner_buf[2] = 0xca;
321 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
322
Patrick Boettcherdea74862006-05-14 05:01:31 -0300323 if (fe->ops.i2c_gate_ctrl)
324 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300325 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300326 wprintk("could not write to tuner at addr: 0x%02x\n",
327 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700328 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300329 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700330 msleep(1);
331 return 0;
332}
333
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300334static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800335{
336 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300337 struct tda1004x_state *state = fe->demodulator_priv;
338 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800339 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
340 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
341
342 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300343 if (fe->ops.i2c_gate_ctrl)
344 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800345 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
346 return -EIO;
347 msleep(1);
348
349 return 0;
350}
351
352/* ------------------------------------------------------------------ */
353
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800354static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700355 .demod_address = 0x8,
356 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800357 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700358 .xtal_freq = TDA10046_XTAL_4M,
359 .agc_config = TDA10046_AGC_DEFAULT,
360 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300361 .tuner_address = 0x60,
362 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363};
364
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800365static struct tda1004x_config philips_tu1216_61_config = {
366
367 .demod_address = 0x8,
368 .invert = 1,
369 .invert_oclk = 0,
370 .xtal_freq = TDA10046_XTAL_4M,
371 .agc_config = TDA10046_AGC_DEFAULT,
372 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300373 .tuner_address = 0x61,
374 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800375};
376
377/* ------------------------------------------------------------------ */
378
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300379static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800380{
381 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300382 struct tda1004x_state *state = fe->demodulator_priv;
383 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800384 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300385 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800386
387 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300388 if (fe->ops.i2c_gate_ctrl)
389 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800390 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
391 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800392 return 0;
393}
394
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300395static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800396{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300397 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800398}
399
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300400static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
401{
402 struct saa7134_dev *dev = fe->dvb->priv;
403 struct tda1004x_state *state = fe->demodulator_priv;
404 u8 addr = state->config->tuner_address;
405 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
406 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
407
408 /* switch the tuner to analog mode */
409 if (fe->ops.i2c_gate_ctrl)
410 fe->ops.i2c_gate_ctrl(fe, 1);
411 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
412 return -EIO;
413 return 0;
414}
415
416/* ------------------------------------------------------------------ */
417
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300418static int philips_europa_tuner_init(struct dvb_frontend *fe)
419{
420 struct saa7134_dev *dev = fe->dvb->priv;
421 static u8 msg[] = { 0x00, 0x40};
422 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
423
424
425 if (philips_td1316_tuner_init(fe))
426 return -EIO;
427 msleep(1);
428 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
429 return -EIO;
430
431 return 0;
432}
433
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300434static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800435{
436 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800437
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300438 static u8 msg[] = { 0x00, 0x14 };
439 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
440
441 if (philips_td1316_tuner_sleep(fe))
442 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800443
444 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300445 if (fe->ops.i2c_gate_ctrl)
446 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800447 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300448 return 0;
449}
450
451static int philips_europa_demod_sleep(struct dvb_frontend *fe)
452{
453 struct saa7134_dev *dev = fe->dvb->priv;
454
455 if (dev->original_demod_sleep)
456 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300457 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300458 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800459}
460
461static struct tda1004x_config philips_europa_config = {
462
463 .demod_address = 0x8,
464 .invert = 0,
465 .invert_oclk = 0,
466 .xtal_freq = TDA10046_XTAL_4M,
467 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
468 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300469 .tuner_address = 0x61,
470 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800471};
472
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700473static struct tda1004x_config medion_cardbus = {
474 .demod_address = 0x08,
475 .invert = 1,
476 .invert_oclk = 0,
477 .xtal_freq = TDA10046_XTAL_16M,
478 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
479 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300480 .tuner_address = 0x61,
481 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700482};
483
Vadim Catana128fe952010-05-29 12:49:16 -0300484static struct tda1004x_config technotrend_budget_t3000_config = {
485 .demod_address = 0x8,
486 .invert = 1,
487 .invert_oclk = 0,
488 .xtal_freq = TDA10046_XTAL_4M,
489 .agc_config = TDA10046_AGC_DEFAULT,
490 .if_freq = TDA10046_FREQ_3617,
491 .tuner_address = 0x63,
492 .request_firmware = philips_tda1004x_request_firmware
493};
494
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300495/* ------------------------------------------------------------------
496 * tda 1004x based cards with philips silicon tuner
497 */
498
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300499static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
500{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300501 struct tda1004x_state *state = fe->demodulator_priv;
502
503 u8 addr = state->config->i2c_gate;
504 static u8 tda8290_close[] = { 0x21, 0xc0};
505 static u8 tda8290_open[] = { 0x21, 0x80};
506 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
507 if (enable) {
508 tda8290_msg.buf = tda8290_close;
509 } else {
510 tda8290_msg.buf = tda8290_open;
511 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300512 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300513 struct saa7134_dev *dev = fe->dvb->priv;
514 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300515 return -EIO;
516 }
517 msleep(20);
518 return 0;
519}
520
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300521static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300522{
523 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300524 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300525
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300526 switch (state->config->antenna_switch) {
527 case 0: break;
528 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
529 saa7134_set_gpio(dev, 21, 0);
530 break;
531 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
532 saa7134_set_gpio(dev, 21, 1);
533 break;
534 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300535 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800536}
537
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300538static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
539{
540 struct saa7134_dev *dev = fe->dvb->priv;
541 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300542
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300543 switch (state->config->antenna_switch) {
544 case 0: break;
545 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
546 saa7134_set_gpio(dev, 21, 1);
547 break;
548 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
549 saa7134_set_gpio(dev, 21, 0);
550 break;
551 }
552 return 0;
553}
554
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300555static int configure_tda827x_fe(struct saa7134_dev *dev,
556 struct tda1004x_config *cdec_conf,
557 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300558{
Steven Toth363c35f2008-10-11 11:05:50 -0300559 struct videobuf_dvb_frontend *fe0;
560
Darron Broad92abe9e2008-10-11 11:18:53 -0300561 /* Get the first frontend */
562 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300563
564 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
565 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300566 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300567 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
568 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300569 cdec_conf->tuner_address,
570 &dev->i2c_adap, tuner_conf))
571 return 0;
572
573 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300574 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300575 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300576 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300577}
578
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800579/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300580
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300581static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300582 .init = philips_tda827x_tuner_init,
583 .sleep = philips_tda827x_tuner_sleep,
584 .config = 0,
585 .switch_addr = 0
586};
587
588static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300589 .init = philips_tda827x_tuner_init,
590 .sleep = philips_tda827x_tuner_sleep,
591 .config = 1,
592 .switch_addr = 0x4b
593};
594
595static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300596 .init = philips_tda827x_tuner_init,
597 .sleep = philips_tda827x_tuner_sleep,
598 .config = 2,
599 .switch_addr = 0x4b
600};
601
602static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300603 .init = philips_tda827x_tuner_init,
604 .sleep = philips_tda827x_tuner_sleep,
605 .config = 2,
606 .switch_addr = 0x42
607};
608
609/* ------------------------------------------------------------------ */
610
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300611static struct tda1004x_config tda827x_lifeview_config = {
612 .demod_address = 0x08,
613 .invert = 1,
614 .invert_oclk = 0,
615 .xtal_freq = TDA10046_XTAL_16M,
616 .agc_config = TDA10046_AGC_TDA827X,
617 .gpio_config = TDA10046_GP11_I,
618 .if_freq = TDA10046_FREQ_045,
619 .tuner_address = 0x60,
620 .request_firmware = philips_tda1004x_request_firmware
621};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800622
623static struct tda1004x_config philips_tiger_config = {
624 .demod_address = 0x08,
625 .invert = 1,
626 .invert_oclk = 0,
627 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300628 .agc_config = TDA10046_AGC_TDA827X,
629 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300630 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300631 .i2c_gate = 0x4b,
632 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300633 .antenna_switch= 1,
634 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300635};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300636
637static struct tda1004x_config cinergy_ht_config = {
638 .demod_address = 0x08,
639 .invert = 1,
640 .invert_oclk = 0,
641 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300642 .agc_config = TDA10046_AGC_TDA827X,
643 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800644 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300645 .i2c_gate = 0x4b,
646 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300647 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800648};
649
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300650static struct tda1004x_config cinergy_ht_pci_config = {
651 .demod_address = 0x08,
652 .invert = 1,
653 .invert_oclk = 0,
654 .xtal_freq = TDA10046_XTAL_16M,
655 .agc_config = TDA10046_AGC_TDA827X,
656 .gpio_config = TDA10046_GP01_I,
657 .if_freq = TDA10046_FREQ_045,
658 .i2c_gate = 0x4b,
659 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300660 .request_firmware = philips_tda1004x_request_firmware
661};
662
663static struct tda1004x_config philips_tiger_s_config = {
664 .demod_address = 0x08,
665 .invert = 1,
666 .invert_oclk = 0,
667 .xtal_freq = TDA10046_XTAL_16M,
668 .agc_config = TDA10046_AGC_TDA827X,
669 .gpio_config = TDA10046_GP01_I,
670 .if_freq = TDA10046_FREQ_045,
671 .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
675};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200676
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300677static struct tda1004x_config pinnacle_pctv_310i_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_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300684 .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 Hackmann587d2fd2006-10-06 19:13:50 -0300688};
689
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300690static struct tda1004x_config hauppauge_hvr_1110_config = {
691 .demod_address = 0x08,
692 .invert = 1,
693 .invert_oclk = 0,
694 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300695 .agc_config = TDA10046_AGC_TDA827X,
696 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300697 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300698 .i2c_gate = 0x4b,
699 .tuner_address = 0x61,
700 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300701};
702
Hartmut Hackmann83646812006-10-12 20:38:51 -0300703static struct tda1004x_config asus_p7131_dual_config = {
704 .demod_address = 0x08,
705 .invert = 1,
706 .invert_oclk = 0,
707 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300708 .agc_config = TDA10046_AGC_TDA827X,
709 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300710 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300711 .i2c_gate = 0x4b,
712 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300713 .antenna_switch= 2,
714 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300715};
716
Nico Sabbi420f32f2006-03-03 12:11:28 -0300717static struct tda1004x_config lifeview_trio_config = {
718 .demod_address = 0x09,
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_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300724 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300725 .tuner_address = 0x60,
726 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300727};
728
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300729static struct tda1004x_config tevion_dvbt220rf_config = {
730 .demod_address = 0x08,
731 .invert = 1,
732 .invert_oclk = 0,
733 .xtal_freq = TDA10046_XTAL_16M,
734 .agc_config = TDA10046_AGC_TDA827X,
735 .gpio_config = TDA10046_GP11_I,
736 .if_freq = TDA10046_FREQ_045,
737 .tuner_address = 0x60,
738 .request_firmware = philips_tda1004x_request_firmware
739};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300740
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300741static struct tda1004x_config md8800_dvbt_config = {
742 .demod_address = 0x08,
743 .invert = 1,
744 .invert_oclk = 0,
745 .xtal_freq = TDA10046_XTAL_16M,
746 .agc_config = TDA10046_AGC_TDA827X,
747 .gpio_config = TDA10046_GP01_I,
748 .if_freq = TDA10046_FREQ_045,
749 .i2c_gate = 0x4b,
750 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300751 .request_firmware = philips_tda1004x_request_firmware
752};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200753
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300754static struct tda1004x_config asus_p7131_4871_config = {
755 .demod_address = 0x08,
756 .invert = 1,
757 .invert_oclk = 0,
758 .xtal_freq = TDA10046_XTAL_16M,
759 .agc_config = TDA10046_AGC_TDA827X,
760 .gpio_config = TDA10046_GP01_I,
761 .if_freq = TDA10046_FREQ_045,
762 .i2c_gate = 0x4b,
763 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300764 .antenna_switch= 2,
765 .request_firmware = philips_tda1004x_request_firmware
766};
767
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300768static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300769 .demod_address = 0x08,
770 .invert = 1,
771 .invert_oclk = 0,
772 .xtal_freq = TDA10046_XTAL_16M,
773 .agc_config = TDA10046_AGC_TDA827X,
774 .gpio_config = TDA10046_GP11_I,
775 .if_freq = TDA10046_FREQ_045,
776 .i2c_gate = 0x4b,
777 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300778 .antenna_switch= 2,
779 .request_firmware = philips_tda1004x_request_firmware
780};
Edgar Simo261f5082007-08-20 14:06:00 -0300781
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300782static struct tda1004x_config kworld_dvb_t_210_config = {
783 .demod_address = 0x08,
784 .invert = 1,
785 .invert_oclk = 0,
786 .xtal_freq = TDA10046_XTAL_16M,
787 .agc_config = TDA10046_AGC_TDA827X,
788 .gpio_config = TDA10046_GP11_I,
789 .if_freq = TDA10046_FREQ_045,
790 .i2c_gate = 0x4b,
791 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300792 .antenna_switch= 1,
793 .request_firmware = philips_tda1004x_request_firmware
794};
Edgar Simo261f5082007-08-20 14:06:00 -0300795
Edgar Simod90d9f52007-08-20 14:14:50 -0300796static struct tda1004x_config avermedia_super_007_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 = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300806 .antenna_switch= 1,
807 .request_firmware = philips_tda1004x_request_firmware
808};
809
Hermann Pitton4ba24372008-01-20 19:27:51 -0300810static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
811 .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_GP01_I,
817 .if_freq = TDA10046_FREQ_045,
818 .i2c_gate = 0x42,
819 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300820 .antenna_switch = 1,
821 .request_firmware = philips_tda1004x_request_firmware
822};
823
hermann pitton301e9d62008-09-14 17:49:14 -0300824static struct tda1004x_config asus_tiger_3in1_config = {
825 .demod_address = 0x0b,
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,
834 .antenna_switch = 1,
835 .request_firmware = philips_tda1004x_request_firmware
836};
837
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300838/* ------------------------------------------------------------------
839 * special case: this card uses saa713x GPIO22 for the mode switch
840 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200841
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300842static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200843{
844 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300845 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200846 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300847 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200848 return 0;
849}
850
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300851static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200852{
853 struct saa7134_dev *dev = fe->dvb->priv;
854 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300855 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300856 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300857 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200858}
859
Michael Krufky8ce47da2007-04-27 12:31:14 -0300860static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300861 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300862 .sleep = ads_duo_tuner_sleep,
863 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300864};
865
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200866static struct tda1004x_config ads_tech_duo_config = {
867 .demod_address = 0x08,
868 .invert = 1,
869 .invert_oclk = 0,
870 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300871 .agc_config = TDA10046_AGC_TDA827X,
872 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200873 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300874 .tuner_address = 0x61,
875 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200876};
877
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300878static struct zl10353_config behold_h6_config = {
879 .demod_address = 0x1e>>1,
880 .no_tuner = 1,
881 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300882 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300883};
884
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300885static struct xc5000_config behold_x7_tunerconfig = {
886 .i2c_address = 0xc2>>1,
887 .if_khz = 4560,
Devin Heitmueller2a0d0562009-09-30 23:04:39 -0300888 .radio_input = XC5000_RADIO_FM1,
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300889};
890
891static struct zl10353_config behold_x7_config = {
892 .demod_address = 0x1e>>1,
893 .if2 = 45600,
894 .no_tuner = 1,
895 .parallel_ts = 1,
896 .disable_i2c_gate_ctrl = 1,
897};
898
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300899/* ==================================================================
900 * tda10086 based DVB-S cards, helper functions
901 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300902
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300903static struct tda10086_config flydvbs = {
904 .demod_address = 0x0e,
905 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300906 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300907 .xtal_freq = TDA10086_XTAL_16M,
908};
909
910static struct tda10086_config sd1878_4m = {
911 .demod_address = 0x0e,
912 .invert = 0,
913 .diseqc_tone = 0,
914 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300915};
916
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300917/* ------------------------------------------------------------------
918 * special case: lnb supply is connected to the gated i2c
919 */
920
921static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
922{
923 int res = -EIO;
924 struct saa7134_dev *dev = fe->dvb->priv;
925 if (fe->ops.i2c_gate_ctrl) {
926 fe->ops.i2c_gate_ctrl(fe, 1);
927 if (dev->original_set_voltage)
928 res = dev->original_set_voltage(fe, voltage);
929 fe->ops.i2c_gate_ctrl(fe, 0);
930 }
931 return res;
932};
933
934static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
935{
936 int res = -EIO;
937 struct saa7134_dev *dev = fe->dvb->priv;
938 if (fe->ops.i2c_gate_ctrl) {
939 fe->ops.i2c_gate_ctrl(fe, 1);
940 if (dev->original_set_high_voltage)
941 res = dev->original_set_high_voltage(fe, arg);
942 fe->ops.i2c_gate_ctrl(fe, 0);
943 }
944 return res;
945};
946
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300947static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
948{
949 struct saa7134_dev *dev = fe->dvb->priv;
950 u8 wbuf[2] = { 0x1f, 00 };
951 u8 rbuf;
952 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
953 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
954
955 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
956 return -EIO;
957 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
958 if (voltage == SEC_VOLTAGE_18)
959 wbuf[1] = rbuf | 0x10;
960 else
961 wbuf[1] = rbuf & 0xef;
962 msg[0].len = 2;
963 i2c_transfer(&dev->i2c_adap, msg, 1);
964 return 0;
965}
966
967static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
968{
969 struct saa7134_dev *dev = fe->dvb->priv;
970 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
971 return -EIO;
972}
973
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300974/* ==================================================================
975 * nxt200x based ATSC cards, helper functions
976 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800977
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800978static struct nxt200x_config avertvhda180 = {
979 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800980};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300981
982static struct nxt200x_config kworldatsc110 = {
983 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300984};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800985
Matthias Schwarzott04574182009-02-24 12:35:16 -0300986/* ------------------------------------------------------------------ */
987
988static struct mt312_config avertv_a700_mt312 = {
989 .demod_address = 0x0e,
990 .voltage_inverted = 1,
991};
992
993static struct zl10036_config avertv_a700_tuner = {
994 .tuner_address = 0x60,
995};
996
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -0300997static struct mt312_config zl10313_compro_s350_config = {
998 .demod_address = 0x0e,
999};
1000
Michael Krufky3abdedd2009-01-19 01:10:49 -03001001static struct lgdt3305_config hcw_lgdt3305_config = {
1002 .i2c_addr = 0x0e,
1003 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1004 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1005 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1006 .deny_i2c_rptr = 1,
1007 .spectral_inversion = 1,
1008 .qam_if_khz = 4000,
1009 .vsb_if_khz = 3250,
1010};
1011
Michael Krufky1bc7f512009-01-19 01:10:49 -03001012static struct tda10048_config hcw_tda10048_config = {
1013 .demod_address = 0x10 >> 1,
1014 .output_mode = TDA10048_SERIAL_OUTPUT,
1015 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1016 .inversion = TDA10048_INVERSION_ON,
1017 .dtv6_if_freq_khz = TDA10048_IF_3300,
1018 .dtv7_if_freq_khz = TDA10048_IF_3500,
1019 .dtv8_if_freq_khz = TDA10048_IF_4000,
1020 .clk_freq_khz = TDA10048_CLK_16000,
1021 .disable_gate_access = 1,
1022};
1023
Michael Krufky3abdedd2009-01-19 01:10:49 -03001024static struct tda18271_std_map hauppauge_tda18271_std_map = {
1025 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1026 .if_lvl = 1, .rfagc_top = 0x58, },
1027 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1028 .if_lvl = 1, .rfagc_top = 0x58, },
1029};
1030
1031static struct tda18271_config hcw_tda18271_config = {
1032 .std_map = &hauppauge_tda18271_std_map,
1033 .gate = TDA18271_GATE_ANALOG,
1034 .config = 3,
Michael Krufky542cb052009-08-29 17:45:48 -03001035 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky3abdedd2009-01-19 01:10:49 -03001036};
1037
1038static struct tda829x_config tda829x_no_probe = {
1039 .probe_tuner = TDA829X_DONT_PROBE,
1040};
1041
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001042static struct tda10048_config zolid_tda10048_config = {
1043 .demod_address = 0x10 >> 1,
1044 .output_mode = TDA10048_PARALLEL_OUTPUT,
1045 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1046 .inversion = TDA10048_INVERSION_ON,
1047 .dtv6_if_freq_khz = TDA10048_IF_3300,
1048 .dtv7_if_freq_khz = TDA10048_IF_3500,
1049 .dtv8_if_freq_khz = TDA10048_IF_4000,
1050 .clk_freq_khz = TDA10048_CLK_16000,
1051 .disable_gate_access = 1,
1052};
1053
1054static struct tda18271_config zolid_tda18271_config = {
1055 .gate = TDA18271_GATE_ANALOG,
1056};
1057
Michael Krufky184e7692009-06-05 04:28:28 -03001058static struct tda10048_config dtv1000s_tda10048_config = {
1059 .demod_address = 0x10 >> 1,
1060 .output_mode = TDA10048_PARALLEL_OUTPUT,
1061 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1062 .inversion = TDA10048_INVERSION_ON,
1063 .dtv6_if_freq_khz = TDA10048_IF_3300,
1064 .dtv7_if_freq_khz = TDA10048_IF_3800,
1065 .dtv8_if_freq_khz = TDA10048_IF_4300,
1066 .clk_freq_khz = TDA10048_CLK_16000,
1067 .disable_gate_access = 1,
1068};
1069
1070static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1071 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1072 .if_lvl = 1, .rfagc_top = 0x37, },
1073 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1074 .if_lvl = 1, .rfagc_top = 0x37, },
1075 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1076 .if_lvl = 1, .rfagc_top = 0x37, },
1077};
1078
1079static struct tda18271_config dtv1000s_tda18271_config = {
1080 .std_map = &dtv1000s_tda18271_std_map,
1081 .gate = TDA18271_GATE_ANALOG,
1082};
1083
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001084/* ==================================================================
1085 * Core code
1086 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001087
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088static int dvb_init(struct saa7134_dev *dev)
1089{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001090 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001091 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001092 struct videobuf_dvb_frontend *fe0;
1093
Darron Broadf972e0b2008-10-11 11:24:30 -03001094 /* FIXME: add support for multi-frontend */
1095 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001096 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -03001097
1098 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001099 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1100 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -03001101 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1102 return -ENOMEM;
1103 }
1104
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 /* init struct videobuf_dvb */
1106 dev->ts.nr_bufs = 32;
1107 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001108 fe0->dvb.name = dev->name;
1109 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001110 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001111 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1112 V4L2_FIELD_ALTERNATE,
1113 sizeof(struct saa7134_buf),
Hans Verkuil08bff032010-09-20 17:39:46 -03001114 dev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115
1116 switch (dev->board) {
1117 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001118 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001119 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001120 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001121 if (fe0->dvb.frontend) {
1122 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001123 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001125 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001126 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001127 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001128 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001129 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001130 if (fe0->dvb.frontend) {
1131 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001132 &dev->i2c_adap, 0x61,
1133 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001134 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001135 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001136 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001137 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001138 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001139 &avermedia_xc3028_mt352_dev,
1140 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001141 attach_xc3028 = 1;
1142 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001144 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001145 &medion_cardbus,
1146 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001147 if (fe0->dvb.frontend) {
1148 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd332008-04-22 14:46:16 -03001149 &dev->i2c_adap, medion_cardbus.tuner_address,
1150 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001151 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001153 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001154 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001155 &philips_tu1216_60_config,
1156 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001157 if (fe0->dvb.frontend) {
1158 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1159 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001160 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001161 break;
1162 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001163 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001164 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1165 &tda827x_cfg_0) < 0)
1166 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001167 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001168 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001169 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Danny Woode3c6e1a2009-09-20 12:14:21 -03001170 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001171 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001172 &philips_europa_config,
1173 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001174 if (fe0->dvb.frontend) {
1175 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1176 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1177 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1178 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1179 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001180 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001181 break;
Vadim Catana128fe952010-05-29 12:49:16 -03001182 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1183 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1184 &technotrend_budget_t3000_config,
1185 &dev->i2c_adap);
1186 if (fe0->dvb.frontend) {
1187 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1188 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1189 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1190 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1191 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1192 }
1193 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001194 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001195 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001196 &philips_tu1216_61_config,
1197 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001198 if (fe0->dvb.frontend) {
1199 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1200 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001201 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001202 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001203 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001204 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1205 &tda827x_cfg_2) < 0)
1206 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001207 break;
Michael Krufky0e316ec2009-08-03 16:51:33 -03001208 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
Michael Krufky1bc7f512009-01-19 01:10:49 -03001209 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1210 &hcw_tda10048_config,
1211 &dev->i2c_adap);
1212 if (fe0->dvb.frontend != NULL) {
1213 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1214 &dev->i2c_adap, 0x4b,
1215 &tda829x_no_probe);
1216 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1217 0x60, &dev->i2c_adap,
1218 &hcw_tda18271_config);
1219 }
1220 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001221 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001222 if (configure_tda827x_fe(dev, &philips_tiger_config,
1223 &tda827x_cfg_0) < 0)
1224 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001225 break;
1226 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001227 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1228 &tda827x_cfg_1) < 0)
1229 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001230 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001231 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001232 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1233 &tda827x_cfg_1) < 0)
1234 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001235 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001236 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001237 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1238 &hcw_lgdt3305_config,
1239 &dev->i2c_adap);
1240 if (fe0->dvb.frontend) {
1241 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1242 &dev->i2c_adap, 0x4b,
1243 &tda829x_no_probe);
1244 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1245 0x60, &dev->i2c_adap,
1246 &hcw_tda18271_config);
1247 }
1248 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001249 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001250 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1251 &tda827x_cfg_0) < 0)
1252 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001253 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001254 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001255 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1256 &tda827x_cfg_0) < 0)
1257 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001258 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001259 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001260 if (!use_frontend) { /* terrestrial */
1261 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1262 &tda827x_cfg_0) < 0)
1263 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001264 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001265 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1266 if (fe0->dvb.frontend) {
1267 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001268 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001269 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001270 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001271 }
Steven Toth363c35f2008-10-11 11:05:50 -03001272 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001273 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001274 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001275 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001276 }
1277 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001278 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001279 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001280 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001281 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001282 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001283 &ads_tech_duo_config,
1284 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001285 if (fe0->dvb.frontend) {
1286 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001287 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1288 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001289 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001290 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001291 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001292 }
Mauro Carvalho Chehabbc36ec72008-06-14 10:44:04 -03001293 } else
1294 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001295 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001296 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001297 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1298 &tda827x_cfg_0) < 0)
1299 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001300 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001301 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001302 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001303 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1304 &tda827x_cfg_0) < 0)
1305 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001306 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001307 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001308 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001309 if (fe0->dvb.frontend) {
1310 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001311 u8 dev_id = dev->eedata[2];
1312 u8 data = 0xc4;
1313 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1314
Steven Toth363c35f2008-10-11 11:05:50 -03001315 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001316 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001317 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001318 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001319 goto dettach_frontend;
1320 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001321 if (dev_id != 0x08) {
1322 /* we need to open the i2c gate (we know it exists) */
1323 fe->ops.i2c_gate_ctrl(fe, 1);
1324 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001325 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001326 wprintk("%s: Medion Quadro, no ISL6405 "
1327 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001328 goto dettach_frontend;
1329 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001330 if (dev_id == 0x07) {
1331 /* fire up the 2nd section of the LNB supply since
1332 we can't do this from the other section */
1333 msg.buf = &data;
1334 i2c_transfer(&dev->i2c_adap, &msg, 1);
1335 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001336 fe->ops.i2c_gate_ctrl(fe, 0);
1337 dev->original_set_voltage = fe->ops.set_voltage;
1338 fe->ops.set_voltage = md8800_set_voltage;
1339 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1340 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1341 } else {
1342 fe->ops.set_voltage = md8800_set_voltage2;
1343 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1344 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001345 }
1346 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001347 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001348 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001349 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001350 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001351 if (fe0->dvb.frontend)
1352 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001353 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001354 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001355 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001356 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001357 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001358 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001359 if (fe0->dvb.frontend)
1360 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001361 &dev->i2c_adap, 0x61,
1362 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001363 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001364 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001365 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001366 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001367 if (fe0->dvb.frontend) {
1368 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001369 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001370 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001371 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001372 }
Steven Toth363c35f2008-10-11 11:05:50 -03001373 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001374 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001375 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001376 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001377 }
1378 }
1379 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001380 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001381 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001382 &medion_cardbus,
1383 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001384 if (fe0->dvb.frontend) {
1385 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1386 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001387
Steven Toth363c35f2008-10-11 11:05:50 -03001388 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd332008-04-22 14:46:16 -03001389 &dev->i2c_adap, medion_cardbus.tuner_address,
1390 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001391 }
1392 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001393 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001394 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001395 &philips_europa_config,
1396 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001397 if (fe0->dvb.frontend) {
1398 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1399 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001400 }
1401 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001402 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001403 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1404 &tda827x_cfg_0) < 0)
1405 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001406 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001407 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001408 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1409 &tda827x_cfg_0) < 0)
1410 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001411 break;
1412 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001413 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1414 &tda827x_cfg_2) < 0)
1415 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001416 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001417 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001418 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1419 &tda827x_cfg_2) < 0)
1420 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001421 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001422 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001423 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1424 &tda827x_cfg_2) < 0)
1425 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001426 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001427 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001428 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1429 &tda827x_cfg_0) < 0)
1430 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001431 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001432 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001433 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1434 &tda827x_cfg_2_sw42) < 0)
1435 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001436 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001437 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001438 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001439 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001440 if (fe0->dvb.frontend) {
1441 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001442 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001443 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001444 goto dettach_frontend;
1445 }
Steven Toth363c35f2008-10-11 11:05:50 -03001446 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001447 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001448 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001449 goto dettach_frontend;
1450 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001451 }
1452 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001453 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001454 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1455 &tda827x_cfg_0) < 0)
1456 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001457 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001458 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001459 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1460 &tda827x_cfg_2) < 0)
1461 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001462 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001463 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001464 dprintk("AverMedia E506R dvb setup\n");
1465 saa7134_set_gpio(dev, 25, 0);
1466 msleep(10);
1467 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001468 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001469 &avermedia_xc3028_mt352_dev,
1470 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001471 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001472 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001473 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001474 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001475 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001476 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001477 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001478 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001479 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001480 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001481 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001482 goto dettach_frontend;
1483 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001484 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001485 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001486 fe->ops.i2c_gate_ctrl(fe, 1);
1487 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001488 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001489 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001490 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001491 goto dettach_frontend;
1492 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001493 fe->ops.i2c_gate_ctrl(fe, 0);
1494 dev->original_set_voltage = fe->ops.set_voltage;
1495 fe->ops.set_voltage = md8800_set_voltage;
1496 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1497 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1498 }
1499 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001500 case SAA7134_BOARD_AVERMEDIA_M103:
1501 saa7134_set_gpio(dev, 25, 0);
1502 msleep(10);
1503 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001504 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001505 &avermedia_xc3028_mt352_dev,
1506 &dev->i2c_adap);
1507 attach_xc3028 = 1;
1508 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001509 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1510 if (!use_frontend) { /* terrestrial */
1511 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1512 &tda827x_cfg_2) < 0)
1513 goto dettach_frontend;
1514 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001515 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001516 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001517 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001518 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001519 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001520 &dev->i2c_adap, 0) == NULL) {
1521 wprintk("%s: Asus Tiger 3in1, no "
1522 "tda826x found!\n", __func__);
1523 goto dettach_frontend;
1524 }
Steven Toth363c35f2008-10-11 11:05:50 -03001525 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001526 &dev->i2c_adap, 0, 0) == NULL) {
1527 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1528 " found!\n", __func__);
1529 goto dettach_frontend;
1530 }
1531 }
1532 }
1533 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001534 case SAA7134_BOARD_ASUSTeK_TIGER:
1535 if (configure_tda827x_fe(dev, &philips_tiger_config,
1536 &tda827x_cfg_0) < 0)
1537 goto dettach_frontend;
1538 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001539 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001540 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001541 &behold_h6_config,
1542 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001543 if (fe0->dvb.frontend) {
1544 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001545 &dev->i2c_adap, 0x61,
Beholder Intl. Ltd. Dmitry Belimov4786dd62009-08-04 20:07:42 -03001546 TUNER_PHILIPS_FMD1216MEX_MK3);
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001547 }
1548 break;
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -03001549 case SAA7134_BOARD_BEHOLD_X7:
1550 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1551 &behold_x7_config,
1552 &dev->i2c_adap);
1553 if (fe0->dvb.frontend) {
1554 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1555 &dev->i2c_adap, &behold_x7_tunerconfig);
1556 }
1557 break;
Dmitri Belimov0faa2ed2010-04-06 01:00:05 -03001558 case SAA7134_BOARD_BEHOLD_H7:
1559 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1560 &behold_x7_config,
1561 &dev->i2c_adap);
1562 if (fe0->dvb.frontend) {
1563 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1564 &dev->i2c_adap, &behold_x7_tunerconfig);
1565 }
1566 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001567 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1568 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1569 /* Zarlink ZL10313 */
1570 fe0->dvb.frontend = dvb_attach(mt312_attach,
1571 &avertv_a700_mt312, &dev->i2c_adap);
1572 if (fe0->dvb.frontend) {
1573 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1574 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1575 wprintk("%s: No zl10036 found!\n",
1576 __func__);
1577 }
1578 }
1579 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001580 case SAA7134_BOARD_VIDEOMATE_S350:
1581 fe0->dvb.frontend = dvb_attach(mt312_attach,
1582 &zl10313_compro_s350_config, &dev->i2c_adap);
1583 if (fe0->dvb.frontend)
1584 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1585 0x60, &dev->i2c_adap) == NULL)
1586 wprintk("%s: No zl10039 found!\n",
1587 __func__);
1588
1589 break;
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001590 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1591 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1592 &zolid_tda10048_config,
1593 &dev->i2c_adap);
1594 if (fe0->dvb.frontend != NULL) {
1595 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1596 &dev->i2c_adap, 0x4b,
1597 &tda829x_no_probe);
1598 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1599 0x60, &dev->i2c_adap,
1600 &zolid_tda18271_config);
1601 }
1602 break;
Michael Krufky184e7692009-06-05 04:28:28 -03001603 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1604 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1605 &dtv1000s_tda10048_config,
1606 &dev->i2c_adap);
1607 if (fe0->dvb.frontend != NULL) {
1608 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1609 &dev->i2c_adap, 0x4b,
1610 &tda829x_no_probe);
1611 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1612 0x60, &dev->i2c_adap,
1613 &dtv1000s_tda18271_config);
1614 }
1615 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001616 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001617 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001618 break;
1619 }
1620
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001621 if (attach_xc3028) {
1622 struct dvb_frontend *fe;
1623 struct xc2028_config cfg = {
1624 .i2c_adap = &dev->i2c_adap,
1625 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001626 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001627
Steven Toth363c35f2008-10-11 11:05:50 -03001628 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001629 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001630
Steven Toth363c35f2008-10-11 11:05:50 -03001631 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001632 if (!fe) {
1633 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1634 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001635 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001636 }
1637 }
1638
Steven Toth363c35f2008-10-11 11:05:50 -03001639 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001640 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001641 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001643 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001644 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001645
1646 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001647 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001648 &dev->pci->dev, adapter_nr, 0, NULL);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001649
1650 /* this sequence is necessary to make the tda1004x load its firmware
1651 * and to enter analog mode of hybrid boards
1652 */
1653 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001654 if (fe0->dvb.frontend->ops.init)
1655 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1656 if (fe0->dvb.frontend->ops.sleep)
1657 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1658 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1659 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001660 }
1661 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001662
1663dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001664 videobuf_dvb_dealloc_frontends(&dev->frontends);
1665 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666}
1667
1668static int dvb_fini(struct saa7134_dev *dev)
1669{
Steven Toth363c35f2008-10-11 11:05:50 -03001670 struct videobuf_dvb_frontend *fe0;
1671
1672 /* Get the first frontend */
1673 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1674 if (!fe0)
1675 return -EINVAL;
1676
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001677 /* FIXME: I suspect that this code is bogus, since the entry for
1678 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1679 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1680 */
1681 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1682 struct v4l2_priv_tun_config tda9887_cfg;
1683 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001684
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001685 tda9887_cfg.tuner = TUNER_TDA9887;
1686 tda9887_cfg.priv = &on;
1687
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001689 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001690 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001691 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001692 /* turn off the 2nd lnb supply */
1693 u8 data = 0x80;
1694 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1695 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001696 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001697 if (fe->ops.i2c_gate_ctrl) {
1698 fe->ops.i2c_gate_ctrl(fe, 1);
1699 i2c_transfer(&dev->i2c_adap, &msg, 1);
1700 fe->ops.i2c_gate_ctrl(fe, 0);
1701 }
1702 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001703 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001704 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705 return 0;
1706}
1707
1708static struct saa7134_mpeg_ops dvb_ops = {
1709 .type = SAA7134_MPEG_DVB,
1710 .init = dvb_init,
1711 .fini = dvb_fini,
1712};
1713
1714static int __init dvb_register(void)
1715{
1716 return saa7134_ts_register(&dvb_ops);
1717}
1718
1719static void __exit dvb_unregister(void)
1720{
1721 saa7134_ts_unregister(&dvb_ops);
1722}
1723
1724module_init(dvb_register);
1725module_exit(dvb_unregister);
1726
1727/* ------------------------------------------------------------------ */
1728/*
1729 * Local variables:
1730 * c-basic-offset: 8
1731 * End:
1732 */