blob: 59180cab0a855ad7f8c9eb4729c17341dd234f90 [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"
Steven Toth5c00fac2008-04-22 14:45:14 -030048#include "tuner-xc2028.h"
49#include "tuner-xc2028-types.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
52MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
53MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
54MODULE_LICENSE("GPL");
55
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030056static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070057module_param(debug, int, 0644);
58MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
59
60#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020061 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63/* ------------------------------------------------------------------ */
64
65static int dvb_buf_setup(struct videobuf_queue *q,
66 unsigned int *count, unsigned int *size)
67{
68 struct cx8802_dev *dev = q->priv_data;
69
70 dev->ts_packet_size = 188 * 4;
71 dev->ts_packet_count = 32;
72
73 *size = dev->ts_packet_size * dev->ts_packet_count;
74 *count = 32;
75 return 0;
76}
77
Michael Krufky4a390552006-12-05 02:00:53 -030078static int dvb_buf_prepare(struct videobuf_queue *q,
79 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080{
81 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030082 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083}
84
85static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
86{
87 struct cx8802_dev *dev = q->priv_data;
88 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
89}
90
Michael Krufky4a390552006-12-05 02:00:53 -030091static void dvb_buf_release(struct videobuf_queue *q,
92 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -070093{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030094 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -070095}
96
Adrian Bunk408b6642005-05-01 08:59:29 -070097static struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 .buf_setup = dvb_buf_setup,
99 .buf_prepare = dvb_buf_prepare,
100 .buf_queue = dvb_buf_queue,
101 .buf_release = dvb_buf_release,
102};
103
104/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300105
106static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
107{
108 struct cx8802_dev *dev= fe->dvb->priv;
109 struct cx8802_driver *drv = NULL;
110 int ret = 0;
111
112 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
113 if (drv) {
Michael Krufky4a390552006-12-05 02:00:53 -0300114 if (acquire)
Michael Krufky22f3f172006-12-05 01:38:58 -0300115 ret = drv->request_acquire(drv);
116 else
117 ret = drv->request_release(drv);
118 }
119
120 return ret;
121}
122
123/* ------------------------------------------------------------------ */
124
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200125static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126{
127 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
128 static u8 reset [] = { RESET, 0x80 };
129 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
130 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
131 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
132 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
133
134 mt352_write(fe, clock_config, sizeof(clock_config));
135 udelay(200);
136 mt352_write(fe, reset, sizeof(reset));
137 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
138
139 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
140 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
141 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
142 return 0;
143}
144
Chris Pascoe43eabb42006-01-09 18:21:28 -0200145static int dvico_dual_demod_init(struct dvb_frontend *fe)
146{
147 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
148 static u8 reset [] = { RESET, 0x80 };
149 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
150 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
151 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
152 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
153
154 mt352_write(fe, clock_config, sizeof(clock_config));
155 udelay(200);
156 mt352_write(fe, reset, sizeof(reset));
157 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
158
159 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
160 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
161 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
162
163 return 0;
164}
165
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
167{
168 static u8 clock_config [] = { 0x89, 0x38, 0x39 };
169 static u8 reset [] = { 0x50, 0x80 };
170 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
171 static u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800172 0x00, 0xFF, 0x00, 0x40, 0x40 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 static u8 dntv_extra[] = { 0xB5, 0x7A };
174 static u8 capt_range_cfg[] = { 0x75, 0x32 };
175
176 mt352_write(fe, clock_config, sizeof(clock_config));
177 udelay(2000);
178 mt352_write(fe, reset, sizeof(reset));
179 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
180
181 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
182 udelay(2000);
183 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
184 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
185
186 return 0;
187}
188
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189static struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300190 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200191 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192};
193
194static struct mt352_config dntv_live_dvbt_config = {
195 .demod_address = 0x0f,
196 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197};
Chris Pascoefc40b262006-01-09 15:25:35 -0200198
Chris Pascoe43eabb42006-01-09 18:21:28 -0200199static struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300200 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200201 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200202};
203
Trent Piephoecf854d2007-05-05 20:11:32 -0300204#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200205static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
206{
207 static u8 clock_config [] = { 0x89, 0x38, 0x38 };
208 static u8 reset [] = { 0x50, 0x80 };
209 static u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
210 static u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
211 0x00, 0xFF, 0x00, 0x40, 0x40 };
212 static u8 dntv_extra[] = { 0xB5, 0x7A };
213 static u8 capt_range_cfg[] = { 0x75, 0x32 };
214
215 mt352_write(fe, clock_config, sizeof(clock_config));
216 udelay(2000);
217 mt352_write(fe, reset, sizeof(reset));
218 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
219
220 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
221 udelay(2000);
222 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
223 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
224
225 return 0;
226}
227
Chris Pascoefc40b262006-01-09 15:25:35 -0200228static struct mt352_config dntv_live_dvbt_pro_config = {
229 .demod_address = 0x0f,
230 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200231 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200232};
233#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
Chris Pascoe780dfef2006-02-28 08:34:59 -0300235static struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300236 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300237 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300238};
239
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300240static struct zl10353_config dvico_fusionhdtv_xc3028 = {
241 .demod_address = 0x0f,
242 .if2 = 45600,
243 .no_tuner = 1,
244};
245
246static struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
247 .demod_address = 0x0f,
248 .if2 = 4560,
249 .no_tuner = 1,
250 .demod_init = dvico_fusionhdtv_demod_init,
251};
252
Chris Pascoe780dfef2006-02-28 08:34:59 -0300253static struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300254 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300255};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300256
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257static struct cx22702_config connexant_refboard_config = {
258 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700259 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260};
261
Michael Krufkyed355262006-12-05 01:34:56 -0300262static struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300263 .demod_address = 0x63,
264 .output_mode = CX22702_SERIAL_OUTPUT,
265};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266
Michael Krufky4a390552006-12-05 02:00:53 -0300267static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268{
269 struct cx8802_dev *dev= fe->dvb->priv;
270 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
271 return 0;
272}
273
Adrian Bunk408b6642005-05-01 08:59:29 -0700274static struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300275 .demod_address = 0x15,
276 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278
Michael Krufky6ddcc912005-07-27 11:46:00 -0700279static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700280{
281 struct cx8802_dev *dev= fe->dvb->priv;
282 struct cx88_core *core = dev->core;
283
284 dprintk(1, "%s: index = %d\n", __FUNCTION__, index);
285 if (index == 0)
286 cx_clear(MO_GP0_IO, 8);
287 else
288 cx_set(MO_GP0_IO, 8);
289 return 0;
290}
291
Michael Krufky6ddcc912005-07-27 11:46:00 -0700292static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700293{
294 struct cx8802_dev *dev= fe->dvb->priv;
295 if (is_punctured)
296 dev->ts_gen_cntrl |= 0x04;
297 else
298 dev->ts_gen_cntrl &= ~0x04;
299 return 0;
300}
301
Michael Krufky6ddcc912005-07-27 11:46:00 -0700302static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300303 .demod_address = 0x0e,
304 .demod_chip = LGDT3302,
305 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
306 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700307};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700308
309static struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300310 .demod_address = 0x0e,
311 .demod_chip = LGDT3303,
312 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
313 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700314};
Rusty Scottda215d22006-04-07 02:21:31 -0300315
316static struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300317 .demod_address = 0x59,
318 .demod_chip = LGDT3303,
319 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
320 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300321};
Michael Krufkyf1798492005-07-07 17:58:39 -0700322
Michael Krufky4a390552006-12-05 02:00:53 -0300323static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800324{
325 struct cx8802_dev *dev= fe->dvb->priv;
326 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
327 return 0;
328}
329
330static struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300331 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300332 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800333};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800334
Steven Toth0fa14aa2006-01-09 15:25:02 -0200335static int cx24123_set_ts_param(struct dvb_frontend* fe,
336 int is_punctured)
337{
338 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300339 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200340 return 0;
341}
342
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300343static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
344 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200345{
346 struct cx8802_dev *dev= fe->dvb->priv;
347 struct cx88_core *core = dev->core;
348
Michael Krufky4a390552006-12-05 02:00:53 -0300349 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300350 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300351 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300352 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300353
354 if (core->prev_set_voltage)
355 return core->prev_set_voltage(fe, voltage);
356 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200357}
358
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300359static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
360 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300361{
362 struct cx8802_dev *dev= fe->dvb->priv;
363 struct cx88_core *core = dev->core;
364
365 if (voltage == SEC_VOLTAGE_OFF) {
366 dprintk(1,"LNB Voltage OFF\n");
367 cx_write(MO_GP0_IO, 0x0000efff);
368 }
369
370 if (core->prev_set_voltage)
371 return core->prev_set_voltage(fe, voltage);
372 return 0;
373}
374
Steven Toth5c00fac2008-04-22 14:45:14 -0300375static int cx88_xc3028_callback(void *ptr, int command, int arg)
376{
377 struct cx88_core *core = ptr;
378
379 switch (command) {
380 case XC2028_TUNER_RESET:
381 /* Send the tuner in then out of reset */
382 dprintk(1, "%s: XC2028_TUNER_RESET %d\n", __FUNCTION__, arg);
383
384 switch (core->boardnr) {
385 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
386 /* GPIO-4 xc3028 tuner */
387
388 cx_set(MO_GP0_IO, 0x00001000);
389 cx_clear(MO_GP0_IO, 0x00000010);
390 msleep(100);
391 cx_set(MO_GP0_IO, 0x00000010);
392 msleep(100);
393 break;
394 }
395
396 break;
397 case XC2028_RESET_CLK:
398 dprintk(1, "%s: XC2028_RESET_CLK %d\n", __FUNCTION__, arg);
399 break;
400 default:
401 dprintk(1, "%s: unknown command %d, arg %d\n", __FUNCTION__,
402 command, arg);
403 return -EINVAL;
404 }
405
406 return 0;
407}
408
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300409static struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300410 .demod_address = 0x55,
411 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300412};
413
Steven Toth0fa14aa2006-01-09 15:25:02 -0200414static struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300415 .demod_address = 0x55,
416 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200417};
418
419static struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300420 .demod_address = 0x15,
421 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300422 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200423};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200424
Steven Toth60464da2008-01-05 16:53:01 -0300425static struct s5h1409_config pinnacle_pctv_hd_800i_config = {
426 .demod_address = 0x32 >> 1,
427 .output_mode = S5H1409_PARALLEL_OUTPUT,
428 .gpio = S5H1409_GPIO_ON,
429 .qam_if = 44000,
430 .inversion = S5H1409_INVERSION_OFF,
431 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300432 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300433};
434
Steven Toth5c00fac2008-04-22 14:45:14 -0300435static struct s5h1409_config dvico_hdtv5_pci_nano_config = {
436 .demod_address = 0x32 >> 1,
437 .output_mode = S5H1409_SERIAL_OUTPUT,
438 .gpio = S5H1409_GPIO_OFF,
439 .inversion = S5H1409_INVERSION_OFF,
440 .status_mode = S5H1409_DEMODLOCKING,
441 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
442};
443
Steven Toth60464da2008-01-05 16:53:01 -0300444static struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
445 .i2c_address = 0x64,
446 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300447 .tuner_callback = cx88_tuner_callback,
448};
449
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300450static struct zl10353_config cx88_geniatech_x8000_mt = {
451 .demod_address = (0x1e >> 1),
452 .no_tuner = 1,
453};
454
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300455static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
456{
457 struct dvb_frontend *fe;
458 struct xc2028_config cfg = {
459 .i2c_adap = &dev->core->i2c_adap,
460 .i2c_addr = addr,
461 .video_dev = dev->core,
462 };
463
464 fe = dvb_attach(xc2028_attach, dev->dvb.frontend, &cfg);
465 if (!fe) {
466 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
467 dev->core->name);
468 dvb_frontend_detach(dev->dvb.frontend);
469 dvb_unregister_frontend(dev->dvb.frontend);
470 dev->dvb.frontend = NULL;
471 return -EINVAL;
472 }
473
474 printk(KERN_INFO "%s/2: xc3028 attached\n",
475 dev->core->name);
476
477 return 0;
478}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300479
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480static int dvb_register(struct cx8802_dev *dev)
481{
482 /* init struct videobuf_dvb */
483 dev->dvb.name = dev->core->name;
484 dev->ts_gen_cntrl = 0x0c;
485
486 /* init frontend */
Trent Piepho6a59d642007-08-15 14:41:57 -0300487 switch (dev->core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300489 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300490 &connexant_refboard_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300491 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300492 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300493 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300494 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300495 DVB_PLL_THOMSON_DTT759X);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300496 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700498 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200500 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800501 case CX88_BOARD_WINFAST_DTV1000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300502 dev->dvb.frontend = dvb_attach(cx22702_attach,
503 &connexant_refboard_config,
504 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300505 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300506 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300507 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300508 DVB_PLL_THOMSON_DTT7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300509 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300511 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -0200512 case CX88_BOARD_HAUPPAUGE_HVR1100:
513 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300514 case CX88_BOARD_HAUPPAUGE_HVR1300:
515 case CX88_BOARD_HAUPPAUGE_HVR3000:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300516 dev->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300517 &hauppauge_hvr_config,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300518 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300519 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300520 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300521 &dev->core->i2c_adap, DVB_PLL_FMD1216ME);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300522 }
Steven Toth611900c2006-01-09 15:25:12 -0200523 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300524 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300525 dev->dvb.frontend = dvb_attach(mt352_attach,
526 &dvico_fusionhdtv,
527 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300528 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300529 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300530 NULL, DVB_PLL_THOMSON_DTT7579);
Chris Pascoe780dfef2006-02-28 08:34:59 -0300531 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300532 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300533 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300534 dev->dvb.frontend = dvb_attach(zl10353_attach,
535 &dvico_fusionhdtv_plus_v1_1,
536 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300537 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300538 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300539 NULL, DVB_PLL_THOMSON_DTT7579);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300540 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300541 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300542 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300543 /* The tin box says DEE1601, but it seems to be DTT7579
544 * compatible, with a slightly different MT352 AGC gain. */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300545 dev->dvb.frontend = dvb_attach(mt352_attach,
546 &dvico_fusionhdtv_dual,
547 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300548 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300549 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300550 NULL, DVB_PLL_THOMSON_DTT7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300551 break;
552 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300553 /* ZL10353 replaces MT352 on later cards */
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300554 dev->dvb.frontend = dvb_attach(zl10353_attach,
555 &dvico_fusionhdtv_plus_v1_1,
556 &dev->core->i2c_adap);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300557 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300558 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300559 NULL, DVB_PLL_THOMSON_DTT7579);
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300560 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300561 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300563 dev->dvb.frontend = dvb_attach(mt352_attach,
564 &dvico_fusionhdtv,
565 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300566 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300567 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300568 NULL, DVB_PLL_LG_Z201);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300569 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 case CX88_BOARD_KWORLD_DVB_T:
572 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -0700573 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300574 dev->dvb.frontend = dvb_attach(mt352_attach,
575 &dntv_live_dvbt_config,
576 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300577 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300578 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300579 NULL, DVB_PLL_UNKNOWN_1);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300580 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 break;
Chris Pascoefc40b262006-01-09 15:25:35 -0200582 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -0300583#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -0300584 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300585 dev->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -0300586 &dev->vp3054->adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300587 if (dev->dvb.frontend != NULL) {
Trent Piephob7754d72007-05-08 18:05:16 -0300588 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300589 &dev->core->i2c_adap, DVB_PLL_FMD1216ME);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300590 }
Chris Pascoefc40b262006-01-09 15:25:35 -0200591#else
Trent Piepho5772f812007-08-15 14:41:59 -0300592 printk(KERN_ERR "%s/2: built without vp3054 support\n", dev->core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -0200593#endif
594 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300595 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300596 dev->dvb.frontend = dvb_attach(zl10353_attach,
597 &dvico_fusionhdtv_hybrid,
598 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300599 if (dev->dvb.frontend != NULL) {
Michael Krufky5786a342006-12-05 01:21:19 -0300600 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
601 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300602 DVB_PLL_THOMSON_FE6600);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300603 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300604 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300605 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
606 dev->dvb.frontend = dvb_attach(zl10353_attach,
607 &dvico_fusionhdtv_xc3028,
608 &dev->core->i2c_adap);
609 if (dev->dvb.frontend == NULL)
610 dev->dvb.frontend = dvb_attach(mt352_attach,
611 &dvico_fusionhdtv_mt352_xc3028,
612 &dev->core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -0300613 /*
614 * On this board, the demod provides the I2C bus pullup.
615 * We must not permit gate_ctrl to be performed, or
616 * the xc3028 cannot communicate on the bus.
617 */
618 if (dev->dvb.frontend)
619 dev->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300620 if (attach_xc3028(0x61, dev) < 0)
621 return -EINVAL;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300622 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 case CX88_BOARD_PCHDTV_HD3000:
Michael Krufky4a390552006-12-05 02:00:53 -0300624 dev->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300625 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300626 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300627 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300628 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300629 DVB_PLL_THOMSON_DTT761X);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300630 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 break;
Michael Krufkyf1798492005-07-07 17:58:39 -0700632 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
633 dev->ts_gen_cntrl = 0x08;
634 {
635 /* Do a hardware reset of chip before using it. */
636 struct cx88_core *core = dev->core;
637
638 cx_clear(MO_GP0_IO, 1);
639 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700640 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -0700641 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700642
643 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -0700644 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300645 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
646 &fusionhdtv_3_gold,
647 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300648 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300649 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
650 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300651 DVB_PLL_MICROTUNE_4042);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300652 }
Michael Krufkyf1798492005-07-07 17:58:39 -0700653 }
654 break;
Michael Krufky0d723c02005-07-07 17:58:42 -0700655 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
656 dev->ts_gen_cntrl = 0x08;
657 {
658 /* Do a hardware reset of chip before using it. */
659 struct cx88_core *core = dev->core;
660
661 cx_clear(MO_GP0_IO, 1);
662 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -0700663 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -0700664 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300665 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
666 &fusionhdtv_3_gold,
667 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300668 if (dev->dvb.frontend != NULL) {
Michael Krufky1d4bb7d2006-12-05 01:01:39 -0300669 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
670 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300671 DVB_PLL_THOMSON_DTT761X);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300672 }
Michael Krufky0d723c02005-07-07 17:58:42 -0700673 }
674 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700675 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
676 dev->ts_gen_cntrl = 0x08;
677 {
678 /* Do a hardware reset of chip before using it. */
679 struct cx88_core *core = dev->core;
680
681 cx_clear(MO_GP0_IO, 1);
682 mdelay(100);
683 cx_set(MO_GP0_IO, 1);
684 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300685 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
686 &fusionhdtv_5_gold,
687 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300688 if (dev->dvb.frontend != NULL) {
Trent Piepho6bdcc6e2007-04-27 12:31:30 -0300689 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
690 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300691 DVB_PLL_LG_TDVS_H06XF);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300692 }
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700693 }
694 break;
Rusty Scottda215d22006-04-07 02:21:31 -0300695 case CX88_BOARD_PCHDTV_HD5500:
696 dev->ts_gen_cntrl = 0x08;
697 {
698 /* Do a hardware reset of chip before using it. */
699 struct cx88_core *core = dev->core;
700
701 cx_clear(MO_GP0_IO, 1);
702 mdelay(100);
703 cx_set(MO_GP0_IO, 1);
704 mdelay(200);
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300705 dev->dvb.frontend = dvb_attach(lgdt330x_attach,
706 &pchdtv_hd5500,
707 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300708 if (dev->dvb.frontend != NULL) {
Trent Piepho6bdcc6e2007-04-27 12:31:30 -0300709 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
710 &dev->core->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300711 DVB_PLL_LG_TDVS_H06XF);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300712 }
Rusty Scottda215d22006-04-07 02:21:31 -0300713 }
714 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -0800715 case CX88_BOARD_ATI_HDTVWONDER:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300716 dev->dvb.frontend = dvb_attach(nxt200x_attach,
717 &ati_hdtvwonder,
718 &dev->core->i2c_adap);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300719 if (dev->dvb.frontend != NULL) {
Andrew de Quincey2bfe0312006-08-08 09:10:08 -0300720 dvb_attach(dvb_pll_attach, dev->dvb.frontend, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300721 NULL, DVB_PLL_TUV1236D);
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300722 }
Kirk Laprayfde6d312005-11-08 21:38:18 -0800723 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200724 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
725 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300726 dev->dvb.frontend = dvb_attach(cx24123_attach,
727 &hauppauge_novas_config,
728 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300729 if (dev->dvb.frontend) {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300730 dvb_attach(isl6421_attach, dev->dvb.frontend,
731 &dev->core->i2c_adap, 0x08, 0x00, 0x00);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300732 }
Steven Toth0fa14aa2006-01-09 15:25:02 -0200733 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200734 case CX88_BOARD_KWORLD_DVBS_100:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300735 dev->dvb.frontend = dvb_attach(cx24123_attach,
736 &kworld_dvbs_100_config,
737 &dev->core->i2c_adap);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300738 if (dev->dvb.frontend) {
Patrick Boettcherdea74862006-05-14 05:01:31 -0300739 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
740 dev->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300741 }
Vadim Catana0e0351e2006-01-09 15:25:02 -0200742 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300743 case CX88_BOARD_GENIATECH_DVBS:
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300744 dev->dvb.frontend = dvb_attach(cx24123_attach,
745 &geniatech_dvbs_config,
746 &dev->core->i2c_adap);
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300747 if (dev->dvb.frontend) {
748 dev->core->prev_set_voltage = dev->dvb.frontend->ops.set_voltage;
749 dev->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
750 }
751 break;
Steven Toth60464da2008-01-05 16:53:01 -0300752 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth60464da2008-01-05 16:53:01 -0300753 dev->dvb.frontend = dvb_attach(s5h1409_attach,
754 &pinnacle_pctv_hd_800i_config,
755 &dev->core->i2c_adap);
756 if (dev->dvb.frontend != NULL) {
757 /* tuner_config.video_dev must point to
758 * i2c_adap.algo_data
759 */
Steven Toth73c993a2008-01-05 17:08:05 -0300760 pinnacle_pctv_hd_800i_tuner_config.priv =
Steven Toth60464da2008-01-05 16:53:01 -0300761 dev->core->i2c_adap.algo_data;
762 dvb_attach(xc5000_attach, dev->dvb.frontend,
763 &dev->core->i2c_adap,
764 &pinnacle_pctv_hd_800i_tuner_config);
765 }
766 break;
Steven Toth5c00fac2008-04-22 14:45:14 -0300767 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
768 dev->dvb.frontend = dvb_attach(s5h1409_attach,
769 &dvico_hdtv5_pci_nano_config,
770 &dev->core->i2c_adap);
771 if (dev->dvb.frontend != NULL) {
772 struct dvb_frontend *fe;
773 struct xc2028_config cfg = {
774 .i2c_adap = &dev->core->i2c_adap,
775 .i2c_addr = 0x61,
776 .video_dev = dev->core,
777 .callback = cx88_xc3028_callback,
778 };
779 static struct xc2028_ctrl ctl = {
780 .fname = "xc3028-v27.fw",
781 .max_len = 64,
782 .scode_table = OREN538,
783 };
784
785 fe = dvb_attach(xc2028_attach,
786 dev->dvb.frontend, &cfg);
787 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
788 fe->ops.tuner_ops.set_config(fe, &ctl);
789 }
790 break;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300791 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
792 dev->dvb.frontend = dvb_attach(zl10353_attach,
793 &cx88_geniatech_x8000_mt,
794 &dev->core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300795 if (attach_xc3028(0x61, dev) < 0)
796 return -EINVAL;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300797 break;
798 case CX88_BOARD_GENIATECH_X8000_MT:
799 dev->ts_gen_cntrl = 0x00;
800
801 dev->dvb.frontend = dvb_attach(zl10353_attach,
802 &cx88_geniatech_x8000_mt,
803 &dev->core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300804 if (attach_xc3028(0x61, dev) < 0)
805 return -EINVAL;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300806 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 default:
Trent Piepho5772f812007-08-15 14:41:59 -0300808 printk(KERN_ERR "%s/2: The frontend of your DVB/ATSC card isn't supported yet\n",
Gerd Knorr1622c3f2005-05-01 08:59:19 -0700809 dev->core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 break;
811 }
812 if (NULL == dev->dvb.frontend) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300813 printk(KERN_ERR
814 "%s/2: frontend initialization failed\n",
815 dev->core->name);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300816 return -EINVAL;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300817 }
818
Steven Toth6c5be742006-12-02 21:15:51 -0200819 /* Ensure all frontends negotiate bus access */
820 dev->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821
Mauro Carvalho Chehab93352f5c2005-09-13 01:25:42 -0700822 /* Put the analog decoder in standby to keep it quiet */
823 cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL);
824
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 /* register everything */
Andrew de Quinceyd09dbf92006-04-10 09:27:37 -0300826 return videobuf_dvb_register(&dev->dvb, THIS_MODULE, dev, &dev->pci->dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827}
828
829/* ----------------------------------------------------------- */
830
Steven Toth6c5be742006-12-02 21:15:51 -0200831/* CX8802 MPEG -> mini driver - We have been given the hardware */
832static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833{
Steven Toth6c5be742006-12-02 21:15:51 -0200834 struct cx88_core *core = drv->core;
835 int err = 0;
836 dprintk( 1, "%s\n", __FUNCTION__);
837
Trent Piepho6a59d642007-08-15 14:41:57 -0300838 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -0200839 case CX88_BOARD_HAUPPAUGE_HVR1300:
840 /* We arrive here with either the cx23416 or the cx22702
841 * on the bus. Take the bus from the cx23416 and enable the
842 * cx22702 demod
843 */
844 cx_set(MO_GP0_IO, 0x00000080); /* cx22702 out of reset and enable */
845 cx_clear(MO_GP0_IO, 0x00000004);
846 udelay(1000);
847 break;
848 default:
849 err = -ENODEV;
850 }
851 return err;
852}
853
854/* CX8802 MPEG -> mini driver - We no longer have the hardware */
855static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
856{
857 struct cx88_core *core = drv->core;
858 int err = 0;
859 dprintk( 1, "%s\n", __FUNCTION__);
860
Trent Piepho6a59d642007-08-15 14:41:57 -0300861 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -0200862 case CX88_BOARD_HAUPPAUGE_HVR1300:
863 /* Do Nothing, leave the cx22702 on the bus. */
864 break;
865 default:
866 err = -ENODEV;
867 }
868 return err;
869}
870
871static int cx8802_dvb_probe(struct cx8802_driver *drv)
872{
873 struct cx88_core *core = drv->core;
874 struct cx8802_dev *dev = drv->core->dvbdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 int err;
876
Steven Toth6c5be742006-12-02 21:15:51 -0200877 dprintk( 1, "%s\n", __FUNCTION__);
878 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -0300879 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -0200880 core->name,
881 core->pci_bus,
882 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883
884 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -0300885 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 goto fail_core;
887
Trent Piephoecf854d2007-05-05 20:11:32 -0300888 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -0200889 err = vp3054_i2c_probe(dev);
890 if (0 != err)
Steven Toth6c5be742006-12-02 21:15:51 -0200891 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -0200892
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -0300894 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Guennadi Liakhovetski07051352008-04-22 14:42:13 -0300895 videobuf_queue_sg_init(&dev->dvb.dvbq, &dvb_qops,
896 &dev->pci->dev, &dev->slock,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 V4L2_BUF_TYPE_VIDEO_CAPTURE,
898 V4L2_FIELD_TOP,
899 sizeof(struct cx88_buffer),
900 dev);
901 err = dvb_register(dev);
Steven Toth6c5be742006-12-02 21:15:51 -0200902 if (err != 0)
Trent Piepho5772f812007-08-15 14:41:59 -0300903 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
904 core->name, err);
Steven Toth611900c2006-01-09 15:25:12 -0200905
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 return err;
908}
909
Steven Toth6c5be742006-12-02 21:15:51 -0200910static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911{
Steven Toth6c5be742006-12-02 21:15:51 -0200912 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -0200913
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 /* dvb */
915 videobuf_dvb_unregister(&dev->dvb);
916
Chris Pascoefc40b262006-01-09 15:25:35 -0200917 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -0200918
Steven Toth6c5be742006-12-02 21:15:51 -0200919 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920}
921
Steven Toth6c5be742006-12-02 21:15:51 -0200922static struct cx8802_driver cx8802_dvb_driver = {
923 .type_id = CX88_MPEG_DVB,
924 .hw_access = CX8802_DRVCTL_SHARED,
925 .probe = cx8802_dvb_probe,
926 .remove = cx8802_dvb_remove,
927 .advise_acquire = cx8802_dvb_advise_acquire,
928 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929};
930
931static int dvb_init(void)
932{
Trent Piepho5772f812007-08-15 14:41:59 -0300933 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 (CX88_VERSION_CODE >> 16) & 0xff,
935 (CX88_VERSION_CODE >> 8) & 0xff,
936 CX88_VERSION_CODE & 0xff);
937#ifdef SNAPSHOT
938 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
939 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
940#endif
Steven Toth6c5be742006-12-02 21:15:51 -0200941 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942}
943
944static void dvb_fini(void)
945{
Steven Toth6c5be742006-12-02 21:15:51 -0200946 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947}
948
949module_init(dvb_init);
950module_exit(dvb_fini);
951
952/*
953 * Local variables:
954 * c-basic-offset: 8
955 * compile-command: "make DVB=1"
956 * End:
957 */