Blame view

drivers/media/video/saa7134/saa7134-dvb.c 53.5 KB
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1
  /*
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
2
3
4
   *
   * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
   *
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
5
6
7
   *  Extended 3 / 2005 by Hartmut Hackmann to support various
   *  cards with the tda10046 DVB-T channel decoder
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
   *  This program is free software; you can redistribute it and/or modify
   *  it under the terms of the GNU General Public License as published by
   *  the Free Software Foundation; either version 2 of the License, or
   *  (at your option) any later version.
   *
   *  This program is distributed in the hope that it will be useful,
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   *  GNU General Public License for more details.
   *
   *  You should have received a copy of the GNU General Public License
   *  along with this program; if not, write to the Free Software
   *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   */
  
  #include <linux/init.h>
  #include <linux/list.h>
  #include <linux/module.h>
  #include <linux/kernel.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
27
28
29
30
31
32
  #include <linux/delay.h>
  #include <linux/kthread.h>
  #include <linux/suspend.h>
  
  #include "saa7134-reg.h"
  #include "saa7134.h"
5e453dc75   Michael Krufky   V4L/DVB (3269): i...
33
  #include <media/v4l2-common.h>
a78d0bfab   Jose Alberto Reguero   V4L/DVB (3267): A...
34
  #include "dvb-pll.h"
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
35
  #include <dvb_frontend.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36

1f10c7afa   Andrew de Quincey   V4L/DVB (4388): R...
37
38
39
40
  #include "mt352.h"
  #include "mt352_priv.h" /* FIXME */
  #include "tda1004x.h"
  #include "nxt200x.h"
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
41
  #include "tuner-xc2028.h"
2930992c4   Beholder Intl. Ltd. Dmitry Belimov   V4L/DVB (13080): ...
42
  #include "xc5000.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
43

e2ac28fa1   Igor M. Liplianin   V4L/DVB (4398): A...
44
45
  #include "tda10086.h"
  #include "tda826x.h"
8ce47dad8   Michael Krufky   V4L/DVB (5317): C...
46
  #include "tda827x.h"
e2ac28fa1   Igor M. Liplianin   V4L/DVB (4398): A...
47
  #include "isl6421.h"
4b1431ca1   Hartmut Hackmann   V4L/DVB (7224): I...
48
  #include "isl6405.h"
6ab465a82   Hartmut Hackmann   V4L/DVB (7226): s...
49
  #include "lnbp21.h"
cb89cd332   Michael Krufky   V4L/DVB (7413): u...
50
  #include "tuner-simple.h"
1bc7f51c5   Michael Krufky   V4L/DVB (11861): ...
51
  #include "tda10048.h"
3abdedd8a   Michael Krufky   V4L/DVB (10926): ...
52
53
54
  #include "tda18271.h"
  #include "lgdt3305.h"
  #include "tda8290.h"
f0551efc7   Mauro Carvalho Chehab   [media] Add DVB s...
55
  #include "mb86a20s.h"
ce02704d4   Timothy Lee   [media] saa7134: ...
56
  #include "lgs8gxx.h"
8ce47dad8   Michael Krufky   V4L/DVB (5317): C...
57

47aeba5ad   Dmitri Belimov   V4L/DVB (10153): ...
58
  #include "zl10353.h"
dbe8740dd   Carlos Corbacho   [media] Make Comp...
59
  #include "qt1010.h"
47aeba5ad   Dmitri Belimov   V4L/DVB (10153): ...
60

04574185a   Matthias Schwarzott   V4L/DVB (10823): ...
61
  #include "zl10036.h"
ecfcfec80   Igor M. Liplianin   V4L/DVB (12463): ...
62
  #include "zl10039.h"
04574185a   Matthias Schwarzott   V4L/DVB (10823): ...
63
  #include "mt312.h"
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
64
65
  MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
  MODULE_LICENSE("GPL");
ff699e6bd   Douglas Schilling Landgraf   V4L/DVB (7094): ...
66
  static unsigned int antenna_pwr;
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
67

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
69
  module_param(antenna_pwr, int, 0444);
  MODULE_PARM_DESC(antenna_pwr,"enable antenna power (Pinnacle 300i)");
ff699e6bd   Douglas Schilling Landgraf   V4L/DVB (7094): ...
70
  static int use_frontend;
b331daa03   Stephan Berberig   V4L/DVB (4992): F...
71
72
  module_param(use_frontend, int, 0644);
  MODULE_PARM_DESC(use_frontend,"for cards with multiple frontends (0: terrestrial, 1: satellite)");
1f683cd8b   Nico Sabbi   V4L/DVB (4836): A...
73

ff699e6bd   Douglas Schilling Landgraf   V4L/DVB (7094): ...
74
  static int debug;
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
75
76
  module_param(debug, int, 0644);
  MODULE_PARM_DESC(debug, "Turn on/off module debugging (default:off).");
78e92006f   Janne Grunau   V4L/DVB (7538): A...
77
  DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
cf3c34c87   Trent Piepho   V4L/DVB (5391): S...
78
79
80
81
82
83
  #define dprintk(fmt, arg...)	do { if (debug) \
  	printk(KERN_DEBUG "%s/dvb: " fmt, dev->name , ## arg); } while(0)
  
  /* Print a warning */
  #define wprintk(fmt, arg...) \
  	printk(KERN_WARNING "%s/dvb: " fmt, dev->name, ## arg)
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
84
85
86
87
  
  /* ------------------------------------------------------------------
   * mt352 based DVB-T cards
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
  static int pinnacle_antenna_pwr(struct saa7134_dev *dev, int on)
  {
  	u32 ok;
  
  	if (!on) {
  		saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
  		saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 26));
  		return 0;
  	}
  
  	saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 26));
  	saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
  	udelay(10);
  
  	saa_setl(SAA7134_GPIO_GPMODE0 >> 2,     (1 << 28));
  	saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2, (1 << 28));
  	udelay(10);
  	saa_setl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 28));
  	udelay(10);
  	ok = saa_readl(SAA7134_GPIO_GPSTATUS0) & (1 << 27);
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
108
109
  	dprintk("%s %s
  ", __func__, ok ? "on" : "off");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
  
  	if (!ok)
  		saa_clearl(SAA7134_GPIO_GPSTATUS0 >> 2,   (1 << 26));
  	return ok;
  }
  
  static int mt352_pinnacle_init(struct dvb_frontend* fe)
  {
  	static u8 clock_config []  = { CLOCK_CTL,  0x3d, 0x28 };
  	static u8 reset []         = { RESET,      0x80 };
  	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
  	static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0xa0 };
  	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x31 };
  	static u8 fsm_ctl_cfg[]    = { 0x7b,       0x04 };
  	static u8 gpp_ctl_cfg []   = { GPP_CTL,    0x0f };
  	static u8 scan_ctl_cfg []  = { SCAN_CTL,   0x0d };
  	static u8 irq_cfg []       = { INTERRUPT_EN_0, 0x00, 0x00, 0x00, 0x00 };
  	struct saa7134_dev *dev= fe->dvb->priv;
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
128
129
  	dprintk("%s called
  ", __func__);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
130
131
132
133
134
135
136
137
138
139
140
141
  
  	mt352_write(fe, clock_config,   sizeof(clock_config));
  	udelay(200);
  	mt352_write(fe, reset,          sizeof(reset));
  	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
  	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
  	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  	mt352_write(fe, gpp_ctl_cfg,    sizeof(gpp_ctl_cfg));
  
  	mt352_write(fe, fsm_ctl_cfg,    sizeof(fsm_ctl_cfg));
  	mt352_write(fe, scan_ctl_cfg,   sizeof(scan_ctl_cfg));
  	mt352_write(fe, irq_cfg,        sizeof(irq_cfg));
df8cf7068   Hartmut Hackmann   V4L/DVB (3395): F...
142

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
143
144
  	return 0;
  }
a78d0bfab   Jose Alberto Reguero   V4L/DVB (3267): A...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
  static int mt352_aver777_init(struct dvb_frontend* fe)
  {
  	static u8 clock_config []  = { CLOCK_CTL,  0x38, 0x2d };
  	static u8 reset []         = { RESET,      0x80 };
  	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1,  0x40 };
  	static u8 agc_cfg []       = { AGC_TARGET, 0x28, 0xa0 };
  	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
  
  	mt352_write(fe, clock_config,   sizeof(clock_config));
  	udelay(200);
  	mt352_write(fe, reset,          sizeof(reset));
  	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
  	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
  	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
  
  	return 0;
  }
6e501a3f4   Tim Farrington   V4L/DVB (8048): s...
162
  static int mt352_avermedia_xc3028_init(struct dvb_frontend *fe)
95a2fdb6f   Mauro Carvalho Chehab   V4L/DVB (7458): s...
163
  {
6e501a3f4   Tim Farrington   V4L/DVB (8048): s...
164
165
166
167
  	static u8 clock_config []  = { CLOCK_CTL, 0x38, 0x2d };
  	static u8 reset []         = { RESET, 0x80 };
  	static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
  	static u8 agc_cfg []       = { AGC_TARGET, 0xe };
95a2fdb6f   Mauro Carvalho Chehab   V4L/DVB (7458): s...
168
169
170
171
172
173
174
175
  	static u8 capt_range_cfg[] = { CAPT_RANGE, 0x33 };
  
  	mt352_write(fe, clock_config,   sizeof(clock_config));
  	udelay(200);
  	mt352_write(fe, reset,          sizeof(reset));
  	mt352_write(fe, adc_ctl_1_cfg,  sizeof(adc_ctl_1_cfg));
  	mt352_write(fe, agc_cfg,        sizeof(agc_cfg));
  	mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
95a2fdb6f   Mauro Carvalho Chehab   V4L/DVB (7458): s...
176
177
  	return 0;
  }
0463f12c5   Andrew de Quincey   V4L/DVB (4032): F...
178
179
  static int mt352_pinnacle_tuner_set_params(struct dvb_frontend* fe,
  					   struct dvb_frontend_parameters* params)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
180
  {
df8cf7068   Hartmut Hackmann   V4L/DVB (3395): F...
181
182
183
  	u8 off[] = { 0x00, 0xf1};
  	u8 on[]  = { 0x00, 0x71};
  	struct i2c_msg msg = {.addr=0x43, .flags=0, .buf=off, .len = sizeof(off)};
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
184
185
186
187
188
189
190
  	struct saa7134_dev *dev = fe->dvb->priv;
  	struct v4l2_frequency f;
  
  	/* set frequency (mt2050) */
  	f.tuner     = 0;
  	f.type      = V4L2_TUNER_DIGITAL_TV;
  	f.frequency = params->frequency / 1000 * 16 / 1000;
dea74869f   Patrick Boettcher   V4L/DVB (4028): C...
191
192
  	if (fe->ops.i2c_gate_ctrl)
  		fe->ops.i2c_gate_ctrl(fe, 1);
df8cf7068   Hartmut Hackmann   V4L/DVB (3395): F...
193
  	i2c_transfer(&dev->i2c_adap, &msg, 1);
fac6986c4   Hans Verkuil   V4L/DVB (10247): ...
194
  	saa_call_all(dev, tuner, s_frequency, &f);
df8cf7068   Hartmut Hackmann   V4L/DVB (3395): F...
195
  	msg.buf = on;
dea74869f   Patrick Boettcher   V4L/DVB (4028): C...
196
197
  	if (fe->ops.i2c_gate_ctrl)
  		fe->ops.i2c_gate_ctrl(fe, 1);
df8cf7068   Hartmut Hackmann   V4L/DVB (3395): F...
198
  	i2c_transfer(&dev->i2c_adap, &msg, 1);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
199
200
201
202
  
  	pinnacle_antenna_pwr(dev, antenna_pwr);
  
  	/* mt352 setup */
0463f12c5   Andrew de Quincey   V4L/DVB (4032): F...
203
  	return mt352_pinnacle_init(fe);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
204
205
206
207
208
209
210
211
  }
  
  static struct mt352_config pinnacle_300i = {
  	.demod_address = 0x3c >> 1,
  	.adc_clock     = 20333,
  	.if2           = 36150,
  	.no_tuner      = 1,
  	.demod_init    = mt352_pinnacle_init,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
212
  };
a78d0bfab   Jose Alberto Reguero   V4L/DVB (3267): A...
213
214
215
216
  
  static struct mt352_config avermedia_777 = {
  	.demod_address = 0xf,
  	.demod_init    = mt352_aver777_init,
a78d0bfab   Jose Alberto Reguero   V4L/DVB (3267): A...
217
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
218

6e501a3f4   Tim Farrington   V4L/DVB (8048): s...
219
  static struct mt352_config avermedia_xc3028_mt352_dev = {
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
220
221
  	.demod_address   = (0x1e >> 1),
  	.no_tuner        = 1,
6e501a3f4   Tim Farrington   V4L/DVB (8048): s...
222
  	.demod_init      = mt352_avermedia_xc3028_init,
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
223
  };
f0551efc7   Mauro Carvalho Chehab   [media] Add DVB s...
224
225
226
227
228
229
230
  static struct tda18271_std_map mb86a20s_tda18271_std_map = {
  	.dvbt_6   = { .if_freq = 3300, .agc_mode = 3, .std = 4,
  		      .if_lvl = 7, .rfagc_top = 0x37, },
  };
  
  static struct tda18271_config kworld_tda18271_config = {
  	.std_map = &mb86a20s_tda18271_std_map,
6a58bc0f5   Mauro Carvalho Chehab   [media] saa7134: ...
231
  	.gate    = TDA18271_GATE_DIGITAL,
ecb71d262   Mauro Carvalho Chehab   [media] saa7134: ...
232
  	.config  = 3,	/* Use tuner callback for AGC */
f0551efc7   Mauro Carvalho Chehab   [media] Add DVB s...
233
234
235
236
237
  };
  
  static const struct mb86a20s_config kworld_mb86a20s_config = {
  	.demod_address = 0x10,
  };
6a58bc0f5   Mauro Carvalho Chehab   [media] saa7134: ...
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
  static int kworld_sbtvd_gate_ctrl(struct dvb_frontend* fe, int enable)
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
  
  	unsigned char initmsg[] = {0x45, 0x97};
  	unsigned char msg_enable[] = {0x45, 0xc1};
  	unsigned char msg_disable[] = {0x45, 0x81};
  	struct i2c_msg msg = {.addr = 0x4b, .flags = 0, .buf = initmsg, .len = 2};
  
  	if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
  		wprintk("could not access the I2C gate
  ");
  		return -EIO;
  	}
  	if (enable)
  		msg.buf = msg_enable;
  	else
  		msg.buf = msg_disable;
  	if (i2c_transfer(&dev->i2c_adap, &msg, 1) != 1) {
  		wprintk("could not access the I2C gate
  ");
  		return -EIO;
  	}
  	msleep(20);
  	return 0;
  }
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
264
265
266
267
268
269
  /* ==================================================================
   * tda1004x based DVB-T cards, helper functions
   */
  
  static int philips_tda1004x_request_firmware(struct dvb_frontend *fe,
  					   const struct firmware **fw, char *name)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
270
271
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
272
273
  	return request_firmware(fw, name, &dev->pci->dev);
  }
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
274
275
276
277
278
279
280
281
282
  /* ------------------------------------------------------------------
   * these tuners are tu1216, td1316(a)
   */
  
  static int philips_tda6651_pll_set(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
  	struct tda1004x_state *state = fe->demodulator_priv;
  	u8 addr = state->config->tuner_address;
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
283
  	u8 tuner_buf[4];
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
284
  	struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tuner_buf,.len =
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
  			sizeof(tuner_buf) };
  	int tuner_frequency = 0;
  	u8 band, cp, filter;
  
  	/* determine charge pump */
  	tuner_frequency = params->frequency + 36166000;
  	if (tuner_frequency < 87000000)
  		return -EINVAL;
  	else if (tuner_frequency < 130000000)
  		cp = 3;
  	else if (tuner_frequency < 160000000)
  		cp = 5;
  	else if (tuner_frequency < 200000000)
  		cp = 6;
  	else if (tuner_frequency < 290000000)
  		cp = 3;
  	else if (tuner_frequency < 420000000)
  		cp = 5;
  	else if (tuner_frequency < 480000000)
  		cp = 6;
  	else if (tuner_frequency < 620000000)
  		cp = 3;
  	else if (tuner_frequency < 830000000)
  		cp = 5;
  	else if (tuner_frequency < 895000000)
  		cp = 7;
  	else
  		return -EINVAL;
  
  	/* determine band */
  	if (params->frequency < 49000000)
  		return -EINVAL;
  	else if (params->frequency < 161000000)
  		band = 1;
  	else if (params->frequency < 444000000)
  		band = 2;
  	else if (params->frequency < 861000000)
  		band = 4;
  	else
  		return -EINVAL;
  
  	/* setup PLL filter */
  	switch (params->u.ofdm.bandwidth) {
  	case BANDWIDTH_6_MHZ:
  		filter = 0;
  		break;
  
  	case BANDWIDTH_7_MHZ:
  		filter = 0;
  		break;
  
  	case BANDWIDTH_8_MHZ:
  		filter = 1;
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
339

86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
340
341
342
343
344
345
  	default:
  		return -EINVAL;
  	}
  
  	/* calculate divisor
  	 * ((36166000+((1000000/6)/2)) + Finput)/(1000000/6)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
346
  	 */
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
347
348
349
350
351
352
353
  	tuner_frequency = (((params->frequency / 1000) * 6) + 217496) / 1000;
  
  	/* setup tuner buffer */
  	tuner_buf[0] = (tuner_frequency >> 8) & 0x7f;
  	tuner_buf[1] = tuner_frequency & 0xff;
  	tuner_buf[2] = 0xca;
  	tuner_buf[3] = (cp << 5) | (filter << 3) | band;
dea74869f   Patrick Boettcher   V4L/DVB (4028): C...
354
355
  	if (fe->ops.i2c_gate_ctrl)
  		fe->ops.i2c_gate_ctrl(fe, 1);
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
356
  	if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1) {
cf3c34c87   Trent Piepho   V4L/DVB (5391): S...
357
358
359
  		wprintk("could not write to tuner at addr: 0x%02x
  ",
  			addr << 1);
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
360
  		return -EIO;
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
361
  	}
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
362
363
364
  	msleep(1);
  	return 0;
  }
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
365
  static int philips_tu1216_init(struct dvb_frontend *fe)
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
366
367
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
368
369
  	struct tda1004x_state *state = fe->demodulator_priv;
  	u8 addr = state->config->tuner_address;
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
370
371
  	static u8 tu1216_init[] = { 0x0b, 0xf5, 0x85, 0xab };
  	struct i2c_msg tuner_msg = {.addr = addr,.flags = 0,.buf = tu1216_init,.len = sizeof(tu1216_init) };
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
372

