blob: 90717ee944ec5632e62ae2d3462f7987718671db [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"
Sergey Ivanov111ac842010-08-09 10:18:32 -030059#include "mb86a16.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
62MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
63MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
64MODULE_LICENSE("GPL");
65
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030066static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067module_param(debug, int, 0644);
68MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
69
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030070static unsigned int dvb_buf_tscnt = 32;
71module_param(dvb_buf_tscnt, int, 0644);
72MODULE_PARM_DESC(dvb_buf_tscnt, "DVB Buffer TS count [dvb]");
73
Janne Grunau78e92002008-04-09 19:13:13 -030074DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020077 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79/* ------------------------------------------------------------------ */
80
81static int dvb_buf_setup(struct videobuf_queue *q,
82 unsigned int *count, unsigned int *size)
83{
84 struct cx8802_dev *dev = q->priv_data;
85
86 dev->ts_packet_size = 188 * 4;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030087 dev->ts_packet_count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
89 *size = dev->ts_packet_size * dev->ts_packet_count;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030090 *count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 return 0;
92}
93
Michael Krufky4a390552006-12-05 02:00:53 -030094static int dvb_buf_prepare(struct videobuf_queue *q,
95 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070096{
97 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030098 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}
100
101static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
102{
103 struct cx8802_dev *dev = q->priv_data;
104 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
105}
106
Michael Krufky4a390552006-12-05 02:00:53 -0300107static void dvb_buf_release(struct videobuf_queue *q,
108 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300110 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111}
112
lawrence rust2e4e98e2010-08-25 09:50:20 -0300113static const struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114 .buf_setup = dvb_buf_setup,
115 .buf_prepare = dvb_buf_prepare,
116 .buf_queue = dvb_buf_queue,
117 .buf_release = dvb_buf_release,
118};
119
120/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300121
122static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
123{
124 struct cx8802_dev *dev= fe->dvb->priv;
125 struct cx8802_driver *drv = NULL;
126 int ret = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300127 int fe_id;
128
129 fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
130 if (!fe_id) {
Steven Toth2af03ee2008-10-16 20:17:31 -0300131 printk(KERN_ERR "%s() No frontend found\n", __func__);
Steven Toth363c35f2008-10-11 11:05:50 -0300132 return -EINVAL;
133 }
134
Michael Krufky22f3f172006-12-05 01:38:58 -0300135 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
136 if (drv) {
Steven Toth363c35f2008-10-11 11:05:50 -0300137 if (acquire){
138 dev->frontends.active_fe_id = fe_id;
Michael Krufky22f3f172006-12-05 01:38:58 -0300139 ret = drv->request_acquire(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300140 } else {
Michael Krufky22f3f172006-12-05 01:38:58 -0300141 ret = drv->request_release(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300142 dev->frontends.active_fe_id = 0;
143 }
Michael Krufky22f3f172006-12-05 01:38:58 -0300144 }
145
146 return ret;
147}
148
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300149static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
150{
151 struct videobuf_dvb_frontends *f;
152 struct videobuf_dvb_frontend *fe;
153
154 if (!core->dvbdev)
155 return;
156
157 f = &core->dvbdev->frontends;
158
159 if (!f)
160 return;
161
162 if (f->gate <= 1) /* undefined or fe0 */
163 fe = videobuf_dvb_get_frontend(f, 1);
164 else
165 fe = videobuf_dvb_get_frontend(f, f->gate);
166
167 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
168 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
169}
170
Michael Krufky22f3f172006-12-05 01:38:58 -0300171/* ------------------------------------------------------------------ */
172
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200173static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300175 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
176 static const u8 reset [] = { RESET, 0x80 };
177 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
178 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
179 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
180 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
182 mt352_write(fe, clock_config, sizeof(clock_config));
183 udelay(200);
184 mt352_write(fe, reset, sizeof(reset));
185 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
186
187 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
188 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
189 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
190 return 0;
191}
192
Chris Pascoe43eabb42006-01-09 18:21:28 -0200193static int dvico_dual_demod_init(struct dvb_frontend *fe)
194{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300195 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
196 static const u8 reset [] = { RESET, 0x80 };
197 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
198 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
199 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
200 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Chris Pascoe43eabb42006-01-09 18:21:28 -0200201
202 mt352_write(fe, clock_config, sizeof(clock_config));
203 udelay(200);
204 mt352_write(fe, reset, sizeof(reset));
205 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
206
207 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
208 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
209 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
210
211 return 0;
212}
213
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
215{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300216 static const u8 clock_config [] = { 0x89, 0x38, 0x39 };
217 static const u8 reset [] = { 0x50, 0x80 };
218 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
219 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800220 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300221 static const u8 dntv_extra[] = { 0xB5, 0x7A };
222 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
224 mt352_write(fe, clock_config, sizeof(clock_config));
225 udelay(2000);
226 mt352_write(fe, reset, sizeof(reset));
227 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
228
229 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
230 udelay(2000);
231 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
232 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
233
234 return 0;
235}
236
lawrence rust2e4e98e2010-08-25 09:50:20 -0300237static const struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300238 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200239 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240};
241
lawrence rust2e4e98e2010-08-25 09:50:20 -0300242static const struct mt352_config dntv_live_dvbt_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 .demod_address = 0x0f,
244 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245};
Chris Pascoefc40b262006-01-09 15:25:35 -0200246
lawrence rust2e4e98e2010-08-25 09:50:20 -0300247static const struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300248 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200249 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200250};
251
lawrence rust2e4e98e2010-08-25 09:50:20 -0300252static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
Stephan Wienczny70101a22009-03-10 19:08:06 -0300253 .demod_address = (0x1e >> 1),
254 .no_tuner = 1,
255 .if2 = 45600,
256};
257
Sergey Ivanov111ac842010-08-09 10:18:32 -0300258static struct mb86a16_config twinhan_vp1027 = {
259 .demod_address = 0x08,
260};
261
Trent Piephoecf854d2007-05-05 20:11:32 -0300262#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200263static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
264{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300265 static const u8 clock_config [] = { 0x89, 0x38, 0x38 };
266 static const u8 reset [] = { 0x50, 0x80 };
267 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
268 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200269 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300270 static const u8 dntv_extra[] = { 0xB5, 0x7A };
271 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200272
273 mt352_write(fe, clock_config, sizeof(clock_config));
274 udelay(2000);
275 mt352_write(fe, reset, sizeof(reset));
276 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
277
278 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
279 udelay(2000);
280 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
281 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
282
283 return 0;
284}
285
lawrence rust2e4e98e2010-08-25 09:50:20 -0300286static const struct mt352_config dntv_live_dvbt_pro_config = {
Chris Pascoefc40b262006-01-09 15:25:35 -0200287 .demod_address = 0x0f,
288 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200289 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200290};
291#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
lawrence rust2e4e98e2010-08-25 09:50:20 -0300293static const struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300294 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300295 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300296};
297
lawrence rust2e4e98e2010-08-25 09:50:20 -0300298static const struct zl10353_config dvico_fusionhdtv_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300299 .demod_address = 0x0f,
300 .if2 = 45600,
301 .no_tuner = 1,
302};
303
lawrence rust2e4e98e2010-08-25 09:50:20 -0300304static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300305 .demod_address = 0x0f,
306 .if2 = 4560,
307 .no_tuner = 1,
308 .demod_init = dvico_fusionhdtv_demod_init,
309};
310
lawrence rust2e4e98e2010-08-25 09:50:20 -0300311static const struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300312 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300313};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300314
lawrence rust2e4e98e2010-08-25 09:50:20 -0300315static const struct cx22702_config connexant_refboard_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700317 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318};
319
lawrence rust2e4e98e2010-08-25 09:50:20 -0300320static const struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300321 .demod_address = 0x63,
322 .output_mode = CX22702_SERIAL_OUTPUT,
323};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
Michael Krufky4a390552006-12-05 02:00:53 -0300325static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326{
327 struct cx8802_dev *dev= fe->dvb->priv;
328 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
329 return 0;
330}
331
lawrence rust2e4e98e2010-08-25 09:50:20 -0300332static const struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300333 .demod_address = 0x15,
334 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
Michael Krufky6ddcc912005-07-27 11:46:00 -0700337static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700338{
339 struct cx8802_dev *dev= fe->dvb->priv;
340 struct cx88_core *core = dev->core;
341
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300342 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700343 if (index == 0)
344 cx_clear(MO_GP0_IO, 8);
345 else
346 cx_set(MO_GP0_IO, 8);
347 return 0;
348}
349
Michael Krufky6ddcc912005-07-27 11:46:00 -0700350static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700351{
352 struct cx8802_dev *dev= fe->dvb->priv;
353 if (is_punctured)
354 dev->ts_gen_cntrl |= 0x04;
355 else
356 dev->ts_gen_cntrl &= ~0x04;
357 return 0;
358}
359
Michael Krufky6ddcc912005-07-27 11:46:00 -0700360static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300361 .demod_address = 0x0e,
362 .demod_chip = LGDT3302,
363 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
364 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700365};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700366
lawrence rust2e4e98e2010-08-25 09:50:20 -0300367static const struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300368 .demod_address = 0x0e,
369 .demod_chip = LGDT3303,
370 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
371 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700372};
Rusty Scottda215d22006-04-07 02:21:31 -0300373
lawrence rust2e4e98e2010-08-25 09:50:20 -0300374static const struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300375 .demod_address = 0x59,
376 .demod_chip = LGDT3303,
377 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
378 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300379};
Michael Krufkyf1798492005-07-07 17:58:39 -0700380
Michael Krufky4a390552006-12-05 02:00:53 -0300381static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800382{
383 struct cx8802_dev *dev= fe->dvb->priv;
384 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
385 return 0;
386}
387
lawrence rust2e4e98e2010-08-25 09:50:20 -0300388static const struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300389 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300390 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800391};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800392
Steven Toth0fa14aa2006-01-09 15:25:02 -0200393static int cx24123_set_ts_param(struct dvb_frontend* fe,
394 int is_punctured)
395{
396 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300397 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200398 return 0;
399}
400
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300401static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
402 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200403{
404 struct cx8802_dev *dev= fe->dvb->priv;
405 struct cx88_core *core = dev->core;
406
Michael Krufky4a390552006-12-05 02:00:53 -0300407 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300408 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300409 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300410 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300411
412 if (core->prev_set_voltage)
413 return core->prev_set_voltage(fe, voltage);
414 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200415}
416
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300417static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
418 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300419{
420 struct cx8802_dev *dev= fe->dvb->priv;
421 struct cx88_core *core = dev->core;
422
423 if (voltage == SEC_VOLTAGE_OFF) {
424 dprintk(1,"LNB Voltage OFF\n");
425 cx_write(MO_GP0_IO, 0x0000efff);
426 }
427
428 if (core->prev_set_voltage)
429 return core->prev_set_voltage(fe, voltage);
430 return 0;
431}
432
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300433static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
434 fe_sec_voltage_t voltage)
435{
436 struct cx8802_dev *dev= fe->dvb->priv;
437 struct cx88_core *core = dev->core;
438
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300439 cx_set(MO_GP0_IO, 0x6040);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300440 switch (voltage) {
Sergey Ivanov111ac842010-08-09 10:18:32 -0300441 case SEC_VOLTAGE_13:
442 cx_clear(MO_GP0_IO, 0x20);
443 break;
444 case SEC_VOLTAGE_18:
445 cx_set(MO_GP0_IO, 0x20);
446 break;
447 case SEC_VOLTAGE_OFF:
448 cx_clear(MO_GP0_IO, 0x20);
449 break;
450 }
451
452 if (core->prev_set_voltage)
453 return core->prev_set_voltage(fe, voltage);
454 return 0;
455}
456
457static int vp1027_set_voltage(struct dvb_frontend *fe,
458 fe_sec_voltage_t voltage)
459{
460 struct cx8802_dev *dev = fe->dvb->priv;
461 struct cx88_core *core = dev->core;
462
463 switch (voltage) {
464 case SEC_VOLTAGE_13:
465 dprintk(1, "LNB SEC Voltage=13\n");
466 cx_write(MO_GP0_IO, 0x00001220);
467 break;
468 case SEC_VOLTAGE_18:
469 dprintk(1, "LNB SEC Voltage=18\n");
470 cx_write(MO_GP0_IO, 0x00001222);
471 break;
472 case SEC_VOLTAGE_OFF:
473 dprintk(1, "LNB Voltage OFF\n");
474 cx_write(MO_GP0_IO, 0x00001230);
475 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300476 }
477
478 if (core->prev_set_voltage)
479 return core->prev_set_voltage(fe, voltage);
480 return 0;
481}
482
lawrence rust2e4e98e2010-08-25 09:50:20 -0300483static const struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300484 .demod_address = 0x55,
485 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300486};
487
lawrence rust2e4e98e2010-08-25 09:50:20 -0300488static const struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300489 .demod_address = 0x55,
490 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200491};
492
lawrence rust2e4e98e2010-08-25 09:50:20 -0300493static const struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300494 .demod_address = 0x15,
495 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300496 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200497};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200498
lawrence rust2e4e98e2010-08-25 09:50:20 -0300499static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300500 .demod_address = 0x32 >> 1,
501 .output_mode = S5H1409_PARALLEL_OUTPUT,
502 .gpio = S5H1409_GPIO_ON,
503 .qam_if = 44000,
504 .inversion = S5H1409_INVERSION_OFF,
505 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300506 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300507};
508
lawrence rust2e4e98e2010-08-25 09:50:20 -0300509static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
Steven Toth5c00fac2008-04-22 14:45:14 -0300510 .demod_address = 0x32 >> 1,
511 .output_mode = S5H1409_SERIAL_OUTPUT,
512 .gpio = S5H1409_GPIO_OFF,
513 .inversion = S5H1409_INVERSION_OFF,
514 .status_mode = S5H1409_DEMODLOCKING,
515 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
516};
517
lawrence rust2e4e98e2010-08-25 09:50:20 -0300518static const struct s5h1409_config kworld_atsc_120_config = {
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300519 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300520 .output_mode = S5H1409_SERIAL_OUTPUT,
521 .gpio = S5H1409_GPIO_OFF,
522 .inversion = S5H1409_INVERSION_OFF,
523 .status_mode = S5H1409_DEMODLOCKING,
524 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
525};
526
lawrence rust2e4e98e2010-08-25 09:50:20 -0300527static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300528 .i2c_address = 0x64,
529 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300530};
531
lawrence rust2e4e98e2010-08-25 09:50:20 -0300532static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
Stéphane Voltz3f6014f2008-09-05 14:33:54 -0300533 .demod_address = (0x1e >> 1),
534 .no_tuner = 1,
535 .if2 = 45600,
536};
537
lawrence rust2e4e98e2010-08-25 09:50:20 -0300538static const struct zl10353_config cx88_geniatech_x8000_mt = {
Mauro Carvalho Chehab57069342009-08-20 10:14:45 -0300539 .demod_address = (0x1e >> 1),
540 .no_tuner = 1,
541 .disable_i2c_gate_ctrl = 1,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300542};
543
lawrence rust2e4e98e2010-08-25 09:50:20 -0300544static const struct s5h1411_config dvico_fusionhdtv7_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300545 .output_mode = S5H1411_SERIAL_OUTPUT,
546 .gpio = S5H1411_GPIO_ON,
547 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
548 .qam_if = S5H1411_IF_44000,
549 .vsb_if = S5H1411_IF_44000,
550 .inversion = S5H1411_INVERSION_OFF,
551 .status_mode = S5H1411_DEMODLOCKING
552};
553
lawrence rust2e4e98e2010-08-25 09:50:20 -0300554static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300555 .i2c_address = 0xc2 >> 1,
556 .if_khz = 5380,
Steven Tothd893d5d2008-04-25 03:46:43 -0300557};
558
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300559static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
560{
561 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -0300562 struct videobuf_dvb_frontend *fe0 = NULL;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300563 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300564 struct xc2028_config cfg = {
565 .i2c_adap = &dev->core->i2c_adap,
566 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300567 .ctrl = &ctl,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300568 };
569
Darron Broad92abe9e2008-10-11 11:18:53 -0300570 /* Get the first frontend */
Steven Toth363c35f2008-10-11 11:05:50 -0300571 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
572 if (!fe0)
573 return -EINVAL;
574
575 if (!fe0->dvb.frontend) {
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300576 printk(KERN_ERR "%s/2: dvb frontend not attached. "
577 "Can't attach xc3028\n",
578 dev->core->name);
579 return -EINVAL;
580 }
581
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300582 /*
583 * Some xc3028 devices may be hidden by an I2C gate. This is known
584 * to happen with some s5h1409-based devices.
585 * Now that I2C gate is open, sets up xc3028 configuration
586 */
587 cx88_setup_xc3028(dev->core, &ctl);
588
Steven Toth363c35f2008-10-11 11:05:50 -0300589 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300590 if (!fe) {
591 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
592 dev->core->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300593 dvb_frontend_detach(fe0->dvb.frontend);
594 dvb_unregister_frontend(fe0->dvb.frontend);
595 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300596 return -EINVAL;
597 }
598
599 printk(KERN_INFO "%s/2: xc3028 attached\n",
600 dev->core->name);
601
602 return 0;
603}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300604
Steven Toth5bd1b662008-09-04 01:17:33 -0300605static int cx24116_set_ts_param(struct dvb_frontend *fe,
606 int is_punctured)
607{
608 struct cx8802_dev *dev = fe->dvb->priv;
609 dev->ts_gen_cntrl = 0x2;
610
611 return 0;
612}
613
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300614static int stv0900_set_ts_param(struct dvb_frontend *fe,
615 int is_punctured)
616{
617 struct cx8802_dev *dev = fe->dvb->priv;
618 dev->ts_gen_cntrl = 0;
619
620 return 0;
621}
622
Steven Toth5bd1b662008-09-04 01:17:33 -0300623static int cx24116_reset_device(struct dvb_frontend *fe)
624{
625 struct cx8802_dev *dev = fe->dvb->priv;
626 struct cx88_core *core = dev->core;
627
628 /* Reset the part */
Steven Toth363c35f2008-10-11 11:05:50 -0300629 /* Put the cx24116 into reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300630 cx_write(MO_SRST_IO, 0);
631 msleep(10);
Steven Toth363c35f2008-10-11 11:05:50 -0300632 /* Take the cx24116 out of reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300633 cx_write(MO_SRST_IO, 1);
634 msleep(10);
635
636 return 0;
637}
638
lawrence rust2e4e98e2010-08-25 09:50:20 -0300639static const struct cx24116_config hauppauge_hvr4000_config = {
Steven Toth5bd1b662008-09-04 01:17:33 -0300640 .demod_address = 0x05,
641 .set_ts_params = cx24116_set_ts_param,
642 .reset_device = cx24116_reset_device,
643};
644
lawrence rust2e4e98e2010-08-25 09:50:20 -0300645static const struct cx24116_config tevii_s460_config = {
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300646 .demod_address = 0x55,
647 .set_ts_params = cx24116_set_ts_param,
648 .reset_device = cx24116_reset_device,
649};
650
lawrence rust2e4e98e2010-08-25 09:50:20 -0300651static const struct stv0900_config prof_7301_stv0900_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300652 .demod_address = 0x6a,
653/* demod_mode = 0,*/
654 .xtal = 27000000,
655 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
656 .diseqc_mode = 2,/* 2/3 PWM */
657 .tun1_maddress = 0,/* 0x60 */
658 .tun1_adc = 0,/* 2 Vpp */
659 .path1_mode = 3,
660 .set_ts_params = stv0900_set_ts_param,
661};
662
lawrence rust2e4e98e2010-08-25 09:50:20 -0300663static const struct stb6100_config prof_7301_stb6100_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300664 .tuner_address = 0x60,
665 .refclock = 27000000,
666};
667
lawrence rust2e4e98e2010-08-25 09:50:20 -0300668static const struct stv0299_config tevii_tuner_sharp_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300669 .demod_address = 0x68,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300670 .inittab = sharp_z0194a_inittab,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300671 .mclk = 88000000UL,
672 .invert = 1,
673 .skip_reinit = 0,
674 .lock_output = 1,
675 .volt13_op0_op1 = STV0299_VOLT13_OP1,
676 .min_delay_ms = 100,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300677 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300678 .set_ts_params = cx24116_set_ts_param,
679};
680
lawrence rust2e4e98e2010-08-25 09:50:20 -0300681static const struct stv0288_config tevii_tuner_earda_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300682 .demod_address = 0x68,
683 .min_delay_ms = 100,
684 .set_ts_params = cx24116_set_ts_param,
685};
686
Andy Walls6e0e12f2009-01-11 21:18:04 -0300687static int cx8802_alloc_frontends(struct cx8802_dev *dev)
688{
689 struct cx88_core *core = dev->core;
690 struct videobuf_dvb_frontend *fe = NULL;
691 int i;
692
693 mutex_init(&dev->frontends.lock);
694 INIT_LIST_HEAD(&dev->frontends.felist);
695
696 if (!core->board.num_frontends)
697 return -ENODEV;
698
699 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
700 core->board.num_frontends);
701 for (i = 1; i <= core->board.num_frontends; i++) {
702 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
703 if (!fe) {
704 printk(KERN_ERR "%s() failed to alloc\n", __func__);
705 videobuf_dvb_dealloc_frontends(&dev->frontends);
706 return -ENOMEM;
707 }
708 }
709 return 0;
710}
711
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300712
713
lawrence rust2e4e98e2010-08-25 09:50:20 -0300714static const u8 samsung_smt_7020_inittab[] = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300715 0x01, 0x15,
716 0x02, 0x00,
717 0x03, 0x00,
718 0x04, 0x7D,
719 0x05, 0x0F,
720 0x06, 0x02,
721 0x07, 0x00,
722 0x08, 0x60,
723
724 0x0A, 0xC2,
725 0x0B, 0x00,
726 0x0C, 0x01,
727 0x0D, 0x81,
728 0x0E, 0x44,
729 0x0F, 0x09,
730 0x10, 0x3C,
731 0x11, 0x84,
732 0x12, 0xDA,
733 0x13, 0x99,
734 0x14, 0x8D,
735 0x15, 0xCE,
736 0x16, 0xE8,
737 0x17, 0x43,
738 0x18, 0x1C,
739 0x19, 0x1B,
740 0x1A, 0x1D,
741
742 0x1C, 0x12,
743 0x1D, 0x00,
744 0x1E, 0x00,
745 0x1F, 0x00,
746 0x20, 0x00,
747 0x21, 0x00,
748 0x22, 0x00,
749 0x23, 0x00,
750
751 0x28, 0x02,
752 0x29, 0x28,
753 0x2A, 0x14,
754 0x2B, 0x0F,
755 0x2C, 0x09,
756 0x2D, 0x05,
757
758 0x31, 0x1F,
759 0x32, 0x19,
760 0x33, 0xFC,
761 0x34, 0x13,
762 0xff, 0xff,
763};
764
765
766static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe,
767 struct dvb_frontend_parameters *params)
768{
769 struct cx8802_dev *dev = fe->dvb->priv;
770 u8 buf[4];
771 u32 div;
772 struct i2c_msg msg = {
773 .addr = 0x61,
774 .flags = 0,
775 .buf = buf,
776 .len = sizeof(buf) };
777
778 div = params->frequency / 125;
779
780 buf[0] = (div >> 8) & 0x7f;
781 buf[1] = div & 0xff;
782 buf[2] = 0x84; /* 0xC4 */
783 buf[3] = 0x00;
784
785 if (params->frequency < 1500000)
786 buf[3] |= 0x10;
787
788 if (fe->ops.i2c_gate_ctrl)
789 fe->ops.i2c_gate_ctrl(fe, 1);
790
791 if (i2c_transfer(&dev->core->i2c_adap, &msg, 1) != 1)
792 return -EIO;
793
794 return 0;
795}
796
797static int samsung_smt_7020_set_tone(struct dvb_frontend *fe,
798 fe_sec_tone_mode_t tone)
799{
800 struct cx8802_dev *dev = fe->dvb->priv;
801 struct cx88_core *core = dev->core;
802
803 cx_set(MO_GP0_IO, 0x0800);
804
805 switch (tone) {
806 case SEC_TONE_ON:
807 cx_set(MO_GP0_IO, 0x08);
808 break;
809 case SEC_TONE_OFF:
810 cx_clear(MO_GP0_IO, 0x08);
811 break;
812 default:
813 return -EINVAL;
814 }
815
816 return 0;
817}
818
819static int samsung_smt_7020_set_voltage(struct dvb_frontend *fe,
820 fe_sec_voltage_t voltage)
821{
822 struct cx8802_dev *dev = fe->dvb->priv;
823 struct cx88_core *core = dev->core;
824
825 u8 data;
826 struct i2c_msg msg = {
827 .addr = 8,
828 .flags = 0,
829 .buf = &data,
830 .len = sizeof(data) };
831
832 cx_set(MO_GP0_IO, 0x8000);
833
834 switch (voltage) {
835 case SEC_VOLTAGE_OFF:
836 break;
837 case SEC_VOLTAGE_13:
838 data = ISL6421_EN1 | ISL6421_LLC1;
839 cx_clear(MO_GP0_IO, 0x80);
840 break;
841 case SEC_VOLTAGE_18:
842 data = ISL6421_EN1 | ISL6421_LLC1 | ISL6421_VSEL1;
843 cx_clear(MO_GP0_IO, 0x80);
844 break;
845 default:
846 return -EINVAL;
847 };
848
849 return (i2c_transfer(&dev->core->i2c_adap, &msg, 1) == 1) ? 0 : -EIO;
850}
851
852static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
853 u32 srate, u32 ratio)
854{
855 u8 aclk = 0;
856 u8 bclk = 0;
857
858 if (srate < 1500000) {
859 aclk = 0xb7;
860 bclk = 0x47;
861 } else if (srate < 3000000) {
862 aclk = 0xb7;
863 bclk = 0x4b;
864 } else if (srate < 7000000) {
865 aclk = 0xb7;
866 bclk = 0x4f;
867 } else if (srate < 14000000) {
868 aclk = 0xb7;
869 bclk = 0x53;
870 } else if (srate < 30000000) {
871 aclk = 0xb6;
872 bclk = 0x53;
873 } else if (srate < 45000000) {
874 aclk = 0xb4;
875 bclk = 0x51;
876 }
877
878 stv0299_writereg(fe, 0x13, aclk);
879 stv0299_writereg(fe, 0x14, bclk);
880 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
881 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
882 stv0299_writereg(fe, 0x21, ratio & 0xf0);
883
884 return 0;
885}
886
887
lawrence rust2e4e98e2010-08-25 09:50:20 -0300888static const struct stv0299_config samsung_stv0299_config = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300889 .demod_address = 0x68,
890 .inittab = samsung_smt_7020_inittab,
891 .mclk = 88000000UL,
892 .invert = 0,
893 .skip_reinit = 0,
894 .lock_output = STV0299_LOCKOUTPUT_LK,
895 .volt13_op0_op1 = STV0299_VOLT13_OP1,
896 .min_delay_ms = 100,
897 .set_symbol_rate = samsung_smt_7020_stv0299_set_symbol_rate,
898};
899
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900static int dvb_register(struct cx8802_dev *dev)
901{
Steven Toth363c35f2008-10-11 11:05:50 -0300902 struct cx88_core *core = dev->core;
903 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
Darron Broad59b18422008-10-11 11:44:05 -0300904 int mfe_shared = 0; /* bus not shared by default */
Steven Toth363c35f2008-10-11 11:05:50 -0300905
Matthias Schwarzott0e8bac92008-10-24 10:47:07 -0300906 if (0 != core->i2c_rc) {
907 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
908 goto frontend_detach;
909 }
910
Steven Toth363c35f2008-10-11 11:05:50 -0300911 /* Get the first frontend */
912 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
913 if (!fe0)
Darron Broad60a5a922008-11-11 08:48:27 -0300914 goto frontend_detach;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915
Darron Broad8e739092008-10-11 11:31:41 -0300916 /* multi-frontend gate control is undefined or defaults to fe0 */
917 dev->frontends.gate = 0;
918
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300919 /* Sets the gate control callback to be used by i2c command calls */
920 core->gate_ctrl = cx88_dvb_gate_ctrl;
921
Darron Broad8e739092008-10-11 11:31:41 -0300922 /* init frontend(s) */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300923 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -0300925 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300926 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300927 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300928 if (fe0->dvb.frontend != NULL) {
929 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300930 0x61, &core->i2c_adap,
931 DVB_PLL_THOMSON_DTT759X))
932 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300933 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700935 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200937 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800938 case CX88_BOARD_WINFAST_DTV1000:
Steven Toth363c35f2008-10-11 11:05:50 -0300939 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300940 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300941 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300942 if (fe0->dvb.frontend != NULL) {
943 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300944 0x60, &core->i2c_adap,
945 DVB_PLL_THOMSON_DTT7579))
946 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300947 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300949 case CX88_BOARD_WINFAST_DTV2000H:
Vlastimil Labsky4d14c832009-08-10 22:15:54 -0300950 case CX88_BOARD_WINFAST_DTV2000H_J:
Steven Toth611900c2006-01-09 15:25:12 -0200951 case CX88_BOARD_HAUPPAUGE_HVR1100:
952 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300953 case CX88_BOARD_HAUPPAUGE_HVR1300:
Steven Toth363c35f2008-10-11 11:05:50 -0300954 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300955 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300956 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300957 if (fe0->dvb.frontend != NULL) {
958 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300959 &core->i2c_adap, 0x61,
960 TUNER_PHILIPS_FMD1216ME_MK3))
961 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300962 }
Steven Toth611900c2006-01-09 15:25:12 -0200963 break;
Steven Toth363c35f2008-10-11 11:05:50 -0300964 case CX88_BOARD_HAUPPAUGE_HVR3000:
Darron Broad60a5a922008-11-11 08:48:27 -0300965 /* MFE frontend 1 */
966 mfe_shared = 1;
967 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -0300968 /* DVB-S init */
969 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Darron Broad60a5a922008-11-11 08:48:27 -0300970 &hauppauge_novas_config,
971 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300972 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -0300973 if (!dvb_attach(isl6421_attach,
974 fe0->dvb.frontend,
975 &dev->core->i2c_adap,
976 0x08, ISL6421_DCL, 0x00))
977 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300978 }
Darron Broad60a5a922008-11-11 08:48:27 -0300979 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -0300980 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -0300981 if (!fe1)
982 goto frontend_detach;
983 /* DVB-T init */
984 fe1->dvb.frontend = dvb_attach(cx22702_attach,
985 &hauppauge_hvr_config,
986 &dev->core->i2c_adap);
987 if (fe1->dvb.frontend) {
988 fe1->dvb.frontend->id = 1;
989 if (!dvb_attach(simple_tuner_attach,
990 fe1->dvb.frontend,
991 &dev->core->i2c_adap,
992 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
993 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300994 }
995 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -0300996 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Steven Toth363c35f2008-10-11 11:05:50 -0300997 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300998 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300999 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001000 if (fe0->dvb.frontend != NULL) {
1001 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001002 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1003 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001004 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001005 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001006 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001007 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001008 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001009 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001010 if (fe0->dvb.frontend != NULL) {
1011 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001012 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1013 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001014 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001015 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001016 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001017 /* The tin box says DEE1601, but it seems to be DTT7579
1018 * compatible, with a slightly different MT352 AGC gain. */
Steven Toth363c35f2008-10-11 11:05:50 -03001019 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001020 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001021 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001022 if (fe0->dvb.frontend != NULL) {
1023 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001024 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1025 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001026 break;
1027 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001028 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001029 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001030 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001031 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001032 if (fe0->dvb.frontend != NULL) {
1033 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001034 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1035 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001036 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001037 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -03001039 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001040 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001041 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001042 if (fe0->dvb.frontend != NULL) {
1043 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001044 0x61, NULL, DVB_PLL_LG_Z201))
1045 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001046 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 case CX88_BOARD_KWORLD_DVB_T:
1049 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001050 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Steven Toth363c35f2008-10-11 11:05:50 -03001051 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001052 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001053 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001054 if (fe0->dvb.frontend != NULL) {
1055 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001056 0x61, NULL, DVB_PLL_UNKNOWN_1))
1057 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001058 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059 break;
Chris Pascoefc40b262006-01-09 15:25:35 -02001060 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -03001061#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -03001062 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Steven Toth363c35f2008-10-11 11:05:50 -03001063 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -03001064 &dev->vp3054->adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001065 if (fe0->dvb.frontend != NULL) {
1066 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001067 &core->i2c_adap, 0x61,
1068 TUNER_PHILIPS_FMD1216ME_MK3))
1069 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001070 }
Chris Pascoefc40b262006-01-09 15:25:35 -02001071#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001072 printk(KERN_ERR "%s/2: built without vp3054 support\n",
1073 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -02001074#endif
1075 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001076 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001077 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001078 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001079 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001080 if (fe0->dvb.frontend != NULL) {
1081 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001082 &core->i2c_adap, 0x61,
1083 TUNER_THOMSON_FE6600))
1084 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001085 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001086 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001087 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
Steven Toth363c35f2008-10-11 11:05:50 -03001088 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001089 &dvico_fusionhdtv_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001090 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001091 if (fe0->dvb.frontend == NULL)
1092 fe0->dvb.frontend = dvb_attach(mt352_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001093 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001094 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -03001095 /*
1096 * On this board, the demod provides the I2C bus pullup.
1097 * We must not permit gate_ctrl to be performed, or
1098 * the xc3028 cannot communicate on the bus.
1099 */
Steven Toth363c35f2008-10-11 11:05:50 -03001100 if (fe0->dvb.frontend)
1101 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001102 if (attach_xc3028(0x61, dev) < 0)
Darron Broadbecd4302008-10-21 11:47:50 -03001103 goto frontend_detach;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001104 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 case CX88_BOARD_PCHDTV_HD3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001106 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001107 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001108 if (fe0->dvb.frontend != NULL) {
1109 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001110 &core->i2c_adap, 0x61,
1111 TUNER_THOMSON_DTT761X))
1112 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001113 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 break;
Michael Krufkyf1798492005-07-07 17:58:39 -07001115 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
1116 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -07001117
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001118 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -07001119 cx_clear(MO_GP0_IO, 1);
1120 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001121 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -07001122 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001123
1124 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -07001125 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Steven Toth363c35f2008-10-11 11:05:50 -03001126 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001127 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001128 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001129 if (fe0->dvb.frontend != NULL) {
1130 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001131 &core->i2c_adap, 0x61,
1132 TUNER_MICROTUNE_4042FI5))
1133 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -07001134 }
1135 break;
Michael Krufky0d723c02005-07-07 17:58:42 -07001136 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
1137 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -07001138
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001139 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -07001140 cx_clear(MO_GP0_IO, 1);
1141 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -07001142 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -07001143 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001144 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001145 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001146 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001147 if (fe0->dvb.frontend != NULL) {
1148 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001149 &core->i2c_adap, 0x61,
1150 TUNER_THOMSON_DTT761X))
1151 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -07001152 }
1153 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001154 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
1155 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001156
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001157 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001158 cx_clear(MO_GP0_IO, 1);
1159 mdelay(100);
1160 cx_set(MO_GP0_IO, 1);
1161 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001162 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001163 &fusionhdtv_5_gold,
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_LG_TDVS_H06XF))
1169 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001170 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001171 &core->i2c_adap, 0x43))
1172 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001173 }
1174 break;
Rusty Scottda215d22006-04-07 02:21:31 -03001175 case CX88_BOARD_PCHDTV_HD5500:
1176 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -03001177
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001178 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -03001179 cx_clear(MO_GP0_IO, 1);
1180 mdelay(100);
1181 cx_set(MO_GP0_IO, 1);
1182 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001183 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001184 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001185 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001186 if (fe0->dvb.frontend != NULL) {
1187 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001188 &core->i2c_adap, 0x61,
1189 TUNER_LG_TDVS_H06XF))
1190 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001191 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001192 &core->i2c_adap, 0x43))
1193 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -03001194 }
1195 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -08001196 case CX88_BOARD_ATI_HDTVWONDER:
Steven Toth363c35f2008-10-11 11:05:50 -03001197 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001198 &ati_hdtvwonder,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001199 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001200 if (fe0->dvb.frontend != NULL) {
1201 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001202 &core->i2c_adap, 0x61,
1203 TUNER_PHILIPS_TUV1236D))
1204 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001205 }
Kirk Laprayfde6d312005-11-08 21:38:18 -08001206 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -02001207 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
1208 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Steven Toth363c35f2008-10-11 11:05:50 -03001209 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001210 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001211 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001212 if (fe0->dvb.frontend) {
1213 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
Steven Toth83fe92e2008-09-13 19:22:15 -03001214 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001215 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001216 }
Steven Toth0fa14aa2006-01-09 15:25:02 -02001217 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -02001218 case CX88_BOARD_KWORLD_DVBS_100:
Steven Toth363c35f2008-10-11 11:05:50 -03001219 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001220 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001221 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001222 if (fe0->dvb.frontend) {
1223 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1224 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001225 }
Vadim Catana0e0351e2006-01-09 15:25:02 -02001226 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001227 case CX88_BOARD_GENIATECH_DVBS:
Steven Toth363c35f2008-10-11 11:05:50 -03001228 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001229 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001230 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001231 if (fe0->dvb.frontend) {
1232 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1233 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001234 }
1235 break;
Steven Toth60464da2008-01-05 16:53:01 -03001236 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth363c35f2008-10-11 11:05:50 -03001237 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth60464da2008-01-05 16:53:01 -03001238 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001239 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001240 if (fe0->dvb.frontend != NULL) {
1241 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001242 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001243 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001244 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -03001245 }
1246 break;
Steven Toth5c00fac2008-04-22 14:45:14 -03001247 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
Steven Toth363c35f2008-10-11 11:05:50 -03001248 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth5c00fac2008-04-22 14:45:14 -03001249 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001250 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001251 if (fe0->dvb.frontend != NULL) {
Steven Toth5c00fac2008-04-22 14:45:14 -03001252 struct dvb_frontend *fe;
1253 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001254 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -03001255 .i2c_addr = 0x61,
Steven Toth5c00fac2008-04-22 14:45:14 -03001256 };
1257 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001258 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -03001259 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -03001260 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -03001261 };
1262
1263 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001264 fe0->dvb.frontend, &cfg);
Steven Toth5c00fac2008-04-22 14:45:14 -03001265 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1266 fe->ops.tuner_ops.set_config(fe, &ctl);
1267 }
1268 break;
Ricardo Maraschinid49f7a22010-04-06 02:40:43 -03001269 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
Miroslav Sustek3047a172009-05-31 16:47:28 -03001270 case CX88_BOARD_WINFAST_DTV1800H:
Steven Toth363c35f2008-10-11 11:05:50 -03001271 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001272 &cx88_pinnacle_hybrid_pctv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001273 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001274 if (fe0->dvb.frontend) {
1275 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001276 if (attach_xc3028(0x61, dev) < 0)
1277 goto frontend_detach;
1278 }
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001279 break;
1280 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001281 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001282
Steven Toth363c35f2008-10-11 11:05:50 -03001283 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001284 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001285 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001286 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001287 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001288 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001289 case CX88_BOARD_KWORLD_ATSC_120:
Steven Toth363c35f2008-10-11 11:05:50 -03001290 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001291 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001292 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001293 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001294 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001295 break;
Steven Tothd893d5d2008-04-25 03:46:43 -03001296 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
Steven Toth363c35f2008-10-11 11:05:50 -03001297 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Steven Tothd893d5d2008-04-25 03:46:43 -03001298 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001299 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001300 if (fe0->dvb.frontend != NULL) {
1301 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001302 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001303 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001304 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -03001305 }
1306 break;
Steven Toth5bd1b662008-09-04 01:17:33 -03001307 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad60a5a922008-11-11 08:48:27 -03001308 /* MFE frontend 1 */
1309 mfe_shared = 1;
1310 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001311 /* DVB-S/S2 Init */
1312 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001313 &hauppauge_hvr4000_config,
1314 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001315 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001316 if (!dvb_attach(isl6421_attach,
1317 fe0->dvb.frontend,
1318 &dev->core->i2c_adap,
1319 0x08, ISL6421_DCL, 0x00))
1320 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001321 }
Darron Broad60a5a922008-11-11 08:48:27 -03001322 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001323 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001324 if (!fe1)
1325 goto frontend_detach;
1326 /* DVB-T Init */
1327 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1328 &hauppauge_hvr_config,
1329 &dev->core->i2c_adap);
1330 if (fe1->dvb.frontend) {
1331 fe1->dvb.frontend->id = 1;
1332 if (!dvb_attach(simple_tuner_attach,
1333 fe1->dvb.frontend,
1334 &dev->core->i2c_adap,
1335 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1336 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001337 }
1338 break;
1339 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1340 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001341 &hauppauge_hvr4000_config,
1342 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001343 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001344 if (!dvb_attach(isl6421_attach,
1345 fe0->dvb.frontend,
1346 &dev->core->i2c_adap,
1347 0x08, ISL6421_DCL, 0x00))
1348 goto frontend_detach;
Steven Toth5bd1b662008-09-04 01:17:33 -03001349 }
1350 break;
Igor M. Liplianincd3cde12008-11-09 15:26:25 -03001351 case CX88_BOARD_PROF_6200:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001352 case CX88_BOARD_TBS_8910:
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001353 case CX88_BOARD_TEVII_S420:
Steven Toth363c35f2008-10-11 11:05:50 -03001354 fe0->dvb.frontend = dvb_attach(stv0299_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001355 &tevii_tuner_sharp_config,
1356 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001357 if (fe0->dvb.frontend != NULL) {
1358 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001359 &core->i2c_adap, DVB_PLL_OPERA1))
1360 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001361 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1362 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001363
1364 } else {
Steven Toth363c35f2008-10-11 11:05:50 -03001365 fe0->dvb.frontend = dvb_attach(stv0288_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001366 &tevii_tuner_earda_config,
1367 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001368 if (fe0->dvb.frontend != NULL) {
1369 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001370 &core->i2c_adap))
1371 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001372 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1373 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001374 }
1375 }
1376 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001377 case CX88_BOARD_TEVII_S460:
Steven Toth363c35f2008-10-11 11:05:50 -03001378 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001379 &tevii_s460_config,
1380 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001381 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001382 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001383 break;
Oleg Roitburd4cd7fb82008-09-17 11:30:21 -03001384 case CX88_BOARD_OMICOM_SS4_PCI:
Oleg Roitburdee730422008-09-17 11:58:33 -03001385 case CX88_BOARD_TBS_8920:
Oleg Roitburd57f51db2008-10-08 06:48:08 -03001386 case CX88_BOARD_PROF_7300:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001387 case CX88_BOARD_SATTRADE_ST4200:
Steven Toth363c35f2008-10-11 11:05:50 -03001388 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Oleg Roitburdee730422008-09-17 11:58:33 -03001389 &hauppauge_hvr4000_config,
1390 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001391 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001392 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Oleg Roitburdee730422008-09-17 11:58:33 -03001393 break;
Stephan Wienczny70101a22009-03-10 19:08:06 -03001394 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
1395 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1396 &cx88_terratec_cinergy_ht_pci_mkii_config,
1397 &core->i2c_adap);
1398 if (fe0->dvb.frontend) {
1399 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1400 if (attach_xc3028(0x61, dev) < 0)
1401 goto frontend_detach;
1402 }
1403 break;
Igor M. Liplianinb699c272009-11-16 22:22:32 -03001404 case CX88_BOARD_PROF_7301:{
1405 struct dvb_tuner_ops *tuner_ops = NULL;
1406
1407 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1408 &prof_7301_stv0900_config,
1409 &core->i2c_adap, 0);
1410 if (fe0->dvb.frontend != NULL) {
1411 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1412 &prof_7301_stb6100_config,
1413 &core->i2c_adap))
1414 goto frontend_detach;
1415
1416 tuner_ops = &fe0->dvb.frontend->ops.tuner_ops;
1417 tuner_ops->set_frequency = stb6100_set_freq;
1418 tuner_ops->get_frequency = stb6100_get_freq;
1419 tuner_ops->set_bandwidth = stb6100_set_bandw;
1420 tuner_ops->get_bandwidth = stb6100_get_bandw;
1421
1422 core->prev_set_voltage =
1423 fe0->dvb.frontend->ops.set_voltage;
1424 fe0->dvb.frontend->ops.set_voltage =
1425 tevii_dvbs_set_voltage;
1426 }
1427 break;
1428 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001429 case CX88_BOARD_SAMSUNG_SMT_7020:
1430 dev->ts_gen_cntrl = 0x08;
1431
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001432 cx_set(MO_GP0_IO, 0x0101);
1433
1434 cx_clear(MO_GP0_IO, 0x01);
1435 mdelay(100);
1436 cx_set(MO_GP0_IO, 0x01);
1437 mdelay(200);
1438
1439 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1440 &samsung_stv0299_config,
1441 &dev->core->i2c_adap);
1442 if (fe0->dvb.frontend) {
1443 fe0->dvb.frontend->ops.tuner_ops.set_params =
1444 samsung_smt_7020_tuner_set_params;
1445 fe0->dvb.frontend->tuner_priv =
1446 &dev->core->i2c_adap;
1447 fe0->dvb.frontend->ops.set_voltage =
1448 samsung_smt_7020_set_voltage;
1449 fe0->dvb.frontend->ops.set_tone =
1450 samsung_smt_7020_set_tone;
1451 }
1452
1453 break;
Sergey Ivanov111ac842010-08-09 10:18:32 -03001454 case CX88_BOARD_TWINHAN_VP1027_DVBS:
1455 dev->ts_gen_cntrl = 0x00;
1456 fe0->dvb.frontend = dvb_attach(mb86a16_attach,
1457 &twinhan_vp1027,
1458 &core->i2c_adap);
1459 if (fe0->dvb.frontend) {
1460 core->prev_set_voltage =
1461 fe0->dvb.frontend->ops.set_voltage;
1462 fe0->dvb.frontend->ops.set_voltage =
1463 vp1027_set_voltage;
1464 }
1465 break;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001466
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 default:
Trent Piepho5772f812007-08-15 14:41:59 -03001468 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 -03001469 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470 break;
1471 }
Steven Toth363c35f2008-10-11 11:05:50 -03001472
Mauro Carvalho Chehab2c9bcea2008-11-10 23:35:00 -02001473 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001474 printk(KERN_ERR
1475 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001476 core->name);
Darron Broad60a5a922008-11-11 08:48:27 -03001477 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001478 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001479 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001480 fe0->dvb.frontend->callback = cx88_tuner_callback;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001481
Steven Toth6c5be742006-12-02 21:15:51 -02001482 /* Ensure all frontends negotiate bus access */
Steven Toth363c35f2008-10-11 11:05:50 -03001483 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1484 if (fe1)
1485 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001487 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001488 call_all(core, core, s_power, 0);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001489
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 /* register everything */
Steven Toth363c35f2008-10-11 11:05:50 -03001491 return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001492 &dev->pci->dev, adapter_nr, mfe_shared, NULL);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001493
1494frontend_detach:
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001495 core->gate_ctrl = NULL;
Darron Broadbecd4302008-10-21 11:47:50 -03001496 videobuf_dvb_dealloc_frontends(&dev->frontends);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001497 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498}
1499
1500/* ----------------------------------------------------------- */
1501
Steven Toth6c5be742006-12-02 21:15:51 -02001502/* CX8802 MPEG -> mini driver - We have been given the hardware */
1503static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001504{
Steven Toth6c5be742006-12-02 21:15:51 -02001505 struct cx88_core *core = drv->core;
1506 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001507 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001508
Trent Piepho6a59d642007-08-15 14:41:57 -03001509 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001510 case CX88_BOARD_HAUPPAUGE_HVR1300:
1511 /* We arrive here with either the cx23416 or the cx22702
1512 * on the bus. Take the bus from the cx23416 and enable the
1513 * cx22702 demod
1514 */
Darron Broad79392732008-12-18 06:28:35 -03001515 /* Toggle reset on cx22702 leaving i2c active */
1516 cx_set(MO_GP0_IO, 0x00000080);
1517 udelay(1000);
1518 cx_clear(MO_GP0_IO, 0x00000080);
1519 udelay(50);
1520 cx_set(MO_GP0_IO, 0x00000080);
1521 udelay(1000);
1522 /* enable the cx22702 pins */
Steven Toth6c5be742006-12-02 21:15:51 -02001523 cx_clear(MO_GP0_IO, 0x00000004);
1524 udelay(1000);
1525 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001526
Darron Broad92abe9e2008-10-11 11:18:53 -03001527 case CX88_BOARD_HAUPPAUGE_HVR3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001528 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad79392732008-12-18 06:28:35 -03001529 /* Toggle reset on cx22702 leaving i2c active */
1530 cx_set(MO_GP0_IO, 0x00000080);
1531 udelay(1000);
1532 cx_clear(MO_GP0_IO, 0x00000080);
1533 udelay(50);
1534 cx_set(MO_GP0_IO, 0x00000080);
1535 udelay(1000);
1536 switch (core->dvbdev->frontends.active_fe_id) {
1537 case 1: /* DVB-S/S2 Enabled */
1538 /* tri-state the cx22702 pins */
1539 cx_set(MO_GP0_IO, 0x00000004);
1540 /* Take the cx24116/cx24123 out of reset */
1541 cx_write(MO_SRST_IO, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001542 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
Darron Broad79392732008-12-18 06:28:35 -03001543 break;
1544 case 2: /* DVB-T Enabled */
Steven Toth363c35f2008-10-11 11:05:50 -03001545 /* Put the cx24116/cx24123 into reset */
1546 cx_write(MO_SRST_IO, 0);
Darron Broad79392732008-12-18 06:28:35 -03001547 /* enable the cx22702 pins */
Steven Toth363c35f2008-10-11 11:05:50 -03001548 cx_clear(MO_GP0_IO, 0x00000004);
1549 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
Darron Broad79392732008-12-18 06:28:35 -03001550 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001551 }
Darron Broad79392732008-12-18 06:28:35 -03001552 udelay(1000);
Steven Toth363c35f2008-10-11 11:05:50 -03001553 break;
1554
Steven Toth6c5be742006-12-02 21:15:51 -02001555 default:
1556 err = -ENODEV;
1557 }
1558 return err;
1559}
1560
1561/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1562static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1563{
1564 struct cx88_core *core = drv->core;
1565 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001566 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001567
Trent Piepho6a59d642007-08-15 14:41:57 -03001568 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001569 case CX88_BOARD_HAUPPAUGE_HVR1300:
1570 /* Do Nothing, leave the cx22702 on the bus. */
1571 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001572 case CX88_BOARD_HAUPPAUGE_HVR3000:
1573 case CX88_BOARD_HAUPPAUGE_HVR4000:
1574 break;
Steven Toth6c5be742006-12-02 21:15:51 -02001575 default:
1576 err = -ENODEV;
1577 }
1578 return err;
1579}
1580
1581static int cx8802_dvb_probe(struct cx8802_driver *drv)
1582{
1583 struct cx88_core *core = drv->core;
1584 struct cx8802_dev *dev = drv->core->dvbdev;
Darron Broadcbd82442008-10-30 05:07:44 -03001585 int err;
Andy Walls6e0e12f2009-01-11 21:18:04 -03001586 struct videobuf_dvb_frontend *fe;
1587 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001588
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001589 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001590 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001591 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001592 core->name,
1593 core->pci_bus,
1594 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001595
1596 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001597 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598 goto fail_core;
1599
Trent Piephoecf854d2007-05-05 20:11:32 -03001600 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001601 err = vp3054_i2c_probe(dev);
1602 if (0 != err)
Andy Walls6e0e12f2009-01-11 21:18:04 -03001603 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001604
Linus Torvalds1da177e2005-04-16 15:20:36 -07001605 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001606 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Steven Toth363c35f2008-10-11 11:05:50 -03001607 dev->ts_gen_cntrl = 0x0c;
1608
Andy Walls6e0e12f2009-01-11 21:18:04 -03001609 err = cx8802_alloc_frontends(dev);
1610 if (err)
1611 goto fail_core;
Darron Broadcbd82442008-10-30 05:07:44 -03001612
Andy Walls6e0e12f2009-01-11 21:18:04 -03001613 err = -ENODEV;
1614 for (i = 1; i <= core->board.num_frontends; i++) {
1615 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1616 if (fe == NULL) {
1617 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
Darron Broadcbd82442008-10-30 05:07:44 -03001618 __func__, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001619 goto fail_probe;
1620 }
1621 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
Darron Broadcbd82442008-10-30 05:07:44 -03001622 &dev->pci->dev, &dev->slock,
1623 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1624 V4L2_FIELD_TOP,
1625 sizeof(struct cx88_buffer),
Hans Verkuil08bff032010-09-20 17:39:46 -03001626 dev, NULL);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001627 /* init struct videobuf_dvb */
1628 fe->dvb.name = dev->core->name;
Steven Toth363c35f2008-10-11 11:05:50 -03001629 }
Andy Walls6e0e12f2009-01-11 21:18:04 -03001630
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631 err = dvb_register(dev);
Darron Broadcbd82442008-10-30 05:07:44 -03001632 if (err)
1633 /* frontends/adapter de-allocated in dvb_register */
Trent Piepho5772f812007-08-15 14:41:59 -03001634 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1635 core->name, err);
Darron Broadcbd82442008-10-30 05:07:44 -03001636 return err;
1637fail_probe:
1638 videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
Darron Broad92abe9e2008-10-11 11:18:53 -03001639fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001640 return err;
1641}
1642
Steven Toth6c5be742006-12-02 21:15:51 -02001643static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644{
Darron Broad0fcd4882008-10-21 11:18:47 -03001645 struct cx88_core *core = drv->core;
Steven Toth6c5be742006-12-02 21:15:51 -02001646 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001647
Darron Broad0fcd4882008-10-21 11:18:47 -03001648 dprintk( 1, "%s\n", __func__);
1649
Steven Toth363c35f2008-10-11 11:05:50 -03001650 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001651
Chris Pascoefc40b262006-01-09 15:25:35 -02001652 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001653
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001654 core->gate_ctrl = NULL;
1655
Steven Toth6c5be742006-12-02 21:15:51 -02001656 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001657}
1658
Steven Toth6c5be742006-12-02 21:15:51 -02001659static struct cx8802_driver cx8802_dvb_driver = {
1660 .type_id = CX88_MPEG_DVB,
1661 .hw_access = CX8802_DRVCTL_SHARED,
1662 .probe = cx8802_dvb_probe,
1663 .remove = cx8802_dvb_remove,
1664 .advise_acquire = cx8802_dvb_advise_acquire,
1665 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666};
1667
Peter Huewe31d0f842009-07-17 01:00:01 +02001668static int __init dvb_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669{
Trent Piepho5772f812007-08-15 14:41:59 -03001670 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001671 (CX88_VERSION_CODE >> 16) & 0xff,
1672 (CX88_VERSION_CODE >> 8) & 0xff,
1673 CX88_VERSION_CODE & 0xff);
1674#ifdef SNAPSHOT
1675 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1676 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1677#endif
Steven Toth6c5be742006-12-02 21:15:51 -02001678 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679}
1680
Peter Huewe31d0f842009-07-17 01:00:01 +02001681static void __exit dvb_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682{
Steven Toth6c5be742006-12-02 21:15:51 -02001683 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001684}
1685
1686module_init(dvb_init);
1687module_exit(dvb_fini);
1688
1689/*
1690 * Local variables:
1691 * c-basic-offset: 8
1692 * compile-command: "make DVB=1"
1693 * End:
1694 */