blob: 07270b77ed8a43c40f6494e6a6c7ba30774678a6 [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"
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
53MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
54MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
55MODULE_LICENSE("GPL");
56
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030057static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070058module_param(debug, int, 0644);
59MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
60
Janne Grunau78e92002008-04-09 19:13:13 -030061DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020064 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66/* ------------------------------------------------------------------ */
67
68static int dvb_buf_setup(struct videobuf_queue *q,
69 unsigned int *count, unsigned int *size)
70{
71 struct cx8802_dev *dev = q->priv_data;
72
73 dev->ts_packet_size = 188 * 4;
74 dev->ts_packet_count = 32;
75
76 *size = dev->ts_packet_size * dev->ts_packet_count;
77 *count = 32;
78 return 0;
79}
80
Michael Krufky4a390552006-12-05 02:00:53 -030081static int dvb_buf_prepare(struct videobuf_queue *q,
82 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070083{
84 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030085 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086}
87
88static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
89{
90 struct cx8802_dev *dev = q->priv_data;
91 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
92}
93
Michael Krufky4a390552006-12-05 02:00:53 -030094static void dvb_buf_release(struct videobuf_queue *q,
95 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030097 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070098}
99
Adrian Bunk408b6642005-05-01 08:59:29 -0700100static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 .buf_setup = dvb_buf_setup,
102 .buf_prepare = dvb_buf_prepare,
103 .buf_queue = dvb_buf_queue,
104 .buf_release = dvb_buf_release,
105};
106
107/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300108
109static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
110{
111 struct cx8802_dev *dev= fe->dvb->priv;
112 struct cx8802_driver *drv = NULL;
113 int ret = 0;
114
115 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
116 if (drv) {
Michael Krufky4a390552006-12-05 02:00:53 -0300117 if (acquire)
Michael Krufky22f3f172006-12-05 01:38:58 -0300118 ret = drv->request_acquire(drv);
119 else
120 ret = drv->request_release(drv);
121 }
122
123 return ret;
124}
125
126/* ------------------------------------------------------------------ */
127
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200128static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129{
130 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
131 static u8 reset [] = { RESET, 0x80 };
132 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
133 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
134 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
135 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
136
137 mt352_write(fe, clock_config, sizeof(clock_config));
138 udelay(200);
139 mt352_write(fe, reset, sizeof(reset));
140 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
141
142 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
143 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
144 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
145 return 0;
146}
147
Chris Pascoe43eabb42006-01-09 18:21:28 -0200148static int dvico_dual_demod_init(struct dvb_frontend *fe)
149{
150 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
151 static u8 reset [] = { RESET, 0x80 };
152 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
153 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
154 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
155 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
156
157 mt352_write(fe, clock_config, sizeof(clock_config));
158 udelay(200);
159 mt352_write(fe, reset, sizeof(reset));
160 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
161
162 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
163 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
164 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
165
166 return 0;
167}
168
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
170{
171 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
172 static u8 reset [] = { 0x50, 0x80 };
173 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
174 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800175 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 static u8 dntv_extra[] = { 0xB5, 0x7A };
177 static u8 capt_range_cfg[] = { 0x75, 0x32 };
178
179 mt352_write(fe, clock_config, sizeof(clock_config));
180 udelay(2000);
181 mt352_write(fe, reset, sizeof(reset));
182 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
183
184 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
185 udelay(2000);
186 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
187 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
188
189 return 0;
190}
191
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192static struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300193 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200194 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195};
196
197static struct mt352_config dntv_live_dvbt_config = {
198 .demod_address = 0x0f,
199 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200};
Chris Pascoefc40b262006-01-09 15:25:35 -0200201
Chris Pascoe43eabb42006-01-09 18:21:28 -0200202static struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300203 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200204 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200205};
206
Trent Piephoecf854d2007-05-05 20:11:32 -0300207#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200208static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
209{
210 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
211 static u8 reset [] = { 0x50, 0x80 };
212 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
213 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
214 0x00, 0xFF, 0x00, 0x40, 0x40 };
215 static u8 dntv_extra[] = { 0xB5, 0x7A };
216 static u8 capt_range_cfg[] = { 0x75, 0x32 };
217
218 mt352_write(fe, clock_config, sizeof(clock_config));
219 udelay(2000);
220 mt352_write(fe, reset, sizeof(reset));
221 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
222
223 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
224 udelay(2000);
225 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
226 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
227
228 return 0;
229}
230
Chris Pascoefc40b262006-01-09 15:25:35 -0200231static struct mt352_config dntv_live_dvbt_pro_config = {
232 .demod_address = 0x0f,
233 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200234 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200235};
236#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
Chris Pascoe780dfef2006-02-28 08:34:59 -0300238static struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300239 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300240 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300241};
242
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300243static struct zl10353_config dvico_fusionhdtv_xc3028 = {
244 .demod_address = 0x0f,
245 .if2 = 45600,
246 .no_tuner = 1,
247};
248
249static struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
250 .demod_address = 0x0f,
251 .if2 = 4560,
252 .no_tuner = 1,
253 .demod_init = dvico_fusionhdtv_demod_init,
254};
255
Chris Pascoe780dfef2006-02-28 08:34:59 -0300256static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300257 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300258};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300259
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260static struct cx22702_config connexant_refboard_config = {
261 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700262 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263};
264
Michael Krufkyed355262006-12-05 01:34:56 -0300265static struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300266 .demod_address = 0x63,
267 .output_mode = CX22702_SERIAL_OUTPUT,
268};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
Michael Krufky4a390552006-12-05 02:00:53 -0300270static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271{
272 struct cx8802_dev *dev= fe->dvb->priv;
273 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
274 return 0;
275}
276
Adrian Bunk408b6642005-05-01 08:59:29 -0700277static struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300278 .demod_address = 0x15,
279 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281
Michael Krufky6ddcc912005-07-27 11:46:00 -0700282static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700283{
284 struct cx8802_dev *dev= fe->dvb->priv;
285 struct cx88_core *core = dev->core;
286
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300287 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700288 if (index == 0)
289 cx_clear(MO_GP0_IO, 8);
290 else
291 cx_set(MO_GP0_IO, 8);
292 return 0;
293}
294
Michael Krufky6ddcc912005-07-27 11:46:00 -0700295static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700296{
297 struct cx8802_dev *dev= fe->dvb->priv;
298 if (is_punctured)
299 dev->ts_gen_cntrl |= 0x04;
300 else
301 dev->ts_gen_cntrl &= ~0x04;
302 return 0;
303}
304
Michael Krufky6ddcc912005-07-27 11:46:00 -0700305static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300306 .demod_address = 0x0e,
307 .demod_chip = LGDT3302,
308 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
309 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700310};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700311
312static struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300313 .demod_address = 0x0e,
314 .demod_chip = LGDT3303,
315 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
316 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700317};
Rusty Scottda215d22006-04-07 02:21:31 -0300318
319static struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300320 .demod_address = 0x59,
321 .demod_chip = LGDT3303,
322 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
323 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300324};
Michael Krufkyf1798492005-07-07 17:58:39 -0700325
Michael Krufky4a390552006-12-05 02:00:53 -0300326static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800327{
328 struct cx8802_dev *dev= fe->dvb->priv;
329 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
330 return 0;
331}
332
333static struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300334 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300335 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800336};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800337
Steven Toth0fa14aa2006-01-09 15:25:02 -0200338static int cx24123_set_ts_param(struct dvb_frontend* fe,
339 int is_punctured)
340{
341 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300342 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200343 return 0;
344}
345
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300346static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
347 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200348{
349 struct cx8802_dev *dev= fe->dvb->priv;
350 struct cx88_core *core = dev->core;
351
Michael Krufky4a390552006-12-05 02:00:53 -0300352 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300353 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300354 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300355 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300356
357 if (core->prev_set_voltage)
358 return core->prev_set_voltage(fe, voltage);
359 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200360}
361
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300362static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
363 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300364{
365 struct cx8802_dev *dev= fe->dvb->priv;
366 struct cx88_core *core = dev->core;
367
368 if (voltage == SEC_VOLTAGE_OFF) {
369 dprintk(1,"LNB Voltage OFF\n");
370 cx_write(MO_GP0_IO, 0x0000efff);
371 }
372
373 if (core->prev_set_voltage)
374 return core->prev_set_voltage(fe, voltage);
375 return 0;
376}
377
Mauro Carvalho Chehabc4a3ce12008-04-22 14:45:31 -0300378static int cx88_pci_nano_callback(void *ptr, int command, int arg)
Steven Toth5c00fac2008-04-22 14:45:14 -0300379{
380 struct cx88_core *core = ptr;
381
382 switch (command) {
383 case XC2028_TUNER_RESET:
384 /* Send the tuner in then out of reset */
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300385 dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __func__, arg);
Steven Toth5c00fac2008-04-22 14:45:14 -0300386
387 switch (core->boardnr) {
388 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
389 /* GPIO-4 xc3028 tuner */
390
391 cx_set(MO_GP0_IO, 0x00001000);
392 cx_clear(MO_GP0_IO, 0x00000010);
393 msleep(100);
394 cx_set(MO_GP0_IO, 0x00000010);
395 msleep(100);
396 break;
397 }
398
399 break;
400 case XC2028_RESET_CLK:
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300401 dprintk(1, "%s: XC2028_RESET_CLK %d\n", __func__, arg);
Steven Toth5c00fac2008-04-22 14:45:14 -0300402 break;
403 default:
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300404 dprintk(1, "%s: unknown command %d, arg %d\n", __func__,
Steven Toth5c00fac2008-04-22 14:45:14 -0300405 command, arg);
406 return -EINVAL;
407 }
408
409 return 0;
410}
411
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300412static struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300413 .demod_address = 0x55,
414 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300415};
416
Steven Toth0fa14aa2006-01-09 15:25:02 -0200417static struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300418 .demod_address = 0x55,
419 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200420};
421
422static struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300423 .demod_address = 0x15,
424 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300425 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200426};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200427
Steven Toth60464da2008-01-05 16:53:01 -0300428static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
429 .demod_address = 0x32 >> 1,
430 .output_mode = S5H1409_PARALLEL_OUTPUT,
431 .gpio = S5H1409_GPIO_ON,
432 .qam_if = 44000,
433 .inversion = S5H1409_INVERSION_OFF,
434 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300435 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300436};
437
Steven Toth5c00fac2008-04-22 14:45:14 -0300438static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
439 .demod_address = 0x32 >> 1,
440 .output_mode = S5H1409_SERIAL_OUTPUT,
441 .gpio = S5H1409_GPIO_OFF,
442 .inversion = S5H1409_INVERSION_OFF,
443 .status_mode = S5H1409_DEMODLOCKING,
444 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
445};
446
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300447static struct s5h1409_config kworld_atsc_120_config = {
448 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300449 .output_mode = S5H1409_SERIAL_OUTPUT,
450 .gpio = S5H1409_GPIO_OFF,
451 .inversion = S5H1409_INVERSION_OFF,
452 .status_mode = S5H1409_DEMODLOCKING,
453 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
454};
455
Steven Toth60464da2008-01-05 16:53:01 -0300456static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
457 .i2c_address = 0x64,
458 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300459 .tuner_callback = cx88_tuner_callback,
460};
461
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300462static struct zl10353_config cx88_geniatech_x8000_mt = {
463 .demod_address = (0x1e >> 1),
464 .no_tuner = 1,
465};
466
Steven Tothd893d5d2008-04-25 03:46:43 -0300467static struct s5h1411_config dvico_fusionhdtv7_config = {
468 .output_mode = S5H1411_SERIAL_OUTPUT,
469 .gpio = S5H1411_GPIO_ON,
470 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
471 .qam_if = S5H1411_IF_44000,
472 .vsb_if = S5H1411_IF_44000,
473 .inversion = S5H1411_INVERSION_OFF,
474 .status_mode = S5H1411_DEMODLOCKING
475};
476
477static struct xc5000_config dvico_fusionhdtv7_tuner_config = {
478 .i2c_address = 0xc2 >> 1,
479 .if_khz = 5380,
480 .tuner_callback = cx88_tuner_callback,
481};
482
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300483static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
484{
485 struct dvb_frontend *fe;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300486 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300487 struct xc2028_config cfg = {
488 .i2c_adap = &dev->core->i2c_adap,
489 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300490 .ctrl = &ctl,
491 .callback = cx88_tuner_callback,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300492 };
493
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300494 if (!dev->dvb.frontend) {
495 printk(KERN_ERR "%s/2: dvb frontend not attached. "
496 "Can't attach xc3028\n",
497 dev->core->name);
498 return -EINVAL;
499 }
500
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300501 /*
502 * Some xc3028 devices may be hidden by an I2C gate. This is known
503 * to happen with some s5h1409-based devices.
504 * Now that I2C gate is open, sets up xc3028 configuration
505 */
506 cx88_setup_xc3028(dev->core, &ctl);
507
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300508 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
509 if (!fe) {
510 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
511 dev->core->name);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300512 return -EINVAL;
513 }
514
515 printk(KERN_INFO "%s/2: xc3028 attached\n",
516 dev->core->name);
517
518 return 0;
519}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300520
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521static int dvb_register(struct cx8802_dev *dev)
522{
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300523 struct cx88_core *core = dev->core;
524
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 /* init struct videobuf_dvb */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300526 dev->dvb.name = core->name;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 dev->ts_gen_cntrl = 0x0c;
528
529 /* init frontend */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300530 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300532 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300533 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300534 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300535 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300536 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
537 0x61, &core->i2c_adap,
538 DVB_PLL_THOMSON_DTT759X))
539 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300540 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700542 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200544 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800545 case CX88_BOARD_WINFAST_DTV1000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300546 dev->dvb.frontend = dvb_attach(cx22702_attach,
547 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300548 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300549 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300550 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
551 0x60, &core->i2c_adap,
552 DVB_PLL_THOMSON_DTT7579))
553 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300554 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300556 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -0200557 case CX88_BOARD_HAUPPAUGE_HVR1100:
558 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300559 case CX88_BOARD_HAUPPAUGE_HVR1300:
560 case CX88_BOARD_HAUPPAUGE_HVR3000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300561 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300562 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300563 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300564 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300565 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
566 &core->i2c_adap, 0x61,
567 TUNER_PHILIPS_FMD1216ME_MK3))
568 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300569 }
Steven Toth611900c2006-01-09 15:25:12 -0200570 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300571 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300572 dev->dvb.frontend = dvb_attach(mt352_attach,
573 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300574 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300575 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300576 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
577 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
578 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300579 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300580 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300581 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300582 dev->dvb.frontend = dvb_attach(zl10353_attach,
583 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300584 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300585 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300586 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
587 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
588 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300589 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300590 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300591 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300592 /* The tin box says DEE1601, but it seems to be DTT7579
593 * compatible, with a slightly different MT352 AGC gain. */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300594 dev->dvb.frontend = dvb_attach(mt352_attach,
595 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300596 &core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300597 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300598 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
599 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
600 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300601 break;
602 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300603 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300604 dev->dvb.frontend = dvb_attach(zl10353_attach,
605 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300606 &core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300607 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300608 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
609 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
610 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300611 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300612 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300614 dev->dvb.frontend = dvb_attach(mt352_attach,
615 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300616 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300617 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300618 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
619 0x61, NULL, DVB_PLL_LG_Z201))
620 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300621 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 case CX88_BOARD_KWORLD_DVB_T:
624 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700625 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300626 dev->dvb.frontend = dvb_attach(mt352_attach,
627 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300628 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300629 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300630 if (!dvb_attach(dvb_pll_attach, dev->dvb.frontend,
631 0x61, NULL, DVB_PLL_UNKNOWN_1))
632 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300633 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200635 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -0300636#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -0300637 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300638 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -0300639 &dev->vp3054->adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300640 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300641 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
642 &core->i2c_adap, 0x61,
643 TUNER_PHILIPS_FMD1216ME_MK3))
644 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300645 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200646#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300647 printk(KERN_ERR "%s/2: built without vp3054 support\n",
648 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -0200649#endif
650 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300651 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300652 dev->dvb.frontend = dvb_attach(zl10353_attach,
653 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300654 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300655 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300656 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
657 &core->i2c_adap, 0x61,
658 TUNER_THOMSON_FE6600))
659 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300660 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300661 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300662 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
663 dev->dvb.frontend = dvb_attach(zl10353_attach,
664 &dvico_fusionhdtv_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300665 &core->i2c_adap);
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300666 if (dev->dvb.frontend == NULL)
667 dev->dvb.frontend = dvb_attach(mt352_attach,
668 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300669 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -0300670 /*
671 * On this board, the demod provides the I2C bus pullup.
672 * We must not permit gate_ctrl to be performed, or
673 * the xc3028 cannot communicate on the bus.
674 */
675 if (dev->dvb.frontend)
676 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300677 if (attach_xc3028(0x61, dev) < 0)
678 return -EINVAL;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300679 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 case CX88_BOARD_PCHDTV_HD3000:
Michael Krufky4a390552006-12-05 02:00:53 -0300681 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300682 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300683 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300684 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
685 &core->i2c_adap, 0x61,
686 TUNER_THOMSON_DTT761X))
687 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300688 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700690 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
691 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -0700692
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300693 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -0700694 cx_clear(MO_GP0_IO, 1);
695 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700696 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700697 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700698
699 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700700 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300701 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
702 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300703 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300704 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300705 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
706 &core->i2c_adap, 0x61,
707 TUNER_MICROTUNE_4042FI5))
708 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -0700709 }
710 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700711 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
712 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -0700713
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300714 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -0700715 cx_clear(MO_GP0_IO, 1);
716 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700717 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700718 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300719 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
720 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300721 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300722 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300723 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
724 &core->i2c_adap, 0x61,
725 TUNER_THOMSON_DTT761X))
726 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -0700727 }
728 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700729 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
730 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700731
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300732 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700733 cx_clear(MO_GP0_IO, 1);
734 mdelay(100);
735 cx_set(MO_GP0_IO, 1);
736 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300737 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
738 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300739 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300740 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300741 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
742 &core->i2c_adap, 0x61,
743 TUNER_LG_TDVS_H06XF))
744 goto frontend_detach;
745 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
746 &core->i2c_adap, 0x43))
747 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700748 }
749 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300750 case CX88_BOARD_PCHDTV_HD5500:
751 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -0300752
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300753 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -0300754 cx_clear(MO_GP0_IO, 1);
755 mdelay(100);
756 cx_set(MO_GP0_IO, 1);
757 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300758 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
759 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300760 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300761 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300762 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
763 &core->i2c_adap, 0x61,
764 TUNER_LG_TDVS_H06XF))
765 goto frontend_detach;
766 if (!dvb_attach(tda9887_attach, dev->dvb.frontend,
767 &core->i2c_adap, 0x43))
768 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -0300769 }
770 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -0800771 case CX88_BOARD_ATI_HDTVWONDER:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300772 dev->dvb.frontend = dvb_attach(nxt200x_attach,
773 &ati_hdtvwonder,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300774 &core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300775 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300776 if (!dvb_attach(simple_tuner_attach, dev->dvb.frontend,
777 &core->i2c_adap, 0x61,
778 TUNER_PHILIPS_TUV1236D))
779 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300780 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800781 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200782 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
783 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300784 dev->dvb.frontend = dvb_attach(cx24123_attach,
785 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300786 &core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300787 if (dev->dvb.frontend) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300788 if (!dvb_attach(isl6421_attach, dev->dvb.frontend,
789 &core->i2c_adap, 0x08, 0x00, 0x00))
790 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300791 }
Steven Toth0fa14aa2006-01-09 15:25:02 -0200792 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200793 case CX88_BOARD_KWORLD_DVBS_100:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300794 dev->dvb.frontend = dvb_attach(cx24123_attach,
795 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300796 &core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300797 if (dev->dvb.frontend) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300798 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
Patrick Boettcherdea74862006-05-14 05:01:31 -0300799 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300800 }
Vadim Catana0e0351e2006-01-09 15:25:02 -0200801 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300802 case CX88_BOARD_GENIATECH_DVBS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300803 dev->dvb.frontend = dvb_attach(cx24123_attach,
804 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300805 &core->i2c_adap);
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300806 if (dev->dvb.frontend) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300807 core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300808 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
809 }
810 break;
Steven Toth60464da2008-01-05 16:53:01 -0300811 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth60464da2008-01-05 16:53:01 -0300812 dev->dvb.frontend = dvb_attach(s5h1409_attach,
813 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300814 &core->i2c_adap);
Steven Toth60464da2008-01-05 16:53:01 -0300815 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300816 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
817 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -0300818 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300819 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -0300820 }
821 break;
Steven Toth5c00fac2008-04-22 14:45:14 -0300822 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
823 dev->dvb.frontend = dvb_attach(s5h1409_attach,
824 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300825 &core->i2c_adap);
Steven Toth5c00fac2008-04-22 14:45:14 -0300826 if (dev->dvb.frontend != NULL) {
827 struct dvb_frontend *fe;
828 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300829 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -0300830 .i2c_addr = 0x61,
Mauro Carvalho Chehabc4a3ce12008-04-22 14:45:31 -0300831 .callback = cx88_pci_nano_callback,
Steven Toth5c00fac2008-04-22 14:45:14 -0300832 };
833 static struct xc2028_ctrl ctl = {
834 .fname = "xc3028-v27.fw",
835 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -0300836 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -0300837 };
838
839 fe = dvb_attach(xc2028_attach,
840 dev->dvb.frontend, &cfg);
841 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
842 fe->ops.tuner_ops.set_config(fe, &ctl);
843 }
844 break;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300845 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
846 dev->dvb.frontend = dvb_attach(zl10353_attach,
847 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300848 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300849 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300850 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300851 break;
852 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300853 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300854
855 dev->dvb.frontend = dvb_attach(zl10353_attach,
856 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300857 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300858 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300859 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300860 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300861 case CX88_BOARD_KWORLD_ATSC_120:
862 dev->dvb.frontend = dvb_attach(s5h1409_attach,
863 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300864 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300865 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300866 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300867 break;
Steven Tothd893d5d2008-04-25 03:46:43 -0300868 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
869 dev->dvb.frontend = dvb_attach(s5h1411_attach,
870 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300871 &core->i2c_adap);
Steven Tothd893d5d2008-04-25 03:46:43 -0300872 if (dev->dvb.frontend != NULL) {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300873 if (!dvb_attach(xc5000_attach, dev->dvb.frontend,
874 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -0300875 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300876 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -0300877 }
878 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 default:
Trent Piepho5772f812007-08-15 14:41:59 -0300880 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 -0300881 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 break;
883 }
884 if (NULL == dev->dvb.frontend) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300885 printk(KERN_ERR
886 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300887 core->name);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300888 return -EINVAL;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300889 }
890
Steven Toth6c5be742006-12-02 21:15:51 -0200891 /* Ensure all frontends negotiate bus access */
892 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893
Mauro Carvalho Chehab93352f5c2005-09-13 01:25:42 -0700894 /* Put the analog decoder in standby to keep it quiet */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300895 cx88_call_i2c_clients(core, TUNER_SET_STANDBY, NULL);
Mauro Carvalho Chehab93352f5c2005-09-13 01:25:42 -0700896
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 /* register everything */
Janne Grunau78e92002008-04-09 19:13:13 -0300898 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev,
899 &dev->pci->dev, adapter_nr);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300900
901frontend_detach:
902 if (dev->dvb.frontend) {
903 dvb_frontend_detach(dev->dvb.frontend);
904 dev->dvb.frontend = NULL;
905 }
906 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907}
908
909/* ----------------------------------------------------------- */
910
Steven Toth6c5be742006-12-02 21:15:51 -0200911/* CX8802 MPEG -> mini driver - We have been given the hardware */
912static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913{
Steven Toth6c5be742006-12-02 21:15:51 -0200914 struct cx88_core *core = drv->core;
915 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300916 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -0200917
Trent Piepho6a59d642007-08-15 14:41:57 -0300918 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -0200919 case CX88_BOARD_HAUPPAUGE_HVR1300:
920 /* We arrive here with either the cx23416 or the cx22702
921 * on the bus. Take the bus from the cx23416 and enable the
922 * cx22702 demod
923 */
924 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
925 cx_clear(MO_GP0_IO, 0x00000004);
926 udelay(1000);
927 break;
928 default:
929 err = -ENODEV;
930 }
931 return err;
932}
933
934/* CX8802 MPEG -> mini driver - We no longer have the hardware */
935static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
936{
937 struct cx88_core *core = drv->core;
938 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300939 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -0200940
Trent Piepho6a59d642007-08-15 14:41:57 -0300941 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -0200942 case CX88_BOARD_HAUPPAUGE_HVR1300:
943 /* Do Nothing, leave the cx22702 on the bus. */
944 break;
945 default:
946 err = -ENODEV;
947 }
948 return err;
949}
950
951static int cx8802_dvb_probe(struct cx8802_driver *drv)
952{
953 struct cx88_core *core = drv->core;
954 struct cx8802_dev *dev = drv->core->dvbdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 int err;
956
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300957 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -0200958 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -0300959 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -0200960 core->name,
961 core->pci_bus,
962 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963
964 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -0300965 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 goto fail_core;
967
Trent Piephoecf854d2007-05-05 20:11:32 -0300968 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -0200969 err = vp3054_i2c_probe(dev);
970 if (0 != err)
Steven Toth6c5be742006-12-02 21:15:51 -0200971 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -0200972
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -0300974 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Guennadi Liakhovetski07051352008-04-22 14:42:13 -0300975 videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops,
976 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 V4L2_BUF_TYPE_VIDEO_CAPTURE,
978 V4L2_FIELD_TOP,
979 sizeof(struct cx88_buffer),
980 dev);
981 err = dvb_register(dev);
Steven Toth6c5be742006-12-02 21:15:51 -0200982 if (err != 0)
Trent Piepho5772f812007-08-15 14:41:59 -0300983 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
984 core->name, err);
Steven Toth611900c2006-01-09 15:25:12 -0200985
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986 fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 return err;
988}
989
Steven Toth6c5be742006-12-02 21:15:51 -0200990static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991{
Steven Toth6c5be742006-12-02 21:15:51 -0200992 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -0200993
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 /* dvb */
Mauro Carvalho Chehab9950c1b2008-04-11 11:29:44 -0300995 if (dev->dvb.frontend)
996 videobuf_dvb_unregister(&dev->dvb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997
Chris Pascoefc40b262006-01-09 15:25:35 -0200998 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -0200999
Steven Toth6c5be742006-12-02 21:15:51 -02001000 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001}
1002
Steven Toth6c5be742006-12-02 21:15:51 -02001003static struct cx8802_driver cx8802_dvb_driver = {
1004 .type_id = CX88_MPEG_DVB,
1005 .hw_access = CX8802_DRVCTL_SHARED,
1006 .probe = cx8802_dvb_probe,
1007 .remove = cx8802_dvb_remove,
1008 .advise_acquire = cx8802_dvb_advise_acquire,
1009 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010};
1011
1012static int dvb_init(void)
1013{
Trent Piepho5772f812007-08-15 14:41:59 -03001014 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 (CX88_VERSION_CODE >> 16) & 0xff,
1016 (CX88_VERSION_CODE >> 8) & 0xff,
1017 CX88_VERSION_CODE & 0xff);
1018#ifdef SNAPSHOT
1019 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1020 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1021#endif
Steven Toth6c5be742006-12-02 21:15:51 -02001022 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023}
1024
1025static void dvb_fini(void)
1026{
Steven Toth6c5be742006-12-02 21:15:51 -02001027 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028}
1029
1030module_init(dvb_init);
1031module_exit(dvb_fini);
1032
1033/*
1034 * Local variables:
1035 * c-basic-offset: 8
1036 * compile-command: "make DVB=1"
1037 * End:
1038 */