2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
373
  	/* setup PLL configuration */
dea74869f   Patrick Boettcher   V4L/DVB (4028): C...
374
375
  	if (fe->ops.i2c_gate_ctrl)
  		fe->ops.i2c_gate_ctrl(fe, 1);
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
376
377
  	if (i2c_transfer(&dev->i2c_adap, &tuner_msg, 1) != 1)
  		return -EIO;
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
378
  	msleep(1);
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
379

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
380
381
  	return 0;
  }
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
382
  /* ------------------------------------------------------------------ */
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
383
  static struct tda1004x_config philips_tu1216_60_config = {
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
384
385
  	.demod_address = 0x8,
  	.invert        = 1,
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
386
  	.invert_oclk   = 0,
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
387
388
389
  	.xtal_freq     = TDA10046_XTAL_4M,
  	.agc_config    = TDA10046_AGC_DEFAULT,
  	.if_freq       = TDA10046_FREQ_3617,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
390
391
  	.tuner_address = 0x60,
  	.request_firmware = philips_tda1004x_request_firmware
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
392
  };
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
393
394
395
396
397
398
399
400
  static struct tda1004x_config philips_tu1216_61_config = {
  
  	.demod_address = 0x8,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_4M,
  	.agc_config    = TDA10046_AGC_DEFAULT,
  	.if_freq       = TDA10046_FREQ_3617,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
401
402
  	.tuner_address = 0x61,
  	.request_firmware = philips_tda1004x_request_firmware
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
403
404
405
  };
  
  /* ------------------------------------------------------------------ */
cbb94521c   Hartmut Hackmann   V4L/DVB (4792): A...
406
  static int philips_td1316_tuner_init(struct dvb_frontend *fe)
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
407
408
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
409
410
  	struct tda1004x_state *state = fe->demodulator_priv;
  	u8 addr = state->config->tuner_address;
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
411
  	static u8 msg[] = { 0x0b, 0xf5, 0x86, 0xab };
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
412
  	struct i2c_msg init_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
413
414
  
  	/* setup PLL configuration */
dea74869f   Patrick Boettcher   V4L/DVB (4028): C...
415
416
  	if (fe->ops.i2c_gate_ctrl)
  		fe->ops.i2c_gate_ctrl(fe, 1);
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
417
418
  	if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  		return -EIO;
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
419
420
  	return 0;
  }
a79ddae9f   Andrew de Quincey   V4L/DVB (3879): C...
421
  static int philips_td1316_tuner_set_params(struct dvb_frontend *fe, struct dvb_frontend_parameters *params)
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
422
  {
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
  	return philips_tda6651_pll_set(fe, params);
  }
  
  static int philips_td1316_tuner_sleep(struct dvb_frontend *fe)
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
  	struct tda1004x_state *state = fe->demodulator_priv;
  	u8 addr = state->config->tuner_address;
  	static u8 msg[] = { 0x0b, 0xdc, 0x86, 0xa4 };
  	struct i2c_msg analog_msg = {.addr = addr,.flags = 0,.buf = msg,.len = sizeof(msg) };
  
  	/* switch the tuner to analog mode */
  	if (fe->ops.i2c_gate_ctrl)
  		fe->ops.i2c_gate_ctrl(fe, 1);
  	if (i2c_transfer(&dev->i2c_adap, &analog_msg, 1) != 1)
  		return -EIO;
  	return 0;
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
440
  }
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
441
  /* ------------------------------------------------------------------ */
cbb94521c   Hartmut Hackmann   V4L/DVB (4792): A...
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
  static int philips_europa_tuner_init(struct dvb_frontend *fe)
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
  	static u8 msg[] = { 0x00, 0x40};
  	struct i2c_msg init_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  
  
  	if (philips_td1316_tuner_init(fe))
  		return -EIO;
  	msleep(1);
  	if (i2c_transfer(&dev->i2c_adap, &init_msg, 1) != 1)
  		return -EIO;
  
  	return 0;
  }
a79ddae9f   Andrew de Quincey   V4L/DVB (3879): C...
457
  static int philips_europa_tuner_sleep(struct dvb_frontend *fe)
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
458
459
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
460

58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
461
462
463
464
465
  	static u8 msg[] = { 0x00, 0x14 };
  	struct i2c_msg analog_msg = {.addr = 0x43,.flags = 0,.buf = msg,.len = sizeof(msg) };
  
  	if (philips_td1316_tuner_sleep(fe))
  		return -EIO;
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
466
467
  
  	/* switch the board to analog mode */
dea74869f   Patrick Boettcher   V4L/DVB (4028): C...
468
469
  	if (fe->ops.i2c_gate_ctrl)
  		fe->ops.i2c_gate_ctrl(fe, 1);
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
470
  	i2c_transfer(&dev->i2c_adap, &analog_msg, 1);
a79ddae9f   Andrew de Quincey   V4L/DVB (3879): C...
471
472
473
474
475
476
477
478
479
  	return 0;
  }
  
  static int philips_europa_demod_sleep(struct dvb_frontend *fe)
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
  
  	if (dev->original_demod_sleep)
  		dev->original_demod_sleep(fe);
dea74869f   Patrick Boettcher   V4L/DVB (4028): C...
480
  	fe->ops.i2c_gate_ctrl(fe, 1);
a79ddae9f   Andrew de Quincey   V4L/DVB (3879): C...
481
  	return 0;
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
482
483
484
485
486
487
488
489
490
491
  }
  
  static struct tda1004x_config philips_europa_config = {
  
  	.demod_address = 0x8,
  	.invert        = 0,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_4M,
  	.agc_config    = TDA10046_AGC_IFO_AUTO_POS,
  	.if_freq       = TDA10046_FREQ_052,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
492
493
  	.tuner_address = 0x61,
  	.request_firmware = philips_tda1004x_request_firmware
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
494
  };
408b664a7   Adrian Bunk   [PATCH] make lots...
495
  static struct tda1004x_config medion_cardbus = {
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
496
497
498
499
500
501
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_IFO_AUTO_NEG,
  	.if_freq       = TDA10046_FREQ_3613,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
502
503
  	.tuner_address = 0x61,
  	.request_firmware = philips_tda1004x_request_firmware
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
504
  };
