blob: ae0a7ecc46d9757cd810ec49552f37398b1d488c [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"
59#include "mt312.h"
60
Linus Torvalds1da177e2005-04-16 15:20:36 -070061MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
62MODULE_LICENSE("GPL");
63
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030064static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070065
Linus Torvalds1da177e2005-04-16 15:20:36 -070066module_param(antenna_pwr, int, 0444);
67MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
68
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030069static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030070module_param(use_frontend, int, 0644);
71MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030072
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030073static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030074module_param(debug, int, 0644);
75MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
76
Janne Grunau78e92002008-04-09 19:13:13 -030077DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
78
Trent Piephocf3c34c2007-03-07 18:19:48 -030079#define dprintk(fmt, arg...) do { if (debug) \
80 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
81
82/* Print a warning */
83#define wprintk(fmt, arg...) \
84 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030085
86/* ------------------------------------------------------------------
87 * mt352 based DVB-T cards
88 */
89
Linus Torvalds1da177e2005-04-16 15:20:36 -070090static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
91{
92 u32 ok;
93
94 if (!on) {
95 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
96 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
97 return 0;
98 }
99
100 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
101 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
102 udelay(10);
103
104 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
105 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
106 udelay(10);
107 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
108 udelay(10);
109 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300110 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
112 if (!ok)
113 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
114 return ok;
115}
116
117static int mt352_pinnacle_init(struct dvb_frontend* fe)
118{
119 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
120 static u8 reset [] = { RESET, 0x80 };
121 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
122 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
123 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
124 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
125 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
126 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
127 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
128 struct saa7134_dev *dev= fe->dvb->priv;
129
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300130 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132 mt352_write(fe, clock_config, sizeof(clock_config));
133 udelay(200);
134 mt352_write(fe, reset, sizeof(reset));
135 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
136 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
137 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
138 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
139
140 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
141 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
142 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 return 0;
145}
146
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200147static int mt352_aver777_init(struct dvb_frontend* fe)
148{
149 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
150 static u8 reset [] = { RESET, 0x80 };
151 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
152 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
153 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
154
155 mt352_write(fe, clock_config, sizeof(clock_config));
156 udelay(200);
157 mt352_write(fe, reset, sizeof(reset));
158 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
159 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
160 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
161
162 return 0;
163}
164
Tim Farrington6e501a32008-06-15 13:33:42 -0300165static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300166{
Tim Farrington6e501a32008-06-15 13:33:42 -0300167 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
168 static u8 reset [] = { RESET, 0x80 };
169 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
170 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300171 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
172
173 mt352_write(fe, clock_config, sizeof(clock_config));
174 udelay(200);
175 mt352_write(fe, reset, sizeof(reset));
176 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
177 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
178 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300179 return 0;
180}
181
Andrew de Quincey0463f122006-05-16 17:22:02 -0300182static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
183 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300185 u8 off[] = { 0x00, 0xf1};
186 u8 on[] = { 0x00, 0x71};
187 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
188
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 struct saa7134_dev *dev = fe->dvb->priv;
190 struct v4l2_frequency f;
191
192 /* set frequency (mt2050) */
193 f.tuner = 0;
194 f.type = V4L2_TUNER_DIGITAL_TV;
195 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300196 if (fe->ops.i2c_gate_ctrl)
197 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300198 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300199 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300200 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300201 if (fe->ops.i2c_gate_ctrl)
202 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300203 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
205 pinnacle_antenna_pwr(dev, antenna_pwr);
206
207 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300208 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209}
210
211static struct mt352_config pinnacle_300i = {
212 .demod_address = 0x3c >> 1,
213 .adc_clock = 20333,
214 .if2 = 36150,
215 .no_tuner = 1,
216 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200218
219static struct mt352_config avermedia_777 = {
220 .demod_address = 0xf,
221 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200222};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Tim Farrington6e501a32008-06-15 13:33:42 -0300224static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300225 .demod_address = (0x1e >> 1),
226 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300227 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300228};
229
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300230/* ==================================================================
231 * tda1004x based DVB-T cards, helper functions
232 */
233
234static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
235 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700236{
237 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300238 return request_firmware(fw, name, &dev->pci->dev);
239}
240
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300241/* ------------------------------------------------------------------
242 * these tuners are tu1216, td1316(a)
243 */
244
245static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
246{
247 struct saa7134_dev *dev = fe->dvb->priv;
248 struct tda1004x_state *state = fe->demodulator_priv;
249 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700250 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800251 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700252 sizeof(tuner_buf) };
253 int tuner_frequency = 0;
254 u8 band, cp, filter;
255
256 /* determine charge pump */
257 tuner_frequency = params->frequency + 36166000;
258 if (tuner_frequency < 87000000)
259 return -EINVAL;
260 else if (tuner_frequency < 130000000)
261 cp = 3;
262 else if (tuner_frequency < 160000000)
263 cp = 5;
264 else if (tuner_frequency < 200000000)
265 cp = 6;
266 else if (tuner_frequency < 290000000)
267 cp = 3;
268 else if (tuner_frequency < 420000000)
269 cp = 5;
270 else if (tuner_frequency < 480000000)
271 cp = 6;
272 else if (tuner_frequency < 620000000)
273 cp = 3;
274 else if (tuner_frequency < 830000000)
275 cp = 5;
276 else if (tuner_frequency < 895000000)
277 cp = 7;
278 else
279 return -EINVAL;
280
281 /* determine band */
282 if (params->frequency < 49000000)
283 return -EINVAL;
284 else if (params->frequency < 161000000)
285 band = 1;
286 else if (params->frequency < 444000000)
287 band = 2;
288 else if (params->frequency < 861000000)
289 band = 4;
290 else
291 return -EINVAL;
292
293 /* setup PLL filter */
294 switch (params->u.ofdm.bandwidth) {
295 case BANDWIDTH_6_MHZ:
296 filter = 0;
297 break;
298
299 case BANDWIDTH_7_MHZ:
300 filter = 0;
301 break;
302
303 case BANDWIDTH_8_MHZ:
304 filter = 1;
305 break;
306
307 default:
308 return -EINVAL;
309 }
310
311 /* calculate divisor
312 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
313 */
314 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
315
316 /* setup tuner buffer */
317 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
318 tuner_buf[1] = tuner_frequency & 0xff;
319 tuner_buf[2] = 0xca;
320 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
321
Patrick Boettcherdea74862006-05-14 05:01:31 -0300322 if (fe->ops.i2c_gate_ctrl)
323 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300324 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300325 wprintk("could not write to tuner at addr: 0x%02x\n",
326 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700327 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300328 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700329 msleep(1);
330 return 0;
331}
332
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300333static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800334{
335 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300336 struct tda1004x_state *state = fe->demodulator_priv;
337 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800338 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
339 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
340
341 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300342 if (fe->ops.i2c_gate_ctrl)
343 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800344 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
345 return -EIO;
346 msleep(1);
347
348 return 0;
349}
350
351/* ------------------------------------------------------------------ */
352
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800353static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700354 .demod_address = 0x8,
355 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800356 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700357 .xtal_freq = TDA10046_XTAL_4M,
358 .agc_config = TDA10046_AGC_DEFAULT,
359 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300360 .tuner_address = 0x60,
361 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362};
363
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800364static struct tda1004x_config philips_tu1216_61_config = {
365
366 .demod_address = 0x8,
367 .invert = 1,
368 .invert_oclk = 0,
369 .xtal_freq = TDA10046_XTAL_4M,
370 .agc_config = TDA10046_AGC_DEFAULT,
371 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300372 .tuner_address = 0x61,
373 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800374};
375
376/* ------------------------------------------------------------------ */
377
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300378static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800379{
380 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300381 struct tda1004x_state *state = fe->demodulator_priv;
382 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800383 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300384 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800385
386 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300387 if (fe->ops.i2c_gate_ctrl)
388 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800389 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
390 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800391 return 0;
392}
393
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300394static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800395{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300396 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800397}
398
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300399static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
400{
401 struct saa7134_dev *dev = fe->dvb->priv;
402 struct tda1004x_state *state = fe->demodulator_priv;
403 u8 addr = state->config->tuner_address;
404 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
405 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
406
407 /* switch the tuner to analog mode */
408 if (fe->ops.i2c_gate_ctrl)
409 fe->ops.i2c_gate_ctrl(fe, 1);
410 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
411 return -EIO;
412 return 0;
413}
414
415/* ------------------------------------------------------------------ */
416
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300417static int philips_europa_tuner_init(struct dvb_frontend *fe)
418{
419 struct saa7134_dev *dev = fe->dvb->priv;
420 static u8 msg[] = { 0x00, 0x40};
421 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
422
423
424 if (philips_td1316_tuner_init(fe))
425 return -EIO;
426 msleep(1);
427 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
428 return -EIO;
429
430 return 0;
431}
432
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300433static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800434{
435 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800436
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300437 static u8 msg[] = { 0x00, 0x14 };
438 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
439
440 if (philips_td1316_tuner_sleep(fe))
441 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800442
443 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300444 if (fe->ops.i2c_gate_ctrl)
445 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800446 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300447 return 0;
448}
449
450static int philips_europa_demod_sleep(struct dvb_frontend *fe)
451{
452 struct saa7134_dev *dev = fe->dvb->priv;
453
454 if (dev->original_demod_sleep)
455 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300456 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300457 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800458}
459
460static struct tda1004x_config philips_europa_config = {
461
462 .demod_address = 0x8,
463 .invert = 0,
464 .invert_oclk = 0,
465 .xtal_freq = TDA10046_XTAL_4M,
466 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
467 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300468 .tuner_address = 0x61,
469 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800470};
471
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700472static struct tda1004x_config medion_cardbus = {
473 .demod_address = 0x08,
474 .invert = 1,
475 .invert_oclk = 0,
476 .xtal_freq = TDA10046_XTAL_16M,
477 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
478 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300479 .tuner_address = 0x61,
480 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700481};
482
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300483/* ------------------------------------------------------------------
484 * tda 1004x based cards with philips silicon tuner
485 */
486
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300487static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
488{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300489 struct tda1004x_state *state = fe->demodulator_priv;
490
491 u8 addr = state->config->i2c_gate;
492 static u8 tda8290_close[] = { 0x21, 0xc0};
493 static u8 tda8290_open[] = { 0x21, 0x80};
494 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
495 if (enable) {
496 tda8290_msg.buf = tda8290_close;
497 } else {
498 tda8290_msg.buf = tda8290_open;
499 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300500 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300501 struct saa7134_dev *dev = fe->dvb->priv;
502 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300503 return -EIO;
504 }
505 msleep(20);
506 return 0;
507}
508
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300509static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300510{
511 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300512 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300513
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300514 switch (state->config->antenna_switch) {
515 case 0: break;
516 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
517 saa7134_set_gpio(dev, 21, 0);
518 break;
519 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
520 saa7134_set_gpio(dev, 21, 1);
521 break;
522 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300523 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800524}
525
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300526static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
527{
528 struct saa7134_dev *dev = fe->dvb->priv;
529 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300530
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300531 switch (state->config->antenna_switch) {
532 case 0: break;
533 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
534 saa7134_set_gpio(dev, 21, 1);
535 break;
536 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
537 saa7134_set_gpio(dev, 21, 0);
538 break;
539 }
540 return 0;
541}
542
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300543static int configure_tda827x_fe(struct saa7134_dev *dev,
544 struct tda1004x_config *cdec_conf,
545 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300546{
Steven Toth363c35f2008-10-11 11:05:50 -0300547 struct videobuf_dvb_frontend *fe0;
548
Darron Broad92abe9e2008-10-11 11:18:53 -0300549 /* Get the first frontend */
550 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300551
552 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
553 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300554 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300555 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
556 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300557 cdec_conf->tuner_address,
558 &dev->i2c_adap, tuner_conf))
559 return 0;
560
561 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300562 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300563 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300564 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300565}
566
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800567/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300568
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300569static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300570 .init = philips_tda827x_tuner_init,
571 .sleep = philips_tda827x_tuner_sleep,
572 .config = 0,
573 .switch_addr = 0
574};
575
576static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300577 .init = philips_tda827x_tuner_init,
578 .sleep = philips_tda827x_tuner_sleep,
579 .config = 1,
580 .switch_addr = 0x4b
581};
582
583static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300584 .init = philips_tda827x_tuner_init,
585 .sleep = philips_tda827x_tuner_sleep,
586 .config = 2,
587 .switch_addr = 0x4b
588};
589
590static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300591 .init = philips_tda827x_tuner_init,
592 .sleep = philips_tda827x_tuner_sleep,
593 .config = 2,
594 .switch_addr = 0x42
595};
596
597/* ------------------------------------------------------------------ */
598
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300599static struct tda1004x_config tda827x_lifeview_config = {
600 .demod_address = 0x08,
601 .invert = 1,
602 .invert_oclk = 0,
603 .xtal_freq = TDA10046_XTAL_16M,
604 .agc_config = TDA10046_AGC_TDA827X,
605 .gpio_config = TDA10046_GP11_I,
606 .if_freq = TDA10046_FREQ_045,
607 .tuner_address = 0x60,
608 .request_firmware = philips_tda1004x_request_firmware
609};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800610
611static struct tda1004x_config philips_tiger_config = {
612 .demod_address = 0x08,
613 .invert = 1,
614 .invert_oclk = 0,
615 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300616 .agc_config = TDA10046_AGC_TDA827X,
617 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300618 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300619 .i2c_gate = 0x4b,
620 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300621 .antenna_switch= 1,
622 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300623};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300624
625static struct tda1004x_config cinergy_ht_config = {
626 .demod_address = 0x08,
627 .invert = 1,
628 .invert_oclk = 0,
629 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300630 .agc_config = TDA10046_AGC_TDA827X,
631 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800632 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300633 .i2c_gate = 0x4b,
634 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300635 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800636};
637
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300638static struct tda1004x_config cinergy_ht_pci_config = {
639 .demod_address = 0x08,
640 .invert = 1,
641 .invert_oclk = 0,
642 .xtal_freq = TDA10046_XTAL_16M,
643 .agc_config = TDA10046_AGC_TDA827X,
644 .gpio_config = TDA10046_GP01_I,
645 .if_freq = TDA10046_FREQ_045,
646 .i2c_gate = 0x4b,
647 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300648 .request_firmware = philips_tda1004x_request_firmware
649};
650
651static struct tda1004x_config philips_tiger_s_config = {
652 .demod_address = 0x08,
653 .invert = 1,
654 .invert_oclk = 0,
655 .xtal_freq = TDA10046_XTAL_16M,
656 .agc_config = TDA10046_AGC_TDA827X,
657 .gpio_config = TDA10046_GP01_I,
658 .if_freq = TDA10046_FREQ_045,
659 .i2c_gate = 0x4b,
660 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300661 .antenna_switch= 1,
662 .request_firmware = philips_tda1004x_request_firmware
663};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200664
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300665static struct tda1004x_config pinnacle_pctv_310i_config = {
666 .demod_address = 0x08,
667 .invert = 1,
668 .invert_oclk = 0,
669 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300670 .agc_config = TDA10046_AGC_TDA827X,
671 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300672 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300673 .i2c_gate = 0x4b,
674 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300675 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300676};
677
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300678static struct tda1004x_config hauppauge_hvr_1110_config = {
679 .demod_address = 0x08,
680 .invert = 1,
681 .invert_oclk = 0,
682 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300683 .agc_config = TDA10046_AGC_TDA827X,
684 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300685 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300686 .i2c_gate = 0x4b,
687 .tuner_address = 0x61,
688 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300689};
690
Hartmut Hackmann83646812006-10-12 20:38:51 -0300691static struct tda1004x_config asus_p7131_dual_config = {
692 .demod_address = 0x08,
693 .invert = 1,
694 .invert_oclk = 0,
695 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300696 .agc_config = TDA10046_AGC_TDA827X,
697 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300698 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300699 .i2c_gate = 0x4b,
700 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300701 .antenna_switch= 2,
702 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300703};
704
Nico Sabbi420f32f2006-03-03 12:11:28 -0300705static struct tda1004x_config lifeview_trio_config = {
706 .demod_address = 0x09,
707 .invert = 1,
708 .invert_oclk = 0,
709 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300710 .agc_config = TDA10046_AGC_TDA827X,
711 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300712 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300713 .tuner_address = 0x60,
714 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300715};
716
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300717static struct tda1004x_config tevion_dvbt220rf_config = {
718 .demod_address = 0x08,
719 .invert = 1,
720 .invert_oclk = 0,
721 .xtal_freq = TDA10046_XTAL_16M,
722 .agc_config = TDA10046_AGC_TDA827X,
723 .gpio_config = TDA10046_GP11_I,
724 .if_freq = TDA10046_FREQ_045,
725 .tuner_address = 0x60,
726 .request_firmware = philips_tda1004x_request_firmware
727};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300728
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300729static struct tda1004x_config md8800_dvbt_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_GP01_I,
736 .if_freq = TDA10046_FREQ_045,
737 .i2c_gate = 0x4b,
738 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300739 .request_firmware = philips_tda1004x_request_firmware
740};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200741
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300742static struct tda1004x_config asus_p7131_4871_config = {
743 .demod_address = 0x08,
744 .invert = 1,
745 .invert_oclk = 0,
746 .xtal_freq = TDA10046_XTAL_16M,
747 .agc_config = TDA10046_AGC_TDA827X,
748 .gpio_config = TDA10046_GP01_I,
749 .if_freq = TDA10046_FREQ_045,
750 .i2c_gate = 0x4b,
751 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300752 .antenna_switch= 2,
753 .request_firmware = philips_tda1004x_request_firmware
754};
755
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300756static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300757 .demod_address = 0x08,
758 .invert = 1,
759 .invert_oclk = 0,
760 .xtal_freq = TDA10046_XTAL_16M,
761 .agc_config = TDA10046_AGC_TDA827X,
762 .gpio_config = TDA10046_GP11_I,
763 .if_freq = TDA10046_FREQ_045,
764 .i2c_gate = 0x4b,
765 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300766 .antenna_switch= 2,
767 .request_firmware = philips_tda1004x_request_firmware
768};
Edgar Simo261f5082007-08-20 14:06:00 -0300769
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300770static struct tda1004x_config kworld_dvb_t_210_config = {
771 .demod_address = 0x08,
772 .invert = 1,
773 .invert_oclk = 0,
774 .xtal_freq = TDA10046_XTAL_16M,
775 .agc_config = TDA10046_AGC_TDA827X,
776 .gpio_config = TDA10046_GP11_I,
777 .if_freq = TDA10046_FREQ_045,
778 .i2c_gate = 0x4b,
779 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300780 .antenna_switch= 1,
781 .request_firmware = philips_tda1004x_request_firmware
782};
Edgar Simo261f5082007-08-20 14:06:00 -0300783
Edgar Simod90d9f52007-08-20 14:14:50 -0300784static struct tda1004x_config avermedia_super_007_config = {
785 .demod_address = 0x08,
786 .invert = 1,
787 .invert_oclk = 0,
788 .xtal_freq = TDA10046_XTAL_16M,
789 .agc_config = TDA10046_AGC_TDA827X,
790 .gpio_config = TDA10046_GP01_I,
791 .if_freq = TDA10046_FREQ_045,
792 .i2c_gate = 0x4b,
793 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300794 .antenna_switch= 1,
795 .request_firmware = philips_tda1004x_request_firmware
796};
797
Hermann Pitton4ba24372008-01-20 19:27:51 -0300798static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
799 .demod_address = 0x08,
800 .invert = 1,
801 .invert_oclk = 0,
802 .xtal_freq = TDA10046_XTAL_16M,
803 .agc_config = TDA10046_AGC_TDA827X,
804 .gpio_config = TDA10046_GP01_I,
805 .if_freq = TDA10046_FREQ_045,
806 .i2c_gate = 0x42,
807 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300808 .antenna_switch = 1,
809 .request_firmware = philips_tda1004x_request_firmware
810};
811
hermann pitton301e9d62008-09-14 17:49:14 -0300812static struct tda1004x_config asus_tiger_3in1_config = {
813 .demod_address = 0x0b,
814 .invert = 1,
815 .invert_oclk = 0,
816 .xtal_freq = TDA10046_XTAL_16M,
817 .agc_config = TDA10046_AGC_TDA827X,
818 .gpio_config = TDA10046_GP11_I,
819 .if_freq = TDA10046_FREQ_045,
820 .i2c_gate = 0x4b,
821 .tuner_address = 0x61,
822 .antenna_switch = 1,
823 .request_firmware = philips_tda1004x_request_firmware
824};
825
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300826/* ------------------------------------------------------------------
827 * special case: this card uses saa713x GPIO22 for the mode switch
828 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200829
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300830static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200831{
832 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300833 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200834 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300835 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200836 return 0;
837}
838
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300839static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200840{
841 struct saa7134_dev *dev = fe->dvb->priv;
842 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300843 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300844 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300845 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200846}
847
Michael Krufky8ce47da2007-04-27 12:31:14 -0300848static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300849 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300850 .sleep = ads_duo_tuner_sleep,
851 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300852};
853
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200854static struct tda1004x_config ads_tech_duo_config = {
855 .demod_address = 0x08,
856 .invert = 1,
857 .invert_oclk = 0,
858 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300859 .agc_config = TDA10046_AGC_TDA827X,
860 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200861 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300862 .tuner_address = 0x61,
863 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200864};
865
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300866static struct zl10353_config behold_h6_config = {
867 .demod_address = 0x1e>>1,
868 .no_tuner = 1,
869 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300870 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300871};
872
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300873/* ==================================================================
874 * tda10086 based DVB-S cards, helper functions
875 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300876
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300877static struct tda10086_config flydvbs = {
878 .demod_address = 0x0e,
879 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300880 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300881 .xtal_freq = TDA10086_XTAL_16M,
882};
883
884static struct tda10086_config sd1878_4m = {
885 .demod_address = 0x0e,
886 .invert = 0,
887 .diseqc_tone = 0,
888 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300889};
890
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300891/* ------------------------------------------------------------------
892 * special case: lnb supply is connected to the gated i2c
893 */
894
895static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
896{
897 int res = -EIO;
898 struct saa7134_dev *dev = fe->dvb->priv;
899 if (fe->ops.i2c_gate_ctrl) {
900 fe->ops.i2c_gate_ctrl(fe, 1);
901 if (dev->original_set_voltage)
902 res = dev->original_set_voltage(fe, voltage);
903 fe->ops.i2c_gate_ctrl(fe, 0);
904 }
905 return res;
906};
907
908static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
909{
910 int res = -EIO;
911 struct saa7134_dev *dev = fe->dvb->priv;
912 if (fe->ops.i2c_gate_ctrl) {
913 fe->ops.i2c_gate_ctrl(fe, 1);
914 if (dev->original_set_high_voltage)
915 res = dev->original_set_high_voltage(fe, arg);
916 fe->ops.i2c_gate_ctrl(fe, 0);
917 }
918 return res;
919};
920
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300921static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
922{
923 struct saa7134_dev *dev = fe->dvb->priv;
924 u8 wbuf[2] = { 0x1f, 00 };
925 u8 rbuf;
926 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
927 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
928
929 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
930 return -EIO;
931 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
932 if (voltage == SEC_VOLTAGE_18)
933 wbuf[1] = rbuf | 0x10;
934 else
935 wbuf[1] = rbuf & 0xef;
936 msg[0].len = 2;
937 i2c_transfer(&dev->i2c_adap, msg, 1);
938 return 0;
939}
940
941static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
942{
943 struct saa7134_dev *dev = fe->dvb->priv;
944 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
945 return -EIO;
946}
947
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300948/* ==================================================================
949 * nxt200x based ATSC cards, helper functions
950 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800951
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800952static struct nxt200x_config avertvhda180 = {
953 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800954};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300955
956static struct nxt200x_config kworldatsc110 = {
957 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300958};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800959
Matthias Schwarzott04574182009-02-24 12:35:16 -0300960/* ------------------------------------------------------------------ */
961
962static struct mt312_config avertv_a700_mt312 = {
963 .demod_address = 0x0e,
964 .voltage_inverted = 1,
965};
966
967static struct zl10036_config avertv_a700_tuner = {
968 .tuner_address = 0x60,
969};
970
Michael Krufky3abdedd2009-01-19 01:10:49 -0300971static struct lgdt3305_config hcw_lgdt3305_config = {
972 .i2c_addr = 0x0e,
973 .mpeg_mode = LGDT3305_MPEG_SERIAL,
974 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
975 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
976 .deny_i2c_rptr = 1,
977 .spectral_inversion = 1,
978 .qam_if_khz = 4000,
979 .vsb_if_khz = 3250,
980};
981
Michael Krufky1bc7f512009-01-19 01:10:49 -0300982static struct tda10048_config hcw_tda10048_config = {
983 .demod_address = 0x10 >> 1,
984 .output_mode = TDA10048_SERIAL_OUTPUT,
985 .fwbulkwritelen = TDA10048_BULKWRITE_200,
986 .inversion = TDA10048_INVERSION_ON,
987 .dtv6_if_freq_khz = TDA10048_IF_3300,
988 .dtv7_if_freq_khz = TDA10048_IF_3500,
989 .dtv8_if_freq_khz = TDA10048_IF_4000,
990 .clk_freq_khz = TDA10048_CLK_16000,
991 .disable_gate_access = 1,
992};
993
Michael Krufky3abdedd2009-01-19 01:10:49 -0300994static struct tda18271_std_map hauppauge_tda18271_std_map = {
995 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
996 .if_lvl = 1, .rfagc_top = 0x58, },
997 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
998 .if_lvl = 1, .rfagc_top = 0x58, },
999};
1000
1001static struct tda18271_config hcw_tda18271_config = {
1002 .std_map = &hauppauge_tda18271_std_map,
1003 .gate = TDA18271_GATE_ANALOG,
1004 .config = 3,
1005};
1006
1007static struct tda829x_config tda829x_no_probe = {
1008 .probe_tuner = TDA829X_DONT_PROBE,
1009};
1010
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001011/* ==================================================================
1012 * Core code
1013 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001014
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015static int dvb_init(struct saa7134_dev *dev)
1016{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001017 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001018 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001019 struct videobuf_dvb_frontend *fe0;
1020
Darron Broadf972e0bd2008-10-11 11:24:30 -03001021 /* FIXME: add support for multi-frontend */
1022 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001023 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0bd2008-10-11 11:24:30 -03001024
1025 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001026 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1027 if (!fe0) {
Darron Broadf972e0bd2008-10-11 11:24:30 -03001028 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1029 return -ENOMEM;
1030 }
1031
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 /* init struct videobuf_dvb */
1033 dev->ts.nr_bufs = 32;
1034 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001035 fe0->dvb.name = dev->name;
1036 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001037 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1039 V4L2_FIELD_ALTERNATE,
1040 sizeof(struct saa7134_buf),
1041 dev);
1042
1043 switch (dev->board) {
1044 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001045 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001046 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001047 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001048 if (fe0->dvb.frontend) {
1049 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001050 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001052 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001053 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001054 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001055 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001056 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001057 if (fe0->dvb.frontend) {
1058 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001059 &dev->i2c_adap, 0x61,
1060 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001061 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001062 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001063 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001064 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001065 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001066 &avermedia_xc3028_mt352_dev,
1067 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001068 attach_xc3028 = 1;
1069 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001071 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001072 &medion_cardbus,
1073 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001074 if (fe0->dvb.frontend) {
1075 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001076 &dev->i2c_adap, medion_cardbus.tuner_address,
1077 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001078 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001080 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001081 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001082 &philips_tu1216_60_config,
1083 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001084 if (fe0->dvb.frontend) {
1085 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1086 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001087 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001088 break;
1089 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001090 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001091 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1092 &tda827x_cfg_0) < 0)
1093 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001094 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001095 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001096 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Steven Toth363c35f2008-10-11 11:05:50 -03001097 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001098 &philips_europa_config,
1099 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001100 if (fe0->dvb.frontend) {
1101 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1102 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1103 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1104 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1105 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001106 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001107 break;
1108 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001109 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001110 &philips_tu1216_61_config,
1111 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001112 if (fe0->dvb.frontend) {
1113 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1114 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001115 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001116 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001117 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001118 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1119 &tda827x_cfg_2) < 0)
1120 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001121 break;
Michael Krufky1bc7f512009-01-19 01:10:49 -03001122 case SAA7134_BOARD_HAUPPAUGE_HVR1110R3:
1123 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1124 &hcw_tda10048_config,
1125 &dev->i2c_adap);
1126 if (fe0->dvb.frontend != NULL) {
1127 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1128 &dev->i2c_adap, 0x4b,
1129 &tda829x_no_probe);
1130 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1131 0x60, &dev->i2c_adap,
1132 &hcw_tda18271_config);
1133 }
1134 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001135 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001136 if (configure_tda827x_fe(dev, &philips_tiger_config,
1137 &tda827x_cfg_0) < 0)
1138 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001139 break;
1140 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001141 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1142 &tda827x_cfg_1) < 0)
1143 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001144 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001145 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001146 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1147 &tda827x_cfg_1) < 0)
1148 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001149 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001150 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001151 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1152 &hcw_lgdt3305_config,
1153 &dev->i2c_adap);
1154 if (fe0->dvb.frontend) {
1155 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1156 &dev->i2c_adap, 0x4b,
1157 &tda829x_no_probe);
1158 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1159 0x60, &dev->i2c_adap,
1160 &hcw_tda18271_config);
1161 }
1162 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001163 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001164 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1165 &tda827x_cfg_0) < 0)
1166 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001167 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001168 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001169 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1170 &tda827x_cfg_0) < 0)
1171 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001172 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001173 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001174 if (!use_frontend) { /* terrestrial */
1175 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1176 &tda827x_cfg_0) < 0)
1177 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001178 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001179 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1180 if (fe0->dvb.frontend) {
1181 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001182 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001183 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001184 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001185 }
Steven Toth363c35f2008-10-11 11:05:50 -03001186 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001187 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001188 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001189 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001190 }
1191 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001192 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001193 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001194 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001195 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001196 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001197 &ads_tech_duo_config,
1198 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001199 if (fe0->dvb.frontend) {
1200 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001201 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1202 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001203 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001204 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001205 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001206 }
Mauro Carvalho Chehabbc36ec72008-06-14 10:44:04 -03001207 } else
1208 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001209 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001210 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001211 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1212 &tda827x_cfg_0) < 0)
1213 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001214 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001215 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001216 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001217 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1218 &tda827x_cfg_0) < 0)
1219 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001220 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001221 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001222 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001223 if (fe0->dvb.frontend) {
1224 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001225 u8 dev_id = dev->eedata[2];
1226 u8 data = 0xc4;
1227 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1228
Steven Toth363c35f2008-10-11 11:05:50 -03001229 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001230 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001231 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001232 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001233 goto dettach_frontend;
1234 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001235 if (dev_id != 0x08) {
1236 /* we need to open the i2c gate (we know it exists) */
1237 fe->ops.i2c_gate_ctrl(fe, 1);
1238 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001239 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001240 wprintk("%s: Medion Quadro, no ISL6405 "
1241 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001242 goto dettach_frontend;
1243 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001244 if (dev_id == 0x07) {
1245 /* fire up the 2nd section of the LNB supply since
1246 we can't do this from the other section */
1247 msg.buf = &data;
1248 i2c_transfer(&dev->i2c_adap, &msg, 1);
1249 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001250 fe->ops.i2c_gate_ctrl(fe, 0);
1251 dev->original_set_voltage = fe->ops.set_voltage;
1252 fe->ops.set_voltage = md8800_set_voltage;
1253 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1254 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1255 } else {
1256 fe->ops.set_voltage = md8800_set_voltage2;
1257 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1258 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001259 }
1260 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001261 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001262 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001263 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001264 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001265 if (fe0->dvb.frontend)
1266 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001267 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001268 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001269 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001270 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001271 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001272 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001273 if (fe0->dvb.frontend)
1274 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff817a2008-04-22 14:46:17 -03001275 &dev->i2c_adap, 0x61,
1276 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001277 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001278 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001279 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001280 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001281 if (fe0->dvb.frontend) {
1282 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001283 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001284 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001285 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001286 }
Steven Toth363c35f2008-10-11 11:05:50 -03001287 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001288 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001289 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001290 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001291 }
1292 }
1293 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001294 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001295 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001296 &medion_cardbus,
1297 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001298 if (fe0->dvb.frontend) {
1299 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1300 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001301
Steven Toth363c35f2008-10-11 11:05:50 -03001302 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001303 &dev->i2c_adap, medion_cardbus.tuner_address,
1304 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001305 }
1306 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001307 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001308 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001309 &philips_europa_config,
1310 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001311 if (fe0->dvb.frontend) {
1312 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1313 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001314 }
1315 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001316 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001317 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1318 &tda827x_cfg_0) < 0)
1319 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001320 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001321 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001322 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1323 &tda827x_cfg_0) < 0)
1324 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001325 break;
1326 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001327 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1328 &tda827x_cfg_2) < 0)
1329 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001330 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001331 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001332 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1333 &tda827x_cfg_2) < 0)
1334 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001335 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001336 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001337 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1338 &tda827x_cfg_2) < 0)
1339 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001340 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001341 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001342 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1343 &tda827x_cfg_0) < 0)
1344 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001345 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001346 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001347 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1348 &tda827x_cfg_2_sw42) < 0)
1349 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001350 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001351 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001352 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001353 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001354 if (fe0->dvb.frontend) {
1355 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001356 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001357 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001358 goto dettach_frontend;
1359 }
Steven Toth363c35f2008-10-11 11:05:50 -03001360 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001361 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001362 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001363 goto dettach_frontend;
1364 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001365 }
1366 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001367 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001368 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1369 &tda827x_cfg_0) < 0)
1370 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001371 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001372 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001373 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1374 &tda827x_cfg_2) < 0)
1375 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001376 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001377 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001378 dprintk("AverMedia E506R dvb setup\n");
1379 saa7134_set_gpio(dev, 25, 0);
1380 msleep(10);
1381 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001382 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001383 &avermedia_xc3028_mt352_dev,
1384 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001385 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001386 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001387 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001388 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001389 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001390 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001391 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001392 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001393 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001394 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001395 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001396 goto dettach_frontend;
1397 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001398 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001399 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001400 fe->ops.i2c_gate_ctrl(fe, 1);
1401 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001402 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001403 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001404 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001405 goto dettach_frontend;
1406 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001407 fe->ops.i2c_gate_ctrl(fe, 0);
1408 dev->original_set_voltage = fe->ops.set_voltage;
1409 fe->ops.set_voltage = md8800_set_voltage;
1410 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1411 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1412 }
1413 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001414 case SAA7134_BOARD_AVERMEDIA_M103:
1415 saa7134_set_gpio(dev, 25, 0);
1416 msleep(10);
1417 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001418 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001419 &avermedia_xc3028_mt352_dev,
1420 &dev->i2c_adap);
1421 attach_xc3028 = 1;
1422 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001423 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1424 if (!use_frontend) { /* terrestrial */
1425 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1426 &tda827x_cfg_2) < 0)
1427 goto dettach_frontend;
1428 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001429 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001430 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001431 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001432 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001433 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001434 &dev->i2c_adap, 0) == NULL) {
1435 wprintk("%s: Asus Tiger 3in1, no "
1436 "tda826x found!\n", __func__);
1437 goto dettach_frontend;
1438 }
Steven Toth363c35f2008-10-11 11:05:50 -03001439 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001440 &dev->i2c_adap, 0, 0) == NULL) {
1441 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1442 " found!\n", __func__);
1443 goto dettach_frontend;
1444 }
1445 }
1446 }
1447 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001448 case SAA7134_BOARD_ASUSTeK_TIGER:
1449 if (configure_tda827x_fe(dev, &philips_tiger_config,
1450 &tda827x_cfg_0) < 0)
1451 goto dettach_frontend;
1452 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001453 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001454 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001455 &behold_h6_config,
1456 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001457 if (fe0->dvb.frontend) {
1458 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001459 &dev->i2c_adap, 0x61,
1460 TUNER_PHILIPS_FMD1216ME_MK3);
1461 }
1462 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001463 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1464 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1465 /* Zarlink ZL10313 */
1466 fe0->dvb.frontend = dvb_attach(mt312_attach,
1467 &avertv_a700_mt312, &dev->i2c_adap);
1468 if (fe0->dvb.frontend) {
1469 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1470 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1471 wprintk("%s: No zl10036 found!\n",
1472 __func__);
1473 }
1474 }
1475 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001477 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 break;
1479 }
1480
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001481 if (attach_xc3028) {
1482 struct dvb_frontend *fe;
1483 struct xc2028_config cfg = {
1484 .i2c_adap = &dev->i2c_adap,
1485 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001486 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001487
Steven Toth363c35f2008-10-11 11:05:50 -03001488 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001489 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001490
Steven Toth363c35f2008-10-11 11:05:50 -03001491 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001492 if (!fe) {
1493 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1494 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001495 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001496 }
1497 }
1498
Steven Toth363c35f2008-10-11 11:05:50 -03001499 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001500 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001501 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001503 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001504 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001505
1506 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001507 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Darron Broad59b18422008-10-11 11:44:05 -03001508 &dev->pci->dev, adapter_nr, 0);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001509
1510 /* this sequence is necessary to make the tda1004x load its firmware
1511 * and to enter analog mode of hybrid boards
1512 */
1513 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001514 if (fe0->dvb.frontend->ops.init)
1515 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1516 if (fe0->dvb.frontend->ops.sleep)
1517 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1518 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1519 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001520 }
1521 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001522
1523dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001524 videobuf_dvb_dealloc_frontends(&dev->frontends);
1525 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001526}
1527
1528static int dvb_fini(struct saa7134_dev *dev)
1529{
Steven Toth363c35f2008-10-11 11:05:50 -03001530 struct videobuf_dvb_frontend *fe0;
1531
1532 /* Get the first frontend */
1533 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1534 if (!fe0)
1535 return -EINVAL;
1536
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001537 /* FIXME: I suspect that this code is bogus, since the entry for
1538 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1539 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1540 */
1541 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1542 struct v4l2_priv_tun_config tda9887_cfg;
1543 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001545 tda9887_cfg.tuner = TUNER_TDA9887;
1546 tda9887_cfg.priv = &on;
1547
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001549 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001550 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001551 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001552 /* turn off the 2nd lnb supply */
1553 u8 data = 0x80;
1554 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1555 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001556 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001557 if (fe->ops.i2c_gate_ctrl) {
1558 fe->ops.i2c_gate_ctrl(fe, 1);
1559 i2c_transfer(&dev->i2c_adap, &msg, 1);
1560 fe->ops.i2c_gate_ctrl(fe, 0);
1561 }
1562 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001563 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001564 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565 return 0;
1566}
1567
1568static struct saa7134_mpeg_ops dvb_ops = {
1569 .type = SAA7134_MPEG_DVB,
1570 .init = dvb_init,
1571 .fini = dvb_fini,
1572};
1573
1574static int __init dvb_register(void)
1575{
1576 return saa7134_ts_register(&dvb_ops);
1577}
1578
1579static void __exit dvb_unregister(void)
1580{
1581 saa7134_ts_unregister(&dvb_ops);
1582}
1583
1584module_init(dvb_register);
1585module_exit(dvb_unregister);
1586
1587/* ------------------------------------------------------------------ */
1588/*
1589 * Local variables:
1590 * c-basic-offset: 8
1591 * End:
1592 */