blob: c69df7ebb6a7575f0478a34c7b41142aa83c4cc9 [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"
Igor M. Liplianin0cb73632011-02-25 18:41:24 -030060#include "ds3000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
63MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
64MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
65MODULE_LICENSE("GPL");
66
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030067static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068module_param(debug, int, 0644);
69MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
70
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030071static unsigned int dvb_buf_tscnt = 32;
72module_param(dvb_buf_tscnt, int, 0644);
73MODULE_PARM_DESC(dvb_buf_tscnt, "DVB Buffer TS count [dvb]");
74
Janne Grunau78e92002008-04-09 19:13:13 -030075DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020078 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80/* ------------------------------------------------------------------ */
81
82static int dvb_buf_setup(struct videobuf_queue *q,
83 unsigned int *count, unsigned int *size)
84{
85 struct cx8802_dev *dev = q->priv_data;
86
87 dev->ts_packet_size = 188 * 4;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030088 dev->ts_packet_count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90 *size = dev->ts_packet_size * dev->ts_packet_count;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030091 *count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 return 0;
93}
94
Michael Krufky4a390552006-12-05 02:00:53 -030095static int dvb_buf_prepare(struct videobuf_queue *q,
96 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
98 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030099 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100}
101
102static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
103{
104 struct cx8802_dev *dev = q->priv_data;
105 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
106}
107
Michael Krufky4a390552006-12-05 02:00:53 -0300108static void dvb_buf_release(struct videobuf_queue *q,
109 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300111 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112}
113
lawrence rust2e4e98e2010-08-25 09:50:20 -0300114static const struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 .buf_setup = dvb_buf_setup,
116 .buf_prepare = dvb_buf_prepare,
117 .buf_queue = dvb_buf_queue,
118 .buf_release = dvb_buf_release,
119};
120
121/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300122
123static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
124{
125 struct cx8802_dev *dev= fe->dvb->priv;
126 struct cx8802_driver *drv = NULL;
127 int ret = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300128 int fe_id;
129
130 fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
131 if (!fe_id) {
Steven Toth2af03ee2008-10-16 20:17:31 -0300132 printk(KERN_ERR "%s() No frontend found\n", __func__);
Steven Toth363c35f2008-10-11 11:05:50 -0300133 return -EINVAL;
134 }
135
Jonathan Nieder8a317a82011-05-01 06:29:16 -0300136 mutex_lock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300137 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
138 if (drv) {
Steven Toth363c35f2008-10-11 11:05:50 -0300139 if (acquire){
140 dev->frontends.active_fe_id = fe_id;
Michael Krufky22f3f172006-12-05 01:38:58 -0300141 ret = drv->request_acquire(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300142 } else {
Michael Krufky22f3f172006-12-05 01:38:58 -0300143 ret = drv->request_release(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300144 dev->frontends.active_fe_id = 0;
145 }
Michael Krufky22f3f172006-12-05 01:38:58 -0300146 }
Jonathan Nieder1fe70e92011-05-01 06:29:37 -0300147 mutex_unlock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300148
149 return ret;
150}
151
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300152static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
153{
154 struct videobuf_dvb_frontends *f;
155 struct videobuf_dvb_frontend *fe;
156
157 if (!core->dvbdev)
158 return;
159
160 f = &core->dvbdev->frontends;
161
162 if (!f)
163 return;
164
165 if (f->gate <= 1) /* undefined or fe0 */
166 fe = videobuf_dvb_get_frontend(f, 1);
167 else
168 fe = videobuf_dvb_get_frontend(f, f->gate);
169
170 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
171 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
172}
173
Michael Krufky22f3f172006-12-05 01:38:58 -0300174/* ------------------------------------------------------------------ */
175
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200176static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300178 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
179 static const u8 reset [] = { RESET, 0x80 };
180 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
181 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
182 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
183 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
185 mt352_write(fe, clock_config, sizeof(clock_config));
186 udelay(200);
187 mt352_write(fe, reset, sizeof(reset));
188 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
189
190 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
191 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
192 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
193 return 0;
194}
195
Chris Pascoe43eabb42006-01-09 18:21:28 -0200196static int dvico_dual_demod_init(struct dvb_frontend *fe)
197{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300198 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
199 static const u8 reset [] = { RESET, 0x80 };
200 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
201 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
202 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
203 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Chris Pascoe43eabb42006-01-09 18:21:28 -0200204
205 mt352_write(fe, clock_config, sizeof(clock_config));
206 udelay(200);
207 mt352_write(fe, reset, sizeof(reset));
208 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
209
210 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
211 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
212 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
213
214 return 0;
215}
216
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
218{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300219 static const u8 clock_config [] = { 0x89, 0x38, 0x39 };
220 static const u8 reset [] = { 0x50, 0x80 };
221 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
222 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800223 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300224 static const u8 dntv_extra[] = { 0xB5, 0x7A };
225 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
227 mt352_write(fe, clock_config, sizeof(clock_config));
228 udelay(2000);
229 mt352_write(fe, reset, sizeof(reset));
230 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
231
232 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
233 udelay(2000);
234 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
235 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
236
237 return 0;
238}
239
lawrence rust2e4e98e2010-08-25 09:50:20 -0300240static const struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300241 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200242 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243};
244
lawrence rust2e4e98e2010-08-25 09:50:20 -0300245static const struct mt352_config dntv_live_dvbt_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 .demod_address = 0x0f,
247 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248};
Chris Pascoefc40b262006-01-09 15:25:35 -0200249
lawrence rust2e4e98e2010-08-25 09:50:20 -0300250static const struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300251 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200252 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200253};
254
lawrence rust2e4e98e2010-08-25 09:50:20 -0300255static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
Stephan Wienczny70101a22009-03-10 19:08:06 -0300256 .demod_address = (0x1e >> 1),
257 .no_tuner = 1,
258 .if2 = 45600,
259};
260
Sergey Ivanov111ac842010-08-09 10:18:32 -0300261static struct mb86a16_config twinhan_vp1027 = {
262 .demod_address = 0x08,
263};
264
Trent Piephoecf854d2007-05-05 20:11:32 -0300265#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200266static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
267{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300268 static const u8 clock_config [] = { 0x89, 0x38, 0x38 };
269 static const u8 reset [] = { 0x50, 0x80 };
270 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
271 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200272 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300273 static const u8 dntv_extra[] = { 0xB5, 0x7A };
274 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200275
276 mt352_write(fe, clock_config, sizeof(clock_config));
277 udelay(2000);
278 mt352_write(fe, reset, sizeof(reset));
279 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
280
281 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
282 udelay(2000);
283 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
284 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
285
286 return 0;
287}
288
lawrence rust2e4e98e2010-08-25 09:50:20 -0300289static const struct mt352_config dntv_live_dvbt_pro_config = {
Chris Pascoefc40b262006-01-09 15:25:35 -0200290 .demod_address = 0x0f,
291 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200292 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200293};
294#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
lawrence rust2e4e98e2010-08-25 09:50:20 -0300296static const struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300297 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300298 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300299};
300
lawrence rust2e4e98e2010-08-25 09:50:20 -0300301static const struct zl10353_config dvico_fusionhdtv_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300302 .demod_address = 0x0f,
303 .if2 = 45600,
304 .no_tuner = 1,
305};
306
lawrence rust2e4e98e2010-08-25 09:50:20 -0300307static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300308 .demod_address = 0x0f,
309 .if2 = 4560,
310 .no_tuner = 1,
311 .demod_init = dvico_fusionhdtv_demod_init,
312};
313
lawrence rust2e4e98e2010-08-25 09:50:20 -0300314static const struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300315 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300316};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300317
lawrence rust2e4e98e2010-08-25 09:50:20 -0300318static const struct cx22702_config connexant_refboard_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700320 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321};
322
lawrence rust2e4e98e2010-08-25 09:50:20 -0300323static const struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300324 .demod_address = 0x63,
325 .output_mode = CX22702_SERIAL_OUTPUT,
326};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327
Michael Krufky4a390552006-12-05 02:00:53 -0300328static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329{
330 struct cx8802_dev *dev= fe->dvb->priv;
331 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
332 return 0;
333}
334
lawrence rust2e4e98e2010-08-25 09:50:20 -0300335static const struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300336 .demod_address = 0x15,
337 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339
Michael Krufky6ddcc912005-07-27 11:46:00 -0700340static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700341{
342 struct cx8802_dev *dev= fe->dvb->priv;
343 struct cx88_core *core = dev->core;
344
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300345 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700346 if (index == 0)
347 cx_clear(MO_GP0_IO, 8);
348 else
349 cx_set(MO_GP0_IO, 8);
350 return 0;
351}
352
Michael Krufky6ddcc912005-07-27 11:46:00 -0700353static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700354{
355 struct cx8802_dev *dev= fe->dvb->priv;
356 if (is_punctured)
357 dev->ts_gen_cntrl |= 0x04;
358 else
359 dev->ts_gen_cntrl &= ~0x04;
360 return 0;
361}
362
Michael Krufky6ddcc912005-07-27 11:46:00 -0700363static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300364 .demod_address = 0x0e,
365 .demod_chip = LGDT3302,
366 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
367 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700368};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700369
lawrence rust2e4e98e2010-08-25 09:50:20 -0300370static const struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300371 .demod_address = 0x0e,
372 .demod_chip = LGDT3303,
373 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
374 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700375};
Rusty Scottda215d22006-04-07 02:21:31 -0300376
lawrence rust2e4e98e2010-08-25 09:50:20 -0300377static const struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300378 .demod_address = 0x59,
379 .demod_chip = LGDT3303,
380 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
381 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300382};
Michael Krufkyf1798492005-07-07 17:58:39 -0700383
Michael Krufky4a390552006-12-05 02:00:53 -0300384static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800385{
386 struct cx8802_dev *dev= fe->dvb->priv;
387 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
388 return 0;
389}
390
lawrence rust2e4e98e2010-08-25 09:50:20 -0300391static const struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300392 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300393 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800394};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800395
Steven Toth0fa14aa2006-01-09 15:25:02 -0200396static int cx24123_set_ts_param(struct dvb_frontend* fe,
397 int is_punctured)
398{
399 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300400 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200401 return 0;
402}
403
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300404static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
405 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200406{
407 struct cx8802_dev *dev= fe->dvb->priv;
408 struct cx88_core *core = dev->core;
409
Michael Krufky4a390552006-12-05 02:00:53 -0300410 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300411 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300412 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300413 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300414
415 if (core->prev_set_voltage)
416 return core->prev_set_voltage(fe, voltage);
417 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200418}
419
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300420static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
421 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300422{
423 struct cx8802_dev *dev= fe->dvb->priv;
424 struct cx88_core *core = dev->core;
425
426 if (voltage == SEC_VOLTAGE_OFF) {
427 dprintk(1,"LNB Voltage OFF\n");
428 cx_write(MO_GP0_IO, 0x0000efff);
429 }
430
431 if (core->prev_set_voltage)
432 return core->prev_set_voltage(fe, voltage);
433 return 0;
434}
435
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300436static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
437 fe_sec_voltage_t voltage)
438{
439 struct cx8802_dev *dev= fe->dvb->priv;
440 struct cx88_core *core = dev->core;
441
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300442 cx_set(MO_GP0_IO, 0x6040);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300443 switch (voltage) {
Sergey Ivanov111ac842010-08-09 10:18:32 -0300444 case SEC_VOLTAGE_13:
445 cx_clear(MO_GP0_IO, 0x20);
446 break;
447 case SEC_VOLTAGE_18:
448 cx_set(MO_GP0_IO, 0x20);
449 break;
450 case SEC_VOLTAGE_OFF:
451 cx_clear(MO_GP0_IO, 0x20);
452 break;
453 }
454
455 if (core->prev_set_voltage)
456 return core->prev_set_voltage(fe, voltage);
457 return 0;
458}
459
460static int vp1027_set_voltage(struct dvb_frontend *fe,
461 fe_sec_voltage_t voltage)
462{
463 struct cx8802_dev *dev = fe->dvb->priv;
464 struct cx88_core *core = dev->core;
465
466 switch (voltage) {
467 case SEC_VOLTAGE_13:
468 dprintk(1, "LNB SEC Voltage=13\n");
469 cx_write(MO_GP0_IO, 0x00001220);
470 break;
471 case SEC_VOLTAGE_18:
472 dprintk(1, "LNB SEC Voltage=18\n");
473 cx_write(MO_GP0_IO, 0x00001222);
474 break;
475 case SEC_VOLTAGE_OFF:
476 dprintk(1, "LNB Voltage OFF\n");
477 cx_write(MO_GP0_IO, 0x00001230);
478 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300479 }
480
481 if (core->prev_set_voltage)
482 return core->prev_set_voltage(fe, voltage);
483 return 0;
484}
485
lawrence rust2e4e98e2010-08-25 09:50:20 -0300486static const struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300487 .demod_address = 0x55,
488 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300489};
490
lawrence rust2e4e98e2010-08-25 09:50:20 -0300491static const struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300492 .demod_address = 0x55,
493 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200494};
495
lawrence rust2e4e98e2010-08-25 09:50:20 -0300496static const struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300497 .demod_address = 0x15,
498 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300499 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200500};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200501
lawrence rust2e4e98e2010-08-25 09:50:20 -0300502static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300503 .demod_address = 0x32 >> 1,
504 .output_mode = S5H1409_PARALLEL_OUTPUT,
505 .gpio = S5H1409_GPIO_ON,
506 .qam_if = 44000,
507 .inversion = S5H1409_INVERSION_OFF,
508 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300509 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300510};
511
lawrence rust2e4e98e2010-08-25 09:50:20 -0300512static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
Steven Toth5c00fac2008-04-22 14:45:14 -0300513 .demod_address = 0x32 >> 1,
514 .output_mode = S5H1409_SERIAL_OUTPUT,
515 .gpio = S5H1409_GPIO_OFF,
516 .inversion = S5H1409_INVERSION_OFF,
517 .status_mode = S5H1409_DEMODLOCKING,
518 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
519};
520
lawrence rust2e4e98e2010-08-25 09:50:20 -0300521static const struct s5h1409_config kworld_atsc_120_config = {
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300522 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300523 .output_mode = S5H1409_SERIAL_OUTPUT,
524 .gpio = S5H1409_GPIO_OFF,
525 .inversion = S5H1409_INVERSION_OFF,
526 .status_mode = S5H1409_DEMODLOCKING,
527 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
528};
529
lawrence rust2e4e98e2010-08-25 09:50:20 -0300530static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300531 .i2c_address = 0x64,
532 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300533};
534
lawrence rust2e4e98e2010-08-25 09:50:20 -0300535static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
Stéphane Voltz3f6014f2008-09-05 14:33:54 -0300536 .demod_address = (0x1e >> 1),
537 .no_tuner = 1,
538 .if2 = 45600,
539};
540
lawrence rust2e4e98e2010-08-25 09:50:20 -0300541static const struct zl10353_config cx88_geniatech_x8000_mt = {
Mauro Carvalho Chehab57069342009-08-20 10:14:45 -0300542 .demod_address = (0x1e >> 1),
543 .no_tuner = 1,
544 .disable_i2c_gate_ctrl = 1,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300545};
546
lawrence rust2e4e98e2010-08-25 09:50:20 -0300547static const struct s5h1411_config dvico_fusionhdtv7_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300548 .output_mode = S5H1411_SERIAL_OUTPUT,
549 .gpio = S5H1411_GPIO_ON,
550 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
551 .qam_if = S5H1411_IF_44000,
552 .vsb_if = S5H1411_IF_44000,
553 .inversion = S5H1411_INVERSION_OFF,
554 .status_mode = S5H1411_DEMODLOCKING
555};
556
lawrence rust2e4e98e2010-08-25 09:50:20 -0300557static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300558 .i2c_address = 0xc2 >> 1,
559 .if_khz = 5380,
Steven Tothd893d5d2008-04-25 03:46:43 -0300560};
561
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300562static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
563{
564 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -0300565 struct videobuf_dvb_frontend *fe0 = NULL;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300566 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300567 struct xc2028_config cfg = {
568 .i2c_adap = &dev->core->i2c_adap,
569 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300570 .ctrl = &ctl,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300571 };
572
Darron Broad92abe9e2008-10-11 11:18:53 -0300573 /* Get the first frontend */
Steven Toth363c35f2008-10-11 11:05:50 -0300574 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
575 if (!fe0)
576 return -EINVAL;
577
578 if (!fe0->dvb.frontend) {
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300579 printk(KERN_ERR "%s/2: dvb frontend not attached. "
580 "Can't attach xc3028\n",
581 dev->core->name);
582 return -EINVAL;
583 }
584
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300585 /*
586 * Some xc3028 devices may be hidden by an I2C gate. This is known
587 * to happen with some s5h1409-based devices.
588 * Now that I2C gate is open, sets up xc3028 configuration
589 */
590 cx88_setup_xc3028(dev->core, &ctl);
591
Steven Toth363c35f2008-10-11 11:05:50 -0300592 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300593 if (!fe) {
594 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
595 dev->core->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300596 dvb_frontend_detach(fe0->dvb.frontend);
597 dvb_unregister_frontend(fe0->dvb.frontend);
598 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300599 return -EINVAL;
600 }
601
602 printk(KERN_INFO "%s/2: xc3028 attached\n",
603 dev->core->name);
604
605 return 0;
606}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300607
Steven Toth5bd1b662008-09-04 01:17:33 -0300608static int cx24116_set_ts_param(struct dvb_frontend *fe,
609 int is_punctured)
610{
611 struct cx8802_dev *dev = fe->dvb->priv;
612 dev->ts_gen_cntrl = 0x2;
613
614 return 0;
615}
616
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300617static int stv0900_set_ts_param(struct dvb_frontend *fe,
618 int is_punctured)
619{
620 struct cx8802_dev *dev = fe->dvb->priv;
621 dev->ts_gen_cntrl = 0;
622
623 return 0;
624}
625
Steven Toth5bd1b662008-09-04 01:17:33 -0300626static int cx24116_reset_device(struct dvb_frontend *fe)
627{
628 struct cx8802_dev *dev = fe->dvb->priv;
629 struct cx88_core *core = dev->core;
630
631 /* Reset the part */
Steven Toth363c35f2008-10-11 11:05:50 -0300632 /* Put the cx24116 into reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300633 cx_write(MO_SRST_IO, 0);
634 msleep(10);
Steven Toth363c35f2008-10-11 11:05:50 -0300635 /* Take the cx24116 out of reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300636 cx_write(MO_SRST_IO, 1);
637 msleep(10);
638
639 return 0;
640}
641
lawrence rust2e4e98e2010-08-25 09:50:20 -0300642static const struct cx24116_config hauppauge_hvr4000_config = {
Steven Toth5bd1b662008-09-04 01:17:33 -0300643 .demod_address = 0x05,
644 .set_ts_params = cx24116_set_ts_param,
645 .reset_device = cx24116_reset_device,
646};
647
lawrence rust2e4e98e2010-08-25 09:50:20 -0300648static const struct cx24116_config tevii_s460_config = {
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300649 .demod_address = 0x55,
650 .set_ts_params = cx24116_set_ts_param,
651 .reset_device = cx24116_reset_device,
652};
653
Igor M. Liplianin0cb73632011-02-25 18:41:24 -0300654static int ds3000_set_ts_param(struct dvb_frontend *fe,
655 int is_punctured)
656{
657 struct cx8802_dev *dev = fe->dvb->priv;
658 dev->ts_gen_cntrl = 4;
659
660 return 0;
661}
662
663static struct ds3000_config tevii_ds3000_config = {
664 .demod_address = 0x68,
665 .set_ts_params = ds3000_set_ts_param,
666};
667
lawrence rust2e4e98e2010-08-25 09:50:20 -0300668static const struct stv0900_config prof_7301_stv0900_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300669 .demod_address = 0x6a,
670/* demod_mode = 0,*/
671 .xtal = 27000000,
672 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
673 .diseqc_mode = 2,/* 2/3 PWM */
674 .tun1_maddress = 0,/* 0x60 */
675 .tun1_adc = 0,/* 2 Vpp */
676 .path1_mode = 3,
677 .set_ts_params = stv0900_set_ts_param,
678};
679
lawrence rust2e4e98e2010-08-25 09:50:20 -0300680static const struct stb6100_config prof_7301_stb6100_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300681 .tuner_address = 0x60,
682 .refclock = 27000000,
683};
684
lawrence rust2e4e98e2010-08-25 09:50:20 -0300685static const struct stv0299_config tevii_tuner_sharp_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300686 .demod_address = 0x68,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300687 .inittab = sharp_z0194a_inittab,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300688 .mclk = 88000000UL,
689 .invert = 1,
690 .skip_reinit = 0,
691 .lock_output = 1,
692 .volt13_op0_op1 = STV0299_VOLT13_OP1,
693 .min_delay_ms = 100,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300694 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300695 .set_ts_params = cx24116_set_ts_param,
696};
697
lawrence rust2e4e98e2010-08-25 09:50:20 -0300698static const struct stv0288_config tevii_tuner_earda_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300699 .demod_address = 0x68,
700 .min_delay_ms = 100,
701 .set_ts_params = cx24116_set_ts_param,
702};
703
Andy Walls6e0e12f2009-01-11 21:18:04 -0300704static int cx8802_alloc_frontends(struct cx8802_dev *dev)
705{
706 struct cx88_core *core = dev->core;
707 struct videobuf_dvb_frontend *fe = NULL;
708 int i;
709
710 mutex_init(&dev->frontends.lock);
711 INIT_LIST_HEAD(&dev->frontends.felist);
712
713 if (!core->board.num_frontends)
714 return -ENODEV;
715
716 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
717 core->board.num_frontends);
718 for (i = 1; i <= core->board.num_frontends; i++) {
719 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
720 if (!fe) {
721 printk(KERN_ERR "%s() failed to alloc\n", __func__);
722 videobuf_dvb_dealloc_frontends(&dev->frontends);
723 return -ENOMEM;
724 }
725 }
726 return 0;
727}
728
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300729
730
lawrence rust2e4e98e2010-08-25 09:50:20 -0300731static const u8 samsung_smt_7020_inittab[] = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300732 0x01, 0x15,
733 0x02, 0x00,
734 0x03, 0x00,
735 0x04, 0x7D,
736 0x05, 0x0F,
737 0x06, 0x02,
738 0x07, 0x00,
739 0x08, 0x60,
740
741 0x0A, 0xC2,
742 0x0B, 0x00,
743 0x0C, 0x01,
744 0x0D, 0x81,
745 0x0E, 0x44,
746 0x0F, 0x09,
747 0x10, 0x3C,
748 0x11, 0x84,
749 0x12, 0xDA,
750 0x13, 0x99,
751 0x14, 0x8D,
752 0x15, 0xCE,
753 0x16, 0xE8,
754 0x17, 0x43,
755 0x18, 0x1C,
756 0x19, 0x1B,
757 0x1A, 0x1D,
758
759 0x1C, 0x12,
760 0x1D, 0x00,
761 0x1E, 0x00,
762 0x1F, 0x00,
763 0x20, 0x00,
764 0x21, 0x00,
765 0x22, 0x00,
766 0x23, 0x00,
767
768 0x28, 0x02,
769 0x29, 0x28,
770 0x2A, 0x14,
771 0x2B, 0x0F,
772 0x2C, 0x09,
773 0x2D, 0x05,
774
775 0x31, 0x1F,
776 0x32, 0x19,
777 0x33, 0xFC,
778 0x34, 0x13,
779 0xff, 0xff,
780};
781
782
783static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe,
784 struct dvb_frontend_parameters *params)
785{
786 struct cx8802_dev *dev = fe->dvb->priv;
787 u8 buf[4];
788 u32 div;
789 struct i2c_msg msg = {
790 .addr = 0x61,
791 .flags = 0,
792 .buf = buf,
793 .len = sizeof(buf) };
794
795 div = params->frequency / 125;
796
797 buf[0] = (div >> 8) & 0x7f;
798 buf[1] = div & 0xff;
799 buf[2] = 0x84; /* 0xC4 */
800 buf[3] = 0x00;
801
802 if (params->frequency < 1500000)
803 buf[3] |= 0x10;
804
805 if (fe->ops.i2c_gate_ctrl)
806 fe->ops.i2c_gate_ctrl(fe, 1);
807
808 if (i2c_transfer(&dev->core->i2c_adap, &msg, 1) != 1)
809 return -EIO;
810
811 return 0;
812}
813
814static int samsung_smt_7020_set_tone(struct dvb_frontend *fe,
815 fe_sec_tone_mode_t tone)
816{
817 struct cx8802_dev *dev = fe->dvb->priv;
818 struct cx88_core *core = dev->core;
819
820 cx_set(MO_GP0_IO, 0x0800);
821
822 switch (tone) {
823 case SEC_TONE_ON:
824 cx_set(MO_GP0_IO, 0x08);
825 break;
826 case SEC_TONE_OFF:
827 cx_clear(MO_GP0_IO, 0x08);
828 break;
829 default:
830 return -EINVAL;
831 }
832
833 return 0;
834}
835
836static int samsung_smt_7020_set_voltage(struct dvb_frontend *fe,
837 fe_sec_voltage_t voltage)
838{
839 struct cx8802_dev *dev = fe->dvb->priv;
840 struct cx88_core *core = dev->core;
841
842 u8 data;
843 struct i2c_msg msg = {
844 .addr = 8,
845 .flags = 0,
846 .buf = &data,
847 .len = sizeof(data) };
848
849 cx_set(MO_GP0_IO, 0x8000);
850
851 switch (voltage) {
852 case SEC_VOLTAGE_OFF:
853 break;
854 case SEC_VOLTAGE_13:
855 data = ISL6421_EN1 | ISL6421_LLC1;
856 cx_clear(MO_GP0_IO, 0x80);
857 break;
858 case SEC_VOLTAGE_18:
859 data = ISL6421_EN1 | ISL6421_LLC1 | ISL6421_VSEL1;
860 cx_clear(MO_GP0_IO, 0x80);
861 break;
862 default:
863 return -EINVAL;
864 };
865
866 return (i2c_transfer(&dev->core->i2c_adap, &msg, 1) == 1) ? 0 : -EIO;
867}
868
869static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
870 u32 srate, u32 ratio)
871{
872 u8 aclk = 0;
873 u8 bclk = 0;
874
875 if (srate < 1500000) {
876 aclk = 0xb7;
877 bclk = 0x47;
878 } else if (srate < 3000000) {
879 aclk = 0xb7;
880 bclk = 0x4b;
881 } else if (srate < 7000000) {
882 aclk = 0xb7;
883 bclk = 0x4f;
884 } else if (srate < 14000000) {
885 aclk = 0xb7;
886 bclk = 0x53;
887 } else if (srate < 30000000) {
888 aclk = 0xb6;
889 bclk = 0x53;
890 } else if (srate < 45000000) {
891 aclk = 0xb4;
892 bclk = 0x51;
893 }
894
895 stv0299_writereg(fe, 0x13, aclk);
896 stv0299_writereg(fe, 0x14, bclk);
897 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
898 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
899 stv0299_writereg(fe, 0x21, ratio & 0xf0);
900
901 return 0;
902}
903
904
lawrence rust2e4e98e2010-08-25 09:50:20 -0300905static const struct stv0299_config samsung_stv0299_config = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300906 .demod_address = 0x68,
907 .inittab = samsung_smt_7020_inittab,
908 .mclk = 88000000UL,
909 .invert = 0,
910 .skip_reinit = 0,
911 .lock_output = STV0299_LOCKOUTPUT_LK,
912 .volt13_op0_op1 = STV0299_VOLT13_OP1,
913 .min_delay_ms = 100,
914 .set_symbol_rate = samsung_smt_7020_stv0299_set_symbol_rate,
915};
916
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917static int dvb_register(struct cx8802_dev *dev)
918{
Steven Toth363c35f2008-10-11 11:05:50 -0300919 struct cx88_core *core = dev->core;
920 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
Darron Broad59b18422008-10-11 11:44:05 -0300921 int mfe_shared = 0; /* bus not shared by default */
Steven Toth363c35f2008-10-11 11:05:50 -0300922
Matthias Schwarzott0e8bac92008-10-24 10:47:07 -0300923 if (0 != core->i2c_rc) {
924 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
925 goto frontend_detach;
926 }
927
Steven Toth363c35f2008-10-11 11:05:50 -0300928 /* Get the first frontend */
929 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
930 if (!fe0)
Darron Broad60a5a922008-11-11 08:48:27 -0300931 goto frontend_detach;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932
Darron Broad8e739092008-10-11 11:31:41 -0300933 /* multi-frontend gate control is undefined or defaults to fe0 */
934 dev->frontends.gate = 0;
935
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300936 /* Sets the gate control callback to be used by i2c command calls */
937 core->gate_ctrl = cx88_dvb_gate_ctrl;
938
Darron Broad8e739092008-10-11 11:31:41 -0300939 /* init frontend(s) */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300940 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -0300942 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300943 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300944 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300945 if (fe0->dvb.frontend != NULL) {
946 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300947 0x61, &core->i2c_adap,
948 DVB_PLL_THOMSON_DTT759X))
949 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300950 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700952 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200954 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800955 case CX88_BOARD_WINFAST_DTV1000:
Steven Toth363c35f2008-10-11 11:05:50 -0300956 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300957 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300958 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300959 if (fe0->dvb.frontend != NULL) {
960 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300961 0x60, &core->i2c_adap,
962 DVB_PLL_THOMSON_DTT7579))
963 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300964 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300966 case CX88_BOARD_WINFAST_DTV2000H:
Vlastimil Labsky4d14c832009-08-10 22:15:54 -0300967 case CX88_BOARD_WINFAST_DTV2000H_J:
Steven Toth611900c2006-01-09 15:25:12 -0200968 case CX88_BOARD_HAUPPAUGE_HVR1100:
969 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300970 case CX88_BOARD_HAUPPAUGE_HVR1300:
Steven Toth363c35f2008-10-11 11:05:50 -0300971 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300972 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300973 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300974 if (fe0->dvb.frontend != NULL) {
975 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300976 &core->i2c_adap, 0x61,
977 TUNER_PHILIPS_FMD1216ME_MK3))
978 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300979 }
Steven Toth611900c2006-01-09 15:25:12 -0200980 break;
Steven Toth363c35f2008-10-11 11:05:50 -0300981 case CX88_BOARD_HAUPPAUGE_HVR3000:
Darron Broad60a5a922008-11-11 08:48:27 -0300982 /* MFE frontend 1 */
983 mfe_shared = 1;
984 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -0300985 /* DVB-S init */
986 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Darron Broad60a5a922008-11-11 08:48:27 -0300987 &hauppauge_novas_config,
988 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300989 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -0300990 if (!dvb_attach(isl6421_attach,
991 fe0->dvb.frontend,
992 &dev->core->i2c_adap,
993 0x08, ISL6421_DCL, 0x00))
994 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300995 }
Darron Broad60a5a922008-11-11 08:48:27 -0300996 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -0300997 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -0300998 if (!fe1)
999 goto frontend_detach;
1000 /* DVB-T init */
1001 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1002 &hauppauge_hvr_config,
1003 &dev->core->i2c_adap);
1004 if (fe1->dvb.frontend) {
1005 fe1->dvb.frontend->id = 1;
1006 if (!dvb_attach(simple_tuner_attach,
1007 fe1->dvb.frontend,
1008 &dev->core->i2c_adap,
1009 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1010 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001011 }
1012 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001013 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001014 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001015 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001016 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001017 if (fe0->dvb.frontend != NULL) {
1018 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001019 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1020 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001021 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001022 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001023 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001024 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001025 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001026 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001027 if (fe0->dvb.frontend != NULL) {
1028 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001029 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1030 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001031 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001032 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001033 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001034 /* The tin box says DEE1601, but it seems to be DTT7579
1035 * compatible, with a slightly different MT352 AGC gain. */
Steven Toth363c35f2008-10-11 11:05:50 -03001036 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001037 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001038 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001039 if (fe0->dvb.frontend != NULL) {
1040 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001041 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1042 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001043 break;
1044 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001045 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001046 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001047 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001048 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001049 if (fe0->dvb.frontend != NULL) {
1050 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001051 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1052 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001053 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001054 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -03001056 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001057 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001058 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001059 if (fe0->dvb.frontend != NULL) {
1060 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001061 0x61, NULL, DVB_PLL_LG_Z201))
1062 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001063 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001064 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065 case CX88_BOARD_KWORLD_DVB_T:
1066 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001067 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Steven Toth363c35f2008-10-11 11:05:50 -03001068 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001069 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001070 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001071 if (fe0->dvb.frontend != NULL) {
1072 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001073 0x61, NULL, DVB_PLL_UNKNOWN_1))
1074 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001075 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076 break;
Chris Pascoefc40b262006-01-09 15:25:35 -02001077 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -03001078#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -03001079 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Steven Toth363c35f2008-10-11 11:05:50 -03001080 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -03001081 &dev->vp3054->adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001082 if (fe0->dvb.frontend != NULL) {
1083 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001084 &core->i2c_adap, 0x61,
1085 TUNER_PHILIPS_FMD1216ME_MK3))
1086 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001087 }
Chris Pascoefc40b262006-01-09 15:25:35 -02001088#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001089 printk(KERN_ERR "%s/2: built without vp3054 support\n",
1090 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -02001091#endif
1092 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001093 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001094 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001095 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001096 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001097 if (fe0->dvb.frontend != NULL) {
1098 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001099 &core->i2c_adap, 0x61,
1100 TUNER_THOMSON_FE6600))
1101 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001102 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001103 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001104 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
Steven Toth363c35f2008-10-11 11:05:50 -03001105 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001106 &dvico_fusionhdtv_xc3028,
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 fe0->dvb.frontend = dvb_attach(mt352_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001110 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001111 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -03001112 /*
1113 * On this board, the demod provides the I2C bus pullup.
1114 * We must not permit gate_ctrl to be performed, or
1115 * the xc3028 cannot communicate on the bus.
1116 */
Steven Toth363c35f2008-10-11 11:05:50 -03001117 if (fe0->dvb.frontend)
1118 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001119 if (attach_xc3028(0x61, dev) < 0)
Darron Broadbecd4302008-10-21 11:47:50 -03001120 goto frontend_detach;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001121 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 case CX88_BOARD_PCHDTV_HD3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001123 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001124 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001125 if (fe0->dvb.frontend != NULL) {
1126 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001127 &core->i2c_adap, 0x61,
1128 TUNER_THOMSON_DTT761X))
1129 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001130 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131 break;
Michael Krufkyf1798492005-07-07 17:58:39 -07001132 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
1133 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -07001134
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001135 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -07001136 cx_clear(MO_GP0_IO, 1);
1137 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001138 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -07001139 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001140
1141 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -07001142 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Steven Toth363c35f2008-10-11 11:05:50 -03001143 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001144 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001145 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001146 if (fe0->dvb.frontend != NULL) {
1147 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001148 &core->i2c_adap, 0x61,
1149 TUNER_MICROTUNE_4042FI5))
1150 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -07001151 }
1152 break;
Michael Krufky0d723c02005-07-07 17:58:42 -07001153 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
1154 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -07001155
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001156 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -07001157 cx_clear(MO_GP0_IO, 1);
1158 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -07001159 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -07001160 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001161 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001162 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001163 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001164 if (fe0->dvb.frontend != NULL) {
1165 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001166 &core->i2c_adap, 0x61,
1167 TUNER_THOMSON_DTT761X))
1168 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -07001169 }
1170 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001171 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
1172 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001173
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001174 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001175 cx_clear(MO_GP0_IO, 1);
1176 mdelay(100);
1177 cx_set(MO_GP0_IO, 1);
1178 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001179 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001180 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001181 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001182 if (fe0->dvb.frontend != NULL) {
1183 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001184 &core->i2c_adap, 0x61,
1185 TUNER_LG_TDVS_H06XF))
1186 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001187 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001188 &core->i2c_adap, 0x43))
1189 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001190 }
1191 break;
Rusty Scottda215d22006-04-07 02:21:31 -03001192 case CX88_BOARD_PCHDTV_HD5500:
1193 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -03001194
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001195 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -03001196 cx_clear(MO_GP0_IO, 1);
1197 mdelay(100);
1198 cx_set(MO_GP0_IO, 1);
1199 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001200 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001201 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001202 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001203 if (fe0->dvb.frontend != NULL) {
1204 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001205 &core->i2c_adap, 0x61,
1206 TUNER_LG_TDVS_H06XF))
1207 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001208 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001209 &core->i2c_adap, 0x43))
1210 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -03001211 }
1212 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -08001213 case CX88_BOARD_ATI_HDTVWONDER:
Steven Toth363c35f2008-10-11 11:05:50 -03001214 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001215 &ati_hdtvwonder,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001216 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001217 if (fe0->dvb.frontend != NULL) {
1218 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001219 &core->i2c_adap, 0x61,
1220 TUNER_PHILIPS_TUV1236D))
1221 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001222 }
Kirk Laprayfde6d312005-11-08 21:38:18 -08001223 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -02001224 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
1225 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Steven Toth363c35f2008-10-11 11:05:50 -03001226 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001227 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001228 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001229 if (fe0->dvb.frontend) {
1230 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
Steven Toth83fe92e2008-09-13 19:22:15 -03001231 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001232 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001233 }
Steven Toth0fa14aa2006-01-09 15:25:02 -02001234 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -02001235 case CX88_BOARD_KWORLD_DVBS_100:
Steven Toth363c35f2008-10-11 11:05:50 -03001236 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001237 &kworld_dvbs_100_config,
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 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1241 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001242 }
Vadim Catana0e0351e2006-01-09 15:25:02 -02001243 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001244 case CX88_BOARD_GENIATECH_DVBS:
Steven Toth363c35f2008-10-11 11:05:50 -03001245 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001246 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001247 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001248 if (fe0->dvb.frontend) {
1249 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1250 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001251 }
1252 break;
Steven Toth60464da2008-01-05 16:53:01 -03001253 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth363c35f2008-10-11 11:05:50 -03001254 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth60464da2008-01-05 16:53:01 -03001255 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001256 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001257 if (fe0->dvb.frontend != NULL) {
1258 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001259 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001260 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001261 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -03001262 }
1263 break;
Steven Toth5c00fac2008-04-22 14:45:14 -03001264 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
Steven Toth363c35f2008-10-11 11:05:50 -03001265 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth5c00fac2008-04-22 14:45:14 -03001266 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001267 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001268 if (fe0->dvb.frontend != NULL) {
Steven Toth5c00fac2008-04-22 14:45:14 -03001269 struct dvb_frontend *fe;
1270 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001271 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -03001272 .i2c_addr = 0x61,
Steven Toth5c00fac2008-04-22 14:45:14 -03001273 };
1274 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001275 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -03001276 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -03001277 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -03001278 };
1279
1280 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001281 fe0->dvb.frontend, &cfg);
Steven Toth5c00fac2008-04-22 14:45:14 -03001282 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1283 fe->ops.tuner_ops.set_config(fe, &ctl);
1284 }
1285 break;
Ricardo Maraschinid49f7a22010-04-06 02:40:43 -03001286 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
Miroslav Sustek3047a172009-05-31 16:47:28 -03001287 case CX88_BOARD_WINFAST_DTV1800H:
Steven Toth363c35f2008-10-11 11:05:50 -03001288 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001289 &cx88_pinnacle_hybrid_pctv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001290 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001291 if (fe0->dvb.frontend) {
1292 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001293 if (attach_xc3028(0x61, dev) < 0)
1294 goto frontend_detach;
1295 }
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001296 break;
1297 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001298 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001299
Steven Toth363c35f2008-10-11 11:05:50 -03001300 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001301 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001302 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001303 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001304 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001305 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001306 case CX88_BOARD_KWORLD_ATSC_120:
Steven Toth363c35f2008-10-11 11:05:50 -03001307 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001308 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001309 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001310 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001311 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001312 break;
Steven Tothd893d5d2008-04-25 03:46:43 -03001313 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
Steven Toth363c35f2008-10-11 11:05:50 -03001314 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Steven Tothd893d5d2008-04-25 03:46:43 -03001315 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001316 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001317 if (fe0->dvb.frontend != NULL) {
1318 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001319 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001320 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001321 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -03001322 }
1323 break;
Steven Toth5bd1b662008-09-04 01:17:33 -03001324 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad60a5a922008-11-11 08:48:27 -03001325 /* MFE frontend 1 */
1326 mfe_shared = 1;
1327 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001328 /* DVB-S/S2 Init */
1329 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001330 &hauppauge_hvr4000_config,
1331 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001332 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001333 if (!dvb_attach(isl6421_attach,
1334 fe0->dvb.frontend,
1335 &dev->core->i2c_adap,
1336 0x08, ISL6421_DCL, 0x00))
1337 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001338 }
Darron Broad60a5a922008-11-11 08:48:27 -03001339 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001340 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001341 if (!fe1)
1342 goto frontend_detach;
1343 /* DVB-T Init */
1344 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1345 &hauppauge_hvr_config,
1346 &dev->core->i2c_adap);
1347 if (fe1->dvb.frontend) {
1348 fe1->dvb.frontend->id = 1;
1349 if (!dvb_attach(simple_tuner_attach,
1350 fe1->dvb.frontend,
1351 &dev->core->i2c_adap,
1352 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1353 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001354 }
1355 break;
1356 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1357 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001358 &hauppauge_hvr4000_config,
1359 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001360 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001361 if (!dvb_attach(isl6421_attach,
1362 fe0->dvb.frontend,
1363 &dev->core->i2c_adap,
1364 0x08, ISL6421_DCL, 0x00))
1365 goto frontend_detach;
Steven Toth5bd1b662008-09-04 01:17:33 -03001366 }
1367 break;
Igor M. Liplianincd3cde12008-11-09 15:26:25 -03001368 case CX88_BOARD_PROF_6200:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001369 case CX88_BOARD_TBS_8910:
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001370 case CX88_BOARD_TEVII_S420:
Steven Toth363c35f2008-10-11 11:05:50 -03001371 fe0->dvb.frontend = dvb_attach(stv0299_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001372 &tevii_tuner_sharp_config,
1373 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001374 if (fe0->dvb.frontend != NULL) {
1375 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001376 &core->i2c_adap, DVB_PLL_OPERA1))
1377 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001378 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1379 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001380
1381 } else {
Steven Toth363c35f2008-10-11 11:05:50 -03001382 fe0->dvb.frontend = dvb_attach(stv0288_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001383 &tevii_tuner_earda_config,
1384 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001385 if (fe0->dvb.frontend != NULL) {
1386 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001387 &core->i2c_adap))
1388 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001389 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1390 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001391 }
1392 }
1393 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001394 case CX88_BOARD_TEVII_S460:
Steven Toth363c35f2008-10-11 11:05:50 -03001395 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001396 &tevii_s460_config,
1397 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001398 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001399 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001400 break;
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001401 case CX88_BOARD_TEVII_S464:
1402 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1403 &tevii_ds3000_config,
1404 &core->i2c_adap);
1405 if (fe0->dvb.frontend != NULL)
1406 fe0->dvb.frontend->ops.set_voltage =
1407 tevii_dvbs_set_voltage;
1408 break;
Oleg Roitburd4cd7fb82008-09-17 11:30:21 -03001409 case CX88_BOARD_OMICOM_SS4_PCI:
Oleg Roitburdee730422008-09-17 11:58:33 -03001410 case CX88_BOARD_TBS_8920:
Oleg Roitburd57f51db2008-10-08 06:48:08 -03001411 case CX88_BOARD_PROF_7300:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001412 case CX88_BOARD_SATTRADE_ST4200:
Steven Toth363c35f2008-10-11 11:05:50 -03001413 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Oleg Roitburdee730422008-09-17 11:58:33 -03001414 &hauppauge_hvr4000_config,
1415 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001416 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001417 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Oleg Roitburdee730422008-09-17 11:58:33 -03001418 break;
Stephan Wienczny70101a22009-03-10 19:08:06 -03001419 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
1420 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1421 &cx88_terratec_cinergy_ht_pci_mkii_config,
1422 &core->i2c_adap);
1423 if (fe0->dvb.frontend) {
1424 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1425 if (attach_xc3028(0x61, dev) < 0)
1426 goto frontend_detach;
1427 }
1428 break;
Igor M. Liplianinb699c272009-11-16 22:22:32 -03001429 case CX88_BOARD_PROF_7301:{
1430 struct dvb_tuner_ops *tuner_ops = NULL;
1431
1432 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1433 &prof_7301_stv0900_config,
1434 &core->i2c_adap, 0);
1435 if (fe0->dvb.frontend != NULL) {
1436 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1437 &prof_7301_stb6100_config,
1438 &core->i2c_adap))
1439 goto frontend_detach;
1440
1441 tuner_ops = &fe0->dvb.frontend->ops.tuner_ops;
1442 tuner_ops->set_frequency = stb6100_set_freq;
1443 tuner_ops->get_frequency = stb6100_get_freq;
1444 tuner_ops->set_bandwidth = stb6100_set_bandw;
1445 tuner_ops->get_bandwidth = stb6100_get_bandw;
1446
1447 core->prev_set_voltage =
1448 fe0->dvb.frontend->ops.set_voltage;
1449 fe0->dvb.frontend->ops.set_voltage =
1450 tevii_dvbs_set_voltage;
1451 }
1452 break;
1453 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001454 case CX88_BOARD_SAMSUNG_SMT_7020:
1455 dev->ts_gen_cntrl = 0x08;
1456
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001457 cx_set(MO_GP0_IO, 0x0101);
1458
1459 cx_clear(MO_GP0_IO, 0x01);
1460 mdelay(100);
1461 cx_set(MO_GP0_IO, 0x01);
1462 mdelay(200);
1463
1464 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1465 &samsung_stv0299_config,
1466 &dev->core->i2c_adap);
1467 if (fe0->dvb.frontend) {
1468 fe0->dvb.frontend->ops.tuner_ops.set_params =
1469 samsung_smt_7020_tuner_set_params;
1470 fe0->dvb.frontend->tuner_priv =
1471 &dev->core->i2c_adap;
1472 fe0->dvb.frontend->ops.set_voltage =
1473 samsung_smt_7020_set_voltage;
1474 fe0->dvb.frontend->ops.set_tone =
1475 samsung_smt_7020_set_tone;
1476 }
1477
1478 break;
Sergey Ivanov111ac842010-08-09 10:18:32 -03001479 case CX88_BOARD_TWINHAN_VP1027_DVBS:
1480 dev->ts_gen_cntrl = 0x00;
1481 fe0->dvb.frontend = dvb_attach(mb86a16_attach,
1482 &twinhan_vp1027,
1483 &core->i2c_adap);
1484 if (fe0->dvb.frontend) {
1485 core->prev_set_voltage =
1486 fe0->dvb.frontend->ops.set_voltage;
1487 fe0->dvb.frontend->ops.set_voltage =
1488 vp1027_set_voltage;
1489 }
1490 break;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001491
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 default:
Trent Piepho5772f812007-08-15 14:41:59 -03001493 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 -03001494 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 break;
1496 }
Steven Toth363c35f2008-10-11 11:05:50 -03001497
Mauro Carvalho Chehab2c9bcea2008-11-10 23:35:00 -02001498 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001499 printk(KERN_ERR
1500 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001501 core->name);
Darron Broad60a5a922008-11-11 08:48:27 -03001502 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001503 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001504 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001505 fe0->dvb.frontend->callback = cx88_tuner_callback;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001506
Steven Toth6c5be742006-12-02 21:15:51 -02001507 /* Ensure all frontends negotiate bus access */
Steven Toth363c35f2008-10-11 11:05:50 -03001508 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1509 if (fe1)
1510 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001512 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001513 call_all(core, core, s_power, 0);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001514
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 /* register everything */
Steven Toth363c35f2008-10-11 11:05:50 -03001516 return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001517 &dev->pci->dev, adapter_nr, mfe_shared, NULL);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001518
1519frontend_detach:
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001520 core->gate_ctrl = NULL;
Darron Broadbecd4302008-10-21 11:47:50 -03001521 videobuf_dvb_dealloc_frontends(&dev->frontends);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001522 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001523}
1524
1525/* ----------------------------------------------------------- */
1526
Steven Toth6c5be742006-12-02 21:15:51 -02001527/* CX8802 MPEG -> mini driver - We have been given the hardware */
1528static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529{
Steven Toth6c5be742006-12-02 21:15:51 -02001530 struct cx88_core *core = drv->core;
1531 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001532 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001533
Trent Piepho6a59d642007-08-15 14:41:57 -03001534 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001535 case CX88_BOARD_HAUPPAUGE_HVR1300:
1536 /* We arrive here with either the cx23416 or the cx22702
1537 * on the bus. Take the bus from the cx23416 and enable the
1538 * cx22702 demod
1539 */
Darron Broad79392732008-12-18 06:28:35 -03001540 /* Toggle reset on cx22702 leaving i2c active */
1541 cx_set(MO_GP0_IO, 0x00000080);
1542 udelay(1000);
1543 cx_clear(MO_GP0_IO, 0x00000080);
1544 udelay(50);
1545 cx_set(MO_GP0_IO, 0x00000080);
1546 udelay(1000);
1547 /* enable the cx22702 pins */
Steven Toth6c5be742006-12-02 21:15:51 -02001548 cx_clear(MO_GP0_IO, 0x00000004);
1549 udelay(1000);
1550 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001551
Darron Broad92abe9e2008-10-11 11:18:53 -03001552 case CX88_BOARD_HAUPPAUGE_HVR3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001553 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad79392732008-12-18 06:28:35 -03001554 /* Toggle reset on cx22702 leaving i2c active */
1555 cx_set(MO_GP0_IO, 0x00000080);
1556 udelay(1000);
1557 cx_clear(MO_GP0_IO, 0x00000080);
1558 udelay(50);
1559 cx_set(MO_GP0_IO, 0x00000080);
1560 udelay(1000);
1561 switch (core->dvbdev->frontends.active_fe_id) {
1562 case 1: /* DVB-S/S2 Enabled */
1563 /* tri-state the cx22702 pins */
1564 cx_set(MO_GP0_IO, 0x00000004);
1565 /* Take the cx24116/cx24123 out of reset */
1566 cx_write(MO_SRST_IO, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001567 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
Darron Broad79392732008-12-18 06:28:35 -03001568 break;
1569 case 2: /* DVB-T Enabled */
Steven Toth363c35f2008-10-11 11:05:50 -03001570 /* Put the cx24116/cx24123 into reset */
1571 cx_write(MO_SRST_IO, 0);
Darron Broad79392732008-12-18 06:28:35 -03001572 /* enable the cx22702 pins */
Steven Toth363c35f2008-10-11 11:05:50 -03001573 cx_clear(MO_GP0_IO, 0x00000004);
1574 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
Darron Broad79392732008-12-18 06:28:35 -03001575 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001576 }
Darron Broad79392732008-12-18 06:28:35 -03001577 udelay(1000);
Steven Toth363c35f2008-10-11 11:05:50 -03001578 break;
1579
Steven Toth6c5be742006-12-02 21:15:51 -02001580 default:
1581 err = -ENODEV;
1582 }
1583 return err;
1584}
1585
1586/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1587static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1588{
1589 struct cx88_core *core = drv->core;
1590 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001591 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001592
Trent Piepho6a59d642007-08-15 14:41:57 -03001593 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001594 case CX88_BOARD_HAUPPAUGE_HVR1300:
1595 /* Do Nothing, leave the cx22702 on the bus. */
1596 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001597 case CX88_BOARD_HAUPPAUGE_HVR3000:
1598 case CX88_BOARD_HAUPPAUGE_HVR4000:
1599 break;
Steven Toth6c5be742006-12-02 21:15:51 -02001600 default:
1601 err = -ENODEV;
1602 }
1603 return err;
1604}
1605
1606static int cx8802_dvb_probe(struct cx8802_driver *drv)
1607{
1608 struct cx88_core *core = drv->core;
1609 struct cx8802_dev *dev = drv->core->dvbdev;
Darron Broadcbd82442008-10-30 05:07:44 -03001610 int err;
Andy Walls6e0e12f2009-01-11 21:18:04 -03001611 struct videobuf_dvb_frontend *fe;
1612 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001613
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001614 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001615 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001616 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001617 core->name,
1618 core->pci_bus,
1619 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620
1621 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001622 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623 goto fail_core;
1624
Trent Piephoecf854d2007-05-05 20:11:32 -03001625 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001626 err = vp3054_i2c_probe(dev);
1627 if (0 != err)
Andy Walls6e0e12f2009-01-11 21:18:04 -03001628 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001629
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001631 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Steven Toth363c35f2008-10-11 11:05:50 -03001632 dev->ts_gen_cntrl = 0x0c;
1633
Andy Walls6e0e12f2009-01-11 21:18:04 -03001634 err = cx8802_alloc_frontends(dev);
1635 if (err)
1636 goto fail_core;
Darron Broadcbd82442008-10-30 05:07:44 -03001637
Andy Walls6e0e12f2009-01-11 21:18:04 -03001638 err = -ENODEV;
1639 for (i = 1; i <= core->board.num_frontends; i++) {
1640 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1641 if (fe == NULL) {
1642 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
Darron Broadcbd82442008-10-30 05:07:44 -03001643 __func__, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001644 goto fail_probe;
1645 }
1646 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
Darron Broadcbd82442008-10-30 05:07:44 -03001647 &dev->pci->dev, &dev->slock,
1648 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1649 V4L2_FIELD_TOP,
1650 sizeof(struct cx88_buffer),
Hans Verkuil08bff032010-09-20 17:39:46 -03001651 dev, NULL);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001652 /* init struct videobuf_dvb */
1653 fe->dvb.name = dev->core->name;
Steven Toth363c35f2008-10-11 11:05:50 -03001654 }
Andy Walls6e0e12f2009-01-11 21:18:04 -03001655
Linus Torvalds1da177e2005-04-16 15:20:36 -07001656 err = dvb_register(dev);
Darron Broadcbd82442008-10-30 05:07:44 -03001657 if (err)
1658 /* frontends/adapter de-allocated in dvb_register */
Trent Piepho5772f812007-08-15 14:41:59 -03001659 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1660 core->name, err);
Darron Broadcbd82442008-10-30 05:07:44 -03001661 return err;
1662fail_probe:
1663 videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
Darron Broad92abe9e2008-10-11 11:18:53 -03001664fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665 return err;
1666}
1667
Steven Toth6c5be742006-12-02 21:15:51 -02001668static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669{
Darron Broad0fcd4882008-10-21 11:18:47 -03001670 struct cx88_core *core = drv->core;
Steven Toth6c5be742006-12-02 21:15:51 -02001671 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001672
Darron Broad0fcd4882008-10-21 11:18:47 -03001673 dprintk( 1, "%s\n", __func__);
1674
Steven Toth363c35f2008-10-11 11:05:50 -03001675 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676
Chris Pascoefc40b262006-01-09 15:25:35 -02001677 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001678
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001679 core->gate_ctrl = NULL;
1680
Steven Toth6c5be742006-12-02 21:15:51 -02001681 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682}
1683
Steven Toth6c5be742006-12-02 21:15:51 -02001684static struct cx8802_driver cx8802_dvb_driver = {
1685 .type_id = CX88_MPEG_DVB,
1686 .hw_access = CX8802_DRVCTL_SHARED,
1687 .probe = cx8802_dvb_probe,
1688 .remove = cx8802_dvb_remove,
1689 .advise_acquire = cx8802_dvb_advise_acquire,
1690 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001691};
1692
Peter Huewe31d0f842009-07-17 01:00:01 +02001693static int __init dvb_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001694{
Trent Piepho5772f812007-08-15 14:41:59 -03001695 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 (CX88_VERSION_CODE >> 16) & 0xff,
1697 (CX88_VERSION_CODE >> 8) & 0xff,
1698 CX88_VERSION_CODE & 0xff);
1699#ifdef SNAPSHOT
1700 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1701 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1702#endif
Steven Toth6c5be742006-12-02 21:15:51 -02001703 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001704}
1705
Peter Huewe31d0f842009-07-17 01:00:01 +02001706static void __exit dvb_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001707{
Steven Toth6c5be742006-12-02 21:15:51 -02001708 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709}
1710
1711module_init(dvb_init);
1712module_exit(dvb_fini);
1713
1714/*
1715 * Local variables:
1716 * c-basic-offset: 8
1717 * compile-command: "make DVB=1"
1718 * End:
1719 */