blob: af9a22d1b94d6691e235c6799d0022e92f95c176 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
4 *
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07005 * Extended 3 / 2005 by Hartmut Hackmann to support various
6 * cards with the tda10046 DVB-T channel decoder
7 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 */
22
23#include <linux/init.h>
24#include <linux/list.h>
25#include <linux/module.h>
26#include <linux/kernel.h>
27#include <linux/slab.h>
28#include <linux/delay.h>
29#include <linux/kthread.h>
30#include <linux/suspend.h>
31
32#include "saa7134-reg.h"
33#include "saa7134.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020034#include <media/v4l2-common.h>
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -020035#include "dvb-pll.h"
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -030036#include <dvb_frontend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030038#include "mt352.h"
39#include "mt352_priv.h" /* FIXME */
40#include "tda1004x.h"
41#include "nxt200x.h"
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -030042#include "tuner-xc2028.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070043
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030044#include "tda10086.h"
45#include "tda826x.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030046#include "tda827x.h"
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030047#include "isl6421.h"
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -030048#include "isl6405.h"
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -030049#include "lnbp21.h"
Michael Krufkycb89cd332008-04-22 14:46:16 -030050#include "tuner-simple.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030051
Dmitri Belimov47aeba52008-12-23 03:53:03 -030052#include "zl10353.h"
53
Linus Torvalds1da177e2005-04-16 15:20:36 -070054MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
55MODULE_LICENSE("GPL");
56
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030057static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070058
Linus Torvalds1da177e2005-04-16 15:20:36 -070059module_param(antenna_pwr, int, 0444);
60MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
61
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030062static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030063module_param(use_frontend, int, 0644);
64MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030065
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030066static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030067module_param(debug, int, 0644);
68MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
69
Janne Grunau78e92002008-04-09 19:13:13 -030070DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
71
Trent Piephocf3c34c2007-03-07 18:19:48 -030072#define dprintk(fmt, arg...) do { if (debug) \
73 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
74
75/* Print a warning */
76#define wprintk(fmt, arg...) \
77 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030078
79/* ------------------------------------------------------------------
80 * mt352 based DVB-T cards
81 */
82
Linus Torvalds1da177e2005-04-16 15:20:36 -070083static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
84{
85 u32 ok;
86
87 if (!on) {
88 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
89 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
90 return 0;
91 }
92
93 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
94 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
95 udelay(10);
96
97 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
98 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
99 udelay(10);
100 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
101 udelay(10);
102 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300103 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105 if (!ok)
106 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
107 return ok;
108}
109
110static int mt352_pinnacle_init(struct dvb_frontend* fe)
111{
112 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
113 static u8 reset [] = { RESET, 0x80 };
114 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
115 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
116 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
117 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
118 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
119 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
120 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
121 struct saa7134_dev *dev= fe->dvb->priv;
122
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300123 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124
125 mt352_write(fe, clock_config, sizeof(clock_config));
126 udelay(200);
127 mt352_write(fe, reset, sizeof(reset));
128 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
129 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
130 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
131 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
132
133 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
134 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
135 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 return 0;
138}
139
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200140static int mt352_aver777_init(struct dvb_frontend* fe)
141{
142 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
143 static u8 reset [] = { RESET, 0x80 };
144 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
145 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
146 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
147
148 mt352_write(fe, clock_config, sizeof(clock_config));
149 udelay(200);
150 mt352_write(fe, reset, sizeof(reset));
151 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
152 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
153 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
154
155 return 0;
156}
157
Tim Farrington6e501a32008-06-15 13:33:42 -0300158static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300159{
Tim Farrington6e501a32008-06-15 13:33:42 -0300160 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
161 static u8 reset [] = { RESET, 0x80 };
162 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
163 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300164 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
165
166 mt352_write(fe, clock_config, sizeof(clock_config));
167 udelay(200);
168 mt352_write(fe, reset, sizeof(reset));
169 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
170 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
171 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300172 return 0;
173}
174
Andrew de Quincey0463f122006-05-16 17:22:02 -0300175static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
176 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300178 u8 off[] = { 0x00, 0xf1};
179 u8 on[] = { 0x00, 0x71};
180 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
181
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 struct saa7134_dev *dev = fe->dvb->priv;
183 struct v4l2_frequency f;
184
185 /* set frequency (mt2050) */
186 f.tuner = 0;
187 f.type = V4L2_TUNER_DIGITAL_TV;
188 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300189 if (fe->ops.i2c_gate_ctrl)
190 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300191 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300192 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300193 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300194 if (fe->ops.i2c_gate_ctrl)
195 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300196 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
198 pinnacle_antenna_pwr(dev, antenna_pwr);
199
200 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300201 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202}
203
204static struct mt352_config pinnacle_300i = {
205 .demod_address = 0x3c >> 1,
206 .adc_clock = 20333,
207 .if2 = 36150,
208 .no_tuner = 1,
209 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200211
212static struct mt352_config avermedia_777 = {
213 .demod_address = 0xf,
214 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200215};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216
Tim Farrington6e501a32008-06-15 13:33:42 -0300217static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300218 .demod_address = (0x1e >> 1),
219 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300220 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300221};
222
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300223/* ==================================================================
224 * tda1004x based DVB-T cards, helper functions
225 */
226
227static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
228 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700229{
230 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300231 return request_firmware(fw, name, &dev->pci->dev);
232}
233
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300234/* ------------------------------------------------------------------
235 * these tuners are tu1216, td1316(a)
236 */
237
238static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
239{
240 struct saa7134_dev *dev = fe->dvb->priv;
241 struct tda1004x_state *state = fe->demodulator_priv;
242 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700243 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800244 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700245 sizeof(tuner_buf) };
246 int tuner_frequency = 0;
247 u8 band, cp, filter;
248
249 /* determine charge pump */
250 tuner_frequency = params->frequency + 36166000;
251 if (tuner_frequency < 87000000)
252 return -EINVAL;
253 else if (tuner_frequency < 130000000)
254 cp = 3;
255 else if (tuner_frequency < 160000000)
256 cp = 5;
257 else if (tuner_frequency < 200000000)
258 cp = 6;
259 else if (tuner_frequency < 290000000)
260 cp = 3;
261 else if (tuner_frequency < 420000000)
262 cp = 5;
263 else if (tuner_frequency < 480000000)
264 cp = 6;
265 else if (tuner_frequency < 620000000)
266 cp = 3;
267 else if (tuner_frequency < 830000000)
268 cp = 5;
269 else if (tuner_frequency < 895000000)
270 cp = 7;
271 else
272 return -EINVAL;
273
274 /* determine band */
275 if (params->frequency < 49000000)
276 return -EINVAL;
277 else if (params->frequency < 161000000)
278 band = 1;
279 else if (params->frequency < 444000000)
280 band = 2;
281 else if (params->frequency < 861000000)
282 band = 4;
283 else
284 return -EINVAL;
285
286 /* setup PLL filter */
287 switch (params->u.ofdm.bandwidth) {
288 case BANDWIDTH_6_MHZ:
289 filter = 0;
290 break;
291
292 case BANDWIDTH_7_MHZ:
293 filter = 0;
294 break;
295
296 case BANDWIDTH_8_MHZ:
297 filter = 1;
298 break;
299
300 default:
301 return -EINVAL;
302 }
303
304 /* calculate divisor
305 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
306 */
307 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
308
309 /* setup tuner buffer */
310 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
311 tuner_buf[1] = tuner_frequency & 0xff;
312 tuner_buf[2] = 0xca;
313 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
314
Patrick Boettcherdea74862006-05-14 05:01:31 -0300315 if (fe->ops.i2c_gate_ctrl)
316 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300317 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300318 wprintk("could not write to tuner at addr: 0x%02x\n",
319 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700320 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300321 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700322 msleep(1);
323 return 0;
324}
325
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300326static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800327{
328 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300329 struct tda1004x_state *state = fe->demodulator_priv;
330 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800331 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
332 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
333
334 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300335 if (fe->ops.i2c_gate_ctrl)
336 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800337 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
338 return -EIO;
339 msleep(1);
340
341 return 0;
342}
343
344/* ------------------------------------------------------------------ */
345
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800346static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700347 .demod_address = 0x8,
348 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800349 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700350 .xtal_freq = TDA10046_XTAL_4M,
351 .agc_config = TDA10046_AGC_DEFAULT,
352 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300353 .tuner_address = 0x60,
354 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355};
356
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800357static struct tda1004x_config philips_tu1216_61_config = {
358
359 .demod_address = 0x8,
360 .invert = 1,
361 .invert_oclk = 0,
362 .xtal_freq = TDA10046_XTAL_4M,
363 .agc_config = TDA10046_AGC_DEFAULT,
364 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300365 .tuner_address = 0x61,
366 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800367};
368
369/* ------------------------------------------------------------------ */
370
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300371static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800372{
373 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300374 struct tda1004x_state *state = fe->demodulator_priv;
375 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800376 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300377 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800378
379 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300380 if (fe->ops.i2c_gate_ctrl)
381 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800382 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
383 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800384 return 0;
385}
386
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300387static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800388{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300389 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800390}
391
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300392static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
393{
394 struct saa7134_dev *dev = fe->dvb->priv;
395 struct tda1004x_state *state = fe->demodulator_priv;
396 u8 addr = state->config->tuner_address;
397 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
398 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
399
400 /* switch the tuner to analog mode */
401 if (fe->ops.i2c_gate_ctrl)
402 fe->ops.i2c_gate_ctrl(fe, 1);
403 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
404 return -EIO;
405 return 0;
406}
407
408/* ------------------------------------------------------------------ */
409
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300410static int philips_europa_tuner_init(struct dvb_frontend *fe)
411{
412 struct saa7134_dev *dev = fe->dvb->priv;
413 static u8 msg[] = { 0x00, 0x40};
414 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
415
416
417 if (philips_td1316_tuner_init(fe))
418 return -EIO;
419 msleep(1);
420 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
421 return -EIO;
422
423 return 0;
424}
425
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300426static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800427{
428 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800429
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300430 static u8 msg[] = { 0x00, 0x14 };
431 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
432
433 if (philips_td1316_tuner_sleep(fe))
434 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800435
436 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300437 if (fe->ops.i2c_gate_ctrl)
438 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800439 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300440 return 0;
441}
442
443static int philips_europa_demod_sleep(struct dvb_frontend *fe)
444{
445 struct saa7134_dev *dev = fe->dvb->priv;
446
447 if (dev->original_demod_sleep)
448 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300449 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300450 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800451}
452
453static struct tda1004x_config philips_europa_config = {
454
455 .demod_address = 0x8,
456 .invert = 0,
457 .invert_oclk = 0,
458 .xtal_freq = TDA10046_XTAL_4M,
459 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
460 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300461 .tuner_address = 0x61,
462 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800463};
464
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700465static struct tda1004x_config medion_cardbus = {
466 .demod_address = 0x08,
467 .invert = 1,
468 .invert_oclk = 0,
469 .xtal_freq = TDA10046_XTAL_16M,
470 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
471 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300472 .tuner_address = 0x61,
473 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700474};
475
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300476/* ------------------------------------------------------------------
477 * tda 1004x based cards with philips silicon tuner
478 */
479
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300480static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
481{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300482 struct tda1004x_state *state = fe->demodulator_priv;
483
484 u8 addr = state->config->i2c_gate;
485 static u8 tda8290_close[] = { 0x21, 0xc0};
486 static u8 tda8290_open[] = { 0x21, 0x80};
487 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
488 if (enable) {
489 tda8290_msg.buf = tda8290_close;
490 } else {
491 tda8290_msg.buf = tda8290_open;
492 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300493 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300494 struct saa7134_dev *dev = fe->dvb->priv;
495 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300496 return -EIO;
497 }
498 msleep(20);
499 return 0;
500}
501
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300502static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300503{
504 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300505 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300506
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300507 switch (state->config->antenna_switch) {
508 case 0: break;
509 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
510 saa7134_set_gpio(dev, 21, 0);
511 break;
512 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
513 saa7134_set_gpio(dev, 21, 1);
514 break;
515 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300516 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800517}
518
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300519static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
520{
521 struct saa7134_dev *dev = fe->dvb->priv;
522 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300523
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300524 switch (state->config->antenna_switch) {
525 case 0: break;
526 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
527 saa7134_set_gpio(dev, 21, 1);
528 break;
529 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
530 saa7134_set_gpio(dev, 21, 0);
531 break;
532 }
533 return 0;
534}
535
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300536static int configure_tda827x_fe(struct saa7134_dev *dev,
537 struct tda1004x_config *cdec_conf,
538 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300539{
Steven Toth363c35f2008-10-11 11:05:50 -0300540 struct videobuf_dvb_frontend *fe0;
541
Darron Broad92abe9e2008-10-11 11:18:53 -0300542 /* Get the first frontend */
543 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300544
545 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
546 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300547 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300548 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
549 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300550 cdec_conf->tuner_address,
551 &dev->i2c_adap, tuner_conf))
552 return 0;
553
554 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300555 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300556 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300557 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300558}
559
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800560/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300561
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300562static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300563 .init = philips_tda827x_tuner_init,
564 .sleep = philips_tda827x_tuner_sleep,
565 .config = 0,
566 .switch_addr = 0
567};
568
569static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300570 .init = philips_tda827x_tuner_init,
571 .sleep = philips_tda827x_tuner_sleep,
572 .config = 1,
573 .switch_addr = 0x4b
574};
575
576static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300577 .init = philips_tda827x_tuner_init,
578 .sleep = philips_tda827x_tuner_sleep,
579 .config = 2,
580 .switch_addr = 0x4b
581};
582
583static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300584 .init = philips_tda827x_tuner_init,
585 .sleep = philips_tda827x_tuner_sleep,
586 .config = 2,
587 .switch_addr = 0x42
588};
589
590/* ------------------------------------------------------------------ */
591
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300592static struct tda1004x_config tda827x_lifeview_config = {
593 .demod_address = 0x08,
594 .invert = 1,
595 .invert_oclk = 0,
596 .xtal_freq = TDA10046_XTAL_16M,
597 .agc_config = TDA10046_AGC_TDA827X,
598 .gpio_config = TDA10046_GP11_I,
599 .if_freq = TDA10046_FREQ_045,
600 .tuner_address = 0x60,
601 .request_firmware = philips_tda1004x_request_firmware
602};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800603
604static struct tda1004x_config philips_tiger_config = {
605 .demod_address = 0x08,
606 .invert = 1,
607 .invert_oclk = 0,
608 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300609 .agc_config = TDA10046_AGC_TDA827X,
610 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300611 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300612 .i2c_gate = 0x4b,
613 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300614 .antenna_switch= 1,
615 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300616};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300617
618static struct tda1004x_config cinergy_ht_config = {
619 .demod_address = 0x08,
620 .invert = 1,
621 .invert_oclk = 0,
622 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300623 .agc_config = TDA10046_AGC_TDA827X,
624 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800625 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300626 .i2c_gate = 0x4b,
627 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300628 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800629};
630
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300631static struct tda1004x_config cinergy_ht_pci_config = {
632 .demod_address = 0x08,
633 .invert = 1,
634 .invert_oclk = 0,
635 .xtal_freq = TDA10046_XTAL_16M,
636 .agc_config = TDA10046_AGC_TDA827X,
637 .gpio_config = TDA10046_GP01_I,
638 .if_freq = TDA10046_FREQ_045,
639 .i2c_gate = 0x4b,
640 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300641 .request_firmware = philips_tda1004x_request_firmware
642};
643
644static struct tda1004x_config philips_tiger_s_config = {
645 .demod_address = 0x08,
646 .invert = 1,
647 .invert_oclk = 0,
648 .xtal_freq = TDA10046_XTAL_16M,
649 .agc_config = TDA10046_AGC_TDA827X,
650 .gpio_config = TDA10046_GP01_I,
651 .if_freq = TDA10046_FREQ_045,
652 .i2c_gate = 0x4b,
653 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300654 .antenna_switch= 1,
655 .request_firmware = philips_tda1004x_request_firmware
656};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200657
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300658static struct tda1004x_config pinnacle_pctv_310i_config = {
659 .demod_address = 0x08,
660 .invert = 1,
661 .invert_oclk = 0,
662 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300663 .agc_config = TDA10046_AGC_TDA827X,
664 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300665 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300666 .i2c_gate = 0x4b,
667 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300668 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300669};
670
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300671static struct tda1004x_config hauppauge_hvr_1110_config = {
672 .demod_address = 0x08,
673 .invert = 1,
674 .invert_oclk = 0,
675 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300676 .agc_config = TDA10046_AGC_TDA827X,
677 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300678 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300679 .i2c_gate = 0x4b,
680 .tuner_address = 0x61,
681 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300682};
683
Hartmut Hackmann83646812006-10-12 20:38:51 -0300684static struct tda1004x_config asus_p7131_dual_config = {
685 .demod_address = 0x08,
686 .invert = 1,
687 .invert_oclk = 0,
688 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300689 .agc_config = TDA10046_AGC_TDA827X,
690 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300691 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300692 .i2c_gate = 0x4b,
693 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300694 .antenna_switch= 2,
695 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300696};
697
Nico Sabbi420f32f2006-03-03 12:11:28 -0300698static struct tda1004x_config lifeview_trio_config = {
699 .demod_address = 0x09,
700 .invert = 1,
701 .invert_oclk = 0,
702 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300703 .agc_config = TDA10046_AGC_TDA827X,
704 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300705 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300706 .tuner_address = 0x60,
707 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300708};
709
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300710static struct tda1004x_config tevion_dvbt220rf_config = {
711 .demod_address = 0x08,
712 .invert = 1,
713 .invert_oclk = 0,
714 .xtal_freq = TDA10046_XTAL_16M,
715 .agc_config = TDA10046_AGC_TDA827X,
716 .gpio_config = TDA10046_GP11_I,
717 .if_freq = TDA10046_FREQ_045,
718 .tuner_address = 0x60,
719 .request_firmware = philips_tda1004x_request_firmware
720};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300721
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300722static struct tda1004x_config md8800_dvbt_config = {
723 .demod_address = 0x08,
724 .invert = 1,
725 .invert_oclk = 0,
726 .xtal_freq = TDA10046_XTAL_16M,
727 .agc_config = TDA10046_AGC_TDA827X,
728 .gpio_config = TDA10046_GP01_I,
729 .if_freq = TDA10046_FREQ_045,
730 .i2c_gate = 0x4b,
731 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300732 .request_firmware = philips_tda1004x_request_firmware
733};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200734
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300735static struct tda1004x_config asus_p7131_4871_config = {
736 .demod_address = 0x08,
737 .invert = 1,
738 .invert_oclk = 0,
739 .xtal_freq = TDA10046_XTAL_16M,
740 .agc_config = TDA10046_AGC_TDA827X,
741 .gpio_config = TDA10046_GP01_I,
742 .if_freq = TDA10046_FREQ_045,
743 .i2c_gate = 0x4b,
744 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300745 .antenna_switch= 2,
746 .request_firmware = philips_tda1004x_request_firmware
747};
748
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300749static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300750 .demod_address = 0x08,
751 .invert = 1,
752 .invert_oclk = 0,
753 .xtal_freq = TDA10046_XTAL_16M,
754 .agc_config = TDA10046_AGC_TDA827X,
755 .gpio_config = TDA10046_GP11_I,
756 .if_freq = TDA10046_FREQ_045,
757 .i2c_gate = 0x4b,
758 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300759 .antenna_switch= 2,
760 .request_firmware = philips_tda1004x_request_firmware
761};
Edgar Simo261f5082007-08-20 14:06:00 -0300762
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300763static struct tda1004x_config kworld_dvb_t_210_config = {
764 .demod_address = 0x08,
765 .invert = 1,
766 .invert_oclk = 0,
767 .xtal_freq = TDA10046_XTAL_16M,
768 .agc_config = TDA10046_AGC_TDA827X,
769 .gpio_config = TDA10046_GP11_I,
770 .if_freq = TDA10046_FREQ_045,
771 .i2c_gate = 0x4b,
772 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300773 .antenna_switch= 1,
774 .request_firmware = philips_tda1004x_request_firmware
775};
Edgar Simo261f5082007-08-20 14:06:00 -0300776
Edgar Simod90d9f52007-08-20 14:14:50 -0300777static struct tda1004x_config avermedia_super_007_config = {
778 .demod_address = 0x08,
779 .invert = 1,
780 .invert_oclk = 0,
781 .xtal_freq = TDA10046_XTAL_16M,
782 .agc_config = TDA10046_AGC_TDA827X,
783 .gpio_config = TDA10046_GP01_I,
784 .if_freq = TDA10046_FREQ_045,
785 .i2c_gate = 0x4b,
786 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300787 .antenna_switch= 1,
788 .request_firmware = philips_tda1004x_request_firmware
789};
790
Hermann Pitton4ba24372008-01-20 19:27:51 -0300791static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
792 .demod_address = 0x08,
793 .invert = 1,
794 .invert_oclk = 0,
795 .xtal_freq = TDA10046_XTAL_16M,
796 .agc_config = TDA10046_AGC_TDA827X,
797 .gpio_config = TDA10046_GP01_I,
798 .if_freq = TDA10046_FREQ_045,
799 .i2c_gate = 0x42,
800 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300801 .antenna_switch = 1,
802 .request_firmware = philips_tda1004x_request_firmware
803};
804
hermann pitton301e9d62008-09-14 17:49:14 -0300805static struct tda1004x_config asus_tiger_3in1_config = {
806 .demod_address = 0x0b,
807 .invert = 1,
808 .invert_oclk = 0,
809 .xtal_freq = TDA10046_XTAL_16M,
810 .agc_config = TDA10046_AGC_TDA827X,
811 .gpio_config = TDA10046_GP11_I,
812 .if_freq = TDA10046_FREQ_045,
813 .i2c_gate = 0x4b,
814 .tuner_address = 0x61,
815 .antenna_switch = 1,
816 .request_firmware = philips_tda1004x_request_firmware
817};
818
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300819/* ------------------------------------------------------------------
820 * special case: this card uses saa713x GPIO22 for the mode switch
821 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200822
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300823static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200824{
825 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300826 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200827 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300828 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200829 return 0;
830}
831
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300832static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200833{
834 struct saa7134_dev *dev = fe->dvb->priv;
835 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300836 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300837 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300838 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200839}
840
Michael Krufky8ce47da2007-04-27 12:31:14 -0300841static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300842 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300843 .sleep = ads_duo_tuner_sleep,
844 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300845};
846
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200847static struct tda1004x_config ads_tech_duo_config = {
848 .demod_address = 0x08,
849 .invert = 1,
850 .invert_oclk = 0,
851 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300852 .agc_config = TDA10046_AGC_TDA827X,
853 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200854 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300855 .tuner_address = 0x61,
856 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200857};
858
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300859static struct zl10353_config behold_h6_config = {
860 .demod_address = 0x1e>>1,
861 .no_tuner = 1,
862 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300863 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300864};
865
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300866/* ==================================================================
867 * tda10086 based DVB-S cards, helper functions
868 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300869
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300870static struct tda10086_config flydvbs = {
871 .demod_address = 0x0e,
872 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300873 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300874 .xtal_freq = TDA10086_XTAL_16M,
875};
876
877static struct tda10086_config sd1878_4m = {
878 .demod_address = 0x0e,
879 .invert = 0,
880 .diseqc_tone = 0,
881 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300882};
883
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300884/* ------------------------------------------------------------------
885 * special case: lnb supply is connected to the gated i2c
886 */
887
888static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
889{
890 int res = -EIO;
891 struct saa7134_dev *dev = fe->dvb->priv;
892 if (fe->ops.i2c_gate_ctrl) {
893 fe->ops.i2c_gate_ctrl(fe, 1);
894 if (dev->original_set_voltage)
895 res = dev->original_set_voltage(fe, voltage);
896 fe->ops.i2c_gate_ctrl(fe, 0);
897 }
898 return res;
899};
900
901static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
902{
903 int res = -EIO;
904 struct saa7134_dev *dev = fe->dvb->priv;
905 if (fe->ops.i2c_gate_ctrl) {
906 fe->ops.i2c_gate_ctrl(fe, 1);
907 if (dev->original_set_high_voltage)
908 res = dev->original_set_high_voltage(fe, arg);
909 fe->ops.i2c_gate_ctrl(fe, 0);
910 }
911 return res;
912};
913
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300914static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
915{
916 struct saa7134_dev *dev = fe->dvb->priv;
917 u8 wbuf[2] = { 0x1f, 00 };
918 u8 rbuf;
919 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
920 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
921
922 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
923 return -EIO;
924 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
925 if (voltage == SEC_VOLTAGE_18)
926 wbuf[1] = rbuf | 0x10;
927 else
928 wbuf[1] = rbuf & 0xef;
929 msg[0].len = 2;
930 i2c_transfer(&dev->i2c_adap, msg, 1);
931 return 0;
932}
933
934static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
935{
936 struct saa7134_dev *dev = fe->dvb->priv;
937 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
938 return -EIO;
939}
940
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300941/* ==================================================================
942 * nxt200x based ATSC cards, helper functions
943 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800944
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800945static struct nxt200x_config avertvhda180 = {
946 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800947};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300948
949static struct nxt200x_config kworldatsc110 = {
950 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300951};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800952
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300953/* ==================================================================
954 * Core code
955 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700956
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957static int dvb_init(struct saa7134_dev *dev)
958{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -0300959 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300960 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300961 struct videobuf_dvb_frontend *fe0;
962
Darron Broadf972e0b2008-10-11 11:24:30 -0300963 /* FIXME: add support for multi-frontend */
964 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -0300965 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -0300966
967 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -0300968 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
969 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -0300970 printk(KERN_ERR "%s() failed to alloc\n", __func__);
971 return -ENOMEM;
972 }
973
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 /* init struct videobuf_dvb */
975 dev->ts.nr_bufs = 32;
976 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -0300977 fe0->dvb.name = dev->name;
978 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -0300979 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 V4L2_BUF_TYPE_VIDEO_CAPTURE,
981 V4L2_FIELD_ALTERNATE,
982 sizeof(struct saa7134_buf),
983 dev);
984
985 switch (dev->board) {
986 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300987 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -0300988 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300989 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300990 if (fe0->dvb.frontend) {
991 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -0300992 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200994 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -0300995 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -0300996 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -0300997 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300998 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300999 if (fe0->dvb.frontend) {
1000 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001001 &dev->i2c_adap, 0x61,
1002 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001003 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001004 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001005 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001006 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001007 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001008 &avermedia_xc3028_mt352_dev,
1009 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001010 attach_xc3028 = 1;
1011 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001013 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001014 &medion_cardbus,
1015 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001016 if (fe0->dvb.frontend) {
1017 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd332008-04-22 14:46:16 -03001018 &dev->i2c_adap, medion_cardbus.tuner_address,
1019 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001020 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001022 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001023 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001024 &philips_tu1216_60_config,
1025 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001026 if (fe0->dvb.frontend) {
1027 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1028 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001029 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001030 break;
1031 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001032 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001033 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1034 &tda827x_cfg_0) < 0)
1035 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001036 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001037 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001038 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Steven Toth363c35f2008-10-11 11:05:50 -03001039 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001040 &philips_europa_config,
1041 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001042 if (fe0->dvb.frontend) {
1043 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1044 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1045 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1046 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1047 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001048 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001049 break;
1050 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001051 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001052 &philips_tu1216_61_config,
1053 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001054 if (fe0->dvb.frontend) {
1055 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1056 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001057 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001058 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001059 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001060 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1061 &tda827x_cfg_2) < 0)
1062 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001063 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001064 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001065 if (configure_tda827x_fe(dev, &philips_tiger_config,
1066 &tda827x_cfg_0) < 0)
1067 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001068 break;
1069 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001070 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1071 &tda827x_cfg_1) < 0)
1072 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001073 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001074 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001075 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1076 &tda827x_cfg_1) < 0)
1077 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001078 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001079 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001080 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1081 &tda827x_cfg_0) < 0)
1082 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001083 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001084 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001085 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1086 &tda827x_cfg_0) < 0)
1087 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001088 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001089 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001090 if (!use_frontend) { /* terrestrial */
1091 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1092 &tda827x_cfg_0) < 0)
1093 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001094 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001095 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1096 if (fe0->dvb.frontend) {
1097 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001098 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001099 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001100 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001101 }
Steven Toth363c35f2008-10-11 11:05:50 -03001102 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001103 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001104 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001105 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001106 }
1107 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001108 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001109 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001110 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001111 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001112 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001113 &ads_tech_duo_config,
1114 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001115 if (fe0->dvb.frontend) {
1116 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001117 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1118 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001119 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001120 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001121 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001122 }
Mauro Carvalho Chehabbc36ec72008-06-14 10:44:04 -03001123 } else
1124 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001125 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001126 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001127 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1128 &tda827x_cfg_0) < 0)
1129 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001130 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001131 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001132 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001133 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1134 &tda827x_cfg_0) < 0)
1135 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001136 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001137 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001138 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001139 if (fe0->dvb.frontend) {
1140 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001141 u8 dev_id = dev->eedata[2];
1142 u8 data = 0xc4;
1143 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1144
Steven Toth363c35f2008-10-11 11:05:50 -03001145 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001146 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001147 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001148 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001149 goto dettach_frontend;
1150 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001151 if (dev_id != 0x08) {
1152 /* we need to open the i2c gate (we know it exists) */
1153 fe->ops.i2c_gate_ctrl(fe, 1);
1154 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001155 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001156 wprintk("%s: Medion Quadro, no ISL6405 "
1157 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001158 goto dettach_frontend;
1159 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001160 if (dev_id == 0x07) {
1161 /* fire up the 2nd section of the LNB supply since
1162 we can't do this from the other section */
1163 msg.buf = &data;
1164 i2c_transfer(&dev->i2c_adap, &msg, 1);
1165 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001166 fe->ops.i2c_gate_ctrl(fe, 0);
1167 dev->original_set_voltage = fe->ops.set_voltage;
1168 fe->ops.set_voltage = md8800_set_voltage;
1169 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1170 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1171 } else {
1172 fe->ops.set_voltage = md8800_set_voltage2;
1173 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1174 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001175 }
1176 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001177 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001178 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001179 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001180 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001181 if (fe0->dvb.frontend)
1182 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001183 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001184 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001185 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001186 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001187 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001188 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001189 if (fe0->dvb.frontend)
1190 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001191 &dev->i2c_adap, 0x61,
1192 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001193 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001194 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001195 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001196 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001197 if (fe0->dvb.frontend) {
1198 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001199 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001200 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001201 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001202 }
Steven Toth363c35f2008-10-11 11:05:50 -03001203 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001204 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001205 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001206 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001207 }
1208 }
1209 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001210 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001211 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001212 &medion_cardbus,
1213 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001214 if (fe0->dvb.frontend) {
1215 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1216 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001217
Steven Toth363c35f2008-10-11 11:05:50 -03001218 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd332008-04-22 14:46:16 -03001219 &dev->i2c_adap, medion_cardbus.tuner_address,
1220 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001221 }
1222 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001223 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001224 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001225 &philips_europa_config,
1226 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001227 if (fe0->dvb.frontend) {
1228 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1229 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001230 }
1231 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001232 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001233 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1234 &tda827x_cfg_0) < 0)
1235 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001236 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001237 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001238 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1239 &tda827x_cfg_0) < 0)
1240 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001241 break;
1242 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001243 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1244 &tda827x_cfg_2) < 0)
1245 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001246 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001247 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001248 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1249 &tda827x_cfg_2) < 0)
1250 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001251 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001252 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001253 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1254 &tda827x_cfg_2) < 0)
1255 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001256 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001257 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001258 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1259 &tda827x_cfg_0) < 0)
1260 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001261 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001262 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001263 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1264 &tda827x_cfg_2_sw42) < 0)
1265 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001266 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001267 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001268 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001269 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001270 if (fe0->dvb.frontend) {
1271 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001272 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001273 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001274 goto dettach_frontend;
1275 }
Steven Toth363c35f2008-10-11 11:05:50 -03001276 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001277 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001278 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001279 goto dettach_frontend;
1280 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001281 }
1282 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001283 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001284 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1285 &tda827x_cfg_0) < 0)
1286 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001287 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001288 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001289 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1290 &tda827x_cfg_2) < 0)
1291 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001292 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001293 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001294 dprintk("AverMedia E506R dvb setup\n");
1295 saa7134_set_gpio(dev, 25, 0);
1296 msleep(10);
1297 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001298 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001299 &avermedia_xc3028_mt352_dev,
1300 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001301 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001302 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001303 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001304 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001305 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001306 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001307 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001308 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001309 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001310 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001311 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001312 goto dettach_frontend;
1313 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001314 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001315 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001316 fe->ops.i2c_gate_ctrl(fe, 1);
1317 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001318 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001319 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001320 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001321 goto dettach_frontend;
1322 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001323 fe->ops.i2c_gate_ctrl(fe, 0);
1324 dev->original_set_voltage = fe->ops.set_voltage;
1325 fe->ops.set_voltage = md8800_set_voltage;
1326 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1327 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1328 }
1329 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001330 case SAA7134_BOARD_AVERMEDIA_M103:
1331 saa7134_set_gpio(dev, 25, 0);
1332 msleep(10);
1333 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001334 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001335 &avermedia_xc3028_mt352_dev,
1336 &dev->i2c_adap);
1337 attach_xc3028 = 1;
1338 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001339 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1340 if (!use_frontend) { /* terrestrial */
1341 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1342 &tda827x_cfg_2) < 0)
1343 goto dettach_frontend;
1344 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001345 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001346 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001347 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001348 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001349 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001350 &dev->i2c_adap, 0) == NULL) {
1351 wprintk("%s: Asus Tiger 3in1, no "
1352 "tda826x found!\n", __func__);
1353 goto dettach_frontend;
1354 }
Steven Toth363c35f2008-10-11 11:05:50 -03001355 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001356 &dev->i2c_adap, 0, 0) == NULL) {
1357 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1358 " found!\n", __func__);
1359 goto dettach_frontend;
1360 }
1361 }
1362 }
1363 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001364 case SAA7134_BOARD_ASUSTeK_TIGER:
1365 if (configure_tda827x_fe(dev, &philips_tiger_config,
1366 &tda827x_cfg_0) < 0)
1367 goto dettach_frontend;
1368 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001369 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001370 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001371 &behold_h6_config,
1372 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001373 if (fe0->dvb.frontend) {
1374 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001375 &dev->i2c_adap, 0x61,
1376 TUNER_PHILIPS_FMD1216ME_MK3);
1377 }
1378 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001380 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381 break;
1382 }
1383
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001384 if (attach_xc3028) {
1385 struct dvb_frontend *fe;
1386 struct xc2028_config cfg = {
1387 .i2c_adap = &dev->i2c_adap,
1388 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001389 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001390
Steven Toth363c35f2008-10-11 11:05:50 -03001391 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001392 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001393
Steven Toth363c35f2008-10-11 11:05:50 -03001394 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001395 if (!fe) {
1396 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1397 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001398 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001399 }
1400 }
1401
Steven Toth363c35f2008-10-11 11:05:50 -03001402 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001403 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001404 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001406 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001407 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408
1409 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001410 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Darron Broad59b18422008-10-11 11:44:05 -03001411 &dev->pci->dev, adapter_nr, 0);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001412
1413 /* this sequence is necessary to make the tda1004x load its firmware
1414 * and to enter analog mode of hybrid boards
1415 */
1416 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001417 if (fe0->dvb.frontend->ops.init)
1418 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1419 if (fe0->dvb.frontend->ops.sleep)
1420 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1421 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1422 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001423 }
1424 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001425
1426dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001427 videobuf_dvb_dealloc_frontends(&dev->frontends);
1428 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429}
1430
1431static int dvb_fini(struct saa7134_dev *dev)
1432{
Steven Toth363c35f2008-10-11 11:05:50 -03001433 struct videobuf_dvb_frontend *fe0;
1434
1435 /* Get the first frontend */
1436 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1437 if (!fe0)
1438 return -EINVAL;
1439
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001440 /* FIXME: I suspect that this code is bogus, since the entry for
1441 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1442 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1443 */
1444 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1445 struct v4l2_priv_tun_config tda9887_cfg;
1446 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001448 tda9887_cfg.tuner = TUNER_TDA9887;
1449 tda9887_cfg.priv = &on;
1450
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001452 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001453 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001454 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001455 /* turn off the 2nd lnb supply */
1456 u8 data = 0x80;
1457 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1458 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001459 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001460 if (fe->ops.i2c_gate_ctrl) {
1461 fe->ops.i2c_gate_ctrl(fe, 1);
1462 i2c_transfer(&dev->i2c_adap, &msg, 1);
1463 fe->ops.i2c_gate_ctrl(fe, 0);
1464 }
1465 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001466 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001467 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 return 0;
1469}
1470
1471static struct saa7134_mpeg_ops dvb_ops = {
1472 .type = SAA7134_MPEG_DVB,
1473 .init = dvb_init,
1474 .fini = dvb_fini,
1475};
1476
1477static int __init dvb_register(void)
1478{
1479 return saa7134_ts_register(&dvb_ops);
1480}
1481
1482static void __exit dvb_unregister(void)
1483{
1484 saa7134_ts_unregister(&dvb_ops);
1485}
1486
1487module_init(dvb_register);
1488module_exit(dvb_unregister);
1489
1490/* ------------------------------------------------------------------ */
1491/*
1492 * Local variables:
1493 * c-basic-offset: 8
1494 * End:
1495 */