blob: a29d800616b17a09baec8f1959de910bcd731f4e [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"
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030037#include "mt352.h"
38#include "mt352_priv.h" /* FIXME */
39#include "tda1004x.h"
40#include "nxt200x.h"
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -030041#include "tuner-xc2028.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070042
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030043#include "tda10086.h"
44#include "tda826x.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030045#include "tda827x.h"
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030046#include "isl6421.h"
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -030047#include "isl6405.h"
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -030048#include "lnbp21.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030049
Linus Torvalds1da177e2005-04-16 15:20:36 -070050MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
51MODULE_LICENSE("GPL");
52
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030053static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070054
Linus Torvalds1da177e2005-04-16 15:20:36 -070055module_param(antenna_pwr, int, 0444);
56MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
57
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030058static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030059module_param(use_frontend, int, 0644);
60MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030061
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030062static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030063module_param(debug, int, 0644);
64MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
65
Trent Piephocf3c34c2007-03-07 18:19:48 -030066#define dprintk(fmt, arg...) do { if (debug) \
67 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
68
69/* Print a warning */
70#define wprintk(fmt, arg...) \
71 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030072
73/* ------------------------------------------------------------------
74 * mt352 based DVB-T cards
75 */
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
78{
79 u32 ok;
80
81 if (!on) {
82 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
83 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
84 return 0;
85 }
86
87 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
88 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
89 udelay(10);
90
91 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
92 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
93 udelay(10);
94 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
95 udelay(10);
96 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Trent Piephocf3c34c2007-03-07 18:19:48 -030097 dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -070098
99 if (!ok)
100 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
101 return ok;
102}
103
104static int mt352_pinnacle_init(struct dvb_frontend* fe)
105{
106 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
107 static u8 reset [] = { RESET, 0x80 };
108 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
109 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
110 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
111 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
112 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
113 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
114 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
115 struct saa7134_dev *dev= fe->dvb->priv;
116
Trent Piephocf3c34c2007-03-07 18:19:48 -0300117 dprintk("%s called\n", __FUNCTION__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119 mt352_write(fe, clock_config, sizeof(clock_config));
120 udelay(200);
121 mt352_write(fe, reset, sizeof(reset));
122 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
123 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
124 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
125 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
126
127 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
128 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
129 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 return 0;
132}
133
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200134static int mt352_aver777_init(struct dvb_frontend* fe)
135{
136 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
137 static u8 reset [] = { RESET, 0x80 };
138 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
139 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
140 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
141
142 mt352_write(fe, clock_config, sizeof(clock_config));
143 udelay(200);
144 mt352_write(fe, reset, sizeof(reset));
145 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
146 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
147 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
148
149 return 0;
150}
151
Andrew de Quincey0463f122006-05-16 17:22:02 -0300152static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
153 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300155 u8 off[] = { 0x00, 0xf1};
156 u8 on[] = { 0x00, 0x71};
157 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
158
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 struct saa7134_dev *dev = fe->dvb->priv;
160 struct v4l2_frequency f;
161
162 /* set frequency (mt2050) */
163 f.tuner = 0;
164 f.type = V4L2_TUNER_DIGITAL_TV;
165 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300166 if (fe->ops.i2c_gate_ctrl)
167 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300168 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300170 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300171 if (fe->ops.i2c_gate_ctrl)
172 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300173 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175 pinnacle_antenna_pwr(dev, antenna_pwr);
176
177 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300178 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179}
180
181static struct mt352_config pinnacle_300i = {
182 .demod_address = 0x3c >> 1,
183 .adc_clock = 20333,
184 .if2 = 36150,
185 .no_tuner = 1,
186 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200188
189static struct mt352_config avermedia_777 = {
190 .demod_address = 0xf,
191 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200192};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300194static struct mt352_config avermedia_e506r_mt352_dev = {
195 .demod_address = (0x1e >> 1),
196 .no_tuner = 1,
197};
198
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300199/* ==================================================================
200 * tda1004x based DVB-T cards, helper functions
201 */
202
203static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
204 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700205{
206 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300207 return request_firmware(fw, name, &dev->pci->dev);
208}
209
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300210/* ------------------------------------------------------------------
211 * these tuners are tu1216, td1316(a)
212 */
213
214static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
215{
216 struct saa7134_dev *dev = fe->dvb->priv;
217 struct tda1004x_state *state = fe->demodulator_priv;
218 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700219 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800220 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700221 sizeof(tuner_buf) };
222 int tuner_frequency = 0;
223 u8 band, cp, filter;
224
225 /* determine charge pump */
226 tuner_frequency = params->frequency + 36166000;
227 if (tuner_frequency < 87000000)
228 return -EINVAL;
229 else if (tuner_frequency < 130000000)
230 cp = 3;
231 else if (tuner_frequency < 160000000)
232 cp = 5;
233 else if (tuner_frequency < 200000000)
234 cp = 6;
235 else if (tuner_frequency < 290000000)
236 cp = 3;
237 else if (tuner_frequency < 420000000)
238 cp = 5;
239 else if (tuner_frequency < 480000000)
240 cp = 6;
241 else if (tuner_frequency < 620000000)
242 cp = 3;
243 else if (tuner_frequency < 830000000)
244 cp = 5;
245 else if (tuner_frequency < 895000000)
246 cp = 7;
247 else
248 return -EINVAL;
249
250 /* determine band */
251 if (params->frequency < 49000000)
252 return -EINVAL;
253 else if (params->frequency < 161000000)
254 band = 1;
255 else if (params->frequency < 444000000)
256 band = 2;
257 else if (params->frequency < 861000000)
258 band = 4;
259 else
260 return -EINVAL;
261
262 /* setup PLL filter */
263 switch (params->u.ofdm.bandwidth) {
264 case BANDWIDTH_6_MHZ:
265 filter = 0;
266 break;
267
268 case BANDWIDTH_7_MHZ:
269 filter = 0;
270 break;
271
272 case BANDWIDTH_8_MHZ:
273 filter = 1;
274 break;
275
276 default:
277 return -EINVAL;
278 }
279
280 /* calculate divisor
281 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
282 */
283 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
284
285 /* setup tuner buffer */
286 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
287 tuner_buf[1] = tuner_frequency & 0xff;
288 tuner_buf[2] = 0xca;
289 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
290
Patrick Boettcherdea74862006-05-14 05:01:31 -0300291 if (fe->ops.i2c_gate_ctrl)
292 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300293 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300294 wprintk("could not write to tuner at addr: 0x%02x\n",
295 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700296 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300297 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700298 msleep(1);
299 return 0;
300}
301
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300302static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800303{
304 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300305 struct tda1004x_state *state = fe->demodulator_priv;
306 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800307 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
308 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
309
310 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300311 if (fe->ops.i2c_gate_ctrl)
312 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800313 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
314 return -EIO;
315 msleep(1);
316
317 return 0;
318}
319
320/* ------------------------------------------------------------------ */
321
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800322static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700323 .demod_address = 0x8,
324 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800325 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700326 .xtal_freq = TDA10046_XTAL_4M,
327 .agc_config = TDA10046_AGC_DEFAULT,
328 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300329 .tuner_address = 0x60,
330 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331};
332
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800333static struct tda1004x_config philips_tu1216_61_config = {
334
335 .demod_address = 0x8,
336 .invert = 1,
337 .invert_oclk = 0,
338 .xtal_freq = TDA10046_XTAL_4M,
339 .agc_config = TDA10046_AGC_DEFAULT,
340 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300341 .tuner_address = 0x61,
342 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800343};
344
345/* ------------------------------------------------------------------ */
346
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300347static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800348{
349 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300350 struct tda1004x_state *state = fe->demodulator_priv;
351 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800352 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300353 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800354
355 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300356 if (fe->ops.i2c_gate_ctrl)
357 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800358 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
359 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800360 return 0;
361}
362
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300363static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800364{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300365 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800366}
367
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300368static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
369{
370 struct saa7134_dev *dev = fe->dvb->priv;
371 struct tda1004x_state *state = fe->demodulator_priv;
372 u8 addr = state->config->tuner_address;
373 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
374 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
375
376 /* switch the tuner to analog mode */
377 if (fe->ops.i2c_gate_ctrl)
378 fe->ops.i2c_gate_ctrl(fe, 1);
379 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
380 return -EIO;
381 return 0;
382}
383
384/* ------------------------------------------------------------------ */
385
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300386static int philips_europa_tuner_init(struct dvb_frontend *fe)
387{
388 struct saa7134_dev *dev = fe->dvb->priv;
389 static u8 msg[] = { 0x00, 0x40};
390 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
391
392
393 if (philips_td1316_tuner_init(fe))
394 return -EIO;
395 msleep(1);
396 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
397 return -EIO;
398
399 return 0;
400}
401
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300402static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800403{
404 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800405
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300406 static u8 msg[] = { 0x00, 0x14 };
407 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
408
409 if (philips_td1316_tuner_sleep(fe))
410 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800411
412 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300413 if (fe->ops.i2c_gate_ctrl)
414 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800415 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300416 return 0;
417}
418
419static int philips_europa_demod_sleep(struct dvb_frontend *fe)
420{
421 struct saa7134_dev *dev = fe->dvb->priv;
422
423 if (dev->original_demod_sleep)
424 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300425 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300426 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800427}
428
429static struct tda1004x_config philips_europa_config = {
430
431 .demod_address = 0x8,
432 .invert = 0,
433 .invert_oclk = 0,
434 .xtal_freq = TDA10046_XTAL_4M,
435 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
436 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300437 .tuner_address = 0x61,
438 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800439};
440
441/* ------------------------------------------------------------------ */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700442
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700443static struct tda1004x_config medion_cardbus = {
444 .demod_address = 0x08,
445 .invert = 1,
446 .invert_oclk = 0,
447 .xtal_freq = TDA10046_XTAL_16M,
448 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
449 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300450 .tuner_address = 0x61,
451 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700452};
453
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300454/* ------------------------------------------------------------------
455 * tda 1004x based cards with philips silicon tuner
456 */
457
458static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
459{
460 struct saa7134_dev *dev = fe->dvb->priv;
461 struct tda1004x_state *state = fe->demodulator_priv;
462 u8 addr = state->config->i2c_gate;
463 u8 config = state->config->tuner_config;
464 u8 GP00_CF[] = {0x20, 0x01};
465 u8 GP00_LEV[] = {0x22, 0x00};
466
467 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
468 if (config) {
469 if (high) {
470 dprintk("setting LNA to high gain\n");
471 } else {
472 dprintk("setting LNA to low gain\n");
473 }
474 }
475 switch (config) {
476 case 0: /* no LNA */
477 break;
478 case 1: /* switch is GPIO 0 of tda8290 */
479 case 2:
480 /* turn Vsync off */
481 saa7134_set_gpio(dev, 22, 0);
482 GP00_LEV[1] = high ? 0 : 1;
483 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300484 wprintk("could not access tda8290 at addr: 0x%02x\n",
485 addr << 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300486 return;
487 }
488 msg.buf = GP00_LEV;
489 if (config == 2)
490 GP00_LEV[1] = high ? 1 : 0;
491 i2c_transfer(&dev->i2c_adap, &msg, 1);
492 break;
493 case 3: /* switch with GPIO of saa713x */
494 saa7134_set_gpio(dev, 22, high);
495 break;
496 }
497}
498
499static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
500{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300501 struct tda1004x_state *state = fe->demodulator_priv;
502
503 u8 addr = state->config->i2c_gate;
504 static u8 tda8290_close[] = { 0x21, 0xc0};
505 static u8 tda8290_open[] = { 0x21, 0x80};
506 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
507 if (enable) {
508 tda8290_msg.buf = tda8290_close;
509 } else {
510 tda8290_msg.buf = tda8290_open;
511 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300512 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300513 struct saa7134_dev *dev = fe->dvb->priv;
514 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300515 return -EIO;
516 }
517 msleep(20);
518 return 0;
519}
520
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700521/* ------------------------------------------------------------------ */
522
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300523static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300524{
525 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300526 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300527
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300528 switch (state->config->antenna_switch) {
529 case 0: break;
530 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
531 saa7134_set_gpio(dev, 21, 0);
532 break;
533 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
534 saa7134_set_gpio(dev, 21, 1);
535 break;
536 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300537 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800538}
539
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300540static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
541{
542 struct saa7134_dev *dev = fe->dvb->priv;
543 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300544
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300545 switch (state->config->antenna_switch) {
546 case 0: break;
547 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
548 saa7134_set_gpio(dev, 21, 1);
549 break;
550 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
551 saa7134_set_gpio(dev, 21, 0);
552 break;
553 }
554 return 0;
555}
556
Michael Krufky8ce47da2007-04-27 12:31:14 -0300557static struct tda827x_config tda827x_cfg = {
558 .lna_gain = philips_tda827x_lna_gain,
559 .init = philips_tda827x_tuner_init,
560 .sleep = philips_tda827x_tuner_sleep
561};
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300562
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300563static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300564{
565 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
566 if (dev->dvb.frontend) {
567 if (tda_conf->i2c_gate)
568 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
Hartmut Hackmannede22002007-04-27 12:31:32 -0300569 if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
570 &dev->i2c_adap,&tda827x_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300571 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -0300572 tda_conf->tuner_address);
573 }
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300574 }
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300575}
576
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800577/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300578
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300579static struct tda1004x_config tda827x_lifeview_config = {
580 .demod_address = 0x08,
581 .invert = 1,
582 .invert_oclk = 0,
583 .xtal_freq = TDA10046_XTAL_16M,
584 .agc_config = TDA10046_AGC_TDA827X,
585 .gpio_config = TDA10046_GP11_I,
586 .if_freq = TDA10046_FREQ_045,
587 .tuner_address = 0x60,
588 .request_firmware = philips_tda1004x_request_firmware
589};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800590
591static struct tda1004x_config philips_tiger_config = {
592 .demod_address = 0x08,
593 .invert = 1,
594 .invert_oclk = 0,
595 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300596 .agc_config = TDA10046_AGC_TDA827X,
597 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300598 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300599 .i2c_gate = 0x4b,
600 .tuner_address = 0x61,
601 .tuner_config = 0,
602 .antenna_switch= 1,
603 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300604};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300605
606static struct tda1004x_config cinergy_ht_config = {
607 .demod_address = 0x08,
608 .invert = 1,
609 .invert_oclk = 0,
610 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300611 .agc_config = TDA10046_AGC_TDA827X,
612 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800613 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300614 .i2c_gate = 0x4b,
615 .tuner_address = 0x61,
616 .tuner_config = 0,
617 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800618};
619
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300620static struct tda1004x_config cinergy_ht_pci_config = {
621 .demod_address = 0x08,
622 .invert = 1,
623 .invert_oclk = 0,
624 .xtal_freq = TDA10046_XTAL_16M,
625 .agc_config = TDA10046_AGC_TDA827X,
626 .gpio_config = TDA10046_GP01_I,
627 .if_freq = TDA10046_FREQ_045,
628 .i2c_gate = 0x4b,
629 .tuner_address = 0x60,
630 .tuner_config = 0,
631 .request_firmware = philips_tda1004x_request_firmware
632};
633
634static struct tda1004x_config philips_tiger_s_config = {
635 .demod_address = 0x08,
636 .invert = 1,
637 .invert_oclk = 0,
638 .xtal_freq = TDA10046_XTAL_16M,
639 .agc_config = TDA10046_AGC_TDA827X,
640 .gpio_config = TDA10046_GP01_I,
641 .if_freq = TDA10046_FREQ_045,
642 .i2c_gate = 0x4b,
643 .tuner_address = 0x61,
644 .tuner_config = 2,
645 .antenna_switch= 1,
646 .request_firmware = philips_tda1004x_request_firmware
647};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200648
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300649static struct tda1004x_config pinnacle_pctv_310i_config = {
650 .demod_address = 0x08,
651 .invert = 1,
652 .invert_oclk = 0,
653 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300654 .agc_config = TDA10046_AGC_TDA827X,
655 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300656 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300657 .i2c_gate = 0x4b,
658 .tuner_address = 0x61,
659 .tuner_config = 1,
660 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300661};
662
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300663static struct tda1004x_config hauppauge_hvr_1110_config = {
664 .demod_address = 0x08,
665 .invert = 1,
666 .invert_oclk = 0,
667 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300668 .agc_config = TDA10046_AGC_TDA827X,
669 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300670 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300671 .i2c_gate = 0x4b,
672 .tuner_address = 0x61,
Benoit Istinbc548372007-12-07 02:00:04 -0300673 .tuner_config = 1,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300674 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300675};
676
Hartmut Hackmann83646812006-10-12 20:38:51 -0300677static struct tda1004x_config asus_p7131_dual_config = {
678 .demod_address = 0x08,
679 .invert = 1,
680 .invert_oclk = 0,
681 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300682 .agc_config = TDA10046_AGC_TDA827X,
683 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300684 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300685 .i2c_gate = 0x4b,
686 .tuner_address = 0x61,
687 .tuner_config = 0,
688 .antenna_switch= 2,
689 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300690};
691
Nico Sabbi420f32f2006-03-03 12:11:28 -0300692static struct tda1004x_config lifeview_trio_config = {
693 .demod_address = 0x09,
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_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300699 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300700 .tuner_address = 0x60,
701 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300702};
703
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300704static struct tda1004x_config tevion_dvbt220rf_config = {
705 .demod_address = 0x08,
706 .invert = 1,
707 .invert_oclk = 0,
708 .xtal_freq = TDA10046_XTAL_16M,
709 .agc_config = TDA10046_AGC_TDA827X,
710 .gpio_config = TDA10046_GP11_I,
711 .if_freq = TDA10046_FREQ_045,
712 .tuner_address = 0x60,
713 .request_firmware = philips_tda1004x_request_firmware
714};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300715
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300716static struct tda1004x_config md8800_dvbt_config = {
717 .demod_address = 0x08,
718 .invert = 1,
719 .invert_oclk = 0,
720 .xtal_freq = TDA10046_XTAL_16M,
721 .agc_config = TDA10046_AGC_TDA827X,
722 .gpio_config = TDA10046_GP01_I,
723 .if_freq = TDA10046_FREQ_045,
724 .i2c_gate = 0x4b,
725 .tuner_address = 0x60,
726 .tuner_config = 0,
727 .request_firmware = philips_tda1004x_request_firmware
728};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200729
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300730static struct tda1004x_config asus_p7131_4871_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 = 0x61,
740 .tuner_config = 2,
741 .antenna_switch= 2,
742 .request_firmware = philips_tda1004x_request_firmware
743};
744
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300745static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300746 .demod_address = 0x08,
747 .invert = 1,
748 .invert_oclk = 0,
749 .xtal_freq = TDA10046_XTAL_16M,
750 .agc_config = TDA10046_AGC_TDA827X,
751 .gpio_config = TDA10046_GP11_I,
752 .if_freq = TDA10046_FREQ_045,
753 .i2c_gate = 0x4b,
754 .tuner_address = 0x61,
755 .tuner_config = 2,
756 .antenna_switch= 2,
757 .request_firmware = philips_tda1004x_request_firmware
758};
Edgar Simo261f5082007-08-20 14:06:00 -0300759
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300760static struct tda1004x_config kworld_dvb_t_210_config = {
761 .demod_address = 0x08,
762 .invert = 1,
763 .invert_oclk = 0,
764 .xtal_freq = TDA10046_XTAL_16M,
765 .agc_config = TDA10046_AGC_TDA827X,
766 .gpio_config = TDA10046_GP11_I,
767 .if_freq = TDA10046_FREQ_045,
768 .i2c_gate = 0x4b,
769 .tuner_address = 0x61,
770 .tuner_config = 2,
771 .antenna_switch= 1,
772 .request_firmware = philips_tda1004x_request_firmware
773};
Edgar Simo261f5082007-08-20 14:06:00 -0300774
Edgar Simod90d9f52007-08-20 14:14:50 -0300775static struct tda1004x_config avermedia_super_007_config = {
776 .demod_address = 0x08,
777 .invert = 1,
778 .invert_oclk = 0,
779 .xtal_freq = TDA10046_XTAL_16M,
780 .agc_config = TDA10046_AGC_TDA827X,
781 .gpio_config = TDA10046_GP01_I,
782 .if_freq = TDA10046_FREQ_045,
783 .i2c_gate = 0x4b,
784 .tuner_address = 0x60,
785 .tuner_config = 0,
786 .antenna_switch= 1,
787 .request_firmware = philips_tda1004x_request_firmware
788};
789
Hermann Pitton4ba24372008-01-20 19:27:51 -0300790static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
791 .demod_address = 0x08,
792 .invert = 1,
793 .invert_oclk = 0,
794 .xtal_freq = TDA10046_XTAL_16M,
795 .agc_config = TDA10046_AGC_TDA827X,
796 .gpio_config = TDA10046_GP01_I,
797 .if_freq = TDA10046_FREQ_045,
798 .i2c_gate = 0x42,
799 .tuner_address = 0x61,
800 .tuner_config = 2,
801 .antenna_switch = 1,
802 .request_firmware = philips_tda1004x_request_firmware
803};
804
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300805/* ------------------------------------------------------------------
806 * special case: this card uses saa713x GPIO22 for the mode switch
807 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200808
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300809static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200810{
811 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300812 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200813 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300814 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200815 return 0;
816}
817
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300818static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200819{
820 struct saa7134_dev *dev = fe->dvb->priv;
821 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300822 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300823 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300824 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200825}
826
Michael Krufky8ce47da2007-04-27 12:31:14 -0300827static struct tda827x_config ads_duo_cfg = {
828 .lna_gain = philips_tda827x_lna_gain,
829 .init = ads_duo_tuner_init,
830 .sleep = ads_duo_tuner_sleep
831};
832
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200833static struct tda1004x_config ads_tech_duo_config = {
834 .demod_address = 0x08,
835 .invert = 1,
836 .invert_oclk = 0,
837 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300838 .agc_config = TDA10046_AGC_TDA827X,
839 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200840 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300841 .tuner_address = 0x61,
842 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200843};
844
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300845/* ==================================================================
846 * tda10086 based DVB-S cards, helper functions
847 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300848
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300849static struct tda10086_config flydvbs = {
850 .demod_address = 0x0e,
851 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300852 .diseqc_tone = 0,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300853};
854
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300855/* ------------------------------------------------------------------
856 * special case: lnb supply is connected to the gated i2c
857 */
858
859static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
860{
861 int res = -EIO;
862 struct saa7134_dev *dev = fe->dvb->priv;
863 if (fe->ops.i2c_gate_ctrl) {
864 fe->ops.i2c_gate_ctrl(fe, 1);
865 if (dev->original_set_voltage)
866 res = dev->original_set_voltage(fe, voltage);
867 fe->ops.i2c_gate_ctrl(fe, 0);
868 }
869 return res;
870};
871
872static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
873{
874 int res = -EIO;
875 struct saa7134_dev *dev = fe->dvb->priv;
876 if (fe->ops.i2c_gate_ctrl) {
877 fe->ops.i2c_gate_ctrl(fe, 1);
878 if (dev->original_set_high_voltage)
879 res = dev->original_set_high_voltage(fe, arg);
880 fe->ops.i2c_gate_ctrl(fe, 0);
881 }
882 return res;
883};
884
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300885/* ==================================================================
886 * nxt200x based ATSC cards, helper functions
887 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800888
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800889static struct nxt200x_config avertvhda180 = {
890 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800891};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300892
893static struct nxt200x_config kworldatsc110 = {
894 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300895};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800896
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300897/* ==================================================================
898 * Core code
899 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700900
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901static int dvb_init(struct saa7134_dev *dev)
902{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -0300903 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300904 int attach_xc3028 = 0;
905
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 /* init struct videobuf_dvb */
907 dev->ts.nr_bufs = 32;
908 dev->ts.nr_packets = 32*4;
909 dev->dvb.name = dev->name;
Guennadi Liakhovetski07051352008-04-22 14:42:13 -0300910 videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops,
911 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 V4L2_BUF_TYPE_VIDEO_CAPTURE,
913 V4L2_FIELD_ALTERNATE,
914 sizeof(struct saa7134_buf),
915 dev);
916
917 switch (dev->board) {
918 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300919 dprintk("pinnacle 300i dvb setup\n");
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300920 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300921 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300922 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300923 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300924 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200926 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -0300927 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300928 dprintk("avertv 777 dvb setup\n");
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300929 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300930 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300931 if (dev->dvb.frontend) {
Michael Krufky8511df92007-05-07 01:34:36 -0300932 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300933 NULL, DVB_PLL_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300934 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200935 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 case SAA7134_BOARD_MD7134:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300937 dev->dvb.frontend = dvb_attach(tda10046_attach,
938 &medion_cardbus,
939 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300940 if (dev->dvb.frontend) {
Trent Piephob7754d72007-05-08 18:05:16 -0300941 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
Michael Krufky47a99912007-06-12 16:10:51 -0300942 &dev->i2c_adap, DVB_PLL_FMD1216ME);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300943 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700945 case SAA7134_BOARD_PHILIPS_TOUGH:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300946 dev->dvb.frontend = dvb_attach(tda10046_attach,
947 &philips_tu1216_60_config,
948 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300949 if (dev->dvb.frontend) {
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300950 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
951 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300952 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700953 break;
954 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -0200955 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300956 configure_tda827x_fe(dev, &tda827x_lifeview_config);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700957 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800958 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800959 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300960 dev->dvb.frontend = dvb_attach(tda10046_attach,
961 &philips_europa_config,
962 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300963 if (dev->dvb.frontend) {
Hartmut Hackmann588f9832006-10-18 17:30:42 -0300964 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
965 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300966 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
967 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
968 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300969 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800970 break;
971 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300972 dev->dvb.frontend = dvb_attach(tda10046_attach,
973 &philips_tu1216_61_config,
974 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300975 if (dev->dvb.frontend) {
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300976 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
977 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300978 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800979 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300980 case SAA7134_BOARD_KWORLD_DVBT_210:
981 configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
982 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800983 case SAA7134_BOARD_PHILIPS_TIGER:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300984 configure_tda827x_fe(dev, &philips_tiger_config);
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300985 break;
986 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300987 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800988 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300989 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300990 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300991 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -0800992 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300993 configure_tda827x_fe(dev, &asus_p7131_dual_config);
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -0800994 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -0200995 case SAA7134_BOARD_FLYDVBT_LR301:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300996 configure_tda827x_fe(dev, &tda827x_lifeview_config);
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -0200997 break;
Nico Sabbi420f32f2006-03-03 12:11:28 -0300998 case SAA7134_BOARD_FLYDVB_TRIO:
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300999 if(! use_frontend) { /* terrestrial */
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001000 configure_tda827x_fe(dev, &lifeview_trio_config);
Hartmut Hackmannea75baf2008-02-09 23:54:24 -03001001 } else { /* satellite */
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001002 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1003 if (dev->dvb.frontend) {
1004 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1005 &dev->i2c_adap, 0) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001006 wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001007 }
1008 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1009 0x08, 0, 0) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001010 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001011 }
1012 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001013 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001014 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001015 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001016 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001017 dev->dvb.frontend = dvb_attach(tda10046_attach,
1018 &ads_tech_duo_config,
1019 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001020 if (dev->dvb.frontend) {
Hartmut Hackmannede22002007-04-27 12:31:32 -03001021 if (dvb_attach(tda827x_attach,dev->dvb.frontend,
Michael Krufky8ce47da2007-04-27 12:31:14 -03001022 ads_tech_duo_config.tuner_address,
Hartmut Hackmannede22002007-04-27 12:31:32 -03001023 &dev->i2c_adap,&ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001024 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001025 ads_tech_duo_config.tuner_address);
1026 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001027 }
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001028 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001029 case SAA7134_BOARD_TEVION_DVBT_220RF:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001030 configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001031 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001032 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001033 if (!use_frontend) { /* terrestrial */
1034 configure_tda827x_fe(dev, &md8800_dvbt_config);
1035 } else { /* satellite */
1036 dev->dvb.frontend = dvb_attach(tda10086_attach,
1037 &flydvbs, &dev->i2c_adap);
1038 if (dev->dvb.frontend) {
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -03001039 struct dvb_frontend *fe;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001040 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1041 0x60, &dev->i2c_adap, 0) == NULL)
1042 wprintk("%s: Medion Quadro, no tda826x "
1043 "found !\n", __FUNCTION__);
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -03001044 /* Note 10.2. Hac
1045 * up to here. configuration for ctx948 and and one branch
1046 * of md8800 should be identical
1047 */
1048 /* we need to open the i2c gate (we know it exists) */
1049 fe = dev->dvb.frontend;
1050 fe->ops.i2c_gate_ctrl(fe, 1);
1051 if (dvb_attach(isl6405_attach, fe,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001052 &dev->i2c_adap, 0x08, 0, 0) == NULL)
1053 wprintk("%s: Medion Quadro, no ISL6405 "
1054 "found !\n", __FUNCTION__);
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -03001055 fe->ops.i2c_gate_ctrl(fe, 0);
1056 dev->original_set_voltage = fe->ops.set_voltage;
1057 fe->ops.set_voltage = md8800_set_voltage;
1058 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1059 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001060 }
1061 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001062 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001063 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001064 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1065 &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001066 if (dev->dvb.frontend) {
Michael Krufky4ad8eee52006-08-08 15:48:08 -03001067 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001068 NULL, DVB_PLL_TDHU2);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001069 }
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001070 break;
Andrew Burri3e1410a2006-02-27 00:08:23 -03001071 case SAA7134_BOARD_KWORLD_ATSC110:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001072 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1073 &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001074 if (dev->dvb.frontend) {
Michael Krufky4ad8eee52006-08-08 15:48:08 -03001075 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001076 NULL, DVB_PLL_TUV1236D);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001077 }
Andrew Burri3e1410a2006-02-27 00:08:23 -03001078 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001079 case SAA7134_BOARD_FLYDVBS_LR300:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001080 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1081 &dev->i2c_adap);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001082 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001083 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1084 &dev->i2c_adap, 0) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001085 wprintk("%s: No tda826x found!\n", __FUNCTION__);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001086 }
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001087 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1088 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001089 wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001090 }
1091 }
1092 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001093 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001094 dev->dvb.frontend = dvb_attach(tda10046_attach,
1095 &medion_cardbus,
1096 &dev->i2c_adap);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001097 if (dev->dvb.frontend) {
1098 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1099 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001100
1101 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
Michael Krufky47a99912007-06-12 16:10:51 -03001102 &dev->i2c_adap, DVB_PLL_FMD1216ME);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001103 }
1104 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001105 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1106 dev->dvb.frontend = dvb_attach(tda10046_attach,
1107 &philips_europa_config,
1108 &dev->i2c_adap);
1109 if (dev->dvb.frontend) {
1110 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1111 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1112 }
1113 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001114 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001115 configure_tda827x_fe(dev, &cinergy_ht_config);
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001116 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001117 case SAA7134_BOARD_CINERGY_HT_PCI:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001118 configure_tda827x_fe(dev, &cinergy_ht_pci_config);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001119 break;
1120 case SAA7134_BOARD_PHILIPS_TIGER_S:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001121 configure_tda827x_fe(dev, &philips_tiger_s_config);
Michael Krufky9de271e2007-01-16 18:36:40 -03001122 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001123 case SAA7134_BOARD_ASUS_P7131_4871:
1124 configure_tda827x_fe(dev, &asus_p7131_4871_config);
1125 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001126 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1127 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001128 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001129 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1130 configure_tda827x_fe(dev, &avermedia_super_007_config);
1131 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001132 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1133 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
1134 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001135 case SAA7134_BOARD_PHILIPS_SNAKE:
1136 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1137 &dev->i2c_adap);
1138 if (dev->dvb.frontend) {
1139 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1140 &dev->i2c_adap, 0) == NULL)
1141 wprintk("%s: No tda826x found!\n", __FUNCTION__);
1142 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1143 &dev->i2c_adap, 0, 0) == NULL)
1144 wprintk("%s: No lnbp21 found!\n", __FUNCTION__);
1145 }
1146 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001147 case SAA7134_BOARD_CREATIX_CTX953:
1148 configure_tda827x_fe(dev, &md8800_dvbt_config);
1149 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001150 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1151 configure_tda827x_fe(dev, &philips_tiger_s_config);
1152 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001153 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1154 dev->dvb.frontend = dvb_attach(mt352_attach,
1155 &avermedia_e506r_mt352_dev,
1156 &dev->i2c_adap);
1157 attach_xc3028 = 1;
1158 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001159 case SAA7134_BOARD_MD7134_BRIDGE_2:
1160 dev->dvb.frontend = dvb_attach(tda10086_attach,
1161 &flydvbs, &dev->i2c_adap);
1162 if (dev->dvb.frontend) {
1163 struct dvb_frontend *fe;
1164 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
1165 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL)
1166 wprintk("%s: MD7134 DVB-S, no SD1878 "
1167 "found !\n", __FUNCTION__);
1168 /* we need to open the i2c gate (we know it exists) */
1169 fe = dev->dvb.frontend;
1170 fe->ops.i2c_gate_ctrl(fe, 1);
1171 if (dvb_attach(isl6405_attach, fe,
1172 &dev->i2c_adap, 0x08, 0, 0) == NULL)
1173 wprintk("%s: MD7134 DVB-S, no ISL6405 "
1174 "found !\n", __FUNCTION__);
1175 fe->ops.i2c_gate_ctrl(fe, 0);
1176 dev->original_set_voltage = fe->ops.set_voltage;
1177 fe->ops.set_voltage = md8800_set_voltage;
1178 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1179 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1180 }
1181 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001183 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184 break;
1185 }
1186
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001187 if (attach_xc3028) {
1188 struct dvb_frontend *fe;
1189 struct xc2028_config cfg = {
1190 .i2c_adap = &dev->i2c_adap,
1191 .i2c_addr = 0x61,
Mauro Carvalho Chehab50407f92008-04-22 14:46:02 -03001192 .video_dev = dev->i2c_adap.algo_data,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001193 };
1194 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
1195 if (!fe) {
1196 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1197 dev->name);
1198 dvb_frontend_detach(dev->dvb.frontend);
1199 dvb_unregister_frontend(dev->dvb.frontend);
1200 dev->dvb.frontend = NULL;
1201 return -1;
1202 }
1203 }
1204
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 if (NULL == dev->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001206 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 return -1;
1208 }
1209
1210 /* register everything else */
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001211 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1212
1213 /* this sequence is necessary to make the tda1004x load its firmware
1214 * and to enter analog mode of hybrid boards
1215 */
1216 if (!ret) {
1217 if (dev->dvb.frontend->ops.init)
1218 dev->dvb.frontend->ops.init(dev->dvb.frontend);
1219 if (dev->dvb.frontend->ops.sleep)
1220 dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
Hartmut Hackmann9971f4f2007-03-23 21:00:07 -03001221 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1222 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001223 }
1224 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225}
1226
1227static int dvb_fini(struct saa7134_dev *dev)
1228{
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001229 /* FIXME: I suspect that this code is bogus, since the entry for
1230 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1231 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1232 */
1233 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1234 struct v4l2_priv_tun_config tda9887_cfg;
1235 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001237 tda9887_cfg.tuner = TUNER_TDA9887;
1238 tda9887_cfg.priv = &on;
1239
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240 /* otherwise we don't detect the tuner on next insmod */
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001241 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
1242 }
1243
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244 videobuf_dvb_unregister(&dev->dvb);
1245 return 0;
1246}
1247
1248static struct saa7134_mpeg_ops dvb_ops = {
1249 .type = SAA7134_MPEG_DVB,
1250 .init = dvb_init,
1251 .fini = dvb_fini,
1252};
1253
1254static int __init dvb_register(void)
1255{
1256 return saa7134_ts_register(&dvb_ops);
1257}
1258
1259static void __exit dvb_unregister(void)
1260{
1261 saa7134_ts_unregister(&dvb_ops);
1262}
1263
1264module_init(dvb_register);
1265module_exit(dvb_unregister);
1266
1267/* ------------------------------------------------------------------ */
1268/*
1269 * Local variables:
1270 * c-basic-offset: 8
1271 * End:
1272 */