blob: b14296923250871f8d8234cf5ec4e3c25242fab2 [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"
Igor M. Liplianine4aab642008-09-23 15:43:57 -030051#include "stv0299.h"
52#include "z0194a.h"
53#include "stv0288.h"
54#include "stb6000.h"
Steven Toth5bd1b662008-09-04 01:17:33 -030055#include "cx24116.h"
Igor M. Liplianinb699c272009-11-16 22:22:32 -030056#include "stv0900.h"
57#include "stb6100.h"
58#include "stb6100_proc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
61MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
62MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
63MODULE_LICENSE("GPL");
64
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030065static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066module_param(debug, int, 0644);
67MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
68
Janne Grunau78e92002008-04-09 19:13:13 -030069DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020072 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74/* ------------------------------------------------------------------ */
75
76static int dvb_buf_setup(struct videobuf_queue *q,
77 unsigned int *count, unsigned int *size)
78{
79 struct cx8802_dev *dev = q->priv_data;
80
81 dev->ts_packet_size = 188 * 4;
82 dev->ts_packet_count = 32;
83
84 *size = dev->ts_packet_size * dev->ts_packet_count;
85 *count = 32;
86 return 0;
87}
88
Michael Krufky4a390552006-12-05 02:00:53 -030089static int dvb_buf_prepare(struct videobuf_queue *q,
90 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070091{
92 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030093 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
95
96static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
97{
98 struct cx8802_dev *dev = q->priv_data;
99 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
100}
101
Michael Krufky4a390552006-12-05 02:00:53 -0300102static void dvb_buf_release(struct videobuf_queue *q,
103 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300105 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106}
107
Adrian Bunk408b6642005-05-01 08:59:29 -0700108static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 .buf_setup = dvb_buf_setup,
110 .buf_prepare = dvb_buf_prepare,
111 .buf_queue = dvb_buf_queue,
112 .buf_release = dvb_buf_release,
113};
114
115/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300116
117static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
118{
119 struct cx8802_dev *dev= fe->dvb->priv;
120 struct cx8802_driver *drv = NULL;
121 int ret = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300122 int fe_id;
123
124 fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
125 if (!fe_id) {
Steven Toth2af03ee2008-10-16 20:17:31 -0300126 printk(KERN_ERR "%s() No frontend found\n", __func__);
Steven Toth363c35f2008-10-11 11:05:50 -0300127 return -EINVAL;
128 }
129
Michael Krufky22f3f172006-12-05 01:38:58 -0300130 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
131 if (drv) {
Steven Toth363c35f2008-10-11 11:05:50 -0300132 if (acquire){
133 dev->frontends.active_fe_id = fe_id;
Michael Krufky22f3f172006-12-05 01:38:58 -0300134 ret = drv->request_acquire(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300135 } else {
Michael Krufky22f3f172006-12-05 01:38:58 -0300136 ret = drv->request_release(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300137 dev->frontends.active_fe_id = 0;
138 }
Michael Krufky22f3f172006-12-05 01:38:58 -0300139 }
140
141 return ret;
142}
143
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300144static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
145{
146 struct videobuf_dvb_frontends *f;
147 struct videobuf_dvb_frontend *fe;
148
149 if (!core->dvbdev)
150 return;
151
152 f = &core->dvbdev->frontends;
153
154 if (!f)
155 return;
156
157 if (f->gate <= 1) /* undefined or fe0 */
158 fe = videobuf_dvb_get_frontend(f, 1);
159 else
160 fe = videobuf_dvb_get_frontend(f, f->gate);
161
162 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
163 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
164}
165
Michael Krufky22f3f172006-12-05 01:38:58 -0300166/* ------------------------------------------------------------------ */
167
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200168static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169{
170 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
171 static u8 reset [] = { RESET, 0x80 };
172 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
173 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
174 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
175 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
176
177 mt352_write(fe, clock_config, sizeof(clock_config));
178 udelay(200);
179 mt352_write(fe, reset, sizeof(reset));
180 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
181
182 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
183 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
184 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
185 return 0;
186}
187
Chris Pascoe43eabb42006-01-09 18:21:28 -0200188static int dvico_dual_demod_init(struct dvb_frontend *fe)
189{
190 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
191 static u8 reset [] = { RESET, 0x80 };
192 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
193 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
194 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
195 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
196
197 mt352_write(fe, clock_config, sizeof(clock_config));
198 udelay(200);
199 mt352_write(fe, reset, sizeof(reset));
200 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
201
202 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
203 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
204 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
205
206 return 0;
207}
208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
210{
211 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
212 static u8 reset [] = { 0x50, 0x80 };
213 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
214 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800215 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232static struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300233 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200234 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235};
236
237static struct mt352_config dntv_live_dvbt_config = {
238 .demod_address = 0x0f,
239 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240};
Chris Pascoefc40b262006-01-09 15:25:35 -0200241
Chris Pascoe43eabb42006-01-09 18:21:28 -0200242static struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300243 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200244 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200245};
246
Stephan Wienczny70101a22009-03-10 19:08:06 -0300247static struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
248 .demod_address = (0x1e >> 1),
249 .no_tuner = 1,
250 .if2 = 45600,
251};
252
Trent Piephoecf854d2007-05-05 20:11:32 -0300253#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200254static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
255{
256 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
257 static u8 reset [] = { 0x50, 0x80 };
258 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
259 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
260 0x00, 0xFF, 0x00, 0x40, 0x40 };
261 static u8 dntv_extra[] = { 0xB5, 0x7A };
262 static u8 capt_range_cfg[] = { 0x75, 0x32 };
263
264 mt352_write(fe, clock_config, sizeof(clock_config));
265 udelay(2000);
266 mt352_write(fe, reset, sizeof(reset));
267 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
268
269 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
270 udelay(2000);
271 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
272 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
273
274 return 0;
275}
276
Chris Pascoefc40b262006-01-09 15:25:35 -0200277static struct mt352_config dntv_live_dvbt_pro_config = {
278 .demod_address = 0x0f,
279 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200280 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200281};
282#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
Chris Pascoe780dfef2006-02-28 08:34:59 -0300284static struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300285 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300286 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300287};
288
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300289static struct zl10353_config dvico_fusionhdtv_xc3028 = {
290 .demod_address = 0x0f,
291 .if2 = 45600,
292 .no_tuner = 1,
293};
294
295static struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
296 .demod_address = 0x0f,
297 .if2 = 4560,
298 .no_tuner = 1,
299 .demod_init = dvico_fusionhdtv_demod_init,
300};
301
Chris Pascoe780dfef2006-02-28 08:34:59 -0300302static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300303 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300304};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300305
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306static struct cx22702_config connexant_refboard_config = {
307 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700308 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309};
310
Michael Krufkyed355262006-12-05 01:34:56 -0300311static struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300312 .demod_address = 0x63,
313 .output_mode = CX22702_SERIAL_OUTPUT,
314};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
Michael Krufky4a390552006-12-05 02:00:53 -0300316static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317{
318 struct cx8802_dev *dev= fe->dvb->priv;
319 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
320 return 0;
321}
322
Adrian Bunk408b6642005-05-01 08:59:29 -0700323static struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300324 .demod_address = 0x15,
325 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
Michael Krufky6ddcc912005-07-27 11:46:00 -0700328static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700329{
330 struct cx8802_dev *dev= fe->dvb->priv;
331 struct cx88_core *core = dev->core;
332
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300333 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700334 if (index == 0)
335 cx_clear(MO_GP0_IO, 8);
336 else
337 cx_set(MO_GP0_IO, 8);
338 return 0;
339}
340
Michael Krufky6ddcc912005-07-27 11:46:00 -0700341static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700342{
343 struct cx8802_dev *dev= fe->dvb->priv;
344 if (is_punctured)
345 dev->ts_gen_cntrl |= 0x04;
346 else
347 dev->ts_gen_cntrl &= ~0x04;
348 return 0;
349}
350
Michael Krufky6ddcc912005-07-27 11:46:00 -0700351static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300352 .demod_address = 0x0e,
353 .demod_chip = LGDT3302,
354 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
355 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700356};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700357
358static struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300359 .demod_address = 0x0e,
360 .demod_chip = LGDT3303,
361 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
362 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700363};
Rusty Scottda215d22006-04-07 02:21:31 -0300364
365static struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300366 .demod_address = 0x59,
367 .demod_chip = LGDT3303,
368 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
369 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300370};
Michael Krufkyf1798492005-07-07 17:58:39 -0700371
Michael Krufky4a390552006-12-05 02:00:53 -0300372static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800373{
374 struct cx8802_dev *dev= fe->dvb->priv;
375 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
376 return 0;
377}
378
379static struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300380 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300381 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800382};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800383
Steven Toth0fa14aa2006-01-09 15:25:02 -0200384static int cx24123_set_ts_param(struct dvb_frontend* fe,
385 int is_punctured)
386{
387 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300388 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200389 return 0;
390}
391
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300392static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
393 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200394{
395 struct cx8802_dev *dev= fe->dvb->priv;
396 struct cx88_core *core = dev->core;
397
Michael Krufky4a390552006-12-05 02:00:53 -0300398 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300399 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300400 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300401 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300402
403 if (core->prev_set_voltage)
404 return core->prev_set_voltage(fe, voltage);
405 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200406}
407
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300408static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
409 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300410{
411 struct cx8802_dev *dev= fe->dvb->priv;
412 struct cx88_core *core = dev->core;
413
414 if (voltage == SEC_VOLTAGE_OFF) {
415 dprintk(1,"LNB Voltage OFF\n");
416 cx_write(MO_GP0_IO, 0x0000efff);
417 }
418
419 if (core->prev_set_voltage)
420 return core->prev_set_voltage(fe, voltage);
421 return 0;
422}
423
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300424static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
425 fe_sec_voltage_t voltage)
426{
427 struct cx8802_dev *dev= fe->dvb->priv;
428 struct cx88_core *core = dev->core;
429
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300430 cx_set(MO_GP0_IO, 0x6040);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300431 switch (voltage) {
432 case SEC_VOLTAGE_13:
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300433 cx_clear(MO_GP0_IO, 0x20);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300434 break;
435 case SEC_VOLTAGE_18:
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300436 cx_set(MO_GP0_IO, 0x20);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300437 break;
438 case SEC_VOLTAGE_OFF:
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300439 cx_clear(MO_GP0_IO, 0x20);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300440 break;
441 }
442
443 if (core->prev_set_voltage)
444 return core->prev_set_voltage(fe, voltage);
445 return 0;
446}
447
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300448static struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300449 .demod_address = 0x55,
450 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300451};
452
Steven Toth0fa14aa2006-01-09 15:25:02 -0200453static struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300454 .demod_address = 0x55,
455 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200456};
457
458static struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300459 .demod_address = 0x15,
460 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300461 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200462};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200463
Steven Toth60464da2008-01-05 16:53:01 -0300464static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
465 .demod_address = 0x32 >> 1,
466 .output_mode = S5H1409_PARALLEL_OUTPUT,
467 .gpio = S5H1409_GPIO_ON,
468 .qam_if = 44000,
469 .inversion = S5H1409_INVERSION_OFF,
470 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300471 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300472};
473
Steven Toth5c00fac2008-04-22 14:45:14 -0300474static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
475 .demod_address = 0x32 >> 1,
476 .output_mode = S5H1409_SERIAL_OUTPUT,
477 .gpio = S5H1409_GPIO_OFF,
478 .inversion = S5H1409_INVERSION_OFF,
479 .status_mode = S5H1409_DEMODLOCKING,
480 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
481};
482
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300483static struct s5h1409_config kworld_atsc_120_config = {
484 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300485 .output_mode = S5H1409_SERIAL_OUTPUT,
486 .gpio = S5H1409_GPIO_OFF,
487 .inversion = S5H1409_INVERSION_OFF,
488 .status_mode = S5H1409_DEMODLOCKING,
489 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
490};
491
Steven Toth60464da2008-01-05 16:53:01 -0300492static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
493 .i2c_address = 0x64,
494 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300495};
496
Stéphane Voltz3f6014f2008-09-05 14:33:54 -0300497static struct zl10353_config cx88_pinnacle_hybrid_pctv = {
498 .demod_address = (0x1e >> 1),
499 .no_tuner = 1,
500 .if2 = 45600,
501};
502
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300503static struct zl10353_config cx88_geniatech_x8000_mt = {
Mauro Carvalho Chehab57069342009-08-20 10:14:45 -0300504 .demod_address = (0x1e >> 1),
505 .no_tuner = 1,
506 .disable_i2c_gate_ctrl = 1,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300507};
508
Steven Tothd893d5d2008-04-25 03:46:43 -0300509static struct s5h1411_config dvico_fusionhdtv7_config = {
510 .output_mode = S5H1411_SERIAL_OUTPUT,
511 .gpio = S5H1411_GPIO_ON,
512 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
513 .qam_if = S5H1411_IF_44000,
514 .vsb_if = S5H1411_IF_44000,
515 .inversion = S5H1411_INVERSION_OFF,
516 .status_mode = S5H1411_DEMODLOCKING
517};
518
519static struct xc5000_config dvico_fusionhdtv7_tuner_config = {
520 .i2c_address = 0xc2 >> 1,
521 .if_khz = 5380,
Steven Tothd893d5d2008-04-25 03:46:43 -0300522};
523
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300524static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
525{
526 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -0300527 struct videobuf_dvb_frontend *fe0 = NULL;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300528 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300529 struct xc2028_config cfg = {
530 .i2c_adap = &dev->core->i2c_adap,
531 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300532 .ctrl = &ctl,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300533 };
534
Darron Broad92abe9e2008-10-11 11:18:53 -0300535 /* Get the first frontend */
Steven Toth363c35f2008-10-11 11:05:50 -0300536 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
537 if (!fe0)
538 return -EINVAL;
539
540 if (!fe0->dvb.frontend) {
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300541 printk(KERN_ERR "%s/2: dvb frontend not attached. "
542 "Can't attach xc3028\n",
543 dev->core->name);
544 return -EINVAL;
545 }
546
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300547 /*
548 * Some xc3028 devices may be hidden by an I2C gate. This is known
549 * to happen with some s5h1409-based devices.
550 * Now that I2C gate is open, sets up xc3028 configuration
551 */
552 cx88_setup_xc3028(dev->core, &ctl);
553
Steven Toth363c35f2008-10-11 11:05:50 -0300554 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300555 if (!fe) {
556 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
557 dev->core->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300558 dvb_frontend_detach(fe0->dvb.frontend);
559 dvb_unregister_frontend(fe0->dvb.frontend);
560 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300561 return -EINVAL;
562 }
563
564 printk(KERN_INFO "%s/2: xc3028 attached\n",
565 dev->core->name);
566
567 return 0;
568}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300569
Steven Toth5bd1b662008-09-04 01:17:33 -0300570static int cx24116_set_ts_param(struct dvb_frontend *fe,
571 int is_punctured)
572{
573 struct cx8802_dev *dev = fe->dvb->priv;
574 dev->ts_gen_cntrl = 0x2;
575
576 return 0;
577}
578
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300579static int stv0900_set_ts_param(struct dvb_frontend *fe,
580 int is_punctured)
581{
582 struct cx8802_dev *dev = fe->dvb->priv;
583 dev->ts_gen_cntrl = 0;
584
585 return 0;
586}
587
Steven Toth5bd1b662008-09-04 01:17:33 -0300588static int cx24116_reset_device(struct dvb_frontend *fe)
589{
590 struct cx8802_dev *dev = fe->dvb->priv;
591 struct cx88_core *core = dev->core;
592
593 /* Reset the part */
Steven Toth363c35f2008-10-11 11:05:50 -0300594 /* Put the cx24116 into reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300595 cx_write(MO_SRST_IO, 0);
596 msleep(10);
Steven Toth363c35f2008-10-11 11:05:50 -0300597 /* Take the cx24116 out of reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300598 cx_write(MO_SRST_IO, 1);
599 msleep(10);
600
601 return 0;
602}
603
604static struct cx24116_config hauppauge_hvr4000_config = {
605 .demod_address = 0x05,
606 .set_ts_params = cx24116_set_ts_param,
607 .reset_device = cx24116_reset_device,
608};
609
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300610static struct cx24116_config tevii_s460_config = {
611 .demod_address = 0x55,
612 .set_ts_params = cx24116_set_ts_param,
613 .reset_device = cx24116_reset_device,
614};
615
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300616static struct stv0900_config prof_7301_stv0900_config = {
617 .demod_address = 0x6a,
618/* demod_mode = 0,*/
619 .xtal = 27000000,
620 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
621 .diseqc_mode = 2,/* 2/3 PWM */
622 .tun1_maddress = 0,/* 0x60 */
623 .tun1_adc = 0,/* 2 Vpp */
624 .path1_mode = 3,
625 .set_ts_params = stv0900_set_ts_param,
626};
627
628static struct stb6100_config prof_7301_stb6100_config = {
629 .tuner_address = 0x60,
630 .refclock = 27000000,
631};
632
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300633static struct stv0299_config tevii_tuner_sharp_config = {
634 .demod_address = 0x68,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300635 .inittab = sharp_z0194a_inittab,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300636 .mclk = 88000000UL,
637 .invert = 1,
638 .skip_reinit = 0,
639 .lock_output = 1,
640 .volt13_op0_op1 = STV0299_VOLT13_OP1,
641 .min_delay_ms = 100,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300642 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300643 .set_ts_params = cx24116_set_ts_param,
644};
645
646static struct stv0288_config tevii_tuner_earda_config = {
647 .demod_address = 0x68,
648 .min_delay_ms = 100,
649 .set_ts_params = cx24116_set_ts_param,
650};
651
Andy Walls6e0e12f2009-01-11 21:18:04 -0300652static int cx8802_alloc_frontends(struct cx8802_dev *dev)
653{
654 struct cx88_core *core = dev->core;
655 struct videobuf_dvb_frontend *fe = NULL;
656 int i;
657
658 mutex_init(&dev->frontends.lock);
659 INIT_LIST_HEAD(&dev->frontends.felist);
660
661 if (!core->board.num_frontends)
662 return -ENODEV;
663
664 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
665 core->board.num_frontends);
666 for (i = 1; i <= core->board.num_frontends; i++) {
667 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
668 if (!fe) {
669 printk(KERN_ERR "%s() failed to alloc\n", __func__);
670 videobuf_dvb_dealloc_frontends(&dev->frontends);
671 return -ENOMEM;
672 }
673 }
674 return 0;
675}
676
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677static int dvb_register(struct cx8802_dev *dev)
678{
Steven Toth363c35f2008-10-11 11:05:50 -0300679 struct cx88_core *core = dev->core;
680 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
Darron Broad59b18422008-10-11 11:44:05 -0300681 int mfe_shared = 0; /* bus not shared by default */
Steven Toth363c35f2008-10-11 11:05:50 -0300682
Matthias Schwarzott0e8bac92008-10-24 10:47:07 -0300683 if (0 != core->i2c_rc) {
684 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
685 goto frontend_detach;
686 }
687
Steven Toth363c35f2008-10-11 11:05:50 -0300688 /* Get the first frontend */
689 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
690 if (!fe0)
Darron Broad60a5a922008-11-11 08:48:27 -0300691 goto frontend_detach;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692
Darron Broad8e739092008-10-11 11:31:41 -0300693 /* multi-frontend gate control is undefined or defaults to fe0 */
694 dev->frontends.gate = 0;
695
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300696 /* Sets the gate control callback to be used by i2c command calls */
697 core->gate_ctrl = cx88_dvb_gate_ctrl;
698
Darron Broad8e739092008-10-11 11:31:41 -0300699 /* init frontend(s) */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300700 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -0300702 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300703 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300704 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300705 if (fe0->dvb.frontend != NULL) {
706 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300707 0x61, &core->i2c_adap,
708 DVB_PLL_THOMSON_DTT759X))
709 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300710 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700712 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200714 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800715 case CX88_BOARD_WINFAST_DTV1000:
Steven Toth363c35f2008-10-11 11:05:50 -0300716 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300717 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300718 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300719 if (fe0->dvb.frontend != NULL) {
720 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300721 0x60, &core->i2c_adap,
722 DVB_PLL_THOMSON_DTT7579))
723 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300724 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300726 case CX88_BOARD_WINFAST_DTV2000H:
Vlastimil Labsky4d14c832009-08-10 22:15:54 -0300727 case CX88_BOARD_WINFAST_DTV2000H_J:
Steven Toth611900c2006-01-09 15:25:12 -0200728 case CX88_BOARD_HAUPPAUGE_HVR1100:
729 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300730 case CX88_BOARD_HAUPPAUGE_HVR1300:
Steven Toth363c35f2008-10-11 11:05:50 -0300731 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300732 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300733 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300734 if (fe0->dvb.frontend != NULL) {
735 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300736 &core->i2c_adap, 0x61,
737 TUNER_PHILIPS_FMD1216ME_MK3))
738 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300739 }
Steven Toth611900c2006-01-09 15:25:12 -0200740 break;
Steven Toth363c35f2008-10-11 11:05:50 -0300741 case CX88_BOARD_HAUPPAUGE_HVR3000:
Darron Broad60a5a922008-11-11 08:48:27 -0300742 /* MFE frontend 1 */
743 mfe_shared = 1;
744 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -0300745 /* DVB-S init */
746 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Darron Broad60a5a922008-11-11 08:48:27 -0300747 &hauppauge_novas_config,
748 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300749 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -0300750 if (!dvb_attach(isl6421_attach,
751 fe0->dvb.frontend,
752 &dev->core->i2c_adap,
753 0x08, ISL6421_DCL, 0x00))
754 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300755 }
Darron Broad60a5a922008-11-11 08:48:27 -0300756 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -0300757 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -0300758 if (!fe1)
759 goto frontend_detach;
760 /* DVB-T init */
761 fe1->dvb.frontend = dvb_attach(cx22702_attach,
762 &hauppauge_hvr_config,
763 &dev->core->i2c_adap);
764 if (fe1->dvb.frontend) {
765 fe1->dvb.frontend->id = 1;
766 if (!dvb_attach(simple_tuner_attach,
767 fe1->dvb.frontend,
768 &dev->core->i2c_adap,
769 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
770 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300771 }
772 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300773 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Steven Toth363c35f2008-10-11 11:05:50 -0300774 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300775 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300776 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300777 if (fe0->dvb.frontend != NULL) {
778 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300779 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
780 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300781 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300782 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300783 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -0300784 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300785 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300786 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300787 if (fe0->dvb.frontend != NULL) {
788 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300789 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
790 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300791 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300792 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300793 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300794 /* The tin box says DEE1601, but it seems to be DTT7579
795 * compatible, with a slightly different MT352 AGC gain. */
Steven Toth363c35f2008-10-11 11:05:50 -0300796 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300797 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300798 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300799 if (fe0->dvb.frontend != NULL) {
800 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300801 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
802 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300803 break;
804 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300805 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -0300806 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300807 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300808 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300809 if (fe0->dvb.frontend != NULL) {
810 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300811 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
812 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300813 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300814 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -0300816 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300817 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300818 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300819 if (fe0->dvb.frontend != NULL) {
820 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300821 0x61, NULL, DVB_PLL_LG_Z201))
822 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300823 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 case CX88_BOARD_KWORLD_DVB_T:
826 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700827 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Steven Toth363c35f2008-10-11 11:05:50 -0300828 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300829 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300830 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300831 if (fe0->dvb.frontend != NULL) {
832 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300833 0x61, NULL, DVB_PLL_UNKNOWN_1))
834 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300835 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200837 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -0300838#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -0300839 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Steven Toth363c35f2008-10-11 11:05:50 -0300840 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -0300841 &dev->vp3054->adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300842 if (fe0->dvb.frontend != NULL) {
843 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300844 &core->i2c_adap, 0x61,
845 TUNER_PHILIPS_FMD1216ME_MK3))
846 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300847 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200848#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300849 printk(KERN_ERR "%s/2: built without vp3054 support\n",
850 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -0200851#endif
852 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300853 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -0300854 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300855 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300856 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300857 if (fe0->dvb.frontend != NULL) {
858 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300859 &core->i2c_adap, 0x61,
860 TUNER_THOMSON_FE6600))
861 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300862 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300863 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300864 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
Steven Toth363c35f2008-10-11 11:05:50 -0300865 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300866 &dvico_fusionhdtv_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300867 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300868 if (fe0->dvb.frontend == NULL)
869 fe0->dvb.frontend = dvb_attach(mt352_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300870 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300871 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -0300872 /*
873 * On this board, the demod provides the I2C bus pullup.
874 * We must not permit gate_ctrl to be performed, or
875 * the xc3028 cannot communicate on the bus.
876 */
Steven Toth363c35f2008-10-11 11:05:50 -0300877 if (fe0->dvb.frontend)
878 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300879 if (attach_xc3028(0x61, dev) < 0)
Darron Broadbecd4302008-10-21 11:47:50 -0300880 goto frontend_detach;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300881 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 case CX88_BOARD_PCHDTV_HD3000:
Steven Toth363c35f2008-10-11 11:05:50 -0300883 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300884 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300885 if (fe0->dvb.frontend != NULL) {
886 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300887 &core->i2c_adap, 0x61,
888 TUNER_THOMSON_DTT761X))
889 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300890 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700892 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
893 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -0700894
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300895 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -0700896 cx_clear(MO_GP0_IO, 1);
897 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700898 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700899 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700900
901 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700902 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Steven Toth363c35f2008-10-11 11:05:50 -0300903 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300904 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300905 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300906 if (fe0->dvb.frontend != NULL) {
907 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300908 &core->i2c_adap, 0x61,
909 TUNER_MICROTUNE_4042FI5))
910 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -0700911 }
912 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700913 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
914 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -0700915
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300916 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -0700917 cx_clear(MO_GP0_IO, 1);
918 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700919 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700920 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -0300921 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300922 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300923 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300924 if (fe0->dvb.frontend != NULL) {
925 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300926 &core->i2c_adap, 0x61,
927 TUNER_THOMSON_DTT761X))
928 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -0700929 }
930 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700931 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
932 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700933
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300934 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700935 cx_clear(MO_GP0_IO, 1);
936 mdelay(100);
937 cx_set(MO_GP0_IO, 1);
938 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -0300939 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300940 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300941 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300942 if (fe0->dvb.frontend != NULL) {
943 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300944 &core->i2c_adap, 0x61,
945 TUNER_LG_TDVS_H06XF))
946 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300947 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300948 &core->i2c_adap, 0x43))
949 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700950 }
951 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300952 case CX88_BOARD_PCHDTV_HD5500:
953 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -0300954
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300955 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -0300956 cx_clear(MO_GP0_IO, 1);
957 mdelay(100);
958 cx_set(MO_GP0_IO, 1);
959 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -0300960 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300961 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300962 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300963 if (fe0->dvb.frontend != NULL) {
964 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300965 &core->i2c_adap, 0x61,
966 TUNER_LG_TDVS_H06XF))
967 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300968 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300969 &core->i2c_adap, 0x43))
970 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -0300971 }
972 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -0800973 case CX88_BOARD_ATI_HDTVWONDER:
Steven Toth363c35f2008-10-11 11:05:50 -0300974 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300975 &ati_hdtvwonder,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300976 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300977 if (fe0->dvb.frontend != NULL) {
978 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300979 &core->i2c_adap, 0x61,
980 TUNER_PHILIPS_TUV1236D))
981 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300982 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800983 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200984 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
985 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Steven Toth363c35f2008-10-11 11:05:50 -0300986 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300987 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300988 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300989 if (fe0->dvb.frontend) {
990 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
Steven Toth83fe92e2008-09-13 19:22:15 -0300991 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300992 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300993 }
Steven Toth0fa14aa2006-01-09 15:25:02 -0200994 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200995 case CX88_BOARD_KWORLD_DVBS_100:
Steven Toth363c35f2008-10-11 11:05:50 -0300996 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300997 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300998 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300999 if (fe0->dvb.frontend) {
1000 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1001 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001002 }
Vadim Catana0e0351e2006-01-09 15:25:02 -02001003 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001004 case CX88_BOARD_GENIATECH_DVBS:
Steven Toth363c35f2008-10-11 11:05:50 -03001005 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001006 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001007 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001008 if (fe0->dvb.frontend) {
1009 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1010 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001011 }
1012 break;
Steven Toth60464da2008-01-05 16:53:01 -03001013 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth363c35f2008-10-11 11:05:50 -03001014 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth60464da2008-01-05 16:53:01 -03001015 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001016 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001017 if (fe0->dvb.frontend != NULL) {
1018 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001019 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001020 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001021 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -03001022 }
1023 break;
Steven Toth5c00fac2008-04-22 14:45:14 -03001024 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
Steven Toth363c35f2008-10-11 11:05:50 -03001025 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth5c00fac2008-04-22 14:45:14 -03001026 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001027 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001028 if (fe0->dvb.frontend != NULL) {
Steven Toth5c00fac2008-04-22 14:45:14 -03001029 struct dvb_frontend *fe;
1030 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001031 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -03001032 .i2c_addr = 0x61,
Steven Toth5c00fac2008-04-22 14:45:14 -03001033 };
1034 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001035 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -03001036 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -03001037 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -03001038 };
1039
1040 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001041 fe0->dvb.frontend, &cfg);
Steven Toth5c00fac2008-04-22 14:45:14 -03001042 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1043 fe->ops.tuner_ops.set_config(fe, &ctl);
1044 }
1045 break;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001046 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
Miroslav Sustek3047a172009-05-31 16:47:28 -03001047 case CX88_BOARD_WINFAST_DTV1800H:
Steven Toth363c35f2008-10-11 11:05:50 -03001048 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001049 &cx88_pinnacle_hybrid_pctv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001050 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001051 if (fe0->dvb.frontend) {
1052 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001053 if (attach_xc3028(0x61, dev) < 0)
1054 goto frontend_detach;
1055 }
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001056 break;
1057 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001058 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001059
Steven Toth363c35f2008-10-11 11:05:50 -03001060 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001061 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001062 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001063 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001064 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001065 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001066 case CX88_BOARD_KWORLD_ATSC_120:
Steven Toth363c35f2008-10-11 11:05:50 -03001067 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001068 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001069 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001070 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001071 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001072 break;
Steven Tothd893d5d2008-04-25 03:46:43 -03001073 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
Steven Toth363c35f2008-10-11 11:05:50 -03001074 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Steven Tothd893d5d2008-04-25 03:46:43 -03001075 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001076 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001077 if (fe0->dvb.frontend != NULL) {
1078 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001079 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001080 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001081 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -03001082 }
1083 break;
Steven Toth5bd1b662008-09-04 01:17:33 -03001084 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad60a5a922008-11-11 08:48:27 -03001085 /* MFE frontend 1 */
1086 mfe_shared = 1;
1087 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001088 /* DVB-S/S2 Init */
1089 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001090 &hauppauge_hvr4000_config,
1091 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001092 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001093 if (!dvb_attach(isl6421_attach,
1094 fe0->dvb.frontend,
1095 &dev->core->i2c_adap,
1096 0x08, ISL6421_DCL, 0x00))
1097 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001098 }
Darron Broad60a5a922008-11-11 08:48:27 -03001099 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001100 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001101 if (!fe1)
1102 goto frontend_detach;
1103 /* DVB-T Init */
1104 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1105 &hauppauge_hvr_config,
1106 &dev->core->i2c_adap);
1107 if (fe1->dvb.frontend) {
1108 fe1->dvb.frontend->id = 1;
1109 if (!dvb_attach(simple_tuner_attach,
1110 fe1->dvb.frontend,
1111 &dev->core->i2c_adap,
1112 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1113 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001114 }
1115 break;
1116 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1117 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001118 &hauppauge_hvr4000_config,
1119 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001120 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001121 if (!dvb_attach(isl6421_attach,
1122 fe0->dvb.frontend,
1123 &dev->core->i2c_adap,
1124 0x08, ISL6421_DCL, 0x00))
1125 goto frontend_detach;
Steven Toth5bd1b662008-09-04 01:17:33 -03001126 }
1127 break;
Igor M. Liplianincd3cde12008-11-09 15:26:25 -03001128 case CX88_BOARD_PROF_6200:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001129 case CX88_BOARD_TBS_8910:
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001130 case CX88_BOARD_TEVII_S420:
Steven Toth363c35f2008-10-11 11:05:50 -03001131 fe0->dvb.frontend = dvb_attach(stv0299_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001132 &tevii_tuner_sharp_config,
1133 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001134 if (fe0->dvb.frontend != NULL) {
1135 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001136 &core->i2c_adap, DVB_PLL_OPERA1))
1137 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001138 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1139 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001140
1141 } else {
Steven Toth363c35f2008-10-11 11:05:50 -03001142 fe0->dvb.frontend = dvb_attach(stv0288_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001143 &tevii_tuner_earda_config,
1144 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001145 if (fe0->dvb.frontend != NULL) {
1146 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001147 &core->i2c_adap))
1148 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001149 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1150 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001151 }
1152 }
1153 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001154 case CX88_BOARD_TEVII_S460:
Steven Toth363c35f2008-10-11 11:05:50 -03001155 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001156 &tevii_s460_config,
1157 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001158 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001159 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001160 break;
Oleg Roitburd4cd7fb82008-09-17 11:30:21 -03001161 case CX88_BOARD_OMICOM_SS4_PCI:
Oleg Roitburdee730422008-09-17 11:58:33 -03001162 case CX88_BOARD_TBS_8920:
Oleg Roitburd57f51db2008-10-08 06:48:08 -03001163 case CX88_BOARD_PROF_7300:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001164 case CX88_BOARD_SATTRADE_ST4200:
Steven Toth363c35f2008-10-11 11:05:50 -03001165 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Oleg Roitburdee730422008-09-17 11:58:33 -03001166 &hauppauge_hvr4000_config,
1167 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001168 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001169 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Oleg Roitburdee730422008-09-17 11:58:33 -03001170 break;
Stephan Wienczny70101a22009-03-10 19:08:06 -03001171 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
1172 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1173 &cx88_terratec_cinergy_ht_pci_mkii_config,
1174 &core->i2c_adap);
1175 if (fe0->dvb.frontend) {
1176 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1177 if (attach_xc3028(0x61, dev) < 0)
1178 goto frontend_detach;
1179 }
1180 break;
Igor M. Liplianinb699c272009-11-16 22:22:32 -03001181 case CX88_BOARD_PROF_7301:{
1182 struct dvb_tuner_ops *tuner_ops = NULL;
1183
1184 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1185 &prof_7301_stv0900_config,
1186 &core->i2c_adap, 0);
1187 if (fe0->dvb.frontend != NULL) {
1188 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1189 &prof_7301_stb6100_config,
1190 &core->i2c_adap))
1191 goto frontend_detach;
1192
1193 tuner_ops = &fe0->dvb.frontend->ops.tuner_ops;
1194 tuner_ops->set_frequency = stb6100_set_freq;
1195 tuner_ops->get_frequency = stb6100_get_freq;
1196 tuner_ops->set_bandwidth = stb6100_set_bandw;
1197 tuner_ops->get_bandwidth = stb6100_get_bandw;
1198
1199 core->prev_set_voltage =
1200 fe0->dvb.frontend->ops.set_voltage;
1201 fe0->dvb.frontend->ops.set_voltage =
1202 tevii_dvbs_set_voltage;
1203 }
1204 break;
1205 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 default:
Trent Piepho5772f812007-08-15 14:41:59 -03001207 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 -03001208 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209 break;
1210 }
Steven Toth363c35f2008-10-11 11:05:50 -03001211
Mauro Carvalho Chehab2c9bcea2008-11-10 23:35:00 -02001212 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001213 printk(KERN_ERR
1214 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001215 core->name);
Darron Broad60a5a922008-11-11 08:48:27 -03001216 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001217 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001218 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001219 fe0->dvb.frontend->callback = cx88_tuner_callback;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001220
Steven Toth6c5be742006-12-02 21:15:51 -02001221 /* Ensure all frontends negotiate bus access */
Steven Toth363c35f2008-10-11 11:05:50 -03001222 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1223 if (fe1)
1224 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001226 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001227 call_all(core, core, s_power, 0);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001228
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229 /* register everything */
Steven Toth363c35f2008-10-11 11:05:50 -03001230 return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001231 &dev->pci->dev, adapter_nr, mfe_shared, NULL);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001232
1233frontend_detach:
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001234 core->gate_ctrl = NULL;
Darron Broadbecd4302008-10-21 11:47:50 -03001235 videobuf_dvb_dealloc_frontends(&dev->frontends);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001236 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001237}
1238
1239/* ----------------------------------------------------------- */
1240
Steven Toth6c5be742006-12-02 21:15:51 -02001241/* CX8802 MPEG -> mini driver - We have been given the hardware */
1242static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243{
Steven Toth6c5be742006-12-02 21:15:51 -02001244 struct cx88_core *core = drv->core;
1245 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001246 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001247
Trent Piepho6a59d642007-08-15 14:41:57 -03001248 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001249 case CX88_BOARD_HAUPPAUGE_HVR1300:
1250 /* We arrive here with either the cx23416 or the cx22702
1251 * on the bus. Take the bus from the cx23416 and enable the
1252 * cx22702 demod
1253 */
Darron Broad79392732008-12-18 06:28:35 -03001254 /* Toggle reset on cx22702 leaving i2c active */
1255 cx_set(MO_GP0_IO, 0x00000080);
1256 udelay(1000);
1257 cx_clear(MO_GP0_IO, 0x00000080);
1258 udelay(50);
1259 cx_set(MO_GP0_IO, 0x00000080);
1260 udelay(1000);
1261 /* enable the cx22702 pins */
Steven Toth6c5be742006-12-02 21:15:51 -02001262 cx_clear(MO_GP0_IO, 0x00000004);
1263 udelay(1000);
1264 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001265
Darron Broad92abe9e2008-10-11 11:18:53 -03001266 case CX88_BOARD_HAUPPAUGE_HVR3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001267 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad79392732008-12-18 06:28:35 -03001268 /* Toggle reset on cx22702 leaving i2c active */
1269 cx_set(MO_GP0_IO, 0x00000080);
1270 udelay(1000);
1271 cx_clear(MO_GP0_IO, 0x00000080);
1272 udelay(50);
1273 cx_set(MO_GP0_IO, 0x00000080);
1274 udelay(1000);
1275 switch (core->dvbdev->frontends.active_fe_id) {
1276 case 1: /* DVB-S/S2 Enabled */
1277 /* tri-state the cx22702 pins */
1278 cx_set(MO_GP0_IO, 0x00000004);
1279 /* Take the cx24116/cx24123 out of reset */
1280 cx_write(MO_SRST_IO, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001281 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
Darron Broad79392732008-12-18 06:28:35 -03001282 break;
1283 case 2: /* DVB-T Enabled */
Steven Toth363c35f2008-10-11 11:05:50 -03001284 /* Put the cx24116/cx24123 into reset */
1285 cx_write(MO_SRST_IO, 0);
Darron Broad79392732008-12-18 06:28:35 -03001286 /* enable the cx22702 pins */
Steven Toth363c35f2008-10-11 11:05:50 -03001287 cx_clear(MO_GP0_IO, 0x00000004);
1288 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
Darron Broad79392732008-12-18 06:28:35 -03001289 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001290 }
Darron Broad79392732008-12-18 06:28:35 -03001291 udelay(1000);
Steven Toth363c35f2008-10-11 11:05:50 -03001292 break;
1293
Steven Toth6c5be742006-12-02 21:15:51 -02001294 default:
1295 err = -ENODEV;
1296 }
1297 return err;
1298}
1299
1300/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1301static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1302{
1303 struct cx88_core *core = drv->core;
1304 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001305 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001306
Trent Piepho6a59d642007-08-15 14:41:57 -03001307 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001308 case CX88_BOARD_HAUPPAUGE_HVR1300:
1309 /* Do Nothing, leave the cx22702 on the bus. */
1310 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001311 case CX88_BOARD_HAUPPAUGE_HVR3000:
1312 case CX88_BOARD_HAUPPAUGE_HVR4000:
1313 break;
Steven Toth6c5be742006-12-02 21:15:51 -02001314 default:
1315 err = -ENODEV;
1316 }
1317 return err;
1318}
1319
1320static int cx8802_dvb_probe(struct cx8802_driver *drv)
1321{
1322 struct cx88_core *core = drv->core;
1323 struct cx8802_dev *dev = drv->core->dvbdev;
Darron Broadcbd82442008-10-30 05:07:44 -03001324 int err;
Andy Walls6e0e12f2009-01-11 21:18:04 -03001325 struct videobuf_dvb_frontend *fe;
1326 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001328 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001329 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001330 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001331 core->name,
1332 core->pci_bus,
1333 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334
1335 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001336 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 goto fail_core;
1338
Trent Piephoecf854d2007-05-05 20:11:32 -03001339 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001340 err = vp3054_i2c_probe(dev);
1341 if (0 != err)
Andy Walls6e0e12f2009-01-11 21:18:04 -03001342 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001343
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001345 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Steven Toth363c35f2008-10-11 11:05:50 -03001346 dev->ts_gen_cntrl = 0x0c;
1347
Andy Walls6e0e12f2009-01-11 21:18:04 -03001348 err = cx8802_alloc_frontends(dev);
1349 if (err)
1350 goto fail_core;
Darron Broadcbd82442008-10-30 05:07:44 -03001351
Andy Walls6e0e12f2009-01-11 21:18:04 -03001352 err = -ENODEV;
1353 for (i = 1; i <= core->board.num_frontends; i++) {
1354 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1355 if (fe == NULL) {
1356 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
Darron Broadcbd82442008-10-30 05:07:44 -03001357 __func__, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001358 goto fail_probe;
1359 }
1360 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
Darron Broadcbd82442008-10-30 05:07:44 -03001361 &dev->pci->dev, &dev->slock,
1362 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1363 V4L2_FIELD_TOP,
1364 sizeof(struct cx88_buffer),
1365 dev);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001366 /* init struct videobuf_dvb */
1367 fe->dvb.name = dev->core->name;
Steven Toth363c35f2008-10-11 11:05:50 -03001368 }
Andy Walls6e0e12f2009-01-11 21:18:04 -03001369
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370 err = dvb_register(dev);
Darron Broadcbd82442008-10-30 05:07:44 -03001371 if (err)
1372 /* frontends/adapter de-allocated in dvb_register */
Trent Piepho5772f812007-08-15 14:41:59 -03001373 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1374 core->name, err);
Darron Broadcbd82442008-10-30 05:07:44 -03001375 return err;
1376fail_probe:
1377 videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
Darron Broad92abe9e2008-10-11 11:18:53 -03001378fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 return err;
1380}
1381
Steven Toth6c5be742006-12-02 21:15:51 -02001382static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383{
Darron Broad0fcd4882008-10-21 11:18:47 -03001384 struct cx88_core *core = drv->core;
Steven Toth6c5be742006-12-02 21:15:51 -02001385 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001386
Darron Broad0fcd4882008-10-21 11:18:47 -03001387 dprintk( 1, "%s\n", __func__);
1388
Steven Toth363c35f2008-10-11 11:05:50 -03001389 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390
Chris Pascoefc40b262006-01-09 15:25:35 -02001391 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001392
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001393 core->gate_ctrl = NULL;
1394
Steven Toth6c5be742006-12-02 21:15:51 -02001395 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396}
1397
Steven Toth6c5be742006-12-02 21:15:51 -02001398static struct cx8802_driver cx8802_dvb_driver = {
1399 .type_id = CX88_MPEG_DVB,
1400 .hw_access = CX8802_DRVCTL_SHARED,
1401 .probe = cx8802_dvb_probe,
1402 .remove = cx8802_dvb_remove,
1403 .advise_acquire = cx8802_dvb_advise_acquire,
1404 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405};
1406
Peter Huewe31d0f842009-07-17 01:00:01 +02001407static int __init dvb_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408{
Trent Piepho5772f812007-08-15 14:41:59 -03001409 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410 (CX88_VERSION_CODE >> 16) & 0xff,
1411 (CX88_VERSION_CODE >> 8) & 0xff,
1412 CX88_VERSION_CODE & 0xff);
1413#ifdef SNAPSHOT
1414 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1415 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1416#endif
Steven Toth6c5be742006-12-02 21:15:51 -02001417 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001418}
1419
Peter Huewe31d0f842009-07-17 01:00:01 +02001420static void __exit dvb_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001421{
Steven Toth6c5be742006-12-02 21:15:51 -02001422 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423}
1424
1425module_init(dvb_init);
1426module_exit(dvb_fini);
1427
1428/*
1429 * Local variables:
1430 * c-basic-offset: 8
1431 * compile-command: "make DVB=1"
1432 * End:
1433 */