blob: 27915e501db9d3bbcdb3944a4bf8237ef9254ba0 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/delay.h>
28#include <linux/kthread.h>
29#include <linux/suspend.h>
30
31#include "saa7134-reg.h"
32#include "saa7134.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020033#include <media/v4l2-common.h>
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -020034#include "dvb-pll.h"
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -030035#include <dvb_frontend.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030037#include "mt352.h"
38#include "mt352_priv.h" /* FIXME */
39#include "tda1004x.h"
40#include "nxt200x.h"
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -030041#include "tuner-xc2028.h"
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -030042#include "xc5000.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 Krufkycb89cd32008-04-22 14:46:16 -030050#include "tuner-simple.h"
Michael Krufky1bc7f512009-01-19 01:10:49 -030051#include "tda10048.h"
Michael Krufky3abdedd2009-01-19 01:10:49 -030052#include "tda18271.h"
53#include "lgdt3305.h"
54#include "tda8290.h"
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -030055#include "mb86a20s.h"
Timothy Leece027042011-03-25 15:00:33 -030056#include "lgs8gxx.h"
Michael Krufky8ce47da2007-04-27 12:31:14 -030057
Dmitri Belimov47aeba52008-12-23 03:53:03 -030058#include "zl10353.h"
Carlos Corbachodbe87402011-06-25 10:24:28 -030059#include "qt1010.h"
Dmitri Belimov47aeba52008-12-23 03:53:03 -030060
Matthias Schwarzott04574182009-02-24 12:35:16 -030061#include "zl10036.h"
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -030062#include "zl10039.h"
Matthias Schwarzott04574182009-02-24 12:35:16 -030063#include "mt312.h"
Kyle Strickland25fa2072012-02-18 02:24:53 -030064#include "s5h1411.h"
Matthias Schwarzott04574182009-02-24 12:35:16 -030065
Linus Torvalds1da177e2005-04-16 15:20:36 -070066MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
67MODULE_LICENSE("GPL");
68
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030069static unsigned int antenna_pwr;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -070070
Linus Torvalds1da177e2005-04-16 15:20:36 -070071module_param(antenna_pwr, int, 0444);
72MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
73
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030074static int use_frontend;
Stephan Berberigb331daa2006-12-20 09:37:05 -030075module_param(use_frontend, int, 0644);
76MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
Nico Sabbi1f683cd2006-11-15 22:06:56 -030077
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030078static int debug;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030079module_param(debug, int, 0644);
80MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
81
Janne Grunau78e92002008-04-09 19:13:13 -030082DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
83
Trent Piephocf3c34c2007-03-07 18:19:48 -030084#define dprintk(fmt, arg...) do { if (debug) \
85 printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
86
87/* Print a warning */
88#define wprintk(fmt, arg...) \
89 printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -030090
91/* ------------------------------------------------------------------
92 * mt352 based DVB-T cards
93 */
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
96{
97 u32 ok;
98
99 if (!on) {
100 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
101 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
102 return 0;
103 }
104
105 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 26));
106 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
107 udelay(10);
108
109 saa_setl(SAA7134_GPIO_GPMODE0 >> 2, (1 << 28));
110 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
111 udelay(10);
112 saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
113 udelay(10);
114 ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300115 dprintk("%s %s\n", __func__, ok ? "on" : "off");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
117 if (!ok)
118 saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
119 return ok;
120}
121
122static int mt352_pinnacle_init(struct dvb_frontend* fe)
123{
124 static u8 clock_config [] = { CLOCK_CTL, 0x3d, 0x28 };
125 static u8 reset [] = { RESET, 0x80 };
126 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
127 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
128 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
129 static u8 fsm_ctl_cfg[] = { 0x7b, 0x04 };
130 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x0f };
131 static u8 scan_ctl_cfg [] = { SCAN_CTL, 0x0d };
132 static u8 irq_cfg [] = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
133 struct saa7134_dev *dev= fe->dvb->priv;
134
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -0300135 dprintk("%s called\n", __func__);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137 mt352_write(fe, clock_config, sizeof(clock_config));
138 udelay(200);
139 mt352_write(fe, reset, sizeof(reset));
140 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
141 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
142 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
143 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
144
145 mt352_write(fe, fsm_ctl_cfg, sizeof(fsm_ctl_cfg));
146 mt352_write(fe, scan_ctl_cfg, sizeof(scan_ctl_cfg));
147 mt352_write(fe, irq_cfg, sizeof(irq_cfg));
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300148
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149 return 0;
150}
151
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200152static int mt352_aver777_init(struct dvb_frontend* fe)
153{
154 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
155 static u8 reset [] = { RESET, 0x80 };
156 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
157 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0xa0 };
158 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
159
160 mt352_write(fe, clock_config, sizeof(clock_config));
161 udelay(200);
162 mt352_write(fe, reset, sizeof(reset));
163 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
164 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
165 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
166
167 return 0;
168}
169
Tim Farrington6e501a32008-06-15 13:33:42 -0300170static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300171{
Tim Farrington6e501a32008-06-15 13:33:42 -0300172 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x2d };
173 static u8 reset [] = { RESET, 0x80 };
174 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
175 static u8 agc_cfg [] = { AGC_TARGET, 0xe };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300176 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
177
178 mt352_write(fe, clock_config, sizeof(clock_config));
179 udelay(200);
180 mt352_write(fe, reset, sizeof(reset));
181 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
182 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
183 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -0300184 return 0;
185}
186
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300187static int mt352_pinnacle_tuner_set_params(struct dvb_frontend *fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188{
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300189 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300190 u8 off[] = { 0x00, 0xf1};
191 u8 on[] = { 0x00, 0x71};
192 struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 struct saa7134_dev *dev = fe->dvb->priv;
195 struct v4l2_frequency f;
196
197 /* set frequency (mt2050) */
198 f.tuner = 0;
199 f.type = V4L2_TUNER_DIGITAL_TV;
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300200 f.frequency = c->frequency / 1000 * 16 / 1000;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300201 if (fe->ops.i2c_gate_ctrl)
202 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300203 i2c_transfer(&dev->i2c_adap, &msg, 1);
Hans Verkuilfac69862009-01-17 12:17:14 -0300204 saa_call_all(dev, tuner, s_frequency, &f);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300205 msg.buf = on;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300206 if (fe->ops.i2c_gate_ctrl)
207 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmanndf8cf702006-03-03 12:09:26 -0300208 i2c_transfer(&dev->i2c_adap, &msg, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210 pinnacle_antenna_pwr(dev, antenna_pwr);
211
212 /* mt352 setup */
Andrew de Quincey0463f122006-05-16 17:22:02 -0300213 return mt352_pinnacle_init(fe);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214}
215
216static struct mt352_config pinnacle_300i = {
217 .demod_address = 0x3c >> 1,
218 .adc_clock = 20333,
219 .if2 = 36150,
220 .no_tuner = 1,
221 .demod_init = mt352_pinnacle_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222};
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200223
224static struct mt352_config avermedia_777 = {
225 .demod_address = 0xf,
226 .demod_init = mt352_aver777_init,
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -0200227};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
Tim Farrington6e501a32008-06-15 13:33:42 -0300229static struct mt352_config avermedia_xc3028_mt352_dev = {
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300230 .demod_address = (0x1e >> 1),
231 .no_tuner = 1,
Tim Farrington6e501a32008-06-15 13:33:42 -0300232 .demod_init = mt352_avermedia_xc3028_init,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -0300233};
234
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300235static struct tda18271_std_map mb86a20s_tda18271_std_map = {
236 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
237 .if_lvl = 7, .rfagc_top = 0x37, },
238};
239
240static struct tda18271_config kworld_tda18271_config = {
241 .std_map = &mb86a20s_tda18271_std_map,
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -0300242 .gate = TDA18271_GATE_DIGITAL,
Mauro Carvalho Chehabecb71d22011-01-14 12:03:03 -0300243 .config = 3, /* Use tuner callback for AGC */
244
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -0300245};
246
247static const struct mb86a20s_config kworld_mb86a20s_config = {
248 .demod_address = 0x10,
249};
250
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -0300251static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
252{
253 struct saa7134_dev *dev = fe->dvb->priv;
254
255 unsigned char initmsg[] = {0x45, 0x97};
256 unsigned char msg_enable[] = {0x45, 0xc1};
257 unsigned char msg_disable[] = {0x45, 0x81};
258 struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
259
260 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
261 wprintk("could not access the I2C gate\n");
262 return -EIO;
263 }
264 if (enable)
265 msg.buf = msg_enable;
266 else
267 msg.buf = msg_disable;
268 if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
269 wprintk("could not access the I2C gate\n");
270 return -EIO;
271 }
272 msleep(20);
273 return 0;
274}
275
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300276/* ==================================================================
277 * tda1004x based DVB-T cards, helper functions
278 */
279
280static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
281 const struct firmware **fw, char *name)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700282{
283 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300284 return request_firmware(fw, name, &dev->pci->dev);
285}
286
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300287/* ------------------------------------------------------------------
288 * these tuners are tu1216, td1316(a)
289 */
290
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300291static int philips_tda6651_pll_set(struct dvb_frontend *fe)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300292{
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300293 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300294 struct saa7134_dev *dev = fe->dvb->priv;
295 struct tda1004x_state *state = fe->demodulator_priv;
296 u8 addr = state->config->tuner_address;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700297 u8 tuner_buf[4];
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800298 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700299 sizeof(tuner_buf) };
300 int tuner_frequency = 0;
301 u8 band, cp, filter;
302
303 /* determine charge pump */
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300304 tuner_frequency = c->frequency + 36166000;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700305 if (tuner_frequency < 87000000)
306 return -EINVAL;
307 else if (tuner_frequency < 130000000)
308 cp = 3;
309 else if (tuner_frequency < 160000000)
310 cp = 5;
311 else if (tuner_frequency < 200000000)
312 cp = 6;
313 else if (tuner_frequency < 290000000)
314 cp = 3;
315 else if (tuner_frequency < 420000000)
316 cp = 5;
317 else if (tuner_frequency < 480000000)
318 cp = 6;
319 else if (tuner_frequency < 620000000)
320 cp = 3;
321 else if (tuner_frequency < 830000000)
322 cp = 5;
323 else if (tuner_frequency < 895000000)
324 cp = 7;
325 else
326 return -EINVAL;
327
328 /* determine band */
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300329 if (c->frequency < 49000000)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700330 return -EINVAL;
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300331 else if (c->frequency < 161000000)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700332 band = 1;
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300333 else if (c->frequency < 444000000)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700334 band = 2;
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300335 else if (c->frequency < 861000000)
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700336 band = 4;
337 else
338 return -EINVAL;
339
340 /* setup PLL filter */
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300341 switch (c->bandwidth_hz) {
342 case 6000000:
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700343 filter = 0;
344 break;
345
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300346 case 7000000:
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700347 filter = 0;
348 break;
349
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300350 case 8000000:
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700351 filter = 1;
352 break;
353
354 default:
355 return -EINVAL;
356 }
357
358 /* calculate divisor
359 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
360 */
Mauro Carvalho Chehabb09cf612011-12-23 12:25:04 -0300361 tuner_frequency = (((c->frequency / 1000) * 6) + 217496) / 1000;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700362
363 /* setup tuner buffer */
364 tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
365 tuner_buf[1] = tuner_frequency & 0xff;
366 tuner_buf[2] = 0xca;
367 tuner_buf[3] = (cp << 5) | (filter << 3) | band;
368
Patrick Boettcherdea74862006-05-14 05:01:31 -0300369 if (fe->ops.i2c_gate_ctrl)
370 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300371 if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300372 wprintk("could not write to tuner at addr: 0x%02x\n",
373 addr << 1);
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700374 return -EIO;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300375 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700376 msleep(1);
377 return 0;
378}
379
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300380static int philips_tu1216_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 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
386 struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
387
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, &tuner_msg, 1) != 1)
392 return -EIO;
393 msleep(1);
394
395 return 0;
396}
397
398/* ------------------------------------------------------------------ */
399
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800400static struct tda1004x_config philips_tu1216_60_config = {
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700401 .demod_address = 0x8,
402 .invert = 1,
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800403 .invert_oclk = 0,
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700404 .xtal_freq = TDA10046_XTAL_4M,
405 .agc_config = TDA10046_AGC_DEFAULT,
406 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300407 .tuner_address = 0x60,
408 .request_firmware = philips_tda1004x_request_firmware
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409};
410
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800411static struct tda1004x_config philips_tu1216_61_config = {
412
413 .demod_address = 0x8,
414 .invert = 1,
415 .invert_oclk = 0,
416 .xtal_freq = TDA10046_XTAL_4M,
417 .agc_config = TDA10046_AGC_DEFAULT,
418 .if_freq = TDA10046_FREQ_3617,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300419 .tuner_address = 0x61,
420 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800421};
422
423/* ------------------------------------------------------------------ */
424
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300425static int philips_td1316_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800426{
427 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300428 struct tda1004x_state *state = fe->demodulator_priv;
429 u8 addr = state->config->tuner_address;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800430 static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300431 struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800432
433 /* setup PLL configuration */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300434 if (fe->ops.i2c_gate_ctrl)
435 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800436 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
437 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800438 return 0;
439}
440
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300441static int philips_td1316_tuner_set_params(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800442{
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300443 return philips_tda6651_pll_set(fe);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800444}
445
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300446static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
447{
448 struct saa7134_dev *dev = fe->dvb->priv;
449 struct tda1004x_state *state = fe->demodulator_priv;
450 u8 addr = state->config->tuner_address;
451 static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
452 struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
453
454 /* switch the tuner to analog mode */
455 if (fe->ops.i2c_gate_ctrl)
456 fe->ops.i2c_gate_ctrl(fe, 1);
457 if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
458 return -EIO;
459 return 0;
460}
461
462/* ------------------------------------------------------------------ */
463
Hartmut Hackmanncbb94522006-10-30 20:00:16 -0300464static int philips_europa_tuner_init(struct dvb_frontend *fe)
465{
466 struct saa7134_dev *dev = fe->dvb->priv;
467 static u8 msg[] = { 0x00, 0x40};
468 struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
469
470
471 if (philips_td1316_tuner_init(fe))
472 return -EIO;
473 msleep(1);
474 if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
475 return -EIO;
476
477 return 0;
478}
479
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300480static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800481{
482 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800483
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300484 static u8 msg[] = { 0x00, 0x14 };
485 struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
486
487 if (philips_td1316_tuner_sleep(fe))
488 return -EIO;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800489
490 /* switch the board to analog mode */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300491 if (fe->ops.i2c_gate_ctrl)
492 fe->ops.i2c_gate_ctrl(fe, 1);
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800493 i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300494 return 0;
495}
496
497static int philips_europa_demod_sleep(struct dvb_frontend *fe)
498{
499 struct saa7134_dev *dev = fe->dvb->priv;
500
501 if (dev->original_demod_sleep)
502 dev->original_demod_sleep(fe);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300503 fe->ops.i2c_gate_ctrl(fe, 1);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300504 return 0;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800505}
506
507static struct tda1004x_config philips_europa_config = {
508
509 .demod_address = 0x8,
510 .invert = 0,
511 .invert_oclk = 0,
512 .xtal_freq = TDA10046_XTAL_4M,
513 .agc_config = TDA10046_AGC_IFO_AUTO_POS,
514 .if_freq = TDA10046_FREQ_052,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300515 .tuner_address = 0x61,
516 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -0800517};
518
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700519static struct tda1004x_config medion_cardbus = {
520 .demod_address = 0x08,
521 .invert = 1,
522 .invert_oclk = 0,
523 .xtal_freq = TDA10046_XTAL_16M,
524 .agc_config = TDA10046_AGC_IFO_AUTO_NEG,
525 .if_freq = TDA10046_FREQ_3613,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300526 .tuner_address = 0x61,
527 .request_firmware = philips_tda1004x_request_firmware
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -0700528};
529
Vadim Catana128fe952010-05-29 12:49:16 -0300530static struct tda1004x_config technotrend_budget_t3000_config = {
531 .demod_address = 0x8,
532 .invert = 1,
533 .invert_oclk = 0,
534 .xtal_freq = TDA10046_XTAL_4M,
535 .agc_config = TDA10046_AGC_DEFAULT,
536 .if_freq = TDA10046_FREQ_3617,
537 .tuner_address = 0x63,
538 .request_firmware = philips_tda1004x_request_firmware
539};
540
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300541/* ------------------------------------------------------------------
542 * tda 1004x based cards with philips silicon tuner
543 */
544
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300545static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
546{
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300547 struct tda1004x_state *state = fe->demodulator_priv;
548
549 u8 addr = state->config->i2c_gate;
550 static u8 tda8290_close[] = { 0x21, 0xc0};
551 static u8 tda8290_open[] = { 0x21, 0x80};
552 struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
553 if (enable) {
554 tda8290_msg.buf = tda8290_close;
555 } else {
556 tda8290_msg.buf = tda8290_open;
557 }
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300558 if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
Trent Piephocf3c34c2007-03-07 18:19:48 -0300559 struct saa7134_dev *dev = fe->dvb->priv;
560 wprintk("could not access tda8290 I2C gate\n");
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300561 return -EIO;
562 }
563 msleep(20);
564 return 0;
565}
566
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300567static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300568{
569 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300570 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300571
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300572 switch (state->config->antenna_switch) {
573 case 0: break;
574 case 1: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
575 saa7134_set_gpio(dev, 21, 0);
576 break;
577 case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
578 saa7134_set_gpio(dev, 21, 1);
579 break;
580 }
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300581 return 0;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800582}
583
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300584static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
585{
586 struct saa7134_dev *dev = fe->dvb->priv;
587 struct tda1004x_state *state = fe->demodulator_priv;
Michael Krufky8ce47da2007-04-27 12:31:14 -0300588
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300589 switch (state->config->antenna_switch) {
590 case 0: break;
591 case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)\n");
592 saa7134_set_gpio(dev, 21, 1);
593 break;
594 case 2: dprintk("setting GPIO21 to 0 (TV antenna?)\n");
595 saa7134_set_gpio(dev, 21, 0);
596 break;
597 }
598 return 0;
599}
600
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300601static int configure_tda827x_fe(struct saa7134_dev *dev,
602 struct tda1004x_config *cdec_conf,
603 struct tda827x_config *tuner_conf)
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300604{
Steven Toth363c35f2008-10-11 11:05:50 -0300605 struct videobuf_dvb_frontend *fe0;
606
Darron Broad92abe9e2008-10-11 11:18:53 -0300607 /* Get the first frontend */
608 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300609
Peter Senna Tschudin37e310e2012-10-30 11:09:41 -0300610 if (!fe0)
611 return -EINVAL;
612
Steven Toth363c35f2008-10-11 11:05:50 -0300613 fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
614 if (fe0->dvb.frontend) {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300615 if (cdec_conf->i2c_gate)
Steven Toth363c35f2008-10-11 11:05:50 -0300616 fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
617 if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300618 cdec_conf->tuner_address,
619 &dev->i2c_adap, tuner_conf))
620 return 0;
621
622 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300623 cdec_conf->tuner_address);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300624 }
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -0300625 return -EINVAL;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300626}
627
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800628/* ------------------------------------------------------------------ */
Edgar Simo261f5082007-08-20 14:06:00 -0300629
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300630static struct tda827x_config tda827x_cfg_0 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300631 .init = philips_tda827x_tuner_init,
632 .sleep = philips_tda827x_tuner_sleep,
633 .config = 0,
634 .switch_addr = 0
635};
636
637static struct tda827x_config tda827x_cfg_1 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300638 .init = philips_tda827x_tuner_init,
639 .sleep = philips_tda827x_tuner_sleep,
640 .config = 1,
641 .switch_addr = 0x4b
642};
643
644static struct tda827x_config tda827x_cfg_2 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300645 .init = philips_tda827x_tuner_init,
646 .sleep = philips_tda827x_tuner_sleep,
647 .config = 2,
648 .switch_addr = 0x4b
649};
650
651static struct tda827x_config tda827x_cfg_2_sw42 = {
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300652 .init = philips_tda827x_tuner_init,
653 .sleep = philips_tda827x_tuner_sleep,
654 .config = 2,
655 .switch_addr = 0x42
656};
657
658/* ------------------------------------------------------------------ */
659
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300660static struct tda1004x_config tda827x_lifeview_config = {
661 .demod_address = 0x08,
662 .invert = 1,
663 .invert_oclk = 0,
664 .xtal_freq = TDA10046_XTAL_16M,
665 .agc_config = TDA10046_AGC_TDA827X,
666 .gpio_config = TDA10046_GP11_I,
667 .if_freq = TDA10046_FREQ_045,
668 .tuner_address = 0x60,
669 .request_firmware = philips_tda1004x_request_firmware
670};
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800671
672static struct tda1004x_config philips_tiger_config = {
673 .demod_address = 0x08,
674 .invert = 1,
675 .invert_oclk = 0,
676 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300677 .agc_config = TDA10046_AGC_TDA827X,
678 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300679 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300680 .i2c_gate = 0x4b,
681 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300682 .antenna_switch= 1,
683 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300684};
Hartmut Hackmann550a9a52006-11-15 21:31:54 -0300685
686static struct tda1004x_config cinergy_ht_config = {
687 .demod_address = 0x08,
688 .invert = 1,
689 .invert_oclk = 0,
690 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300691 .agc_config = TDA10046_AGC_TDA827X,
692 .gpio_config = TDA10046_GP01_I,
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800693 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300694 .i2c_gate = 0x4b,
695 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300696 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann90e9df72005-11-08 21:38:42 -0800697};
698
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300699static struct tda1004x_config cinergy_ht_pci_config = {
700 .demod_address = 0x08,
701 .invert = 1,
702 .invert_oclk = 0,
703 .xtal_freq = TDA10046_XTAL_16M,
704 .agc_config = TDA10046_AGC_TDA827X,
705 .gpio_config = TDA10046_GP01_I,
706 .if_freq = TDA10046_FREQ_045,
707 .i2c_gate = 0x4b,
708 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300709 .request_firmware = philips_tda1004x_request_firmware
710};
711
712static struct tda1004x_config philips_tiger_s_config = {
713 .demod_address = 0x08,
714 .invert = 1,
715 .invert_oclk = 0,
716 .xtal_freq = TDA10046_XTAL_16M,
717 .agc_config = TDA10046_AGC_TDA827X,
718 .gpio_config = TDA10046_GP01_I,
719 .if_freq = TDA10046_FREQ_045,
720 .i2c_gate = 0x4b,
721 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300722 .antenna_switch= 1,
723 .request_firmware = philips_tda1004x_request_firmware
724};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200725
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300726static struct tda1004x_config pinnacle_pctv_310i_config = {
727 .demod_address = 0x08,
728 .invert = 1,
729 .invert_oclk = 0,
730 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300731 .agc_config = TDA10046_AGC_TDA827X,
732 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300733 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300734 .i2c_gate = 0x4b,
735 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300736 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -0300737};
738
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300739static struct tda1004x_config hauppauge_hvr_1110_config = {
740 .demod_address = 0x08,
741 .invert = 1,
742 .invert_oclk = 0,
743 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300744 .agc_config = TDA10046_AGC_TDA827X,
745 .gpio_config = TDA10046_GP11_I,
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300746 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300747 .i2c_gate = 0x4b,
748 .tuner_address = 0x61,
749 .request_firmware = philips_tda1004x_request_firmware
Thomas Gentyc6e53da2006-11-05 14:17:30 -0300750};
751
Hartmut Hackmann83646812006-10-12 20:38:51 -0300752static struct tda1004x_config asus_p7131_dual_config = {
753 .demod_address = 0x08,
754 .invert = 1,
755 .invert_oclk = 0,
756 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300757 .agc_config = TDA10046_AGC_TDA827X,
758 .gpio_config = TDA10046_GP11_I,
Hartmut Hackmann83646812006-10-12 20:38:51 -0300759 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300760 .i2c_gate = 0x4b,
761 .tuner_address = 0x61,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300762 .antenna_switch= 2,
763 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmann83646812006-10-12 20:38:51 -0300764};
765
Nico Sabbi420f32f2006-03-03 12:11:28 -0300766static struct tda1004x_config lifeview_trio_config = {
767 .demod_address = 0x09,
768 .invert = 1,
769 .invert_oclk = 0,
770 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300771 .agc_config = TDA10046_AGC_TDA827X,
772 .gpio_config = TDA10046_GP00_I,
Nico Sabbi420f32f2006-03-03 12:11:28 -0300773 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300774 .tuner_address = 0x60,
775 .request_firmware = philips_tda1004x_request_firmware
Nico Sabbi420f32f2006-03-03 12:11:28 -0300776};
777
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300778static struct tda1004x_config tevion_dvbt220rf_config = {
779 .demod_address = 0x08,
780 .invert = 1,
781 .invert_oclk = 0,
782 .xtal_freq = TDA10046_XTAL_16M,
783 .agc_config = TDA10046_AGC_TDA827X,
784 .gpio_config = TDA10046_GP11_I,
785 .if_freq = TDA10046_FREQ_045,
786 .tuner_address = 0x60,
787 .request_firmware = philips_tda1004x_request_firmware
788};
Nico Sabbi420f32f2006-03-03 12:11:28 -0300789
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300790static struct tda1004x_config md8800_dvbt_config = {
791 .demod_address = 0x08,
792 .invert = 1,
793 .invert_oclk = 0,
794 .xtal_freq = TDA10046_XTAL_16M,
795 .agc_config = TDA10046_AGC_TDA827X,
796 .gpio_config = TDA10046_GP01_I,
797 .if_freq = TDA10046_FREQ_045,
798 .i2c_gate = 0x4b,
799 .tuner_address = 0x60,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300800 .request_firmware = philips_tda1004x_request_firmware
801};
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200802
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300803static struct tda1004x_config asus_p7131_4871_config = {
804 .demod_address = 0x08,
805 .invert = 1,
806 .invert_oclk = 0,
807 .xtal_freq = TDA10046_XTAL_16M,
808 .agc_config = TDA10046_AGC_TDA827X,
809 .gpio_config = TDA10046_GP01_I,
810 .if_freq = TDA10046_FREQ_045,
811 .i2c_gate = 0x4b,
812 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300813 .antenna_switch= 2,
814 .request_firmware = philips_tda1004x_request_firmware
815};
816
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -0300817static struct tda1004x_config asus_p7131_hybrid_lna_config = {
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300818 .demod_address = 0x08,
819 .invert = 1,
820 .invert_oclk = 0,
821 .xtal_freq = TDA10046_XTAL_16M,
822 .agc_config = TDA10046_AGC_TDA827X,
823 .gpio_config = TDA10046_GP11_I,
824 .if_freq = TDA10046_FREQ_045,
825 .i2c_gate = 0x4b,
826 .tuner_address = 0x61,
Hartmut Hackmanne06cea42007-03-13 20:58:29 -0300827 .antenna_switch= 2,
828 .request_firmware = philips_tda1004x_request_firmware
829};
Edgar Simo261f5082007-08-20 14:06:00 -0300830
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300831static struct tda1004x_config kworld_dvb_t_210_config = {
832 .demod_address = 0x08,
833 .invert = 1,
834 .invert_oclk = 0,
835 .xtal_freq = TDA10046_XTAL_16M,
836 .agc_config = TDA10046_AGC_TDA827X,
837 .gpio_config = TDA10046_GP11_I,
838 .if_freq = TDA10046_FREQ_045,
839 .i2c_gate = 0x4b,
840 .tuner_address = 0x61,
Simon Farnsworthb39423a2007-05-01 10:01:20 -0300841 .antenna_switch= 1,
842 .request_firmware = philips_tda1004x_request_firmware
843};
Edgar Simo261f5082007-08-20 14:06:00 -0300844
Edgar Simod90d9f52007-08-20 14:14:50 -0300845static struct tda1004x_config avermedia_super_007_config = {
846 .demod_address = 0x08,
847 .invert = 1,
848 .invert_oclk = 0,
849 .xtal_freq = TDA10046_XTAL_16M,
850 .agc_config = TDA10046_AGC_TDA827X,
851 .gpio_config = TDA10046_GP01_I,
852 .if_freq = TDA10046_FREQ_045,
853 .i2c_gate = 0x4b,
854 .tuner_address = 0x60,
Edgar Simod90d9f52007-08-20 14:14:50 -0300855 .antenna_switch= 1,
856 .request_firmware = philips_tda1004x_request_firmware
857};
858
Hermann Pitton4ba24372008-01-20 19:27:51 -0300859static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
860 .demod_address = 0x08,
861 .invert = 1,
862 .invert_oclk = 0,
863 .xtal_freq = TDA10046_XTAL_16M,
864 .agc_config = TDA10046_AGC_TDA827X,
865 .gpio_config = TDA10046_GP01_I,
866 .if_freq = TDA10046_FREQ_045,
867 .i2c_gate = 0x42,
868 .tuner_address = 0x61,
Hermann Pitton4ba24372008-01-20 19:27:51 -0300869 .antenna_switch = 1,
870 .request_firmware = philips_tda1004x_request_firmware
871};
872
hermann pitton301e9d62008-09-14 17:49:14 -0300873static struct tda1004x_config asus_tiger_3in1_config = {
874 .demod_address = 0x0b,
875 .invert = 1,
876 .invert_oclk = 0,
877 .xtal_freq = TDA10046_XTAL_16M,
878 .agc_config = TDA10046_AGC_TDA827X,
879 .gpio_config = TDA10046_GP11_I,
880 .if_freq = TDA10046_FREQ_045,
881 .i2c_gate = 0x4b,
882 .tuner_address = 0x61,
883 .antenna_switch = 1,
884 .request_firmware = philips_tda1004x_request_firmware
885};
886
remi schwartz75c7dbc2012-05-19 06:11:47 -0300887static struct tda1004x_config asus_ps3_100_config = {
888 .demod_address = 0x0b,
889 .invert = 1,
890 .invert_oclk = 0,
891 .xtal_freq = TDA10046_XTAL_16M,
892 .agc_config = TDA10046_AGC_TDA827X,
893 .gpio_config = TDA10046_GP11_I,
894 .if_freq = TDA10046_FREQ_045,
895 .i2c_gate = 0x4b,
896 .tuner_address = 0x61,
897 .antenna_switch = 1,
898 .request_firmware = philips_tda1004x_request_firmware
899};
900
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300901/* ------------------------------------------------------------------
902 * special case: this card uses saa713x GPIO22 for the mode switch
903 */
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200904
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300905static int ads_duo_tuner_init(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200906{
907 struct saa7134_dev *dev = fe->dvb->priv;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300908 philips_tda827x_tuner_init(fe);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200909 /* route TDA8275a AGC input to the channel decoder */
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300910 saa7134_set_gpio(dev, 22, 1);
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200911 return 0;
912}
913
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300914static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200915{
916 struct saa7134_dev *dev = fe->dvb->priv;
917 /* route TDA8275a AGC input to the analog IF chip*/
Hartmut Hackmann06be3032007-04-27 12:31:15 -0300918 saa7134_set_gpio(dev, 22, 0);
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300919 philips_tda827x_tuner_sleep(fe);
Andrew de Quinceya79ddae2006-04-18 17:47:11 -0300920 return 0;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200921}
922
Michael Krufky8ce47da2007-04-27 12:31:14 -0300923static struct tda827x_config ads_duo_cfg = {
Michael Krufky8ce47da2007-04-27 12:31:14 -0300924 .init = ads_duo_tuner_init,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -0300925 .sleep = ads_duo_tuner_sleep,
926 .config = 0
Michael Krufky8ce47da2007-04-27 12:31:14 -0300927};
928
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200929static struct tda1004x_config ads_tech_duo_config = {
930 .demod_address = 0x08,
931 .invert = 1,
932 .invert_oclk = 0,
933 .xtal_freq = TDA10046_XTAL_16M,
Hartmut Hackmann1bb0e862007-04-27 12:31:10 -0300934 .agc_config = TDA10046_AGC_TDA827X,
935 .gpio_config = TDA10046_GP00_I,
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200936 .if_freq = TDA10046_FREQ_045,
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300937 .tuner_address = 0x61,
938 .request_firmware = philips_tda1004x_request_firmware
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -0200939};
940
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300941static struct zl10353_config behold_h6_config = {
942 .demod_address = 0x1e>>1,
943 .no_tuner = 1,
944 .parallel_ts = 1,
Antti Palosaari5f77af92009-03-10 13:06:40 -0300945 .disable_i2c_gate_ctrl = 1,
Dmitri Belimov47aeba52008-12-23 03:53:03 -0300946};
947
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300948static struct xc5000_config behold_x7_tunerconfig = {
949 .i2c_address = 0xc2>>1,
950 .if_khz = 4560,
Devin Heitmueller2a0d0562009-09-30 23:04:39 -0300951 .radio_input = XC5000_RADIO_FM1,
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -0300952};
953
954static struct zl10353_config behold_x7_config = {
955 .demod_address = 0x1e>>1,
956 .if2 = 45600,
957 .no_tuner = 1,
958 .parallel_ts = 1,
959 .disable_i2c_gate_ctrl = 1,
960};
961
Carlos Corbachodbe87402011-06-25 10:24:28 -0300962static struct zl10353_config videomate_t750_zl10353_config = {
963 .demod_address = 0x0f,
964 .no_tuner = 1,
965 .parallel_ts = 1,
966 .disable_i2c_gate_ctrl = 1,
967};
968
969static struct qt1010_config videomate_t750_qt1010_config = {
970 .i2c_address = 0x62
971};
972
973
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -0300974/* ==================================================================
975 * tda10086 based DVB-S cards, helper functions
976 */
Hartmut Hackmann5eda2272006-08-07 14:03:32 -0300977
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300978static struct tda10086_config flydvbs = {
979 .demod_address = 0x0e,
980 .invert = 0,
Hartmut Hackmannea75baf2008-02-09 23:54:24 -0300981 .diseqc_tone = 0,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -0300982 .xtal_freq = TDA10086_XTAL_16M,
983};
984
985static struct tda10086_config sd1878_4m = {
986 .demod_address = 0x0e,
987 .invert = 0,
988 .diseqc_tone = 0,
989 .xtal_freq = TDA10086_XTAL_4M,
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -0300990};
991
Hartmut Hackmann1b1cee32008-04-22 14:42:12 -0300992/* ------------------------------------------------------------------
993 * special case: lnb supply is connected to the gated i2c
994 */
995
996static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
997{
998 int res = -EIO;
999 struct saa7134_dev *dev = fe->dvb->priv;
1000 if (fe->ops.i2c_gate_ctrl) {
1001 fe->ops.i2c_gate_ctrl(fe, 1);
1002 if (dev->original_set_voltage)
1003 res = dev->original_set_voltage(fe, voltage);
1004 fe->ops.i2c_gate_ctrl(fe, 0);
1005 }
1006 return res;
1007};
1008
1009static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
1010{
1011 int res = -EIO;
1012 struct saa7134_dev *dev = fe->dvb->priv;
1013 if (fe->ops.i2c_gate_ctrl) {
1014 fe->ops.i2c_gate_ctrl(fe, 1);
1015 if (dev->original_set_high_voltage)
1016 res = dev->original_set_high_voltage(fe, arg);
1017 fe->ops.i2c_gate_ctrl(fe, 0);
1018 }
1019 return res;
1020};
1021
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001022static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
1023{
1024 struct saa7134_dev *dev = fe->dvb->priv;
1025 u8 wbuf[2] = { 0x1f, 00 };
1026 u8 rbuf;
1027 struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
1028 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
1029
1030 if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
1031 return -EIO;
1032 /* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
1033 if (voltage == SEC_VOLTAGE_18)
1034 wbuf[1] = rbuf | 0x10;
1035 else
1036 wbuf[1] = rbuf & 0xef;
1037 msg[0].len = 2;
1038 i2c_transfer(&dev->i2c_adap, msg, 1);
1039 return 0;
1040}
1041
1042static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
1043{
1044 struct saa7134_dev *dev = fe->dvb->priv;
1045 wprintk("%s: sorry can't set high LNB supply voltage from here\n", __func__);
1046 return -EIO;
1047}
1048
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001049/* ==================================================================
1050 * nxt200x based ATSC cards, helper functions
1051 */
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001052
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001053static struct nxt200x_config avertvhda180 = {
1054 .demod_address = 0x0a,
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001055};
Andrew Burri3e1410a2006-02-27 00:08:23 -03001056
1057static struct nxt200x_config kworldatsc110 = {
1058 .demod_address = 0x0a,
Andrew Burri3e1410a2006-02-27 00:08:23 -03001059};
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001060
Matthias Schwarzott04574182009-02-24 12:35:16 -03001061/* ------------------------------------------------------------------ */
1062
1063static struct mt312_config avertv_a700_mt312 = {
1064 .demod_address = 0x0e,
1065 .voltage_inverted = 1,
1066};
1067
1068static struct zl10036_config avertv_a700_tuner = {
1069 .tuner_address = 0x60,
1070};
1071
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001072static struct mt312_config zl10313_compro_s350_config = {
1073 .demod_address = 0x0e,
1074};
1075
Michael Krufky3abdedd2009-01-19 01:10:49 -03001076static struct lgdt3305_config hcw_lgdt3305_config = {
1077 .i2c_addr = 0x0e,
1078 .mpeg_mode = LGDT3305_MPEG_SERIAL,
1079 .tpclk_edge = LGDT3305_TPCLK_RISING_EDGE,
1080 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
1081 .deny_i2c_rptr = 1,
1082 .spectral_inversion = 1,
1083 .qam_if_khz = 4000,
1084 .vsb_if_khz = 3250,
1085};
1086
Michael Krufky1bc7f512009-01-19 01:10:49 -03001087static struct tda10048_config hcw_tda10048_config = {
1088 .demod_address = 0x10 >> 1,
1089 .output_mode = TDA10048_SERIAL_OUTPUT,
1090 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1091 .inversion = TDA10048_INVERSION_ON,
1092 .dtv6_if_freq_khz = TDA10048_IF_3300,
1093 .dtv7_if_freq_khz = TDA10048_IF_3500,
1094 .dtv8_if_freq_khz = TDA10048_IF_4000,
1095 .clk_freq_khz = TDA10048_CLK_16000,
1096 .disable_gate_access = 1,
1097};
1098
Michael Krufky3abdedd2009-01-19 01:10:49 -03001099static struct tda18271_std_map hauppauge_tda18271_std_map = {
1100 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
1101 .if_lvl = 1, .rfagc_top = 0x58, },
1102 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
1103 .if_lvl = 1, .rfagc_top = 0x58, },
1104};
1105
1106static struct tda18271_config hcw_tda18271_config = {
1107 .std_map = &hauppauge_tda18271_std_map,
1108 .gate = TDA18271_GATE_ANALOG,
1109 .config = 3,
Michael Krufky542cb052009-08-29 17:45:48 -03001110 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky3abdedd2009-01-19 01:10:49 -03001111};
1112
1113static struct tda829x_config tda829x_no_probe = {
1114 .probe_tuner = TDA829X_DONT_PROBE,
1115};
1116
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001117static struct tda10048_config zolid_tda10048_config = {
1118 .demod_address = 0x10 >> 1,
1119 .output_mode = TDA10048_PARALLEL_OUTPUT,
1120 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1121 .inversion = TDA10048_INVERSION_ON,
1122 .dtv6_if_freq_khz = TDA10048_IF_3300,
1123 .dtv7_if_freq_khz = TDA10048_IF_3500,
1124 .dtv8_if_freq_khz = TDA10048_IF_4000,
1125 .clk_freq_khz = TDA10048_CLK_16000,
1126 .disable_gate_access = 1,
1127};
1128
1129static struct tda18271_config zolid_tda18271_config = {
1130 .gate = TDA18271_GATE_ANALOG,
1131};
1132
Michael Krufky184e7692009-06-05 04:28:28 -03001133static struct tda10048_config dtv1000s_tda10048_config = {
1134 .demod_address = 0x10 >> 1,
1135 .output_mode = TDA10048_PARALLEL_OUTPUT,
1136 .fwbulkwritelen = TDA10048_BULKWRITE_200,
1137 .inversion = TDA10048_INVERSION_ON,
1138 .dtv6_if_freq_khz = TDA10048_IF_3300,
1139 .dtv7_if_freq_khz = TDA10048_IF_3800,
1140 .dtv8_if_freq_khz = TDA10048_IF_4300,
1141 .clk_freq_khz = TDA10048_CLK_16000,
1142 .disable_gate_access = 1,
1143};
1144
1145static struct tda18271_std_map dtv1000s_tda18271_std_map = {
1146 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
1147 .if_lvl = 1, .rfagc_top = 0x37, },
1148 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
1149 .if_lvl = 1, .rfagc_top = 0x37, },
1150 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
1151 .if_lvl = 1, .rfagc_top = 0x37, },
1152};
1153
1154static struct tda18271_config dtv1000s_tda18271_config = {
1155 .std_map = &dtv1000s_tda18271_std_map,
1156 .gate = TDA18271_GATE_ANALOG,
1157};
1158
Timothy Leece027042011-03-25 15:00:33 -03001159static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
1160 .prod = LGS8GXX_PROD_LGS8G75,
1161 .demod_address = 0x1d,
1162 .serial_ts = 0,
1163 .ts_clk_pol = 1,
1164 .ts_clk_gated = 0,
1165 .if_clk_freq = 30400, /* 30.4 MHz */
1166 .if_freq = 4000, /* 4.00 MHz */
1167 .if_neg_center = 0,
1168 .ext_adc = 0,
1169 .adc_signed = 1,
1170 .adc_vpp = 3, /* 2.0 Vpp */
1171 .if_neg_edge = 1,
1172};
1173
1174static struct tda18271_config prohdtv_pro2_tda18271_config = {
1175 .gate = TDA18271_GATE_ANALOG,
1176 .output_opt = TDA18271_OUTPUT_LT_OFF,
1177};
1178
Kyle Strickland25fa2072012-02-18 02:24:53 -03001179static struct tda18271_std_map kworld_tda18271_std_map = {
1180 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 3,
1181 .if_lvl = 6, .rfagc_top = 0x37 },
1182 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
1183 .if_lvl = 6, .rfagc_top = 0x37 },
1184};
1185
1186static struct tda18271_config kworld_pc150u_tda18271_config = {
1187 .std_map = &kworld_tda18271_std_map,
1188 .gate = TDA18271_GATE_ANALOG,
1189 .output_opt = TDA18271_OUTPUT_LT_OFF,
1190 .config = 3, /* Use tuner callback for AGC */
1191 .rf_cal_on_startup = 1
1192};
1193
1194static struct s5h1411_config kworld_s5h1411_config = {
1195 .output_mode = S5H1411_PARALLEL_OUTPUT,
1196 .gpio = S5H1411_GPIO_OFF,
1197 .qam_if = S5H1411_IF_4000,
1198 .vsb_if = S5H1411_IF_3250,
1199 .inversion = S5H1411_INVERSION_ON,
1200 .status_mode = S5H1411_DEMODLOCKING,
1201 .mpeg_timing =
1202 S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
1203};
1204
1205
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001206/* ==================================================================
1207 * Core code
1208 */
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001209
Linus Torvalds1da177e2005-04-16 15:20:36 -07001210static int dvb_init(struct saa7134_dev *dev)
1211{
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001212 int ret;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001213 int attach_xc3028 = 0;
Steven Toth363c35f2008-10-11 11:05:50 -03001214 struct videobuf_dvb_frontend *fe0;
1215
Darron Broadf972e0b2008-10-11 11:24:30 -03001216 /* FIXME: add support for multi-frontend */
1217 mutex_init(&dev->frontends.lock);
Darron Broad7bdf84f2008-10-15 13:43:41 -03001218 INIT_LIST_HEAD(&dev->frontends.felist);
Darron Broadf972e0b2008-10-11 11:24:30 -03001219
1220 printk(KERN_INFO "%s() allocating 1 frontend\n", __func__);
Darron Broadf3f741e2008-11-11 08:50:02 -03001221 fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
1222 if (!fe0) {
Darron Broadf972e0b2008-10-11 11:24:30 -03001223 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1224 return -ENOMEM;
1225 }
1226
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 /* init struct videobuf_dvb */
1228 dev->ts.nr_bufs = 32;
1229 dev->ts.nr_packets = 32*4;
Steven Toth363c35f2008-10-11 11:05:50 -03001230 fe0->dvb.name = dev->name;
1231 videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001232 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001233 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1234 V4L2_FIELD_ALTERNATE,
1235 sizeof(struct saa7134_buf),
Hans Verkuil08bff032010-09-20 17:39:46 -03001236 dev, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237
1238 switch (dev->board) {
1239 case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001240 dprintk("pinnacle 300i dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001241 fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001242 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001243 if (fe0->dvb.frontend) {
1244 fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001245 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 break;
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001247 case SAA7134_BOARD_AVERMEDIA_777:
Petr Baudis515c2082006-09-26 16:53:53 -03001248 case SAA7134_BOARD_AVERMEDIA_A16AR:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001249 dprintk("avertv 777 dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001250 fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001251 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001252 if (fe0->dvb.frontend) {
1253 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkyfb147e92008-04-22 14:46:16 -03001254 &dev->i2c_adap, 0x61,
1255 TUNER_PHILIPS_TD1316);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001256 }
Jose Alberto Regueroa78d0bf2006-02-07 06:25:14 -02001257 break;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001258 case SAA7134_BOARD_AVERMEDIA_A16D:
Tim Farrington6e501a32008-06-15 13:33:42 -03001259 dprintk("AverMedia A16D dvb setup\n");
Steven Toth363c35f2008-10-11 11:05:50 -03001260 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001261 &avermedia_xc3028_mt352_dev,
1262 &dev->i2c_adap);
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001263 attach_xc3028 = 1;
1264 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265 case SAA7134_BOARD_MD7134:
Steven Toth363c35f2008-10-11 11:05:50 -03001266 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001267 &medion_cardbus,
1268 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001269 if (fe0->dvb.frontend) {
1270 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001271 &dev->i2c_adap, medion_cardbus.tuner_address,
1272 TUNER_PHILIPS_FMD1216ME_MK3);
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001273 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274 break;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001275 case SAA7134_BOARD_PHILIPS_TOUGH:
Steven Toth363c35f2008-10-11 11:05:50 -03001276 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001277 &philips_tu1216_60_config,
1278 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001279 if (fe0->dvb.frontend) {
1280 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1281 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001282 }
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001283 break;
1284 case SAA7134_BOARD_FLYDVBTDUO:
Peter Missel10b7a902006-01-23 17:11:06 -02001285 case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001286 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1287 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001288 goto detach_frontend;
Mauro Carvalho Chehab86ddd962005-07-12 13:58:47 -07001289 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001290 case SAA7134_BOARD_PHILIPS_EUROPA:
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001291 case SAA7134_BOARD_VIDEOMATE_DVBT_300:
Danny Woode3c6e1a2009-09-20 12:14:21 -03001292 case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001293 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001294 &philips_europa_config,
1295 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001296 if (fe0->dvb.frontend) {
1297 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1298 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1299 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1300 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1301 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001302 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001303 break;
Vadim Catana128fe952010-05-29 12:49:16 -03001304 case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
1305 fe0->dvb.frontend = dvb_attach(tda10046_attach,
1306 &technotrend_budget_t3000_config,
1307 &dev->i2c_adap);
1308 if (fe0->dvb.frontend) {
1309 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1310 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
1311 fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
1312 fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
1313 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
1314 }
1315 break;
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001316 case SAA7134_BOARD_VIDEOMATE_DVBT_200:
Steven Toth363c35f2008-10-11 11:05:50 -03001317 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001318 &philips_tu1216_61_config,
1319 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001320 if (fe0->dvb.frontend) {
1321 fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
1322 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001323 }
Hartmut Hackmann2cf36ac2005-11-08 21:36:32 -08001324 break;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001325 case SAA7134_BOARD_KWORLD_DVBT_210:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001326 if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
1327 &tda827x_cfg_2) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001328 goto detach_frontend;
Simon Farnsworthb39423a2007-05-01 10:01:20 -03001329 break;
Michael Krufky0e316ec2009-08-03 16:51:33 -03001330 case SAA7134_BOARD_HAUPPAUGE_HVR1120:
Michael Krufky1bc7f512009-01-19 01:10:49 -03001331 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1332 &hcw_tda10048_config,
1333 &dev->i2c_adap);
1334 if (fe0->dvb.frontend != NULL) {
1335 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1336 &dev->i2c_adap, 0x4b,
1337 &tda829x_no_probe);
1338 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1339 0x60, &dev->i2c_adap,
1340 &hcw_tda18271_config);
1341 }
1342 break;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001343 case SAA7134_BOARD_PHILIPS_TIGER:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001344 if (configure_tda827x_fe(dev, &philips_tiger_config,
1345 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001346 goto detach_frontend;
Hartmut Hackmann587d2fd2006-10-06 19:13:50 -03001347 break;
1348 case SAA7134_BOARD_PINNACLE_PCTV_310i:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001349 if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
1350 &tda827x_cfg_1) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001351 goto detach_frontend;
Hartmut Hackmann90e9df72005-11-08 21:38:42 -08001352 break;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001353 case SAA7134_BOARD_HAUPPAUGE_HVR1110:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001354 if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
1355 &tda827x_cfg_1) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001356 goto detach_frontend;
Thomas Gentyc6e53da2006-11-05 14:17:30 -03001357 break;
Michael Krufkyb5f05062009-08-03 16:51:33 -03001358 case SAA7134_BOARD_HAUPPAUGE_HVR1150:
Michael Krufky3abdedd2009-01-19 01:10:49 -03001359 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
1360 &hcw_lgdt3305_config,
1361 &dev->i2c_adap);
1362 if (fe0->dvb.frontend) {
1363 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1364 &dev->i2c_adap, 0x4b,
1365 &tda829x_no_probe);
1366 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1367 0x60, &dev->i2c_adap,
1368 &hcw_tda18271_config);
1369 }
1370 break;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001371 case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001372 if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
1373 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001374 goto detach_frontend;
Hartmut Hackmannd4b0aba2005-11-08 21:38:44 -08001375 break;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001376 case SAA7134_BOARD_FLYDVBT_LR301:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001377 if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
1378 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001379 goto detach_frontend;
Giampiero Giancipoli3d8466e2006-02-07 06:49:09 -02001380 break;
Darron Broad92abe9e2008-10-11 11:18:53 -03001381 case SAA7134_BOARD_FLYDVB_TRIO:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001382 if (!use_frontend) { /* terrestrial */
1383 if (configure_tda827x_fe(dev, &lifeview_trio_config,
1384 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001385 goto detach_frontend;
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001386 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001387 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
1388 if (fe0->dvb.frontend) {
1389 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001390 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001391 wprintk("%s: Lifeview Trio, No tda826x found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001392 goto detach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001393 }
Steven Toth363c35f2008-10-11 11:05:50 -03001394 if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001395 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001396 wprintk("%s: Lifeview Trio, No ISL6421 found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001397 goto detach_frontend;
Nico Sabbi1f683cd2006-11-15 22:06:56 -03001398 }
1399 }
Andrew de Quincey6b3ccab2006-04-20 12:01:47 -03001400 }
Nico Sabbi420f32f2006-03-03 12:11:28 -03001401 break;
Hartmut Hackmanndf42eaf2006-02-07 06:49:10 -02001402 case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001403 case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001404 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001405 &ads_tech_duo_config,
1406 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001407 if (fe0->dvb.frontend) {
1408 if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
Hartmut Hackmann7bff4b42008-04-22 14:46:08 -03001409 ads_tech_duo_config.tuner_address, &dev->i2c_adap,
1410 &ads_duo_cfg) == NULL) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001411 wprintk("no tda827x tuner found at addr: %02x\n",
Hartmut Hackmannede22002007-04-27 12:31:32 -03001412 ads_tech_duo_config.tuner_address);
Peter Meerwald91268a52012-07-02 17:27:41 -03001413 goto detach_frontend;
Hartmut Hackmannede22002007-04-27 12:31:32 -03001414 }
Mauro Carvalho Chehabbc36ec7462008-06-14 10:44:04 -03001415 } else
1416 wprintk("failed to attach tda10046\n");
Hartmut Hackmannd95b8942006-03-27 19:39:30 -03001417 break;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001418 case SAA7134_BOARD_TEVION_DVBT_220RF:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001419 if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
1420 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001421 goto detach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001422 break;
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001423 case SAA7134_BOARD_MEDION_MD8800_QUADRO:
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001424 if (!use_frontend) { /* terrestrial */
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001425 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1426 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001427 goto detach_frontend;
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001428 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001429 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001430 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001431 if (fe0->dvb.frontend) {
1432 struct dvb_frontend *fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001433 u8 dev_id = dev->eedata[2];
1434 u8 data = 0xc4;
1435 struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
1436
Steven Toth363c35f2008-10-11 11:05:50 -03001437 if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001438 0x60, &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001439 wprintk("%s: Medion Quadro, no tda826x "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001440 "found !\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001441 goto detach_frontend;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001442 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001443 if (dev_id != 0x08) {
1444 /* we need to open the i2c gate (we know it exists) */
1445 fe->ops.i2c_gate_ctrl(fe, 1);
1446 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001447 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001448 wprintk("%s: Medion Quadro, no ISL6405 "
1449 "found !\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001450 goto detach_frontend;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001451 }
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001452 if (dev_id == 0x07) {
1453 /* fire up the 2nd section of the LNB supply since
1454 we can't do this from the other section */
1455 msg.buf = &data;
1456 i2c_transfer(&dev->i2c_adap, &msg, 1);
1457 }
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001458 fe->ops.i2c_gate_ctrl(fe, 0);
1459 dev->original_set_voltage = fe->ops.set_voltage;
1460 fe->ops.set_voltage = md8800_set_voltage;
1461 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1462 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1463 } else {
1464 fe->ops.set_voltage = md8800_set_voltage2;
1465 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
1466 }
Hartmut Hackmann4b1431c2008-04-22 14:42:09 -03001467 }
1468 }
Hartmut Hackmann5eda2272006-08-07 14:03:32 -03001469 break;
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001470 case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
Steven Toth363c35f2008-10-11 11:05:50 -03001471 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001472 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001473 if (fe0->dvb.frontend)
1474 dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -03001475 NULL, DVB_PLL_TDHU2);
Michael Krufky3b64e8e2005-11-08 21:38:20 -08001476 break;
Adam Gloverf689d902008-05-06 03:20:27 -03001477 case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
Andrew Burri3e1410a2006-02-27 00:08:23 -03001478 case SAA7134_BOARD_KWORLD_ATSC110:
Steven Toth363c35f2008-10-11 11:05:50 -03001479 fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001480 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001481 if (fe0->dvb.frontend)
1482 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky62ff8172008-04-22 14:46:17 -03001483 &dev->i2c_adap, 0x61,
1484 TUNER_PHILIPS_TUV1236D);
Andrew Burri3e1410a2006-02-27 00:08:23 -03001485 break;
Kyle Strickland25fa2072012-02-18 02:24:53 -03001486 case SAA7134_BOARD_KWORLD_PC150U:
1487 saa7134_set_gpio(dev, 18, 1); /* Switch to digital mode */
1488 saa7134_tuner_callback(dev, 0,
1489 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
1490 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1491 &kworld_s5h1411_config,
1492 &dev->i2c_adap);
1493 if (fe0->dvb.frontend != NULL) {
1494 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1495 &dev->i2c_adap, 0x4b,
1496 &tda829x_no_probe);
1497 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1498 0x60, &dev->i2c_adap,
1499 &kworld_pc150u_tda18271_config);
1500 }
1501 break;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001502 case SAA7134_BOARD_FLYDVBS_LR300:
Steven Toth363c35f2008-10-11 11:05:50 -03001503 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001504 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001505 if (fe0->dvb.frontend) {
1506 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001507 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001508 wprintk("%s: No tda826x found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001509 goto detach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001510 }
Steven Toth363c35f2008-10-11 11:05:50 -03001511 if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001512 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001513 wprintk("%s: No ISL6421 found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001514 goto detach_frontend;
Igor M. Liplianine2ac28f2006-08-08 09:10:10 -03001515 }
1516 }
1517 break;
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001518 case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001519 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Matthias Schwarzott0e8f4cc2008-01-28 12:01:11 -03001520 &medion_cardbus,
1521 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001522 if (fe0->dvb.frontend) {
1523 dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
1524 fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
Trent Piephob7754d72007-05-08 18:05:16 -03001525
Steven Toth363c35f2008-10-11 11:05:50 -03001526 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufkycb89cd32008-04-22 14:46:16 -03001527 &dev->i2c_adap, medion_cardbus.tuner_address,
1528 TUNER_PHILIPS_FMD1216ME_MK3);
Hartmut Hackmanncf146ca2006-10-02 20:49:24 -03001529 }
1530 break;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001531 case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
Steven Toth363c35f2008-10-11 11:05:50 -03001532 fe0->dvb.frontend = dvb_attach(tda10046_attach,
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001533 &philips_europa_config,
1534 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001535 if (fe0->dvb.frontend) {
1536 fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
1537 fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
Hartmut Hackmanncbb94522006-10-30 20:00:16 -03001538 }
1539 break;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001540 case SAA7134_BOARD_CINERGY_HT_PCMCIA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001541 if (configure_tda827x_fe(dev, &cinergy_ht_config,
1542 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001543 goto detach_frontend;
Hartmut Hackmann550a9a52006-11-15 21:31:54 -03001544 break;
Michael Krufky9de271e2007-01-16 18:36:40 -03001545 case SAA7134_BOARD_CINERGY_HT_PCI:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001546 if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
1547 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001548 goto detach_frontend;
Hartmut Hackmann58ef4f92007-04-27 12:31:12 -03001549 break;
1550 case SAA7134_BOARD_PHILIPS_TIGER_S:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001551 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1552 &tda827x_cfg_2) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001553 goto detach_frontend;
Michael Krufky9de271e2007-01-16 18:36:40 -03001554 break;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001555 case SAA7134_BOARD_ASUS_P7131_4871:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001556 if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
1557 &tda827x_cfg_2) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001558 goto detach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001559 break;
Hartmut Hackmannf3eec0c02007-03-14 20:33:55 -03001560 case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001561 if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
1562 &tda827x_cfg_2) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001563 goto detach_frontend;
Hartmut Hackmanne06cea42007-03-13 20:58:29 -03001564 break;
Edgar Simod90d9f52007-08-20 14:14:50 -03001565 case SAA7134_BOARD_AVERMEDIA_SUPER_007:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001566 if (configure_tda827x_fe(dev, &avermedia_super_007_config,
1567 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001568 goto detach_frontend;
Edgar Simod90d9f52007-08-20 14:14:50 -03001569 break;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001570 case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001571 if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
1572 &tda827x_cfg_2_sw42) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001573 goto detach_frontend;
Hermann Pitton4ba24372008-01-20 19:27:51 -03001574 break;
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001575 case SAA7134_BOARD_PHILIPS_SNAKE:
Steven Toth363c35f2008-10-11 11:05:50 -03001576 fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001577 &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001578 if (fe0->dvb.frontend) {
1579 if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001580 &dev->i2c_adap, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001581 wprintk("%s: No tda826x found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001582 goto detach_frontend;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001583 }
Steven Toth363c35f2008-10-11 11:05:50 -03001584 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001585 &dev->i2c_adap, 0, 0) == NULL) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001586 wprintk("%s: No lnbp21 found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001587 goto detach_frontend;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001588 }
Hartmut Hackmann6ab465a2008-04-22 14:42:11 -03001589 }
1590 break;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001591 case SAA7134_BOARD_CREATIX_CTX953:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001592 if (configure_tda827x_fe(dev, &md8800_dvbt_config,
1593 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001594 goto detach_frontend;
Hermann Pitton7b5b3f12008-04-22 14:42:12 -03001595 break;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001596 case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001597 if (configure_tda827x_fe(dev, &philips_tiger_s_config,
1598 &tda827x_cfg_2) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001599 goto detach_frontend;
Russell Kliese6a6179b62008-04-22 14:42:12 -03001600 break;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001601 case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
Tim Farrington6e501a32008-06-15 13:33:42 -03001602 dprintk("AverMedia E506R dvb setup\n");
1603 saa7134_set_gpio(dev, 25, 0);
1604 msleep(10);
1605 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001606 fe0->dvb.frontend = dvb_attach(mt352_attach,
Tim Farrington6e501a32008-06-15 13:33:42 -03001607 &avermedia_xc3028_mt352_dev,
1608 &dev->i2c_adap);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001609 attach_xc3028 = 1;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001610 break;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001611 case SAA7134_BOARD_MD7134_BRIDGE_2:
Steven Toth363c35f2008-10-11 11:05:50 -03001612 fe0->dvb.frontend = dvb_attach(tda10086_attach,
Hartmut Hackmann9a1b04e2008-04-09 23:07:11 -03001613 &sd1878_4m, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001614 if (fe0->dvb.frontend) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001615 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001616 if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001617 &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001618 wprintk("%s: MD7134 DVB-S, no SD1878 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001619 "found !\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001620 goto detach_frontend;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001621 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001622 /* we need to open the i2c gate (we know it exists) */
Steven Toth363c35f2008-10-11 11:05:50 -03001623 fe = fe0->dvb.frontend;
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001624 fe->ops.i2c_gate_ctrl(fe, 1);
1625 if (dvb_attach(isl6405_attach, fe,
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001626 &dev->i2c_adap, 0x08, 0, 0) == NULL) {
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001627 wprintk("%s: MD7134 DVB-S, no ISL6405 "
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001628 "found !\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001629 goto detach_frontend;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001630 }
Hartmut Hackmann637afdb2008-04-22 14:46:08 -03001631 fe->ops.i2c_gate_ctrl(fe, 0);
1632 dev->original_set_voltage = fe->ops.set_voltage;
1633 fe->ops.set_voltage = md8800_set_voltage;
1634 dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
1635 fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
1636 }
1637 break;
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001638 case SAA7134_BOARD_AVERMEDIA_M103:
1639 saa7134_set_gpio(dev, 25, 0);
1640 msleep(10);
1641 saa7134_set_gpio(dev, 25, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001642 fe0->dvb.frontend = dvb_attach(mt352_attach,
Massimo Piccionie2fc00c2008-07-11 13:48:02 -03001643 &avermedia_xc3028_mt352_dev,
1644 &dev->i2c_adap);
1645 attach_xc3028 = 1;
1646 break;
hermann pitton301e9d62008-09-14 17:49:14 -03001647 case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
1648 if (!use_frontend) { /* terrestrial */
1649 if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
1650 &tda827x_cfg_2) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001651 goto detach_frontend;
hermann pitton301e9d62008-09-14 17:49:14 -03001652 } else { /* satellite */
Steven Toth363c35f2008-10-11 11:05:50 -03001653 fe0->dvb.frontend = dvb_attach(tda10086_attach,
hermann pitton301e9d62008-09-14 17:49:14 -03001654 &flydvbs, &dev->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001655 if (fe0->dvb.frontend) {
hermann pitton301e9d62008-09-14 17:49:14 -03001656 if (dvb_attach(tda826x_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001657 fe0->dvb.frontend, 0x60,
hermann pitton301e9d62008-09-14 17:49:14 -03001658 &dev->i2c_adap, 0) == NULL) {
1659 wprintk("%s: Asus Tiger 3in1, no "
1660 "tda826x found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001661 goto detach_frontend;
hermann pitton301e9d62008-09-14 17:49:14 -03001662 }
Steven Toth363c35f2008-10-11 11:05:50 -03001663 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
hermann pitton301e9d62008-09-14 17:49:14 -03001664 &dev->i2c_adap, 0, 0) == NULL) {
1665 wprintk("%s: Asus Tiger 3in1, no lnbp21"
1666 " found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001667 goto detach_frontend;
remi schwartz75c7dbc2012-05-19 06:11:47 -03001668 }
1669 }
1670 }
1671 break;
1672 case SAA7134_BOARD_ASUSTeK_PS3_100:
1673 if (!use_frontend) { /* terrestrial */
1674 if (configure_tda827x_fe(dev, &asus_ps3_100_config,
1675 &tda827x_cfg_2) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001676 goto detach_frontend;
remi schwartz75c7dbc2012-05-19 06:11:47 -03001677 } else { /* satellite */
1678 fe0->dvb.frontend = dvb_attach(tda10086_attach,
1679 &flydvbs, &dev->i2c_adap);
1680 if (fe0->dvb.frontend) {
1681 if (dvb_attach(tda826x_attach,
1682 fe0->dvb.frontend, 0x60,
1683 &dev->i2c_adap, 0) == NULL) {
1684 wprintk("%s: Asus My Cinema PS3-100, no "
1685 "tda826x found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001686 goto detach_frontend;
remi schwartz75c7dbc2012-05-19 06:11:47 -03001687 }
1688 if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
1689 &dev->i2c_adap, 0, 0) == NULL) {
1690 wprintk("%s: Asus My Cinema PS3-100, no lnbp21"
1691 " found!\n", __func__);
Peter Meerwald91268a52012-07-02 17:27:41 -03001692 goto detach_frontend;
hermann pitton301e9d62008-09-14 17:49:14 -03001693 }
1694 }
1695 }
1696 break;
Hermann Pitton028165a2008-10-04 21:37:36 -03001697 case SAA7134_BOARD_ASUSTeK_TIGER:
1698 if (configure_tda827x_fe(dev, &philips_tiger_config,
1699 &tda827x_cfg_0) < 0)
Peter Meerwald91268a52012-07-02 17:27:41 -03001700 goto detach_frontend;
Hermann Pitton028165a2008-10-04 21:37:36 -03001701 break;
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001702 case SAA7134_BOARD_BEHOLD_H6:
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001703 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001704 &behold_h6_config,
1705 &dev->i2c_adap);
Mauro Carvalho Chehabb0c4be82008-12-30 19:10:09 -03001706 if (fe0->dvb.frontend) {
1707 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001708 &dev->i2c_adap, 0x61,
Beholder Intl. Ltd. Dmitry Belimov4786dd62009-08-04 20:07:42 -03001709 TUNER_PHILIPS_FMD1216MEX_MK3);
Dmitri Belimov47aeba52008-12-23 03:53:03 -03001710 }
1711 break;
Beholder Intl. Ltd. Dmitry Belimov29309922009-09-30 23:02:21 -03001712 case SAA7134_BOARD_BEHOLD_X7:
1713 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1714 &behold_x7_config,
1715 &dev->i2c_adap);
1716 if (fe0->dvb.frontend) {
1717 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1718 &dev->i2c_adap, &behold_x7_tunerconfig);
1719 }
1720 break;
Dmitri Belimov0faa2ed2010-04-06 01:00:05 -03001721 case SAA7134_BOARD_BEHOLD_H7:
1722 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1723 &behold_x7_config,
1724 &dev->i2c_adap);
1725 if (fe0->dvb.frontend) {
1726 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1727 &dev->i2c_adap, &behold_x7_tunerconfig);
1728 }
1729 break;
Matthias Schwarzott04574182009-02-24 12:35:16 -03001730 case SAA7134_BOARD_AVERMEDIA_A700_PRO:
1731 case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
1732 /* Zarlink ZL10313 */
1733 fe0->dvb.frontend = dvb_attach(mt312_attach,
1734 &avertv_a700_mt312, &dev->i2c_adap);
1735 if (fe0->dvb.frontend) {
1736 if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
1737 &avertv_a700_tuner, &dev->i2c_adap) == NULL) {
1738 wprintk("%s: No zl10036 found!\n",
1739 __func__);
1740 }
1741 }
1742 break;
Igor M. Liplianinecfcfec2009-08-13 21:42:21 -03001743 case SAA7134_BOARD_VIDEOMATE_S350:
1744 fe0->dvb.frontend = dvb_attach(mt312_attach,
1745 &zl10313_compro_s350_config, &dev->i2c_adap);
1746 if (fe0->dvb.frontend)
1747 if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
1748 0x60, &dev->i2c_adap) == NULL)
1749 wprintk("%s: No zl10039 found!\n",
1750 __func__);
1751
1752 break;
Carlos Corbachodbe87402011-06-25 10:24:28 -03001753 case SAA7134_BOARD_VIDEOMATE_T750:
1754 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1755 &videomate_t750_zl10353_config,
1756 &dev->i2c_adap);
1757 if (fe0->dvb.frontend != NULL) {
1758 if (dvb_attach(qt1010_attach,
1759 fe0->dvb.frontend,
1760 &dev->i2c_adap,
1761 &videomate_t750_qt1010_config) == NULL)
1762 wprintk("error attaching QT1010\n");
1763 }
1764 break;
Henk Vergonet6c119ff2009-09-18 20:44:37 -03001765 case SAA7134_BOARD_ZOLID_HYBRID_PCI:
1766 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1767 &zolid_tda10048_config,
1768 &dev->i2c_adap);
1769 if (fe0->dvb.frontend != NULL) {
1770 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1771 &dev->i2c_adap, 0x4b,
1772 &tda829x_no_probe);
1773 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1774 0x60, &dev->i2c_adap,
1775 &zolid_tda18271_config);
1776 }
1777 break;
Michael Krufky184e7692009-06-05 04:28:28 -03001778 case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
1779 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1780 &dtv1000s_tda10048_config,
1781 &dev->i2c_adap);
1782 if (fe0->dvb.frontend != NULL) {
1783 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1784 &dev->i2c_adap, 0x4b,
1785 &tda829x_no_probe);
1786 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1787 0x60, &dev->i2c_adap,
1788 &dtv1000s_tda18271_config);
1789 }
1790 break;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001791 case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
Mauro Carvalho Chehabecb71d22011-01-14 12:03:03 -03001792 /* Switch to digital mode */
1793 saa7134_tuner_callback(dev, 0,
1794 TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001795 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1796 &kworld_mb86a20s_config,
1797 &dev->i2c_adap);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001798 if (fe0->dvb.frontend != NULL) {
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001799 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1800 &dev->i2c_adap, 0x4b,
1801 &tda829x_no_probe);
Manoel Pinheirob08deeb2011-05-19 14:16:57 -03001802 fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001803 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1804 0x60, &dev->i2c_adap,
1805 &kworld_tda18271_config);
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001806 }
Mauro Carvalho Chehab6a58bc02011-01-14 09:11:21 -03001807
1808 /* mb86a20s need to use the I2C gateway */
Mauro Carvalho Chehabf0551ef2010-10-03 07:01:26 -03001809 break;
Timothy Leece027042011-03-25 15:00:33 -03001810 case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
1811 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1812 &prohdtv_pro2_lgs8g75_config,
1813 &dev->i2c_adap);
1814 if (fe0->dvb.frontend != NULL) {
1815 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1816 &dev->i2c_adap, 0x4b,
1817 &tda829x_no_probe);
1818 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1819 0x60, &dev->i2c_adap,
1820 &prohdtv_pro2_tda18271_config);
1821 }
1822 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001823 default:
Trent Piephocf3c34c2007-03-07 18:19:48 -03001824 wprintk("Huh? unknown DVB card?\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825 break;
1826 }
1827
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001828 if (attach_xc3028) {
1829 struct dvb_frontend *fe;
1830 struct xc2028_config cfg = {
1831 .i2c_adap = &dev->i2c_adap,
1832 .i2c_addr = 0x61,
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001833 };
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001834
Steven Toth363c35f2008-10-11 11:05:50 -03001835 if (!fe0->dvb.frontend)
Peter Meerwald91268a52012-07-02 17:27:41 -03001836 goto detach_frontend;
Mauro Carvalho Chehab95a2fdb2008-03-28 17:52:44 -03001837
Steven Toth363c35f2008-10-11 11:05:50 -03001838 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001839 if (!fe) {
1840 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
1841 dev->name);
Peter Meerwald91268a52012-07-02 17:27:41 -03001842 goto detach_frontend;
Mauro Carvalho Chehabbc36a682008-04-22 14:45:27 -03001843 }
1844 }
1845
Steven Toth363c35f2008-10-11 11:05:50 -03001846 if (NULL == fe0->dvb.frontend) {
Trent Piephocf3c34c2007-03-07 18:19:48 -03001847 printk(KERN_ERR "%s/dvb: frontend initialization failed\n", dev->name);
Peter Meerwald91268a52012-07-02 17:27:41 -03001848 goto detach_frontend;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001850 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001851 fe0->dvb.frontend->callback = saa7134_tuner_callback;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852
1853 /* register everything else */
Steven Toth363c35f2008-10-11 11:05:50 -03001854 ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Mauro Carvalho Chehab9adf6132012-08-05 14:16:30 -03001855 &dev->pci->dev, adapter_nr, 0);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001856
1857 /* this sequence is necessary to make the tda1004x load its firmware
1858 * and to enter analog mode of hybrid boards
1859 */
1860 if (!ret) {
Steven Toth363c35f2008-10-11 11:05:50 -03001861 if (fe0->dvb.frontend->ops.init)
1862 fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
1863 if (fe0->dvb.frontend->ops.sleep)
1864 fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
1865 if (fe0->dvb.frontend->ops.tuner_ops.sleep)
1866 fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
Hartmut Hackmann1c4f76a2007-04-27 12:31:16 -03001867 }
1868 return ret;
Mauro Carvalho Chehabd557dab2008-04-30 15:27:55 -03001869
Peter Meerwald91268a52012-07-02 17:27:41 -03001870detach_frontend:
Darron Broadf3f741e2008-11-11 08:50:02 -03001871 videobuf_dvb_dealloc_frontends(&dev->frontends);
1872 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001873}
1874
1875static int dvb_fini(struct saa7134_dev *dev)
1876{
Steven Toth363c35f2008-10-11 11:05:50 -03001877 struct videobuf_dvb_frontend *fe0;
1878
1879 /* Get the first frontend */
1880 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
1881 if (!fe0)
1882 return -EINVAL;
1883
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001884 /* FIXME: I suspect that this code is bogus, since the entry for
1885 Pinnacle 300I DVB-T PAL already defines the proper init to allow
1886 the detection of mt2032 (TDA9887_PORT2_INACTIVE)
1887 */
1888 if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
1889 struct v4l2_priv_tun_config tda9887_cfg;
1890 static int on = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001892 tda9887_cfg.tuner = TUNER_TDA9887;
1893 tda9887_cfg.priv = &on;
1894
Linus Torvalds1da177e2005-04-16 15:20:36 -07001895 /* otherwise we don't detect the tuner on next insmod */
Hans Verkuilfac69862009-01-17 12:17:14 -03001896 saa_call_all(dev, tuner, s_config, &tda9887_cfg);
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001897 } else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
Hartmut Hackmanne9c1ac92008-04-22 14:46:10 -03001898 if ((dev->eedata[2] == 0x07) && use_frontend) {
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001899 /* turn off the 2nd lnb supply */
1900 u8 data = 0x80;
1901 struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
1902 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -03001903 fe = fe0->dvb.frontend;
Hartmut Hackmann5823b3a2008-04-22 14:46:08 -03001904 if (fe->ops.i2c_gate_ctrl) {
1905 fe->ops.i2c_gate_ctrl(fe, 1);
1906 i2c_transfer(&dev->i2c_adap, &msg, 1);
1907 fe->ops.i2c_gate_ctrl(fe, 0);
1908 }
1909 }
Mauro Carvalho Chehab7f171122007-10-18 19:56:47 -03001910 }
Darron Broadf3f741e2008-11-11 08:50:02 -03001911 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001912 return 0;
1913}
1914
1915static struct saa7134_mpeg_ops dvb_ops = {
1916 .type = SAA7134_MPEG_DVB,
1917 .init = dvb_init,
1918 .fini = dvb_fini,
1919};
1920
1921static int __init dvb_register(void)
1922{
1923 return saa7134_ts_register(&dvb_ops);
1924}
1925
1926static void __exit dvb_unregister(void)
1927{
1928 saa7134_ts_unregister(&dvb_ops);
1929}
1930
1931module_init(dvb_register);
1932module_exit(dvb_unregister);
1933
1934/* ------------------------------------------------------------------ */
1935/*
1936 * Local variables:
1937 * c-basic-offset: 8
1938 * End:
1939 */