blob: 7e1ffd8ba26dae8e1b31ba8b5fc22b364c113e9c [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>
27#include <linux/slab.h>
28#include <linux/delay.h>
29#include <linux/kthread.h>
30#include <linux/suspend.h>
31
32#include "saa7134-reg.h"
33#include "saa7134.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020034#include <media/v4l2-common.h>
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -020035#include "dvb-pll.h"
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -030036#include <dvb_frontend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030038#include "mt352.h"
39#include "mt352_priv.h" /* FIXME */
40#include "tda1004x.h"
41#include "nxt200x.h"
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -030042#include "tuner-xc2028.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"
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
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300484/* ------------------------------------------------------------------
485 * tda 1004x based cards with philips silicon tuner
486 */
487
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300488static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
489{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300490 struct tda1004x_state *state = fe->demodulator_priv;
491
492 u8 addr = state->config->i2c_gate;
493 static u8 tda8290_close[] = { 0x21, 0xc0};
494 static u8 tda8290_open[] = { 0x21, 0x80};
495 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
496 if (enable) {
497 tda8290_msg.buf = tda8290_close;
498 } else {
499 tda8290_msg.buf = tda8290_open;
500 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300501 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300502 struct saa7134_dev *dev = fe->dvb->priv;
503 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300504 return -EIO;
505 }
506 msleep(20);
507 return 0;
508}
509
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300510static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300511{
512 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300513 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300514
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300515 switch (state->config->antenna_switch) {
516 case 0: break;
517 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
518 saa7134_set_gpio(dev, 21, 0);
519 break;
520 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
521 saa7134_set_gpio(dev, 21, 1);
522 break;
523 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300524 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800525}
526
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300527static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
528{
529 struct saa7134_dev *dev = fe->dvb->priv;
530 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300531
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300532 switch (state->config->antenna_switch) {
533 case 0: break;
534 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
535 saa7134_set_gpio(dev, 21, 1);
536 break;
537 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
538 saa7134_set_gpio(dev, 21, 0);
539 break;
540 }
541 return 0;
542}
543
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300544static int configure_tda827x_fe(struct saa7134_dev *dev,
545 struct tda1004x_config *cdec_conf,
546 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300547{
Steven Toth363c35f2008-10-11 11:05:50 -0300548 struct videobuf_dvb_frontend *fe0;
549
Darron Broad92abe9e2008-10-11 11:18:53 -0300550 /* Get the first frontend */
551 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300552
553 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
554 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300555 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300556 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
557 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300558 cdec_conf->tuner_address,
559 &dev->i2c_adap, tuner_conf))
560 return 0;
561
562 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300563 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300564 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300565 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300566}
567
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800568/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300569
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300570static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300571 .init = philips_tda827x_tuner_init,
572 .sleep = philips_tda827x_tuner_sleep,
573 .config = 0,
574 .switch_addr = 0
575};
576
577static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300578 .init = philips_tda827x_tuner_init,
579 .sleep = philips_tda827x_tuner_sleep,
580 .config = 1,
581 .switch_addr = 0x4b
582};
583
584static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300585 .init = philips_tda827x_tuner_init,
586 .sleep = philips_tda827x_tuner_sleep,
587 .config = 2,
588 .switch_addr = 0x4b
589};
590
591static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300592 .init = philips_tda827x_tuner_init,
593 .sleep = philips_tda827x_tuner_sleep,
594 .config = 2,
595 .switch_addr = 0x42
596};
597
598/* ------------------------------------------------------------------ */
599
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300600static struct tda1004x_config tda827x_lifeview_config = {
601 .demod_address = 0x08,
602 .invert = 1,
603 .invert_oclk = 0,
604 .xtal_freq = TDA10046_XTAL_16M,
605 .agc_config = TDA10046_AGC_TDA827X,
606 .gpio_config = TDA10046_GP11_I,
607 .if_freq = TDA10046_FREQ_045,
608 .tuner_address = 0x60,
609 .request_firmware = philips_tda1004x_request_firmware
610};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800611
612static struct tda1004x_config philips_tiger_config = {
613 .demod_address = 0x08,
614 .invert = 1,
615 .invert_oclk = 0,
616 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300617 .agc_config = TDA10046_AGC_TDA827X,
618 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300619 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300620 .i2c_gate = 0x4b,
621 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300622 .antenna_switch= 1,
623 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300624};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300625
626static struct tda1004x_config cinergy_ht_config = {
627 .demod_address = 0x08,
628 .invert = 1,
629 .invert_oclk = 0,
630 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300631 .agc_config = TDA10046_AGC_TDA827X,
632 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800633 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300634 .i2c_gate = 0x4b,
635 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300636 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800637};
638
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300639static struct tda1004x_config cinergy_ht_pci_config = {
640 .demod_address = 0x08,
641 .invert = 1,
642 .invert_oclk = 0,
643 .xtal_freq = TDA10046_XTAL_16M,
644 .agc_config = TDA10046_AGC_TDA827X,
645 .gpio_config = TDA10046_GP01_I,
646 .if_freq = TDA10046_FREQ_045,
647 .i2c_gate = 0x4b,
648 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300649 .request_firmware = philips_tda1004x_request_firmware
650};
651
652static struct tda1004x_config philips_tiger_s_config = {
653 .demod_address = 0x08,
654 .invert = 1,
655 .invert_oclk = 0,
656 .xtal_freq = TDA10046_XTAL_16M,
657 .agc_config = TDA10046_AGC_TDA827X,
658 .gpio_config = TDA10046_GP01_I,
659 .if_freq = TDA10046_FREQ_045,
660 .i2c_gate = 0x4b,
661 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300662 .antenna_switch= 1,
663 .request_firmware = philips_tda1004x_request_firmware
664};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200665
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300666static struct tda1004x_config pinnacle_pctv_310i_config = {
667 .demod_address = 0x08,
668 .invert = 1,
669 .invert_oclk = 0,
670 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300671 .agc_config = TDA10046_AGC_TDA827X,
672 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300673 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300674 .i2c_gate = 0x4b,
675 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300676 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300677};
678
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300679static struct tda1004x_config hauppauge_hvr_1110_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_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300686 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300687 .i2c_gate = 0x4b,
688 .tuner_address = 0x61,
689 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300690};
691
Hartmut Hackmann83646812006-10-12 20:38:51 -0300692static struct tda1004x_config asus_p7131_dual_config = {
693 .demod_address = 0x08,
694 .invert = 1,
695 .invert_oclk = 0,
696 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300697 .agc_config = TDA10046_AGC_TDA827X,
698 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300699 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300700 .i2c_gate = 0x4b,
701 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300702 .antenna_switch= 2,
703 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300704};
705
Nico Sabbi420f32f2006-03-03 12:11:28 -0300706static struct tda1004x_config lifeview_trio_config = {
707 .demod_address = 0x09,
708 .invert = 1,
709 .invert_oclk = 0,
710 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300711 .agc_config = TDA10046_AGC_TDA827X,
712 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300713 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300714 .tuner_address = 0x60,
715 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300716};
717
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300718static struct tda1004x_config tevion_dvbt220rf_config = {
719 .demod_address = 0x08,
720 .invert = 1,
721 .invert_oclk = 0,
722 .xtal_freq = TDA10046_XTAL_16M,
723 .agc_config = TDA10046_AGC_TDA827X,
724 .gpio_config = TDA10046_GP11_I,
725 .if_freq = TDA10046_FREQ_045,
726 .tuner_address = 0x60,
727 .request_firmware = philips_tda1004x_request_firmware
728};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300729
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300730static struct tda1004x_config md8800_dvbt_config = {
731 .demod_address = 0x08,
732 .invert = 1,
733 .invert_oclk = 0,
734 .xtal_freq = TDA10046_XTAL_16M,
735 .agc_config = TDA10046_AGC_TDA827X,
736 .gpio_config = TDA10046_GP01_I,
737 .if_freq = TDA10046_FREQ_045,
738 .i2c_gate = 0x4b,
739 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300740 .request_firmware = philips_tda1004x_request_firmware
741};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200742
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300743static struct tda1004x_config asus_p7131_4871_config = {
744 .demod_address = 0x08,
745 .invert = 1,
746 .invert_oclk = 0,
747 .xtal_freq = TDA10046_XTAL_16M,
748 .agc_config = TDA10046_AGC_TDA827X,
749 .gpio_config = TDA10046_GP01_I,
750 .if_freq = TDA10046_FREQ_045,
751 .i2c_gate = 0x4b,
752 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300753 .antenna_switch= 2,
754 .request_firmware = philips_tda1004x_request_firmware
755};
756
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300757static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300758 .demod_address = 0x08,
759 .invert = 1,
760 .invert_oclk = 0,
761 .xtal_freq = TDA10046_XTAL_16M,
762 .agc_config = TDA10046_AGC_TDA827X,
763 .gpio_config = TDA10046_GP11_I,
764 .if_freq = TDA10046_FREQ_045,
765 .i2c_gate = 0x4b,
766 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300767 .antenna_switch= 2,
768 .request_firmware = philips_tda1004x_request_firmware
769};
Edgar Simo261f5082007-08-20 14:06:00 -0300770
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300771static struct tda1004x_config kworld_dvb_t_210_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 .i2c_gate = 0x4b,
780 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300781 .antenna_switch= 1,
782 .request_firmware = philips_tda1004x_request_firmware
783};
Edgar Simo261f5082007-08-20 14:06:00 -0300784
Edgar Simod90d9f52007-08-20 14:14:50 -0300785static struct tda1004x_config avermedia_super_007_config = {
786 .demod_address = 0x08,
787 .invert = 1,
788 .invert_oclk = 0,
789 .xtal_freq = TDA10046_XTAL_16M,
790 .agc_config = TDA10046_AGC_TDA827X,
791 .gpio_config = TDA10046_GP01_I,
792 .if_freq = TDA10046_FREQ_045,
793 .i2c_gate = 0x4b,
794 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300795 .antenna_switch= 1,
796 .request_firmware = philips_tda1004x_request_firmware
797};
798
Hermann Pitton4ba24372008-01-20 19:27:51 -0300799static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
800 .demod_address = 0x08,
801 .invert = 1,
802 .invert_oclk = 0,
803 .xtal_freq = TDA10046_XTAL_16M,
804 .agc_config = TDA10046_AGC_TDA827X,
805 .gpio_config = TDA10046_GP01_I,
806 .if_freq = TDA10046_FREQ_045,
807 .i2c_gate = 0x42,
808 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300809 .antenna_switch = 1,
810 .request_firmware = philips_tda1004x_request_firmware
811};
812
hermann pitton301e9d62008-09-14 17:49:14 -0300813static struct tda1004x_config asus_tiger_3in1_config = {
814 .demod_address = 0x0b,
815 .invert = 1,
816 .invert_oclk = 0,
817 .xtal_freq = TDA10046_XTAL_16M,
818 .agc_config = TDA10046_AGC_TDA827X,
819 .gpio_config = TDA10046_GP11_I,
820 .if_freq = TDA10046_FREQ_045,
821 .i2c_gate = 0x4b,
822 .tuner_address = 0x61,
823 .antenna_switch = 1,
824 .request_firmware = philips_tda1004x_request_firmware
825};
826
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300827/* ------------------------------------------------------------------
828 * special case: this card uses saa713x GPIO22 for the mode switch
829 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200830
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300831static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200832{
833 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300834 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200835 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300836 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200837 return 0;
838}
839
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300840static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200841{
842 struct saa7134_dev *dev = fe->dvb->priv;
843 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300844 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300845 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300846 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200847}
848
Michael Krufky8ce47da2007-04-27 12:31:14 -0300849static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300850 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300851 .sleep = ads_duo_tuner_sleep,
852 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300853};
854
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200855static struct tda1004x_config ads_tech_duo_config = {
856 .demod_address = 0x08,
857 .invert = 1,
858 .invert_oclk = 0,
859 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300860 .agc_config = TDA10046_AGC_TDA827X,
861 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200862 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300863 .tuner_address = 0x61,
864 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200865};
866
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300867static struct zl10353_config behold_h6_config = {
868 .demod_address = 0x1e>>1,
869 .no_tuner = 1,
870 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300871 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300872};
873
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300874/* ==================================================================
875 * tda10086 based DVB-S cards, helper functions
876 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300877
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300878static struct tda10086_config flydvbs = {
879 .demod_address = 0x0e,
880 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300881 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300882 .xtal_freq = TDA10086_XTAL_16M,
883};
884
885static struct tda10086_config sd1878_4m = {
886 .demod_address = 0x0e,
887 .invert = 0,
888 .diseqc_tone = 0,
889 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300890};
891
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300892/* ------------------------------------------------------------------
893 * special case: lnb supply is connected to the gated i2c
894 */
895
896static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
897{
898 int res = -EIO;
899 struct saa7134_dev *dev = fe->dvb->priv;
900 if (fe->ops.i2c_gate_ctrl) {
901 fe->ops.i2c_gate_ctrl(fe, 1);
902 if (dev->original_set_voltage)
903 res = dev->original_set_voltage(fe, voltage);
904 fe->ops.i2c_gate_ctrl(fe, 0);
905 }
906 return res;
907};
908
909static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
910{
911 int res = -EIO;
912 struct saa7134_dev *dev = fe->dvb->priv;
913 if (fe->ops.i2c_gate_ctrl) {
914 fe->ops.i2c_gate_ctrl(fe, 1);
915 if (dev->original_set_high_voltage)
916 res = dev->original_set_high_voltage(fe, arg);
917 fe->ops.i2c_gate_ctrl(fe, 0);
918 }
919 return res;
920};
921
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300922static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
923{
924 struct saa7134_dev *dev = fe->dvb->priv;
925 u8 wbuf[2] = { 0x1f, 00 };
926 u8 rbuf;
927 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
928 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
929
930 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
931 return -EIO;
932 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
933 if (voltage == SEC_VOLTAGE_18)
934 wbuf[1] = rbuf | 0x10;
935 else
936 wbuf[1] = rbuf & 0xef;
937 msg[0].len = 2;
938 i2c_transfer(&dev->i2c_adap, msg, 1);
939 return 0;
940}
941
942static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
943{
944 struct saa7134_dev *dev = fe->dvb->priv;
945 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
946 return -EIO;
947}
948
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300949/* ==================================================================
950 * nxt200x based ATSC cards, helper functions
951 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800952
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800953static struct nxt200x_config avertvhda180 = {
954 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800955};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300956
957static struct nxt200x_config kworldatsc110 = {
958 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300959};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800960
Matthias Schwarzott04574182009-02-24 12:35:16 -0300961/* ------------------------------------------------------------------ */
962
963static struct mt312_config avertv_a700_mt312 = {
964 .demod_address = 0x0e,
965 .voltage_inverted = 1,
966};
967
968static struct zl10036_config avertv_a700_tuner = {
969 .tuner_address = 0x60,
970};
971
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -0300972static struct mt312_config zl10313_compro_s350_config = {
973 .demod_address = 0x0e,
974};
975
Michael Krufky3abdedd2009-01-19 01:10:49 -0300976static struct lgdt3305_config hcw_lgdt3305_config = {
977 .i2c_addr = 0x0e,
978 .mpeg_mode = LGDT3305_MPEG_SERIAL,
979 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
980 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
981 .deny_i2c_rptr = 1,
982 .spectral_inversion = 1,
983 .qam_if_khz = 4000,
984 .vsb_if_khz = 3250,
985};
986
Michael Krufky1bc7f512009-01-19 01:10:49 -0300987static struct tda10048_config hcw_tda10048_config = {
988 .demod_address = 0x10 >> 1,
989 .output_mode = TDA10048_SERIAL_OUTPUT,
990 .fwbulkwritelen = TDA10048_BULKWRITE_200,
991 .inversion = TDA10048_INVERSION_ON,
992 .dtv6_if_freq_khz = TDA10048_IF_3300,
993 .dtv7_if_freq_khz = TDA10048_IF_3500,
994 .dtv8_if_freq_khz = TDA10048_IF_4000,
995 .clk_freq_khz = TDA10048_CLK_16000,
996 .disable_gate_access = 1,
997};
998
Michael Krufky3abdedd2009-01-19 01:10:49 -0300999static struct tda18271_std_map hauppauge_tda18271_std_map = {
1000 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1001 .if_lvl = 1, .rfagc_top = 0x58, },
1002 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1003 .if_lvl = 1, .rfagc_top = 0x58, },
1004};
1005
1006static struct tda18271_config hcw_tda18271_config = {
1007 .std_map = &hauppauge_tda18271_std_map,
1008 .gate = TDA18271_GATE_ANALOG,
1009 .config = 3,
Michael Krufky542cb052009-08-29 17:45:48 -03001010 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky3abdedd2009-01-19 01:10:49 -03001011};
1012
1013static struct tda829x_config tda829x_no_probe = {
1014 .probe_tuner = TDA829X_DONT_PROBE,
1015};
1016
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001017/* ==================================================================
1018 * Core code
1019 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001020
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021static int dvb_init(struct saa7134_dev *dev)
1022{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001023 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001024 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001025 struct videobuf_dvb_frontend *fe0;
1026
Darron Broadf972e0b2008-10-11 11:24:30 -03001027 /* FIXME: add support for multi-frontend */
1028 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001029 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -03001030
1031 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001032 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1033 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -03001034 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1035 return -ENOMEM;
1036 }
1037
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 /* init struct videobuf_dvb */
1039 dev->ts.nr_bufs = 32;
1040 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001041 fe0->dvb.name = dev->name;
1042 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001043 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1045 V4L2_FIELD_ALTERNATE,
1046 sizeof(struct saa7134_buf),
1047 dev);
1048
1049 switch (dev->board) {
1050 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001051 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001052 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001053 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001054 if (fe0->dvb.frontend) {
1055 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001056 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001058 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001059 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001060 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001061 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001062 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001063 if (fe0->dvb.frontend) {
1064 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001065 &dev->i2c_adap, 0x61,
1066 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001067 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001068 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001069 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001070 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001071 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001072 &avermedia_xc3028_mt352_dev,
1073 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001074 attach_xc3028 = 1;
1075 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001077 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001078 &medion_cardbus,
1079 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001080 if (fe0->dvb.frontend) {
1081 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001082 &dev->i2c_adap, medion_cardbus.tuner_address,
1083 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001084 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001086 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001087 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001088 &philips_tu1216_60_config,
1089 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001090 if (fe0->dvb.frontend) {
1091 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1092 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001093 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001094 break;
1095 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001096 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001097 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1098 &tda827x_cfg_0) < 0)
1099 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001100 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001101 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001102 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Steven Toth363c35f2008-10-11 11:05:50 -03001103 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001104 &philips_europa_config,
1105 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001106 if (fe0->dvb.frontend) {
1107 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1108 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1109 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1110 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1111 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001112 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001113 break;
1114 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001115 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001116 &philips_tu1216_61_config,
1117 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001118 if (fe0->dvb.frontend) {
1119 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1120 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001121 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001122 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001123 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001124 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1125 &tda827x_cfg_2) < 0)
1126 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001127 break;
Michael Krufky0e316ec2009-08-03 16:51:33 -03001128 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
Michael Krufky1bc7f512009-01-19 01:10:49 -03001129 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1130 &hcw_tda10048_config,
1131 &dev->i2c_adap);
1132 if (fe0->dvb.frontend != NULL) {
1133 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1134 &dev->i2c_adap, 0x4b,
1135 &tda829x_no_probe);
1136 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1137 0x60, &dev->i2c_adap,
1138 &hcw_tda18271_config);
1139 }
1140 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001141 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001142 if (configure_tda827x_fe(dev, &philips_tiger_config,
1143 &tda827x_cfg_0) < 0)
1144 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001145 break;
1146 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001147 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1148 &tda827x_cfg_1) < 0)
1149 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001150 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001151 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001152 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1153 &tda827x_cfg_1) < 0)
1154 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001155 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001156 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001157 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1158 &hcw_lgdt3305_config,
1159 &dev->i2c_adap);
1160 if (fe0->dvb.frontend) {
1161 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1162 &dev->i2c_adap, 0x4b,
1163 &tda829x_no_probe);
1164 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1165 0x60, &dev->i2c_adap,
1166 &hcw_tda18271_config);
1167 }
1168 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001169 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001170 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1171 &tda827x_cfg_0) < 0)
1172 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001173 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001174 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001175 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1176 &tda827x_cfg_0) < 0)
1177 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001178 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001179 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001180 if (!use_frontend) { /* terrestrial */
1181 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1182 &tda827x_cfg_0) < 0)
1183 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001184 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001185 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1186 if (fe0->dvb.frontend) {
1187 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001188 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001189 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001190 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001191 }
Steven Toth363c35f2008-10-11 11:05:50 -03001192 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001193 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001194 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001195 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001196 }
1197 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001198 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001199 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001200 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001201 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001202 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001203 &ads_tech_duo_config,
1204 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001205 if (fe0->dvb.frontend) {
1206 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001207 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1208 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001209 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001210 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001211 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001212 }
Mauro Carvalho Chehabbc36ec7462008-06-14 10:44:04 -03001213 } else
1214 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001215 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001216 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001217 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1218 &tda827x_cfg_0) < 0)
1219 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001220 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001221 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001222 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001223 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1224 &tda827x_cfg_0) < 0)
1225 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001226 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001227 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001228 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001229 if (fe0->dvb.frontend) {
1230 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001231 u8 dev_id = dev->eedata[2];
1232 u8 data = 0xc4;
1233 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1234
Steven Toth363c35f2008-10-11 11:05:50 -03001235 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001236 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001237 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001238 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001239 goto dettach_frontend;
1240 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001241 if (dev_id != 0x08) {
1242 /* we need to open the i2c gate (we know it exists) */
1243 fe->ops.i2c_gate_ctrl(fe, 1);
1244 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001245 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001246 wprintk("%s: Medion Quadro, no ISL6405 "
1247 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001248 goto dettach_frontend;
1249 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001250 if (dev_id == 0x07) {
1251 /* fire up the 2nd section of the LNB supply since
1252 we can't do this from the other section */
1253 msg.buf = &data;
1254 i2c_transfer(&dev->i2c_adap, &msg, 1);
1255 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001256 fe->ops.i2c_gate_ctrl(fe, 0);
1257 dev->original_set_voltage = fe->ops.set_voltage;
1258 fe->ops.set_voltage = md8800_set_voltage;
1259 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1260 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1261 } else {
1262 fe->ops.set_voltage = md8800_set_voltage2;
1263 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1264 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001265 }
1266 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001267 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001268 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001269 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001270 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001271 if (fe0->dvb.frontend)
1272 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001273 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001274 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001275 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001276 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001277 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001278 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001279 if (fe0->dvb.frontend)
1280 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001281 &dev->i2c_adap, 0x61,
1282 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001283 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001284 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001285 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001286 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001287 if (fe0->dvb.frontend) {
1288 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001289 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001290 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001291 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001292 }
Steven Toth363c35f2008-10-11 11:05:50 -03001293 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001294 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001295 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001296 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001297 }
1298 }
1299 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001300 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001301 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001302 &medion_cardbus,
1303 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001304 if (fe0->dvb.frontend) {
1305 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1306 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001307
Steven Toth363c35f2008-10-11 11:05:50 -03001308 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001309 &dev->i2c_adap, medion_cardbus.tuner_address,
1310 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001311 }
1312 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001313 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001314 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001315 &philips_europa_config,
1316 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001317 if (fe0->dvb.frontend) {
1318 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1319 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001320 }
1321 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001322 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001323 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1324 &tda827x_cfg_0) < 0)
1325 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001326 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001327 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001328 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1329 &tda827x_cfg_0) < 0)
1330 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001331 break;
1332 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001333 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1334 &tda827x_cfg_2) < 0)
1335 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001336 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001337 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001338 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1339 &tda827x_cfg_2) < 0)
1340 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001341 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001342 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001343 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1344 &tda827x_cfg_2) < 0)
1345 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001346 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001347 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001348 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1349 &tda827x_cfg_0) < 0)
1350 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001351 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001352 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001353 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1354 &tda827x_cfg_2_sw42) < 0)
1355 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001356 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001357 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001358 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001359 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001360 if (fe0->dvb.frontend) {
1361 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001362 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001363 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001364 goto dettach_frontend;
1365 }
Steven Toth363c35f2008-10-11 11:05:50 -03001366 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001367 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001368 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001369 goto dettach_frontend;
1370 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001371 }
1372 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001373 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001374 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1375 &tda827x_cfg_0) < 0)
1376 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001377 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001378 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001379 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1380 &tda827x_cfg_2) < 0)
1381 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001382 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001383 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001384 dprintk("AverMedia E506R dvb setup\n");
1385 saa7134_set_gpio(dev, 25, 0);
1386 msleep(10);
1387 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001388 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001389 &avermedia_xc3028_mt352_dev,
1390 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001391 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001392 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001393 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001394 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001395 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001396 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001397 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001398 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001399 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001400 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001401 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001402 goto dettach_frontend;
1403 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001404 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001405 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001406 fe->ops.i2c_gate_ctrl(fe, 1);
1407 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001408 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001409 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001410 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001411 goto dettach_frontend;
1412 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001413 fe->ops.i2c_gate_ctrl(fe, 0);
1414 dev->original_set_voltage = fe->ops.set_voltage;
1415 fe->ops.set_voltage = md8800_set_voltage;
1416 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1417 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1418 }
1419 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001420 case SAA7134_BOARD_AVERMEDIA_M103:
1421 saa7134_set_gpio(dev, 25, 0);
1422 msleep(10);
1423 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001424 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001425 &avermedia_xc3028_mt352_dev,
1426 &dev->i2c_adap);
1427 attach_xc3028 = 1;
1428 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001429 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1430 if (!use_frontend) { /* terrestrial */
1431 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1432 &tda827x_cfg_2) < 0)
1433 goto dettach_frontend;
1434 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001435 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001436 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001437 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001438 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001439 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001440 &dev->i2c_adap, 0) == NULL) {
1441 wprintk("%s: Asus Tiger 3in1, no "
1442 "tda826x found!\n", __func__);
1443 goto dettach_frontend;
1444 }
Steven Toth363c35f2008-10-11 11:05:50 -03001445 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001446 &dev->i2c_adap, 0, 0) == NULL) {
1447 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1448 " found!\n", __func__);
1449 goto dettach_frontend;
1450 }
1451 }
1452 }
1453 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001454 case SAA7134_BOARD_ASUSTeK_TIGER:
1455 if (configure_tda827x_fe(dev, &philips_tiger_config,
1456 &tda827x_cfg_0) < 0)
1457 goto dettach_frontend;
1458 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001459 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001460 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001461 &behold_h6_config,
1462 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001463 if (fe0->dvb.frontend) {
1464 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001465 &dev->i2c_adap, 0x61,
Beholder Intl. Ltd. Dmitry Belimov4786dd62009-08-04 20:07:42 -03001466 TUNER_PHILIPS_FMD1216MEX_MK3);
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001467 }
1468 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001469 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1470 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1471 /* Zarlink ZL10313 */
1472 fe0->dvb.frontend = dvb_attach(mt312_attach,
1473 &avertv_a700_mt312, &dev->i2c_adap);
1474 if (fe0->dvb.frontend) {
1475 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1476 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1477 wprintk("%s: No zl10036 found!\n",
1478 __func__);
1479 }
1480 }
1481 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001482 case SAA7134_BOARD_VIDEOMATE_S350:
1483 fe0->dvb.frontend = dvb_attach(mt312_attach,
1484 &zl10313_compro_s350_config, &dev->i2c_adap);
1485 if (fe0->dvb.frontend)
1486 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1487 0x60, &dev->i2c_adap) == NULL)
1488 wprintk("%s: No zl10039 found!\n",
1489 __func__);
1490
1491 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001493 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 break;
1495 }
1496
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001497 if (attach_xc3028) {
1498 struct dvb_frontend *fe;
1499 struct xc2028_config cfg = {
1500 .i2c_adap = &dev->i2c_adap,
1501 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001502 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001503
Steven Toth363c35f2008-10-11 11:05:50 -03001504 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001505 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001506
Steven Toth363c35f2008-10-11 11:05:50 -03001507 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001508 if (!fe) {
1509 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1510 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001511 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001512 }
1513 }
1514
Steven Toth363c35f2008-10-11 11:05:50 -03001515 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001516 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001517 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001518 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001519 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001520 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521
1522 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001523 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Darron Broad59b18422008-10-11 11:44:05 -03001524 &dev->pci->dev, adapter_nr, 0);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001525
1526 /* this sequence is necessary to make the tda1004x load its firmware
1527 * and to enter analog mode of hybrid boards
1528 */
1529 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001530 if (fe0->dvb.frontend->ops.init)
1531 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1532 if (fe0->dvb.frontend->ops.sleep)
1533 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1534 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1535 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001536 }
1537 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001538
1539dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001540 videobuf_dvb_dealloc_frontends(&dev->frontends);
1541 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001542}
1543
1544static int dvb_fini(struct saa7134_dev *dev)
1545{
Steven Toth363c35f2008-10-11 11:05:50 -03001546 struct videobuf_dvb_frontend *fe0;
1547
1548 /* Get the first frontend */
1549 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1550 if (!fe0)
1551 return -EINVAL;
1552
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001553 /* FIXME: I suspect that this code is bogus, since the entry for
1554 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1555 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1556 */
1557 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1558 struct v4l2_priv_tun_config tda9887_cfg;
1559 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001561 tda9887_cfg.tuner = TUNER_TDA9887;
1562 tda9887_cfg.priv = &on;
1563
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001565 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001566 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001567 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001568 /* turn off the 2nd lnb supply */
1569 u8 data = 0x80;
1570 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1571 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001572 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001573 if (fe->ops.i2c_gate_ctrl) {
1574 fe->ops.i2c_gate_ctrl(fe, 1);
1575 i2c_transfer(&dev->i2c_adap, &msg, 1);
1576 fe->ops.i2c_gate_ctrl(fe, 0);
1577 }
1578 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001579 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001580 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581 return 0;
1582}
1583
1584static struct saa7134_mpeg_ops dvb_ops = {
1585 .type = SAA7134_MPEG_DVB,
1586 .init = dvb_init,
1587 .fini = dvb_fini,
1588};
1589
1590static int __init dvb_register(void)
1591{
1592 return saa7134_ts_register(&dvb_ops);
1593}
1594
1595static void __exit dvb_unregister(void)
1596{
1597 saa7134_ts_unregister(&dvb_ops);
1598}
1599
1600module_init(dvb_register);
1601module_exit(dvb_unregister);
1602
1603/* ------------------------------------------------------------------ */
1604/*
1605 * Local variables:
1606 * c-basic-offset: 8
1607 * End:
1608 */