blob: 8b203354fccdff8f533702fba23610a6a9f0f3c8 [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"
Michael Krufky76db93d2006-11-19 19:45:26 -030045#include "lgh06xf.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030046#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) \
Steven Toth6c5be742006-12-02 21:15:51 -020060 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
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
Michael Krufky4a390552006-12-05 02:00:53 -030077static int dvb_buf_prepare(struct videobuf_queue *q,
78 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079{
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
Michael Krufky4a390552006-12-05 02:00:53 -030090static void dvb_buf_release(struct videobuf_queue *q,
91 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030093 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
95
Adrian Bunk408b6642005-05-01 08:59:29 -070096static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 .buf_setup = dvb_buf_setup,
98 .buf_prepare = dvb_buf_prepare,
99 .buf_queue = dvb_buf_queue,
100 .buf_release = dvb_buf_release,
101};
102
103/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300104
105static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
106{
107 struct cx8802_dev *dev= fe->dvb->priv;
108 struct cx8802_driver *drv = NULL;
109 int ret = 0;
110
111 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
112 if (drv) {
Michael Krufky4a390552006-12-05 02:00:53 -0300113 if (acquire)
Michael Krufky22f3f172006-12-05 01:38:58 -0300114 ret = drv->request_acquire(drv);
115 else
116 ret = drv->request_release(drv);
117 }
118
119 return ret;
120}
121
122/* ------------------------------------------------------------------ */
123
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200124static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125{
126 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
127 static u8 reset [] = { RESET, 0x80 };
128 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
129 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
130 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
131 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
132
133 mt352_write(fe, clock_config, sizeof(clock_config));
134 udelay(200);
135 mt352_write(fe, reset, sizeof(reset));
136 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
137
138 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
139 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
140 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
141 return 0;
142}
143
Chris Pascoe43eabb42006-01-09 18:21:28 -0200144static int dvico_dual_demod_init(struct dvb_frontend *fe)
145{
146 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
147 static u8 reset [] = { RESET, 0x80 };
148 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
149 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
150 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
151 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
152
153 mt352_write(fe, clock_config, sizeof(clock_config));
154 udelay(200);
155 mt352_write(fe, reset, sizeof(reset));
156 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
157
158 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
159 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
160 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
161
162 return 0;
163}
164
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
166{
167 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
168 static u8 reset [] = { 0x50, 0x80 };
169 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
170 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800171 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 static u8 dntv_extra[] = { 0xB5, 0x7A };
173 static u8 capt_range_cfg[] = { 0x75, 0x32 };
174
175 mt352_write(fe, clock_config, sizeof(clock_config));
176 udelay(2000);
177 mt352_write(fe, reset, sizeof(reset));
178 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
179
180 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
181 udelay(2000);
182 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
183 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
184
185 return 0;
186}
187
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188static struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300189 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200190 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191};
192
193static struct mt352_config dntv_live_dvbt_config = {
194 .demod_address = 0x0f,
195 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196};
Chris Pascoefc40b262006-01-09 15:25:35 -0200197
Chris Pascoe43eabb42006-01-09 18:21:28 -0200198static struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300199 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200200 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200201};
202
Chris Pascoefc40b262006-01-09 15:25:35 -0200203#ifdef HAVE_VP3054_I2C
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200204static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
205{
206 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
207 static u8 reset [] = { 0x50, 0x80 };
208 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
209 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
210 0x00, 0xFF, 0x00, 0x40, 0x40 };
211 static u8 dntv_extra[] = { 0xB5, 0x7A };
212 static u8 capt_range_cfg[] = { 0x75, 0x32 };
213
214 mt352_write(fe, clock_config, sizeof(clock_config));
215 udelay(2000);
216 mt352_write(fe, reset, sizeof(reset));
217 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
218
219 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
220 udelay(2000);
221 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
222 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
223
224 return 0;
225}
226
Chris Pascoefc40b262006-01-09 15:25:35 -0200227static int philips_fmd1216_pll_init(struct dvb_frontend *fe)
228{
229 struct cx8802_dev *dev= fe->dvb->priv;
230
231 /* this message is to set up ATC and ALC */
232 static u8 fmd1216_init[] = { 0x0b, 0xdc, 0x9c, 0xa0 };
233 struct i2c_msg msg =
234 { .addr = dev->core->pll_addr, .flags = 0,
235 .buf = fmd1216_init, .len = sizeof(fmd1216_init) };
236 int err;
237
Patrick Boettcherdea74862006-05-14 05:01:31 -0300238 if (fe->ops.i2c_gate_ctrl)
239 fe->ops.i2c_gate_ctrl(fe, 1);
Chris Pascoefc40b262006-01-09 15:25:35 -0200240 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
241 if (err < 0)
242 return err;
243 else
244 return -EREMOTEIO;
245 }
246
247 return 0;
248}
249
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300250static int dntv_live_dvbt_pro_tuner_set_params(struct dvb_frontend* fe,
251 struct dvb_frontend_parameters* params)
Chris Pascoefc40b262006-01-09 15:25:35 -0200252{
253 struct cx8802_dev *dev= fe->dvb->priv;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300254 u8 buf[4];
Chris Pascoefc40b262006-01-09 15:25:35 -0200255 struct i2c_msg msg =
256 { .addr = dev->core->pll_addr, .flags = 0,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300257 .buf = buf, .len = 4 };
Chris Pascoefc40b262006-01-09 15:25:35 -0200258 int err;
259
260 /* Switch PLL to DVB mode */
261 err = philips_fmd1216_pll_init(fe);
262 if (err)
263 return err;
264
265 /* Tune PLL */
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300266 dvb_pll_configure(dev->core->pll_desc, buf,
Chris Pascoefc40b262006-01-09 15:25:35 -0200267 params->frequency,
268 params->u.ofdm.bandwidth);
Patrick Boettcherdea74862006-05-14 05:01:31 -0300269 if (fe->ops.i2c_gate_ctrl)
270 fe->ops.i2c_gate_ctrl(fe, 1);
Chris Pascoefc40b262006-01-09 15:25:35 -0200271 if ((err = i2c_transfer(&dev->core->i2c_adap, &msg, 1)) != 1) {
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300272
Chris Pascoefc40b262006-01-09 15:25:35 -0200273 printk(KERN_WARNING "cx88-dvb: %s error "
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300274 "(addr %02x <- %02x, err = %i)\n",
275 __FUNCTION__, dev->core->pll_addr, buf[0], err);
Chris Pascoefc40b262006-01-09 15:25:35 -0200276 if (err < 0)
277 return err;
278 else
279 return -EREMOTEIO;
280 }
281
282 return 0;
283}
284
285static struct mt352_config dntv_live_dvbt_pro_config = {
286 .demod_address = 0x0f,
287 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200288 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200289};
290#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291
Chris Pascoe780dfef2006-02-28 08:34:59 -0300292static struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300293 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300294 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300295};
296
297static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300298 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300299};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300300
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301static struct cx22702_config connexant_refboard_config = {
302 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700303 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304};
305
Michael Krufkyed355262006-12-05 01:34:56 -0300306static struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300307 .demod_address = 0x63,
308 .output_mode = CX22702_SERIAL_OUTPUT,
309};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
Michael Krufky4a390552006-12-05 02:00:53 -0300311static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312{
313 struct cx8802_dev *dev= fe->dvb->priv;
314 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
315 return 0;
316}
317
Adrian Bunk408b6642005-05-01 08:59:29 -0700318static struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300319 .demod_address = 0x15,
320 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322
Michael Krufky6ddcc912005-07-27 11:46:00 -0700323static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700324{
325 struct cx8802_dev *dev= fe->dvb->priv;
326 struct cx88_core *core = dev->core;
327
328 dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
329 if (index == 0)
330 cx_clear(MO_GP0_IO, 8);
331 else
332 cx_set(MO_GP0_IO, 8);
333 return 0;
334}
335
Michael Krufky6ddcc912005-07-27 11:46:00 -0700336static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700337{
338 struct cx8802_dev *dev= fe->dvb->priv;
339 if (is_punctured)
340 dev->ts_gen_cntrl |= 0x04;
341 else
342 dev->ts_gen_cntrl &= ~0x04;
343 return 0;
344}
345
Michael Krufky6ddcc912005-07-27 11:46:00 -0700346static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300347 .demod_address = 0x0e,
348 .demod_chip = LGDT3302,
349 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
350 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700351};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700352
353static struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300354 .demod_address = 0x0e,
355 .demod_chip = LGDT3303,
356 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
357 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700358};
Rusty Scottda215d22006-04-07 02:21:31 -0300359
360static struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300361 .demod_address = 0x59,
362 .demod_chip = LGDT3303,
363 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
364 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300365};
Michael Krufkyf1798492005-07-07 17:58:39 -0700366
Michael Krufky4a390552006-12-05 02:00:53 -0300367static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800368{
369 struct cx8802_dev *dev= fe->dvb->priv;
370 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
371 return 0;
372}
373
Kirk Laprayd4c34aa2005-11-08 21:38:40 -0800374static int nxt200x_set_pll_input(u8* buf, int input)
375{
376 if (input)
377 buf[3] |= 0x08;
378 else
379 buf[3] &= ~0x08;
380 return 0;
381}
382
Kirk Laprayfde6d312005-11-08 21:38:18 -0800383static struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300384 .demod_address = 0x0a,
385 .set_pll_input = nxt200x_set_pll_input,
386 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800387};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800388
Steven Toth0fa14aa2006-01-09 15:25:02 -0200389static int cx24123_set_ts_param(struct dvb_frontend* fe,
390 int is_punctured)
391{
392 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300393 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200394 return 0;
395}
396
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300397static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
398 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200399{
400 struct cx8802_dev *dev= fe->dvb->priv;
401 struct cx88_core *core = dev->core;
402
Michael Krufky4a390552006-12-05 02:00:53 -0300403 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300404 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300405 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300406 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300407
408 if (core->prev_set_voltage)
409 return core->prev_set_voltage(fe, voltage);
410 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200411}
412
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300413static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
414 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300415{
416 struct cx8802_dev *dev= fe->dvb->priv;
417 struct cx88_core *core = dev->core;
418
419 if (voltage == SEC_VOLTAGE_OFF) {
420 dprintk(1,"LNB Voltage OFF\n");
421 cx_write(MO_GP0_IO, 0x0000efff);
422 }
423
424 if (core->prev_set_voltage)
425 return core->prev_set_voltage(fe, voltage);
426 return 0;
427}
428
429static struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300430 .demod_address = 0x55,
431 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300432};
433
Steven Toth0fa14aa2006-01-09 15:25:02 -0200434static struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300435 .demod_address = 0x55,
436 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200437};
438
439static struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300440 .demod_address = 0x15,
441 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300442 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200443};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200444
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445static int dvb_register(struct cx8802_dev *dev)
446{
447 /* init struct videobuf_dvb */
448 dev->dvb.name = dev->core->name;
449 dev->ts_gen_cntrl = 0x0c;
450
451 /* init frontend */
452 switch (dev->core->board) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300454 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300455 &connexant_refboard_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300456 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300457 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300458 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300459 &dev->core->i2c_adap,
460 &dvb_pll_thomson_dtt759x);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300461 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700463 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200465 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800466 case CX88_BOARD_WINFAST_DTV1000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300467 dev->dvb.frontend = dvb_attach(cx22702_attach,
468 &connexant_refboard_config,
469 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300470 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300471 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300472 &dev->core->i2c_adap,
473 &dvb_pll_thomson_dtt7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300474 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300476 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -0200477 case CX88_BOARD_HAUPPAUGE_HVR1100:
478 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300479 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300480 &hauppauge_hvr_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300481 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300482 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300483 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky4a390552006-12-05 02:00:53 -0300484 &dev->core->i2c_adap, &dvb_pll_fmd1216me);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300485 }
Steven Toth611900c2006-01-09 15:25:12 -0200486 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300487 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300488 dev->dvb.frontend = dvb_attach(mt352_attach,
489 &dvico_fusionhdtv,
490 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300491 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300492 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Chris Pascoec162dff2006-08-08 15:48:08 -0300493 NULL, &dvb_pll_thomson_dtt7579);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300494 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300495 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300496 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300497 dev->dvb.frontend = dvb_attach(zl10353_attach,
498 &dvico_fusionhdtv_plus_v1_1,
499 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300500 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300501 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Chris Pascoec162dff2006-08-08 15:48:08 -0300502 NULL, &dvb_pll_thomson_dtt7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300503 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300504 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300505 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300506 /* The tin box says DEE1601, but it seems to be DTT7579
507 * compatible, with a slightly different MT352 AGC gain. */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300508 dev->dvb.frontend = dvb_attach(mt352_attach,
509 &dvico_fusionhdtv_dual,
510 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300511 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300512 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300513 NULL, &dvb_pll_thomson_dtt7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300514 break;
515 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300516 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300517 dev->dvb.frontend = dvb_attach(zl10353_attach,
518 &dvico_fusionhdtv_plus_v1_1,
519 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300520 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300521 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300522 NULL, &dvb_pll_thomson_dtt7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300523 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300524 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300526 dev->dvb.frontend = dvb_attach(mt352_attach,
527 &dvico_fusionhdtv,
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, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300531 NULL, &dvb_pll_lg_z201);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300532 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 case CX88_BOARD_KWORLD_DVB_T:
535 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700536 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300537 dev->dvb.frontend = dvb_attach(mt352_attach,
538 &dntv_live_dvbt_config,
539 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300540 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300541 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Chris Pascoec162dff2006-08-08 15:48:08 -0300542 NULL, &dvb_pll_unknown_1);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300543 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200545 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
546#ifdef HAVE_VP3054_I2C
547 dev->core->pll_addr = 0x61;
548 dev->core->pll_desc = &dvb_pll_fmd1216me;
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300549 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Chris Pascoefc40b262006-01-09 15:25:35 -0200550 &((struct vp3054_i2c_state *)dev->card_priv)->adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300551 if (dev->dvb.frontend != NULL) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300552 dev->dvb.frontend->ops.tuner_ops.set_params = dntv_live_dvbt_pro_tuner_set_params;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300553 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200554#else
555 printk("%s: built without vp3054 support\n", dev->core->name);
556#endif
557 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300558 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300559 dev->dvb.frontend = dvb_attach(zl10353_attach,
560 &dvico_fusionhdtv_hybrid,
561 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300562 if (dev->dvb.frontend != NULL) {
Michael Krufky5786a342006-12-05 01:21:19 -0300563 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
564 &dev->core->i2c_adap,
565 &dvb_pll_thomson_fe6600);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300566 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300567 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 case CX88_BOARD_PCHDTV_HD3000:
Michael Krufky4a390552006-12-05 02:00:53 -0300569 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300570 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300571 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300572 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300573 &dev->core->i2c_adap,
574 &dvb_pll_thomson_dtt761x);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300575 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700577 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
578 dev->ts_gen_cntrl = 0x08;
579 {
580 /* Do a hardware reset of chip before using it. */
581 struct cx88_core *core = dev->core;
582
583 cx_clear(MO_GP0_IO, 1);
584 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700585 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700586 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700587
588 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700589 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300590 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
591 &fusionhdtv_3_gold,
592 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300593 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300594 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
595 &dev->core->i2c_adap,
596 &dvb_pll_microtune_4042);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300597 }
Michael Krufkyf1798492005-07-07 17:58:39 -0700598 }
599 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700600 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
601 dev->ts_gen_cntrl = 0x08;
602 {
603 /* Do a hardware reset of chip before using it. */
604 struct cx88_core *core = dev->core;
605
606 cx_clear(MO_GP0_IO, 1);
607 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700608 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700609 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300610 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
611 &fusionhdtv_3_gold,
612 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300613 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300614 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
615 &dev->core->i2c_adap,
616 &dvb_pll_thomson_dtt761x);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300617 }
Michael Krufky0d723c02005-07-07 17:58:42 -0700618 }
619 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700620 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
621 dev->ts_gen_cntrl = 0x08;
622 {
623 /* Do a hardware reset of chip before using it. */
624 struct cx88_core *core = dev->core;
625
626 cx_clear(MO_GP0_IO, 1);
627 mdelay(100);
628 cx_set(MO_GP0_IO, 1);
629 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300630 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
631 &fusionhdtv_5_gold,
632 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300633 if (dev->dvb.frontend != NULL) {
Michael Krufky76db93d2006-11-19 19:45:26 -0300634 dvb_attach(lgh06xf_attach, dev->dvb.frontend,
635 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300636 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700637 }
638 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300639 case CX88_BOARD_PCHDTV_HD5500:
640 dev->ts_gen_cntrl = 0x08;
641 {
642 /* Do a hardware reset of chip before using it. */
643 struct cx88_core *core = dev->core;
644
645 cx_clear(MO_GP0_IO, 1);
646 mdelay(100);
647 cx_set(MO_GP0_IO, 1);
648 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300649 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
650 &pchdtv_hd5500,
651 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300652 if (dev->dvb.frontend != NULL) {
Michael Krufky76db93d2006-11-19 19:45:26 -0300653 dvb_attach(lgh06xf_attach, dev->dvb.frontend,
654 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300655 }
Rusty Scottda215d22006-04-07 02:21:31 -0300656 }
657 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -0800658 case CX88_BOARD_ATI_HDTVWONDER:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300659 dev->dvb.frontend = dvb_attach(nxt200x_attach,
660 &ati_hdtvwonder,
661 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300662 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300663 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky4ad8eee2006-08-08 15:48:08 -0300664 NULL, &dvb_pll_tuv1236d);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300665 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800666 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200667 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
668 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300669 dev->dvb.frontend = dvb_attach(cx24123_attach,
670 &hauppauge_novas_config,
671 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300672 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300673 dvb_attach(isl6421_attach, dev->dvb.frontend,
674 &dev->core->i2c_adap, 0x08, 0x00, 0x00);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300675 }
Steven Toth0fa14aa2006-01-09 15:25:02 -0200676 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200677 case CX88_BOARD_KWORLD_DVBS_100:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300678 dev->dvb.frontend = dvb_attach(cx24123_attach,
679 &kworld_dvbs_100_config,
680 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300681 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300682 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
683 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300684 }
Vadim Catana0e0351e2006-01-09 15:25:02 -0200685 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300686 case CX88_BOARD_GENIATECH_DVBS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300687 dev->dvb.frontend = dvb_attach(cx24123_attach,
688 &geniatech_dvbs_config,
689 &dev->core->i2c_adap);
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300690 if (dev->dvb.frontend) {
691 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
692 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
693 }
694 break;
Steven Toth6c5be742006-12-02 21:15:51 -0200695 case CX88_BOARD_HAUPPAUGE_HVR1300:
696 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300697 &hauppauge_hvr_config,
Steven Toth6c5be742006-12-02 21:15:51 -0200698 &dev->core->i2c_adap);
699 if (dev->dvb.frontend != NULL) {
700 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky4a390552006-12-05 02:00:53 -0300701 &dev->core->i2c_adap, &dvb_pll_fmd1216me);
Steven Toth6c5be742006-12-02 21:15:51 -0200702 }
703 break;
704 case CX88_BOARD_HAUPPAUGE_HVR3000:
705 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300706 &hauppauge_hvr_config,
Steven Toth6c5be742006-12-02 21:15:51 -0200707 &dev->core->i2c_adap);
708 if (dev->dvb.frontend != NULL) {
709 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky4a390552006-12-05 02:00:53 -0300710 &dev->core->i2c_adap, &dvb_pll_fmd1216me);
Steven Toth6c5be742006-12-02 21:15:51 -0200711 }
712 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 default:
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700714 printk("%s: The frontend of your DVB/ATSC card isn't supported yet\n",
715 dev->core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 break;
717 }
718 if (NULL == dev->dvb.frontend) {
719 printk("%s: frontend initialization failed\n",dev->core->name);
720 return -1;
721 }
722
723 if (dev->core->pll_desc) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300724 dev->dvb.frontend->ops.info.frequency_min = dev->core->pll_desc->min;
725 dev->dvb.frontend->ops.info.frequency_max = dev->core->pll_desc->max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 }
Steven Toth6c5be742006-12-02 21:15:51 -0200727 /* Ensure all frontends negotiate bus access */
728 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729
Mauro Carvalho Chehab93352f5c2005-09-13 01:25:42 -0700730 /* Put the analog decoder in standby to keep it quiet */
731 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
732
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 /* register everything */
Andrew de Quinceyd09dbf92006-04-10 09:27:37 -0300734 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735}
736
737/* ----------------------------------------------------------- */
738
Steven Toth6c5be742006-12-02 21:15:51 -0200739/* CX8802 MPEG -> mini driver - We have been given the hardware */
740static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741{
Steven Toth6c5be742006-12-02 21:15:51 -0200742 struct cx88_core *core = drv->core;
743 int err = 0;
744 dprintk( 1, "%s\n", __FUNCTION__);
745
746 switch (core->board) {
747 case CX88_BOARD_HAUPPAUGE_HVR1300:
748 /* We arrive here with either the cx23416 or the cx22702
749 * on the bus. Take the bus from the cx23416 and enable the
750 * cx22702 demod
751 */
752 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
753 cx_clear(MO_GP0_IO, 0x00000004);
754 udelay(1000);
755 break;
756 default:
757 err = -ENODEV;
758 }
759 return err;
760}
761
762/* CX8802 MPEG -> mini driver - We no longer have the hardware */
763static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
764{
765 struct cx88_core *core = drv->core;
766 int err = 0;
767 dprintk( 1, "%s\n", __FUNCTION__);
768
769 switch (core->board) {
770 case CX88_BOARD_HAUPPAUGE_HVR1300:
771 /* Do Nothing, leave the cx22702 on the bus. */
772 break;
773 default:
774 err = -ENODEV;
775 }
776 return err;
777}
778
779static int cx8802_dvb_probe(struct cx8802_driver *drv)
780{
781 struct cx88_core *core = drv->core;
782 struct cx8802_dev *dev = drv->core->dvbdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 int err;
784
Steven Toth6c5be742006-12-02 21:15:51 -0200785 dprintk( 1, "%s\n", __FUNCTION__);
786 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
787 core->board,
788 core->name,
789 core->pci_bus,
790 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791
792 err = -ENODEV;
Michael Krufky48d5e802006-09-25 14:09:10 -0300793 if (!(cx88_boards[core->board].mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 goto fail_core;
795
Chris Pascoefc40b262006-01-09 15:25:35 -0200796#ifdef HAVE_VP3054_I2C
797 err = vp3054_i2c_probe(dev);
798 if (0 != err)
Steven Toth6c5be742006-12-02 21:15:51 -0200799 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -0200800#endif
801
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 /* dvb stuff */
803 printk("%s/2: cx2388x based dvb card\n", core->name);
804 videobuf_queue_init(&dev->dvb.dvbq, &dvb_qops,
805 dev->pci, &dev->slock,
806 V4L2_BUF_TYPE_VIDEO_CAPTURE,
807 V4L2_FIELD_TOP,
808 sizeof(struct cx88_buffer),
809 dev);
810 err = dvb_register(dev);
Steven Toth6c5be742006-12-02 21:15:51 -0200811 if (err != 0)
812 printk("%s dvb_register failed err = %d\n", __FUNCTION__, err);
Steven Toth611900c2006-01-09 15:25:12 -0200813
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 return err;
816}
817
Steven Toth6c5be742006-12-02 21:15:51 -0200818static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819{
Steven Toth6c5be742006-12-02 21:15:51 -0200820 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -0200821
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 /* dvb */
823 videobuf_dvb_unregister(&dev->dvb);
824
Chris Pascoefc40b262006-01-09 15:25:35 -0200825#ifdef HAVE_VP3054_I2C
826 vp3054_i2c_remove(dev);
827#endif
828
Steven Toth6c5be742006-12-02 21:15:51 -0200829 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830}
831
Steven Toth6c5be742006-12-02 21:15:51 -0200832static struct cx8802_driver cx8802_dvb_driver = {
833 .type_id = CX88_MPEG_DVB,
834 .hw_access = CX8802_DRVCTL_SHARED,
835 .probe = cx8802_dvb_probe,
836 .remove = cx8802_dvb_remove,
837 .advise_acquire = cx8802_dvb_advise_acquire,
838 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839};
840
841static int dvb_init(void)
842{
843 printk(KERN_INFO "cx2388x dvb driver version %d.%d.%d loaded\n",
844 (CX88_VERSION_CODE >> 16) & 0xff,
845 (CX88_VERSION_CODE >> 8) & 0xff,
846 CX88_VERSION_CODE & 0xff);
847#ifdef SNAPSHOT
848 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
849 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
850#endif
Steven Toth6c5be742006-12-02 21:15:51 -0200851 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852}
853
854static void dvb_fini(void)
855{
Steven Toth6c5be742006-12-02 21:15:51 -0200856 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857}
858
859module_init(dvb_init);
860module_exit(dvb_fini);
861
862/*
863 * Local variables:
864 * c-basic-offset: 8
865 * compile-command: "make DVB=1"
866 * End:
867 */