blob: ce1752dc8e2b2cdfcf1a292ffc167fbb7823ab47 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines
5 *
Chris Pascoefc40b262006-01-09 15:25:35 -02006 * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/device.h>
27#include <linux/fs.h>
28#include <linux/kthread.h>
29#include <linux/file.h>
30#include <linux/suspend.h>
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "cx88.h"
33#include "dvb-pll.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020034#include <media/v4l2-common.h>
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070035
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030036#include "mt352.h"
37#include "mt352_priv.h"
Trent Piephoecf854d2007-05-05 20:11:32 -030038#include "cx88-vp3054-i2c.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030039#include "zl10353.h"
40#include "cx22702.h"
41#include "or51132.h"
42#include "lgdt330x.h"
Steven Toth60464da2008-01-05 16:53:01 -030043#include "s5h1409.h"
44#include "xc5000.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030045#include "nxt200x.h"
46#include "cx24123.h"
Andrew de Quinceycd20ca92006-05-12 20:31:51 -030047#include "isl6421.h"
Michael Krufky0df31f82008-04-22 14:46:13 -030048#include "tuner-simple.h"
Michael Krufky827855d2008-04-22 14:46:16 -030049#include "tda9887.h"
Steven Tothd893d5d2008-04-25 03:46:43 -030050#include "s5h1411.h"
Steven Toth5bd1b662008-09-04 01:17:33 -030051#include "cx24116.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
54MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
55MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
56MODULE_LICENSE("GPL");
57
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030058static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070059module_param(debug, int, 0644);
60MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
61
Janne Grunau78e92002008-04-09 19:13:13 -030062DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020065 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67/* ------------------------------------------------------------------ */
68
69static int dvb_buf_setup(struct videobuf_queue *q,
70 unsigned int *count, unsigned int *size)
71{
72 struct cx8802_dev *dev = q->priv_data;
73
74 dev->ts_packet_size = 188 * 4;
75 dev->ts_packet_count = 32;
76
77 *size = dev->ts_packet_size * dev->ts_packet_count;
78 *count = 32;
79 return 0;
80}
81
Michael Krufky4a390552006-12-05 02:00:53 -030082static int dvb_buf_prepare(struct videobuf_queue *q,
83 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070084{
85 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030086 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070087}
88
89static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
90{
91 struct cx8802_dev *dev = q->priv_data;
92 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
93}
94
Michael Krufky4a390552006-12-05 02:00:53 -030095static void dvb_buf_release(struct videobuf_queue *q,
96 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030098 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}
100
Adrian Bunk408b6642005-05-01 08:59:29 -0700101static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 .buf_setup = dvb_buf_setup,
103 .buf_prepare = dvb_buf_prepare,
104 .buf_queue = dvb_buf_queue,
105 .buf_release = dvb_buf_release,
106};
107
108/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300109
110static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
111{
112 struct cx8802_dev *dev= fe->dvb->priv;
113 struct cx8802_driver *drv = NULL;
114 int ret = 0;
115
116 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
117 if (drv) {
Michael Krufky4a390552006-12-05 02:00:53 -0300118 if (acquire)
Michael Krufky22f3f172006-12-05 01:38:58 -0300119 ret = drv->request_acquire(drv);
120 else
121 ret = drv->request_release(drv);
122 }
123
124 return ret;
125}
126
127/* ------------------------------------------------------------------ */
128
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200129static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130{
131 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
132 static u8 reset [] = { RESET, 0x80 };
133 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
134 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
135 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
136 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
137
138 mt352_write(fe, clock_config, sizeof(clock_config));
139 udelay(200);
140 mt352_write(fe, reset, sizeof(reset));
141 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
142
143 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
144 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
145 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
146 return 0;
147}
148
Chris Pascoe43eabb42006-01-09 18:21:28 -0200149static int dvico_dual_demod_init(struct dvb_frontend *fe)
150{
151 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
152 static u8 reset [] = { RESET, 0x80 };
153 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
154 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
155 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
156 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
157
158 mt352_write(fe, clock_config, sizeof(clock_config));
159 udelay(200);
160 mt352_write(fe, reset, sizeof(reset));
161 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
162
163 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
164 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
165 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
166
167 return 0;
168}
169
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
171{
172 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
173 static u8 reset [] = { 0x50, 0x80 };
174 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
175 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800176 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 static u8 dntv_extra[] = { 0xB5, 0x7A };
178 static u8 capt_range_cfg[] = { 0x75, 0x32 };
179
180 mt352_write(fe, clock_config, sizeof(clock_config));
181 udelay(2000);
182 mt352_write(fe, reset, sizeof(reset));
183 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
184
185 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
186 udelay(2000);
187 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
188 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
189
190 return 0;
191}
192
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193static struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300194 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200195 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196};
197
198static struct mt352_config dntv_live_dvbt_config = {
199 .demod_address = 0x0f,
200 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201};
Chris Pascoefc40b262006-01-09 15:25:35 -0200202
Chris Pascoe43eabb42006-01-09 18:21:28 -0200203static struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300204 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200205 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200206};
207
Trent Piephoecf854d2007-05-05 20:11:32 -0300208#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200209static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
210{
211 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
212 static u8 reset [] = { 0x50, 0x80 };
213 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
214 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
215 0x00, 0xFF, 0x00, 0x40, 0x40 };
216 static u8 dntv_extra[] = { 0xB5, 0x7A };
217 static u8 capt_range_cfg[] = { 0x75, 0x32 };
218
219 mt352_write(fe, clock_config, sizeof(clock_config));
220 udelay(2000);
221 mt352_write(fe, reset, sizeof(reset));
222 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
223
224 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
225 udelay(2000);
226 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
227 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
228
229 return 0;
230}
231
Chris Pascoefc40b262006-01-09 15:25:35 -0200232static struct mt352_config dntv_live_dvbt_pro_config = {
233 .demod_address = 0x0f,
234 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200235 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200236};
237#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238
Chris Pascoe780dfef2006-02-28 08:34:59 -0300239static struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300240 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300241 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300242};
243
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300244static struct zl10353_config dvico_fusionhdtv_xc3028 = {
245 .demod_address = 0x0f,
246 .if2 = 45600,
247 .no_tuner = 1,
248};
249
250static struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
251 .demod_address = 0x0f,
252 .if2 = 4560,
253 .no_tuner = 1,
254 .demod_init = dvico_fusionhdtv_demod_init,
255};
256
Chris Pascoe780dfef2006-02-28 08:34:59 -0300257static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300258 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300259};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300260
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261static struct cx22702_config connexant_refboard_config = {
262 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700263 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264};
265
Michael Krufkyed355262006-12-05 01:34:56 -0300266static struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300267 .demod_address = 0x63,
268 .output_mode = CX22702_SERIAL_OUTPUT,
269};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Michael Krufky4a390552006-12-05 02:00:53 -0300271static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272{
273 struct cx8802_dev *dev= fe->dvb->priv;
274 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
275 return 0;
276}
277
Adrian Bunk408b6642005-05-01 08:59:29 -0700278static struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300279 .demod_address = 0x15,
280 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Michael Krufky6ddcc912005-07-27 11:46:00 -0700283static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700284{
285 struct cx8802_dev *dev= fe->dvb->priv;
286 struct cx88_core *core = dev->core;
287
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300288 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700289 if (index == 0)
290 cx_clear(MO_GP0_IO, 8);
291 else
292 cx_set(MO_GP0_IO, 8);
293 return 0;
294}
295
Michael Krufky6ddcc912005-07-27 11:46:00 -0700296static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700297{
298 struct cx8802_dev *dev= fe->dvb->priv;
299 if (is_punctured)
300 dev->ts_gen_cntrl |= 0x04;
301 else
302 dev->ts_gen_cntrl &= ~0x04;
303 return 0;
304}
305
Michael Krufky6ddcc912005-07-27 11:46:00 -0700306static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300307 .demod_address = 0x0e,
308 .demod_chip = LGDT3302,
309 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
310 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700311};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700312
313static struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300314 .demod_address = 0x0e,
315 .demod_chip = LGDT3303,
316 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
317 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700318};
Rusty Scottda215d22006-04-07 02:21:31 -0300319
320static struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300321 .demod_address = 0x59,
322 .demod_chip = LGDT3303,
323 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
324 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300325};
Michael Krufkyf1798492005-07-07 17:58:39 -0700326
Michael Krufky4a390552006-12-05 02:00:53 -0300327static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800328{
329 struct cx8802_dev *dev= fe->dvb->priv;
330 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
331 return 0;
332}
333
334static struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300335 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300336 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800337};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800338
Steven Toth0fa14aa2006-01-09 15:25:02 -0200339static int cx24123_set_ts_param(struct dvb_frontend* fe,
340 int is_punctured)
341{
342 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300343 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200344 return 0;
345}
346
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300347static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
348 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200349{
350 struct cx8802_dev *dev= fe->dvb->priv;
351 struct cx88_core *core = dev->core;
352
Michael Krufky4a390552006-12-05 02:00:53 -0300353 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300354 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300355 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300356 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300357
358 if (core->prev_set_voltage)
359 return core->prev_set_voltage(fe, voltage);
360 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200361}
362
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300363static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
364 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300365{
366 struct cx8802_dev *dev= fe->dvb->priv;
367 struct cx88_core *core = dev->core;
368
369 if (voltage == SEC_VOLTAGE_OFF) {
370 dprintk(1,"LNB Voltage OFF\n");
371 cx_write(MO_GP0_IO, 0x0000efff);
372 }
373
374 if (core->prev_set_voltage)
375 return core->prev_set_voltage(fe, voltage);
376 return 0;
377}
378
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300379static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
380 fe_sec_voltage_t voltage)
381{
382 struct cx8802_dev *dev= fe->dvb->priv;
383 struct cx88_core *core = dev->core;
384
385 switch (voltage) {
386 case SEC_VOLTAGE_13:
387 printk("LNB Voltage SEC_VOLTAGE_13\n");
388 cx_write(MO_GP0_IO, 0x00006040);
389 break;
390 case SEC_VOLTAGE_18:
391 printk("LNB Voltage SEC_VOLTAGE_18\n");
392 cx_write(MO_GP0_IO, 0x00006060);
393 break;
394 case SEC_VOLTAGE_OFF:
395 printk("LNB Voltage SEC_VOLTAGE_off\n");
396 break;
397 }
398
399 if (core->prev_set_voltage)
400 return core->prev_set_voltage(fe, voltage);
401 return 0;
402}
403
Mauro Carvalho Chehabc4a3ce12008-04-22 14:45:31 -0300404static int cx88_pci_nano_callback(void *ptr, int command, int arg)
Steven Toth5c00fac2008-04-22 14:45:14 -0300405{
406 struct cx88_core *core = ptr;
407
408 switch (command) {
409 case XC2028_TUNER_RESET:
410 /* Send the tuner in then out of reset */
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300411 dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __func__, arg);
Steven Toth5c00fac2008-04-22 14:45:14 -0300412
413 switch (core->boardnr) {
414 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
415 /* GPIO-4 xc3028 tuner */
416
417 cx_set(MO_GP0_IO, 0x00001000);
418 cx_clear(MO_GP0_IO, 0x00000010);
419 msleep(100);
420 cx_set(MO_GP0_IO, 0x00000010);
421 msleep(100);
422 break;
423 }
424
425 break;
426 case XC2028_RESET_CLK:
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300427 dprintk(1, "%s: XC2028_RESET_CLK %d\n", __func__, arg);
Steven Toth5c00fac2008-04-22 14:45:14 -0300428 break;
429 default:
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300430 dprintk(1, "%s: unknown command %d, arg %d\n", __func__,
Steven Toth5c00fac2008-04-22 14:45:14 -0300431 command, arg);
432 return -EINVAL;
433 }
434
435 return 0;
436}
437
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300438static struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300439 .demod_address = 0x55,
440 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300441};
442
Steven Toth0fa14aa2006-01-09 15:25:02 -0200443static struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300444 .demod_address = 0x55,
445 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200446};
447
448static struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300449 .demod_address = 0x15,
450 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300451 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200452};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200453
Steven Toth60464da2008-01-05 16:53:01 -0300454static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
455 .demod_address = 0x32 >> 1,
456 .output_mode = S5H1409_PARALLEL_OUTPUT,
457 .gpio = S5H1409_GPIO_ON,
458 .qam_if = 44000,
459 .inversion = S5H1409_INVERSION_OFF,
460 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300461 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300462};
463
Steven Toth5c00fac2008-04-22 14:45:14 -0300464static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
465 .demod_address = 0x32 >> 1,
466 .output_mode = S5H1409_SERIAL_OUTPUT,
467 .gpio = S5H1409_GPIO_OFF,
468 .inversion = S5H1409_INVERSION_OFF,
469 .status_mode = S5H1409_DEMODLOCKING,
470 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
471};
472
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300473static struct s5h1409_config kworld_atsc_120_config = {
474 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300475 .output_mode = S5H1409_SERIAL_OUTPUT,
476 .gpio = S5H1409_GPIO_OFF,
477 .inversion = S5H1409_INVERSION_OFF,
478 .status_mode = S5H1409_DEMODLOCKING,
479 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
480};
481
Steven Toth60464da2008-01-05 16:53:01 -0300482static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
483 .i2c_address = 0x64,
484 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300485 .tuner_callback = cx88_tuner_callback,
486};
487
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300488static struct zl10353_config cx88_geniatech_x8000_mt = {
489 .demod_address = (0x1e >> 1),
490 .no_tuner = 1,
491};
492
Steven Tothd893d5d2008-04-25 03:46:43 -0300493static struct s5h1411_config dvico_fusionhdtv7_config = {
494 .output_mode = S5H1411_SERIAL_OUTPUT,
495 .gpio = S5H1411_GPIO_ON,
496 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
497 .qam_if = S5H1411_IF_44000,
498 .vsb_if = S5H1411_IF_44000,
499 .inversion = S5H1411_INVERSION_OFF,
500 .status_mode = S5H1411_DEMODLOCKING
501};
502
503static struct xc5000_config dvico_fusionhdtv7_tuner_config = {
504 .i2c_address = 0xc2 >> 1,
505 .if_khz = 5380,
506 .tuner_callback = cx88_tuner_callback,
507};
508
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300509static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
510{
511 struct dvb_frontend *fe;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300512 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300513 struct xc2028_config cfg = {
514 .i2c_adap = &dev->core->i2c_adap,
515 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300516 .ctrl = &ctl,
517 .callback = cx88_tuner_callback,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300518 };
519
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300520 if (!dev->dvb.frontend) {
521 printk(KERN_ERR "%s/2: dvb frontend not attached. "
522 "Can't attach xc3028\n",
523 dev->core->name);
524 return -EINVAL;
525 }
526
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300527 /*
528 * Some xc3028 devices may be hidden by an I2C gate. This is known
529 * to happen with some s5h1409-based devices.
530 * Now that I2C gate is open, sets up xc3028 configuration
531 */
532 cx88_setup_xc3028(dev->core, &ctl);
533
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300534 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
535 if (!fe) {
536 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
537 dev->core->name);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300538 return -EINVAL;
539 }
540
541 printk(KERN_INFO "%s/2: xc3028 attached\n",
542 dev->core->name);
543
544 return 0;
545}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300546
Steven Toth5bd1b662008-09-04 01:17:33 -0300547static int cx24116_set_ts_param(struct dvb_frontend *fe,
548 int is_punctured)
549{
550 struct cx8802_dev *dev = fe->dvb->priv;
551 dev->ts_gen_cntrl = 0x2;
552
553 return 0;
554}
555
556static int cx24116_reset_device(struct dvb_frontend *fe)
557{
558 struct cx8802_dev *dev = fe->dvb->priv;
559 struct cx88_core *core = dev->core;
560
561 /* Reset the part */
562 cx_write(MO_SRST_IO, 0);
563 msleep(10);
564 cx_write(MO_SRST_IO, 1);
565 msleep(10);
566
567 return 0;
568}
569
570static struct cx24116_config hauppauge_hvr4000_config = {
571 .demod_address = 0x05,
572 .set_ts_params = cx24116_set_ts_param,
573 .reset_device = cx24116_reset_device,
574};
575
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300576static struct cx24116_config tevii_s460_config = {
577 .demod_address = 0x55,
578 .set_ts_params = cx24116_set_ts_param,
579 .reset_device = cx24116_reset_device,
580};
581
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582static int dvb_register(struct cx8802_dev *dev)
583{
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300584 struct cx88_core *core = dev->core;
585
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 /* init struct videobuf_dvb */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300587 dev->dvb.name = core->name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 dev->ts_gen_cntrl = 0x0c;
589
590 /* init frontend */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300591 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300593 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300594 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300595 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300596 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300597 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
598 0x61, &core->i2c_adap,
599 DVB_PLL_THOMSON_DTT759X))
600 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300601 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700603 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200605 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800606 case CX88_BOARD_WINFAST_DTV1000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300607 dev->dvb.frontend = dvb_attach(cx22702_attach,
608 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300609 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300610 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300611 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
612 0x60, &core->i2c_adap,
613 DVB_PLL_THOMSON_DTT7579))
614 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300615 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300617 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -0200618 case CX88_BOARD_HAUPPAUGE_HVR1100:
619 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300620 case CX88_BOARD_HAUPPAUGE_HVR1300:
621 case CX88_BOARD_HAUPPAUGE_HVR3000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300622 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300623 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300624 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300625 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300626 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
627 &core->i2c_adap, 0x61,
628 TUNER_PHILIPS_FMD1216ME_MK3))
629 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300630 }
Steven Toth611900c2006-01-09 15:25:12 -0200631 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300632 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300633 dev->dvb.frontend = dvb_attach(mt352_attach,
634 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300635 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300636 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300637 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
638 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
639 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300640 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300641 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300642 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300643 dev->dvb.frontend = dvb_attach(zl10353_attach,
644 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300645 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300646 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300647 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
648 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
649 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300650 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300651 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300652 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300653 /* The tin box says DEE1601, but it seems to be DTT7579
654 * compatible, with a slightly different MT352 AGC gain. */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300655 dev->dvb.frontend = dvb_attach(mt352_attach,
656 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300657 &core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300658 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300659 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
660 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
661 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300662 break;
663 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300664 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300665 dev->dvb.frontend = dvb_attach(zl10353_attach,
666 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300667 &core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300668 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300669 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
670 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
671 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300672 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300673 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300675 dev->dvb.frontend = dvb_attach(mt352_attach,
676 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300677 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300678 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300679 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
680 0x61, NULL, DVB_PLL_LG_Z201))
681 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300682 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 case CX88_BOARD_KWORLD_DVB_T:
685 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700686 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300687 dev->dvb.frontend = dvb_attach(mt352_attach,
688 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300689 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300690 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300691 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
692 0x61, NULL, DVB_PLL_UNKNOWN_1))
693 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300694 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200696 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -0300697#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -0300698 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300699 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -0300700 &dev->vp3054->adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300701 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300702 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
703 &core->i2c_adap, 0x61,
704 TUNER_PHILIPS_FMD1216ME_MK3))
705 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300706 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200707#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300708 printk(KERN_ERR "%s/2: built without vp3054 support\n",
709 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -0200710#endif
711 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300712 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300713 dev->dvb.frontend = dvb_attach(zl10353_attach,
714 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300715 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300716 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300717 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
718 &core->i2c_adap, 0x61,
719 TUNER_THOMSON_FE6600))
720 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300721 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300722 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300723 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
724 dev->dvb.frontend = dvb_attach(zl10353_attach,
725 &dvico_fusionhdtv_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300726 &core->i2c_adap);
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300727 if (dev->dvb.frontend == NULL)
728 dev->dvb.frontend = dvb_attach(mt352_attach,
729 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300730 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -0300731 /*
732 * On this board, the demod provides the I2C bus pullup.
733 * We must not permit gate_ctrl to be performed, or
734 * the xc3028 cannot communicate on the bus.
735 */
736 if (dev->dvb.frontend)
737 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300738 if (attach_xc3028(0x61, dev) < 0)
739 return -EINVAL;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300740 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 case CX88_BOARD_PCHDTV_HD3000:
Michael Krufky4a390552006-12-05 02:00:53 -0300742 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300743 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300744 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300745 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
746 &core->i2c_adap, 0x61,
747 TUNER_THOMSON_DTT761X))
748 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300749 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700751 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
752 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -0700753
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300754 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -0700755 cx_clear(MO_GP0_IO, 1);
756 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700757 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700758 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700759
760 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700761 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300762 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
763 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300764 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300765 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300766 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
767 &core->i2c_adap, 0x61,
768 TUNER_MICROTUNE_4042FI5))
769 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -0700770 }
771 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700772 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
773 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -0700774
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300775 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -0700776 cx_clear(MO_GP0_IO, 1);
777 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700778 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700779 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300780 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
781 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300782 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300783 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300784 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
785 &core->i2c_adap, 0x61,
786 TUNER_THOMSON_DTT761X))
787 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -0700788 }
789 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700790 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
791 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700792
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300793 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700794 cx_clear(MO_GP0_IO, 1);
795 mdelay(100);
796 cx_set(MO_GP0_IO, 1);
797 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300798 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
799 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300800 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300801 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300802 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
803 &core->i2c_adap, 0x61,
804 TUNER_LG_TDVS_H06XF))
805 goto frontend_detach;
806 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
807 &core->i2c_adap, 0x43))
808 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700809 }
810 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300811 case CX88_BOARD_PCHDTV_HD5500:
812 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -0300813
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300814 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -0300815 cx_clear(MO_GP0_IO, 1);
816 mdelay(100);
817 cx_set(MO_GP0_IO, 1);
818 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300819 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
820 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300821 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300822 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300823 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
824 &core->i2c_adap, 0x61,
825 TUNER_LG_TDVS_H06XF))
826 goto frontend_detach;
827 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
828 &core->i2c_adap, 0x43))
829 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -0300830 }
831 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -0800832 case CX88_BOARD_ATI_HDTVWONDER:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300833 dev->dvb.frontend = dvb_attach(nxt200x_attach,
834 &ati_hdtvwonder,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300835 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300836 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300837 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
838 &core->i2c_adap, 0x61,
839 TUNER_PHILIPS_TUV1236D))
840 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300841 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800842 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200843 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
844 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300845 dev->dvb.frontend = dvb_attach(cx24123_attach,
846 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300847 &core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300848 if (dev->dvb.frontend) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300849 if (!dvb_attach(isl6421_attach, dev->dvb.frontend,
Steven Toth83fe92e2008-09-13 19:22:15 -0300850 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300851 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300852 }
Steven Toth0fa14aa2006-01-09 15:25:02 -0200853 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200854 case CX88_BOARD_KWORLD_DVBS_100:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300855 dev->dvb.frontend = dvb_attach(cx24123_attach,
856 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300857 &core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300858 if (dev->dvb.frontend) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300859 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300860 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300861 }
Vadim Catana0e0351e2006-01-09 15:25:02 -0200862 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300863 case CX88_BOARD_GENIATECH_DVBS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300864 dev->dvb.frontend = dvb_attach(cx24123_attach,
865 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300866 &core->i2c_adap);
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300867 if (dev->dvb.frontend) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300868 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300869 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
870 }
871 break;
Steven Toth60464da2008-01-05 16:53:01 -0300872 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth60464da2008-01-05 16:53:01 -0300873 dev->dvb.frontend = dvb_attach(s5h1409_attach,
874 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300875 &core->i2c_adap);
Steven Toth60464da2008-01-05 16:53:01 -0300876 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300877 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
878 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -0300879 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300880 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -0300881 }
882 break;
Steven Toth5c00fac2008-04-22 14:45:14 -0300883 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
884 dev->dvb.frontend = dvb_attach(s5h1409_attach,
885 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300886 &core->i2c_adap);
Steven Toth5c00fac2008-04-22 14:45:14 -0300887 if (dev->dvb.frontend != NULL) {
888 struct dvb_frontend *fe;
889 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300890 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -0300891 .i2c_addr = 0x61,
Mauro Carvalho Chehabc4a3ce12008-04-22 14:45:31 -0300892 .callback = cx88_pci_nano_callback,
Steven Toth5c00fac2008-04-22 14:45:14 -0300893 };
894 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300895 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -0300896 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -0300897 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -0300898 };
899
900 fe = dvb_attach(xc2028_attach,
901 dev->dvb.frontend, &cfg);
902 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
903 fe->ops.tuner_ops.set_config(fe, &ctl);
904 }
905 break;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300906 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
907 dev->dvb.frontend = dvb_attach(zl10353_attach,
908 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300909 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300910 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300911 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300912 break;
913 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300914 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300915
916 dev->dvb.frontend = dvb_attach(zl10353_attach,
917 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300918 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300919 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300920 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300921 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300922 case CX88_BOARD_KWORLD_ATSC_120:
923 dev->dvb.frontend = dvb_attach(s5h1409_attach,
924 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300925 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300926 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300927 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300928 break;
Steven Tothd893d5d2008-04-25 03:46:43 -0300929 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
930 dev->dvb.frontend = dvb_attach(s5h1411_attach,
931 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300932 &core->i2c_adap);
Steven Tothd893d5d2008-04-25 03:46:43 -0300933 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300934 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
935 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -0300936 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300937 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -0300938 }
939 break;
Steven Toth5bd1b662008-09-04 01:17:33 -0300940 case CX88_BOARD_HAUPPAUGE_HVR4000:
941 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
942 /* Support for DVB-S only, not DVB-T support */
943 dev->dvb.frontend = dvb_attach(cx24116_attach,
944 &hauppauge_hvr4000_config,
945 &dev->core->i2c_adap);
946 if (dev->dvb.frontend) {
947 dvb_attach(isl6421_attach, dev->dvb.frontend,
948 &dev->core->i2c_adap,
Darron Broad7396d3e2008-09-14 10:45:58 -0300949 0x08, ISL6421_DCL, 0x00);
Steven Toth5bd1b662008-09-04 01:17:33 -0300950 }
951 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300952 case CX88_BOARD_TEVII_S460:
Steven Toth83fe92e2008-09-13 19:22:15 -0300953 dev->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300954 &tevii_s460_config,
955 &core->i2c_adap);
956 if (dev->dvb.frontend != NULL) {
957 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
958 dev->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
959 }
960 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 default:
Trent Piepho5772f812007-08-15 14:41:59 -0300962 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300963 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 break;
965 }
966 if (NULL == dev->dvb.frontend) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300967 printk(KERN_ERR
968 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300969 core->name);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300970 return -EINVAL;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300971 }
972
Steven Toth6c5be742006-12-02 21:15:51 -0200973 /* Ensure all frontends negotiate bus access */
974 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -0700976 /* Put the analog decoder in standby to keep it quiet */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300977 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -0700978
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 /* register everything */
Janne Grunau78e92002008-04-09 19:13:13 -0300980 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev,
981 &dev->pci->dev, adapter_nr);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300982
983frontend_detach:
984 if (dev->dvb.frontend) {
985 dvb_frontend_detach(dev->dvb.frontend);
986 dev->dvb.frontend = NULL;
987 }
988 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989}
990
991/* ----------------------------------------------------------- */
992
Steven Toth6c5be742006-12-02 21:15:51 -0200993/* CX8802 MPEG -> mini driver - We have been given the hardware */
994static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995{
Steven Toth6c5be742006-12-02 21:15:51 -0200996 struct cx88_core *core = drv->core;
997 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300998 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -0200999
Trent Piepho6a59d642007-08-15 14:41:57 -03001000 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001001 case CX88_BOARD_HAUPPAUGE_HVR1300:
1002 /* We arrive here with either the cx23416 or the cx22702
1003 * on the bus. Take the bus from the cx23416 and enable the
1004 * cx22702 demod
1005 */
1006 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
1007 cx_clear(MO_GP0_IO, 0x00000004);
1008 udelay(1000);
1009 break;
1010 default:
1011 err = -ENODEV;
1012 }
1013 return err;
1014}
1015
1016/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1017static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1018{
1019 struct cx88_core *core = drv->core;
1020 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001021 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001022
Trent Piepho6a59d642007-08-15 14:41:57 -03001023 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001024 case CX88_BOARD_HAUPPAUGE_HVR1300:
1025 /* Do Nothing, leave the cx22702 on the bus. */
1026 break;
1027 default:
1028 err = -ENODEV;
1029 }
1030 return err;
1031}
1032
1033static int cx8802_dvb_probe(struct cx8802_driver *drv)
1034{
1035 struct cx88_core *core = drv->core;
1036 struct cx8802_dev *dev = drv->core->dvbdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037 int err;
1038
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001039 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001040 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001041 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001042 core->name,
1043 core->pci_bus,
1044 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045
1046 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001047 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 goto fail_core;
1049
Trent Piephoecf854d2007-05-05 20:11:32 -03001050 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001051 err = vp3054_i2c_probe(dev);
1052 if (0 != err)
Steven Toth6c5be742006-12-02 21:15:51 -02001053 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001054
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001056 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Guennadi Liakhovetski07051352008-04-22 14:42:13 -03001057 videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops,
1058 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1060 V4L2_FIELD_TOP,
1061 sizeof(struct cx88_buffer),
1062 dev);
1063 err = dvb_register(dev);
Steven Toth6c5be742006-12-02 21:15:51 -02001064 if (err != 0)
Trent Piepho5772f812007-08-15 14:41:59 -03001065 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1066 core->name, err);
Steven Toth611900c2006-01-09 15:25:12 -02001067
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069 return err;
1070}
1071
Steven Toth6c5be742006-12-02 21:15:51 -02001072static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073{
Steven Toth6c5be742006-12-02 21:15:51 -02001074 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001075
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076 /* dvb */
Mauro Carvalho Chehab9950c1b2008-04-11 11:29:44 -03001077 if (dev->dvb.frontend)
1078 videobuf_dvb_unregister(&dev->dvb);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079
Chris Pascoefc40b262006-01-09 15:25:35 -02001080 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001081
Steven Toth6c5be742006-12-02 21:15:51 -02001082 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083}
1084
Steven Toth6c5be742006-12-02 21:15:51 -02001085static struct cx8802_driver cx8802_dvb_driver = {
1086 .type_id = CX88_MPEG_DVB,
1087 .hw_access = CX8802_DRVCTL_SHARED,
1088 .probe = cx8802_dvb_probe,
1089 .remove = cx8802_dvb_remove,
1090 .advise_acquire = cx8802_dvb_advise_acquire,
1091 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092};
1093
1094static int dvb_init(void)
1095{
Trent Piepho5772f812007-08-15 14:41:59 -03001096 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 (CX88_VERSION_CODE >> 16) & 0xff,
1098 (CX88_VERSION_CODE >> 8) & 0xff,
1099 CX88_VERSION_CODE & 0xff);
1100#ifdef SNAPSHOT
1101 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1102 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1103#endif
Steven Toth6c5be742006-12-02 21:15:51 -02001104 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105}
1106
1107static void dvb_fini(void)
1108{
Steven Toth6c5be742006-12-02 21:15:51 -02001109 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110}
1111
1112module_init(dvb_init);
1113module_exit(dvb_fini);
1114
1115/*
1116 * Local variables:
1117 * c-basic-offset: 8
1118 * compile-command: "make DVB=1"
1119 * End:
1120 */