128fe95d7   Vadim Catana   V4L/DVB: TechnoTr...
505
506
507
508
509
510
511
512
513
514
  static struct tda1004x_config technotrend_budget_t3000_config = {
  	.demod_address = 0x8,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_4M,
  	.agc_config    = TDA10046_AGC_DEFAULT,
  	.if_freq       = TDA10046_FREQ_3617,
  	.tuner_address = 0x63,
  	.request_firmware = philips_tda1004x_request_firmware
  };
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
515
516
517
  /* ------------------------------------------------------------------
   * tda 1004x based cards with philips silicon tuner
   */
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
518
519
  static int tda8290_i2c_gate_ctrl( struct dvb_frontend* fe, int enable)
  {
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
520
521
522
523
524
525
526
527
528
529
530
  	struct tda1004x_state *state = fe->demodulator_priv;
  
  	u8 addr = state->config->i2c_gate;
  	static u8 tda8290_close[] = { 0x21, 0xc0};
  	static u8 tda8290_open[]  = { 0x21, 0x80};
  	struct i2c_msg tda8290_msg = {.addr = addr,.flags = 0, .len = 2};
  	if (enable) {
  		tda8290_msg.buf = tda8290_close;
  	} else {
  		tda8290_msg.buf = tda8290_open;
  	}
06be3035f   Hartmut Hackmann   V4L/DVB (5318): F...
531
  	if (i2c_transfer(state->i2c, &tda8290_msg, 1) != 1) {
cf3c34c87   Trent Piepho   V4L/DVB (5391): S...
532
533
534
  		struct saa7134_dev *dev = fe->dvb->priv;
  		wprintk("could not access tda8290 I2C gate
  ");
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
535
536
537
538
539
  		return -EIO;
  	}
  	msleep(20);
  	return 0;
  }
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
540
  static int philips_tda827x_tuner_init(struct dvb_frontend *fe)
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
541
  {
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
542
  	struct saa7134_dev *dev = fe->dvb->priv;
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
543
  	struct tda1004x_state *state = fe->demodulator_priv;
8ce47dad8   Michael Krufky   V4L/DVB (5317): C...
544

58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
545
546
547
548
549
550
551
552
553
554
  	switch (state->config->antenna_switch) {
  	case 0: break;
  	case 1:	dprintk("setting GPIO21 to 0 (TV antenna?)
  ");
  		saa7134_set_gpio(dev, 21, 0);
  		break;
  	case 2: dprintk("setting GPIO21 to 1 (Radio antenna?)
  ");
  		saa7134_set_gpio(dev, 21, 1);
  		break;
587d2fd7f   Hartmut Hackmann   V4L/DVB (4726): A...
555
  	}
587d2fd7f   Hartmut Hackmann   V4L/DVB (4726): A...
556
557
  	return 0;
  }
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
558
  static int philips_tda827x_tuner_sleep(struct dvb_frontend *fe)
587d2fd7f   Hartmut Hackmann   V4L/DVB (4726): A...
559
  {
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
560
561
  	struct saa7134_dev *dev = fe->dvb->priv;
  	struct tda1004x_state *state = fe->demodulator_priv;
8ce47dad8   Michael Krufky   V4L/DVB (5317): C...
562

58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
563
564
565
566
567
568
569
570
571
572
573
  	switch (state->config->antenna_switch) {
  	case 0: break;
  	case 1: dprintk("setting GPIO21 to 1 (Radio antenna?)
  ");
  		saa7134_set_gpio(dev, 21, 1);
  		break;
  	case 2:	dprintk("setting GPIO21 to 0 (TV antenna?)
  ");
  		saa7134_set_gpio(dev, 21, 0);
  		break;
  	}
587d2fd7f   Hartmut Hackmann   V4L/DVB (4726): A...
574
  	return 0;
2d6b5f625   Hartmut Hackmann   V4L/DVB (3401): C...
575
  }
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
576

d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
577
578
579
  static int configure_tda827x_fe(struct saa7134_dev *dev,
  				struct tda1004x_config *cdec_conf,
  				struct tda827x_config *tuner_conf)
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
580
  {
363c35fc4   Steven Toth   V4L/DVB (9222): S...
581
  	struct videobuf_dvb_frontend *fe0;
92abe9ee3   Darron Broad   V4L/DVB (9223): M...
582
583
  	/* Get the first frontend */
  	fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
584
585
586
  
  	fe0->dvb.frontend = dvb_attach(tda10046_attach, cdec_conf, &dev->i2c_adap);
  	if (fe0->dvb.frontend) {
7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
587
  		if (cdec_conf->i2c_gate)
363c35fc4   Steven Toth   V4L/DVB (9222): S...
588
589
  			fe0->dvb.frontend->ops.i2c_gate_ctrl = tda8290_i2c_gate_ctrl;
  		if (dvb_attach(tda827x_attach, fe0->dvb.frontend,
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
590
591
592
593
594
595
  			       cdec_conf->tuner_address,
  			       &dev->i2c_adap, tuner_conf))
  			return 0;
  
  		wprintk("no tda827x tuner found at addr: %02x
  ",
7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
596
  				cdec_conf->tuner_address);
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
597
  	}
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
598
  	return -EINVAL;
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
599
  }
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
600
  /* ------------------------------------------------------------------ */
261f5081a   Edgar Simo   V4L/DVB (6071): s...
601

7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
602
  static struct tda827x_config tda827x_cfg_0 = {
7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
603
604
605
606
607
608
609
  	.init = philips_tda827x_tuner_init,
  	.sleep = philips_tda827x_tuner_sleep,
  	.config = 0,
  	.switch_addr = 0
  };
  
  static struct tda827x_config tda827x_cfg_1 = {
7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
610
611
612
613
614
615
616
  	.init = philips_tda827x_tuner_init,
  	.sleep = philips_tda827x_tuner_sleep,
  	.config = 1,
  	.switch_addr = 0x4b
  };
  
  static struct tda827x_config tda827x_cfg_2 = {
7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
617
618
619
620
621
622
623
  	.init = philips_tda827x_tuner_init,
  	.sleep = philips_tda827x_tuner_sleep,
  	.config = 2,
  	.switch_addr = 0x4b
  };
  
  static struct tda827x_config tda827x_cfg_2_sw42 = {
7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
624
625
626
627
628
629
630
  	.init = philips_tda827x_tuner_init,
  	.sleep = philips_tda827x_tuner_sleep,
  	.config = 2,
  	.switch_addr = 0x42
  };
  
  /* ------------------------------------------------------------------ */
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
631
  static struct tda1004x_config tda827x_lifeview_config = {
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
632
633
634
635
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
1bb0e8667   Hartmut Hackmann   V4L/DVB (5311): T...
636
637
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP11_I,
550a9a5e5   Hartmut Hackmann   V4L/DVB (4835): A...
638
  	.if_freq       = TDA10046_FREQ_045,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
639
640
  	.tuner_address = 0x60,
  	.request_firmware = philips_tda1004x_request_firmware
550a9a5e5   Hartmut Hackmann   V4L/DVB (4835): A...
641
  };
550a9a5e5   Hartmut Hackmann   V4L/DVB (4835): A...
642

58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
643
644
645
646
647
648
649
650
651
652
  static struct tda1004x_config philips_tiger_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP11_I,
  	.if_freq       = TDA10046_FREQ_045,
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
653
654
655
  	.antenna_switch= 1,
  	.request_firmware = philips_tda1004x_request_firmware
  };
550a9a5e5   Hartmut Hackmann   V4L/DVB (4835): A...
656
657
658
659
660
661
  
  static struct tda1004x_config cinergy_ht_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
1bb0e8667   Hartmut Hackmann   V4L/DVB (5311): T...
662
663
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP01_I,
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
664
  	.if_freq       = TDA10046_FREQ_045,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
665
666
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
667
  	.request_firmware = philips_tda1004x_request_firmware
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
668
  };
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
669
670
671
672
673
674
675
676
677
678
  static struct tda1004x_config cinergy_ht_pci_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP01_I,
  	.if_freq       = TDA10046_FREQ_045,
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x60,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
679
680
681
682
683
684
685
686
687
688
689
690
691
  	.request_firmware = philips_tda1004x_request_firmware
  };
  
  static struct tda1004x_config philips_tiger_s_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP01_I,
  	.if_freq       = TDA10046_FREQ_045,
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
692
693
694
  	.antenna_switch= 1,
  	.request_firmware = philips_tda1004x_request_firmware
  };
df42eaf2b   Hartmut Hackmann   V4L/DVB (3305): A...
695

587d2fd7f   Hartmut Hackmann   V4L/DVB (4726): A...
696
697
698
699
700
  static struct tda1004x_config pinnacle_pctv_310i_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
1bb0e8667   Hartmut Hackmann   V4L/DVB (5311): T...
701
702
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP11_I,
587d2fd7f   Hartmut Hackmann   V4L/DVB (4726): A...
703
  	.if_freq       = TDA10046_FREQ_045,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
704
705
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
706
  	.request_firmware = philips_tda1004x_request_firmware
587d2fd7f   Hartmut Hackmann   V4L/DVB (4726): A...
707
  };
c6e53daff   Thomas Genty   V4L/DVB (4806): S...
708
709
710
711
712
  static struct tda1004x_config hauppauge_hvr_1110_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
1bb0e8667   Hartmut Hackmann   V4L/DVB (5311): T...
713
714
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP11_I,
c6e53daff   Thomas Genty   V4L/DVB (4806): S...
715
  	.if_freq       = TDA10046_FREQ_045,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
716
717
718
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
  	.request_firmware = philips_tda1004x_request_firmware
c6e53daff   Thomas Genty   V4L/DVB (4806): S...
719
  };
836468176   Hartmut Hackmann   V4L/DVB (4769): A...
720
721
722
723
724
  static struct tda1004x_config asus_p7131_dual_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
1bb0e8667   Hartmut Hackmann   V4L/DVB (5311): T...
725
726
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP11_I,
836468176   Hartmut Hackmann   V4L/DVB (4769): A...
727
  	.if_freq       = TDA10046_FREQ_045,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
728
729
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
730
731
  	.antenna_switch= 2,
  	.request_firmware = philips_tda1004x_request_firmware
836468176   Hartmut Hackmann   V4L/DVB (4769): A...
732
  };
420f32fe4   Nico Sabbi   V4L/DVB (3396): A...
733
734
735
736
737
  static struct tda1004x_config lifeview_trio_config = {
  	.demod_address = 0x09,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
1bb0e8667   Hartmut Hackmann   V4L/DVB (5311): T...
738
739
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP00_I,
420f32fe4   Nico Sabbi   V4L/DVB (3396): A...
740
  	.if_freq       = TDA10046_FREQ_045,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
741
742
  	.tuner_address = 0x60,
  	.request_firmware = philips_tda1004x_request_firmware
420f32fe4   Nico Sabbi   V4L/DVB (3396): A...
743
  };
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
744
  static struct tda1004x_config tevion_dvbt220rf_config = {
df42eaf2b   Hartmut Hackmann   V4L/DVB (3305): A...
745
746
747
748
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
1bb0e8667   Hartmut Hackmann   V4L/DVB (5311): T...
749
  	.agc_config    = TDA10046_AGC_TDA827X,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
750
  	.gpio_config   = TDA10046_GP11_I,
df42eaf2b   Hartmut Hackmann   V4L/DVB (3305): A...
751
  	.if_freq       = TDA10046_FREQ_045,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
752
753
  	.tuner_address = 0x60,
  	.request_firmware = philips_tda1004x_request_firmware
df42eaf2b   Hartmut Hackmann   V4L/DVB (3305): A...
754
  };
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
755
  static struct tda1004x_config md8800_dvbt_config = {
3dfb729f4   Peter Hartshorn   V4L/DVB (3315): A...
756
757
758
759
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
1bb0e8667   Hartmut Hackmann   V4L/DVB (5311): T...
760
  	.agc_config    = TDA10046_AGC_TDA827X,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
761
  	.gpio_config   = TDA10046_GP01_I,
3dfb729f4   Peter Hartshorn   V4L/DVB (3315): A...
762
  	.if_freq       = TDA10046_FREQ_045,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
763
764
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x60,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
765
  	.request_firmware = philips_tda1004x_request_firmware
3dfb729f4   Peter Hartshorn   V4L/DVB (3315): A...
766
  };
e06cea4cb   Hartmut Hackmann   V4L/DVB (5445): A...
767
768
769
770
771
772
773
774
775
776
  static struct tda1004x_config asus_p7131_4871_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP01_I,
  	.if_freq       = TDA10046_FREQ_045,
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
e06cea4cb   Hartmut Hackmann   V4L/DVB (5445): A...
777
778
779
  	.antenna_switch= 2,
  	.request_firmware = philips_tda1004x_request_firmware
  };
f3eec0c00   Hartmut Hackmann   V4L/DVB (5446): R...
780
  static struct tda1004x_config asus_p7131_hybrid_lna_config = {
e06cea4cb   Hartmut Hackmann   V4L/DVB (5445): A...
781
782
783
784
785
786
787
788
789
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP11_I,
  	.if_freq       = TDA10046_FREQ_045,
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
e06cea4cb   Hartmut Hackmann   V4L/DVB (5445): A...
790
791
792
  	.antenna_switch= 2,
  	.request_firmware = philips_tda1004x_request_firmware
  };
