blob: 8e55c7572b4b6e252a3307684fabecc9b0bdc000 [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 Krufky8ce47da2007-04-27 12:31:14 -030050
Linus Torvalds1da177e2005-04-16 15:20:36 -070051MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
52MODULE_LICENSE("GPL");
53
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030054static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070055
Linus Torvalds1da177e2005-04-16 15:20:36 -070056module_param(antenna_pwr, int, 0444);
57MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
58
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030059static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030060module_param(use_frontend, int, 0644);
61MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030062
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030063static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030064module_param(debug, int, 0644);
65MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
66
Trent Piephocf3c34c2007-03-07 18:19:48 -030067#define dprintk(fmt, arg...) do { if (debug) \
68 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
69
70/* Print a warning */
71#define wprintk(fmt, arg...) \
72 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030073
74/* ------------------------------------------------------------------
75 * mt352 based DVB-T cards
76 */
77
Linus Torvalds1da177e2005-04-16 15:20:36 -070078static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
79{
80 u32 ok;
81
82 if (!on) {
83 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
84 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
85 return 0;
86 }
87
88 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
89 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
90 udelay(10);
91
92 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
93 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
94 udelay(10);
95 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
96 udelay(10);
97 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -030098 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100 if (!ok)
101 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
102 return ok;
103}
104
105static int mt352_pinnacle_init(struct dvb_frontend* fe)
106{
107 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
108 static u8 reset [] = { RESET, 0x80 };
109 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
110 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
111 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
112 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
113 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
114 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
115 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
116 struct saa7134_dev *dev= fe->dvb->priv;
117
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300118 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120 mt352_write(fe, clock_config, sizeof(clock_config));
121 udelay(200);
122 mt352_write(fe, reset, sizeof(reset));
123 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
124 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
125 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
126 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
127
128 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
129 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
130 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 return 0;
133}
134
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200135static int mt352_aver777_init(struct dvb_frontend* fe)
136{
137 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
138 static u8 reset [] = { RESET, 0x80 };
139 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
140 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
141 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
142
143 mt352_write(fe, clock_config, sizeof(clock_config));
144 udelay(200);
145 mt352_write(fe, reset, sizeof(reset));
146 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
147 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
148 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
149
150 return 0;
151}
152
Andrew de Quincey0463f122006-05-16 17:22:02 -0300153static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
154 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300156 u8 off[] = { 0x00, 0xf1};
157 u8 on[] = { 0x00, 0x71};
158 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
159
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 struct saa7134_dev *dev = fe->dvb->priv;
161 struct v4l2_frequency f;
162
163 /* set frequency (mt2050) */
164 f.tuner = 0;
165 f.type = V4L2_TUNER_DIGITAL_TV;
166 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300167 if (fe->ops.i2c_gate_ctrl)
168 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300169 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300171 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300172 if (fe->ops.i2c_gate_ctrl)
173 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300174 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
176 pinnacle_antenna_pwr(dev, antenna_pwr);
177
178 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300179 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180}
181
182static struct mt352_config pinnacle_300i = {
183 .demod_address = 0x3c >> 1,
184 .adc_clock = 20333,
185 .if2 = 36150,
186 .no_tuner = 1,
187 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200189
190static struct mt352_config avermedia_777 = {
191 .demod_address = 0xf,
192 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200193};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300195static struct mt352_config avermedia_e506r_mt352_dev = {
196 .demod_address = (0x1e >> 1),
197 .no_tuner = 1,
198};
199
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300200/* ==================================================================
201 * tda1004x based DVB-T cards, helper functions
202 */
203
204static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
205 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700206{
207 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300208 return request_firmware(fw, name, &dev->pci->dev);
209}
210
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300211/* ------------------------------------------------------------------
212 * these tuners are tu1216, td1316(a)
213 */
214
215static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
216{
217 struct saa7134_dev *dev = fe->dvb->priv;
218 struct tda1004x_state *state = fe->demodulator_priv;
219 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700220 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800221 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700222 sizeof(tuner_buf) };
223 int tuner_frequency = 0;
224 u8 band, cp, filter;
225
226 /* determine charge pump */
227 tuner_frequency = params->frequency + 36166000;
228 if (tuner_frequency < 87000000)
229 return -EINVAL;
230 else if (tuner_frequency < 130000000)
231 cp = 3;
232 else if (tuner_frequency < 160000000)
233 cp = 5;
234 else if (tuner_frequency < 200000000)
235 cp = 6;
236 else if (tuner_frequency < 290000000)
237 cp = 3;
238 else if (tuner_frequency < 420000000)
239 cp = 5;
240 else if (tuner_frequency < 480000000)
241 cp = 6;
242 else if (tuner_frequency < 620000000)
243 cp = 3;
244 else if (tuner_frequency < 830000000)
245 cp = 5;
246 else if (tuner_frequency < 895000000)
247 cp = 7;
248 else
249 return -EINVAL;
250
251 /* determine band */
252 if (params->frequency < 49000000)
253 return -EINVAL;
254 else if (params->frequency < 161000000)
255 band = 1;
256 else if (params->frequency < 444000000)
257 band = 2;
258 else if (params->frequency < 861000000)
259 band = 4;
260 else
261 return -EINVAL;
262
263 /* setup PLL filter */
264 switch (params->u.ofdm.bandwidth) {
265 case BANDWIDTH_6_MHZ:
266 filter = 0;
267 break;
268
269 case BANDWIDTH_7_MHZ:
270 filter = 0;
271 break;
272
273 case BANDWIDTH_8_MHZ:
274 filter = 1;
275 break;
276
277 default:
278 return -EINVAL;
279 }
280
281 /* calculate divisor
282 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
283 */
284 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
285
286 /* setup tuner buffer */
287 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
288 tuner_buf[1] = tuner_frequency & 0xff;
289 tuner_buf[2] = 0xca;
290 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
291
Patrick Boettcherdea74862006-05-14 05:01:31 -0300292 if (fe->ops.i2c_gate_ctrl)
293 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300294 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300295 wprintk("could not write to tuner at addr: 0x%02x\n",
296 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700297 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300298 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700299 msleep(1);
300 return 0;
301}
302
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300303static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800304{
305 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300306 struct tda1004x_state *state = fe->demodulator_priv;
307 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800308 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
309 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
310
311 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300312 if (fe->ops.i2c_gate_ctrl)
313 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800314 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
315 return -EIO;
316 msleep(1);
317
318 return 0;
319}
320
321/* ------------------------------------------------------------------ */
322
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800323static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700324 .demod_address = 0x8,
325 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800326 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700327 .xtal_freq = TDA10046_XTAL_4M,
328 .agc_config = TDA10046_AGC_DEFAULT,
329 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300330 .tuner_address = 0x60,
331 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332};
333
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800334static struct tda1004x_config philips_tu1216_61_config = {
335
336 .demod_address = 0x8,
337 .invert = 1,
338 .invert_oclk = 0,
339 .xtal_freq = TDA10046_XTAL_4M,
340 .agc_config = TDA10046_AGC_DEFAULT,
341 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300342 .tuner_address = 0x61,
343 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800344};
345
346/* ------------------------------------------------------------------ */
347
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300348static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800349{
350 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300351 struct tda1004x_state *state = fe->demodulator_priv;
352 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800353 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300354 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800355
356 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300357 if (fe->ops.i2c_gate_ctrl)
358 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800359 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
360 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800361 return 0;
362}
363
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300364static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800365{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300366 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800367}
368
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300369static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
370{
371 struct saa7134_dev *dev = fe->dvb->priv;
372 struct tda1004x_state *state = fe->demodulator_priv;
373 u8 addr = state->config->tuner_address;
374 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
375 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
376
377 /* switch the tuner to analog mode */
378 if (fe->ops.i2c_gate_ctrl)
379 fe->ops.i2c_gate_ctrl(fe, 1);
380 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
381 return -EIO;
382 return 0;
383}
384
385/* ------------------------------------------------------------------ */
386
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300387static int philips_europa_tuner_init(struct dvb_frontend *fe)
388{
389 struct saa7134_dev *dev = fe->dvb->priv;
390 static u8 msg[] = { 0x00, 0x40};
391 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
392
393
394 if (philips_td1316_tuner_init(fe))
395 return -EIO;
396 msleep(1);
397 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
398 return -EIO;
399
400 return 0;
401}
402
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300403static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800404{
405 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800406
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300407 static u8 msg[] = { 0x00, 0x14 };
408 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
409
410 if (philips_td1316_tuner_sleep(fe))
411 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800412
413 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300414 if (fe->ops.i2c_gate_ctrl)
415 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800416 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300417 return 0;
418}
419
420static int philips_europa_demod_sleep(struct dvb_frontend *fe)
421{
422 struct saa7134_dev *dev = fe->dvb->priv;
423
424 if (dev->original_demod_sleep)
425 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300426 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300427 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800428}
429
430static struct tda1004x_config philips_europa_config = {
431
432 .demod_address = 0x8,
433 .invert = 0,
434 .invert_oclk = 0,
435 .xtal_freq = TDA10046_XTAL_4M,
436 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
437 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300438 .tuner_address = 0x61,
439 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800440};
441
442/* ------------------------------------------------------------------ */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700443
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700444static struct tda1004x_config medion_cardbus = {
445 .demod_address = 0x08,
446 .invert = 1,
447 .invert_oclk = 0,
448 .xtal_freq = TDA10046_XTAL_16M,
449 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
450 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300451 .tuner_address = 0x61,
452 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700453};
454
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300455/* ------------------------------------------------------------------
456 * tda 1004x based cards with philips silicon tuner
457 */
458
459static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
460{
461 struct saa7134_dev *dev = fe->dvb->priv;
462 struct tda1004x_state *state = fe->demodulator_priv;
463 u8 addr = state->config->i2c_gate;
464 u8 config = state->config->tuner_config;
465 u8 GP00_CF[] = {0x20, 0x01};
466 u8 GP00_LEV[] = {0x22, 0x00};
467
468 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
469 if (config) {
470 if (high) {
471 dprintk("setting LNA to high gain\n");
472 } else {
473 dprintk("setting LNA to low gain\n");
474 }
475 }
476 switch (config) {
477 case 0: /* no LNA */
478 break;
479 case 1: /* switch is GPIO 0 of tda8290 */
480 case 2:
481 /* turn Vsync off */
482 saa7134_set_gpio(dev, 22, 0);
483 GP00_LEV[1] = high ? 0 : 1;
484 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300485 wprintk("could not access tda8290 at addr: 0x%02x\n",
486 addr << 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300487 return;
488 }
489 msg.buf = GP00_LEV;
490 if (config == 2)
491 GP00_LEV[1] = high ? 1 : 0;
492 i2c_transfer(&dev->i2c_adap, &msg, 1);
493 break;
494 case 3: /* switch with GPIO of saa713x */
495 saa7134_set_gpio(dev, 22, high);
496 break;
497 }
498}
499
500static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
501{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300502 struct tda1004x_state *state = fe->demodulator_priv;
503
504 u8 addr = state->config->i2c_gate;
505 static u8 tda8290_close[] = { 0x21, 0xc0};
506 static u8 tda8290_open[] = { 0x21, 0x80};
507 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
508 if (enable) {
509 tda8290_msg.buf = tda8290_close;
510 } else {
511 tda8290_msg.buf = tda8290_open;
512 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300513 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300514 struct saa7134_dev *dev = fe->dvb->priv;
515 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300516 return -EIO;
517 }
518 msleep(20);
519 return 0;
520}
521
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700522/* ------------------------------------------------------------------ */
523
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300524static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300525{
526 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300527 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300528
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300529 switch (state->config->antenna_switch) {
530 case 0: break;
531 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
532 saa7134_set_gpio(dev, 21, 0);
533 break;
534 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
535 saa7134_set_gpio(dev, 21, 1);
536 break;
537 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300538 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800539}
540
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300541static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
542{
543 struct saa7134_dev *dev = fe->dvb->priv;
544 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300545
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300546 switch (state->config->antenna_switch) {
547 case 0: break;
548 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
549 saa7134_set_gpio(dev, 21, 1);
550 break;
551 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
552 saa7134_set_gpio(dev, 21, 0);
553 break;
554 }
555 return 0;
556}
557
Michael Krufky8ce47da2007-04-27 12:31:14 -0300558static struct tda827x_config tda827x_cfg = {
559 .lna_gain = philips_tda827x_lna_gain,
560 .init = philips_tda827x_tuner_init,
561 .sleep = philips_tda827x_tuner_sleep
562};
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300563
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300564static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300565{
566 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
567 if (dev->dvb.frontend) {
568 if (tda_conf->i2c_gate)
569 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
Hartmut Hackmannede22002007-04-27 12:31:32 -0300570 if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
571 &dev->i2c_adap,&tda827x_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300572 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -0300573 tda_conf->tuner_address);
574 }
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300575 }
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300576}
577
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800578/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300579
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300580static struct tda1004x_config tda827x_lifeview_config = {
581 .demod_address = 0x08,
582 .invert = 1,
583 .invert_oclk = 0,
584 .xtal_freq = TDA10046_XTAL_16M,
585 .agc_config = TDA10046_AGC_TDA827X,
586 .gpio_config = TDA10046_GP11_I,
587 .if_freq = TDA10046_FREQ_045,
588 .tuner_address = 0x60,
589 .request_firmware = philips_tda1004x_request_firmware
590};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800591
592static struct tda1004x_config philips_tiger_config = {
593 .demod_address = 0x08,
594 .invert = 1,
595 .invert_oclk = 0,
596 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300597 .agc_config = TDA10046_AGC_TDA827X,
598 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300599 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300600 .i2c_gate = 0x4b,
601 .tuner_address = 0x61,
602 .tuner_config = 0,
603 .antenna_switch= 1,
604 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300605};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300606
607static struct tda1004x_config cinergy_ht_config = {
608 .demod_address = 0x08,
609 .invert = 1,
610 .invert_oclk = 0,
611 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300612 .agc_config = TDA10046_AGC_TDA827X,
613 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800614 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300615 .i2c_gate = 0x4b,
616 .tuner_address = 0x61,
617 .tuner_config = 0,
618 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800619};
620
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300621static struct tda1004x_config cinergy_ht_pci_config = {
622 .demod_address = 0x08,
623 .invert = 1,
624 .invert_oclk = 0,
625 .xtal_freq = TDA10046_XTAL_16M,
626 .agc_config = TDA10046_AGC_TDA827X,
627 .gpio_config = TDA10046_GP01_I,
628 .if_freq = TDA10046_FREQ_045,
629 .i2c_gate = 0x4b,
630 .tuner_address = 0x60,
631 .tuner_config = 0,
632 .request_firmware = philips_tda1004x_request_firmware
633};
634
635static struct tda1004x_config philips_tiger_s_config = {
636 .demod_address = 0x08,
637 .invert = 1,
638 .invert_oclk = 0,
639 .xtal_freq = TDA10046_XTAL_16M,
640 .agc_config = TDA10046_AGC_TDA827X,
641 .gpio_config = TDA10046_GP01_I,
642 .if_freq = TDA10046_FREQ_045,
643 .i2c_gate = 0x4b,
644 .tuner_address = 0x61,
645 .tuner_config = 2,
646 .antenna_switch= 1,
647 .request_firmware = philips_tda1004x_request_firmware
648};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200649
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300650static struct tda1004x_config pinnacle_pctv_310i_config = {
651 .demod_address = 0x08,
652 .invert = 1,
653 .invert_oclk = 0,
654 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300655 .agc_config = TDA10046_AGC_TDA827X,
656 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300657 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300658 .i2c_gate = 0x4b,
659 .tuner_address = 0x61,
660 .tuner_config = 1,
661 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300662};
663
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300664static struct tda1004x_config hauppauge_hvr_1110_config = {
665 .demod_address = 0x08,
666 .invert = 1,
667 .invert_oclk = 0,
668 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300669 .agc_config = TDA10046_AGC_TDA827X,
670 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300671 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300672 .i2c_gate = 0x4b,
673 .tuner_address = 0x61,
Benoit Istinbc548372007-12-07 02:00:04 -0300674 .tuner_config = 1,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300675 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300676};
677
Hartmut Hackmann83646812006-10-12 20:38:51 -0300678static struct tda1004x_config asus_p7131_dual_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,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300685 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300686 .i2c_gate = 0x4b,
687 .tuner_address = 0x61,
688 .tuner_config = 0,
689 .antenna_switch= 2,
690 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300691};
692
Nico Sabbi420f32f2006-03-03 12:11:28 -0300693static struct tda1004x_config lifeview_trio_config = {
694 .demod_address = 0x09,
695 .invert = 1,
696 .invert_oclk = 0,
697 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300698 .agc_config = TDA10046_AGC_TDA827X,
699 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300700 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300701 .tuner_address = 0x60,
702 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300703};
704
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300705static struct tda1004x_config tevion_dvbt220rf_config = {
706 .demod_address = 0x08,
707 .invert = 1,
708 .invert_oclk = 0,
709 .xtal_freq = TDA10046_XTAL_16M,
710 .agc_config = TDA10046_AGC_TDA827X,
711 .gpio_config = TDA10046_GP11_I,
712 .if_freq = TDA10046_FREQ_045,
713 .tuner_address = 0x60,
714 .request_firmware = philips_tda1004x_request_firmware
715};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300716
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300717static struct tda1004x_config md8800_dvbt_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_GP01_I,
724 .if_freq = TDA10046_FREQ_045,
725 .i2c_gate = 0x4b,
726 .tuner_address = 0x60,
727 .tuner_config = 0,
728 .request_firmware = philips_tda1004x_request_firmware
729};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200730
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300731static struct tda1004x_config asus_p7131_4871_config = {
732 .demod_address = 0x08,
733 .invert = 1,
734 .invert_oclk = 0,
735 .xtal_freq = TDA10046_XTAL_16M,
736 .agc_config = TDA10046_AGC_TDA827X,
737 .gpio_config = TDA10046_GP01_I,
738 .if_freq = TDA10046_FREQ_045,
739 .i2c_gate = 0x4b,
740 .tuner_address = 0x61,
741 .tuner_config = 2,
742 .antenna_switch= 2,
743 .request_firmware = philips_tda1004x_request_firmware
744};
745
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300746static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300747 .demod_address = 0x08,
748 .invert = 1,
749 .invert_oclk = 0,
750 .xtal_freq = TDA10046_XTAL_16M,
751 .agc_config = TDA10046_AGC_TDA827X,
752 .gpio_config = TDA10046_GP11_I,
753 .if_freq = TDA10046_FREQ_045,
754 .i2c_gate = 0x4b,
755 .tuner_address = 0x61,
756 .tuner_config = 2,
757 .antenna_switch= 2,
758 .request_firmware = philips_tda1004x_request_firmware
759};
Edgar Simo261f5082007-08-20 14:06:00 -0300760
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300761static struct tda1004x_config kworld_dvb_t_210_config = {
762 .demod_address = 0x08,
763 .invert = 1,
764 .invert_oclk = 0,
765 .xtal_freq = TDA10046_XTAL_16M,
766 .agc_config = TDA10046_AGC_TDA827X,
767 .gpio_config = TDA10046_GP11_I,
768 .if_freq = TDA10046_FREQ_045,
769 .i2c_gate = 0x4b,
770 .tuner_address = 0x61,
771 .tuner_config = 2,
772 .antenna_switch= 1,
773 .request_firmware = philips_tda1004x_request_firmware
774};
Edgar Simo261f5082007-08-20 14:06:00 -0300775
Edgar Simod90d9f52007-08-20 14:14:50 -0300776static struct tda1004x_config avermedia_super_007_config = {
777 .demod_address = 0x08,
778 .invert = 1,
779 .invert_oclk = 0,
780 .xtal_freq = TDA10046_XTAL_16M,
781 .agc_config = TDA10046_AGC_TDA827X,
782 .gpio_config = TDA10046_GP01_I,
783 .if_freq = TDA10046_FREQ_045,
784 .i2c_gate = 0x4b,
785 .tuner_address = 0x60,
786 .tuner_config = 0,
787 .antenna_switch= 1,
788 .request_firmware = philips_tda1004x_request_firmware
789};
790
Hermann Pitton4ba24372008-01-20 19:27:51 -0300791static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
792 .demod_address = 0x08,
793 .invert = 1,
794 .invert_oclk = 0,
795 .xtal_freq = TDA10046_XTAL_16M,
796 .agc_config = TDA10046_AGC_TDA827X,
797 .gpio_config = TDA10046_GP01_I,
798 .if_freq = TDA10046_FREQ_045,
799 .i2c_gate = 0x42,
800 .tuner_address = 0x61,
801 .tuner_config = 2,
802 .antenna_switch = 1,
803 .request_firmware = philips_tda1004x_request_firmware
804};
805
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300806/* ------------------------------------------------------------------
807 * special case: this card uses saa713x GPIO22 for the mode switch
808 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200809
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300810static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200811{
812 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300813 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200814 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300815 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200816 return 0;
817}
818
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300819static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200820{
821 struct saa7134_dev *dev = fe->dvb->priv;
822 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300823 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300824 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300825 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200826}
827
Michael Krufky8ce47da2007-04-27 12:31:14 -0300828static struct tda827x_config ads_duo_cfg = {
829 .lna_gain = philips_tda827x_lna_gain,
830 .init = ads_duo_tuner_init,
831 .sleep = ads_duo_tuner_sleep
832};
833
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200834static struct tda1004x_config ads_tech_duo_config = {
835 .demod_address = 0x08,
836 .invert = 1,
837 .invert_oclk = 0,
838 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300839 .agc_config = TDA10046_AGC_TDA827X,
840 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200841 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300842 .tuner_address = 0x61,
843 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200844};
845
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300846/* ==================================================================
847 * tda10086 based DVB-S cards, helper functions
848 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300849
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300850static struct tda10086_config flydvbs = {
851 .demod_address = 0x0e,
852 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300853 .diseqc_tone = 0,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300854};
855
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300856/* ------------------------------------------------------------------
857 * special case: lnb supply is connected to the gated i2c
858 */
859
860static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
861{
862 int res = -EIO;
863 struct saa7134_dev *dev = fe->dvb->priv;
864 if (fe->ops.i2c_gate_ctrl) {
865 fe->ops.i2c_gate_ctrl(fe, 1);
866 if (dev->original_set_voltage)
867 res = dev->original_set_voltage(fe, voltage);
868 fe->ops.i2c_gate_ctrl(fe, 0);
869 }
870 return res;
871};
872
873static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
874{
875 int res = -EIO;
876 struct saa7134_dev *dev = fe->dvb->priv;
877 if (fe->ops.i2c_gate_ctrl) {
878 fe->ops.i2c_gate_ctrl(fe, 1);
879 if (dev->original_set_high_voltage)
880 res = dev->original_set_high_voltage(fe, arg);
881 fe->ops.i2c_gate_ctrl(fe, 0);
882 }
883 return res;
884};
885
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300886static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
887{
888 struct saa7134_dev *dev = fe->dvb->priv;
889 u8 wbuf[2] = { 0x1f, 00 };
890 u8 rbuf;
891 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
892 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
893
894 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
895 return -EIO;
896 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
897 if (voltage == SEC_VOLTAGE_18)
898 wbuf[1] = rbuf | 0x10;
899 else
900 wbuf[1] = rbuf & 0xef;
901 msg[0].len = 2;
902 i2c_transfer(&dev->i2c_adap, msg, 1);
903 return 0;
904}
905
906static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
907{
908 struct saa7134_dev *dev = fe->dvb->priv;
909 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
910 return -EIO;
911}
912
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300913/* ==================================================================
914 * nxt200x based ATSC cards, helper functions
915 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800916
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800917static struct nxt200x_config avertvhda180 = {
918 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800919};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300920
921static struct nxt200x_config kworldatsc110 = {
922 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300923};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800924
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300925/* ==================================================================
926 * Core code
927 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700928
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929static int dvb_init(struct saa7134_dev *dev)
930{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -0300931 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300932 int attach_xc3028 = 0;
933
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 /* init struct videobuf_dvb */
935 dev->ts.nr_bufs = 32;
936 dev->ts.nr_packets = 32*4;
937 dev->dvb.name = dev->name;
Guennadi Liakhovetski07051352008-04-22 14:42:13 -0300938 videobuf_queue_sg_init(&dev->dvb.dvbq, &saa7134_ts_qops,
939 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 V4L2_BUF_TYPE_VIDEO_CAPTURE,
941 V4L2_FIELD_ALTERNATE,
942 sizeof(struct saa7134_buf),
943 dev);
944
945 switch (dev->board) {
946 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300947 dprintk("pinnacle 300i dvb setup\n");
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300948 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300949 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300950 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300951 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300952 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200954 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -0300955 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300956 dprintk("avertv 777 dvb setup\n");
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300957 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300958 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300959 if (dev->dvb.frontend) {
Michael Krufky8511df92007-05-07 01:34:36 -0300960 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300961 NULL, DVB_PLL_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300962 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200963 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 case SAA7134_BOARD_MD7134:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300965 dev->dvb.frontend = dvb_attach(tda10046_attach,
966 &medion_cardbus,
967 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300968 if (dev->dvb.frontend) {
Trent Piephob7754d72007-05-08 18:05:16 -0300969 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
Michael Krufky47a99912007-06-12 16:10:51 -0300970 &dev->i2c_adap, DVB_PLL_FMD1216ME);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300971 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700973 case SAA7134_BOARD_PHILIPS_TOUGH:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300974 dev->dvb.frontend = dvb_attach(tda10046_attach,
975 &philips_tu1216_60_config,
976 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300977 if (dev->dvb.frontend) {
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300978 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
979 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300980 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700981 break;
982 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -0200983 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300984 configure_tda827x_fe(dev, &tda827x_lifeview_config);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700985 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800986 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800987 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300988 dev->dvb.frontend = dvb_attach(tda10046_attach,
989 &philips_europa_config,
990 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300991 if (dev->dvb.frontend) {
Hartmut Hackmann588f9832006-10-18 17:30:42 -0300992 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
993 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300994 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
995 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
996 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300997 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800998 break;
999 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001000 dev->dvb.frontend = dvb_attach(tda10046_attach,
1001 &philips_tu1216_61_config,
1002 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001003 if (dev->dvb.frontend) {
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001004 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1005 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001006 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001007 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001008 case SAA7134_BOARD_KWORLD_DVBT_210:
1009 configure_tda827x_fe(dev, &kworld_dvb_t_210_config);
1010 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001011 case SAA7134_BOARD_PHILIPS_TIGER:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001012 configure_tda827x_fe(dev, &philips_tiger_config);
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001013 break;
1014 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001015 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001016 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001017 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001018 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001019 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001020 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001021 configure_tda827x_fe(dev, &asus_p7131_dual_config);
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001022 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001023 case SAA7134_BOARD_FLYDVBT_LR301:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001024 configure_tda827x_fe(dev, &tda827x_lifeview_config);
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001025 break;
Nico Sabbi420f32f2006-03-03 12:11:28 -03001026 case SAA7134_BOARD_FLYDVB_TRIO:
Hartmut Hackmannea75baf2008-02-09 23:54:24 -03001027 if(! use_frontend) { /* terrestrial */
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001028 configure_tda827x_fe(dev, &lifeview_trio_config);
Hartmut Hackmannea75baf2008-02-09 23:54:24 -03001029 } else { /* satellite */
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001030 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1031 if (dev->dvb.frontend) {
1032 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1033 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001034 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001035 }
1036 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1037 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001038 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001039 }
1040 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001041 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001042 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001043 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001044 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001045 dev->dvb.frontend = dvb_attach(tda10046_attach,
1046 &ads_tech_duo_config,
1047 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001048 if (dev->dvb.frontend) {
Hartmut Hackmannede22002007-04-27 12:31:32 -03001049 if (dvb_attach(tda827x_attach,dev->dvb.frontend,
Michael Krufky8ce47da2007-04-27 12:31:14 -03001050 ads_tech_duo_config.tuner_address,
Hartmut Hackmannede22002007-04-27 12:31:32 -03001051 &dev->i2c_adap,&ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001052 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001053 ads_tech_duo_config.tuner_address);
1054 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001055 }
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001056 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001057 case SAA7134_BOARD_TEVION_DVBT_220RF:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001058 configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001059 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001060 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001061 if (!use_frontend) { /* terrestrial */
1062 configure_tda827x_fe(dev, &md8800_dvbt_config);
1063 } else { /* satellite */
1064 dev->dvb.frontend = dvb_attach(tda10086_attach,
1065 &flydvbs, &dev->i2c_adap);
1066 if (dev->dvb.frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001067 struct dvb_frontend *fe = dev->dvb.frontend;
1068 u8 dev_id = dev->eedata[2];
1069 u8 data = 0xc4;
1070 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1071
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001072 if (dvb_attach(tda826x_attach, dev->dvb.frontend,
1073 0x60, &dev->i2c_adap, 0) == NULL)
1074 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001075 "found !\n", __func__);
1076 if (dev_id != 0x08) {
1077 /* we need to open the i2c gate (we know it exists) */
1078 fe->ops.i2c_gate_ctrl(fe, 1);
1079 if (dvb_attach(isl6405_attach, fe,
1080 &dev->i2c_adap, 0x08, 0, 0) == NULL)
1081 wprintk("%s: Medion Quadro, no ISL6405 "
1082 "found !\n", __func__);
1083 /* fire up the 2nd section of the LNB supply since we can't do
1084 this from the other section */
1085 msg.buf = &data;
1086 i2c_transfer(&dev->i2c_adap, &msg, 1);
1087 fe->ops.i2c_gate_ctrl(fe, 0);
1088 dev->original_set_voltage = fe->ops.set_voltage;
1089 fe->ops.set_voltage = md8800_set_voltage;
1090 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1091 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1092 } else {
1093 fe->ops.set_voltage = md8800_set_voltage2;
1094 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1095 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001096 }
1097 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001098 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001099 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001100 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1101 &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001102 if (dev->dvb.frontend) {
Michael Krufky4ad8eee52006-08-08 15:48:08 -03001103 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001104 NULL, DVB_PLL_TDHU2);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001105 }
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001106 break;
Andrew Burri3e1410a2006-02-27 00:08:23 -03001107 case SAA7134_BOARD_KWORLD_ATSC110:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001108 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1109 &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001110 if (dev->dvb.frontend) {
Michael Krufky4ad8eee52006-08-08 15:48:08 -03001111 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001112 NULL, DVB_PLL_TUV1236D);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001113 }
Andrew Burri3e1410a2006-02-27 00:08:23 -03001114 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001115 case SAA7134_BOARD_FLYDVBS_LR300:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001116 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1117 &dev->i2c_adap);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001118 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001119 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1120 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001121 wprintk("%s: No tda826x found!\n", __func__);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001122 }
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001123 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1124 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001125 wprintk("%s: No ISL6421 found!\n", __func__);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001126 }
1127 }
1128 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001129 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001130 dev->dvb.frontend = dvb_attach(tda10046_attach,
1131 &medion_cardbus,
1132 &dev->i2c_adap);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001133 if (dev->dvb.frontend) {
1134 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1135 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001136
1137 dvb_attach(dvb_pll_attach, dev->dvb.frontend, medion_cardbus.tuner_address,
Michael Krufky47a99912007-06-12 16:10:51 -03001138 &dev->i2c_adap, DVB_PLL_FMD1216ME);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001139 }
1140 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001141 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1142 dev->dvb.frontend = dvb_attach(tda10046_attach,
1143 &philips_europa_config,
1144 &dev->i2c_adap);
1145 if (dev->dvb.frontend) {
1146 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1147 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1148 }
1149 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001150 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001151 configure_tda827x_fe(dev, &cinergy_ht_config);
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001152 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001153 case SAA7134_BOARD_CINERGY_HT_PCI:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001154 configure_tda827x_fe(dev, &cinergy_ht_pci_config);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001155 break;
1156 case SAA7134_BOARD_PHILIPS_TIGER_S:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001157 configure_tda827x_fe(dev, &philips_tiger_s_config);
Michael Krufky9de271e2007-01-16 18:36:40 -03001158 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001159 case SAA7134_BOARD_ASUS_P7131_4871:
1160 configure_tda827x_fe(dev, &asus_p7131_4871_config);
1161 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001162 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1163 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001164 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001165 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
1166 configure_tda827x_fe(dev, &avermedia_super_007_config);
1167 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001168 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
1169 configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config);
1170 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001171 case SAA7134_BOARD_PHILIPS_SNAKE:
1172 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1173 &dev->i2c_adap);
1174 if (dev->dvb.frontend) {
1175 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1176 &dev->i2c_adap, 0) == NULL)
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001177 wprintk("%s: No tda826x found!\n", __func__);
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001178 if (dvb_attach(lnbp21_attach, dev->dvb.frontend,
1179 &dev->i2c_adap, 0, 0) == NULL)
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001180 wprintk("%s: No lnbp21 found!\n", __func__);
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001181 }
1182 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001183 case SAA7134_BOARD_CREATIX_CTX953:
1184 configure_tda827x_fe(dev, &md8800_dvbt_config);
1185 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001186 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
1187 configure_tda827x_fe(dev, &philips_tiger_s_config);
1188 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001189 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
1190 dev->dvb.frontend = dvb_attach(mt352_attach,
1191 &avermedia_e506r_mt352_dev,
1192 &dev->i2c_adap);
1193 attach_xc3028 = 1;
1194 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001195 case SAA7134_BOARD_MD7134_BRIDGE_2:
1196 dev->dvb.frontend = dvb_attach(tda10086_attach,
1197 &flydvbs, &dev->i2c_adap);
1198 if (dev->dvb.frontend) {
1199 struct dvb_frontend *fe;
1200 if (dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
1201 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL)
1202 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001203 "found !\n", __func__);
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001204 /* we need to open the i2c gate (we know it exists) */
1205 fe = dev->dvb.frontend;
1206 fe->ops.i2c_gate_ctrl(fe, 1);
1207 if (dvb_attach(isl6405_attach, fe,
1208 &dev->i2c_adap, 0x08, 0, 0) == NULL)
1209 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001210 "found !\n", __func__);
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001211 fe->ops.i2c_gate_ctrl(fe, 0);
1212 dev->original_set_voltage = fe->ops.set_voltage;
1213 fe->ops.set_voltage = md8800_set_voltage;
1214 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1215 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1216 }
1217 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001219 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 break;
1221 }
1222
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001223 if (attach_xc3028) {
1224 struct dvb_frontend *fe;
1225 struct xc2028_config cfg = {
1226 .i2c_adap = &dev->i2c_adap,
1227 .i2c_addr = 0x61,
Mauro Carvalho Chehab50407f92008-04-22 14:46:02 -03001228 .video_dev = dev->i2c_adap.algo_data,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001229 };
1230 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
1231 if (!fe) {
1232 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1233 dev->name);
1234 dvb_frontend_detach(dev->dvb.frontend);
1235 dvb_unregister_frontend(dev->dvb.frontend);
1236 dev->dvb.frontend = NULL;
1237 return -1;
1238 }
1239 }
1240
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 if (NULL == dev->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001242 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 return -1;
1244 }
1245
1246 /* register everything else */
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001247 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1248
1249 /* this sequence is necessary to make the tda1004x load its firmware
1250 * and to enter analog mode of hybrid boards
1251 */
1252 if (!ret) {
1253 if (dev->dvb.frontend->ops.init)
1254 dev->dvb.frontend->ops.init(dev->dvb.frontend);
1255 if (dev->dvb.frontend->ops.sleep)
1256 dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
Hartmut Hackmann9971f4f2007-03-23 21:00:07 -03001257 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1258 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001259 }
1260 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261}
1262
1263static int dvb_fini(struct saa7134_dev *dev)
1264{
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001265 /* FIXME: I suspect that this code is bogus, since the entry for
1266 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1267 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1268 */
1269 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1270 struct v4l2_priv_tun_config tda9887_cfg;
1271 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001272
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001273 tda9887_cfg.tuner = TUNER_TDA9887;
1274 tda9887_cfg.priv = &on;
1275
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276 /* otherwise we don't detect the tuner on next insmod */
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001277 saa7134_i2c_call_clients(dev, TUNER_SET_CONFIG, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001278 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
1279 if ((dev->eedata[2] != 0x08) && use_frontend) {
1280 /* turn off the 2nd lnb supply */
1281 u8 data = 0x80;
1282 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1283 struct dvb_frontend *fe;
1284 fe = dev->dvb.frontend;
1285 if (fe->ops.i2c_gate_ctrl) {
1286 fe->ops.i2c_gate_ctrl(fe, 1);
1287 i2c_transfer(&dev->i2c_adap, &msg, 1);
1288 fe->ops.i2c_gate_ctrl(fe, 0);
1289 }
1290 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001291 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001292 videobuf_dvb_unregister(&dev->dvb);
1293 return 0;
1294}
1295
1296static struct saa7134_mpeg_ops dvb_ops = {
1297 .type = SAA7134_MPEG_DVB,
1298 .init = dvb_init,
1299 .fini = dvb_fini,
1300};
1301
1302static int __init dvb_register(void)
1303{
1304 return saa7134_ts_register(&dvb_ops);
1305}
1306
1307static void __exit dvb_unregister(void)
1308{
1309 saa7134_ts_unregister(&dvb_ops);
1310}
1311
1312module_init(dvb_register);
1313module_exit(dvb_unregister);
1314
1315/* ------------------------------------------------------------------ */
1316/*
1317 * Local variables:
1318 * c-basic-offset: 8
1319 * End:
1320 */