blob: 6f98ec40553c8fa396939feeb8c5c833fbe34f25 [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
63#define dprintk(fmt, arg...) if (debug) \
64 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg)
65
66/* ------------------------------------------------------------------
67 * mt352 based DVB-T cards
68 */
69
Linus Torvalds1da177e2005-04-16 15:20:36 -070070static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
71{
72 u32 ok;
73
74 if (!on) {
75 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
76 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
77 return 0;
78 }
79
80 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
81 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
82 udelay(10);
83
84 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
85 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
86 udelay(10);
87 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
88 udelay(10);
89 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
90 printk("%s: %s %s\n", dev->name, __FUNCTION__,
91 ok ? "on" : "off");
92
93 if (!ok)
94 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
95 return ok;
96}
97
98static int mt352_pinnacle_init(struct dvb_frontend* fe)
99{
100 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
101 static u8 reset [] = { RESET, 0x80 };
102 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
103 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
104 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
105 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
106 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
107 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
108 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
109 struct saa7134_dev *dev= fe->dvb->priv;
110
111 printk("%s: %s called\n",dev->name,__FUNCTION__);
112
113 mt352_write(fe, clock_config, sizeof(clock_config));
114 udelay(200);
115 mt352_write(fe, reset, sizeof(reset));
116 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
117 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
118 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
119 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
120
121 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
122 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
123 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 return 0;
126}
127
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200128static int mt352_aver777_init(struct dvb_frontend* fe)
129{
130 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
131 static u8 reset [] = { RESET, 0x80 };
132 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
133 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
134 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
135
136 mt352_write(fe, clock_config, sizeof(clock_config));
137 udelay(200);
138 mt352_write(fe, reset, sizeof(reset));
139 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
140 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
141 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
142
143 return 0;
144}
145
Andrew de Quincey0463f122006-05-16 17:22:02 -0300146static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
147 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300149 u8 off[] = { 0x00, 0xf1};
150 u8 on[] = { 0x00, 0x71};
151 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
152
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 struct saa7134_dev *dev = fe->dvb->priv;
154 struct v4l2_frequency f;
155
156 /* set frequency (mt2050) */
157 f.tuner = 0;
158 f.type = V4L2_TUNER_DIGITAL_TV;
159 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300160 if (fe->ops.i2c_gate_ctrl)
161 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300162 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 saa7134_i2c_call_clients(dev,VIDIOC_S_FREQUENCY,&f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300164 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300165 if (fe->ops.i2c_gate_ctrl)
166 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300167 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
169 pinnacle_antenna_pwr(dev, antenna_pwr);
170
171 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300172 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173}
174
Andrew de Quinceybd4956b2006-04-18 21:38:49 -0300175static 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 -0200176{
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300177 if (buf_len < 5)
178 return -EINVAL;
179
180 pllbuf[0] = 0x61;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200181 dvb_pll_configure(&dvb_pll_philips_td1316, pllbuf+1,
182 params->frequency,
183 params->u.ofdm.bandwidth);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300184 return 5;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200185}
186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187static struct mt352_config pinnacle_300i = {
188 .demod_address = 0x3c >> 1,
189 .adc_clock = 20333,
190 .if2 = 36150,
191 .no_tuner = 1,
192 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200194
195static struct mt352_config avermedia_777 = {
196 .demod_address = 0xf,
197 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200198};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
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
211static void philips_tda1004x_set_board_name(struct dvb_frontend *fe, char *name)
212{
213 size_t len;
214
215 len = sizeof(fe->ops.info.name);
216 strncpy(fe->ops.info.name, name, len);
217 fe->ops.info.name[len - 1] = 0;
218}
219
220/* ------------------------------------------------------------------
221 * these tuners are tu1216, td1316(a)
222 */
223
224static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
225{
226 struct saa7134_dev *dev = fe->dvb->priv;
227 struct tda1004x_state *state = fe->demodulator_priv;
228 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700229 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800230 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700231 sizeof(tuner_buf) };
232 int tuner_frequency = 0;
233 u8 band, cp, filter;
234
235 /* determine charge pump */
236 tuner_frequency = params->frequency + 36166000;
237 if (tuner_frequency < 87000000)
238 return -EINVAL;
239 else if (tuner_frequency < 130000000)
240 cp = 3;
241 else if (tuner_frequency < 160000000)
242 cp = 5;
243 else if (tuner_frequency < 200000000)
244 cp = 6;
245 else if (tuner_frequency < 290000000)
246 cp = 3;
247 else if (tuner_frequency < 420000000)
248 cp = 5;
249 else if (tuner_frequency < 480000000)
250 cp = 6;
251 else if (tuner_frequency < 620000000)
252 cp = 3;
253 else if (tuner_frequency < 830000000)
254 cp = 5;
255 else if (tuner_frequency < 895000000)
256 cp = 7;
257 else
258 return -EINVAL;
259
260 /* determine band */
261 if (params->frequency < 49000000)
262 return -EINVAL;
263 else if (params->frequency < 161000000)
264 band = 1;
265 else if (params->frequency < 444000000)
266 band = 2;
267 else if (params->frequency < 861000000)
268 band = 4;
269 else
270 return -EINVAL;
271
272 /* setup PLL filter */
273 switch (params->u.ofdm.bandwidth) {
274 case BANDWIDTH_6_MHZ:
275 filter = 0;
276 break;
277
278 case BANDWIDTH_7_MHZ:
279 filter = 0;
280 break;
281
282 case BANDWIDTH_8_MHZ:
283 filter = 1;
284 break;
285
286 default:
287 return -EINVAL;
288 }
289
290 /* calculate divisor
291 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
292 */
293 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
294
295 /* setup tuner buffer */
296 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
297 tuner_buf[1] = tuner_frequency & 0xff;
298 tuner_buf[2] = 0xca;
299 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
300
Patrick Boettcherdea74862006-05-14 05:01:31 -0300301 if (fe->ops.i2c_gate_ctrl)
302 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300303 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
304 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700305 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300306 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700307 msleep(1);
308 return 0;
309}
310
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300311static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800312{
313 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300314 struct tda1004x_state *state = fe->demodulator_priv;
315 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800316 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
317 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
318
319 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300320 if (fe->ops.i2c_gate_ctrl)
321 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800322 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
323 return -EIO;
324 msleep(1);
325
326 return 0;
327}
328
329/* ------------------------------------------------------------------ */
330
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800331static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700332 .demod_address = 0x8,
333 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800334 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700335 .xtal_freq = TDA10046_XTAL_4M,
336 .agc_config = TDA10046_AGC_DEFAULT,
337 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300338 .tuner_address = 0x60,
339 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340};
341
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800342static struct tda1004x_config philips_tu1216_61_config = {
343
344 .demod_address = 0x8,
345 .invert = 1,
346 .invert_oclk = 0,
347 .xtal_freq = TDA10046_XTAL_4M,
348 .agc_config = TDA10046_AGC_DEFAULT,
349 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300350 .tuner_address = 0x61,
351 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800352};
353
354/* ------------------------------------------------------------------ */
355
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300356static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800357{
358 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300359 struct tda1004x_state *state = fe->demodulator_priv;
360 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800361 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300362 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800363
364 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300365 if (fe->ops.i2c_gate_ctrl)
366 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800367 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
368 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800369 return 0;
370}
371
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300372static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800373{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300374 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800375}
376
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300377static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
378{
379 struct saa7134_dev *dev = fe->dvb->priv;
380 struct tda1004x_state *state = fe->demodulator_priv;
381 u8 addr = state->config->tuner_address;
382 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
383 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
384
385 /* switch the tuner to analog mode */
386 if (fe->ops.i2c_gate_ctrl)
387 fe->ops.i2c_gate_ctrl(fe, 1);
388 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
389 return -EIO;
390 return 0;
391}
392
393/* ------------------------------------------------------------------ */
394
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300395static int philips_europa_tuner_init(struct dvb_frontend *fe)
396{
397 struct saa7134_dev *dev = fe->dvb->priv;
398 static u8 msg[] = { 0x00, 0x40};
399 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
400
401
402 if (philips_td1316_tuner_init(fe))
403 return -EIO;
404 msleep(1);
405 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
406 return -EIO;
407
408 return 0;
409}
410
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300411static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800412{
413 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800414
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300415 static u8 msg[] = { 0x00, 0x14 };
416 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
417
418 if (philips_td1316_tuner_sleep(fe))
419 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800420
421 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300422 if (fe->ops.i2c_gate_ctrl)
423 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800424 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300425 return 0;
426}
427
428static int philips_europa_demod_sleep(struct dvb_frontend *fe)
429{
430 struct saa7134_dev *dev = fe->dvb->priv;
431
432 if (dev->original_demod_sleep)
433 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300434 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300435 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800436}
437
438static struct tda1004x_config philips_europa_config = {
439
440 .demod_address = 0x8,
441 .invert = 0,
442 .invert_oclk = 0,
443 .xtal_freq = TDA10046_XTAL_4M,
444 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
445 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300446 .tuner_address = 0x61,
447 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800448};
449
450/* ------------------------------------------------------------------ */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700451
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300452static int philips_fmd1216_tuner_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700453{
454 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300455 struct tda1004x_state *state = fe->demodulator_priv;
456 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700457 /* this message is to set up ATC and ALC */
458 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300459 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700460
Patrick Boettcherdea74862006-05-14 05:01:31 -0300461 if (fe->ops.i2c_gate_ctrl)
462 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700463 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
464 return -EIO;
465 msleep(1);
466
467 return 0;
468}
469
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300470static int philips_fmd1216_tuner_sleep(struct dvb_frontend *fe)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700471{
472 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300473 struct tda1004x_state *state = fe->demodulator_priv;
474 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700475 /* this message actually turns the tuner back to analog mode */
476 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0x60 };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300477 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = fmd1216_init,.len = sizeof(fmd1216_init) };
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700478
Patrick Boettcherdea74862006-05-14 05:01:31 -0300479 if (fe->ops.i2c_gate_ctrl)
480 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700481 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
482 msleep(1);
483 fmd1216_init[2] = 0x86;
484 fmd1216_init[3] = 0x54;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300485 if (fe->ops.i2c_gate_ctrl)
486 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700487 i2c_transfer(&dev->i2c_adap, &tuner_msg, 1);
488 msleep(1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300489 return 0;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700490}
491
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300492static int philips_fmd1216_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700493{
494 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300495 struct tda1004x_state *state = fe->demodulator_priv;
496 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700497 u8 tuner_buf[4];
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300498 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700499 sizeof(tuner_buf) };
500 int tuner_frequency = 0;
501 int divider = 0;
502 u8 band, mode, cp;
503
504 /* determine charge pump */
505 tuner_frequency = params->frequency + 36130000;
506 if (tuner_frequency < 87000000)
507 return -EINVAL;
508 /* low band */
509 else if (tuner_frequency < 180000000) {
510 band = 1;
511 mode = 7;
512 cp = 0;
513 } else if (tuner_frequency < 195000000) {
514 band = 1;
515 mode = 6;
516 cp = 1;
517 /* mid band */
518 } else if (tuner_frequency < 366000000) {
519 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
520 band = 10;
521 } else {
522 band = 2;
523 }
524 mode = 7;
525 cp = 0;
526 } else if (tuner_frequency < 478000000) {
527 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
528 band = 10;
529 } else {
530 band = 2;
531 }
532 mode = 6;
533 cp = 1;
534 /* high band */
535 } else if (tuner_frequency < 662000000) {
536 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
537 band = 12;
538 } else {
539 band = 4;
540 }
541 mode = 7;
542 cp = 0;
543 } else if (tuner_frequency < 840000000) {
544 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
545 band = 12;
546 } else {
547 band = 4;
548 }
549 mode = 6;
550 cp = 1;
551 } else {
552 if (params->u.ofdm.bandwidth == BANDWIDTH_8_MHZ) {
553 band = 12;
554 } else {
555 band = 4;
556 }
557 mode = 7;
558 cp = 1;
559
560 }
561 /* calculate divisor */
562 /* ((36166000 + Finput) / 166666) rounded! */
563 divider = (tuner_frequency + 83333) / 166667;
564
565 /* setup tuner buffer */
566 tuner_buf[0] = (divider >> 8) & 0x7f;
567 tuner_buf[1] = divider & 0xff;
568 tuner_buf[2] = 0x80 | (cp << 6) | (mode << 3) | 4;
569 tuner_buf[3] = 0x40 | band;
570
Patrick Boettcherdea74862006-05-14 05:01:31 -0300571 if (fe->ops.i2c_gate_ctrl)
572 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300573 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
574 printk("%s/dvb: could not write to tuner at addr: 0x%02x\n",dev->name, addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700575 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300576 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700577 return 0;
578}
579
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700580static struct tda1004x_config medion_cardbus = {
581 .demod_address = 0x08,
582 .invert = 1,
583 .invert_oclk = 0,
584 .xtal_freq = TDA10046_XTAL_16M,
585 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
586 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300587 .tuner_address = 0x61,
588 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700589};
590
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300591/* ------------------------------------------------------------------
592 * tda 1004x based cards with philips silicon tuner
593 */
594
595static void philips_tda827x_lna_gain(struct dvb_frontend *fe, int high)
596{
597 struct saa7134_dev *dev = fe->dvb->priv;
598 struct tda1004x_state *state = fe->demodulator_priv;
599 u8 addr = state->config->i2c_gate;
600 u8 config = state->config->tuner_config;
601 u8 GP00_CF[] = {0x20, 0x01};
602 u8 GP00_LEV[] = {0x22, 0x00};
603
604 struct i2c_msg msg = {.addr = addr,.flags = 0,.buf = GP00_CF, .len = 2};
605 if (config) {
606 if (high) {
607 dprintk("setting LNA to high gain\n");
608 } else {
609 dprintk("setting LNA to low gain\n");
610 }
611 }
612 switch (config) {
613 case 0: /* no LNA */
614 break;
615 case 1: /* switch is GPIO 0 of tda8290 */
616 case 2:
617 /* turn Vsync off */
618 saa7134_set_gpio(dev, 22, 0);
619 GP00_LEV[1] = high ? 0 : 1;
620 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
621 printk("%s/dvb: could not access tda8290 at addr: 0x%02x\n",dev->name, addr << 1);
622 return;
623 }
624 msg.buf = GP00_LEV;
625 if (config == 2)
626 GP00_LEV[1] = high ? 1 : 0;
627 i2c_transfer(&dev->i2c_adap, &msg, 1);
628 break;
629 case 3: /* switch with GPIO of saa713x */
630 saa7134_set_gpio(dev, 22, high);
631 break;
632 }
633}
634
635static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
636{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300637 struct tda1004x_state *state = fe->demodulator_priv;
638
639 u8 addr = state->config->i2c_gate;
640 static u8 tda8290_close[] = { 0x21, 0xc0};
641 static u8 tda8290_open[] = { 0x21, 0x80};
642 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
643 if (enable) {
644 tda8290_msg.buf = tda8290_close;
645 } else {
646 tda8290_msg.buf = tda8290_open;
647 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300648 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
649 printk("saa7134/dvb: could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300650 return -EIO;
651 }
652 msleep(20);
653 return 0;
654}
655
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700656/* ------------------------------------------------------------------ */
657
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300658static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300659{
660 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300661 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300662
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300663 switch (state->config->antenna_switch) {
664 case 0: break;
665 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
666 saa7134_set_gpio(dev, 21, 0);
667 break;
668 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
669 saa7134_set_gpio(dev, 21, 1);
670 break;
671 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300672 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800673}
674
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300675static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
676{
677 struct saa7134_dev *dev = fe->dvb->priv;
678 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300679
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300680 switch (state->config->antenna_switch) {
681 case 0: break;
682 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
683 saa7134_set_gpio(dev, 21, 1);
684 break;
685 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
686 saa7134_set_gpio(dev, 21, 0);
687 break;
688 }
689 return 0;
690}
691
Michael Krufky8ce47da2007-04-27 12:31:14 -0300692static struct tda827x_config tda827x_cfg = {
693 .lna_gain = philips_tda827x_lna_gain,
694 .init = philips_tda827x_tuner_init,
695 .sleep = philips_tda827x_tuner_sleep
696};
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300697
698static void configure_tda827x_fe(struct saa7134_dev *dev, struct tda1004x_config *tda_conf,
699 char *board_name)
700{
701 dev->dvb.frontend = dvb_attach(tda10046_attach, tda_conf, &dev->i2c_adap);
702 if (dev->dvb.frontend) {
703 if (tda_conf->i2c_gate)
704 dev->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300705 dvb_attach(tda827x_attach,dev->dvb.frontend,
706 tda_conf->tuner_address,&dev->i2c_adap,&tda827x_cfg);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300707 }
708 philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
709}
710
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800711/* ------------------------------------------------------------------ */
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300712static struct tda1004x_config tda827x_lifeview_config = {
713 .demod_address = 0x08,
714 .invert = 1,
715 .invert_oclk = 0,
716 .xtal_freq = TDA10046_XTAL_16M,
717 .agc_config = TDA10046_AGC_TDA827X,
718 .gpio_config = TDA10046_GP11_I,
719 .if_freq = TDA10046_FREQ_045,
720 .tuner_address = 0x60,
721 .request_firmware = philips_tda1004x_request_firmware
722};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800723
724static struct tda1004x_config philips_tiger_config = {
725 .demod_address = 0x08,
726 .invert = 1,
727 .invert_oclk = 0,
728 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300729 .agc_config = TDA10046_AGC_TDA827X,
730 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300731 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300732 .i2c_gate = 0x4b,
733 .tuner_address = 0x61,
734 .tuner_config = 0,
735 .antenna_switch= 1,
736 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300737};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300738
739static struct tda1004x_config cinergy_ht_config = {
740 .demod_address = 0x08,
741 .invert = 1,
742 .invert_oclk = 0,
743 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300744 .agc_config = TDA10046_AGC_TDA827X,
745 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800746 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300747 .i2c_gate = 0x4b,
748 .tuner_address = 0x61,
749 .tuner_config = 0,
750 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800751};
752
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300753static struct tda1004x_config cinergy_ht_pci_config = {
754 .demod_address = 0x08,
755 .invert = 1,
756 .invert_oclk = 0,
757 .xtal_freq = TDA10046_XTAL_16M,
758 .agc_config = TDA10046_AGC_TDA827X,
759 .gpio_config = TDA10046_GP01_I,
760 .if_freq = TDA10046_FREQ_045,
761 .i2c_gate = 0x4b,
762 .tuner_address = 0x60,
763 .tuner_config = 0,
764 .request_firmware = philips_tda1004x_request_firmware
765};
766
767static struct tda1004x_config philips_tiger_s_config = {
768 .demod_address = 0x08,
769 .invert = 1,
770 .invert_oclk = 0,
771 .xtal_freq = TDA10046_XTAL_16M,
772 .agc_config = TDA10046_AGC_TDA827X,
773 .gpio_config = TDA10046_GP01_I,
774 .if_freq = TDA10046_FREQ_045,
775 .i2c_gate = 0x4b,
776 .tuner_address = 0x61,
777 .tuner_config = 2,
778 .antenna_switch= 1,
779 .request_firmware = philips_tda1004x_request_firmware
780};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200781
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300782static struct tda1004x_config pinnacle_pctv_310i_config = {
783 .demod_address = 0x08,
784 .invert = 1,
785 .invert_oclk = 0,
786 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300787 .agc_config = TDA10046_AGC_TDA827X,
788 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300789 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300790 .i2c_gate = 0x4b,
791 .tuner_address = 0x61,
792 .tuner_config = 1,
793 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300794};
795
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300796static struct tda1004x_config hauppauge_hvr_1110_config = {
797 .demod_address = 0x08,
798 .invert = 1,
799 .invert_oclk = 0,
800 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300801 .agc_config = TDA10046_AGC_TDA827X,
802 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300803 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300804 .i2c_gate = 0x4b,
805 .tuner_address = 0x61,
806 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300807};
808
Hartmut Hackmann83646812006-10-12 20:38:51 -0300809static struct tda1004x_config asus_p7131_dual_config = {
810 .demod_address = 0x08,
811 .invert = 1,
812 .invert_oclk = 0,
813 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300814 .agc_config = TDA10046_AGC_TDA827X,
815 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300816 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300817 .i2c_gate = 0x4b,
818 .tuner_address = 0x61,
819 .tuner_config = 0,
820 .antenna_switch= 2,
821 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300822};
823
Nico Sabbi420f32f2006-03-03 12:11:28 -0300824static struct tda1004x_config lifeview_trio_config = {
825 .demod_address = 0x09,
826 .invert = 1,
827 .invert_oclk = 0,
828 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300829 .agc_config = TDA10046_AGC_TDA827X,
830 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300831 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300832 .tuner_address = 0x60,
833 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300834};
835
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300836static struct tda1004x_config tevion_dvbt220rf_config = {
837 .demod_address = 0x08,
838 .invert = 1,
839 .invert_oclk = 0,
840 .xtal_freq = TDA10046_XTAL_16M,
841 .agc_config = TDA10046_AGC_TDA827X,
842 .gpio_config = TDA10046_GP11_I,
843 .if_freq = TDA10046_FREQ_045,
844 .tuner_address = 0x60,
845 .request_firmware = philips_tda1004x_request_firmware
846};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300847
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300848static struct tda1004x_config md8800_dvbt_config = {
849 .demod_address = 0x08,
850 .invert = 1,
851 .invert_oclk = 0,
852 .xtal_freq = TDA10046_XTAL_16M,
853 .agc_config = TDA10046_AGC_TDA827X,
854 .gpio_config = TDA10046_GP01_I,
855 .if_freq = TDA10046_FREQ_045,
856 .i2c_gate = 0x4b,
857 .tuner_address = 0x60,
858 .tuner_config = 0,
859 .request_firmware = philips_tda1004x_request_firmware
860};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200861
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300862/* ------------------------------------------------------------------
863 * special case: this card uses saa713x GPIO22 for the mode switch
864 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200865
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300866static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200867{
868 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300869 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200870 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300871 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200872 return 0;
873}
874
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300875static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200876{
877 struct saa7134_dev *dev = fe->dvb->priv;
878 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300879 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300880 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300881 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200882}
883
Michael Krufky8ce47da2007-04-27 12:31:14 -0300884static struct tda827x_config ads_duo_cfg = {
885 .lna_gain = philips_tda827x_lna_gain,
886 .init = ads_duo_tuner_init,
887 .sleep = ads_duo_tuner_sleep
888};
889
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200890static struct tda1004x_config ads_tech_duo_config = {
891 .demod_address = 0x08,
892 .invert = 1,
893 .invert_oclk = 0,
894 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300895 .agc_config = TDA10046_AGC_TDA827X,
896 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200897 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300898 .tuner_address = 0x61,
899 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200900};
901
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300902/* ==================================================================
903 * tda10086 based DVB-S cards, helper functions
904 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300905
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300906static struct tda10086_config flydvbs = {
907 .demod_address = 0x0e,
908 .invert = 0,
909};
910
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300911/* ==================================================================
912 * nxt200x based ATSC cards, helper functions
913 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800914
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800915static struct nxt200x_config avertvhda180 = {
916 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800917};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300918
Curt Meyersfbc81c02006-02-27 00:08:27 -0300919static int nxt200x_set_pll_input(u8 *buf, int input)
920{
921 if (input)
922 buf[3] |= 0x08;
923 else
924 buf[3] &= ~0x08;
925 return 0;
926}
927
Andrew Burri3e1410a2006-02-27 00:08:23 -0300928static struct nxt200x_config kworldatsc110 = {
929 .demod_address = 0x0a,
Curt Meyersfbc81c02006-02-27 00:08:27 -0300930 .set_pll_input = nxt200x_set_pll_input,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300931};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800932
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300933/* ==================================================================
934 * Core code
935 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700936
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937static int dvb_init(struct saa7134_dev *dev)
938{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300939 char *board_name;
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -0300940 int ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 /* init struct videobuf_dvb */
942 dev->ts.nr_bufs = 32;
943 dev->ts.nr_packets = 32*4;
944 dev->dvb.name = dev->name;
945 videobuf_queue_init(&dev->dvb.dvbq, &saa7134_ts_qops,
946 dev->pci, &dev->slock,
947 V4L2_BUF_TYPE_VIDEO_CAPTURE,
948 V4L2_FIELD_ALTERNATE,
949 sizeof(struct saa7134_buf),
950 dev);
951
952 switch (dev->board) {
953 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
954 printk("%s: pinnacle 300i dvb setup\n",dev->name);
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300955 dev->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300956 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300957 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300958 dev->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300959 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200961 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -0300962 case SAA7134_BOARD_AVERMEDIA_A16AR:
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200963 printk("%s: avertv 777 dvb setup\n",dev->name);
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300964 dev->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300965 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300966 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300967 dev->dvb.frontend->ops.tuner_ops.calc_regs = mt352_aver777_tuner_calc_regs;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300968 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200969 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970 case SAA7134_BOARD_MD7134:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300971 dev->dvb.frontend = dvb_attach(tda10046_attach,
972 &medion_cardbus,
973 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300974 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300975 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
976 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
977 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300978 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Medion MD7134");
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300979 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700981 case SAA7134_BOARD_PHILIPS_TOUGH:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300982 dev->dvb.frontend = dvb_attach(tda10046_attach,
983 &philips_tu1216_60_config,
984 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300985 if (dev->dvb.frontend) {
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300986 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
987 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
988 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Philips TOUGH");
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300989 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700990 break;
991 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -0200992 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300993 configure_tda827x_fe(dev, &tda827x_lifeview_config, "DVB-T Lifeview FlyDVB Duo");
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700994 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800995 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800996 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300997 dev->dvb.frontend = dvb_attach(tda10046_attach,
998 &philips_europa_config,
999 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001000 if (dev->dvb.frontend) {
Hartmut Hackmann588f9832006-10-18 17:30:42 -03001001 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1002 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Patrick Boettcherdea74862006-05-14 05:01:31 -03001003 dev->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1004 dev->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1005 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001006 if (dev->board == SAA7134_BOARD_VIDEOMATE_DVBT_300)
1007 board_name = "DVB-T Compro VideoMate 300";
1008 else
1009 board_name = "DVB-T Philips Europa";
1010 philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001011 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001012 break;
1013 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001014 dev->dvb.frontend = dvb_attach(tda10046_attach,
1015 &philips_tu1216_61_config,
1016 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001017 if (dev->dvb.frontend) {
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001018 dev->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1019 dev->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
1020 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVB-T Compro VideoMate 200");
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001021 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001022 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001023 case SAA7134_BOARD_PHILIPS_TIGER:
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001024 configure_tda827x_fe(dev, &philips_tiger_config, "DVB-T Philips Tiger");
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001025 break;
1026 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001027 configure_tda827x_fe(dev, &pinnacle_pctv_310i_config, "DVB-T Pinnacle PCTV 310i");
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001028 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001029 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001030 configure_tda827x_fe(dev, &hauppauge_hvr_1110_config, "DVB-T Hauppauge HVR 1110");
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001031 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001032 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Hartmut Hackmann06be3032007-04-27 12:31:15 -03001033 configure_tda827x_fe(dev, &asus_p7131_dual_config, "DVB-T Asus P7131 Dual");
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001034 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001035 case SAA7134_BOARD_FLYDVBT_LR301:
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001036 configure_tda827x_fe(dev, &tda827x_lifeview_config, "DVB-T Lifeview FlyDVBT LR301");
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001037 break;
Nico Sabbi420f32f2006-03-03 12:11:28 -03001038 case SAA7134_BOARD_FLYDVB_TRIO:
Stephan Berberigb331daa2006-12-20 09:37:05 -03001039 if(! use_frontend) { //terrestrial
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001040 configure_tda827x_fe(dev, &lifeview_trio_config, NULL);
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001041 } else { //satellite
1042 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1043 if (dev->dvb.frontend) {
1044 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x63,
1045 &dev->i2c_adap, 0) == NULL) {
1046 printk("%s: Lifeview Trio, No tda826x found!\n", __FUNCTION__);
1047 }
1048 if (dvb_attach(isl6421_attach, dev->dvb.frontend, &dev->i2c_adap,
1049 0x08, 0, 0) == NULL) {
1050 printk("%s: Lifeview Trio, No ISL6421 found!\n", __FUNCTION__);
1051 }
1052 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001053 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001054 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001055 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001056 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001057 dev->dvb.frontend = dvb_attach(tda10046_attach,
1058 &ads_tech_duo_config,
1059 &dev->i2c_adap);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001060 if (dev->dvb.frontend) {
Michael Krufky8ce47da2007-04-27 12:31:14 -03001061 dvb_attach(tda827x_attach,dev->dvb.frontend,
1062 ads_tech_duo_config.tuner_address,
1063 &dev->i2c_adap,&ads_duo_cfg);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001064 if (dev->board == SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331)
1065 board_name = "DVB-T ADS DUO Cardbus PTV331";
1066 else
1067 board_name = "DVB-T Lifeview FlyDVT Cardbus";
1068 philips_tda1004x_set_board_name(dev->dvb.frontend, board_name);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001069 }
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001070 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001071 case SAA7134_BOARD_TEVION_DVBT_220RF:
1072 configure_tda827x_fe(dev, &tevion_dvbt220rf_config, "DVB-T Tevion 220RF");
1073 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001074 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001075 configure_tda827x_fe(dev, &md8800_dvbt_config, "DVB-T Medion MD8800");
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001076 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001077 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001078 dev->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
1079 &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001080 if (dev->dvb.frontend) {
Michael Krufky4ad8eee52006-08-08 15:48:08 -03001081 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1082 NULL, &dvb_pll_tdhu2);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001083 }
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001084 break;
Andrew Burri3e1410a2006-02-27 00:08:23 -03001085 case SAA7134_BOARD_KWORLD_ATSC110:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001086 dev->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
1087 &dev->i2c_adap);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001088 if (dev->dvb.frontend) {
Michael Krufky4ad8eee52006-08-08 15:48:08 -03001089 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
1090 NULL, &dvb_pll_tuv1236d);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -03001091 }
Andrew Burri3e1410a2006-02-27 00:08:23 -03001092 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001093 case SAA7134_BOARD_FLYDVBS_LR300:
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001094 dev->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
1095 &dev->i2c_adap);
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001096 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001097 if (dvb_attach(tda826x_attach, dev->dvb.frontend, 0x60,
1098 &dev->i2c_adap, 0) == NULL) {
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001099 printk("%s: No tda826x found!\n", __FUNCTION__);
1100 }
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001101 if (dvb_attach(isl6421_attach, dev->dvb.frontend,
1102 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001103 printk("%s: No ISL6421 found!\n", __FUNCTION__);
1104 }
1105 }
1106 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001107 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
1108 dev->dvb.frontend = tda10046_attach(&medion_cardbus,
1109 &dev->i2c_adap);
1110 if (dev->dvb.frontend) {
1111 dev->original_demod_sleep = dev->dvb.frontend->ops.sleep;
1112 dev->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1113 dev->dvb.frontend->ops.tuner_ops.init = philips_fmd1216_tuner_init;
1114 dev->dvb.frontend->ops.tuner_ops.sleep = philips_fmd1216_tuner_sleep;
1115 dev->dvb.frontend->ops.tuner_ops.set_params = philips_fmd1216_tuner_set_params;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001116 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVBT Asus Europa 2 Hybrid");
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001117 }
1118 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001119 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
1120 dev->dvb.frontend = dvb_attach(tda10046_attach,
1121 &philips_europa_config,
1122 &dev->i2c_adap);
1123 if (dev->dvb.frontend) {
1124 dev->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1125 dev->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001126 philips_tda1004x_set_board_name(dev->dvb.frontend, "DVBT Compro Videomate 200a");
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001127 }
1128 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001129 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001130 configure_tda827x_fe(dev, &cinergy_ht_config, "DVB-T Terratec Cinergy HT Cardbus");
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001131 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001132 case SAA7134_BOARD_CINERGY_HT_PCI:
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001133 configure_tda827x_fe(dev, &cinergy_ht_pci_config, "DVB-T Terratec Cinergy HT PCI");
1134 break;
1135 case SAA7134_BOARD_PHILIPS_TIGER_S:
1136 configure_tda827x_fe(dev, &philips_tiger_s_config, "DVB-T Philips Tiger S");
Michael Krufky9de271e2007-01-16 18:36:40 -03001137 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 default:
1139 printk("%s: Huh? unknown DVB card?\n",dev->name);
1140 break;
1141 }
1142
1143 if (NULL == dev->dvb.frontend) {
1144 printk("%s: frontend initialization failed\n",dev->name);
1145 return -1;
1146 }
1147
1148 /* register everything else */
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001149 ret = videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
1150
1151 /* this sequence is necessary to make the tda1004x load its firmware
1152 * and to enter analog mode of hybrid boards
1153 */
1154 if (!ret) {
1155 if (dev->dvb.frontend->ops.init)
1156 dev->dvb.frontend->ops.init(dev->dvb.frontend);
1157 if (dev->dvb.frontend->ops.sleep)
1158 dev->dvb.frontend->ops.sleep(dev->dvb.frontend);
1159 }
1160 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161}
1162
1163static int dvb_fini(struct saa7134_dev *dev)
1164{
1165 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
1166
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 switch (dev->board) {
1168 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
1169 /* otherwise we don't detect the tuner on next insmod */
1170 saa7134_i2c_call_clients(dev,TDA9887_SET_CONFIG,&on);
1171 break;
1172 };
1173 videobuf_dvb_unregister(&dev->dvb);
1174 return 0;
1175}
1176
1177static struct saa7134_mpeg_ops dvb_ops = {
1178 .type = SAA7134_MPEG_DVB,
1179 .init = dvb_init,
1180 .fini = dvb_fini,
1181};
1182
1183static int __init dvb_register(void)
1184{
1185 return saa7134_ts_register(&dvb_ops);
1186}
1187
1188static void __exit dvb_unregister(void)
1189{
1190 saa7134_ts_unregister(&dvb_ops);
1191}
1192
1193module_init(dvb_register);
1194module_exit(dvb_unregister);
1195
1196/* ------------------------------------------------------------------ */
1197/*
1198 * Local variables:
1199 * c-basic-offset: 8
1200 * End:
1201 */