261f5081a   Edgar Simo   V4L/DVB (6071): s...
793

b39423a95   Simon Farnsworth   V4L/DVB (5580): A...
794
795
796
797
798
799
800
801
802
803
  static struct tda1004x_config kworld_dvb_t_210_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP11_I,
  	.if_freq       = TDA10046_FREQ_045,
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
b39423a95   Simon Farnsworth   V4L/DVB (5580): A...
804
805
806
  	.antenna_switch= 1,
  	.request_firmware = philips_tda1004x_request_firmware
  };
261f5081a   Edgar Simo   V4L/DVB (6071): s...
807

d90d9f5a0   Edgar Simo   V4L/DVB (6072): s...
808
809
810
811
812
813
814
815
816
817
  static struct tda1004x_config avermedia_super_007_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP01_I,
  	.if_freq       = TDA10046_FREQ_045,
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x60,
d90d9f5a0   Edgar Simo   V4L/DVB (6072): s...
818
819
820
  	.antenna_switch= 1,
  	.request_firmware = philips_tda1004x_request_firmware
  };
4ba243734   Hermann Pitton   V4L/DVB (7082): s...
821
822
823
824
825
826
827
828
829
830
  static struct tda1004x_config twinhan_dtv_dvb_3056_config = {
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP01_I,
  	.if_freq       = TDA10046_FREQ_045,
  	.i2c_gate      = 0x42,
  	.tuner_address = 0x61,
4ba243734   Hermann Pitton   V4L/DVB (7082): s...
831
832
833
  	.antenna_switch = 1,
  	.request_firmware = philips_tda1004x_request_firmware
  };
301e9d64e   hermann pitton   V4L/DVB (9028): s...
834
835
836
837
838
839
840
841
842
843
844
845
846
  static struct tda1004x_config asus_tiger_3in1_config = {
  	.demod_address = 0x0b,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
  	.agc_config    = TDA10046_AGC_TDA827X,
  	.gpio_config   = TDA10046_GP11_I,
  	.if_freq       = TDA10046_FREQ_045,
  	.i2c_gate      = 0x4b,
  	.tuner_address = 0x61,
  	.antenna_switch = 1,
  	.request_firmware = philips_tda1004x_request_firmware
  };
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
847
848
849
  /* ------------------------------------------------------------------
   * special case: this card uses saa713x GPIO22 for the mode switch
   */
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
850

58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
851
  static int ads_duo_tuner_init(struct dvb_frontend *fe)
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
852
853
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
854
855
  	philips_tda827x_tuner_init(fe);
  	/* route TDA8275a AGC input to the channel decoder */
06be3035f   Hartmut Hackmann   V4L/DVB (5318): F...
856
  	saa7134_set_gpio(dev, 22, 1);
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
857
858
  	return 0;
  }
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
859
  static int ads_duo_tuner_sleep(struct dvb_frontend *fe)
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
860
  {
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
861
  	struct saa7134_dev *dev = fe->dvb->priv;
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
862
  	/* route TDA8275a AGC input to the analog IF chip*/
06be3035f   Hartmut Hackmann   V4L/DVB (5318): F...
863
  	saa7134_set_gpio(dev, 22, 0);
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
864
865
  	philips_tda827x_tuner_sleep(fe);
  	return 0;
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
866
  }
8ce47dad8   Michael Krufky   V4L/DVB (5317): C...
867
  static struct tda827x_config ads_duo_cfg = {
8ce47dad8   Michael Krufky   V4L/DVB (5317): C...
868
  	.init = ads_duo_tuner_init,
7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
869
870
  	.sleep = ads_duo_tuner_sleep,
  	.config = 0
8ce47dad8   Michael Krufky   V4L/DVB (5317): C...
871
  };
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
872
  static struct tda1004x_config ads_tech_duo_config = {
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
873
874
875
876
  	.demod_address = 0x08,
  	.invert        = 1,
  	.invert_oclk   = 0,
  	.xtal_freq     = TDA10046_XTAL_16M,
1bb0e8667   Hartmut Hackmann   V4L/DVB (5311): T...
877
  	.agc_config    = TDA10046_AGC_TDA827X,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
878
  	.gpio_config   = TDA10046_GP00_I,
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
879
  	.if_freq       = TDA10046_FREQ_045,
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
880
881
  	.tuner_address = 0x61,
  	.request_firmware = philips_tda1004x_request_firmware
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
882
  };
47aeba5ad   Dmitri Belimov   V4L/DVB (10153): ...
883
884
885
886
  static struct zl10353_config behold_h6_config = {
  	.demod_address = 0x1e>>1,
  	.no_tuner      = 1,
  	.parallel_ts   = 1,
5f77af932   Antti Palosaari   V4L/DVB (10972): ...
887
  	.disable_i2c_gate_ctrl = 1,
47aeba5ad   Dmitri Belimov   V4L/DVB (10153): ...
888
  };
2930992c4   Beholder Intl. Ltd. Dmitry Belimov   V4L/DVB (13080): ...
889
890
891
  static struct xc5000_config behold_x7_tunerconfig = {
  	.i2c_address      = 0xc2>>1,
  	.if_khz           = 4560,
2a0d05601   Devin Heitmueller   V4L/DVB (13081): ...
892
  	.radio_input      = XC5000_RADIO_FM1,
2930992c4   Beholder Intl. Ltd. Dmitry Belimov   V4L/DVB (13080): ...
893
894
895
896
897
898
899
900
901
  };
  
  static struct zl10353_config behold_x7_config = {
  	.demod_address = 0x1e>>1,
  	.if2           = 45600,
  	.no_tuner      = 1,
  	.parallel_ts   = 1,
  	.disable_i2c_gate_ctrl = 1,
  };
dbe8740dd   Carlos Corbacho   [media] Make Comp...
902
903
904
905
906
907
908
909
910
911
  static struct zl10353_config videomate_t750_zl10353_config = {
  	.demod_address         = 0x0f,
  	.no_tuner              = 1,
  	.parallel_ts           = 1,
  	.disable_i2c_gate_ctrl = 1,
  };
  
  static struct qt1010_config videomate_t750_qt1010_config = {
  	.i2c_address = 0x62
  };
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
912
913
914
  /* ==================================================================
   * tda10086 based DVB-S cards, helper functions
   */
e2ac28fa1   Igor M. Liplianin   V4L/DVB (4398): A...
915
916
917
  static struct tda10086_config flydvbs = {
  	.demod_address = 0x0e,
  	.invert = 0,
ea75baf4b   Hartmut Hackmann   V4L/DVB (7186): t...
918
  	.diseqc_tone = 0,
9a1b04e46   Hartmut Hackmann   V4L/DVB (7654): t...
919
920
921
922
923
924
925
926
  	.xtal_freq = TDA10086_XTAL_16M,
  };
  
  static struct tda10086_config sd1878_4m = {
  	.demod_address = 0x0e,
  	.invert = 0,
  	.diseqc_tone = 0,
  	.xtal_freq = TDA10086_XTAL_4M,
e2ac28fa1   Igor M. Liplianin   V4L/DVB (4398): A...
927
  };
