blob: a5812e2e25c145c4793646ca0ad92de541ff6cc4 [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"
38#ifdef HAVE_VP3054_I2C
39# include "cx88-vp3054-i2c.h"
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070040#endif
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030041#include "zl10353.h"
42#include "cx22702.h"
43#include "or51132.h"
44#include "lgdt330x.h"
45#include "lg_h06xf.h"
46#include "nxt200x.h"
47#include "cx24123.h"
Andrew de Quinceycd20ca92006-05-12 20:31:51 -030048#include "isl6421.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
51MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
52MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
53MODULE_LICENSE("GPL");
54
55static unsigned int debug = 0;
56module_param(debug, int, 0644);
57MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
58
59#define dprintk(level,fmt, arg...) if (debug >= level) \
60 printk(KERN_DEBUG "%s/2-dvb: " fmt, dev->core->name , ## arg)
61
62/* ------------------------------------------------------------------ */
63
64static int dvb_buf_setup(struct videobuf_queue *q,
65 unsigned int *count, unsigned int *size)
66{
67 struct cx8802_dev *dev = q->priv_data;
68
69 dev->ts_packet_size = 188 * 4;
70 dev->ts_packet_count = 32;
71
72 *size = dev->ts_packet_size * dev->ts_packet_count;
73 *count = 32;
74 return 0;
75}
76
77static int dvb_buf_prepare(struct videobuf_queue *q, struct videobuf_buffer *vb,
78 enum v4l2_field field)
79{
80 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030081 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082}
83
84static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
85{
86 struct cx8802_dev *dev = q->priv_data;
87 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
88}
89
90static void dvb_buf_release(struct videobuf_queue *q, struct videobuf_buffer *vb)
91{
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/* ------------------------------------------------------------------ */
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200103static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104{
105 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
106 static u8 reset [] = { RESET, 0x80 };
107 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
108 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
109 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
110 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
111
112 mt352_write(fe, clock_config, sizeof(clock_config));
113 udelay(200);
114 mt352_write(fe, reset, sizeof(reset));
115 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
116
117 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
118 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
119 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
120 return 0;
121}
122
Chris Pascoe43eabb42006-01-09 18:21:28 -0200123static int dvico_dual_demod_init(struct dvb_frontend *fe)
124{
125 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
126 static u8 reset [] = { RESET, 0x80 };
127 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
128 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 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
141 return 0;
142}
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
145{
146 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
147 static u8 reset [] = { 0x50, 0x80 };
148 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
149 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800150 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 static u8 dntv_extra[] = { 0xB5, 0x7A };
152 static u8 capt_range_cfg[] = { 0x75, 0x32 };
153
154 mt352_write(fe, clock_config, sizeof(clock_config));
155 udelay(2000);
156 mt352_write(fe, reset, sizeof(reset));
157 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
158
159 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
160 udelay(2000);
161 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
162 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
163
164 return 0;
165}
166
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167static struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300168 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200169 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170};
171
172static struct mt352_config dntv_live_dvbt_config = {
173 .demod_address = 0x0f,
174 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175};
Chris Pascoefc40b262006-01-09 15:25:35 -0200176
Chris Pascoe43eabb42006-01-09 18:21:28 -0200177static struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300178 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200179 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200180};
181
Chris Pascoefc40b262006-01-09 15:25:35 -0200182#ifdef HAVE_VP3054_I2C
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200183static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
184{
185 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
186 static u8 reset [] = { 0x50, 0x80 };
187 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
188 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
189 0x00, 0xFF, 0x00, 0x40, 0x40 };
190 static u8 dntv_extra[] = { 0xB5, 0x7A };
191 static u8 capt_range_cfg[] = { 0x75, 0x32 };
192
193 mt352_write(fe, clock_config, sizeof(clock_config));
194 udelay(2000);
195 mt352_write(fe, reset, sizeof(reset));
196 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
197
198 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
199 udelay(2000);
200 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
201 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
202
203 return 0;
204}
205
Chris Pascoefc40b262006-01-09 15:25:35 -0200206static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
207{
208 struct cx8802_dev *dev= fe->dvb->priv;
209
210 /* this message is to set up ATC and ALC */
211 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
212 struct i2c_msg msg =
213 { .addr = dev->core->pll_addr, .flags = 0,
214 .buf = fmd1216_init, .len = sizeof(fmd1216_init) };
215 int err;
216
Patrick Boettcherdea74862006-05-14 05:01:31 -0300217 if (fe->ops.i2c_gate_ctrl)
218 fe->ops.i2c_gate_ctrl(fe, 1);
Chris Pascoefc40b262006-01-09 15:25:35 -0200219 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
220 if (err < 0)
221 return err;
222 else
223 return -EREMOTEIO;
224 }
225
226 return 0;
227}
228
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300229static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
230 struct dvb_frontend_parameters* params)
Chris Pascoefc40b262006-01-09 15:25:35 -0200231{
232 struct cx8802_dev *dev= fe->dvb->priv;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300233 u8 buf[4];
Chris Pascoefc40b262006-01-09 15:25:35 -0200234 struct i2c_msg msg =
235 { .addr = dev->core->pll_addr, .flags = 0,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300236 .buf = buf, .len = 4 };
Chris Pascoefc40b262006-01-09 15:25:35 -0200237 int err;
238
239 /* Switch PLL to DVB mode */
240 err = philips_fmd1216_pll_init(fe);
241 if (err)
242 return err;
243
244 /* Tune PLL */
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300245 dvb_pll_configure(dev->core->pll_desc, buf,
Chris Pascoefc40b262006-01-09 15:25:35 -0200246 params->frequency,
247 params->u.ofdm.bandwidth);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300248 if (fe->ops.i2c_gate_ctrl)
249 fe->ops.i2c_gate_ctrl(fe, 1);
Chris Pascoefc40b262006-01-09 15:25:35 -0200250 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300251
Chris Pascoefc40b262006-01-09 15:25:35 -0200252 printk(KERN_WARNING "cx88-dvb: %s error "
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300253 "(addr %02x <- %02x, err = %i)\n",
254 __FUNCTION__, dev->core->pll_addr, buf[0], err);
Chris Pascoefc40b262006-01-09 15:25:35 -0200255 if (err < 0)
256 return err;
257 else
258 return -EREMOTEIO;
259 }
260
261 return 0;
262}
263
264static struct mt352_config dntv_live_dvbt_pro_config = {
265 .demod_address = 0x0f,
266 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200267 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200268};
269#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300271static int dvico_hybrid_tuner_set_params(struct dvb_frontend *fe,
272 struct dvb_frontend_parameters *params)
Chris Pascoe780dfef2006-02-28 08:34:59 -0300273{
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300274 u8 pllbuf[4];
Chris Pascoe780dfef2006-02-28 08:34:59 -0300275 struct cx8802_dev *dev= fe->dvb->priv;
276 struct i2c_msg msg =
277 { .addr = dev->core->pll_addr, .flags = 0,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300278 .buf = pllbuf, .len = 4 };
Chris Pascoe780dfef2006-02-28 08:34:59 -0300279 int err;
280
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300281 dvb_pll_configure(dev->core->pll_desc, pllbuf,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300282 params->frequency,
283 params->u.ofdm.bandwidth);
284
Patrick Boettcherdea74862006-05-14 05:01:31 -0300285 if (fe->ops.i2c_gate_ctrl)
286 fe->ops.i2c_gate_ctrl(fe, 1);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300287 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
288 printk(KERN_WARNING "cx88-dvb: %s error "
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300289 "(addr %02x <- %02x, err = %i)\n",
290 __FUNCTION__, pllbuf[0], pllbuf[1], err);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300291 if (err < 0)
292 return err;
293 else
294 return -EREMOTEIO;
295 }
296
297 return 0;
298}
299
300static struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300301 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300302 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300303};
304
305static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300306 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300307};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300308
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309static struct cx22702_config connexant_refboard_config = {
310 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700311 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312};
313
314static struct cx22702_config hauppauge_novat_config = {
315 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700316 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317};
Steven Toth611900c2006-01-09 15:25:12 -0200318static struct cx22702_config hauppauge_hvr1100_config = {
319 .demod_address = 0x63,
320 .output_mode = CX22702_SERIAL_OUTPUT,
Steven Toth611900c2006-01-09 15:25:12 -0200321};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323static int or51132_set_ts_param(struct dvb_frontend* fe,
324 int is_punctured)
325{
326 struct cx8802_dev *dev= fe->dvb->priv;
327 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
328 return 0;
329}
330
Adrian Bunk408b6642005-05-01 08:59:29 -0700331static struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300332 .demod_address = 0x15,
333 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300336static int lgdt3302_tuner_set_params(struct dvb_frontend* fe,
Trent Piepho657de3c2006-06-20 00:30:57 -0300337 struct dvb_frontend_parameters* params)
Michael Krufkyb6aef072005-07-27 11:45:54 -0700338{
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700339 /* FIXME make this routine use the tuner-simple code.
340 * It could probably be shared with a number of ATSC
341 * frontends. Many share the same tuner with analog TV. */
342
Michael Krufkyb6aef072005-07-27 11:45:54 -0700343 struct cx8802_dev *dev= fe->dvb->priv;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700344 struct cx88_core *core = dev->core;
Michael Krufky1963c902005-08-08 09:22:43 -0700345 u8 buf[4];
346 struct i2c_msg msg =
347 { .addr = dev->core->pll_addr, .flags = 0, .buf = buf, .len = 4 };
348 int err;
Michael Krufkyb6aef072005-07-27 11:45:54 -0700349
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700350 dvb_pll_configure(core->pll_desc, buf, params->frequency, 0);
Michael Krufky1963c902005-08-08 09:22:43 -0700351 dprintk(1, "%s: tuner at 0x%02x bytes: 0x%02x 0x%02x 0x%02x 0x%02x\n",
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300352 __FUNCTION__, msg.addr, buf[0],buf[1],buf[2],buf[3]);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300353
Patrick Boettcherdea74862006-05-14 05:01:31 -0300354 if (fe->ops.i2c_gate_ctrl)
355 fe->ops.i2c_gate_ctrl(fe, 1);
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700356 if ((err = i2c_transfer(&core->i2c_adap, &msg, 1)) != 1) {
Michael Krufky1963c902005-08-08 09:22:43 -0700357 printk(KERN_WARNING "cx88-dvb: %s error "
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300358 "(addr %02x <- %02x, err = %i)\n",
359 __FUNCTION__, buf[0], buf[1], err);
Michael Krufky1963c902005-08-08 09:22:43 -0700360 if (err < 0)
361 return err;
362 else
363 return -EREMOTEIO;
364 }
Michael Krufkyb6aef072005-07-27 11:45:54 -0700365 return 0;
366}
367
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300368static int lgdt3303_tuner_set_params(struct dvb_frontend* fe,
369 struct dvb_frontend_parameters* params)
Michael Krufky7e557742006-04-18 17:47:08 -0300370{
371 struct cx8802_dev *dev= fe->dvb->priv;
372 struct cx88_core *core = dev->core;
373
374 /* Put the analog decoder in standby to keep it quiet */
375 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
376
377 return lg_h06xf_pll_set(fe, &core->i2c_adap, params);
378}
379
Michael Krufky6ddcc912005-07-27 11:46:00 -0700380static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700381{
382 struct cx8802_dev *dev= fe->dvb->priv;
383 struct cx88_core *core = dev->core;
384
385 dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
386 if (index == 0)
387 cx_clear(MO_GP0_IO, 8);
388 else
389 cx_set(MO_GP0_IO, 8);
390 return 0;
391}
392
Michael Krufky6ddcc912005-07-27 11:46:00 -0700393static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700394{
395 struct cx8802_dev *dev= fe->dvb->priv;
396 if (is_punctured)
397 dev->ts_gen_cntrl |= 0x04;
398 else
399 dev->ts_gen_cntrl &= ~0x04;
400 return 0;
401}
402
Michael Krufky6ddcc912005-07-27 11:46:00 -0700403static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300404 .demod_address = 0x0e,
405 .demod_chip = LGDT3302,
406 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
407 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700408};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700409
410static struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300411 .demod_address = 0x0e,
412 .demod_chip = LGDT3303,
413 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
414 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700415};
Rusty Scottda215d22006-04-07 02:21:31 -0300416
417static struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300418 .demod_address = 0x59,
419 .demod_chip = LGDT3303,
420 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
421 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300422};
Michael Krufkyf1798492005-07-07 17:58:39 -0700423
Kirk Laprayfde6d312005-11-08 21:38:18 -0800424static int nxt200x_set_ts_param(struct dvb_frontend* fe,
425 int is_punctured)
426{
427 struct cx8802_dev *dev= fe->dvb->priv;
428 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
429 return 0;
430}
431
Kirk Laprayd4c34aa2005-11-08 21:38:40 -0800432static int nxt200x_set_pll_input(u8* buf, int input)
433{
434 if (input)
435 buf[3] |= 0x08;
436 else
437 buf[3] &= ~0x08;
438 return 0;
439}
440
Kirk Laprayfde6d312005-11-08 21:38:18 -0800441static struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300442 .demod_address = 0x0a,
443 .set_pll_input = nxt200x_set_pll_input,
444 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800445};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800446
Steven Toth0fa14aa2006-01-09 15:25:02 -0200447static int cx24123_set_ts_param(struct dvb_frontend* fe,
448 int is_punctured)
449{
450 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300451 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200452 return 0;
453}
454
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300455static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
456 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200457{
458 struct cx8802_dev *dev= fe->dvb->priv;
459 struct cx88_core *core = dev->core;
460
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300461 if (voltage == SEC_VOLTAGE_OFF) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300462 cx_write(MO_GP0_IO, 0x000006fb);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300463 } else {
464 cx_write(MO_GP0_IO, 0x000006f9);
465 }
466
467 if (core->prev_set_voltage)
468 return core->prev_set_voltage(fe, voltage);
469 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200470}
471
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300472static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
473 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300474{
475 struct cx8802_dev *dev= fe->dvb->priv;
476 struct cx88_core *core = dev->core;
477
478 if (voltage == SEC_VOLTAGE_OFF) {
479 dprintk(1,"LNB Voltage OFF\n");
480 cx_write(MO_GP0_IO, 0x0000efff);
481 }
482
483 if (core->prev_set_voltage)
484 return core->prev_set_voltage(fe, voltage);
485 return 0;
486}
487
488static struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300489 .demod_address = 0x55,
490 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300491};
492
Steven Toth0fa14aa2006-01-09 15:25:02 -0200493static struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300494 .demod_address = 0x55,
495 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200496};
497
498static struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300499 .demod_address = 0x15,
500 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300501 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200502};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200503
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504static int dvb_register(struct cx8802_dev *dev)
505{
506 /* init struct videobuf_dvb */
507 dev->dvb.name = dev->core->name;
508 dev->ts_gen_cntrl = 0x0c;
509
510 /* init frontend */
511 switch (dev->core->board) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300513 dev->dvb.frontend = dvb_attach(cx22702_attach,
514 &hauppauge_novat_config,
515 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300516 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300517 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300518 &dev->core->i2c_adap,
519 &dvb_pll_thomson_dtt759x);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300520 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700522 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200524 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800525 case CX88_BOARD_WINFAST_DTV1000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300526 dev->dvb.frontend = dvb_attach(cx22702_attach,
527 &connexant_refboard_config,
528 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300529 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300530 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300531 &dev->core->i2c_adap,
532 &dvb_pll_thomson_dtt7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300533 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300535 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -0200536 case CX88_BOARD_HAUPPAUGE_HVR1100:
537 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300538 dev->dvb.frontend = dvb_attach(cx22702_attach,
539 &hauppauge_hvr1100_config,
540 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300541 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300542 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300543 &dev->core->i2c_adap,
544 &dvb_pll_fmd1216me);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300545 }
Steven Toth611900c2006-01-09 15:25:12 -0200546 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300547 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300548 dev->dvb.frontend = dvb_attach(mt352_attach,
549 &dvico_fusionhdtv,
550 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300551 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300552 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Chris Pascoec162dff2006-08-08 15:48:08 -0300553 NULL, &dvb_pll_thomson_dtt7579);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300554 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300555 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300556 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300557 dev->dvb.frontend = dvb_attach(zl10353_attach,
558 &dvico_fusionhdtv_plus_v1_1,
559 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300560 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300561 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Chris Pascoec162dff2006-08-08 15:48:08 -0300562 NULL, &dvb_pll_thomson_dtt7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300563 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300564 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300565 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300566 /* The tin box says DEE1601, but it seems to be DTT7579
567 * compatible, with a slightly different MT352 AGC gain. */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300568 dev->dvb.frontend = dvb_attach(mt352_attach,
569 &dvico_fusionhdtv_dual,
570 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300571 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300572 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300573 NULL, &dvb_pll_thomson_dtt7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300574 break;
575 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300576 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300577 dev->dvb.frontend = dvb_attach(zl10353_attach,
578 &dvico_fusionhdtv_plus_v1_1,
579 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300580 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300581 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300582 NULL, &dvb_pll_thomson_dtt7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300583 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300584 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300586 dev->dvb.frontend = dvb_attach(mt352_attach,
587 &dvico_fusionhdtv,
588 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300589 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300590 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300591 NULL, &dvb_pll_lg_z201);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300592 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 case CX88_BOARD_KWORLD_DVB_T:
595 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700596 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300597 dev->dvb.frontend = dvb_attach(mt352_attach,
598 &dntv_live_dvbt_config,
599 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300600 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300601 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300602 NULL, &dvb_pll_unknown_1);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300603 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200605 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
606#ifdef HAVE_VP3054_I2C
607 dev->core->pll_addr = 0x61;
608 dev->core->pll_desc = &dvb_pll_fmd1216me;
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300609 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Chris Pascoefc40b262006-01-09 15:25:35 -0200610 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300611 if (dev->dvb.frontend != NULL) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300612 dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300613 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200614#else
615 printk("%s: built without vp3054 support\n", dev->core->name);
616#endif
617 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300618 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
619 dev->core->pll_addr = 0x61;
Michael Krufky91ae3292006-03-01 00:04:42 -0300620 dev->core->pll_desc = &dvb_pll_thomson_fe6600;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300621 dev->dvb.frontend = dvb_attach(zl10353_attach,
622 &dvico_fusionhdtv_hybrid,
623 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300624 if (dev->dvb.frontend != NULL) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300625 dev->dvb.frontend->ops.tuner_ops.set_params = dvico_hybrid_tuner_set_params;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300626 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300627 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 case CX88_BOARD_PCHDTV_HD3000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300629 dev->dvb.frontend = dvb_attach(or51132_attach,
630 &pchdtv_hd3000,
631 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300632 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300633 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300634 &dev->core->i2c_adap,
635 &dvb_pll_thomson_dtt761x);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300636 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700638 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
639 dev->ts_gen_cntrl = 0x08;
640 {
641 /* Do a hardware reset of chip before using it. */
642 struct cx88_core *core = dev->core;
643
644 cx_clear(MO_GP0_IO, 1);
645 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700646 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700647 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700648
649 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700650 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyb6aef072005-07-27 11:45:54 -0700651 dev->core->pll_addr = 0x61;
652 dev->core->pll_desc = &dvb_pll_microtune_4042;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300653 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
654 &fusionhdtv_3_gold,
655 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300656 if (dev->dvb.frontend != NULL) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300657 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300658 }
Michael Krufkyf1798492005-07-07 17:58:39 -0700659 }
660 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700661 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
662 dev->ts_gen_cntrl = 0x08;
663 {
664 /* Do a hardware reset of chip before using it. */
665 struct cx88_core *core = dev->core;
666
667 cx_clear(MO_GP0_IO, 1);
668 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700669 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700670 mdelay(200);
Michael Krufkyb6aef072005-07-27 11:45:54 -0700671 dev->core->pll_addr = 0x61;
Michael Krufky83ac87222006-01-09 15:25:29 -0200672 dev->core->pll_desc = &dvb_pll_thomson_dtt761x;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300673 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
674 &fusionhdtv_3_gold,
675 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300676 if (dev->dvb.frontend != NULL) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300677 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3302_tuner_set_params;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300678 }
Michael Krufky0d723c02005-07-07 17:58:42 -0700679 }
680 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700681 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
682 dev->ts_gen_cntrl = 0x08;
683 {
684 /* Do a hardware reset of chip before using it. */
685 struct cx88_core *core = dev->core;
686
687 cx_clear(MO_GP0_IO, 1);
688 mdelay(100);
689 cx_set(MO_GP0_IO, 1);
690 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300691 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
692 &fusionhdtv_5_gold,
693 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300694 if (dev->dvb.frontend != NULL) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300695 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300696 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700697 }
698 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300699 case CX88_BOARD_PCHDTV_HD5500:
700 dev->ts_gen_cntrl = 0x08;
701 {
702 /* Do a hardware reset of chip before using it. */
703 struct cx88_core *core = dev->core;
704
705 cx_clear(MO_GP0_IO, 1);
706 mdelay(100);
707 cx_set(MO_GP0_IO, 1);
708 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300709 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
710 &pchdtv_hd5500,
711 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300712 if (dev->dvb.frontend != NULL) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300713 dev->dvb.frontend->ops.tuner_ops.set_params = lgdt3303_tuner_set_params;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300714 }
Rusty Scottda215d22006-04-07 02:21:31 -0300715 }
716 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -0800717 case CX88_BOARD_ATI_HDTVWONDER:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300718 dev->dvb.frontend = dvb_attach(nxt200x_attach,
719 &ati_hdtvwonder,
720 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300721 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300722 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky4ad8eee52006-08-08 15:48:08 -0300723 NULL, &dvb_pll_tuv1236d);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300724 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800725 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200726 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
727 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300728 dev->dvb.frontend = dvb_attach(cx24123_attach,
729 &hauppauge_novas_config,
730 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300731 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300732 dvb_attach(isl6421_attach, dev->dvb.frontend,
733 &dev->core->i2c_adap, 0x08, 0x00, 0x00);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300734 }
Steven Toth0fa14aa2006-01-09 15:25:02 -0200735 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200736 case CX88_BOARD_KWORLD_DVBS_100:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300737 dev->dvb.frontend = dvb_attach(cx24123_attach,
738 &kworld_dvbs_100_config,
739 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300740 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300741 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
742 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300743 }
Vadim Catana0e0351e2006-01-09 15:25:02 -0200744 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300745 case CX88_BOARD_GENIATECH_DVBS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300746 dev->dvb.frontend = dvb_attach(cx24123_attach,
747 &geniatech_dvbs_config,
748 &dev->core->i2c_adap);
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300749 if (dev->dvb.frontend) {
750 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
751 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
752 }
753 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 default:
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700755 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
756 dev->core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 break;
758 }
759 if (NULL == dev->dvb.frontend) {
760 printk("%s: frontend initialization failed\n",dev->core->name);
761 return -1;
762 }
763
764 if (dev->core->pll_desc) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300765 dev->dvb.frontend->ops.info.frequency_min = dev->core->pll_desc->min;
766 dev->dvb.frontend->ops.info.frequency_max = dev->core->pll_desc->max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 }
768
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -0700769 /* Put the analog decoder in standby to keep it quiet */
770 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
771
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 /* register everything */
Andrew de Quinceyd09dbf92006-04-10 09:27:37 -0300773 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774}
775
776/* ----------------------------------------------------------- */
777
778static int __devinit dvb_probe(struct pci_dev *pci_dev,
779 const struct pci_device_id *pci_id)
780{
781 struct cx8802_dev *dev;
782 struct cx88_core *core;
783 int err;
784
785 /* general setup */
786 core = cx88_core_get(pci_dev);
787 if (NULL == core)
788 return -EINVAL;
789
790 err = -ENODEV;
791 if (!cx88_boards[core->board].dvb)
792 goto fail_core;
793
794 err = -ENOMEM;
Panagiotis Issaris74081872006-01-11 19:40:56 -0200795 dev = kzalloc(sizeof(*dev),GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 if (NULL == dev)
797 goto fail_core;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 dev->pci = pci_dev;
799 dev->core = core;
800
801 err = cx8802_init_common(dev);
802 if (0 != err)
803 goto fail_free;
804
Chris Pascoefc40b262006-01-09 15:25:35 -0200805#ifdef HAVE_VP3054_I2C
806 err = vp3054_i2c_probe(dev);
807 if (0 != err)
808 goto fail_free;
809#endif
810
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 /* dvb stuff */
812 printk("%s/2: cx2388x based dvb card\n", core->name);
813 videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops,
814 dev->pci, &dev->slock,
815 V4L2_BUF_TYPE_VIDEO_CAPTURE,
816 V4L2_FIELD_TOP,
817 sizeof(struct cx88_buffer),
818 dev);
819 err = dvb_register(dev);
820 if (0 != err)
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700821 goto fail_fini;
Steven Toth611900c2006-01-09 15:25:12 -0200822
823 /* Maintain a reference to cx88-video can query the 8802 device. */
824 core->dvbdev = dev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 return 0;
826
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700827 fail_fini:
828 cx8802_fini_common(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 fail_free:
830 kfree(dev);
831 fail_core:
832 cx88_core_put(core,pci_dev);
833 return err;
834}
835
836static void __devexit dvb_remove(struct pci_dev *pci_dev)
837{
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800838 struct cx8802_dev *dev = pci_get_drvdata(pci_dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839
Steven Toth611900c2006-01-09 15:25:12 -0200840 /* Destroy any 8802 reference. */
841 dev->core->dvbdev = NULL;
842
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 /* dvb */
844 videobuf_dvb_unregister(&dev->dvb);
845
Chris Pascoefc40b262006-01-09 15:25:35 -0200846#ifdef HAVE_VP3054_I2C
847 vp3054_i2c_remove(dev);
848#endif
849
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 /* common */
851 cx8802_fini_common(dev);
852 cx88_core_put(dev->core,dev->pci);
853 kfree(dev);
854}
855
856static struct pci_device_id cx8802_pci_tbl[] = {
857 {
858 .vendor = 0x14f1,
859 .device = 0x8802,
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800860 .subvendor = PCI_ANY_ID,
861 .subdevice = PCI_ANY_ID,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 },{
863 /* --- end of list --- */
864 }
865};
866MODULE_DEVICE_TABLE(pci, cx8802_pci_tbl);
867
868static struct pci_driver dvb_pci_driver = {
Mauro Carvalho Chehab4ac97912005-11-08 21:37:43 -0800869 .name = "cx88-dvb",
870 .id_table = cx8802_pci_tbl,
871 .probe = dvb_probe,
872 .remove = __devexit_p(dvb_remove),
Alexey Dobriyan17bc98a2006-08-12 22:01:27 -0300873#ifdef CONFIG_PM
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874 .suspend = cx8802_suspend_common,
875 .resume = cx8802_resume_common,
Alexey Dobriyan17bc98a2006-08-12 22:01:27 -0300876#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877};
878
879static int dvb_init(void)
880{
881 printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n",
882 (CX88_VERSION_CODE >> 16) & 0xff,
883 (CX88_VERSION_CODE >> 8) & 0xff,
884 CX88_VERSION_CODE & 0xff);
885#ifdef SNAPSHOT
886 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
887 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
888#endif
889 return pci_register_driver(&dvb_pci_driver);
890}
891
892static void dvb_fini(void)
893{
894 pci_unregister_driver(&dvb_pci_driver);
895}
896
897module_init(dvb_init);
898module_exit(dvb_fini);
899
900/*
901 * Local variables:
902 * c-basic-offset: 8
903 * compile-command: "make DVB=1"
904 * End:
905 */