blob: 65aec881bbde9a4e6f5dd622b3032a34963f9c15 [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"
Linus Torvalds1da177e2005-04-16 15:20:36 -070041
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030042#include "tda10086.h"
43#include "tda826x.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030044#include "tda827x.h"
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030045#include "isl6421.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030046
Linus Torvalds1da177e2005-04-16 15:20:36 -070047MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
48MODULE_LICENSE("GPL");
49
50static unsigned int antenna_pwr = 0;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070051
Linus Torvalds1da177e2005-04-16 15:20:36 -070052module_param(antenna_pwr, int, 0444);
53MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
54
Stephan Berberigb331daa2006-12-20 09:37:05 -030055static int use_frontend = 0;
56module_param(use_frontend, int, 0644);
57MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030058
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030059static int debug = 0;
60module_param(debug, int, 0644);
61MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
62
Trent Piephocf3c34c2007-03-07 18:19:48 -030063#define dprintk(fmt, arg...) do { if (debug) \
64 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
65
66/* Print a warning */
67#define wprintk(fmt, arg...) \
68 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030069
70/* ------------------------------------------------------------------
71 * mt352 based DVB-T cards
72 */
73
Linus Torvalds1da177e2005-04-16 15:20:36 -070074static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
75{
76 u32 ok;
77
78 if (!on) {
79 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
80 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
81 return 0;
82 }
83
84 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
85 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
86 udelay(10);
87
88 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
89 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
90 udelay(10);
91 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
92 udelay(10);
93 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Trent Piephocf3c34c2007-03-07 18:19:48 -030094 dprintk("%s %s\n", __FUNCTION__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
96 if (!ok)
97 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
98 return ok;
99}
100
101static int mt352_pinnacle_init(struct dvb_frontend* fe)
102{
103 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
104 static u8 reset [] = { RESET, 0x80 };
105 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
106 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
107 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
108 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
109 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
110 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
111 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
112 struct saa7134_dev *dev= fe->dvb->priv;
113
Trent Piephocf3c34c2007-03-07 18:19:48 -0300114 dprintk("%s called\n", __FUNCTION__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116 mt352_write(fe, clock_config, sizeof(clock_config));
117 udelay(200);
118 mt352_write(fe, reset, sizeof(reset));
119 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
120 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
121 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
122 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
123
124 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
125 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
126 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300127
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 return 0;
129}
130
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200131static int mt352_aver777_init(struct dvb_frontend* fe)
132{
133 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
134 static u8 reset [] = { RESET, 0x80 };
135 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
136 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
137 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
138
139 mt352_write(fe, clock_config, sizeof(clock_config));
140 udelay(200);
141 mt352_write(fe, reset, sizeof(reset));
142 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
143 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
144 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
145
146 return 0;
147}
148
Andrew de Quincey0463f122006-05-16 17:22:02 -0300149static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
150 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300152 u8 off[] = { 0x00, 0xf1};
153 u8 on[] = { 0x00, 0x71};
154 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
155
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 struct saa7134_dev *dev = fe->dvb->priv;
157 struct v4l2_frequency f;
158
159 /* set frequency (mt2050) */
160 f.tuner = 0;
161 f.type = V4L2_TUNER_DIGITAL_TV;
162 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300163 if (fe->ops.i2c_gate_ctrl)
164 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300165 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300167 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300168 if (fe->ops.i2c_gate_ctrl)
169 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300170 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
172 pinnacle_antenna_pwr(dev, antenna_pwr);
173
174 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300175 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176}
177
Andrew de Quinceybd4956b2006-04-18 21:38:49 -0300178static int mt352_aver777_tuner_calc_regs(struct dvb_frontend *fe, struct dvb_frontend_parameters *params, u8* pllbuf, int buf_len)
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200179{
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300180 if (buf_len < 5)
181 return -EINVAL;
182
183 pllbuf[0] = 0x61;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200184 dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1,
185 params->frequency,
186 params->u.ofdm.bandwidth);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300187 return 5;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200188}
189
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190static struct mt352_config pinnacle_300i = {
191 .demod_address = 0x3c >> 1,
192 .adc_clock = 20333,
193 .if2 = 36150,
194 .no_tuner = 1,
195 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200197
198static struct mt352_config avermedia_777 = {
199 .demod_address = 0xf,
200 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200201};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300203/* ==================================================================
204 * tda1004x based DVB-T cards, helper functions
205 */
206
207static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
208 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700209{
210 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300211 return request_firmware(fw, name, &dev->pci->dev);
212}
213
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300214/* ------------------------------------------------------------------
215 * these tuners are tu1216, td1316(a)
216 */
217
218static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
219{
220 struct saa7134_dev *dev = fe->dvb->priv;
221 struct tda1004x_state *state = fe->demodulator_priv;
222 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700223 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800224 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700225 sizeof(tuner_buf) };
226 int tuner_frequency = 0;
227 u8 band, cp, filter;
228
229 /* determine charge pump */
230 tuner_frequency = params->frequency + 36166000;
231 if (tuner_frequency < 87000000)
232 return -EINVAL;
233 else if (tuner_frequency < 130000000)
234 cp = 3;
235 else if (tuner_frequency < 160000000)
236 cp = 5;
237 else if (tuner_frequency < 200000000)
238 cp = 6;
239 else if (tuner_frequency < 290000000)
240 cp = 3;
241 else if (tuner_frequency < 420000000)
242 cp = 5;
243 else if (tuner_frequency < 480000000)
244 cp = 6;
245 else if (tuner_frequency < 620000000)
246 cp = 3;
247 else if (tuner_frequency < 830000000)
248 cp = 5;
249 else if (tuner_frequency < 895000000)
250 cp = 7;
251 else
252 return -EINVAL;
253
254 /* determine band */
255 if (params->frequency < 49000000)
256 return -EINVAL;
257 else if (params->frequency < 161000000)
258 band = 1;
259 else if (params->frequency < 444000000)
260 band = 2;
261 else if (params->frequency < 861000000)
262 band = 4;
263 else
264 return -EINVAL;
265
266 /* setup PLL filter */
267 switch (params->u.ofdm.bandwidth) {
268 case BANDWIDTH_6_MHZ:
269 filter = 0;
270 break;
271
272 case BANDWIDTH_7_MHZ:
273 filter = 0;
274 break;
275
276 case BANDWIDTH_8_MHZ:
277 filter = 1;
278 break;
279
280 default:
281 return -EINVAL;
282 }
283
284 /* calculate divisor
285 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
286 */
287 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
288
289 /* setup tuner buffer */
290 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
291 tuner_buf[1] = tuner_frequency & 0xff;
292 tuner_buf[2] = 0xca;
293 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
294
Patrick Boettcherdea74862006-05-14 05:01:31 -0300295 if (fe->ops.i2c_gate_ctrl)
296 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300297 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300298 wprintk("could not write to tuner at addr: 0x%02x\n",
299 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700300 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300301 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700302 msleep(1);
303 return 0;
304}
305
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300306static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800307{
308 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300309 struct tda1004x_state *state = fe->demodulator_priv;
310 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800311 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
312 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
313
314 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300315 if (fe->ops.i2c_gate_ctrl)
316 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800317 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
318 return -EIO;
319 msleep(1);
320
321 return 0;
322}
323
324/* ------------------------------------------------------------------ */
325
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800326static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700327 .demod_address = 0x8,
328 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800329 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700330 .xtal_freq = TDA10046_XTAL_4M,
331 .agc_config = TDA10046_AGC_DEFAULT,
332 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300333 .tuner_address = 0x60,
334 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335};
336
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800337static struct tda1004x_config philips_tu1216_61_config = {
338
339 .demod_address = 0x8,
340 .invert = 1,
341 .invert_oclk = 0,
342 .xtal_freq = TDA10046_XTAL_4M,
343 .agc_config = TDA10046_AGC_DEFAULT,
344 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300345 .tuner_address = 0x61,
346 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800347};
348
349/* ------------------------------------------------------------------ */
350
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300351static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800352{
353 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300354 struct tda1004x_state *state = fe->demodulator_priv;
355 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800356 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300357 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800358
359 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300360 if (fe->ops.i2c_gate_ctrl)
361 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800362 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
363 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800364 return 0;
365}
366
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300367static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800368{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300369 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800370}
371
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300372static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
373{
374 struct saa7134_dev *dev = fe->dvb->priv;
375 struct tda1004x_state *state = fe->demodulator_priv;
376 u8 addr = state->config->tuner_address;
377 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
378 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
379
380 /* switch the tuner to analog mode */
381 if (fe->ops.i2c_gate_ctrl)
382 fe->ops.i2c_gate_ctrl(fe, 1);
383 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
384 return -EIO;
385 return 0;
386}
387
388/* ------------------------------------------------------------------ */
389
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300390static int philips_europa_tuner_init(struct dvb_frontend *fe)
391{
392 struct saa7134_dev *dev = fe->dvb->priv;
393 static u8 msg[] = { 0x00, 0x40};
394 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
395
396
397 if (philips_td1316_tuner_init(fe))
398 return -EIO;
399 msleep(1);
400 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
401 return -EIO;
402
403 return 0;
404}
405
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300406static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800407{
408 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800409
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300410 static u8 msg[] = { 0x00, 0x14 };
411 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
412
413 if (philips_td1316_tuner_sleep(fe))
414 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800415
416 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300417 if (fe->ops.i2c_gate_ctrl)
418 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800419 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300420 return 0;
421}
422
423static int philips_europa_demod_sleep(struct dvb_frontend *fe)
424{
425 struct saa7134_dev *dev = fe->dvb->priv;
426
427 if (dev->original_demod_sleep)
428 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300429 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300430 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800431}
432
433static struct tda1004x_config philips_europa_config = {
434
435 .demod_address = 0x8,
436 .invert = 0,
437 .invert_oclk = 0,
438 .xtal_freq = TDA10046_XTAL_4M,
439 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
440 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300441 .tuner_address = 0x61,
442 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800443};
444
445/* ------------------------------------------------------------------ */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700446
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300447static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700448{
449 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300450 struct tda1004x_state *state = fe->demodulator_priv;
451 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700452 /* this message is to set up ATC and ALC */
453 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300454 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700455
Patrick Boettcherdea74862006-05-14 05:01:31 -0300456 if (fe->ops.i2c_gate_ctrl)
457 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700458 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
459 return -EIO;
460 msleep(1);
461
462 return 0;
463}
464
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300465static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700466{
467 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300468 struct tda1004x_state *state = fe->demodulator_priv;
469 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700470 /* this message actually turns the tuner back to analog mode */
Hartmut Hackmanncf83ac42007-03-13 20:52:35 -0300471 u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300472 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700473
Patrick Boettcherdea74862006-05-14 05:01:31 -0300474 if (fe->ops.i2c_gate_ctrl)
475 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700476 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
477 msleep(1);
478 fmd1216_init[2] = 0x86;
479 fmd1216_init[3] = 0x54;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300480 if (fe->ops.i2c_gate_ctrl)
481 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700482 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
483 msleep(1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300484 return 0;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700485}
486
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300487static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700488{
489 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300490 struct tda1004x_state *state = fe->demodulator_priv;
491 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700492 u8 tuner_buf[4];
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300493 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700494 sizeof(tuner_buf) };
495 int tuner_frequency = 0;
496 int divider = 0;
497 u8 band, mode, cp;
498
499 /* determine charge pump */
500 tuner_frequency = params->frequency + 36130000;
501 if (tuner_frequency < 87000000)
502 return -EINVAL;
503 /* low band */
504 else if (tuner_frequency < 180000000) {
505 band = 1;
506 mode = 7;
507 cp = 0;
508 } else if (tuner_frequency < 195000000) {
509 band = 1;
510 mode = 6;
511 cp = 1;
512 /* mid band */
513 } else if (tuner_frequency < 366000000) {
514 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
515 band = 10;
516 } else {
517 band = 2;
518 }
519 mode = 7;
520 cp = 0;
521 } else if (tuner_frequency < 478000000) {
522 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
523 band = 10;
524 } else {
525 band = 2;
526 }
527 mode = 6;
528 cp = 1;
529 /* high band */
530 } else if (tuner_frequency < 662000000) {
531 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
532 band = 12;
533 } else {
534 band = 4;
535 }
536 mode = 7;
537 cp = 0;
538 } else if (tuner_frequency < 840000000) {
539 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
540 band = 12;
541 } else {
542 band = 4;
543 }
544 mode = 6;
545 cp = 1;
546 } else {
547 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
548 band = 12;
549 } else {
550 band = 4;
551 }
552 mode = 7;
553 cp = 1;
554
555 }
556 /* calculate divisor */
557 /* ((36166000 + Finput) / 166666) rounded! */
558 divider = (tuner_frequency + 83333) / 166667;
559
560 /* setup tuner buffer */
561 tuner_buf[0] = (divider >> 8) & 0x7f;
562 tuner_buf[1] = divider & 0xff;
563 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
564 tuner_buf[3] = 0x40 | band;
565
Patrick Boettcherdea74862006-05-14 05:01:31 -0300566 if (fe->ops.i2c_gate_ctrl)
567 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300568 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300569 wprintk("could not write to tuner at addr: 0x%02x\n",
570 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700571 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300572 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700573 return 0;
574}
575
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700576static struct tda1004x_config medion_cardbus = {
577 .demod_address = 0x08,
578 .invert = 1,
579 .invert_oclk = 0,
580 .xtal_freq = TDA10046_XTAL_16M,
581 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
582 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300583 .tuner_address = 0x61,
584 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700585};
586
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300587/* ------------------------------------------------------------------
588 * tda 1004x based cards with philips silicon tuner
589 */
590
591static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
592{
593 struct saa7134_dev *dev = fe->dvb->priv;
594 struct tda1004x_state *state = fe->demodulator_priv;
595 u8 addr = state->config->i2c_gate;
596 u8 config = state->config->tuner_config;
597 u8 GP00_CF[] = {0x20, 0x01};
598 u8 GP00_LEV[] = {0x22, 0x00};
599
600 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
601 if (config) {
602 if (high) {
603 dprintk("setting LNA to high gain\n");
604 } else {
605 dprintk("setting LNA to low gain\n");
606 }
607 }
608 switch (config) {
609 case 0: /* no LNA */
610 break;
611 case 1: /* switch is GPIO 0 of tda8290 */
612 case 2:
613 /* turn Vsync off */
614 saa7134_set_gpio(dev, 22, 0);
615 GP00_LEV[1] = high ? 0 : 1;
616 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300617 wprintk("could not access tda8290 at addr: 0x%02x\n",
618 addr << 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300619 return;
620 }
621 msg.buf = GP00_LEV;
622 if (config == 2)
623 GP00_LEV[1] = high ? 1 : 0;
624 i2c_transfer(&dev->i2c_adap, &msg, 1);
625 break;
626 case 3: /* switch with GPIO of saa713x */
627 saa7134_set_gpio(dev, 22, high);
628 break;
629 }
630}
631
632static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
633{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300634 struct tda1004x_state *state = fe->demodulator_priv;
635
636 u8 addr = state->config->i2c_gate;
637 static u8 tda8290_close[] = { 0x21, 0xc0};
638 static u8 tda8290_open[] = { 0x21, 0x80};
639 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
640 if (enable) {
641 tda8290_msg.buf = tda8290_close;
642 } else {
643 tda8290_msg.buf = tda8290_open;
644 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300645 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300646 struct saa7134_dev *dev = fe->dvb->priv;
647 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300648 return -EIO;
649 }
650 msleep(20);
651 return 0;
652}
653
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700654/* ------------------------------------------------------------------ */
655
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300656static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300657{
658 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300659 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300660
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300661 switch (state->config->antenna_switch) {
662 case 0: break;
663 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
664 saa7134_set_gpio(dev, 21, 0);
665 break;
666 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
667 saa7134_set_gpio(dev, 21, 1);
668 break;
669 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300670 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800671}
672
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300673static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
674{
675 struct saa7134_dev *dev = fe->dvb->priv;
676 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300677
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300678 switch (state->config->antenna_switch) {
679 case 0: break;
680 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
681 saa7134_set_gpio(dev, 21, 1);
682 break;
683 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
684 saa7134_set_gpio(dev, 21, 0);
685 break;
686 }
687 return 0;
688}
689
Michael Krufky8ce47da2007-04-27 12:31:14 -0300690static struct tda827x_config tda827x_cfg = {
691 .lna_gain = philips_tda827x_lna_gain,
692 .init = philips_tda827x_tuner_init,
693 .sleep = philips_tda827x_tuner_sleep
694};
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300695
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -0300696static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300697{
698 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
699 if (dev->dvb.frontend) {
700 if (tda_conf->i2c_gate)
701 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
Hartmut Hackmannede22002007-04-27 12:31:32 -0300702 if (dvb_attach(tda827x_attach, dev->dvb.frontend, tda_conf->tuner_address,
703 &dev->i2c_adap,&tda827x_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300704 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -0300705 tda_conf->tuner_address);
706 }
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300707 }
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300708}
709
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800710/* ------------------------------------------------------------------ */
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300711static struct tda1004x_config tda827x_lifeview_config = {
712 .demod_address = 0x08,
713 .invert = 1,
714 .invert_oclk = 0,
715 .xtal_freq = TDA10046_XTAL_16M,
716 .agc_config = TDA10046_AGC_TDA827X,
717 .gpio_config = TDA10046_GP11_I,
718 .if_freq = TDA10046_FREQ_045,
719 .tuner_address = 0x60,
720 .request_firmware = philips_tda1004x_request_firmware
721};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800722
723static struct tda1004x_config philips_tiger_config = {
724 .demod_address = 0x08,
725 .invert = 1,
726 .invert_oclk = 0,
727 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300728 .agc_config = TDA10046_AGC_TDA827X,
729 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300730 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300731 .i2c_gate = 0x4b,
732 .tuner_address = 0x61,
733 .tuner_config = 0,
734 .antenna_switch= 1,
735 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300736};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300737
738static struct tda1004x_config cinergy_ht_config = {
739 .demod_address = 0x08,
740 .invert = 1,
741 .invert_oclk = 0,
742 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300743 .agc_config = TDA10046_AGC_TDA827X,
744 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800745 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300746 .i2c_gate = 0x4b,
747 .tuner_address = 0x61,
748 .tuner_config = 0,
749 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800750};
751
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300752static struct tda1004x_config cinergy_ht_pci_config = {
753 .demod_address = 0x08,
754 .invert = 1,
755 .invert_oclk = 0,
756 .xtal_freq = TDA10046_XTAL_16M,
757 .agc_config = TDA10046_AGC_TDA827X,
758 .gpio_config = TDA10046_GP01_I,
759 .if_freq = TDA10046_FREQ_045,
760 .i2c_gate = 0x4b,
761 .tuner_address = 0x60,
762 .tuner_config = 0,
763 .request_firmware = philips_tda1004x_request_firmware
764};
765
766static struct tda1004x_config philips_tiger_s_config = {
767 .demod_address = 0x08,
768 .invert = 1,
769 .invert_oclk = 0,
770 .xtal_freq = TDA10046_XTAL_16M,
771 .agc_config = TDA10046_AGC_TDA827X,
772 .gpio_config = TDA10046_GP01_I,
773 .if_freq = TDA10046_FREQ_045,
774 .i2c_gate = 0x4b,
775 .tuner_address = 0x61,
776 .tuner_config = 2,
777 .antenna_switch= 1,
778 .request_firmware = philips_tda1004x_request_firmware
779};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200780
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300781static struct tda1004x_config pinnacle_pctv_310i_config = {
782 .demod_address = 0x08,
783 .invert = 1,
784 .invert_oclk = 0,
785 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300786 .agc_config = TDA10046_AGC_TDA827X,
787 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300788 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300789 .i2c_gate = 0x4b,
790 .tuner_address = 0x61,
791 .tuner_config = 1,
792 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300793};
794
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300795static struct tda1004x_config hauppauge_hvr_1110_config = {
796 .demod_address = 0x08,
797 .invert = 1,
798 .invert_oclk = 0,
799 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300800 .agc_config = TDA10046_AGC_TDA827X,
801 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300802 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300803 .i2c_gate = 0x4b,
804 .tuner_address = 0x61,
805 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300806};
807
Hartmut Hackmann83646812006-10-12 20:38:51 -0300808static struct tda1004x_config asus_p7131_dual_config = {
809 .demod_address = 0x08,
810 .invert = 1,
811 .invert_oclk = 0,
812 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300813 .agc_config = TDA10046_AGC_TDA827X,
814 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300815 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300816 .i2c_gate = 0x4b,
817 .tuner_address = 0x61,
818 .tuner_config = 0,
819 .antenna_switch= 2,
820 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300821};
822
Nico Sabbi420f32f2006-03-03 12:11:28 -0300823static struct tda1004x_config lifeview_trio_config = {
824 .demod_address = 0x09,
825 .invert = 1,
826 .invert_oclk = 0,
827 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300828 .agc_config = TDA10046_AGC_TDA827X,
829 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300830 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300831 .tuner_address = 0x60,
832 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300833};
834
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300835static struct tda1004x_config tevion_dvbt220rf_config = {
836 .demod_address = 0x08,
837 .invert = 1,
838 .invert_oclk = 0,
839 .xtal_freq = TDA10046_XTAL_16M,
840 .agc_config = TDA10046_AGC_TDA827X,
841 .gpio_config = TDA10046_GP11_I,
842 .if_freq = TDA10046_FREQ_045,
843 .tuner_address = 0x60,
844 .request_firmware = philips_tda1004x_request_firmware
845};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300846
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300847static struct tda1004x_config md8800_dvbt_config = {
848 .demod_address = 0x08,
849 .invert = 1,
850 .invert_oclk = 0,
851 .xtal_freq = TDA10046_XTAL_16M,
852 .agc_config = TDA10046_AGC_TDA827X,
853 .gpio_config = TDA10046_GP01_I,
854 .if_freq = TDA10046_FREQ_045,
855 .i2c_gate = 0x4b,
856 .tuner_address = 0x60,
857 .tuner_config = 0,
858 .request_firmware = philips_tda1004x_request_firmware
859};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200860
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300861static struct tda1004x_config asus_p7131_4871_config = {
862 .demod_address = 0x08,
863 .invert = 1,
864 .invert_oclk = 0,
865 .xtal_freq = TDA10046_XTAL_16M,
866 .agc_config = TDA10046_AGC_TDA827X,
867 .gpio_config = TDA10046_GP01_I,
868 .if_freq = TDA10046_FREQ_045,
869 .i2c_gate = 0x4b,
870 .tuner_address = 0x61,
871 .tuner_config = 2,
872 .antenna_switch= 2,
873 .request_firmware = philips_tda1004x_request_firmware
874};
875
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300876static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300877 .demod_address = 0x08,
878 .invert = 1,
879 .invert_oclk = 0,
880 .xtal_freq = TDA10046_XTAL_16M,
881 .agc_config = TDA10046_AGC_TDA827X,
882 .gpio_config = TDA10046_GP11_I,
883 .if_freq = TDA10046_FREQ_045,
884 .i2c_gate = 0x4b,
885 .tuner_address = 0x61,
886 .tuner_config = 2,
887 .antenna_switch= 2,
888 .request_firmware = philips_tda1004x_request_firmware
889};
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300890/* ------------------------------------------------------------------
891 * special case: this card uses saa713x GPIO22 for the mode switch
892 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200893
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300894static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200895{
896 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300897 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200898 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300899 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200900 return 0;
901}
902
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300903static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200904{
905 struct saa7134_dev *dev = fe->dvb->priv;
906 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300907 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300908 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300909 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200910}
911
Michael Krufky8ce47da2007-04-27 12:31:14 -0300912static struct tda827x_config ads_duo_cfg = {
913 .lna_gain = philips_tda827x_lna_gain,
914 .init = ads_duo_tuner_init,
915 .sleep = ads_duo_tuner_sleep
916};
917
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200918static struct tda1004x_config ads_tech_duo_config = {
919 .demod_address = 0x08,
920 .invert = 1,
921 .invert_oclk = 0,
922 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300923 .agc_config = TDA10046_AGC_TDA827X,
924 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200925 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300926 .tuner_address = 0x61,
927 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200928};
929
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300930/* ==================================================================
931 * tda10086 based DVB-S cards, helper functions
932 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300933
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300934static struct tda10086_config flydvbs = {
935 .demod_address = 0x0e,
936 .invert = 0,
937};
938
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300939/* ==================================================================
940 * nxt200x based ATSC cards, helper functions
941 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800942
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800943static struct nxt200x_config avertvhda180 = {
944 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800945};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300946
Curt Meyersfbc81c02006-02-27 00:08:27 -0300947static int nxt200x_set_pll_input(u8 *buf, int input)
948{
949 if (input)
950 buf[3] |= 0x08;
951 else
952 buf[3] &= ~0x08;
953 return 0;
954}
955
Andrew Burri3e1410a2006-02-27 00:08:23 -0300956static struct nxt200x_config kworldatsc110 = {
957 .demod_address = 0x0a,
Curt Meyersfbc81c02006-02-27 00:08:27 -0300958 .set_pll_input = nxt200x_set_pll_input,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300959};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800960
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300961/* ==================================================================
962 * Core code
963 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700964
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965static int dvb_init(struct saa7134_dev *dev)
966{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -0300967 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968 /* init struct videobuf_dvb */
969 dev->ts.nr_bufs = 32;
970 dev->ts.nr_packets = 32*4;
971 dev->dvb.name = dev->name;
972 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
973 dev->pci, &dev->slock,
974 V4L2_BUF_TYPE_VIDEO_CAPTURE,
975 V4L2_FIELD_ALTERNATE,
976 sizeof(struct saa7134_buf),
977 dev);
978
979 switch (dev->board) {
980 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300981 dprintk("pinnacle 300i dvb setup\n");
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300982 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300983 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300984 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300985 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300986 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200988 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -0300989 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300990 dprintk("avertv 777 dvb setup\n");
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300991 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300992 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300993 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300994 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300995 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200996 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997 case SAA7134_BOARD_MD7134:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300998 dev->dvb.frontend = dvb_attach(tda10046_attach,
999 &medion_cardbus,
1000 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001001 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -03001002 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1003 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1004 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001005 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001007 case SAA7134_BOARD_PHILIPS_TOUGH:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001008 dev->dvb.frontend = dvb_attach(tda10046_attach,
1009 &philips_tu1216_60_config,
1010 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001011 if (dev->dvb.frontend) {
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001012 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1013 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001014 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001015 break;
1016 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001017 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001018 configure_tda827x_fe(dev, &tda827x_lifeview_config);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001019 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001020 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001021 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001022 dev->dvb.frontend = dvb_attach(tda10046_attach,
1023 &philips_europa_config,
1024 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001025 if (dev->dvb.frontend) {
Hartmut Hackmann588f9832006-10-18 17:30:42 -03001026 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1027 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Patrick Boettcherdea74862006-05-14 05:01:31 -03001028 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1029 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1030 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001031 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001032 break;
1033 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001034 dev->dvb.frontend = dvb_attach(tda10046_attach,
1035 &philips_tu1216_61_config,
1036 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001037 if (dev->dvb.frontend) {
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001038 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1039 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001040 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001041 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001042 case SAA7134_BOARD_PHILIPS_TIGER:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001043 configure_tda827x_fe(dev, &philips_tiger_config);
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001044 break;
1045 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001046 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config);
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001047 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001048 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001049 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config);
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001050 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001051 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001052 configure_tda827x_fe(dev, &asus_p7131_dual_config);
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001053 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001054 case SAA7134_BOARD_FLYDVBT_LR301:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001055 configure_tda827x_fe(dev, &tda827x_lifeview_config);
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001056 break;
Nico Sabbi420f32f2006-03-03 12:11:28 -03001057 case SAA7134_BOARD_FLYDVB_TRIO:
Stephan Berberigb331daa2006-12-20 09:37:05 -03001058 if(! use_frontend) { //terrestrial
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001059 configure_tda827x_fe(dev, &lifeview_trio_config);
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001060 } else { //satellite
1061 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1062 if (dev->dvb.frontend) {
1063 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1064 &dev->i2c_adap, 0) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001065 wprintk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001066 }
1067 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1068 0x08, 0, 0) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001069 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001070 }
1071 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001072 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001073 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001074 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001075 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001076 dev->dvb.frontend = dvb_attach(tda10046_attach,
1077 &ads_tech_duo_config,
1078 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001079 if (dev->dvb.frontend) {
Hartmut Hackmannede22002007-04-27 12:31:32 -03001080 if (dvb_attach(tda827x_attach,dev->dvb.frontend,
Michael Krufky8ce47da2007-04-27 12:31:14 -03001081 ads_tech_duo_config.tuner_address,
Hartmut Hackmannede22002007-04-27 12:31:32 -03001082 &dev->i2c_adap,&ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001083 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001084 ads_tech_duo_config.tuner_address);
1085 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001086 }
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001087 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001088 case SAA7134_BOARD_TEVION_DVBT_220RF:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001089 configure_tda827x_fe(dev, &tevion_dvbt220rf_config);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001090 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001091 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001092 configure_tda827x_fe(dev, &md8800_dvbt_config);
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001093 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001094 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001095 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1096 &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001097 if (dev->dvb.frontend) {
Michael Krufky4ad8eee52006-08-08 15:48:08 -03001098 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1099 NULL, &dvb_pll_tdhu2);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001100 }
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001101 break;
Andrew Burri3e1410a2006-02-27 00:08:23 -03001102 case SAA7134_BOARD_KWORLD_ATSC110:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001103 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1104 &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001105 if (dev->dvb.frontend) {
Michael Krufky4ad8eee52006-08-08 15:48:08 -03001106 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1107 NULL, &dvb_pll_tuv1236d);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001108 }
Andrew Burri3e1410a2006-02-27 00:08:23 -03001109 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001110 case SAA7134_BOARD_FLYDVBS_LR300:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001111 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1112 &dev->i2c_adap);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001113 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001114 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1115 &dev->i2c_adap, 0) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001116 wprintk("%s: No tda826x found!\n", __FUNCTION__);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001117 }
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001118 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1119 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001120 wprintk("%s: No ISL6421 found!\n", __FUNCTION__);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001121 }
1122 }
1123 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001124 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1125 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
1126 &dev->i2c_adap);
1127 if (dev->dvb.frontend) {
1128 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1129 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1130 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1131 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1132 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
1133 }
1134 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001135 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1136 dev->dvb.frontend = dvb_attach(tda10046_attach,
1137 &philips_europa_config,
1138 &dev->i2c_adap);
1139 if (dev->dvb.frontend) {
1140 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1141 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1142 }
1143 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001144 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001145 configure_tda827x_fe(dev, &cinergy_ht_config);
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001146 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001147 case SAA7134_BOARD_CINERGY_HT_PCI:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001148 configure_tda827x_fe(dev, &cinergy_ht_pci_config);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001149 break;
1150 case SAA7134_BOARD_PHILIPS_TIGER_S:
Hartmut Hackmannb8bc76d2007-04-27 12:31:16 -03001151 configure_tda827x_fe(dev, &philips_tiger_s_config);
Michael Krufky9de271e2007-01-16 18:36:40 -03001152 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001153 case SAA7134_BOARD_ASUS_P7131_4871:
1154 configure_tda827x_fe(dev, &asus_p7131_4871_config);
1155 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001156 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
1157 configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config);
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001158 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001160 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 break;
1162 }
1163
1164 if (NULL == dev->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001165 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 return -1;
1167 }
1168
1169 /* register everything else */
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001170 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1171
1172 /* this sequence is necessary to make the tda1004x load its firmware
1173 * and to enter analog mode of hybrid boards
1174 */
1175 if (!ret) {
1176 if (dev->dvb.frontend->ops.init)
1177 dev->dvb.frontend->ops.init(dev->dvb.frontend);
1178 if (dev->dvb.frontend->ops.sleep)
1179 dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
Hartmut Hackmann9971f4f2007-03-23 21:00:07 -03001180 if (dev->dvb.frontend->ops.tuner_ops.sleep)
1181 dev->dvb.frontend->ops.tuner_ops.sleep(dev->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001182 }
1183 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184}
1185
1186static int dvb_fini(struct saa7134_dev *dev)
1187{
1188 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1189
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 switch (dev->board) {
1191 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1192 /* otherwise we don't detect the tuner on next insmod */
1193 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1194 break;
1195 };
1196 videobuf_dvb_unregister(&dev->dvb);
1197 return 0;
1198}
1199
1200static struct saa7134_mpeg_ops dvb_ops = {
1201 .type = SAA7134_MPEG_DVB,
1202 .init = dvb_init,
1203 .fini = dvb_fini,
1204};
1205
1206static int __init dvb_register(void)
1207{
1208 return saa7134_ts_register(&dvb_ops);
1209}
1210
1211static void __exit dvb_unregister(void)
1212{
1213 saa7134_ts_unregister(&dvb_ops);
1214}
1215
1216module_init(dvb_register);
1217module_exit(dvb_unregister);
1218
1219/* ------------------------------------------------------------------ */
1220/*
1221 * Local variables:
1222 * c-basic-offset: 8
1223 * End:
1224 */