blob: c852efca1592fdbacd5732f79456bfd853ac7176 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines
5 *
Chris Pascoefc40b262006-01-09 15:25:35 -02006 * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/device.h>
27#include <linux/fs.h>
28#include <linux/kthread.h>
29#include <linux/file.h>
30#include <linux/suspend.h>
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "cx88.h"
33#include "dvb-pll.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020034#include <media/v4l2-common.h>
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070035
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030036#include "mt352.h"
37#include "mt352_priv.h"
Trent Piephoecf854d2007-05-05 20:11:32 -030038#include "cx88-vp3054-i2c.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030039#include "zl10353.h"
40#include "cx22702.h"
41#include "or51132.h"
42#include "lgdt330x.h"
Steven Toth60464da2008-01-05 16:53:01 -030043#include "s5h1409.h"
44#include "xc5000.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030045#include "nxt200x.h"
46#include "cx24123.h"
Andrew de Quinceycd20ca92006-05-12 20:31:51 -030047#include "isl6421.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
50MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
51MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
52MODULE_LICENSE("GPL");
53
54static unsigned int debug = 0;
55module_param(debug, int, 0644);
56MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
57
58#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020059 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61/* ------------------------------------------------------------------ */
62
63static int dvb_buf_setup(struct videobuf_queue *q,
64 unsigned int *count, unsigned int *size)
65{
66 struct cx8802_dev *dev = q->priv_data;
67
68 dev->ts_packet_size = 188 * 4;
69 dev->ts_packet_count = 32;
70
71 *size = dev->ts_packet_size * dev->ts_packet_count;
72 *count = 32;
73 return 0;
74}
75
Michael Krufky4a390552006-12-05 02:00:53 -030076static int dvb_buf_prepare(struct videobuf_queue *q,
77 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078{
79 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030080 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081}
82
83static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
84{
85 struct cx8802_dev *dev = q->priv_data;
86 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
87}
88
Michael Krufky4a390552006-12-05 02:00:53 -030089static void dvb_buf_release(struct videobuf_queue *q,
90 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070091{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030092 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
Adrian Bunk408b6642005-05-01 08:59:29 -070095static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 .buf_setup = dvb_buf_setup,
97 .buf_prepare = dvb_buf_prepare,
98 .buf_queue = dvb_buf_queue,
99 .buf_release = dvb_buf_release,
100};
101
102/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300103
104static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
105{
106 struct cx8802_dev *dev= fe->dvb->priv;
107 struct cx8802_driver *drv = NULL;
108 int ret = 0;
109
110 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
111 if (drv) {
Michael Krufky4a390552006-12-05 02:00:53 -0300112 if (acquire)
Michael Krufky22f3f172006-12-05 01:38:58 -0300113 ret = drv->request_acquire(drv);
114 else
115 ret = drv->request_release(drv);
116 }
117
118 return ret;
119}
120
121/* ------------------------------------------------------------------ */
122
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200123static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124{
125 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
126 static u8 reset [] = { RESET, 0x80 };
127 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
128 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
129 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
130 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
131
132 mt352_write(fe, clock_config, sizeof(clock_config));
133 udelay(200);
134 mt352_write(fe, reset, sizeof(reset));
135 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
136
137 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
138 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
139 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
140 return 0;
141}
142
Chris Pascoe43eabb42006-01-09 18:21:28 -0200143static int dvico_dual_demod_init(struct dvb_frontend *fe)
144{
145 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
146 static u8 reset [] = { RESET, 0x80 };
147 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
148 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
149 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
150 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
151
152 mt352_write(fe, clock_config, sizeof(clock_config));
153 udelay(200);
154 mt352_write(fe, reset, sizeof(reset));
155 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
156
157 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
158 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
159 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
160
161 return 0;
162}
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
165{
166 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
167 static u8 reset [] = { 0x50, 0x80 };
168 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
169 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800170 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 static u8 dntv_extra[] = { 0xB5, 0x7A };
172 static u8 capt_range_cfg[] = { 0x75, 0x32 };
173
174 mt352_write(fe, clock_config, sizeof(clock_config));
175 udelay(2000);
176 mt352_write(fe, reset, sizeof(reset));
177 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
178
179 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
180 udelay(2000);
181 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
182 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
183
184 return 0;
185}
186
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187static struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300188 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200189 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190};
191
192static struct mt352_config dntv_live_dvbt_config = {
193 .demod_address = 0x0f,
194 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195};
Chris Pascoefc40b262006-01-09 15:25:35 -0200196
Chris Pascoe43eabb42006-01-09 18:21:28 -0200197static struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300198 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200199 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200200};
201
Trent Piephoecf854d2007-05-05 20:11:32 -0300202#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200203static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
204{
205 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
206 static u8 reset [] = { 0x50, 0x80 };
207 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
208 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
209 0x00, 0xFF, 0x00, 0x40, 0x40 };
210 static u8 dntv_extra[] = { 0xB5, 0x7A };
211 static u8 capt_range_cfg[] = { 0x75, 0x32 };
212
213 mt352_write(fe, clock_config, sizeof(clock_config));
214 udelay(2000);
215 mt352_write(fe, reset, sizeof(reset));
216 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
217
218 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
219 udelay(2000);
220 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
221 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
222
223 return 0;
224}
225
Chris Pascoefc40b262006-01-09 15:25:35 -0200226static struct mt352_config dntv_live_dvbt_pro_config = {
227 .demod_address = 0x0f,
228 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200229 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200230};
231#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
Chris Pascoe780dfef2006-02-28 08:34:59 -0300233static struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300234 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300235 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300236};
237
238static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300239 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300240};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300241
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242static struct cx22702_config connexant_refboard_config = {
243 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700244 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245};
246
Michael Krufkyed355262006-12-05 01:34:56 -0300247static struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300248 .demod_address = 0x63,
249 .output_mode = CX22702_SERIAL_OUTPUT,
250};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251
Michael Krufky4a390552006-12-05 02:00:53 -0300252static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253{
254 struct cx8802_dev *dev= fe->dvb->priv;
255 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
256 return 0;
257}
258
Adrian Bunk408b6642005-05-01 08:59:29 -0700259static struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300260 .demod_address = 0x15,
261 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263
Michael Krufky6ddcc912005-07-27 11:46:00 -0700264static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700265{
266 struct cx8802_dev *dev= fe->dvb->priv;
267 struct cx88_core *core = dev->core;
268
269 dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
270 if (index == 0)
271 cx_clear(MO_GP0_IO, 8);
272 else
273 cx_set(MO_GP0_IO, 8);
274 return 0;
275}
276
Michael Krufky6ddcc912005-07-27 11:46:00 -0700277static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700278{
279 struct cx8802_dev *dev= fe->dvb->priv;
280 if (is_punctured)
281 dev->ts_gen_cntrl |= 0x04;
282 else
283 dev->ts_gen_cntrl &= ~0x04;
284 return 0;
285}
286
Michael Krufky6ddcc912005-07-27 11:46:00 -0700287static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300288 .demod_address = 0x0e,
289 .demod_chip = LGDT3302,
290 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
291 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700292};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700293
294static struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300295 .demod_address = 0x0e,
296 .demod_chip = LGDT3303,
297 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
298 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700299};
Rusty Scottda215d22006-04-07 02:21:31 -0300300
301static struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300302 .demod_address = 0x59,
303 .demod_chip = LGDT3303,
304 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
305 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300306};
Michael Krufkyf1798492005-07-07 17:58:39 -0700307
Michael Krufky4a390552006-12-05 02:00:53 -0300308static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800309{
310 struct cx8802_dev *dev= fe->dvb->priv;
311 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
312 return 0;
313}
314
315static struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300316 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300317 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800318};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800319
Steven Toth0fa14aa2006-01-09 15:25:02 -0200320static int cx24123_set_ts_param(struct dvb_frontend* fe,
321 int is_punctured)
322{
323 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300324 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200325 return 0;
326}
327
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300328static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
329 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200330{
331 struct cx8802_dev *dev= fe->dvb->priv;
332 struct cx88_core *core = dev->core;
333
Michael Krufky4a390552006-12-05 02:00:53 -0300334 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300335 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300336 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300337 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300338
339 if (core->prev_set_voltage)
340 return core->prev_set_voltage(fe, voltage);
341 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200342}
343
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300344static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
345 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300346{
347 struct cx8802_dev *dev= fe->dvb->priv;
348 struct cx88_core *core = dev->core;
349
350 if (voltage == SEC_VOLTAGE_OFF) {
351 dprintk(1,"LNB Voltage OFF\n");
352 cx_write(MO_GP0_IO, 0x0000efff);
353 }
354
355 if (core->prev_set_voltage)
356 return core->prev_set_voltage(fe, voltage);
357 return 0;
358}
359
360static struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300361 .demod_address = 0x55,
362 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300363};
364
Steven Toth0fa14aa2006-01-09 15:25:02 -0200365static struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300366 .demod_address = 0x55,
367 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200368};
369
370static struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300371 .demod_address = 0x15,
372 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300373 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200374};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200375
Steven Toth60464da2008-01-05 16:53:01 -0300376static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
377 .demod_address = 0x32 >> 1,
378 .output_mode = S5H1409_PARALLEL_OUTPUT,
379 .gpio = S5H1409_GPIO_ON,
380 .qam_if = 44000,
381 .inversion = S5H1409_INVERSION_OFF,
382 .status_mode = S5H1409_DEMODLOCKING,
383};
384
385static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
386 .i2c_address = 0x64,
387 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300388 .tuner_callback = cx88_tuner_callback,
389};
390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391static int dvb_register(struct cx8802_dev *dev)
392{
393 /* init struct videobuf_dvb */
394 dev->dvb.name = dev->core->name;
395 dev->ts_gen_cntrl = 0x0c;
396
397 /* init frontend */
Trent Piepho6a59d642007-08-15 14:41:57 -0300398 switch (dev->core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300400 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300401 &connexant_refboard_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300402 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300403 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300404 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300405 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300406 DVB_PLL_THOMSON_DTT759X);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300407 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700409 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200411 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800412 case CX88_BOARD_WINFAST_DTV1000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300413 dev->dvb.frontend = dvb_attach(cx22702_attach,
414 &connexant_refboard_config,
415 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300416 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300417 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300418 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300419 DVB_PLL_THOMSON_DTT7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300420 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300422 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -0200423 case CX88_BOARD_HAUPPAUGE_HVR1100:
424 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300425 case CX88_BOARD_HAUPPAUGE_HVR1300:
426 case CX88_BOARD_HAUPPAUGE_HVR3000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300427 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300428 &hauppauge_hvr_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300429 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300430 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300431 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300432 &dev->core->i2c_adap, DVB_PLL_FMD1216ME);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300433 }
Steven Toth611900c2006-01-09 15:25:12 -0200434 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300435 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300436 dev->dvb.frontend = dvb_attach(mt352_attach,
437 &dvico_fusionhdtv,
438 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300439 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300440 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300441 NULL, DVB_PLL_THOMSON_DTT7579);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300442 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300443 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300444 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300445 dev->dvb.frontend = dvb_attach(zl10353_attach,
446 &dvico_fusionhdtv_plus_v1_1,
447 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300448 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300449 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300450 NULL, DVB_PLL_THOMSON_DTT7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300451 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300452 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300453 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300454 /* The tin box says DEE1601, but it seems to be DTT7579
455 * compatible, with a slightly different MT352 AGC gain. */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300456 dev->dvb.frontend = dvb_attach(mt352_attach,
457 &dvico_fusionhdtv_dual,
458 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300459 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300460 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300461 NULL, DVB_PLL_THOMSON_DTT7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300462 break;
463 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300464 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300465 dev->dvb.frontend = dvb_attach(zl10353_attach,
466 &dvico_fusionhdtv_plus_v1_1,
467 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300468 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300469 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300470 NULL, DVB_PLL_THOMSON_DTT7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300471 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300472 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300474 dev->dvb.frontend = dvb_attach(mt352_attach,
475 &dvico_fusionhdtv,
476 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300477 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300478 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300479 NULL, DVB_PLL_LG_Z201);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300480 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 case CX88_BOARD_KWORLD_DVB_T:
483 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700484 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300485 dev->dvb.frontend = dvb_attach(mt352_attach,
486 &dntv_live_dvbt_config,
487 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300488 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300489 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300490 NULL, DVB_PLL_UNKNOWN_1);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300491 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200493 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -0300494#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -0300495 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300496 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -0300497 &dev->vp3054->adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300498 if (dev->dvb.frontend != NULL) {
Trent Piephob7754d72007-05-08 18:05:16 -0300499 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300500 &dev->core->i2c_adap, DVB_PLL_FMD1216ME);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300501 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200502#else
Trent Piepho5772f812007-08-15 14:41:59 -0300503 printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -0200504#endif
505 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300506 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300507 dev->dvb.frontend = dvb_attach(zl10353_attach,
508 &dvico_fusionhdtv_hybrid,
509 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300510 if (dev->dvb.frontend != NULL) {
Michael Krufky5786a342006-12-05 01:21:19 -0300511 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
512 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300513 DVB_PLL_THOMSON_FE6600);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300514 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300515 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 case CX88_BOARD_PCHDTV_HD3000:
Michael Krufky4a390552006-12-05 02:00:53 -0300517 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300518 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300519 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300520 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300521 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300522 DVB_PLL_THOMSON_DTT761X);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300523 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700525 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
526 dev->ts_gen_cntrl = 0x08;
527 {
528 /* Do a hardware reset of chip before using it. */
529 struct cx88_core *core = dev->core;
530
531 cx_clear(MO_GP0_IO, 1);
532 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700533 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700534 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700535
536 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700537 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300538 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
539 &fusionhdtv_3_gold,
540 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300541 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300542 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
543 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300544 DVB_PLL_MICROTUNE_4042);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300545 }
Michael Krufkyf1798492005-07-07 17:58:39 -0700546 }
547 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700548 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
549 dev->ts_gen_cntrl = 0x08;
550 {
551 /* Do a hardware reset of chip before using it. */
552 struct cx88_core *core = dev->core;
553
554 cx_clear(MO_GP0_IO, 1);
555 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700556 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700557 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300558 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
559 &fusionhdtv_3_gold,
560 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300561 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300562 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
563 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300564 DVB_PLL_THOMSON_DTT761X);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300565 }
Michael Krufky0d723c02005-07-07 17:58:42 -0700566 }
567 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700568 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
569 dev->ts_gen_cntrl = 0x08;
570 {
571 /* Do a hardware reset of chip before using it. */
572 struct cx88_core *core = dev->core;
573
574 cx_clear(MO_GP0_IO, 1);
575 mdelay(100);
576 cx_set(MO_GP0_IO, 1);
577 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300578 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
579 &fusionhdtv_5_gold,
580 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300581 if (dev->dvb.frontend != NULL) {
Trent Piepho6bdcc6e2007-04-27 12:31:30 -0300582 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
583 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300584 DVB_PLL_LG_TDVS_H06XF);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300585 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700586 }
587 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300588 case CX88_BOARD_PCHDTV_HD5500:
589 dev->ts_gen_cntrl = 0x08;
590 {
591 /* Do a hardware reset of chip before using it. */
592 struct cx88_core *core = dev->core;
593
594 cx_clear(MO_GP0_IO, 1);
595 mdelay(100);
596 cx_set(MO_GP0_IO, 1);
597 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300598 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
599 &pchdtv_hd5500,
600 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300601 if (dev->dvb.frontend != NULL) {
Trent Piepho6bdcc6e2007-04-27 12:31:30 -0300602 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
603 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300604 DVB_PLL_LG_TDVS_H06XF);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300605 }
Rusty Scottda215d22006-04-07 02:21:31 -0300606 }
607 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -0800608 case CX88_BOARD_ATI_HDTVWONDER:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300609 dev->dvb.frontend = dvb_attach(nxt200x_attach,
610 &ati_hdtvwonder,
611 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300612 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300613 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300614 NULL, DVB_PLL_TUV1236D);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300615 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800616 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200617 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
618 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300619 dev->dvb.frontend = dvb_attach(cx24123_attach,
620 &hauppauge_novas_config,
621 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300622 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300623 dvb_attach(isl6421_attach, dev->dvb.frontend,
624 &dev->core->i2c_adap, 0x08, 0x00, 0x00);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300625 }
Steven Toth0fa14aa2006-01-09 15:25:02 -0200626 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200627 case CX88_BOARD_KWORLD_DVBS_100:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300628 dev->dvb.frontend = dvb_attach(cx24123_attach,
629 &kworld_dvbs_100_config,
630 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300631 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300632 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
633 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300634 }
Vadim Catana0e0351e2006-01-09 15:25:02 -0200635 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300636 case CX88_BOARD_GENIATECH_DVBS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300637 dev->dvb.frontend = dvb_attach(cx24123_attach,
638 &geniatech_dvbs_config,
639 &dev->core->i2c_adap);
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300640 if (dev->dvb.frontend) {
641 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
642 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
643 }
644 break;
Steven Toth60464da2008-01-05 16:53:01 -0300645 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
646 /* Parallel mpeg data port and punctured clock mode */
647 dev->ts_gen_cntrl = 0x04;
648
649 dev->dvb.frontend = dvb_attach(s5h1409_attach,
650 &pinnacle_pctv_hd_800i_config,
651 &dev->core->i2c_adap);
652 if (dev->dvb.frontend != NULL) {
653 /* tuner_config.video_dev must point to
654 * i2c_adap.algo_data
655 */
Steven Toth73c993a2008-01-05 17:08:05 -0300656 pinnacle_pctv_hd_800i_tuner_config.priv =
Steven Toth60464da2008-01-05 16:53:01 -0300657 dev->core->i2c_adap.algo_data;
658 dvb_attach(xc5000_attach, dev->dvb.frontend,
659 &dev->core->i2c_adap,
660 &pinnacle_pctv_hd_800i_tuner_config);
661 }
662 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 default:
Trent Piepho5772f812007-08-15 14:41:59 -0300664 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700665 dev->core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 break;
667 }
668 if (NULL == dev->dvb.frontend) {
Trent Piepho5772f812007-08-15 14:41:59 -0300669 printk(KERN_ERR "%s/2: frontend initialization failed\n", dev->core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 return -1;
671 }
672
Steven Toth6c5be742006-12-02 21:15:51 -0200673 /* Ensure all frontends negotiate bus access */
674 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675
Mauro Carvalho Chehab93352f5c2005-09-13 01:25:42 -0700676 /* Put the analog decoder in standby to keep it quiet */
677 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
678
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 /* register everything */
Andrew de Quinceyd09dbf92006-04-10 09:27:37 -0300680 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681}
682
683/* ----------------------------------------------------------- */
684
Steven Toth6c5be742006-12-02 21:15:51 -0200685/* CX8802 MPEG -> mini driver - We have been given the hardware */
686static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687{
Steven Toth6c5be742006-12-02 21:15:51 -0200688 struct cx88_core *core = drv->core;
689 int err = 0;
690 dprintk( 1, "%s\n", __FUNCTION__);
691
Trent Piepho6a59d642007-08-15 14:41:57 -0300692 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -0200693 case CX88_BOARD_HAUPPAUGE_HVR1300:
694 /* We arrive here with either the cx23416 or the cx22702
695 * on the bus. Take the bus from the cx23416 and enable the
696 * cx22702 demod
697 */
698 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
699 cx_clear(MO_GP0_IO, 0x00000004);
700 udelay(1000);
701 break;
702 default:
703 err = -ENODEV;
704 }
705 return err;
706}
707
708/* CX8802 MPEG -> mini driver - We no longer have the hardware */
709static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
710{
711 struct cx88_core *core = drv->core;
712 int err = 0;
713 dprintk( 1, "%s\n", __FUNCTION__);
714
Trent Piepho6a59d642007-08-15 14:41:57 -0300715 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -0200716 case CX88_BOARD_HAUPPAUGE_HVR1300:
717 /* Do Nothing, leave the cx22702 on the bus. */
718 break;
719 default:
720 err = -ENODEV;
721 }
722 return err;
723}
724
725static int cx8802_dvb_probe(struct cx8802_driver *drv)
726{
727 struct cx88_core *core = drv->core;
728 struct cx8802_dev *dev = drv->core->dvbdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 int err;
730
Steven Toth6c5be742006-12-02 21:15:51 -0200731 dprintk( 1, "%s\n", __FUNCTION__);
732 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -0300733 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -0200734 core->name,
735 core->pci_bus,
736 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737
738 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -0300739 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 goto fail_core;
741
Trent Piephoecf854d2007-05-05 20:11:32 -0300742 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -0200743 err = vp3054_i2c_probe(dev);
744 if (0 != err)
Steven Toth6c5be742006-12-02 21:15:51 -0200745 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -0200746
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -0300748 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Mauro Carvalho Chehabc1accaa2007-08-23 16:37:49 -0300749 videobuf_queue_pci_init(&dev->dvb.dvbq, &dvb_qops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 dev->pci, &dev->slock,
751 V4L2_BUF_TYPE_VIDEO_CAPTURE,
752 V4L2_FIELD_TOP,
753 sizeof(struct cx88_buffer),
754 dev);
755 err = dvb_register(dev);
Steven Toth6c5be742006-12-02 21:15:51 -0200756 if (err != 0)
Trent Piepho5772f812007-08-15 14:41:59 -0300757 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
758 core->name, err);
Steven Toth611900c2006-01-09 15:25:12 -0200759
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 return err;
762}
763
Steven Toth6c5be742006-12-02 21:15:51 -0200764static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765{
Steven Toth6c5be742006-12-02 21:15:51 -0200766 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -0200767
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 /* dvb */
769 videobuf_dvb_unregister(&dev->dvb);
770
Chris Pascoefc40b262006-01-09 15:25:35 -0200771 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -0200772
Steven Toth6c5be742006-12-02 21:15:51 -0200773 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774}
775
Steven Toth6c5be742006-12-02 21:15:51 -0200776static struct cx8802_driver cx8802_dvb_driver = {
777 .type_id = CX88_MPEG_DVB,
778 .hw_access = CX8802_DRVCTL_SHARED,
779 .probe = cx8802_dvb_probe,
780 .remove = cx8802_dvb_remove,
781 .advise_acquire = cx8802_dvb_advise_acquire,
782 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783};
784
785static int dvb_init(void)
786{
Trent Piepho5772f812007-08-15 14:41:59 -0300787 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 (CX88_VERSION_CODE >> 16) & 0xff,
789 (CX88_VERSION_CODE >> 8) & 0xff,
790 CX88_VERSION_CODE & 0xff);
791#ifdef SNAPSHOT
792 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
793 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
794#endif
Steven Toth6c5be742006-12-02 21:15:51 -0200795 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796}
797
798static void dvb_fini(void)
799{
Steven Toth6c5be742006-12-02 21:15:51 -0200800 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801}
802
803module_init(dvb_init);
804module_exit(dvb_fini);
805
806/*
807 * Local variables:
808 * c-basic-offset: 8
809 * compile-command: "make DVB=1"
810 * End:
811 */