blob: 73739d2a63dd529857461087fd95d60383667599 [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"
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -030043#include "xc5000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070044
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030045#include "tda10086.h"
46#include "tda826x.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030047#include "tda827x.h"
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -030048#include "isl6421.h"
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -030049#include "isl6405.h"
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -030050#include "lnbp21.h"
Michael Krufkycb89cd32008-04-22 14:46:16 -030051#include "tuner-simple.h"
Michael Krufky1bc7f512009-01-19 01:10:49 -030052#include "tda10048.h"
Michael Krufky3abdedd2009-01-19 01:10:49 -030053#include "tda18271.h"
54#include "lgdt3305.h"
55#include "tda8290.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030056
Dmitri Belimov47aeba52008-12-23 03:53:03 -030057#include "zl10353.h"
58
Matthias Schwarzott04574182009-02-24 12:35:16 -030059#include "zl10036.h"
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -030060#include "zl10039.h"
Matthias Schwarzott04574182009-02-24 12:35:16 -030061#include "mt312.h"
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
64MODULE_LICENSE("GPL");
65
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030066static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070067
Linus Torvalds1da177e2005-04-16 15:20:36 -070068module_param(antenna_pwr, int, 0444);
69MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
70
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030071static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030072module_param(use_frontend, int, 0644);
73MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030074
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030075static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030076module_param(debug, int, 0644);
77MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
78
Janne Grunau78e92002008-04-09 19:13:13 -030079DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
80
Trent Piephocf3c34c2007-03-07 18:19:48 -030081#define dprintk(fmt, arg...) do { if (debug) \
82 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
83
84/* Print a warning */
85#define wprintk(fmt, arg...) \
86 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030087
88/* ------------------------------------------------------------------
89 * mt352 based DVB-T cards
90 */
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
93{
94 u32 ok;
95
96 if (!on) {
97 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
98 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
99 return 0;
100 }
101
102 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
103 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
104 udelay(10);
105
106 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
107 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
108 udelay(10);
109 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
110 udelay(10);
111 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300112 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
114 if (!ok)
115 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
116 return ok;
117}
118
119static int mt352_pinnacle_init(struct dvb_frontend* fe)
120{
121 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
122 static u8 reset [] = { RESET, 0x80 };
123 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
124 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
125 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
126 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
127 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
128 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
129 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
130 struct saa7134_dev *dev= fe->dvb->priv;
131
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300132 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
134 mt352_write(fe, clock_config, sizeof(clock_config));
135 udelay(200);
136 mt352_write(fe, reset, sizeof(reset));
137 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
138 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
139 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
140 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
141
142 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
143 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
144 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300145
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 return 0;
147}
148
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200149static int mt352_aver777_init(struct dvb_frontend* fe)
150{
151 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
152 static u8 reset [] = { RESET, 0x80 };
153 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
154 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
155 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
156
157 mt352_write(fe, clock_config, sizeof(clock_config));
158 udelay(200);
159 mt352_write(fe, reset, sizeof(reset));
160 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
161 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
162 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
163
164 return 0;
165}
166
Tim Farrington6e501a32008-06-15 13:33:42 -0300167static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300168{
Tim Farrington6e501a32008-06-15 13:33:42 -0300169 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
170 static u8 reset [] = { RESET, 0x80 };
171 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
172 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300173 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
174
175 mt352_write(fe, clock_config, sizeof(clock_config));
176 udelay(200);
177 mt352_write(fe, reset, sizeof(reset));
178 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
179 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
180 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300181 return 0;
182}
183
Andrew de Quincey0463f122006-05-16 17:22:02 -0300184static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
185 struct dvb_frontend_parameters* params)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186{
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300187 u8 off[] = { 0x00, 0xf1};
188 u8 on[] = { 0x00, 0x71};
189 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 struct saa7134_dev *dev = fe->dvb->priv;
192 struct v4l2_frequency f;
193
194 /* set frequency (mt2050) */
195 f.tuner = 0;
196 f.type = V4L2_TUNER_DIGITAL_TV;
197 f.frequency = params->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300198 if (fe->ops.i2c_gate_ctrl)
199 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300200 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300201 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300202 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300203 if (fe->ops.i2c_gate_ctrl)
204 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300205 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206
207 pinnacle_antenna_pwr(dev, antenna_pwr);
208
209 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300210 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211}
212
213static struct mt352_config pinnacle_300i = {
214 .demod_address = 0x3c >> 1,
215 .adc_clock = 20333,
216 .if2 = 36150,
217 .no_tuner = 1,
218 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200220
221static struct mt352_config avermedia_777 = {
222 .demod_address = 0xf,
223 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200224};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
Tim Farrington6e501a32008-06-15 13:33:42 -0300226static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300227 .demod_address = (0x1e >> 1),
228 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300229 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300230};
231
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300232/* ==================================================================
233 * tda1004x based DVB-T cards, helper functions
234 */
235
236static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
237 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700238{
239 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300240 return request_firmware(fw, name, &dev->pci->dev);
241}
242
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300243/* ------------------------------------------------------------------
244 * these tuners are tu1216, td1316(a)
245 */
246
247static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
248{
249 struct saa7134_dev *dev = fe->dvb->priv;
250 struct tda1004x_state *state = fe->demodulator_priv;
251 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700252 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800253 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700254 sizeof(tuner_buf) };
255 int tuner_frequency = 0;
256 u8 band, cp, filter;
257
258 /* determine charge pump */
259 tuner_frequency = params->frequency + 36166000;
260 if (tuner_frequency < 87000000)
261 return -EINVAL;
262 else if (tuner_frequency < 130000000)
263 cp = 3;
264 else if (tuner_frequency < 160000000)
265 cp = 5;
266 else if (tuner_frequency < 200000000)
267 cp = 6;
268 else if (tuner_frequency < 290000000)
269 cp = 3;
270 else if (tuner_frequency < 420000000)
271 cp = 5;
272 else if (tuner_frequency < 480000000)
273 cp = 6;
274 else if (tuner_frequency < 620000000)
275 cp = 3;
276 else if (tuner_frequency < 830000000)
277 cp = 5;
278 else if (tuner_frequency < 895000000)
279 cp = 7;
280 else
281 return -EINVAL;
282
283 /* determine band */
284 if (params->frequency < 49000000)
285 return -EINVAL;
286 else if (params->frequency < 161000000)
287 band = 1;
288 else if (params->frequency < 444000000)
289 band = 2;
290 else if (params->frequency < 861000000)
291 band = 4;
292 else
293 return -EINVAL;
294
295 /* setup PLL filter */
296 switch (params->u.ofdm.bandwidth) {
297 case BANDWIDTH_6_MHZ:
298 filter = 0;
299 break;
300
301 case BANDWIDTH_7_MHZ:
302 filter = 0;
303 break;
304
305 case BANDWIDTH_8_MHZ:
306 filter = 1;
307 break;
308
309 default:
310 return -EINVAL;
311 }
312
313 /* calculate divisor
314 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
315 */
316 tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
317
318 /* setup tuner buffer */
319 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
320 tuner_buf[1] = tuner_frequency & 0xff;
321 tuner_buf[2] = 0xca;
322 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
323
Patrick Boettcherdea74862006-05-14 05:01:31 -0300324 if (fe->ops.i2c_gate_ctrl)
325 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300326 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300327 wprintk("could not write to tuner at addr: 0x%02x\n",
328 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700329 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300330 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700331 msleep(1);
332 return 0;
333}
334
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300335static int philips_tu1216_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800336{
337 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300338 struct tda1004x_state *state = fe->demodulator_priv;
339 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800340 static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
341 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
342
343 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300344 if (fe->ops.i2c_gate_ctrl)
345 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800346 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
347 return -EIO;
348 msleep(1);
349
350 return 0;
351}
352
353/* ------------------------------------------------------------------ */
354
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800355static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700356 .demod_address = 0x8,
357 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800358 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700359 .xtal_freq = TDA10046_XTAL_4M,
360 .agc_config = TDA10046_AGC_DEFAULT,
361 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300362 .tuner_address = 0x60,
363 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364};
365
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800366static struct tda1004x_config philips_tu1216_61_config = {
367
368 .demod_address = 0x8,
369 .invert = 1,
370 .invert_oclk = 0,
371 .xtal_freq = TDA10046_XTAL_4M,
372 .agc_config = TDA10046_AGC_DEFAULT,
373 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300374 .tuner_address = 0x61,
375 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800376};
377
378/* ------------------------------------------------------------------ */
379
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300380static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800381{
382 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300383 struct tda1004x_state *state = fe->demodulator_priv;
384 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800385 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300386 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800387
388 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300389 if (fe->ops.i2c_gate_ctrl)
390 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800391 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
392 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800393 return 0;
394}
395
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300396static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800397{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300398 return philips_tda6651_pll_set(fe, params);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800399}
400
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300401static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
402{
403 struct saa7134_dev *dev = fe->dvb->priv;
404 struct tda1004x_state *state = fe->demodulator_priv;
405 u8 addr = state->config->tuner_address;
406 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
407 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
408
409 /* switch the tuner to analog mode */
410 if (fe->ops.i2c_gate_ctrl)
411 fe->ops.i2c_gate_ctrl(fe, 1);
412 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
413 return -EIO;
414 return 0;
415}
416
417/* ------------------------------------------------------------------ */
418
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300419static int philips_europa_tuner_init(struct dvb_frontend *fe)
420{
421 struct saa7134_dev *dev = fe->dvb->priv;
422 static u8 msg[] = { 0x00, 0x40};
423 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
424
425
426 if (philips_td1316_tuner_init(fe))
427 return -EIO;
428 msleep(1);
429 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
430 return -EIO;
431
432 return 0;
433}
434
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300435static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800436{
437 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800438
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300439 static u8 msg[] = { 0x00, 0x14 };
440 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
441
442 if (philips_td1316_tuner_sleep(fe))
443 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800444
445 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300446 if (fe->ops.i2c_gate_ctrl)
447 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800448 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300449 return 0;
450}
451
452static int philips_europa_demod_sleep(struct dvb_frontend *fe)
453{
454 struct saa7134_dev *dev = fe->dvb->priv;
455
456 if (dev->original_demod_sleep)
457 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300458 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300459 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800460}
461
462static struct tda1004x_config philips_europa_config = {
463
464 .demod_address = 0x8,
465 .invert = 0,
466 .invert_oclk = 0,
467 .xtal_freq = TDA10046_XTAL_4M,
468 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
469 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300470 .tuner_address = 0x61,
471 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800472};
473
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700474static struct tda1004x_config medion_cardbus = {
475 .demod_address = 0x08,
476 .invert = 1,
477 .invert_oclk = 0,
478 .xtal_freq = TDA10046_XTAL_16M,
479 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
480 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300481 .tuner_address = 0x61,
482 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700483};
484
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300485/* ------------------------------------------------------------------
486 * tda 1004x based cards with philips silicon tuner
487 */
488
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300489static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
490{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300491 struct tda1004x_state *state = fe->demodulator_priv;
492
493 u8 addr = state->config->i2c_gate;
494 static u8 tda8290_close[] = { 0x21, 0xc0};
495 static u8 tda8290_open[] = { 0x21, 0x80};
496 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
497 if (enable) {
498 tda8290_msg.buf = tda8290_close;
499 } else {
500 tda8290_msg.buf = tda8290_open;
501 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300502 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300503 struct saa7134_dev *dev = fe->dvb->priv;
504 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300505 return -EIO;
506 }
507 msleep(20);
508 return 0;
509}
510
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300511static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300512{
513 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300514 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300515
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300516 switch (state->config->antenna_switch) {
517 case 0: break;
518 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
519 saa7134_set_gpio(dev, 21, 0);
520 break;
521 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
522 saa7134_set_gpio(dev, 21, 1);
523 break;
524 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300525 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800526}
527
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300528static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
529{
530 struct saa7134_dev *dev = fe->dvb->priv;
531 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300532
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300533 switch (state->config->antenna_switch) {
534 case 0: break;
535 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
536 saa7134_set_gpio(dev, 21, 1);
537 break;
538 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
539 saa7134_set_gpio(dev, 21, 0);
540 break;
541 }
542 return 0;
543}
544
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300545static int configure_tda827x_fe(struct saa7134_dev *dev,
546 struct tda1004x_config *cdec_conf,
547 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300548{
Steven Toth363c35f2008-10-11 11:05:50 -0300549 struct videobuf_dvb_frontend *fe0;
550
Darron Broad92abe9e2008-10-11 11:18:53 -0300551 /* Get the first frontend */
552 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300553
554 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
555 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300556 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300557 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
558 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300559 cdec_conf->tuner_address,
560 &dev->i2c_adap, tuner_conf))
561 return 0;
562
563 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300564 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300565 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300566 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300567}
568
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800569/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300570
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300571static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300572 .init = philips_tda827x_tuner_init,
573 .sleep = philips_tda827x_tuner_sleep,
574 .config = 0,
575 .switch_addr = 0
576};
577
578static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300579 .init = philips_tda827x_tuner_init,
580 .sleep = philips_tda827x_tuner_sleep,
581 .config = 1,
582 .switch_addr = 0x4b
583};
584
585static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300586 .init = philips_tda827x_tuner_init,
587 .sleep = philips_tda827x_tuner_sleep,
588 .config = 2,
589 .switch_addr = 0x4b
590};
591
592static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300593 .init = philips_tda827x_tuner_init,
594 .sleep = philips_tda827x_tuner_sleep,
595 .config = 2,
596 .switch_addr = 0x42
597};
598
599/* ------------------------------------------------------------------ */
600
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300601static struct tda1004x_config tda827x_lifeview_config = {
602 .demod_address = 0x08,
603 .invert = 1,
604 .invert_oclk = 0,
605 .xtal_freq = TDA10046_XTAL_16M,
606 .agc_config = TDA10046_AGC_TDA827X,
607 .gpio_config = TDA10046_GP11_I,
608 .if_freq = TDA10046_FREQ_045,
609 .tuner_address = 0x60,
610 .request_firmware = philips_tda1004x_request_firmware
611};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800612
613static struct tda1004x_config philips_tiger_config = {
614 .demod_address = 0x08,
615 .invert = 1,
616 .invert_oclk = 0,
617 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300618 .agc_config = TDA10046_AGC_TDA827X,
619 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300620 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300621 .i2c_gate = 0x4b,
622 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300623 .antenna_switch= 1,
624 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300625};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300626
627static struct tda1004x_config cinergy_ht_config = {
628 .demod_address = 0x08,
629 .invert = 1,
630 .invert_oclk = 0,
631 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300632 .agc_config = TDA10046_AGC_TDA827X,
633 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800634 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300635 .i2c_gate = 0x4b,
636 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300637 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800638};
639
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300640static struct tda1004x_config cinergy_ht_pci_config = {
641 .demod_address = 0x08,
642 .invert = 1,
643 .invert_oclk = 0,
644 .xtal_freq = TDA10046_XTAL_16M,
645 .agc_config = TDA10046_AGC_TDA827X,
646 .gpio_config = TDA10046_GP01_I,
647 .if_freq = TDA10046_FREQ_045,
648 .i2c_gate = 0x4b,
649 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300650 .request_firmware = philips_tda1004x_request_firmware
651};
652
653static struct tda1004x_config philips_tiger_s_config = {
654 .demod_address = 0x08,
655 .invert = 1,
656 .invert_oclk = 0,
657 .xtal_freq = TDA10046_XTAL_16M,
658 .agc_config = TDA10046_AGC_TDA827X,
659 .gpio_config = TDA10046_GP01_I,
660 .if_freq = TDA10046_FREQ_045,
661 .i2c_gate = 0x4b,
662 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300663 .antenna_switch= 1,
664 .request_firmware = philips_tda1004x_request_firmware
665};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200666
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300667static struct tda1004x_config pinnacle_pctv_310i_config = {
668 .demod_address = 0x08,
669 .invert = 1,
670 .invert_oclk = 0,
671 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300672 .agc_config = TDA10046_AGC_TDA827X,
673 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300674 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300675 .i2c_gate = 0x4b,
676 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300677 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300678};
679
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300680static struct tda1004x_config hauppauge_hvr_1110_config = {
681 .demod_address = 0x08,
682 .invert = 1,
683 .invert_oclk = 0,
684 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300685 .agc_config = TDA10046_AGC_TDA827X,
686 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300687 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300688 .i2c_gate = 0x4b,
689 .tuner_address = 0x61,
690 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300691};
692
Hartmut Hackmann83646812006-10-12 20:38:51 -0300693static struct tda1004x_config asus_p7131_dual_config = {
694 .demod_address = 0x08,
695 .invert = 1,
696 .invert_oclk = 0,
697 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300698 .agc_config = TDA10046_AGC_TDA827X,
699 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300700 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300701 .i2c_gate = 0x4b,
702 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300703 .antenna_switch= 2,
704 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300705};
706
Nico Sabbi420f32f2006-03-03 12:11:28 -0300707static struct tda1004x_config lifeview_trio_config = {
708 .demod_address = 0x09,
709 .invert = 1,
710 .invert_oclk = 0,
711 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300712 .agc_config = TDA10046_AGC_TDA827X,
713 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300714 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300715 .tuner_address = 0x60,
716 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300717};
718
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300719static struct tda1004x_config tevion_dvbt220rf_config = {
720 .demod_address = 0x08,
721 .invert = 1,
722 .invert_oclk = 0,
723 .xtal_freq = TDA10046_XTAL_16M,
724 .agc_config = TDA10046_AGC_TDA827X,
725 .gpio_config = TDA10046_GP11_I,
726 .if_freq = TDA10046_FREQ_045,
727 .tuner_address = 0x60,
728 .request_firmware = philips_tda1004x_request_firmware
729};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300730
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300731static struct tda1004x_config md8800_dvbt_config = {
732 .demod_address = 0x08,
733 .invert = 1,
734 .invert_oclk = 0,
735 .xtal_freq = TDA10046_XTAL_16M,
736 .agc_config = TDA10046_AGC_TDA827X,
737 .gpio_config = TDA10046_GP01_I,
738 .if_freq = TDA10046_FREQ_045,
739 .i2c_gate = 0x4b,
740 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300741 .request_firmware = philips_tda1004x_request_firmware
742};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200743
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300744static struct tda1004x_config asus_p7131_4871_config = {
745 .demod_address = 0x08,
746 .invert = 1,
747 .invert_oclk = 0,
748 .xtal_freq = TDA10046_XTAL_16M,
749 .agc_config = TDA10046_AGC_TDA827X,
750 .gpio_config = TDA10046_GP01_I,
751 .if_freq = TDA10046_FREQ_045,
752 .i2c_gate = 0x4b,
753 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300754 .antenna_switch= 2,
755 .request_firmware = philips_tda1004x_request_firmware
756};
757
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300758static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300759 .demod_address = 0x08,
760 .invert = 1,
761 .invert_oclk = 0,
762 .xtal_freq = TDA10046_XTAL_16M,
763 .agc_config = TDA10046_AGC_TDA827X,
764 .gpio_config = TDA10046_GP11_I,
765 .if_freq = TDA10046_FREQ_045,
766 .i2c_gate = 0x4b,
767 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300768 .antenna_switch= 2,
769 .request_firmware = philips_tda1004x_request_firmware
770};
Edgar Simo261f5082007-08-20 14:06:00 -0300771
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300772static struct tda1004x_config kworld_dvb_t_210_config = {
773 .demod_address = 0x08,
774 .invert = 1,
775 .invert_oclk = 0,
776 .xtal_freq = TDA10046_XTAL_16M,
777 .agc_config = TDA10046_AGC_TDA827X,
778 .gpio_config = TDA10046_GP11_I,
779 .if_freq = TDA10046_FREQ_045,
780 .i2c_gate = 0x4b,
781 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300782 .antenna_switch= 1,
783 .request_firmware = philips_tda1004x_request_firmware
784};
Edgar Simo261f5082007-08-20 14:06:00 -0300785
Edgar Simod90d9f52007-08-20 14:14:50 -0300786static struct tda1004x_config avermedia_super_007_config = {
787 .demod_address = 0x08,
788 .invert = 1,
789 .invert_oclk = 0,
790 .xtal_freq = TDA10046_XTAL_16M,
791 .agc_config = TDA10046_AGC_TDA827X,
792 .gpio_config = TDA10046_GP01_I,
793 .if_freq = TDA10046_FREQ_045,
794 .i2c_gate = 0x4b,
795 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300796 .antenna_switch= 1,
797 .request_firmware = philips_tda1004x_request_firmware
798};
799
Hermann Pitton4ba24372008-01-20 19:27:51 -0300800static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
801 .demod_address = 0x08,
802 .invert = 1,
803 .invert_oclk = 0,
804 .xtal_freq = TDA10046_XTAL_16M,
805 .agc_config = TDA10046_AGC_TDA827X,
806 .gpio_config = TDA10046_GP01_I,
807 .if_freq = TDA10046_FREQ_045,
808 .i2c_gate = 0x42,
809 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300810 .antenna_switch = 1,
811 .request_firmware = philips_tda1004x_request_firmware
812};
813
hermann pitton301e9d62008-09-14 17:49:14 -0300814static struct tda1004x_config asus_tiger_3in1_config = {
815 .demod_address = 0x0b,
816 .invert = 1,
817 .invert_oclk = 0,
818 .xtal_freq = TDA10046_XTAL_16M,
819 .agc_config = TDA10046_AGC_TDA827X,
820 .gpio_config = TDA10046_GP11_I,
821 .if_freq = TDA10046_FREQ_045,
822 .i2c_gate = 0x4b,
823 .tuner_address = 0x61,
824 .antenna_switch = 1,
825 .request_firmware = philips_tda1004x_request_firmware
826};
827
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300828/* ------------------------------------------------------------------
829 * special case: this card uses saa713x GPIO22 for the mode switch
830 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200831
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300832static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200833{
834 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300835 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200836 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300837 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200838 return 0;
839}
840
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300841static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200842{
843 struct saa7134_dev *dev = fe->dvb->priv;
844 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300845 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300846 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300847 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200848}
849
Michael Krufky8ce47da2007-04-27 12:31:14 -0300850static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300851 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300852 .sleep = ads_duo_tuner_sleep,
853 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300854};
855
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200856static struct tda1004x_config ads_tech_duo_config = {
857 .demod_address = 0x08,
858 .invert = 1,
859 .invert_oclk = 0,
860 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300861 .agc_config = TDA10046_AGC_TDA827X,
862 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200863 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300864 .tuner_address = 0x61,
865 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200866};
867
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300868static struct zl10353_config behold_h6_config = {
869 .demod_address = 0x1e>>1,
870 .no_tuner = 1,
871 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300872 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300873};
874
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300875static struct xc5000_config behold_x7_tunerconfig = {
876 .i2c_address = 0xc2>>1,
877 .if_khz = 4560,
Devin Heitmueller2a0d0562009-09-30 23:04:39 -0300878 .radio_input = XC5000_RADIO_FM1,
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300879};
880
881static struct zl10353_config behold_x7_config = {
882 .demod_address = 0x1e>>1,
883 .if2 = 45600,
884 .no_tuner = 1,
885 .parallel_ts = 1,
886 .disable_i2c_gate_ctrl = 1,
887};
888
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300889/* ==================================================================
890 * tda10086 based DVB-S cards, helper functions
891 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300892
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300893static struct tda10086_config flydvbs = {
894 .demod_address = 0x0e,
895 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300896 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300897 .xtal_freq = TDA10086_XTAL_16M,
898};
899
900static struct tda10086_config sd1878_4m = {
901 .demod_address = 0x0e,
902 .invert = 0,
903 .diseqc_tone = 0,
904 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300905};
906
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300907/* ------------------------------------------------------------------
908 * special case: lnb supply is connected to the gated i2c
909 */
910
911static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
912{
913 int res = -EIO;
914 struct saa7134_dev *dev = fe->dvb->priv;
915 if (fe->ops.i2c_gate_ctrl) {
916 fe->ops.i2c_gate_ctrl(fe, 1);
917 if (dev->original_set_voltage)
918 res = dev->original_set_voltage(fe, voltage);
919 fe->ops.i2c_gate_ctrl(fe, 0);
920 }
921 return res;
922};
923
924static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
925{
926 int res = -EIO;
927 struct saa7134_dev *dev = fe->dvb->priv;
928 if (fe->ops.i2c_gate_ctrl) {
929 fe->ops.i2c_gate_ctrl(fe, 1);
930 if (dev->original_set_high_voltage)
931 res = dev->original_set_high_voltage(fe, arg);
932 fe->ops.i2c_gate_ctrl(fe, 0);
933 }
934 return res;
935};
936
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300937static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
938{
939 struct saa7134_dev *dev = fe->dvb->priv;
940 u8 wbuf[2] = { 0x1f, 00 };
941 u8 rbuf;
942 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
943 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
944
945 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
946 return -EIO;
947 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
948 if (voltage == SEC_VOLTAGE_18)
949 wbuf[1] = rbuf | 0x10;
950 else
951 wbuf[1] = rbuf & 0xef;
952 msg[0].len = 2;
953 i2c_transfer(&dev->i2c_adap, msg, 1);
954 return 0;
955}
956
957static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
958{
959 struct saa7134_dev *dev = fe->dvb->priv;
960 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
961 return -EIO;
962}
963
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300964/* ==================================================================
965 * nxt200x based ATSC cards, helper functions
966 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800967
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800968static struct nxt200x_config avertvhda180 = {
969 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800970};
Andrew Burri3e1410a2006-02-27 00:08:23 -0300971
972static struct nxt200x_config kworldatsc110 = {
973 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -0300974};
Michael Krufky3b64e8e2005-11-08 21:38:20 -0800975
Matthias Schwarzott04574182009-02-24 12:35:16 -0300976/* ------------------------------------------------------------------ */
977
978static struct mt312_config avertv_a700_mt312 = {
979 .demod_address = 0x0e,
980 .voltage_inverted = 1,
981};
982
983static struct zl10036_config avertv_a700_tuner = {
984 .tuner_address = 0x60,
985};
986
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -0300987static struct mt312_config zl10313_compro_s350_config = {
988 .demod_address = 0x0e,
989};
990
Michael Krufky3abdedd2009-01-19 01:10:49 -0300991static struct lgdt3305_config hcw_lgdt3305_config = {
992 .i2c_addr = 0x0e,
993 .mpeg_mode = LGDT3305_MPEG_SERIAL,
994 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
995 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
996 .deny_i2c_rptr = 1,
997 .spectral_inversion = 1,
998 .qam_if_khz = 4000,
999 .vsb_if_khz = 3250,
1000};
1001
Michael Krufky1bc7f512009-01-19 01:10:49 -03001002static struct tda10048_config hcw_tda10048_config = {
1003 .demod_address = 0x10 >> 1,
1004 .output_mode = TDA10048_SERIAL_OUTPUT,
1005 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1006 .inversion = TDA10048_INVERSION_ON,
1007 .dtv6_if_freq_khz = TDA10048_IF_3300,
1008 .dtv7_if_freq_khz = TDA10048_IF_3500,
1009 .dtv8_if_freq_khz = TDA10048_IF_4000,
1010 .clk_freq_khz = TDA10048_CLK_16000,
1011 .disable_gate_access = 1,
1012};
1013
Michael Krufky3abdedd2009-01-19 01:10:49 -03001014static struct tda18271_std_map hauppauge_tda18271_std_map = {
1015 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1016 .if_lvl = 1, .rfagc_top = 0x58, },
1017 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1018 .if_lvl = 1, .rfagc_top = 0x58, },
1019};
1020
1021static struct tda18271_config hcw_tda18271_config = {
1022 .std_map = &hauppauge_tda18271_std_map,
1023 .gate = TDA18271_GATE_ANALOG,
1024 .config = 3,
Michael Krufky542cb052009-08-29 17:45:48 -03001025 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky3abdedd2009-01-19 01:10:49 -03001026};
1027
1028static struct tda829x_config tda829x_no_probe = {
1029 .probe_tuner = TDA829X_DONT_PROBE,
1030};
1031
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001032static struct tda10048_config zolid_tda10048_config = {
1033 .demod_address = 0x10 >> 1,
1034 .output_mode = TDA10048_PARALLEL_OUTPUT,
1035 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1036 .inversion = TDA10048_INVERSION_ON,
1037 .dtv6_if_freq_khz = TDA10048_IF_3300,
1038 .dtv7_if_freq_khz = TDA10048_IF_3500,
1039 .dtv8_if_freq_khz = TDA10048_IF_4000,
1040 .clk_freq_khz = TDA10048_CLK_16000,
1041 .disable_gate_access = 1,
1042};
1043
1044static struct tda18271_config zolid_tda18271_config = {
1045 .gate = TDA18271_GATE_ANALOG,
1046};
1047
Michael Krufky184e7692009-06-05 04:28:28 -03001048static struct tda10048_config dtv1000s_tda10048_config = {
1049 .demod_address = 0x10 >> 1,
1050 .output_mode = TDA10048_PARALLEL_OUTPUT,
1051 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1052 .inversion = TDA10048_INVERSION_ON,
1053 .dtv6_if_freq_khz = TDA10048_IF_3300,
1054 .dtv7_if_freq_khz = TDA10048_IF_3800,
1055 .dtv8_if_freq_khz = TDA10048_IF_4300,
1056 .clk_freq_khz = TDA10048_CLK_16000,
1057 .disable_gate_access = 1,
1058};
1059
1060static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1061 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1062 .if_lvl = 1, .rfagc_top = 0x37, },
1063 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1064 .if_lvl = 1, .rfagc_top = 0x37, },
1065 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1066 .if_lvl = 1, .rfagc_top = 0x37, },
1067};
1068
1069static struct tda18271_config dtv1000s_tda18271_config = {
1070 .std_map = &dtv1000s_tda18271_std_map,
1071 .gate = TDA18271_GATE_ANALOG,
1072};
1073
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001074/* ==================================================================
1075 * Core code
1076 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001077
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078static int dvb_init(struct saa7134_dev *dev)
1079{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001080 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001081 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001082 struct videobuf_dvb_frontend *fe0;
1083
Darron Broadf972e0b2008-10-11 11:24:30 -03001084 /* FIXME: add support for multi-frontend */
1085 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001086 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -03001087
1088 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001089 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1090 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -03001091 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1092 return -ENOMEM;
1093 }
1094
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 /* init struct videobuf_dvb */
1096 dev->ts.nr_bufs = 32;
1097 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001098 fe0->dvb.name = dev->name;
1099 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001100 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1102 V4L2_FIELD_ALTERNATE,
1103 sizeof(struct saa7134_buf),
1104 dev);
1105
1106 switch (dev->board) {
1107 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001108 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001109 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001110 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001111 if (fe0->dvb.frontend) {
1112 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001113 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001115 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001116 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001117 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001118 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001119 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001120 if (fe0->dvb.frontend) {
1121 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001122 &dev->i2c_adap, 0x61,
1123 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001124 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001125 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001126 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001127 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001128 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001129 &avermedia_xc3028_mt352_dev,
1130 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001131 attach_xc3028 = 1;
1132 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001134 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001135 &medion_cardbus,
1136 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001137 if (fe0->dvb.frontend) {
1138 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001139 &dev->i2c_adap, medion_cardbus.tuner_address,
1140 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001141 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001143 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001144 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001145 &philips_tu1216_60_config,
1146 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001147 if (fe0->dvb.frontend) {
1148 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1149 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001150 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001151 break;
1152 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001153 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001154 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1155 &tda827x_cfg_0) < 0)
1156 goto dettach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001157 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001158 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001159 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Danny Woode3c6e1a2009-09-20 12:14:21 -03001160 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001161 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001162 &philips_europa_config,
1163 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001164 if (fe0->dvb.frontend) {
1165 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1166 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1167 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1168 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1169 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001170 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001171 break;
1172 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001173 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001174 &philips_tu1216_61_config,
1175 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001176 if (fe0->dvb.frontend) {
1177 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1178 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001179 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001180 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001181 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001182 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1183 &tda827x_cfg_2) < 0)
1184 goto dettach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001185 break;
Michael Krufky0e316ec2009-08-03 16:51:33 -03001186 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
Michael Krufky1bc7f512009-01-19 01:10:49 -03001187 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1188 &hcw_tda10048_config,
1189 &dev->i2c_adap);
1190 if (fe0->dvb.frontend != NULL) {
1191 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1192 &dev->i2c_adap, 0x4b,
1193 &tda829x_no_probe);
1194 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1195 0x60, &dev->i2c_adap,
1196 &hcw_tda18271_config);
1197 }
1198 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001199 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001200 if (configure_tda827x_fe(dev, &philips_tiger_config,
1201 &tda827x_cfg_0) < 0)
1202 goto dettach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001203 break;
1204 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001205 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1206 &tda827x_cfg_1) < 0)
1207 goto dettach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001208 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001209 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001210 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1211 &tda827x_cfg_1) < 0)
1212 goto dettach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001213 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001214 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001215 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1216 &hcw_lgdt3305_config,
1217 &dev->i2c_adap);
1218 if (fe0->dvb.frontend) {
1219 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1220 &dev->i2c_adap, 0x4b,
1221 &tda829x_no_probe);
1222 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1223 0x60, &dev->i2c_adap,
1224 &hcw_tda18271_config);
1225 }
1226 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001227 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001228 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1229 &tda827x_cfg_0) < 0)
1230 goto dettach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001231 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001232 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001233 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1234 &tda827x_cfg_0) < 0)
1235 goto dettach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001236 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001237 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001238 if (!use_frontend) { /* terrestrial */
1239 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1240 &tda827x_cfg_0) < 0)
1241 goto dettach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001242 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001243 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1244 if (fe0->dvb.frontend) {
1245 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001246 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001247 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001248 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001249 }
Steven Toth363c35f2008-10-11 11:05:50 -03001250 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001251 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001252 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001253 goto dettach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001254 }
1255 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001256 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001257 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001258 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001259 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001260 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001261 &ads_tech_duo_config,
1262 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001263 if (fe0->dvb.frontend) {
1264 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001265 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1266 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001267 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001268 ads_tech_duo_config.tuner_address);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001269 goto dettach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001270 }
Mauro Carvalho Chehabbc36ec7462008-06-14 10:44:04 -03001271 } else
1272 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001273 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001274 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001275 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1276 &tda827x_cfg_0) < 0)
1277 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001278 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001279 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001280 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001281 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1282 &tda827x_cfg_0) < 0)
1283 goto dettach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001284 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001285 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001286 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001287 if (fe0->dvb.frontend) {
1288 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001289 u8 dev_id = dev->eedata[2];
1290 u8 data = 0xc4;
1291 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1292
Steven Toth363c35f2008-10-11 11:05:50 -03001293 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001294 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001295 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001296 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001297 goto dettach_frontend;
1298 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001299 if (dev_id != 0x08) {
1300 /* we need to open the i2c gate (we know it exists) */
1301 fe->ops.i2c_gate_ctrl(fe, 1);
1302 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001303 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001304 wprintk("%s: Medion Quadro, no ISL6405 "
1305 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001306 goto dettach_frontend;
1307 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001308 if (dev_id == 0x07) {
1309 /* fire up the 2nd section of the LNB supply since
1310 we can't do this from the other section */
1311 msg.buf = &data;
1312 i2c_transfer(&dev->i2c_adap, &msg, 1);
1313 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001314 fe->ops.i2c_gate_ctrl(fe, 0);
1315 dev->original_set_voltage = fe->ops.set_voltage;
1316 fe->ops.set_voltage = md8800_set_voltage;
1317 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1318 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1319 } else {
1320 fe->ops.set_voltage = md8800_set_voltage2;
1321 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1322 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001323 }
1324 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001325 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001326 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001327 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001328 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001329 if (fe0->dvb.frontend)
1330 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001331 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001332 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001333 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001334 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001335 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001336 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001337 if (fe0->dvb.frontend)
1338 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001339 &dev->i2c_adap, 0x61,
1340 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001341 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001342 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001343 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001344 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001345 if (fe0->dvb.frontend) {
1346 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001347 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001348 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001349 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001350 }
Steven Toth363c35f2008-10-11 11:05:50 -03001351 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001352 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001353 wprintk("%s: No ISL6421 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001354 goto dettach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001355 }
1356 }
1357 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001358 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001359 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001360 &medion_cardbus,
1361 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001362 if (fe0->dvb.frontend) {
1363 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1364 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001365
Steven Toth363c35f2008-10-11 11:05:50 -03001366 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001367 &dev->i2c_adap, medion_cardbus.tuner_address,
1368 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001369 }
1370 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001371 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001372 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001373 &philips_europa_config,
1374 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001375 if (fe0->dvb.frontend) {
1376 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1377 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001378 }
1379 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001380 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001381 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1382 &tda827x_cfg_0) < 0)
1383 goto dettach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001384 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001385 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001386 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1387 &tda827x_cfg_0) < 0)
1388 goto dettach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001389 break;
1390 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001391 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1392 &tda827x_cfg_2) < 0)
1393 goto dettach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001394 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001395 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001396 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1397 &tda827x_cfg_2) < 0)
1398 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001399 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001400 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001401 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1402 &tda827x_cfg_2) < 0)
1403 goto dettach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001404 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001405 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001406 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1407 &tda827x_cfg_0) < 0)
1408 goto dettach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001409 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001410 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001411 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1412 &tda827x_cfg_2_sw42) < 0)
1413 goto dettach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001414 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001415 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001416 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001417 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001418 if (fe0->dvb.frontend) {
1419 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001420 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001421 wprintk("%s: No tda826x found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001422 goto dettach_frontend;
1423 }
Steven Toth363c35f2008-10-11 11:05:50 -03001424 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001425 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001426 wprintk("%s: No lnbp21 found!\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001427 goto dettach_frontend;
1428 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001429 }
1430 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001431 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001432 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1433 &tda827x_cfg_0) < 0)
1434 goto dettach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001435 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001436 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001437 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1438 &tda827x_cfg_2) < 0)
1439 goto dettach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001440 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001441 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001442 dprintk("AverMedia E506R dvb setup\n");
1443 saa7134_set_gpio(dev, 25, 0);
1444 msleep(10);
1445 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001446 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001447 &avermedia_xc3028_mt352_dev,
1448 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001449 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001450 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001451 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001452 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001453 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001454 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001455 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001456 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001457 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001458 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001459 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001460 goto dettach_frontend;
1461 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001462 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001463 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001464 fe->ops.i2c_gate_ctrl(fe, 1);
1465 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001466 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001467 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001468 "found !\n", __func__);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001469 goto dettach_frontend;
1470 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001471 fe->ops.i2c_gate_ctrl(fe, 0);
1472 dev->original_set_voltage = fe->ops.set_voltage;
1473 fe->ops.set_voltage = md8800_set_voltage;
1474 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1475 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1476 }
1477 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001478 case SAA7134_BOARD_AVERMEDIA_M103:
1479 saa7134_set_gpio(dev, 25, 0);
1480 msleep(10);
1481 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001482 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001483 &avermedia_xc3028_mt352_dev,
1484 &dev->i2c_adap);
1485 attach_xc3028 = 1;
1486 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001487 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1488 if (!use_frontend) { /* terrestrial */
1489 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1490 &tda827x_cfg_2) < 0)
1491 goto dettach_frontend;
1492 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001493 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001494 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001495 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001496 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001497 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001498 &dev->i2c_adap, 0) == NULL) {
1499 wprintk("%s: Asus Tiger 3in1, no "
1500 "tda826x found!\n", __func__);
1501 goto dettach_frontend;
1502 }
Steven Toth363c35f2008-10-11 11:05:50 -03001503 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001504 &dev->i2c_adap, 0, 0) == NULL) {
1505 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1506 " found!\n", __func__);
1507 goto dettach_frontend;
1508 }
1509 }
1510 }
1511 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001512 case SAA7134_BOARD_ASUSTeK_TIGER:
1513 if (configure_tda827x_fe(dev, &philips_tiger_config,
1514 &tda827x_cfg_0) < 0)
1515 goto dettach_frontend;
1516 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001517 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001518 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001519 &behold_h6_config,
1520 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001521 if (fe0->dvb.frontend) {
1522 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001523 &dev->i2c_adap, 0x61,
Beholder Intl. Ltd. Dmitry Belimov4786dd62009-08-04 20:07:42 -03001524 TUNER_PHILIPS_FMD1216MEX_MK3);
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001525 }
1526 break;
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -03001527 case SAA7134_BOARD_BEHOLD_X7:
1528 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1529 &behold_x7_config,
1530 &dev->i2c_adap);
1531 if (fe0->dvb.frontend) {
1532 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1533 &dev->i2c_adap, &behold_x7_tunerconfig);
1534 }
1535 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001536 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1537 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1538 /* Zarlink ZL10313 */
1539 fe0->dvb.frontend = dvb_attach(mt312_attach,
1540 &avertv_a700_mt312, &dev->i2c_adap);
1541 if (fe0->dvb.frontend) {
1542 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1543 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1544 wprintk("%s: No zl10036 found!\n",
1545 __func__);
1546 }
1547 }
1548 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001549 case SAA7134_BOARD_VIDEOMATE_S350:
1550 fe0->dvb.frontend = dvb_attach(mt312_attach,
1551 &zl10313_compro_s350_config, &dev->i2c_adap);
1552 if (fe0->dvb.frontend)
1553 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1554 0x60, &dev->i2c_adap) == NULL)
1555 wprintk("%s: No zl10039 found!\n",
1556 __func__);
1557
1558 break;
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001559 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1560 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1561 &zolid_tda10048_config,
1562 &dev->i2c_adap);
1563 if (fe0->dvb.frontend != NULL) {
1564 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1565 &dev->i2c_adap, 0x4b,
1566 &tda829x_no_probe);
1567 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1568 0x60, &dev->i2c_adap,
1569 &zolid_tda18271_config);
1570 }
1571 break;
Michael Krufky184e7692009-06-05 04:28:28 -03001572 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1573 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1574 &dtv1000s_tda10048_config,
1575 &dev->i2c_adap);
1576 if (fe0->dvb.frontend != NULL) {
1577 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1578 &dev->i2c_adap, 0x4b,
1579 &tda829x_no_probe);
1580 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1581 0x60, &dev->i2c_adap,
1582 &dtv1000s_tda18271_config);
1583 }
1584 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001586 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587 break;
1588 }
1589
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001590 if (attach_xc3028) {
1591 struct dvb_frontend *fe;
1592 struct xc2028_config cfg = {
1593 .i2c_adap = &dev->i2c_adap,
1594 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001595 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001596
Steven Toth363c35f2008-10-11 11:05:50 -03001597 if (!fe0->dvb.frontend)
Darron Broadf3f741e2008-11-11 08:50:02 -03001598 goto dettach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001599
Steven Toth363c35f2008-10-11 11:05:50 -03001600 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001601 if (!fe) {
1602 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1603 dev->name);
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001604 goto dettach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001605 }
1606 }
1607
Steven Toth363c35f2008-10-11 11:05:50 -03001608 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001609 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Darron Broadf3f741e2008-11-11 08:50:02 -03001610 goto dettach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001611 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001612 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001613 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001614
1615 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001616 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001617 &dev->pci->dev, adapter_nr, 0, NULL);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001618
1619 /* this sequence is necessary to make the tda1004x load its firmware
1620 * and to enter analog mode of hybrid boards
1621 */
1622 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001623 if (fe0->dvb.frontend->ops.init)
1624 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1625 if (fe0->dvb.frontend->ops.sleep)
1626 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1627 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1628 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001629 }
1630 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001631
1632dettach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001633 videobuf_dvb_dealloc_frontends(&dev->frontends);
1634 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001635}
1636
1637static int dvb_fini(struct saa7134_dev *dev)
1638{
Steven Toth363c35f2008-10-11 11:05:50 -03001639 struct videobuf_dvb_frontend *fe0;
1640
1641 /* Get the first frontend */
1642 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1643 if (!fe0)
1644 return -EINVAL;
1645
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001646 /* FIXME: I suspect that this code is bogus, since the entry for
1647 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1648 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1649 */
1650 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1651 struct v4l2_priv_tun_config tda9887_cfg;
1652 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001654 tda9887_cfg.tuner = TUNER_TDA9887;
1655 tda9887_cfg.priv = &on;
1656
Linus Torvalds1da177e2005-04-16 15:20:36 -07001657 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001658 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001659 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001660 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001661 /* turn off the 2nd lnb supply */
1662 u8 data = 0x80;
1663 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1664 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001665 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001666 if (fe->ops.i2c_gate_ctrl) {
1667 fe->ops.i2c_gate_ctrl(fe, 1);
1668 i2c_transfer(&dev->i2c_adap, &msg, 1);
1669 fe->ops.i2c_gate_ctrl(fe, 0);
1670 }
1671 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001672 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001673 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674 return 0;
1675}
1676
1677static struct saa7134_mpeg_ops dvb_ops = {
1678 .type = SAA7134_MPEG_DVB,
1679 .init = dvb_init,
1680 .fini = dvb_fini,
1681};
1682
1683static int __init dvb_register(void)
1684{
1685 return saa7134_ts_register(&dvb_ops);
1686}
1687
1688static void __exit dvb_unregister(void)
1689{
1690 saa7134_ts_unregister(&dvb_ops);
1691}
1692
1693module_init(dvb_register);
1694module_exit(dvb_unregister);
1695
1696/* ------------------------------------------------------------------ */
1697/*
1698 * Local variables:
1699 * c-basic-offset: 8
1700 * End:
1701 */