1b1cee35d   Hartmut Hackmann   V4L/DVB (7227): s...
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
  /* ------------------------------------------------------------------
   * special case: lnb supply is connected to the gated i2c
   */
  
  static int md8800_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  {
  	int res = -EIO;
  	struct saa7134_dev *dev = fe->dvb->priv;
  	if (fe->ops.i2c_gate_ctrl) {
  		fe->ops.i2c_gate_ctrl(fe, 1);
  		if (dev->original_set_voltage)
  			res = dev->original_set_voltage(fe, voltage);
  		fe->ops.i2c_gate_ctrl(fe, 0);
  	}
  	return res;
  };
  
  static int md8800_set_high_voltage(struct dvb_frontend *fe, long arg)
  {
  	int res = -EIO;
  	struct saa7134_dev *dev = fe->dvb->priv;
  	if (fe->ops.i2c_gate_ctrl) {
  		fe->ops.i2c_gate_ctrl(fe, 1);
  		if (dev->original_set_high_voltage)
  			res = dev->original_set_high_voltage(fe, arg);
  		fe->ops.i2c_gate_ctrl(fe, 0);
  	}
  	return res;
  };
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
  static int md8800_set_voltage2(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
  	u8 wbuf[2] = { 0x1f, 00 };
  	u8 rbuf;
  	struct i2c_msg msg[] = { { .addr = 0x08, .flags = 0, .buf = wbuf, .len = 1 },
  				 { .addr = 0x08, .flags = I2C_M_RD, .buf = &rbuf, .len = 1 } };
  
  	if (i2c_transfer(&dev->i2c_adap, msg, 2) != 2)
  		return -EIO;
  	/* NOTE: this assumes that gpo1 is used, it might be bit 5 (gpo2) */
  	if (voltage == SEC_VOLTAGE_18)
  		wbuf[1] = rbuf | 0x10;
  	else
  		wbuf[1] = rbuf & 0xef;
  	msg[0].len = 2;
  	i2c_transfer(&dev->i2c_adap, msg, 1);
  	return 0;
  }
  
  static int md8800_set_high_voltage2(struct dvb_frontend *fe, long arg)
  {
  	struct saa7134_dev *dev = fe->dvb->priv;
  	wprintk("%s: sorry can't set high LNB supply voltage from here
  ", __func__);
  	return -EIO;
  }
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
984
985
986
  /* ==================================================================
   * nxt200x based ATSC cards, helper functions
   */
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
987

3b64e8e23   Michael Krufky   [PATCH] v4l: 870:...
988
989
  static struct nxt200x_config avertvhda180 = {
  	.demod_address    = 0x0a,
3b64e8e23   Michael Krufky   [PATCH] v4l: 870:...
990
  };
3e1410adc   Andrew Burri   V4L/DVB (3361): A...
991
992
993
  
  static struct nxt200x_config kworldatsc110 = {
  	.demod_address    = 0x0a,
3e1410adc   Andrew Burri   V4L/DVB (3361): A...
994
  };
3b64e8e23   Michael Krufky   [PATCH] v4l: 870:...
995

04574185a   Matthias Schwarzott   V4L/DVB (10823): ...
996
997
998
999
1000
1001
1002
1003
1004
1005
  /* ------------------------------------------------------------------ */
  
  static struct mt312_config avertv_a700_mt312 = {
  	.demod_address = 0x0e,
  	.voltage_inverted = 1,
  };
  
  static struct zl10036_config avertv_a700_tuner = {
  	.tuner_address = 0x60,
  };
ecfcfec80   Igor M. Liplianin   V4L/DVB (12463): ...
1006
1007
1008
  static struct mt312_config zl10313_compro_s350_config = {
  	.demod_address = 0x0e,
  };
3abdedd8a   Michael Krufky   V4L/DVB (10926): ...
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
  static struct lgdt3305_config hcw_lgdt3305_config = {
  	.i2c_addr           = 0x0e,
  	.mpeg_mode          = LGDT3305_MPEG_SERIAL,
  	.tpclk_edge         = LGDT3305_TPCLK_RISING_EDGE,
  	.tpvalid_polarity   = LGDT3305_TP_VALID_HIGH,
  	.deny_i2c_rptr      = 1,
  	.spectral_inversion = 1,
  	.qam_if_khz         = 4000,
  	.vsb_if_khz         = 3250,
  };
1bc7f51c5   Michael Krufky   V4L/DVB (11861): ...
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
  static struct tda10048_config hcw_tda10048_config = {
  	.demod_address    = 0x10 >> 1,
  	.output_mode      = TDA10048_SERIAL_OUTPUT,
  	.fwbulkwritelen   = TDA10048_BULKWRITE_200,
  	.inversion        = TDA10048_INVERSION_ON,
  	.dtv6_if_freq_khz = TDA10048_IF_3300,
  	.dtv7_if_freq_khz = TDA10048_IF_3500,
  	.dtv8_if_freq_khz = TDA10048_IF_4000,
  	.clk_freq_khz     = TDA10048_CLK_16000,
  	.disable_gate_access = 1,
  };
3abdedd8a   Michael Krufky   V4L/DVB (10926): ...
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
  static struct tda18271_std_map hauppauge_tda18271_std_map = {
  	.atsc_6   = { .if_freq = 3250, .agc_mode = 3, .std = 4,
  		      .if_lvl = 1, .rfagc_top = 0x58, },
  	.qam_6    = { .if_freq = 4000, .agc_mode = 3, .std = 5,
  		      .if_lvl = 1, .rfagc_top = 0x58, },
  };
  
  static struct tda18271_config hcw_tda18271_config = {
  	.std_map = &hauppauge_tda18271_std_map,
  	.gate    = TDA18271_GATE_ANALOG,
  	.config  = 3,
542cb0573   Michael Krufky   V4L/DVB (12873): ...
1041
  	.output_opt = TDA18271_OUTPUT_LT_OFF,
3abdedd8a   Michael Krufky   V4L/DVB (10926): ...
1042
1043
1044
1045
1046
  };
  
  static struct tda829x_config tda829x_no_probe = {
  	.probe_tuner = TDA829X_DONT_PROBE,
  };
6c119ff49   Henk Vergonet   V4L/DVB (13002): ...
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
  static struct tda10048_config zolid_tda10048_config = {
  	.demod_address    = 0x10 >> 1,
  	.output_mode      = TDA10048_PARALLEL_OUTPUT,
  	.fwbulkwritelen   = TDA10048_BULKWRITE_200,
  	.inversion        = TDA10048_INVERSION_ON,
  	.dtv6_if_freq_khz = TDA10048_IF_3300,
  	.dtv7_if_freq_khz = TDA10048_IF_3500,
  	.dtv8_if_freq_khz = TDA10048_IF_4000,
  	.clk_freq_khz     = TDA10048_CLK_16000,
  	.disable_gate_access = 1,
  };
  
  static struct tda18271_config zolid_tda18271_config = {
  	.gate    = TDA18271_GATE_ANALOG,
  };
184e769f9   Michael Krufky   V4L/DVB (13204): ...
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
  static struct tda10048_config dtv1000s_tda10048_config = {
  	.demod_address    = 0x10 >> 1,
  	.output_mode      = TDA10048_PARALLEL_OUTPUT,
  	.fwbulkwritelen   = TDA10048_BULKWRITE_200,
  	.inversion        = TDA10048_INVERSION_ON,
  	.dtv6_if_freq_khz = TDA10048_IF_3300,
  	.dtv7_if_freq_khz = TDA10048_IF_3800,
  	.dtv8_if_freq_khz = TDA10048_IF_4300,
  	.clk_freq_khz     = TDA10048_CLK_16000,
  	.disable_gate_access = 1,
  };
  
  static struct tda18271_std_map dtv1000s_tda18271_std_map = {
  	.dvbt_6   = { .if_freq = 3300, .agc_mode = 3, .std = 4,
  		      .if_lvl = 1, .rfagc_top = 0x37, },
  	.dvbt_7   = { .if_freq = 3800, .agc_mode = 3, .std = 5,
  		      .if_lvl = 1, .rfagc_top = 0x37, },
  	.dvbt_8   = { .if_freq = 4300, .agc_mode = 3, .std = 6,
  		      .if_lvl = 1, .rfagc_top = 0x37, },
  };
  
  static struct tda18271_config dtv1000s_tda18271_config = {
  	.std_map = &dtv1000s_tda18271_std_map,
  	.gate    = TDA18271_GATE_ANALOG,
  };
ce02704d4   Timothy Lee   [media] saa7134: ...
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
  static struct lgs8gxx_config prohdtv_pro2_lgs8g75_config = {
  	.prod = LGS8GXX_PROD_LGS8G75,
  	.demod_address = 0x1d,
  	.serial_ts = 0,
  	.ts_clk_pol = 1,
  	.ts_clk_gated = 0,
  	.if_clk_freq = 30400, /* 30.4 MHz */
  	.if_freq = 4000, /* 4.00 MHz */
  	.if_neg_center = 0,
  	.ext_adc = 0,
  	.adc_signed = 1,
  	.adc_vpp = 3, /* 2.0 Vpp */
  	.if_neg_edge = 1,
  };
  
  static struct tda18271_config prohdtv_pro2_tda18271_config = {
  	.gate = TDA18271_GATE_ANALOG,
  	.output_opt = TDA18271_OUTPUT_LT_OFF,
  };
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
1106
1107
1108
  /* ==================================================================
   * Core code
   */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1109
1110
1111
  
  static int dvb_init(struct saa7134_dev *dev)
  {
1c4f76abb   Hartmut Hackmann   V4L/DVB (5321): S...
1112
  	int ret;
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
1113
  	int attach_xc3028 = 0;
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1114
  	struct videobuf_dvb_frontend *fe0;
f972e0bd9   Darron Broad   V4L/DVB (9224): M...
1115
1116
  	/* FIXME: add support for multi-frontend */
  	mutex_init(&dev->frontends.lock);
7bdf84fc4   Darron Broad   V4L/DVB (9265): v...
1117
  	INIT_LIST_HEAD(&dev->frontends.felist);
f972e0bd9   Darron Broad   V4L/DVB (9224): M...
1118
1119
1120
  
  	printk(KERN_INFO "%s() allocating 1 frontend
  ", __func__);
f3f741e71   Darron Broad   V4L/DVB (9577): s...
1121
1122
  	fe0 = videobuf_dvb_alloc_frontend(&dev->frontends, 1);
  	if (!fe0) {
f972e0bd9   Darron Broad   V4L/DVB (9224): M...
1123
1124
1125
1126
  		printk(KERN_ERR "%s() failed to alloc
  ", __func__);
  		return -ENOMEM;
  	}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1127
1128
1129
  	/* init struct videobuf_dvb */
  	dev->ts.nr_bufs    = 32;
  	dev->ts.nr_packets = 32*4;
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1130
1131
  	fe0->dvb.name = dev->name;
  	videobuf_queue_sg_init(&fe0->dvb.dvbq, &saa7134_ts_qops,
0705135e5   Guennadi Liakhovetski   V4L/DVB (7237): C...
1132
  			    &dev->pci->dev, &dev->slock,
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1133
1134
1135
  			    V4L2_BUF_TYPE_VIDEO_CAPTURE,
  			    V4L2_FIELD_ALTERNATE,
  			    sizeof(struct saa7134_buf),
08bff03ed   Hans Verkuil   V4L/DVB: videobuf...
1136
  			    dev, NULL);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1137
1138
1139
  
  	switch (dev->board) {
  	case SAA7134_BOARD_PINNACLE_300I_DVBT_PAL:
cf3c34c87   Trent Piepho   V4L/DVB (5391): S...
1140
1141
  		dprintk("pinnacle 300i dvb setup
  ");
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1142
  		fe0->dvb.frontend = dvb_attach(mt352_attach, &pinnacle_300i,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1143
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1144
1145
  		if (fe0->dvb.frontend) {
  			fe0->dvb.frontend->ops.tuner_ops.set_params = mt352_pinnacle_tuner_set_params;
6b3ccab75   Andrew de Quincey   V4L/DVB (3895): A...
1146
  		}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1147
  		break;
a78d0bfab   Jose Alberto Reguero   V4L/DVB (3267): A...
1148
  	case SAA7134_BOARD_AVERMEDIA_777:
515c208db   Petr Baudis   V4L/DVB (4671): S...
1149
  	case SAA7134_BOARD_AVERMEDIA_A16AR:
cf3c34c87   Trent Piepho   V4L/DVB (5391): S...
1150
1151
  		dprintk("avertv 777 dvb setup
  ");
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1152
  		fe0->dvb.frontend = dvb_attach(mt352_attach, &avermedia_777,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1153
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1154
1155
  		if (fe0->dvb.frontend) {
  			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
fb147e975   Michael Krufky   V4L/DVB (7414): u...
1156
1157
  				   &dev->i2c_adap, 0x61,
  				   TUNER_PHILIPS_TD1316);
6b3ccab75   Andrew de Quincey   V4L/DVB (3895): A...
1158
  		}
a78d0bfab   Jose Alberto Reguero   V4L/DVB (3267): A...
1159
  		break;
95a2fdb6f   Mauro Carvalho Chehab   V4L/DVB (7458): s...
1160
  	case SAA7134_BOARD_AVERMEDIA_A16D:
6e501a3f4   Tim Farrington   V4L/DVB (8048): s...
1161
1162
  		dprintk("AverMedia A16D dvb setup
  ");
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1163
  		fe0->dvb.frontend = dvb_attach(mt352_attach,
6e501a3f4   Tim Farrington   V4L/DVB (8048): s...
1164
1165
  						&avermedia_xc3028_mt352_dev,
  						&dev->i2c_adap);
95a2fdb6f   Mauro Carvalho Chehab   V4L/DVB (7458): s...
1166
1167
  		attach_xc3028 = 1;
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1168
  	case SAA7134_BOARD_MD7134:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1169
  		fe0->dvb.frontend = dvb_attach(tda10046_attach,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1170
1171
  					       &medion_cardbus,
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1172
1173
  		if (fe0->dvb.frontend) {
  			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
cb89cd332   Michael Krufky   V4L/DVB (7413): u...
1174
1175
  				   &dev->i2c_adap, medion_cardbus.tuner_address,
  				   TUNER_PHILIPS_FMD1216ME_MK3);
6b3ccab75   Andrew de Quincey   V4L/DVB (3895): A...
1176
  		}
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1177
  		break;
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
1178
  	case SAA7134_BOARD_PHILIPS_TOUGH:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1179
  		fe0->dvb.frontend = dvb_attach(tda10046_attach,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1180
1181
  					       &philips_tu1216_60_config,
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1182
1183
1184
  		if (fe0->dvb.frontend) {
  			fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
6b3ccab75   Andrew de Quincey   V4L/DVB (3895): A...
1185
  		}
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
1186
1187
  		break;
  	case SAA7134_BOARD_FLYDVBTDUO:
10b7a9030   Peter Missel   V4L/DVB (3409): M...
1188
  	case SAA7134_BOARD_FLYDVBT_DUO_CARDBUS:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1189
1190
1191
  		if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
86ddd96fc   Mauro Carvalho Chehab   [PATCH] v4l: SAA7...
1192
  		break;
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
1193
  	case SAA7134_BOARD_PHILIPS_EUROPA:
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
1194
  	case SAA7134_BOARD_VIDEOMATE_DVBT_300:
e3c6e1aaa   Danny Wood   V4L/DVB (13168): ...
1195
  	case SAA7134_BOARD_ASUS_EUROPA_HYBRID:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1196
  		fe0->dvb.frontend = dvb_attach(tda10046_attach,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1197
1198
  					       &philips_europa_config,
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1199
1200
1201
1202
1203
1204
  		if (fe0->dvb.frontend) {
  			dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
  			fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  			fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  			fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
6b3ccab75   Andrew de Quincey   V4L/DVB (3895): A...
1205
  		}
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
1206
  		break;
128fe95d7   Vadim Catana   V4L/DVB: TechnoTr...
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
  	case SAA7134_BOARD_TECHNOTREND_BUDGET_T3000:
  		fe0->dvb.frontend = dvb_attach(tda10046_attach,
  					       &technotrend_budget_t3000_config,
  					       &dev->i2c_adap);
  		if (fe0->dvb.frontend) {
  			dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
  			fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
  			fe0->dvb.frontend->ops.tuner_ops.init = philips_europa_tuner_init;
  			fe0->dvb.frontend->ops.tuner_ops.sleep = philips_europa_tuner_sleep;
  			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
  		}
  		break;
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
1219
  	case SAA7134_BOARD_VIDEOMATE_DVBT_200:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1220
  		fe0->dvb.frontend = dvb_attach(tda10046_attach,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1221
1222
  					       &philips_tu1216_61_config,
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1223
1224
1225
  		if (fe0->dvb.frontend) {
  			fe0->dvb.frontend->ops.tuner_ops.init = philips_tu1216_init;
  			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_tda6651_pll_set;
6b3ccab75   Andrew de Quincey   V4L/DVB (3895): A...
1226
  		}
2cf36ac44   Hartmut Hackmann   [PATCH] v4l: 656:...
1227
  		break;
b39423a95   Simon Farnsworth   V4L/DVB (5580): A...
1228
  	case SAA7134_BOARD_KWORLD_DVBT_210:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1229
1230
1231
  		if (configure_tda827x_fe(dev, &kworld_dvb_t_210_config,
  					 &tda827x_cfg_2) < 0)
  			goto dettach_frontend;
b39423a95   Simon Farnsworth   V4L/DVB (5580): A...
1232
  		break;
0e316ecfc   Michael Krufky   V4L/DVB (12391): ...
1233
  	case SAA7134_BOARD_HAUPPAUGE_HVR1120:
1bc7f51c5   Michael Krufky   V4L/DVB (11861): ...
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
  		fe0->dvb.frontend = dvb_attach(tda10048_attach,
  					       &hcw_tda10048_config,
  					       &dev->i2c_adap);
  		if (fe0->dvb.frontend != NULL) {
  			dvb_attach(tda829x_attach, fe0->dvb.frontend,
  				   &dev->i2c_adap, 0x4b,
  				   &tda829x_no_probe);
  			dvb_attach(tda18271_attach, fe0->dvb.frontend,
  				   0x60, &dev->i2c_adap,
  				   &hcw_tda18271_config);
  		}
  		break;
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
1246
  	case SAA7134_BOARD_PHILIPS_TIGER:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1247
1248
1249
  		if (configure_tda827x_fe(dev, &philips_tiger_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
587d2fd7f   Hartmut Hackmann   V4L/DVB (4726): A...
1250
1251
  		break;
  	case SAA7134_BOARD_PINNACLE_PCTV_310i:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1252
1253
1254
  		if (configure_tda827x_fe(dev, &pinnacle_pctv_310i_config,
  					 &tda827x_cfg_1) < 0)
  			goto dettach_frontend;
90e9df7f1   Hartmut Hackmann   [PATCH] V4L: 904:...
1255
  		break;
c6e53daff   Thomas Genty   V4L/DVB (4806): S...
1256
  	case SAA7134_BOARD_HAUPPAUGE_HVR1110:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1257
1258
1259
  		if (configure_tda827x_fe(dev, &hauppauge_hvr_1110_config,
  					 &tda827x_cfg_1) < 0)
  			goto dettach_frontend;
c6e53daff   Thomas Genty   V4L/DVB (4806): S...
1260
  		break;
b5f05064b   Michael Krufky   V4L/DVB (12390): ...
1261
  	case SAA7134_BOARD_HAUPPAUGE_HVR1150:
3abdedd8a   Michael Krufky   V4L/DVB (10926): ...
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
  		fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
  					       &hcw_lgdt3305_config,
  					       &dev->i2c_adap);
  		if (fe0->dvb.frontend) {
  			dvb_attach(tda829x_attach, fe0->dvb.frontend,
  				   &dev->i2c_adap, 0x4b,
  				   &tda829x_no_probe);
  			dvb_attach(tda18271_attach, fe0->dvb.frontend,
  				   0x60, &dev->i2c_adap,
  				   &hcw_tda18271_config);
  		}
  		break;
d4b0aba47   Hartmut Hackmann   [PATCH] V4L: 908:...
1274
  	case SAA7134_BOARD_ASUSTeK_P7131_DUAL:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1275
1276
1277
  		if (configure_tda827x_fe(dev, &asus_p7131_dual_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
d4b0aba47   Hartmut Hackmann   [PATCH] V4L: 908:...
1278
  		break;
3d8466ece   Giampiero Giancipoli   V4L/DVB (3302): A...
1279
  	case SAA7134_BOARD_FLYDVBT_LR301:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1280
1281
1282
  		if (configure_tda827x_fe(dev, &tda827x_lifeview_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
3d8466ece   Giampiero Giancipoli   V4L/DVB (3302): A...
1283
  		break;
92abe9ee3   Darron Broad   V4L/DVB (9223): M...
1284
  	case SAA7134_BOARD_FLYDVB_TRIO:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1285
1286
1287
1288
  		if (!use_frontend) {	/* terrestrial */
  			if (configure_tda827x_fe(dev, &lifeview_trio_config,
  						 &tda827x_cfg_0) < 0)
  				goto dettach_frontend;
7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
1289
  		} else {  		/* satellite */
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1290
1291
1292
  			fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs, &dev->i2c_adap);
  			if (fe0->dvb.frontend) {
  				if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x63,
1f683cd8b   Nico Sabbi   V4L/DVB (4836): A...
1293
  									&dev->i2c_adap, 0) == NULL) {
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1294
1295
  					wprintk("%s: Lifeview Trio, No tda826x found!
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1296
  					goto dettach_frontend;
1f683cd8b   Nico Sabbi   V4L/DVB (4836): A...
1297
  				}
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1298
  				if (dvb_attach(isl6421_attach, fe0->dvb.frontend, &dev->i2c_adap,
1f683cd8b   Nico Sabbi   V4L/DVB (4836): A...
1299
  										0x08, 0, 0) == NULL) {
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1300
1301
  					wprintk("%s: Lifeview Trio, No ISL6421 found!
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1302
  					goto dettach_frontend;
1f683cd8b   Nico Sabbi   V4L/DVB (4836): A...
1303
1304
  				}
  			}
6b3ccab75   Andrew de Quincey   V4L/DVB (3895): A...
1305
  		}
420f32fe4   Nico Sabbi   V4L/DVB (3396): A...
1306
  		break;
df42eaf2b   Hartmut Hackmann   V4L/DVB (3305): A...
1307
  	case SAA7134_BOARD_ADS_DUO_CARDBUS_PTV331:
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
1308
  	case SAA7134_BOARD_FLYDVBT_HYBRID_CARDBUS:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1309
  		fe0->dvb.frontend = dvb_attach(tda10046_attach,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1310
1311
  					       &ads_tech_duo_config,
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1312
1313
  		if (fe0->dvb.frontend) {
  			if (dvb_attach(tda827x_attach,fe0->dvb.frontend,
7bff4b4d3   Hartmut Hackmann   V4L/DVB (7393): t...
1314
1315
  				   ads_tech_duo_config.tuner_address, &dev->i2c_adap,
  								&ads_duo_cfg) == NULL) {
cf3c34c87   Trent Piepho   V4L/DVB (5391): S...
1316
1317
  				wprintk("no tda827x tuner found at addr: %02x
  ",
ede2200d7   Hartmut Hackmann   V4L/DVB (5369): F...
1318
  					ads_tech_duo_config.tuner_address);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1319
  				goto dettach_frontend;
ede2200d7   Hartmut Hackmann   V4L/DVB (5369): F...
1320
  			}
bc36ec746   Mauro Carvalho Chehab   V4L/DVB (8028): I...
1321
1322
1323
  		} else
  			wprintk("failed to attach tda10046
  ");
df42eaf2b   Hartmut Hackmann   V4L/DVB (3305): A...
1324
  		break;
3dfb729f4   Peter Hartshorn   V4L/DVB (3315): A...
1325
  	case SAA7134_BOARD_TEVION_DVBT_220RF:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1326
1327
1328
  		if (configure_tda827x_fe(dev, &tevion_dvbt220rf_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
d95b8942e   Hartmut Hackmann   V4L/DVB (3646): A...
1329
  		break;
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
1330
  	case SAA7134_BOARD_MEDION_MD8800_QUADRO:
4b1431ca1   Hartmut Hackmann   V4L/DVB (7224): I...
1331
  		if (!use_frontend) {     /* terrestrial */
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1332
1333
1334
  			if (configure_tda827x_fe(dev, &md8800_dvbt_config,
  						 &tda827x_cfg_0) < 0)
  				goto dettach_frontend;
4b1431ca1   Hartmut Hackmann   V4L/DVB (7224): I...
1335
  		} else {        /* satellite */
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1336
  			fe0->dvb.frontend = dvb_attach(tda10086_attach,
4b1431ca1   Hartmut Hackmann   V4L/DVB (7224): I...
1337
  							&flydvbs, &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1338
1339
  			if (fe0->dvb.frontend) {
  				struct dvb_frontend *fe = fe0->dvb.frontend;
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1340
1341
1342
  				u8 dev_id = dev->eedata[2];
  				u8 data = 0xc4;
  				struct i2c_msg msg = {.addr = 0x08, .flags = 0, .len = 1};
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1343
  				if (dvb_attach(tda826x_attach, fe0->dvb.frontend,
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1344
  						0x60, &dev->i2c_adap, 0) == NULL) {
4b1431ca1   Hartmut Hackmann   V4L/DVB (7224): I...
1345
  					wprintk("%s: Medion Quadro, no tda826x "
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1346
1347
  						"found !
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1348
1349
  					goto dettach_frontend;
  				}
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1350
1351
1352
1353
  				if (dev_id != 0x08) {
  					/* we need to open the i2c gate (we know it exists) */
  					fe->ops.i2c_gate_ctrl(fe, 1);
  					if (dvb_attach(isl6405_attach, fe,
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1354
  							&dev->i2c_adap, 0x08, 0, 0) == NULL) {
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1355
1356
1357
  						wprintk("%s: Medion Quadro, no ISL6405 "
  							"found !
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1358
1359
  						goto dettach_frontend;
  					}
e9c1ac9d8   Hartmut Hackmann   V4L/DVB (7395): s...
1360
1361
1362
1363
1364
1365
  					if (dev_id == 0x07) {
  						/* fire up the 2nd section of the LNB supply since
  						   we can't do this from the other section */
  						msg.buf = &data;
  						i2c_transfer(&dev->i2c_adap, &msg, 1);
  					}
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1366
1367
1368
1369
1370
1371
1372
1373
1374
  					fe->ops.i2c_gate_ctrl(fe, 0);
  					dev->original_set_voltage = fe->ops.set_voltage;
  					fe->ops.set_voltage = md8800_set_voltage;
  					dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
  					fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
  				} else {
  					fe->ops.set_voltage = md8800_set_voltage2;
  					fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage2;
  				}
4b1431ca1   Hartmut Hackmann   V4L/DVB (7224): I...
1375
1376
  			}
  		}
5eda227fc   Hartmut Hackmann   V4L/DVB (4307): A...
1377
  		break;
3b64e8e23   Michael Krufky   [PATCH] v4l: 870:...
1378
  	case SAA7134_BOARD_AVERMEDIA_AVERTVHD_A180:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1379
  		fe0->dvb.frontend = dvb_attach(nxt200x_attach, &avertvhda180,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1380
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1381
1382
  		if (fe0->dvb.frontend)
  			dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x61,
47a9991e8   Michael Krufky   V4L/DVB (5780): D...
1383
  				   NULL, DVB_PLL_TDHU2);
3b64e8e23   Michael Krufky   [PATCH] v4l: 870:...
1384
  		break;
f689d9083   Adam Glover   V4L/DVB (9063): A...
1385
  	case SAA7134_BOARD_ADS_INSTANT_HDTV_PCI:
3e1410adc   Andrew Burri   V4L/DVB (3361): A...
1386
  	case SAA7134_BOARD_KWORLD_ATSC110:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1387
  		fe0->dvb.frontend = dvb_attach(nxt200x_attach, &kworldatsc110,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1388
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1389
1390
  		if (fe0->dvb.frontend)
  			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
62ff817a0   Michael Krufky   V4L/DVB (7415): u...
1391
1392
  				   &dev->i2c_adap, 0x61,
  				   TUNER_PHILIPS_TUV1236D);
3e1410adc   Andrew Burri   V4L/DVB (3361): A...
1393
  		break;
e2ac28fa1   Igor M. Liplianin   V4L/DVB (4398): A...
1394
  	case SAA7134_BOARD_FLYDVBS_LR300:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1395
  		fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1396
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1397
1398
  		if (fe0->dvb.frontend) {
  			if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1399
  				       &dev->i2c_adap, 0) == NULL) {
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1400
1401
  				wprintk("%s: No tda826x found!
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1402
  				goto dettach_frontend;
e2ac28fa1   Igor M. Liplianin   V4L/DVB (4398): A...
1403
  			}
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1404
  			if (dvb_attach(isl6421_attach, fe0->dvb.frontend,
f7b54b106   Michael Krufky   V4L/DVB (4439): W...
1405
  				       &dev->i2c_adap, 0x08, 0, 0) == NULL) {
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1406
1407
  				wprintk("%s: No ISL6421 found!
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1408
  				goto dettach_frontend;
e2ac28fa1   Igor M. Liplianin   V4L/DVB (4398): A...
1409
1410
1411
  			}
  		}
  		break;
cf146ca4c   Hartmut Hackmann   V4L/DVB (4703): A...
1412
  	case SAA7134_BOARD_ASUS_EUROPA2_HYBRID:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1413
  		fe0->dvb.frontend = dvb_attach(tda10046_attach,
0e8f4cc5c   Matthias Schwarzott   V4L/DVB (7097): s...
1414
1415
  					       &medion_cardbus,
  					       &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1416
1417
1418
  		if (fe0->dvb.frontend) {
  			dev->original_demod_sleep = fe0->dvb.frontend->ops.sleep;
  			fe0->dvb.frontend->ops.sleep = philips_europa_demod_sleep;
b7754d74d   Trent Piepho   V4L/DVB (5636): I...
1419

363c35fc4   Steven Toth   V4L/DVB (9222): S...
1420
  			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
cb89cd332   Michael Krufky   V4L/DVB (7413): u...
1421
1422
  				   &dev->i2c_adap, medion_cardbus.tuner_address,
  				   TUNER_PHILIPS_FMD1216ME_MK3);
cf146ca4c   Hartmut Hackmann   V4L/DVB (4703): A...
1423
1424
  		}
  		break;
cbb94521c   Hartmut Hackmann   V4L/DVB (4792): A...
1425
  	case SAA7134_BOARD_VIDEOMATE_DVBT_200A:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1426
  		fe0->dvb.frontend = dvb_attach(tda10046_attach,
cbb94521c   Hartmut Hackmann   V4L/DVB (4792): A...
1427
1428
  				&philips_europa_config,
  				&dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1429
1430
1431
  		if (fe0->dvb.frontend) {
  			fe0->dvb.frontend->ops.tuner_ops.init = philips_td1316_tuner_init;
  			fe0->dvb.frontend->ops.tuner_ops.set_params = philips_td1316_tuner_set_params;
cbb94521c   Hartmut Hackmann   V4L/DVB (4792): A...
1432
1433
  		}
  		break;
550a9a5e5   Hartmut Hackmann   V4L/DVB (4835): A...
1434
  	case SAA7134_BOARD_CINERGY_HT_PCMCIA:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1435
1436
1437
  		if (configure_tda827x_fe(dev, &cinergy_ht_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
550a9a5e5   Hartmut Hackmann   V4L/DVB (4835): A...
1438
  		break;
9de271e66   Michael Krufky   V4L/DVB (5111): S...
1439
  	case SAA7134_BOARD_CINERGY_HT_PCI:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1440
1441
1442
  		if (configure_tda827x_fe(dev, &cinergy_ht_pci_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
58ef4f924   Hartmut Hackmann   V4L/DVB (5314): A...
1443
1444
  		break;
  	case SAA7134_BOARD_PHILIPS_TIGER_S:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1445
1446
1447
  		if (configure_tda827x_fe(dev, &philips_tiger_s_config,
  					 &tda827x_cfg_2) < 0)
  			goto dettach_frontend;
9de271e66   Michael Krufky   V4L/DVB (5111): S...
1448
  		break;
e06cea4cb   Hartmut Hackmann   V4L/DVB (5445): A...
1449
  	case SAA7134_BOARD_ASUS_P7131_4871:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1450
1451
1452
  		if (configure_tda827x_fe(dev, &asus_p7131_4871_config,
  					 &tda827x_cfg_2) < 0)
  			goto dettach_frontend;
e06cea4cb   Hartmut Hackmann   V4L/DVB (5445): A...
1453
  		break;
f3eec0c00   Hartmut Hackmann   V4L/DVB (5446): R...
1454
  	case SAA7134_BOARD_ASUSTeK_P7131_HYBRID_LNA:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1455
1456
1457
  		if (configure_tda827x_fe(dev, &asus_p7131_hybrid_lna_config,
  					 &tda827x_cfg_2) < 0)
  			goto dettach_frontend;
e06cea4cb   Hartmut Hackmann   V4L/DVB (5445): A...
1458
  		break;
d90d9f5a0   Edgar Simo   V4L/DVB (6072): s...
1459
  	case SAA7134_BOARD_AVERMEDIA_SUPER_007:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1460
1461
1462
  		if (configure_tda827x_fe(dev, &avermedia_super_007_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
d90d9f5a0   Edgar Simo   V4L/DVB (6072): s...
1463
  		break;
4ba243734   Hermann Pitton   V4L/DVB (7082): s...
1464
  	case SAA7134_BOARD_TWINHAN_DTV_DVB_3056:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1465
1466
1467
  		if (configure_tda827x_fe(dev, &twinhan_dtv_dvb_3056_config,
  					 &tda827x_cfg_2_sw42) < 0)
  			goto dettach_frontend;
4ba243734   Hermann Pitton   V4L/DVB (7082): s...
1468
  		break;
6ab465a82   Hartmut Hackmann   V4L/DVB (7226): s...
1469
  	case SAA7134_BOARD_PHILIPS_SNAKE:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1470
  		fe0->dvb.frontend = dvb_attach(tda10086_attach, &flydvbs,
6ab465a82   Hartmut Hackmann   V4L/DVB (7226): s...
1471
  						&dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1472
1473
  		if (fe0->dvb.frontend) {
  			if (dvb_attach(tda826x_attach, fe0->dvb.frontend, 0x60,
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1474
  					&dev->i2c_adap, 0) == NULL) {
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1475
1476
  				wprintk("%s: No tda826x found!
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1477
1478
  				goto dettach_frontend;
  			}
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1479
  			if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1480
  					&dev->i2c_adap, 0, 0) == NULL) {
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1481
1482
  				wprintk("%s: No lnbp21 found!
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1483
1484
  				goto dettach_frontend;
  			}
6ab465a82   Hartmut Hackmann   V4L/DVB (7226): s...
1485
1486
  		}
  		break;
7b5b3f176   Hermann Pitton   V4L/DVB (7229): s...
1487
  	case SAA7134_BOARD_CREATIX_CTX953:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1488
1489
1490
  		if (configure_tda827x_fe(dev, &md8800_dvbt_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
7b5b3f176   Hermann Pitton   V4L/DVB (7229): s...
1491
  		break;
6a6179b6d   Russell Kliese   V4L/DVB (7230): s...
1492
  	case SAA7134_BOARD_MSI_TVANYWHERE_AD11:
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1493
1494
1495
  		if (configure_tda827x_fe(dev, &philips_tiger_s_config,
  					 &tda827x_cfg_2) < 0)
  			goto dettach_frontend;
6a6179b6d   Russell Kliese   V4L/DVB (7230): s...
1496
  		break;
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
1497
  	case SAA7134_BOARD_AVERMEDIA_CARDBUS_506:
6e501a3f4   Tim Farrington   V4L/DVB (8048): s...
1498
1499
1500
1501
1502
  		dprintk("AverMedia E506R dvb setup
  ");
  		saa7134_set_gpio(dev, 25, 0);
  		msleep(10);
  		saa7134_set_gpio(dev, 25, 1);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1503
  		fe0->dvb.frontend = dvb_attach(mt352_attach,
6e501a3f4   Tim Farrington   V4L/DVB (8048): s...
1504
1505
  						&avermedia_xc3028_mt352_dev,
  						&dev->i2c_adap);
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
1506
  		attach_xc3028 = 1;
e2fc00c21   Massimo Piccioni   V4L/DVB (8244): s...
1507
  		break;
637afdb56   Hartmut Hackmann   V4L/DVB (7391): s...
1508
  	case SAA7134_BOARD_MD7134_BRIDGE_2:
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1509
  		fe0->dvb.frontend = dvb_attach(tda10086_attach,
9a1b04e46   Hartmut Hackmann   V4L/DVB (7654): t...
1510
  						&sd1878_4m, &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1511
  		if (fe0->dvb.frontend) {
637afdb56   Hartmut Hackmann   V4L/DVB (7391): s...
1512
  			struct dvb_frontend *fe;
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1513
  			if (dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1514
  				  &dev->i2c_adap, DVB_PLL_PHILIPS_SD1878_TDA8261) == NULL) {
637afdb56   Hartmut Hackmann   V4L/DVB (7391): s...
1515
  				wprintk("%s: MD7134 DVB-S, no SD1878 "
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1516
1517
  					"found !
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1518
1519
  				goto dettach_frontend;
  			}
637afdb56   Hartmut Hackmann   V4L/DVB (7391): s...
1520
  			/* we need to open the i2c gate (we know it exists) */
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1521
  			fe = fe0->dvb.frontend;
637afdb56   Hartmut Hackmann   V4L/DVB (7391): s...
1522
1523
  			fe->ops.i2c_gate_ctrl(fe, 1);
  			if (dvb_attach(isl6405_attach, fe,
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1524
  					&dev->i2c_adap, 0x08, 0, 0) == NULL) {
637afdb56   Hartmut Hackmann   V4L/DVB (7391): s...
1525
  				wprintk("%s: MD7134 DVB-S, no ISL6405 "
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1526
1527
  					"found !
  ", __func__);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1528
1529
  				goto dettach_frontend;
  			}
637afdb56   Hartmut Hackmann   V4L/DVB (7391): s...
1530
1531
1532
1533
1534
1535
1536
  			fe->ops.i2c_gate_ctrl(fe, 0);
  			dev->original_set_voltage = fe->ops.set_voltage;
  			fe->ops.set_voltage = md8800_set_voltage;
  			dev->original_set_high_voltage = fe->ops.enable_high_lnb_voltage;
  			fe->ops.enable_high_lnb_voltage = md8800_set_high_voltage;
  		}
  		break;
e2fc00c21   Massimo Piccioni   V4L/DVB (8244): s...
1537
1538
1539
1540
  	case SAA7134_BOARD_AVERMEDIA_M103:
  		saa7134_set_gpio(dev, 25, 0);
  		msleep(10);
  		saa7134_set_gpio(dev, 25, 1);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1541
  		fe0->dvb.frontend = dvb_attach(mt352_attach,
e2fc00c21   Massimo Piccioni   V4L/DVB (8244): s...
1542
1543
1544
1545
  						&avermedia_xc3028_mt352_dev,
  						&dev->i2c_adap);
  		attach_xc3028 = 1;
  		break;
301e9d64e   hermann pitton   V4L/DVB (9028): s...
1546
1547
1548
1549
1550
1551
  	case SAA7134_BOARD_ASUSTeK_TIGER_3IN1:
  		if (!use_frontend) {     /* terrestrial */
  			if (configure_tda827x_fe(dev, &asus_tiger_3in1_config,
  							&tda827x_cfg_2) < 0)
  				goto dettach_frontend;
  		} else {  		/* satellite */
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1552
  			fe0->dvb.frontend = dvb_attach(tda10086_attach,
301e9d64e   hermann pitton   V4L/DVB (9028): s...
1553
  						&flydvbs, &dev->i2c_adap);
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1554
  			if (fe0->dvb.frontend) {
301e9d64e   hermann pitton   V4L/DVB (9028): s...
1555
  				if (dvb_attach(tda826x_attach,
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1556
  						fe0->dvb.frontend, 0x60,
301e9d64e   hermann pitton   V4L/DVB (9028): s...
1557
1558
1559
1560
1561
1562
  						&dev->i2c_adap, 0) == NULL) {
  					wprintk("%s: Asus Tiger 3in1, no "
  						"tda826x found!
  ", __func__);
  					goto dettach_frontend;
  				}
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1563
  				if (dvb_attach(lnbp21_attach, fe0->dvb.frontend,
301e9d64e   hermann pitton   V4L/DVB (9028): s...
1564
1565
1566
1567
1568
1569
1570
1571
1572
  						&dev->i2c_adap, 0, 0) == NULL) {
  					wprintk("%s: Asus Tiger 3in1, no lnbp21"
  						" found!
  ", __func__);
  					goto dettach_frontend;
  				}
  			}
  		}
  		break;
028165a33   Hermann Pitton   V4L/DVB (9113): s...
1573
1574
1575
1576
1577
  	case SAA7134_BOARD_ASUSTeK_TIGER:
  		if (configure_tda827x_fe(dev, &philips_tiger_config,
  					 &tda827x_cfg_0) < 0)
  			goto dettach_frontend;
  		break;
47aeba5ad   Dmitri Belimov   V4L/DVB (10153): ...
1578
  	case SAA7134_BOARD_BEHOLD_H6:
b0c4be8cf   Mauro Carvalho Chehab   V4L/DVB (10154): ...
1579
  		fe0->dvb.frontend = dvb_attach(zl10353_attach,
47aeba5ad   Dmitri Belimov   V4L/DVB (10153): ...
1580
1581
  						&behold_h6_config,
  						&dev->i2c_adap);
b0c4be8cf   Mauro Carvalho Chehab   V4L/DVB (10154): ...
1582
1583
  		if (fe0->dvb.frontend) {
  			dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
47aeba5ad   Dmitri Belimov   V4L/DVB (10153): ...
1584
  				   &dev->i2c_adap, 0x61,
4786dd65f   Beholder Intl. Ltd. Dmitry Belimov   V4L/DVB (12419): ...
1585
  				   TUNER_PHILIPS_FMD1216MEX_MK3);
47aeba5ad   Dmitri Belimov   V4L/DVB (10153): ...
1586
  		}
04574185a   Matthias Schwarzott   V4L/DVB (10823): ...
1587
  		break;
2930992c4   Beholder Intl. Ltd. Dmitry Belimov   V4L/DVB (13080): ...
1588
1589
1590
1591
1592
1593
1594
1595
1596
  	case SAA7134_BOARD_BEHOLD_X7:
  		fe0->dvb.frontend = dvb_attach(zl10353_attach,
  						&behold_x7_config,
  						&dev->i2c_adap);
  		if (fe0->dvb.frontend) {
  			dvb_attach(xc5000_attach, fe0->dvb.frontend,
  				   &dev->i2c_adap, &behold_x7_tunerconfig);
  		}
  		break;
0faa2ed5b   Dmitri Belimov   V4L/DVB: saa7134:...
1597
1598
1599
1600
1601
1602
1603
1604
1605
  	case SAA7134_BOARD_BEHOLD_H7:
  		fe0->dvb.frontend = dvb_attach(zl10353_attach,
  						&behold_x7_config,
  						&dev->i2c_adap);
  		if (fe0->dvb.frontend) {
  			dvb_attach(xc5000_attach, fe0->dvb.frontend,
  				   &dev->i2c_adap, &behold_x7_tunerconfig);
  		}
  		break;
04574185a   Matthias Schwarzott   V4L/DVB (10823): ...
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
  	case SAA7134_BOARD_AVERMEDIA_A700_PRO:
  	case SAA7134_BOARD_AVERMEDIA_A700_HYBRID:
  		/* Zarlink ZL10313 */
  		fe0->dvb.frontend = dvb_attach(mt312_attach,
  			&avertv_a700_mt312, &dev->i2c_adap);
  		if (fe0->dvb.frontend) {
  			if (dvb_attach(zl10036_attach, fe0->dvb.frontend,
  					&avertv_a700_tuner, &dev->i2c_adap) == NULL) {
  				wprintk("%s: No zl10036 found!
  ",
  					__func__);
  			}
  		}
ecfcfec80   Igor M. Liplianin   V4L/DVB (12463): ...
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
  		break;
  	case SAA7134_BOARD_VIDEOMATE_S350:
  		fe0->dvb.frontend = dvb_attach(mt312_attach,
  				&zl10313_compro_s350_config, &dev->i2c_adap);
  		if (fe0->dvb.frontend)
  			if (dvb_attach(zl10039_attach, fe0->dvb.frontend,
  					0x60, &dev->i2c_adap) == NULL)
  				wprintk("%s: No zl10039 found!
  ",
  					__func__);
6c119ff49   Henk Vergonet   V4L/DVB (13002): ...
1629
  		break;
dbe8740dd   Carlos Corbacho   [media] Make Comp...
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
  	case SAA7134_BOARD_VIDEOMATE_T750:
  		fe0->dvb.frontend = dvb_attach(zl10353_attach,
  						&videomate_t750_zl10353_config,
  						&dev->i2c_adap);
  		if (fe0->dvb.frontend != NULL) {
  			if (dvb_attach(qt1010_attach,
  					fe0->dvb.frontend,
  					&dev->i2c_adap,
  					&videomate_t750_qt1010_config) == NULL)
  				wprintk("error attaching QT1010
  ");
  		}
  		break;
6c119ff49   Henk Vergonet   V4L/DVB (13002): ...
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
  	case SAA7134_BOARD_ZOLID_HYBRID_PCI:
  		fe0->dvb.frontend = dvb_attach(tda10048_attach,
  					       &zolid_tda10048_config,
  					       &dev->i2c_adap);
  		if (fe0->dvb.frontend != NULL) {
  			dvb_attach(tda829x_attach, fe0->dvb.frontend,
  				   &dev->i2c_adap, 0x4b,
  				   &tda829x_no_probe);
  			dvb_attach(tda18271_attach, fe0->dvb.frontend,
  				   0x60, &dev->i2c_adap,
  				   &zolid_tda18271_config);
  		}
47aeba5ad   Dmitri Belimov   V4L/DVB (10153): ...
1655
  		break;
184e769f9   Michael Krufky   V4L/DVB (13204): ...
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
  	case SAA7134_BOARD_LEADTEK_WINFAST_DTV1000S:
  		fe0->dvb.frontend = dvb_attach(tda10048_attach,
  					       &dtv1000s_tda10048_config,
  					       &dev->i2c_adap);
  		if (fe0->dvb.frontend != NULL) {
  			dvb_attach(tda829x_attach, fe0->dvb.frontend,
  				   &dev->i2c_adap, 0x4b,
  				   &tda829x_no_probe);
  			dvb_attach(tda18271_attach, fe0->dvb.frontend,
  				   0x60, &dev->i2c_adap,
  				   &dtv1000s_tda18271_config);
  		}
  		break;
f0551efc7   Mauro Carvalho Chehab   [media] Add DVB s...
1669
  	case SAA7134_BOARD_KWORLD_PCI_SBTVD_FULLSEG:
ecb71d262   Mauro Carvalho Chehab   [media] saa7134: ...
1670
1671
1672
  		/* Switch to digital mode */
  		saa7134_tuner_callback(dev, 0,
  				       TDA18271_CALLBACK_CMD_AGC_ENABLE, 1);
f0551efc7   Mauro Carvalho Chehab   [media] Add DVB s...
1673
1674
1675
  		fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
  					       &kworld_mb86a20s_config,
  					       &dev->i2c_adap);
f0551efc7   Mauro Carvalho Chehab   [media] Add DVB s...
1676
  		if (fe0->dvb.frontend != NULL) {
6a58bc0f5   Mauro Carvalho Chehab   [media] saa7134: ...
1677
1678
1679
  			dvb_attach(tda829x_attach, fe0->dvb.frontend,
  				   &dev->i2c_adap, 0x4b,
  				   &tda829x_no_probe);
f0551efc7   Mauro Carvalho Chehab   [media] Add DVB s...
1680
1681
1682
  			dvb_attach(tda18271_attach, fe0->dvb.frontend,
  				   0x60, &dev->i2c_adap,
  				   &kworld_tda18271_config);
6a58bc0f5   Mauro Carvalho Chehab   [media] saa7134: ...
1683
  			fe0->dvb.frontend->ops.i2c_gate_ctrl = kworld_sbtvd_gate_ctrl;
f0551efc7   Mauro Carvalho Chehab   [media] Add DVB s...
1684
  		}
6a58bc0f5   Mauro Carvalho Chehab   [media] saa7134: ...
1685
1686
  
  		/* mb86a20s need to use the I2C gateway */
f0551efc7   Mauro Carvalho Chehab   [media] Add DVB s...
1687
  		break;
ce02704d4   Timothy Lee   [media] saa7134: ...
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
  	case SAA7134_BOARD_MAGICPRO_PROHDTV_PRO2:
  		fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
  					       &prohdtv_pro2_lgs8g75_config,
  					       &dev->i2c_adap);
  		if (fe0->dvb.frontend != NULL) {
  			dvb_attach(tda829x_attach, fe0->dvb.frontend,
  				   &dev->i2c_adap, 0x4b,
  				   &tda829x_no_probe);
  			dvb_attach(tda18271_attach, fe0->dvb.frontend,
  				   0x60, &dev->i2c_adap,
  				   &prohdtv_pro2_tda18271_config);
  		}
  		break;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1701
  	default:
cf3c34c87   Trent Piepho   V4L/DVB (5391): S...
1702
1703
  		wprintk("Huh? unknown DVB card?
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1704
1705
  		break;
  	}
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
1706
1707
1708
1709
1710
  	if (attach_xc3028) {
  		struct dvb_frontend *fe;
  		struct xc2028_config cfg = {
  			.i2c_adap  = &dev->i2c_adap,
  			.i2c_addr  = 0x61,
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
1711
  		};
95a2fdb6f   Mauro Carvalho Chehab   V4L/DVB (7458): s...
1712

363c35fc4   Steven Toth   V4L/DVB (9222): S...
1713
  		if (!fe0->dvb.frontend)
f3f741e71   Darron Broad   V4L/DVB (9577): s...
1714
  			goto dettach_frontend;
95a2fdb6f   Mauro Carvalho Chehab   V4L/DVB (7458): s...
1715

363c35fc4   Steven Toth   V4L/DVB (9222): S...
1716
  		fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
1717
1718
1719
1720
  		if (!fe) {
  			printk(KERN_ERR "%s/2: xc3028 attach failed
  ",
  			       dev->name);
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1721
  			goto dettach_frontend;
bc36a686a   Mauro Carvalho Chehab   V4L/DVB (7262): A...
1722
1723
  		}
  	}
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1724
  	if (NULL == fe0->dvb.frontend) {
cf3c34c87   Trent Piepho   V4L/DVB (5391): S...
1725
1726
  		printk(KERN_ERR "%s/dvb: frontend initialization failed
  ", dev->name);
f3f741e71   Darron Broad   V4L/DVB (9577): s...
1727
  		goto dettach_frontend;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1728
  	}
d7cba043d   Michael Krufky   V4L/DVB (9049): c...
1729
  	/* define general-purpose callback pointer */
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1730
  	fe0->dvb.frontend->callback = saa7134_tuner_callback;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1731
1732
  
  	/* register everything else */
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1733
  	ret = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
9133aee09   Michael Krufky   V4L/DVB (13103): ...
1734
  					&dev->pci->dev, adapter_nr, 0, NULL);
1c4f76abb   Hartmut Hackmann   V4L/DVB (5321): S...
1735
1736
1737
1738
1739
  
  	/* this sequence is necessary to make the tda1004x load its firmware
  	 * and to enter analog mode of hybrid boards
  	 */
  	if (!ret) {
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1740
1741
1742
1743
1744
1745
  		if (fe0->dvb.frontend->ops.init)
  			fe0->dvb.frontend->ops.init(fe0->dvb.frontend);
  		if (fe0->dvb.frontend->ops.sleep)
  			fe0->dvb.frontend->ops.sleep(fe0->dvb.frontend);
  		if (fe0->dvb.frontend->ops.tuner_ops.sleep)
  			fe0->dvb.frontend->ops.tuner_ops.sleep(fe0->dvb.frontend);
1c4f76abb   Hartmut Hackmann   V4L/DVB (5321): S...
1746
1747
  	}
  	return ret;
d557dab5d   Mauro Carvalho Chehab   V4L/DVB (7801): s...
1748
1749
  
  dettach_frontend:
f3f741e71   Darron Broad   V4L/DVB (9577): s...
1750
1751
  	videobuf_dvb_dealloc_frontends(&dev->frontends);
  	return -EINVAL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1752
1753
1754
1755
  }
  
  static int dvb_fini(struct saa7134_dev *dev)
  {
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1756
1757
1758
1759
1760
1761
  	struct videobuf_dvb_frontend *fe0;
  
  	/* Get the first frontend */
  	fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
  	if (!fe0)
  		return -EINVAL;
7f1711234   Mauro Carvalho Chehab   V4L/DVB (6384): R...
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
  	/* FIXME: I suspect that this code is bogus, since the entry for
  	   Pinnacle 300I DVB-T PAL already defines the proper init to allow
  	   the detection of mt2032 (TDA9887_PORT2_INACTIVE)
  	 */
  	if (dev->board == SAA7134_BOARD_PINNACLE_300I_DVBT_PAL) {
  		struct v4l2_priv_tun_config tda9887_cfg;
  		static int on  = TDA9887_PRESENT | TDA9887_PORT2_INACTIVE;
  
  		tda9887_cfg.tuner = TUNER_TDA9887;
  		tda9887_cfg.priv  = &on;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1772

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1773
  		/* otherwise we don't detect the tuner on next insmod */
fac6986c4   Hans Verkuil   V4L/DVB (10247): ...
1774
  		saa_call_all(dev, tuner, s_config, &tda9887_cfg);
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1775
  	} else if (dev->board == SAA7134_BOARD_MEDION_MD8800_QUADRO) {
e9c1ac9d8   Hartmut Hackmann   V4L/DVB (7395): s...
1776
  		if ((dev->eedata[2] == 0x07) && use_frontend) {
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1777
1778
1779
1780
  			/* turn off the 2nd lnb supply */
  			u8 data = 0x80;
  			struct i2c_msg msg = {.addr = 0x08, .buf = &data, .flags = 0, .len = 1};
  			struct dvb_frontend *fe;
363c35fc4   Steven Toth   V4L/DVB (9222): S...
1781
  			fe = fe0->dvb.frontend;
5823b3a63   Hartmut Hackmann   V4L/DVB (7392): s...
1782
1783
1784
1785
1786
1787
  			if (fe->ops.i2c_gate_ctrl) {
  				fe->ops.i2c_gate_ctrl(fe, 1);
  				i2c_transfer(&dev->i2c_adap, &msg, 1);
  				fe->ops.i2c_gate_ctrl(fe, 0);
  			}
  		}
7f1711234   Mauro Carvalho Chehab   V4L/DVB (6384): R...
1788
  	}
f3f741e71   Darron Broad   V4L/DVB (9577): s...
1789
  	videobuf_dvb_unregister_bus(&dev->frontends);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
  	return 0;
  }
  
  static struct saa7134_mpeg_ops dvb_ops = {
  	.type          = SAA7134_MPEG_DVB,
  	.init          = dvb_init,
  	.fini          = dvb_fini,
  };
  
  static int __init dvb_register(void)
  {
  	return saa7134_ts_register(&dvb_ops);
  }
  
  static void __exit dvb_unregister(void)
  {
  	saa7134_ts_unregister(&dvb_ops);
  }
  
  module_init(dvb_register);
  module_exit(dvb_unregister);
  
  /* ------------------------------------------------------------------ */
  /*
   * Local variables:
   * c-basic-offset: 8
   * End:
   */