blob: d16e5c6d21c07c325b3da0895f0550b5d4723f0f [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"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030043#include "nxt200x.h"
44#include "cx24123.h"
Andrew de Quinceycd20ca92006-05-12 20:31:51 -030045#include "isl6421.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
48MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
49MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
50MODULE_LICENSE("GPL");
51
52static unsigned int debug = 0;
53module_param(debug, int, 0644);
54MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
55
56#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020057 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
59/* ------------------------------------------------------------------ */
60
61static int dvb_buf_setup(struct videobuf_queue *q,
62 unsigned int *count, unsigned int *size)
63{
64 struct cx8802_dev *dev = q->priv_data;
65
66 dev->ts_packet_size = 188 * 4;
67 dev->ts_packet_count = 32;
68
69 *size = dev->ts_packet_size * dev->ts_packet_count;
70 *count = 32;
71 return 0;
72}
73
Michael Krufky4a390552006-12-05 02:00:53 -030074static int dvb_buf_prepare(struct videobuf_queue *q,
75 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070076{
77 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030078 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
80
81static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
82{
83 struct cx8802_dev *dev = q->priv_data;
84 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
85}
86
Michael Krufky4a390552006-12-05 02:00:53 -030087static void dvb_buf_release(struct videobuf_queue *q,
88 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070089{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030090 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091}
92
Adrian Bunk408b6642005-05-01 08:59:29 -070093static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 .buf_setup = dvb_buf_setup,
95 .buf_prepare = dvb_buf_prepare,
96 .buf_queue = dvb_buf_queue,
97 .buf_release = dvb_buf_release,
98};
99
100/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300101
102static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
103{
104 struct cx8802_dev *dev= fe->dvb->priv;
105 struct cx8802_driver *drv = NULL;
106 int ret = 0;
107
108 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
109 if (drv) {
Michael Krufky4a390552006-12-05 02:00:53 -0300110 if (acquire)
Michael Krufky22f3f172006-12-05 01:38:58 -0300111 ret = drv->request_acquire(drv);
112 else
113 ret = drv->request_release(drv);
114 }
115
116 return ret;
117}
118
119/* ------------------------------------------------------------------ */
120
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200121static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122{
123 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
124 static u8 reset [] = { RESET, 0x80 };
125 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
126 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
127 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
128 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
129
130 mt352_write(fe, clock_config, sizeof(clock_config));
131 udelay(200);
132 mt352_write(fe, reset, sizeof(reset));
133 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
134
135 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
136 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
137 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
138 return 0;
139}
140
Chris Pascoe43eabb42006-01-09 18:21:28 -0200141static int dvico_dual_demod_init(struct dvb_frontend *fe)
142{
143 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
144 static u8 reset [] = { RESET, 0x80 };
145 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
146 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
147 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
148 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
149
150 mt352_write(fe, clock_config, sizeof(clock_config));
151 udelay(200);
152 mt352_write(fe, reset, sizeof(reset));
153 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
154
155 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
156 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
157 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
158
159 return 0;
160}
161
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
163{
164 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
165 static u8 reset [] = { 0x50, 0x80 };
166 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
167 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800168 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 static u8 dntv_extra[] = { 0xB5, 0x7A };
170 static u8 capt_range_cfg[] = { 0x75, 0x32 };
171
172 mt352_write(fe, clock_config, sizeof(clock_config));
173 udelay(2000);
174 mt352_write(fe, reset, sizeof(reset));
175 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
176
177 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
178 udelay(2000);
179 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
180 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
181
182 return 0;
183}
184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185static struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300186 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200187 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188};
189
190static struct mt352_config dntv_live_dvbt_config = {
191 .demod_address = 0x0f,
192 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193};
Chris Pascoefc40b262006-01-09 15:25:35 -0200194
Chris Pascoe43eabb42006-01-09 18:21:28 -0200195static struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300196 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200197 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200198};
199
Trent Piephoecf854d2007-05-05 20:11:32 -0300200#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200201static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
202{
203 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
204 static u8 reset [] = { 0x50, 0x80 };
205 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
206 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
207 0x00, 0xFF, 0x00, 0x40, 0x40 };
208 static u8 dntv_extra[] = { 0xB5, 0x7A };
209 static u8 capt_range_cfg[] = { 0x75, 0x32 };
210
211 mt352_write(fe, clock_config, sizeof(clock_config));
212 udelay(2000);
213 mt352_write(fe, reset, sizeof(reset));
214 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
215
216 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
217 udelay(2000);
218 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
219 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
220
221 return 0;
222}
223
Chris Pascoefc40b262006-01-09 15:25:35 -0200224static struct mt352_config dntv_live_dvbt_pro_config = {
225 .demod_address = 0x0f,
226 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200227 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200228};
229#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230
Chris Pascoe780dfef2006-02-28 08:34:59 -0300231static struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300232 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300233 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300234};
235
236static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300237 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300238};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300239
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240static struct cx22702_config connexant_refboard_config = {
241 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700242 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243};
244
Michael Krufkyed355262006-12-05 01:34:56 -0300245static struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300246 .demod_address = 0x63,
247 .output_mode = CX22702_SERIAL_OUTPUT,
248};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Michael Krufky4a390552006-12-05 02:00:53 -0300250static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251{
252 struct cx8802_dev *dev= fe->dvb->priv;
253 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
254 return 0;
255}
256
Adrian Bunk408b6642005-05-01 08:59:29 -0700257static struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300258 .demod_address = 0x15,
259 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261
Michael Krufky6ddcc912005-07-27 11:46:00 -0700262static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700263{
264 struct cx8802_dev *dev= fe->dvb->priv;
265 struct cx88_core *core = dev->core;
266
267 dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
268 if (index == 0)
269 cx_clear(MO_GP0_IO, 8);
270 else
271 cx_set(MO_GP0_IO, 8);
272 return 0;
273}
274
Michael Krufky6ddcc912005-07-27 11:46:00 -0700275static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700276{
277 struct cx8802_dev *dev= fe->dvb->priv;
278 if (is_punctured)
279 dev->ts_gen_cntrl |= 0x04;
280 else
281 dev->ts_gen_cntrl &= ~0x04;
282 return 0;
283}
284
Michael Krufky6ddcc912005-07-27 11:46:00 -0700285static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300286 .demod_address = 0x0e,
287 .demod_chip = LGDT3302,
288 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
289 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700290};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700291
292static struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300293 .demod_address = 0x0e,
294 .demod_chip = LGDT3303,
295 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
296 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700297};
Rusty Scottda215d22006-04-07 02:21:31 -0300298
299static struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300300 .demod_address = 0x59,
301 .demod_chip = LGDT3303,
302 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
303 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300304};
Michael Krufkyf1798492005-07-07 17:58:39 -0700305
Michael Krufky4a390552006-12-05 02:00:53 -0300306static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800307{
308 struct cx8802_dev *dev= fe->dvb->priv;
309 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
310 return 0;
311}
312
313static struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300314 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300315 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800316};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800317
Steven Toth0fa14aa2006-01-09 15:25:02 -0200318static int cx24123_set_ts_param(struct dvb_frontend* fe,
319 int is_punctured)
320{
321 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300322 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200323 return 0;
324}
325
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300326static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
327 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200328{
329 struct cx8802_dev *dev= fe->dvb->priv;
330 struct cx88_core *core = dev->core;
331
Michael Krufky4a390552006-12-05 02:00:53 -0300332 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300333 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300334 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300335 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300336
337 if (core->prev_set_voltage)
338 return core->prev_set_voltage(fe, voltage);
339 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200340}
341
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300342static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
343 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300344{
345 struct cx8802_dev *dev= fe->dvb->priv;
346 struct cx88_core *core = dev->core;
347
348 if (voltage == SEC_VOLTAGE_OFF) {
349 dprintk(1,"LNB Voltage OFF\n");
350 cx_write(MO_GP0_IO, 0x0000efff);
351 }
352
353 if (core->prev_set_voltage)
354 return core->prev_set_voltage(fe, voltage);
355 return 0;
356}
357
358static struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300359 .demod_address = 0x55,
360 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300361};
362
Steven Toth0fa14aa2006-01-09 15:25:02 -0200363static struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300364 .demod_address = 0x55,
365 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200366};
367
368static struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300369 .demod_address = 0x15,
370 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300371 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200372};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200373
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374static int dvb_register(struct cx8802_dev *dev)
375{
376 /* init struct videobuf_dvb */
377 dev->dvb.name = dev->core->name;
378 dev->ts_gen_cntrl = 0x0c;
379
380 /* init frontend */
Trent Piepho6a59d642007-08-15 14:41:57 -0300381 switch (dev->core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300383 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300384 &connexant_refboard_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300385 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300386 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300387 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300388 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300389 DVB_PLL_THOMSON_DTT759X);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300390 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700392 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200394 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800395 case CX88_BOARD_WINFAST_DTV1000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300396 dev->dvb.frontend = dvb_attach(cx22702_attach,
397 &connexant_refboard_config,
398 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300399 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300400 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300401 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300402 DVB_PLL_THOMSON_DTT7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300403 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300405 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -0200406 case CX88_BOARD_HAUPPAUGE_HVR1100:
407 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300408 case CX88_BOARD_HAUPPAUGE_HVR1300:
409 case CX88_BOARD_HAUPPAUGE_HVR3000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300410 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300411 &hauppauge_hvr_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300412 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300413 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300414 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300415 &dev->core->i2c_adap, DVB_PLL_FMD1216ME);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300416 }
Steven Toth611900c2006-01-09 15:25:12 -0200417 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300418 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300419 dev->dvb.frontend = dvb_attach(mt352_attach,
420 &dvico_fusionhdtv,
421 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300422 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300423 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300424 NULL, DVB_PLL_THOMSON_DTT7579);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300425 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300426 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300427 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300428 dev->dvb.frontend = dvb_attach(zl10353_attach,
429 &dvico_fusionhdtv_plus_v1_1,
430 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300431 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300432 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300433 NULL, DVB_PLL_THOMSON_DTT7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300434 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300435 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300436 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300437 /* The tin box says DEE1601, but it seems to be DTT7579
438 * compatible, with a slightly different MT352 AGC gain. */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300439 dev->dvb.frontend = dvb_attach(mt352_attach,
440 &dvico_fusionhdtv_dual,
441 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300442 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300443 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300444 NULL, DVB_PLL_THOMSON_DTT7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300445 break;
446 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300447 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300448 dev->dvb.frontend = dvb_attach(zl10353_attach,
449 &dvico_fusionhdtv_plus_v1_1,
450 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300451 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300452 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300453 NULL, DVB_PLL_THOMSON_DTT7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300454 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300455 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300457 dev->dvb.frontend = dvb_attach(mt352_attach,
458 &dvico_fusionhdtv,
459 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300460 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300461 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300462 NULL, DVB_PLL_LG_Z201);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300463 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 case CX88_BOARD_KWORLD_DVB_T:
466 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700467 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300468 dev->dvb.frontend = dvb_attach(mt352_attach,
469 &dntv_live_dvbt_config,
470 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300471 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300472 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300473 NULL, DVB_PLL_UNKNOWN_1);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300474 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200476 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -0300477#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300478 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Chris Pascoefc40b262006-01-09 15:25:35 -0200479 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300480 if (dev->dvb.frontend != NULL) {
Trent Piephob7754d72007-05-08 18:05:16 -0300481 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300482 &dev->core->i2c_adap, DVB_PLL_FMD1216ME);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300483 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200484#else
Trent Piepho5772f812007-08-15 14:41:59 -0300485 printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -0200486#endif
487 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300488 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300489 dev->dvb.frontend = dvb_attach(zl10353_attach,
490 &dvico_fusionhdtv_hybrid,
491 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300492 if (dev->dvb.frontend != NULL) {
Michael Krufky5786a342006-12-05 01:21:19 -0300493 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
494 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300495 DVB_PLL_THOMSON_FE6600);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300496 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300497 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 case CX88_BOARD_PCHDTV_HD3000:
Michael Krufky4a390552006-12-05 02:00:53 -0300499 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300500 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300501 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300502 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300503 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300504 DVB_PLL_THOMSON_DTT761X);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300505 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700507 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
508 dev->ts_gen_cntrl = 0x08;
509 {
510 /* Do a hardware reset of chip before using it. */
511 struct cx88_core *core = dev->core;
512
513 cx_clear(MO_GP0_IO, 1);
514 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700515 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700516 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700517
518 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700519 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300520 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
521 &fusionhdtv_3_gold,
522 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300523 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300524 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
525 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300526 DVB_PLL_MICROTUNE_4042);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300527 }
Michael Krufkyf1798492005-07-07 17:58:39 -0700528 }
529 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700530 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
531 dev->ts_gen_cntrl = 0x08;
532 {
533 /* Do a hardware reset of chip before using it. */
534 struct cx88_core *core = dev->core;
535
536 cx_clear(MO_GP0_IO, 1);
537 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700538 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700539 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300540 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
541 &fusionhdtv_3_gold,
542 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300543 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300544 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
545 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300546 DVB_PLL_THOMSON_DTT761X);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300547 }
Michael Krufky0d723c02005-07-07 17:58:42 -0700548 }
549 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700550 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
551 dev->ts_gen_cntrl = 0x08;
552 {
553 /* Do a hardware reset of chip before using it. */
554 struct cx88_core *core = dev->core;
555
556 cx_clear(MO_GP0_IO, 1);
557 mdelay(100);
558 cx_set(MO_GP0_IO, 1);
559 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300560 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
561 &fusionhdtv_5_gold,
562 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300563 if (dev->dvb.frontend != NULL) {
Trent Piepho6bdcc6e2007-04-27 12:31:30 -0300564 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
565 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300566 DVB_PLL_LG_TDVS_H06XF);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300567 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700568 }
569 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300570 case CX88_BOARD_PCHDTV_HD5500:
571 dev->ts_gen_cntrl = 0x08;
572 {
573 /* Do a hardware reset of chip before using it. */
574 struct cx88_core *core = dev->core;
575
576 cx_clear(MO_GP0_IO, 1);
577 mdelay(100);
578 cx_set(MO_GP0_IO, 1);
579 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300580 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
581 &pchdtv_hd5500,
582 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300583 if (dev->dvb.frontend != NULL) {
Trent Piepho6bdcc6e2007-04-27 12:31:30 -0300584 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
585 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300586 DVB_PLL_LG_TDVS_H06XF);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300587 }
Rusty Scottda215d22006-04-07 02:21:31 -0300588 }
589 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -0800590 case CX88_BOARD_ATI_HDTVWONDER:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300591 dev->dvb.frontend = dvb_attach(nxt200x_attach,
592 &ati_hdtvwonder,
593 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300594 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300595 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300596 NULL, DVB_PLL_TUV1236D);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300597 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800598 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200599 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
600 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300601 dev->dvb.frontend = dvb_attach(cx24123_attach,
602 &hauppauge_novas_config,
603 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300604 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300605 dvb_attach(isl6421_attach, dev->dvb.frontend,
606 &dev->core->i2c_adap, 0x08, 0x00, 0x00);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300607 }
Steven Toth0fa14aa2006-01-09 15:25:02 -0200608 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200609 case CX88_BOARD_KWORLD_DVBS_100:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300610 dev->dvb.frontend = dvb_attach(cx24123_attach,
611 &kworld_dvbs_100_config,
612 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300613 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300614 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
615 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300616 }
Vadim Catana0e0351e2006-01-09 15:25:02 -0200617 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300618 case CX88_BOARD_GENIATECH_DVBS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300619 dev->dvb.frontend = dvb_attach(cx24123_attach,
620 &geniatech_dvbs_config,
621 &dev->core->i2c_adap);
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300622 if (dev->dvb.frontend) {
623 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
624 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
625 }
626 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 default:
Trent Piepho5772f812007-08-15 14:41:59 -0300628 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700629 dev->core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 break;
631 }
632 if (NULL == dev->dvb.frontend) {
Trent Piepho5772f812007-08-15 14:41:59 -0300633 printk(KERN_ERR "%s/2: frontend initialization failed\n", dev->core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 return -1;
635 }
636
Steven Toth6c5be742006-12-02 21:15:51 -0200637 /* Ensure all frontends negotiate bus access */
638 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639
Mauro Carvalho Chehab93352f5c2005-09-13 01:25:42 -0700640 /* Put the analog decoder in standby to keep it quiet */
641 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
642
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 /* register everything */
Andrew de Quinceyd09dbf92006-04-10 09:27:37 -0300644 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645}
646
647/* ----------------------------------------------------------- */
648
Steven Toth6c5be742006-12-02 21:15:51 -0200649/* CX8802 MPEG -> mini driver - We have been given the hardware */
650static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651{
Steven Toth6c5be742006-12-02 21:15:51 -0200652 struct cx88_core *core = drv->core;
653 int err = 0;
654 dprintk( 1, "%s\n", __FUNCTION__);
655
Trent Piepho6a59d642007-08-15 14:41:57 -0300656 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -0200657 case CX88_BOARD_HAUPPAUGE_HVR1300:
658 /* We arrive here with either the cx23416 or the cx22702
659 * on the bus. Take the bus from the cx23416 and enable the
660 * cx22702 demod
661 */
662 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
663 cx_clear(MO_GP0_IO, 0x00000004);
664 udelay(1000);
665 break;
666 default:
667 err = -ENODEV;
668 }
669 return err;
670}
671
672/* CX8802 MPEG -> mini driver - We no longer have the hardware */
673static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
674{
675 struct cx88_core *core = drv->core;
676 int err = 0;
677 dprintk( 1, "%s\n", __FUNCTION__);
678
Trent Piepho6a59d642007-08-15 14:41:57 -0300679 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -0200680 case CX88_BOARD_HAUPPAUGE_HVR1300:
681 /* Do Nothing, leave the cx22702 on the bus. */
682 break;
683 default:
684 err = -ENODEV;
685 }
686 return err;
687}
688
689static int cx8802_dvb_probe(struct cx8802_driver *drv)
690{
691 struct cx88_core *core = drv->core;
692 struct cx8802_dev *dev = drv->core->dvbdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 int err;
694
Steven Toth6c5be742006-12-02 21:15:51 -0200695 dprintk( 1, "%s\n", __FUNCTION__);
696 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -0300697 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -0200698 core->name,
699 core->pci_bus,
700 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701
702 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -0300703 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 goto fail_core;
705
Trent Piephoecf854d2007-05-05 20:11:32 -0300706 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -0200707 err = vp3054_i2c_probe(dev);
708 if (0 != err)
Steven Toth6c5be742006-12-02 21:15:51 -0200709 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -0200710
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -0300712 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Mauro Carvalho Chehabc1accaa2007-08-23 16:37:49 -0300713 videobuf_queue_pci_init(&dev->dvb.dvbq, &dvb_qops,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 dev->pci, &dev->slock,
715 V4L2_BUF_TYPE_VIDEO_CAPTURE,
716 V4L2_FIELD_TOP,
717 sizeof(struct cx88_buffer),
718 dev);
719 err = dvb_register(dev);
Steven Toth6c5be742006-12-02 21:15:51 -0200720 if (err != 0)
Trent Piepho5772f812007-08-15 14:41:59 -0300721 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
722 core->name, err);
Steven Toth611900c2006-01-09 15:25:12 -0200723
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 return err;
726}
727
Steven Toth6c5be742006-12-02 21:15:51 -0200728static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729{
Steven Toth6c5be742006-12-02 21:15:51 -0200730 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -0200731
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 /* dvb */
733 videobuf_dvb_unregister(&dev->dvb);
734
Chris Pascoefc40b262006-01-09 15:25:35 -0200735 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -0200736
Steven Toth6c5be742006-12-02 21:15:51 -0200737 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738}
739
Steven Toth6c5be742006-12-02 21:15:51 -0200740static struct cx8802_driver cx8802_dvb_driver = {
741 .type_id = CX88_MPEG_DVB,
742 .hw_access = CX8802_DRVCTL_SHARED,
743 .probe = cx8802_dvb_probe,
744 .remove = cx8802_dvb_remove,
745 .advise_acquire = cx8802_dvb_advise_acquire,
746 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747};
748
749static int dvb_init(void)
750{
Trent Piepho5772f812007-08-15 14:41:59 -0300751 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 (CX88_VERSION_CODE >> 16) & 0xff,
753 (CX88_VERSION_CODE >> 8) & 0xff,
754 CX88_VERSION_CODE & 0xff);
755#ifdef SNAPSHOT
756 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
757 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
758#endif
Steven Toth6c5be742006-12-02 21:15:51 -0200759 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760}
761
762static void dvb_fini(void)
763{
Steven Toth6c5be742006-12-02 21:15:51 -0200764 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765}
766
767module_init(dvb_init);
768module_exit(dvb_fini);
769
770/*
771 * Local variables:
772 * c-basic-offset: 8
773 * compile-command: "make DVB=1"
774 * End:
775 */