blob: a037e925ceb976fbf906c38056ca305661475cbe [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines
5 *
Chris Pascoefc40b262006-01-09 15:25:35 -02006 * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/device.h>
27#include <linux/fs.h>
28#include <linux/kthread.h>
29#include <linux/file.h>
30#include <linux/suspend.h>
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "cx88.h"
33#include "dvb-pll.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020034#include <media/v4l2-common.h>
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070035
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030036#include "mt352.h"
37#include "mt352_priv.h"
Trent Piephoecf854d2007-05-05 20:11:32 -030038#include "cx88-vp3054-i2c.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030039#include "zl10353.h"
40#include "cx22702.h"
41#include "or51132.h"
42#include "lgdt330x.h"
Steven Toth60464da2008-01-05 16:53:01 -030043#include "s5h1409.h"
44#include "xc5000.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030045#include "nxt200x.h"
46#include "cx24123.h"
Andrew de Quinceycd20ca92006-05-12 20:31:51 -030047#include "isl6421.h"
Michael Krufky0df31f82008-04-22 14:46:13 -030048#include "tuner-simple.h"
Michael Krufky827855d2008-04-22 14:46:16 -030049#include "tda9887.h"
Steven Tothd893d5d2008-04-25 03:46:43 -030050#include "s5h1411.h"
Igor M. Liplianine4aab642008-09-23 15:43:57 -030051#include "stv0299.h"
52#include "z0194a.h"
53#include "stv0288.h"
54#include "stb6000.h"
Steven Toth5bd1b662008-09-04 01:17:33 -030055#include "cx24116.h"
Igor M. Liplianinb699c272009-11-16 22:22:32 -030056#include "stv0900.h"
57#include "stb6100.h"
58#include "stb6100_proc.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070059
60MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
61MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
62MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
63MODULE_LICENSE("GPL");
64
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030065static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070066module_param(debug, int, 0644);
67MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
68
Janne Grunau78e92002008-04-09 19:13:13 -030069DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
70
Linus Torvalds1da177e2005-04-16 15:20:36 -070071#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020072 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74/* ------------------------------------------------------------------ */
75
76static int dvb_buf_setup(struct videobuf_queue *q,
77 unsigned int *count, unsigned int *size)
78{
79 struct cx8802_dev *dev = q->priv_data;
80
81 dev->ts_packet_size = 188 * 4;
82 dev->ts_packet_count = 32;
83
84 *size = dev->ts_packet_size * dev->ts_packet_count;
85 *count = 32;
86 return 0;
87}
88
Michael Krufky4a390552006-12-05 02:00:53 -030089static int dvb_buf_prepare(struct videobuf_queue *q,
90 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070091{
92 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030093 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
95
96static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
97{
98 struct cx8802_dev *dev = q->priv_data;
99 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
100}
101
Michael Krufky4a390552006-12-05 02:00:53 -0300102static void dvb_buf_release(struct videobuf_queue *q,
103 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300105 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106}
107
lawrence rust2e4e98e2010-08-25 09:50:20 -0300108static const struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 .buf_setup = dvb_buf_setup,
110 .buf_prepare = dvb_buf_prepare,
111 .buf_queue = dvb_buf_queue,
112 .buf_release = dvb_buf_release,
113};
114
115/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300116
117static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
118{
119 struct cx8802_dev *dev= fe->dvb->priv;
120 struct cx8802_driver *drv = NULL;
121 int ret = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300122 int fe_id;
123
124 fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
125 if (!fe_id) {
Steven Toth2af03ee2008-10-16 20:17:31 -0300126 printk(KERN_ERR "%s() No frontend found\n", __func__);
Steven Toth363c35f2008-10-11 11:05:50 -0300127 return -EINVAL;
128 }
129
Michael Krufky22f3f172006-12-05 01:38:58 -0300130 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
131 if (drv) {
Steven Toth363c35f2008-10-11 11:05:50 -0300132 if (acquire){
133 dev->frontends.active_fe_id = fe_id;
Michael Krufky22f3f172006-12-05 01:38:58 -0300134 ret = drv->request_acquire(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300135 } else {
Michael Krufky22f3f172006-12-05 01:38:58 -0300136 ret = drv->request_release(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300137 dev->frontends.active_fe_id = 0;
138 }
Michael Krufky22f3f172006-12-05 01:38:58 -0300139 }
140
141 return ret;
142}
143
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300144static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
145{
146 struct videobuf_dvb_frontends *f;
147 struct videobuf_dvb_frontend *fe;
148
149 if (!core->dvbdev)
150 return;
151
152 f = &core->dvbdev->frontends;
153
154 if (!f)
155 return;
156
157 if (f->gate <= 1) /* undefined or fe0 */
158 fe = videobuf_dvb_get_frontend(f, 1);
159 else
160 fe = videobuf_dvb_get_frontend(f, f->gate);
161
162 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
163 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
164}
165
Michael Krufky22f3f172006-12-05 01:38:58 -0300166/* ------------------------------------------------------------------ */
167
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200168static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300170 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
171 static const u8 reset [] = { RESET, 0x80 };
172 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
173 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
174 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
175 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
177 mt352_write(fe, clock_config, sizeof(clock_config));
178 udelay(200);
179 mt352_write(fe, reset, sizeof(reset));
180 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
181
182 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
183 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
184 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
185 return 0;
186}
187
Chris Pascoe43eabb42006-01-09 18:21:28 -0200188static int dvico_dual_demod_init(struct dvb_frontend *fe)
189{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300190 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
191 static const u8 reset [] = { RESET, 0x80 };
192 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
193 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
194 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
195 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Chris Pascoe43eabb42006-01-09 18:21:28 -0200196
197 mt352_write(fe, clock_config, sizeof(clock_config));
198 udelay(200);
199 mt352_write(fe, reset, sizeof(reset));
200 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
201
202 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
203 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
204 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
205
206 return 0;
207}
208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
210{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300211 static const u8 clock_config [] = { 0x89, 0x38, 0x39 };
212 static const u8 reset [] = { 0x50, 0x80 };
213 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
214 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800215 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300216 static const u8 dntv_extra[] = { 0xB5, 0x7A };
217 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
219 mt352_write(fe, clock_config, sizeof(clock_config));
220 udelay(2000);
221 mt352_write(fe, reset, sizeof(reset));
222 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
223
224 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
225 udelay(2000);
226 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
227 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
228
229 return 0;
230}
231
lawrence rust2e4e98e2010-08-25 09:50:20 -0300232static const struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300233 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200234 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235};
236
lawrence rust2e4e98e2010-08-25 09:50:20 -0300237static const struct mt352_config dntv_live_dvbt_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 .demod_address = 0x0f,
239 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240};
Chris Pascoefc40b262006-01-09 15:25:35 -0200241
lawrence rust2e4e98e2010-08-25 09:50:20 -0300242static const struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300243 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200244 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200245};
246
lawrence rust2e4e98e2010-08-25 09:50:20 -0300247static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
Stephan Wienczny70101a22009-03-10 19:08:06 -0300248 .demod_address = (0x1e >> 1),
249 .no_tuner = 1,
250 .if2 = 45600,
251};
252
Trent Piephoecf854d2007-05-05 20:11:32 -0300253#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200254static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
255{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300256 static const u8 clock_config [] = { 0x89, 0x38, 0x38 };
257 static const u8 reset [] = { 0x50, 0x80 };
258 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
259 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200260 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300261 static const u8 dntv_extra[] = { 0xB5, 0x7A };
262 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200263
264 mt352_write(fe, clock_config, sizeof(clock_config));
265 udelay(2000);
266 mt352_write(fe, reset, sizeof(reset));
267 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
268
269 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
270 udelay(2000);
271 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
272 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
273
274 return 0;
275}
276
lawrence rust2e4e98e2010-08-25 09:50:20 -0300277static const struct mt352_config dntv_live_dvbt_pro_config = {
Chris Pascoefc40b262006-01-09 15:25:35 -0200278 .demod_address = 0x0f,
279 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200280 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200281};
282#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283
lawrence rust2e4e98e2010-08-25 09:50:20 -0300284static const struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300285 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300286 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300287};
288
lawrence rust2e4e98e2010-08-25 09:50:20 -0300289static const struct zl10353_config dvico_fusionhdtv_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300290 .demod_address = 0x0f,
291 .if2 = 45600,
292 .no_tuner = 1,
293};
294
lawrence rust2e4e98e2010-08-25 09:50:20 -0300295static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300296 .demod_address = 0x0f,
297 .if2 = 4560,
298 .no_tuner = 1,
299 .demod_init = dvico_fusionhdtv_demod_init,
300};
301
lawrence rust2e4e98e2010-08-25 09:50:20 -0300302static const struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300303 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300304};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300305
lawrence rust2e4e98e2010-08-25 09:50:20 -0300306static const struct cx22702_config connexant_refboard_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700308 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309};
310
lawrence rust2e4e98e2010-08-25 09:50:20 -0300311static const struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300312 .demod_address = 0x63,
313 .output_mode = CX22702_SERIAL_OUTPUT,
314};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315
Michael Krufky4a390552006-12-05 02:00:53 -0300316static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317{
318 struct cx8802_dev *dev= fe->dvb->priv;
319 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
320 return 0;
321}
322
lawrence rust2e4e98e2010-08-25 09:50:20 -0300323static const struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300324 .demod_address = 0x15,
325 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
Michael Krufky6ddcc912005-07-27 11:46:00 -0700328static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700329{
330 struct cx8802_dev *dev= fe->dvb->priv;
331 struct cx88_core *core = dev->core;
332
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300333 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700334 if (index == 0)
335 cx_clear(MO_GP0_IO, 8);
336 else
337 cx_set(MO_GP0_IO, 8);
338 return 0;
339}
340
Michael Krufky6ddcc912005-07-27 11:46:00 -0700341static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700342{
343 struct cx8802_dev *dev= fe->dvb->priv;
344 if (is_punctured)
345 dev->ts_gen_cntrl |= 0x04;
346 else
347 dev->ts_gen_cntrl &= ~0x04;
348 return 0;
349}
350
Michael Krufky6ddcc912005-07-27 11:46:00 -0700351static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300352 .demod_address = 0x0e,
353 .demod_chip = LGDT3302,
354 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
355 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700356};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700357
lawrence rust2e4e98e2010-08-25 09:50:20 -0300358static const struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300359 .demod_address = 0x0e,
360 .demod_chip = LGDT3303,
361 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
362 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700363};
Rusty Scottda215d22006-04-07 02:21:31 -0300364
lawrence rust2e4e98e2010-08-25 09:50:20 -0300365static const struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300366 .demod_address = 0x59,
367 .demod_chip = LGDT3303,
368 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
369 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300370};
Michael Krufkyf1798492005-07-07 17:58:39 -0700371
Michael Krufky4a390552006-12-05 02:00:53 -0300372static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800373{
374 struct cx8802_dev *dev= fe->dvb->priv;
375 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
376 return 0;
377}
378
lawrence rust2e4e98e2010-08-25 09:50:20 -0300379static const struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300380 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300381 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800382};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800383
Steven Toth0fa14aa2006-01-09 15:25:02 -0200384static int cx24123_set_ts_param(struct dvb_frontend* fe,
385 int is_punctured)
386{
387 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300388 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200389 return 0;
390}
391
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300392static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
393 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200394{
395 struct cx8802_dev *dev= fe->dvb->priv;
396 struct cx88_core *core = dev->core;
397
Michael Krufky4a390552006-12-05 02:00:53 -0300398 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300399 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300400 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300401 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300402
403 if (core->prev_set_voltage)
404 return core->prev_set_voltage(fe, voltage);
405 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200406}
407
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300408static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
409 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300410{
411 struct cx8802_dev *dev= fe->dvb->priv;
412 struct cx88_core *core = dev->core;
413
414 if (voltage == SEC_VOLTAGE_OFF) {
415 dprintk(1,"LNB Voltage OFF\n");
416 cx_write(MO_GP0_IO, 0x0000efff);
417 }
418
419 if (core->prev_set_voltage)
420 return core->prev_set_voltage(fe, voltage);
421 return 0;
422}
423
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300424static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
425 fe_sec_voltage_t voltage)
426{
427 struct cx8802_dev *dev= fe->dvb->priv;
428 struct cx88_core *core = dev->core;
429
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300430 cx_set(MO_GP0_IO, 0x6040);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300431 switch (voltage) {
432 case SEC_VOLTAGE_13:
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300433 cx_clear(MO_GP0_IO, 0x20);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300434 break;
435 case SEC_VOLTAGE_18:
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300436 cx_set(MO_GP0_IO, 0x20);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300437 break;
438 case SEC_VOLTAGE_OFF:
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300439 cx_clear(MO_GP0_IO, 0x20);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300440 break;
441 }
442
443 if (core->prev_set_voltage)
444 return core->prev_set_voltage(fe, voltage);
445 return 0;
446}
447
lawrence rust2e4e98e2010-08-25 09:50:20 -0300448static const struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300449 .demod_address = 0x55,
450 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300451};
452
lawrence rust2e4e98e2010-08-25 09:50:20 -0300453static const struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300454 .demod_address = 0x55,
455 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200456};
457
lawrence rust2e4e98e2010-08-25 09:50:20 -0300458static const struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300459 .demod_address = 0x15,
460 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300461 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200462};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200463
lawrence rust2e4e98e2010-08-25 09:50:20 -0300464static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300465 .demod_address = 0x32 >> 1,
466 .output_mode = S5H1409_PARALLEL_OUTPUT,
467 .gpio = S5H1409_GPIO_ON,
468 .qam_if = 44000,
469 .inversion = S5H1409_INVERSION_OFF,
470 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300471 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300472};
473
lawrence rust2e4e98e2010-08-25 09:50:20 -0300474static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
Steven Toth5c00fac2008-04-22 14:45:14 -0300475 .demod_address = 0x32 >> 1,
476 .output_mode = S5H1409_SERIAL_OUTPUT,
477 .gpio = S5H1409_GPIO_OFF,
478 .inversion = S5H1409_INVERSION_OFF,
479 .status_mode = S5H1409_DEMODLOCKING,
480 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
481};
482
lawrence rust2e4e98e2010-08-25 09:50:20 -0300483static const struct s5h1409_config kworld_atsc_120_config = {
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300484 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300485 .output_mode = S5H1409_SERIAL_OUTPUT,
486 .gpio = S5H1409_GPIO_OFF,
487 .inversion = S5H1409_INVERSION_OFF,
488 .status_mode = S5H1409_DEMODLOCKING,
489 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
490};
491
lawrence rust2e4e98e2010-08-25 09:50:20 -0300492static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300493 .i2c_address = 0x64,
494 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300495};
496
lawrence rust2e4e98e2010-08-25 09:50:20 -0300497static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
Stéphane Voltz3f6014f2008-09-05 14:33:54 -0300498 .demod_address = (0x1e >> 1),
499 .no_tuner = 1,
500 .if2 = 45600,
501};
502
lawrence rust2e4e98e2010-08-25 09:50:20 -0300503static const struct zl10353_config cx88_geniatech_x8000_mt = {
Mauro Carvalho Chehab57069342009-08-20 10:14:45 -0300504 .demod_address = (0x1e >> 1),
505 .no_tuner = 1,
506 .disable_i2c_gate_ctrl = 1,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300507};
508
lawrence rust2e4e98e2010-08-25 09:50:20 -0300509static const struct s5h1411_config dvico_fusionhdtv7_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300510 .output_mode = S5H1411_SERIAL_OUTPUT,
511 .gpio = S5H1411_GPIO_ON,
512 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
513 .qam_if = S5H1411_IF_44000,
514 .vsb_if = S5H1411_IF_44000,
515 .inversion = S5H1411_INVERSION_OFF,
516 .status_mode = S5H1411_DEMODLOCKING
517};
518
lawrence rust2e4e98e2010-08-25 09:50:20 -0300519static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300520 .i2c_address = 0xc2 >> 1,
521 .if_khz = 5380,
Steven Tothd893d5d2008-04-25 03:46:43 -0300522};
523
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300524static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
525{
526 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -0300527 struct videobuf_dvb_frontend *fe0 = NULL;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300528 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300529 struct xc2028_config cfg = {
530 .i2c_adap = &dev->core->i2c_adap,
531 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300532 .ctrl = &ctl,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300533 };
534
Darron Broad92abe9e2008-10-11 11:18:53 -0300535 /* Get the first frontend */
Steven Toth363c35f2008-10-11 11:05:50 -0300536 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
537 if (!fe0)
538 return -EINVAL;
539
540 if (!fe0->dvb.frontend) {
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300541 printk(KERN_ERR "%s/2: dvb frontend not attached. "
542 "Can't attach xc3028\n",
543 dev->core->name);
544 return -EINVAL;
545 }
546
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300547 /*
548 * Some xc3028 devices may be hidden by an I2C gate. This is known
549 * to happen with some s5h1409-based devices.
550 * Now that I2C gate is open, sets up xc3028 configuration
551 */
552 cx88_setup_xc3028(dev->core, &ctl);
553
Steven Toth363c35f2008-10-11 11:05:50 -0300554 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300555 if (!fe) {
556 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
557 dev->core->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300558 dvb_frontend_detach(fe0->dvb.frontend);
559 dvb_unregister_frontend(fe0->dvb.frontend);
560 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300561 return -EINVAL;
562 }
563
564 printk(KERN_INFO "%s/2: xc3028 attached\n",
565 dev->core->name);
566
567 return 0;
568}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300569
Steven Toth5bd1b662008-09-04 01:17:33 -0300570static int cx24116_set_ts_param(struct dvb_frontend *fe,
571 int is_punctured)
572{
573 struct cx8802_dev *dev = fe->dvb->priv;
574 dev->ts_gen_cntrl = 0x2;
575
576 return 0;
577}
578
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300579static int stv0900_set_ts_param(struct dvb_frontend *fe,
580 int is_punctured)
581{
582 struct cx8802_dev *dev = fe->dvb->priv;
583 dev->ts_gen_cntrl = 0;
584
585 return 0;
586}
587
Steven Toth5bd1b662008-09-04 01:17:33 -0300588static int cx24116_reset_device(struct dvb_frontend *fe)
589{
590 struct cx8802_dev *dev = fe->dvb->priv;
591 struct cx88_core *core = dev->core;
592
593 /* Reset the part */
Steven Toth363c35f2008-10-11 11:05:50 -0300594 /* Put the cx24116 into reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300595 cx_write(MO_SRST_IO, 0);
596 msleep(10);
Steven Toth363c35f2008-10-11 11:05:50 -0300597 /* Take the cx24116 out of reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300598 cx_write(MO_SRST_IO, 1);
599 msleep(10);
600
601 return 0;
602}
603
lawrence rust2e4e98e2010-08-25 09:50:20 -0300604static const struct cx24116_config hauppauge_hvr4000_config = {
Steven Toth5bd1b662008-09-04 01:17:33 -0300605 .demod_address = 0x05,
606 .set_ts_params = cx24116_set_ts_param,
607 .reset_device = cx24116_reset_device,
608};
609
lawrence rust2e4e98e2010-08-25 09:50:20 -0300610static const struct cx24116_config tevii_s460_config = {
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300611 .demod_address = 0x55,
612 .set_ts_params = cx24116_set_ts_param,
613 .reset_device = cx24116_reset_device,
614};
615
lawrence rust2e4e98e2010-08-25 09:50:20 -0300616static const struct stv0900_config prof_7301_stv0900_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300617 .demod_address = 0x6a,
618/* demod_mode = 0,*/
619 .xtal = 27000000,
620 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
621 .diseqc_mode = 2,/* 2/3 PWM */
622 .tun1_maddress = 0,/* 0x60 */
623 .tun1_adc = 0,/* 2 Vpp */
624 .path1_mode = 3,
625 .set_ts_params = stv0900_set_ts_param,
626};
627
lawrence rust2e4e98e2010-08-25 09:50:20 -0300628static const struct stb6100_config prof_7301_stb6100_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300629 .tuner_address = 0x60,
630 .refclock = 27000000,
631};
632
lawrence rust2e4e98e2010-08-25 09:50:20 -0300633static const struct stv0299_config tevii_tuner_sharp_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300634 .demod_address = 0x68,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300635 .inittab = sharp_z0194a_inittab,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300636 .mclk = 88000000UL,
637 .invert = 1,
638 .skip_reinit = 0,
639 .lock_output = 1,
640 .volt13_op0_op1 = STV0299_VOLT13_OP1,
641 .min_delay_ms = 100,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300642 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300643 .set_ts_params = cx24116_set_ts_param,
644};
645
lawrence rust2e4e98e2010-08-25 09:50:20 -0300646static const struct stv0288_config tevii_tuner_earda_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300647 .demod_address = 0x68,
648 .min_delay_ms = 100,
649 .set_ts_params = cx24116_set_ts_param,
650};
651
Andy Walls6e0e12f2009-01-11 21:18:04 -0300652static int cx8802_alloc_frontends(struct cx8802_dev *dev)
653{
654 struct cx88_core *core = dev->core;
655 struct videobuf_dvb_frontend *fe = NULL;
656 int i;
657
658 mutex_init(&dev->frontends.lock);
659 INIT_LIST_HEAD(&dev->frontends.felist);
660
661 if (!core->board.num_frontends)
662 return -ENODEV;
663
664 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
665 core->board.num_frontends);
666 for (i = 1; i <= core->board.num_frontends; i++) {
667 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
668 if (!fe) {
669 printk(KERN_ERR "%s() failed to alloc\n", __func__);
670 videobuf_dvb_dealloc_frontends(&dev->frontends);
671 return -ENOMEM;
672 }
673 }
674 return 0;
675}
676
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300677
678
lawrence rust2e4e98e2010-08-25 09:50:20 -0300679static const u8 samsung_smt_7020_inittab[] = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300680 0x01, 0x15,
681 0x02, 0x00,
682 0x03, 0x00,
683 0x04, 0x7D,
684 0x05, 0x0F,
685 0x06, 0x02,
686 0x07, 0x00,
687 0x08, 0x60,
688
689 0x0A, 0xC2,
690 0x0B, 0x00,
691 0x0C, 0x01,
692 0x0D, 0x81,
693 0x0E, 0x44,
694 0x0F, 0x09,
695 0x10, 0x3C,
696 0x11, 0x84,
697 0x12, 0xDA,
698 0x13, 0x99,
699 0x14, 0x8D,
700 0x15, 0xCE,
701 0x16, 0xE8,
702 0x17, 0x43,
703 0x18, 0x1C,
704 0x19, 0x1B,
705 0x1A, 0x1D,
706
707 0x1C, 0x12,
708 0x1D, 0x00,
709 0x1E, 0x00,
710 0x1F, 0x00,
711 0x20, 0x00,
712 0x21, 0x00,
713 0x22, 0x00,
714 0x23, 0x00,
715
716 0x28, 0x02,
717 0x29, 0x28,
718 0x2A, 0x14,
719 0x2B, 0x0F,
720 0x2C, 0x09,
721 0x2D, 0x05,
722
723 0x31, 0x1F,
724 0x32, 0x19,
725 0x33, 0xFC,
726 0x34, 0x13,
727 0xff, 0xff,
728};
729
730
731static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe,
732 struct dvb_frontend_parameters *params)
733{
734 struct cx8802_dev *dev = fe->dvb->priv;
735 u8 buf[4];
736 u32 div;
737 struct i2c_msg msg = {
738 .addr = 0x61,
739 .flags = 0,
740 .buf = buf,
741 .len = sizeof(buf) };
742
743 div = params->frequency / 125;
744
745 buf[0] = (div >> 8) & 0x7f;
746 buf[1] = div & 0xff;
747 buf[2] = 0x84; /* 0xC4 */
748 buf[3] = 0x00;
749
750 if (params->frequency < 1500000)
751 buf[3] |= 0x10;
752
753 if (fe->ops.i2c_gate_ctrl)
754 fe->ops.i2c_gate_ctrl(fe, 1);
755
756 if (i2c_transfer(&dev->core->i2c_adap, &msg, 1) != 1)
757 return -EIO;
758
759 return 0;
760}
761
762static int samsung_smt_7020_set_tone(struct dvb_frontend *fe,
763 fe_sec_tone_mode_t tone)
764{
765 struct cx8802_dev *dev = fe->dvb->priv;
766 struct cx88_core *core = dev->core;
767
768 cx_set(MO_GP0_IO, 0x0800);
769
770 switch (tone) {
771 case SEC_TONE_ON:
772 cx_set(MO_GP0_IO, 0x08);
773 break;
774 case SEC_TONE_OFF:
775 cx_clear(MO_GP0_IO, 0x08);
776 break;
777 default:
778 return -EINVAL;
779 }
780
781 return 0;
782}
783
784static int samsung_smt_7020_set_voltage(struct dvb_frontend *fe,
785 fe_sec_voltage_t voltage)
786{
787 struct cx8802_dev *dev = fe->dvb->priv;
788 struct cx88_core *core = dev->core;
789
790 u8 data;
791 struct i2c_msg msg = {
792 .addr = 8,
793 .flags = 0,
794 .buf = &data,
795 .len = sizeof(data) };
796
797 cx_set(MO_GP0_IO, 0x8000);
798
799 switch (voltage) {
800 case SEC_VOLTAGE_OFF:
801 break;
802 case SEC_VOLTAGE_13:
803 data = ISL6421_EN1 | ISL6421_LLC1;
804 cx_clear(MO_GP0_IO, 0x80);
805 break;
806 case SEC_VOLTAGE_18:
807 data = ISL6421_EN1 | ISL6421_LLC1 | ISL6421_VSEL1;
808 cx_clear(MO_GP0_IO, 0x80);
809 break;
810 default:
811 return -EINVAL;
812 };
813
814 return (i2c_transfer(&dev->core->i2c_adap, &msg, 1) == 1) ? 0 : -EIO;
815}
816
817static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
818 u32 srate, u32 ratio)
819{
820 u8 aclk = 0;
821 u8 bclk = 0;
822
823 if (srate < 1500000) {
824 aclk = 0xb7;
825 bclk = 0x47;
826 } else if (srate < 3000000) {
827 aclk = 0xb7;
828 bclk = 0x4b;
829 } else if (srate < 7000000) {
830 aclk = 0xb7;
831 bclk = 0x4f;
832 } else if (srate < 14000000) {
833 aclk = 0xb7;
834 bclk = 0x53;
835 } else if (srate < 30000000) {
836 aclk = 0xb6;
837 bclk = 0x53;
838 } else if (srate < 45000000) {
839 aclk = 0xb4;
840 bclk = 0x51;
841 }
842
843 stv0299_writereg(fe, 0x13, aclk);
844 stv0299_writereg(fe, 0x14, bclk);
845 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
846 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
847 stv0299_writereg(fe, 0x21, ratio & 0xf0);
848
849 return 0;
850}
851
852
lawrence rust2e4e98e2010-08-25 09:50:20 -0300853static const struct stv0299_config samsung_stv0299_config = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300854 .demod_address = 0x68,
855 .inittab = samsung_smt_7020_inittab,
856 .mclk = 88000000UL,
857 .invert = 0,
858 .skip_reinit = 0,
859 .lock_output = STV0299_LOCKOUTPUT_LK,
860 .volt13_op0_op1 = STV0299_VOLT13_OP1,
861 .min_delay_ms = 100,
862 .set_symbol_rate = samsung_smt_7020_stv0299_set_symbol_rate,
863};
864
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865static int dvb_register(struct cx8802_dev *dev)
866{
Steven Toth363c35f2008-10-11 11:05:50 -0300867 struct cx88_core *core = dev->core;
868 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
Darron Broad59b18422008-10-11 11:44:05 -0300869 int mfe_shared = 0; /* bus not shared by default */
Steven Toth363c35f2008-10-11 11:05:50 -0300870
Matthias Schwarzott0e8bac92008-10-24 10:47:07 -0300871 if (0 != core->i2c_rc) {
872 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
873 goto frontend_detach;
874 }
875
Steven Toth363c35f2008-10-11 11:05:50 -0300876 /* Get the first frontend */
877 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
878 if (!fe0)
Darron Broad60a5a922008-11-11 08:48:27 -0300879 goto frontend_detach;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880
Darron Broad8e739092008-10-11 11:31:41 -0300881 /* multi-frontend gate control is undefined or defaults to fe0 */
882 dev->frontends.gate = 0;
883
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300884 /* Sets the gate control callback to be used by i2c command calls */
885 core->gate_ctrl = cx88_dvb_gate_ctrl;
886
Darron Broad8e739092008-10-11 11:31:41 -0300887 /* init frontend(s) */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300888 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -0300890 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed3552602006-12-05 01:34:56 -0300891 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300892 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300893 if (fe0->dvb.frontend != NULL) {
894 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300895 0x61, &core->i2c_adap,
896 DVB_PLL_THOMSON_DTT759X))
897 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300898 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700900 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200902 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800903 case CX88_BOARD_WINFAST_DTV1000:
Steven Toth363c35f2008-10-11 11:05:50 -0300904 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300905 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300906 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300907 if (fe0->dvb.frontend != NULL) {
908 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300909 0x60, &core->i2c_adap,
910 DVB_PLL_THOMSON_DTT7579))
911 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300912 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300914 case CX88_BOARD_WINFAST_DTV2000H:
Vlastimil Labsky4d14c832009-08-10 22:15:54 -0300915 case CX88_BOARD_WINFAST_DTV2000H_J:
Steven Toth611900c2006-01-09 15:25:12 -0200916 case CX88_BOARD_HAUPPAUGE_HVR1100:
917 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300918 case CX88_BOARD_HAUPPAUGE_HVR1300:
Steven Toth363c35f2008-10-11 11:05:50 -0300919 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed3552602006-12-05 01:34:56 -0300920 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300921 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300922 if (fe0->dvb.frontend != NULL) {
923 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300924 &core->i2c_adap, 0x61,
925 TUNER_PHILIPS_FMD1216ME_MK3))
926 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300927 }
Steven Toth611900c2006-01-09 15:25:12 -0200928 break;
Steven Toth363c35f2008-10-11 11:05:50 -0300929 case CX88_BOARD_HAUPPAUGE_HVR3000:
Darron Broad60a5a922008-11-11 08:48:27 -0300930 /* MFE frontend 1 */
931 mfe_shared = 1;
932 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -0300933 /* DVB-S init */
934 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Darron Broad60a5a922008-11-11 08:48:27 -0300935 &hauppauge_novas_config,
936 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300937 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -0300938 if (!dvb_attach(isl6421_attach,
939 fe0->dvb.frontend,
940 &dev->core->i2c_adap,
941 0x08, ISL6421_DCL, 0x00))
942 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300943 }
Darron Broad60a5a922008-11-11 08:48:27 -0300944 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -0300945 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -0300946 if (!fe1)
947 goto frontend_detach;
948 /* DVB-T init */
949 fe1->dvb.frontend = dvb_attach(cx22702_attach,
950 &hauppauge_hvr_config,
951 &dev->core->i2c_adap);
952 if (fe1->dvb.frontend) {
953 fe1->dvb.frontend->id = 1;
954 if (!dvb_attach(simple_tuner_attach,
955 fe1->dvb.frontend,
956 &dev->core->i2c_adap,
957 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
958 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300959 }
960 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300961 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Steven Toth363c35f2008-10-11 11:05:50 -0300962 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300963 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300964 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300965 if (fe0->dvb.frontend != NULL) {
966 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300967 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
968 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300969 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300970 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300971 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -0300972 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300973 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300974 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300975 if (fe0->dvb.frontend != NULL) {
976 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300977 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
978 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300979 }
Chris Pascoe780dfef2006-02-28 08:34:59 -0300980 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300981 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300982 /* The tin box says DEE1601, but it seems to be DTT7579
983 * compatible, with a slightly different MT352 AGC gain. */
Steven Toth363c35f2008-10-11 11:05:50 -0300984 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300985 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300986 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300987 if (fe0->dvb.frontend != NULL) {
988 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300989 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
990 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300991 break;
992 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -0300993 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -0300994 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300995 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300996 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300997 if (fe0->dvb.frontend != NULL) {
998 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300999 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1000 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001001 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001002 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -03001004 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001005 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001006 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001007 if (fe0->dvb.frontend != NULL) {
1008 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001009 0x61, NULL, DVB_PLL_LG_Z201))
1010 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001011 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 case CX88_BOARD_KWORLD_DVB_T:
1014 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001015 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Steven Toth363c35f2008-10-11 11:05:50 -03001016 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001017 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001018 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001019 if (fe0->dvb.frontend != NULL) {
1020 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001021 0x61, NULL, DVB_PLL_UNKNOWN_1))
1022 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001023 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 break;
Chris Pascoefc40b262006-01-09 15:25:35 -02001025 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -03001026#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -03001027 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Steven Toth363c35f2008-10-11 11:05:50 -03001028 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -03001029 &dev->vp3054->adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001030 if (fe0->dvb.frontend != NULL) {
1031 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001032 &core->i2c_adap, 0x61,
1033 TUNER_PHILIPS_FMD1216ME_MK3))
1034 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001035 }
Chris Pascoefc40b262006-01-09 15:25:35 -02001036#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001037 printk(KERN_ERR "%s/2: built without vp3054 support\n",
1038 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -02001039#endif
1040 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001041 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001042 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001043 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001044 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001045 if (fe0->dvb.frontend != NULL) {
1046 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001047 &core->i2c_adap, 0x61,
1048 TUNER_THOMSON_FE6600))
1049 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001050 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001051 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001052 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
Steven Toth363c35f2008-10-11 11:05:50 -03001053 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001054 &dvico_fusionhdtv_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001055 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001056 if (fe0->dvb.frontend == NULL)
1057 fe0->dvb.frontend = dvb_attach(mt352_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001058 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001059 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -03001060 /*
1061 * On this board, the demod provides the I2C bus pullup.
1062 * We must not permit gate_ctrl to be performed, or
1063 * the xc3028 cannot communicate on the bus.
1064 */
Steven Toth363c35f2008-10-11 11:05:50 -03001065 if (fe0->dvb.frontend)
1066 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001067 if (attach_xc3028(0x61, dev) < 0)
Darron Broadbecd4302008-10-21 11:47:50 -03001068 goto frontend_detach;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001069 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 case CX88_BOARD_PCHDTV_HD3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001071 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001072 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001073 if (fe0->dvb.frontend != NULL) {
1074 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001075 &core->i2c_adap, 0x61,
1076 TUNER_THOMSON_DTT761X))
1077 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001078 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079 break;
Michael Krufkyf1798492005-07-07 17:58:39 -07001080 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
1081 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -07001082
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001083 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -07001084 cx_clear(MO_GP0_IO, 1);
1085 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001086 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -07001087 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001088
1089 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -07001090 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Steven Toth363c35f2008-10-11 11:05:50 -03001091 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001092 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001093 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001094 if (fe0->dvb.frontend != NULL) {
1095 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001096 &core->i2c_adap, 0x61,
1097 TUNER_MICROTUNE_4042FI5))
1098 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -07001099 }
1100 break;
Michael Krufky0d723c02005-07-07 17:58:42 -07001101 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
1102 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -07001103
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001104 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -07001105 cx_clear(MO_GP0_IO, 1);
1106 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -07001107 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -07001108 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001109 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001110 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001111 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001112 if (fe0->dvb.frontend != NULL) {
1113 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001114 &core->i2c_adap, 0x61,
1115 TUNER_THOMSON_DTT761X))
1116 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -07001117 }
1118 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001119 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
1120 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001121
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001122 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001123 cx_clear(MO_GP0_IO, 1);
1124 mdelay(100);
1125 cx_set(MO_GP0_IO, 1);
1126 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001127 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001128 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001129 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001130 if (fe0->dvb.frontend != NULL) {
1131 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001132 &core->i2c_adap, 0x61,
1133 TUNER_LG_TDVS_H06XF))
1134 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001135 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001136 &core->i2c_adap, 0x43))
1137 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001138 }
1139 break;
Rusty Scottda215d22006-04-07 02:21:31 -03001140 case CX88_BOARD_PCHDTV_HD5500:
1141 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -03001142
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001143 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -03001144 cx_clear(MO_GP0_IO, 1);
1145 mdelay(100);
1146 cx_set(MO_GP0_IO, 1);
1147 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001148 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001149 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001150 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001151 if (fe0->dvb.frontend != NULL) {
1152 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001153 &core->i2c_adap, 0x61,
1154 TUNER_LG_TDVS_H06XF))
1155 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001156 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001157 &core->i2c_adap, 0x43))
1158 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -03001159 }
1160 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -08001161 case CX88_BOARD_ATI_HDTVWONDER:
Steven Toth363c35f2008-10-11 11:05:50 -03001162 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001163 &ati_hdtvwonder,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001164 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001165 if (fe0->dvb.frontend != NULL) {
1166 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001167 &core->i2c_adap, 0x61,
1168 TUNER_PHILIPS_TUV1236D))
1169 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001170 }
Kirk Laprayfde6d312005-11-08 21:38:18 -08001171 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -02001172 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
1173 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Steven Toth363c35f2008-10-11 11:05:50 -03001174 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001175 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001176 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001177 if (fe0->dvb.frontend) {
1178 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
Steven Toth83fe92e2008-09-13 19:22:15 -03001179 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001180 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001181 }
Steven Toth0fa14aa2006-01-09 15:25:02 -02001182 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -02001183 case CX88_BOARD_KWORLD_DVBS_100:
Steven Toth363c35f2008-10-11 11:05:50 -03001184 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001185 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001186 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001187 if (fe0->dvb.frontend) {
1188 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1189 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001190 }
Vadim Catana0e0351e2006-01-09 15:25:02 -02001191 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001192 case CX88_BOARD_GENIATECH_DVBS:
Steven Toth363c35f2008-10-11 11:05:50 -03001193 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001194 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001195 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001196 if (fe0->dvb.frontend) {
1197 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1198 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001199 }
1200 break;
Steven Toth60464da2008-01-05 16:53:01 -03001201 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth363c35f2008-10-11 11:05:50 -03001202 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth60464da2008-01-05 16:53:01 -03001203 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001204 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001205 if (fe0->dvb.frontend != NULL) {
1206 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001207 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001208 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001209 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -03001210 }
1211 break;
Steven Toth5c00fac2008-04-22 14:45:14 -03001212 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
Steven Toth363c35f2008-10-11 11:05:50 -03001213 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth5c00fac2008-04-22 14:45:14 -03001214 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001215 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001216 if (fe0->dvb.frontend != NULL) {
Steven Toth5c00fac2008-04-22 14:45:14 -03001217 struct dvb_frontend *fe;
1218 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001219 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -03001220 .i2c_addr = 0x61,
Steven Toth5c00fac2008-04-22 14:45:14 -03001221 };
1222 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001223 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -03001224 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -03001225 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -03001226 };
1227
1228 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001229 fe0->dvb.frontend, &cfg);
Steven Toth5c00fac2008-04-22 14:45:14 -03001230 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1231 fe->ops.tuner_ops.set_config(fe, &ctl);
1232 }
1233 break;
Ricardo Maraschinid49f7a22010-04-06 02:40:43 -03001234 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
Miroslav Sustek3047a172009-05-31 16:47:28 -03001235 case CX88_BOARD_WINFAST_DTV1800H:
Steven Toth363c35f2008-10-11 11:05:50 -03001236 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001237 &cx88_pinnacle_hybrid_pctv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001238 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001239 if (fe0->dvb.frontend) {
1240 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001241 if (attach_xc3028(0x61, dev) < 0)
1242 goto frontend_detach;
1243 }
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001244 break;
1245 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001246 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001247
Steven Toth363c35f2008-10-11 11:05:50 -03001248 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001249 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001250 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001251 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001252 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001253 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001254 case CX88_BOARD_KWORLD_ATSC_120:
Steven Toth363c35f2008-10-11 11:05:50 -03001255 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001256 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001257 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001258 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001259 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001260 break;
Steven Tothd893d5d2008-04-25 03:46:43 -03001261 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
Steven Toth363c35f2008-10-11 11:05:50 -03001262 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Steven Tothd893d5d2008-04-25 03:46:43 -03001263 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001264 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001265 if (fe0->dvb.frontend != NULL) {
1266 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001267 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001268 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001269 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -03001270 }
1271 break;
Steven Toth5bd1b662008-09-04 01:17:33 -03001272 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad60a5a922008-11-11 08:48:27 -03001273 /* MFE frontend 1 */
1274 mfe_shared = 1;
1275 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001276 /* DVB-S/S2 Init */
1277 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001278 &hauppauge_hvr4000_config,
1279 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001280 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001281 if (!dvb_attach(isl6421_attach,
1282 fe0->dvb.frontend,
1283 &dev->core->i2c_adap,
1284 0x08, ISL6421_DCL, 0x00))
1285 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001286 }
Darron Broad60a5a922008-11-11 08:48:27 -03001287 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001288 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001289 if (!fe1)
1290 goto frontend_detach;
1291 /* DVB-T Init */
1292 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1293 &hauppauge_hvr_config,
1294 &dev->core->i2c_adap);
1295 if (fe1->dvb.frontend) {
1296 fe1->dvb.frontend->id = 1;
1297 if (!dvb_attach(simple_tuner_attach,
1298 fe1->dvb.frontend,
1299 &dev->core->i2c_adap,
1300 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1301 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001302 }
1303 break;
1304 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1305 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001306 &hauppauge_hvr4000_config,
1307 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001308 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001309 if (!dvb_attach(isl6421_attach,
1310 fe0->dvb.frontend,
1311 &dev->core->i2c_adap,
1312 0x08, ISL6421_DCL, 0x00))
1313 goto frontend_detach;
Steven Toth5bd1b662008-09-04 01:17:33 -03001314 }
1315 break;
Igor M. Liplianincd3cde12008-11-09 15:26:25 -03001316 case CX88_BOARD_PROF_6200:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001317 case CX88_BOARD_TBS_8910:
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001318 case CX88_BOARD_TEVII_S420:
Steven Toth363c35f2008-10-11 11:05:50 -03001319 fe0->dvb.frontend = dvb_attach(stv0299_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001320 &tevii_tuner_sharp_config,
1321 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001322 if (fe0->dvb.frontend != NULL) {
1323 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001324 &core->i2c_adap, DVB_PLL_OPERA1))
1325 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001326 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1327 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001328
1329 } else {
Steven Toth363c35f2008-10-11 11:05:50 -03001330 fe0->dvb.frontend = dvb_attach(stv0288_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001331 &tevii_tuner_earda_config,
1332 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001333 if (fe0->dvb.frontend != NULL) {
1334 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001335 &core->i2c_adap))
1336 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001337 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1338 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001339 }
1340 }
1341 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001342 case CX88_BOARD_TEVII_S460:
Steven Toth363c35f2008-10-11 11:05:50 -03001343 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001344 &tevii_s460_config,
1345 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001346 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001347 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001348 break;
Oleg Roitburd4cd7fb82008-09-17 11:30:21 -03001349 case CX88_BOARD_OMICOM_SS4_PCI:
Oleg Roitburdee730422008-09-17 11:58:33 -03001350 case CX88_BOARD_TBS_8920:
Oleg Roitburd57f51db2008-10-08 06:48:08 -03001351 case CX88_BOARD_PROF_7300:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001352 case CX88_BOARD_SATTRADE_ST4200:
Steven Toth363c35f2008-10-11 11:05:50 -03001353 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Oleg Roitburdee730422008-09-17 11:58:33 -03001354 &hauppauge_hvr4000_config,
1355 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001356 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001357 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Oleg Roitburdee730422008-09-17 11:58:33 -03001358 break;
Stephan Wienczny70101a22009-03-10 19:08:06 -03001359 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
1360 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1361 &cx88_terratec_cinergy_ht_pci_mkii_config,
1362 &core->i2c_adap);
1363 if (fe0->dvb.frontend) {
1364 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1365 if (attach_xc3028(0x61, dev) < 0)
1366 goto frontend_detach;
1367 }
1368 break;
Igor M. Liplianinb699c272009-11-16 22:22:32 -03001369 case CX88_BOARD_PROF_7301:{
1370 struct dvb_tuner_ops *tuner_ops = NULL;
1371
1372 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1373 &prof_7301_stv0900_config,
1374 &core->i2c_adap, 0);
1375 if (fe0->dvb.frontend != NULL) {
1376 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1377 &prof_7301_stb6100_config,
1378 &core->i2c_adap))
1379 goto frontend_detach;
1380
1381 tuner_ops = &fe0->dvb.frontend->ops.tuner_ops;
1382 tuner_ops->set_frequency = stb6100_set_freq;
1383 tuner_ops->get_frequency = stb6100_get_freq;
1384 tuner_ops->set_bandwidth = stb6100_set_bandw;
1385 tuner_ops->get_bandwidth = stb6100_get_bandw;
1386
1387 core->prev_set_voltage =
1388 fe0->dvb.frontend->ops.set_voltage;
1389 fe0->dvb.frontend->ops.set_voltage =
1390 tevii_dvbs_set_voltage;
1391 }
1392 break;
1393 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001394 case CX88_BOARD_SAMSUNG_SMT_7020:
1395 dev->ts_gen_cntrl = 0x08;
1396
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001397 cx_set(MO_GP0_IO, 0x0101);
1398
1399 cx_clear(MO_GP0_IO, 0x01);
1400 mdelay(100);
1401 cx_set(MO_GP0_IO, 0x01);
1402 mdelay(200);
1403
1404 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1405 &samsung_stv0299_config,
1406 &dev->core->i2c_adap);
1407 if (fe0->dvb.frontend) {
1408 fe0->dvb.frontend->ops.tuner_ops.set_params =
1409 samsung_smt_7020_tuner_set_params;
1410 fe0->dvb.frontend->tuner_priv =
1411 &dev->core->i2c_adap;
1412 fe0->dvb.frontend->ops.set_voltage =
1413 samsung_smt_7020_set_voltage;
1414 fe0->dvb.frontend->ops.set_tone =
1415 samsung_smt_7020_set_tone;
1416 }
1417
1418 break;
1419
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420 default:
Trent Piepho5772f812007-08-15 14:41:59 -03001421 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 -03001422 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 break;
1424 }
Steven Toth363c35f2008-10-11 11:05:50 -03001425
Mauro Carvalho Chehab2c9bcea2008-11-10 23:35:00 -02001426 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001427 printk(KERN_ERR
1428 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001429 core->name);
Darron Broad60a5a922008-11-11 08:48:27 -03001430 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001431 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001432 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001433 fe0->dvb.frontend->callback = cx88_tuner_callback;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001434
Steven Toth6c5be742006-12-02 21:15:51 -02001435 /* Ensure all frontends negotiate bus access */
Steven Toth363c35f2008-10-11 11:05:50 -03001436 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1437 if (fe1)
1438 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001440 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001441 call_all(core, core, s_power, 0);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001442
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443 /* register everything */
Steven Toth363c35f2008-10-11 11:05:50 -03001444 return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001445 &dev->pci->dev, adapter_nr, mfe_shared, NULL);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001446
1447frontend_detach:
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001448 core->gate_ctrl = NULL;
Darron Broadbecd4302008-10-21 11:47:50 -03001449 videobuf_dvb_dealloc_frontends(&dev->frontends);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001450 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451}
1452
1453/* ----------------------------------------------------------- */
1454
Steven Toth6c5be742006-12-02 21:15:51 -02001455/* CX8802 MPEG -> mini driver - We have been given the hardware */
1456static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457{
Steven Toth6c5be742006-12-02 21:15:51 -02001458 struct cx88_core *core = drv->core;
1459 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001460 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001461
Trent Piepho6a59d642007-08-15 14:41:57 -03001462 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001463 case CX88_BOARD_HAUPPAUGE_HVR1300:
1464 /* We arrive here with either the cx23416 or the cx22702
1465 * on the bus. Take the bus from the cx23416 and enable the
1466 * cx22702 demod
1467 */
Darron Broad79392732008-12-18 06:28:35 -03001468 /* Toggle reset on cx22702 leaving i2c active */
1469 cx_set(MO_GP0_IO, 0x00000080);
1470 udelay(1000);
1471 cx_clear(MO_GP0_IO, 0x00000080);
1472 udelay(50);
1473 cx_set(MO_GP0_IO, 0x00000080);
1474 udelay(1000);
1475 /* enable the cx22702 pins */
Steven Toth6c5be742006-12-02 21:15:51 -02001476 cx_clear(MO_GP0_IO, 0x00000004);
1477 udelay(1000);
1478 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001479
Darron Broad92abe9e2008-10-11 11:18:53 -03001480 case CX88_BOARD_HAUPPAUGE_HVR3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001481 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad79392732008-12-18 06:28:35 -03001482 /* Toggle reset on cx22702 leaving i2c active */
1483 cx_set(MO_GP0_IO, 0x00000080);
1484 udelay(1000);
1485 cx_clear(MO_GP0_IO, 0x00000080);
1486 udelay(50);
1487 cx_set(MO_GP0_IO, 0x00000080);
1488 udelay(1000);
1489 switch (core->dvbdev->frontends.active_fe_id) {
1490 case 1: /* DVB-S/S2 Enabled */
1491 /* tri-state the cx22702 pins */
1492 cx_set(MO_GP0_IO, 0x00000004);
1493 /* Take the cx24116/cx24123 out of reset */
1494 cx_write(MO_SRST_IO, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001495 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
Darron Broad79392732008-12-18 06:28:35 -03001496 break;
1497 case 2: /* DVB-T Enabled */
Steven Toth363c35f2008-10-11 11:05:50 -03001498 /* Put the cx24116/cx24123 into reset */
1499 cx_write(MO_SRST_IO, 0);
Darron Broad79392732008-12-18 06:28:35 -03001500 /* enable the cx22702 pins */
Steven Toth363c35f2008-10-11 11:05:50 -03001501 cx_clear(MO_GP0_IO, 0x00000004);
1502 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
Darron Broad79392732008-12-18 06:28:35 -03001503 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001504 }
Darron Broad79392732008-12-18 06:28:35 -03001505 udelay(1000);
Steven Toth363c35f2008-10-11 11:05:50 -03001506 break;
1507
Steven Toth6c5be742006-12-02 21:15:51 -02001508 default:
1509 err = -ENODEV;
1510 }
1511 return err;
1512}
1513
1514/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1515static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1516{
1517 struct cx88_core *core = drv->core;
1518 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001519 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001520
Trent Piepho6a59d642007-08-15 14:41:57 -03001521 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001522 case CX88_BOARD_HAUPPAUGE_HVR1300:
1523 /* Do Nothing, leave the cx22702 on the bus. */
1524 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001525 case CX88_BOARD_HAUPPAUGE_HVR3000:
1526 case CX88_BOARD_HAUPPAUGE_HVR4000:
1527 break;
Steven Toth6c5be742006-12-02 21:15:51 -02001528 default:
1529 err = -ENODEV;
1530 }
1531 return err;
1532}
1533
1534static int cx8802_dvb_probe(struct cx8802_driver *drv)
1535{
1536 struct cx88_core *core = drv->core;
1537 struct cx8802_dev *dev = drv->core->dvbdev;
Darron Broadcbd82442008-10-30 05:07:44 -03001538 int err;
Andy Walls6e0e12f2009-01-11 21:18:04 -03001539 struct videobuf_dvb_frontend *fe;
1540 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001541
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001542 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001543 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001544 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001545 core->name,
1546 core->pci_bus,
1547 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548
1549 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001550 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551 goto fail_core;
1552
Trent Piephoecf854d2007-05-05 20:11:32 -03001553 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001554 err = vp3054_i2c_probe(dev);
1555 if (0 != err)
Andy Walls6e0e12f2009-01-11 21:18:04 -03001556 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001557
Linus Torvalds1da177e2005-04-16 15:20:36 -07001558 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001559 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Steven Toth363c35f2008-10-11 11:05:50 -03001560 dev->ts_gen_cntrl = 0x0c;
1561
Andy Walls6e0e12f2009-01-11 21:18:04 -03001562 err = cx8802_alloc_frontends(dev);
1563 if (err)
1564 goto fail_core;
Darron Broadcbd82442008-10-30 05:07:44 -03001565
Andy Walls6e0e12f2009-01-11 21:18:04 -03001566 err = -ENODEV;
1567 for (i = 1; i <= core->board.num_frontends; i++) {
1568 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1569 if (fe == NULL) {
1570 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
Darron Broadcbd82442008-10-30 05:07:44 -03001571 __func__, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001572 goto fail_probe;
1573 }
1574 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
Darron Broadcbd82442008-10-30 05:07:44 -03001575 &dev->pci->dev, &dev->slock,
1576 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1577 V4L2_FIELD_TOP,
1578 sizeof(struct cx88_buffer),
Hans Verkuil08bff032010-09-20 17:39:46 -03001579 dev, NULL);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001580 /* init struct videobuf_dvb */
1581 fe->dvb.name = dev->core->name;
Steven Toth363c35f2008-10-11 11:05:50 -03001582 }
Andy Walls6e0e12f2009-01-11 21:18:04 -03001583
Linus Torvalds1da177e2005-04-16 15:20:36 -07001584 err = dvb_register(dev);
Darron Broadcbd82442008-10-30 05:07:44 -03001585 if (err)
1586 /* frontends/adapter de-allocated in dvb_register */
Trent Piepho5772f812007-08-15 14:41:59 -03001587 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1588 core->name, err);
Darron Broadcbd82442008-10-30 05:07:44 -03001589 return err;
1590fail_probe:
1591 videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
Darron Broad92abe9e2008-10-11 11:18:53 -03001592fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001593 return err;
1594}
1595
Steven Toth6c5be742006-12-02 21:15:51 -02001596static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001597{
Darron Broad0fcd4882008-10-21 11:18:47 -03001598 struct cx88_core *core = drv->core;
Steven Toth6c5be742006-12-02 21:15:51 -02001599 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001600
Darron Broad0fcd4882008-10-21 11:18:47 -03001601 dprintk( 1, "%s\n", __func__);
1602
Steven Toth363c35f2008-10-11 11:05:50 -03001603 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604
Chris Pascoefc40b262006-01-09 15:25:35 -02001605 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001606
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001607 core->gate_ctrl = NULL;
1608
Steven Toth6c5be742006-12-02 21:15:51 -02001609 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001610}
1611
Steven Toth6c5be742006-12-02 21:15:51 -02001612static struct cx8802_driver cx8802_dvb_driver = {
1613 .type_id = CX88_MPEG_DVB,
1614 .hw_access = CX8802_DRVCTL_SHARED,
1615 .probe = cx8802_dvb_probe,
1616 .remove = cx8802_dvb_remove,
1617 .advise_acquire = cx8802_dvb_advise_acquire,
1618 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619};
1620
Peter Huewe31d0f842009-07-17 01:00:01 +02001621static int __init dvb_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622{
Trent Piepho5772f812007-08-15 14:41:59 -03001623 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624 (CX88_VERSION_CODE >> 16) & 0xff,
1625 (CX88_VERSION_CODE >> 8) & 0xff,
1626 CX88_VERSION_CODE & 0xff);
1627#ifdef SNAPSHOT
1628 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1629 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1630#endif
Steven Toth6c5be742006-12-02 21:15:51 -02001631 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001632}
1633
Peter Huewe31d0f842009-07-17 01:00:01 +02001634static void __exit dvb_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001635{
Steven Toth6c5be742006-12-02 21:15:51 -02001636 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637}
1638
1639module_init(dvb_init);
1640module_exit(dvb_fini);
1641
1642/*
1643 * Local variables:
1644 * c-basic-offset: 8
1645 * compile-command: "make DVB=1"
1646 * End:
1647 */