blob: 1ed72ce2413c2637a6516ee21971352b365f8066 [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"
istvan_v@mailbox.huc21973e2011-06-07 13:12:29 -030044#include "xc4000.h"
Steven Toth60464da2008-01-05 16:53:01 -030045#include "xc5000.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030046#include "nxt200x.h"
47#include "cx24123.h"
Andrew de Quinceycd20ca92006-05-12 20:31:51 -030048#include "isl6421.h"
Michael Krufky0df31f82008-04-22 14:46:13 -030049#include "tuner-simple.h"
Michael Krufky827855d2008-04-22 14:46:16 -030050#include "tda9887.h"
Steven Tothd893d5d2008-04-25 03:46:43 -030051#include "s5h1411.h"
Igor M. Liplianine4aab642008-09-23 15:43:57 -030052#include "stv0299.h"
53#include "z0194a.h"
54#include "stv0288.h"
55#include "stb6000.h"
Steven Toth5bd1b662008-09-04 01:17:33 -030056#include "cx24116.h"
Igor M. Liplianinb699c272009-11-16 22:22:32 -030057#include "stv0900.h"
58#include "stb6100.h"
59#include "stb6100_proc.h"
Sergey Ivanov111ac842010-08-09 10:18:32 -030060#include "mb86a16.h"
Igor M. Liplianin0cb73632011-02-25 18:41:24 -030061#include "ds3000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
64MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
65MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
66MODULE_LICENSE("GPL");
67
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030068static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069module_param(debug, int, 0644);
70MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
71
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030072static unsigned int dvb_buf_tscnt = 32;
73module_param(dvb_buf_tscnt, int, 0644);
74MODULE_PARM_DESC(dvb_buf_tscnt, "DVB Buffer TS count [dvb]");
75
Janne Grunau78e92002008-04-09 19:13:13 -030076DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
77
Linus Torvalds1da177e2005-04-16 15:20:36 -070078#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020079 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81/* ------------------------------------------------------------------ */
82
83static int dvb_buf_setup(struct videobuf_queue *q,
84 unsigned int *count, unsigned int *size)
85{
86 struct cx8802_dev *dev = q->priv_data;
87
88 dev->ts_packet_size = 188 * 4;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030089 dev->ts_packet_count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91 *size = dev->ts_packet_size * dev->ts_packet_count;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030092 *count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093 return 0;
94}
95
Michael Krufky4a390552006-12-05 02:00:53 -030096static int dvb_buf_prepare(struct videobuf_queue *q,
97 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
99 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300100 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101}
102
103static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
104{
105 struct cx8802_dev *dev = q->priv_data;
106 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
107}
108
Michael Krufky4a390552006-12-05 02:00:53 -0300109static void dvb_buf_release(struct videobuf_queue *q,
110 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300112 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113}
114
lawrence rust2e4e98e2010-08-25 09:50:20 -0300115static const struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116 .buf_setup = dvb_buf_setup,
117 .buf_prepare = dvb_buf_prepare,
118 .buf_queue = dvb_buf_queue,
119 .buf_release = dvb_buf_release,
120};
121
122/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300123
124static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
125{
126 struct cx8802_dev *dev= fe->dvb->priv;
127 struct cx8802_driver *drv = NULL;
128 int ret = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300129 int fe_id;
130
131 fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
132 if (!fe_id) {
Steven Toth2af03ee2008-10-16 20:17:31 -0300133 printk(KERN_ERR "%s() No frontend found\n", __func__);
Steven Toth363c35f2008-10-11 11:05:50 -0300134 return -EINVAL;
135 }
136
Jonathan Nieder8a317a82011-05-01 06:29:16 -0300137 mutex_lock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300138 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
139 if (drv) {
Steven Toth363c35f2008-10-11 11:05:50 -0300140 if (acquire){
141 dev->frontends.active_fe_id = fe_id;
Michael Krufky22f3f172006-12-05 01:38:58 -0300142 ret = drv->request_acquire(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300143 } else {
Michael Krufky22f3f172006-12-05 01:38:58 -0300144 ret = drv->request_release(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300145 dev->frontends.active_fe_id = 0;
146 }
Michael Krufky22f3f172006-12-05 01:38:58 -0300147 }
Jonathan Nieder1fe70e92011-05-01 06:29:37 -0300148 mutex_unlock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300149
150 return ret;
151}
152
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300153static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
154{
155 struct videobuf_dvb_frontends *f;
156 struct videobuf_dvb_frontend *fe;
157
158 if (!core->dvbdev)
159 return;
160
161 f = &core->dvbdev->frontends;
162
163 if (!f)
164 return;
165
166 if (f->gate <= 1) /* undefined or fe0 */
167 fe = videobuf_dvb_get_frontend(f, 1);
168 else
169 fe = videobuf_dvb_get_frontend(f, f->gate);
170
171 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
172 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
173}
174
Michael Krufky22f3f172006-12-05 01:38:58 -0300175/* ------------------------------------------------------------------ */
176
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200177static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300179 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
180 static const u8 reset [] = { RESET, 0x80 };
181 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
182 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
183 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
184 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185
186 mt352_write(fe, clock_config, sizeof(clock_config));
187 udelay(200);
188 mt352_write(fe, reset, sizeof(reset));
189 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
190
191 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
192 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
193 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
194 return 0;
195}
196
Chris Pascoe43eabb42006-01-09 18:21:28 -0200197static int dvico_dual_demod_init(struct dvb_frontend *fe)
198{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300199 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
200 static const u8 reset [] = { RESET, 0x80 };
201 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
202 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
203 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
204 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Chris Pascoe43eabb42006-01-09 18:21:28 -0200205
206 mt352_write(fe, clock_config, sizeof(clock_config));
207 udelay(200);
208 mt352_write(fe, reset, sizeof(reset));
209 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
210
211 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
212 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
213 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
214
215 return 0;
216}
217
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
219{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300220 static const u8 clock_config [] = { 0x89, 0x38, 0x39 };
221 static const u8 reset [] = { 0x50, 0x80 };
222 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
223 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800224 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300225 static const u8 dntv_extra[] = { 0xB5, 0x7A };
226 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227
228 mt352_write(fe, clock_config, sizeof(clock_config));
229 udelay(2000);
230 mt352_write(fe, reset, sizeof(reset));
231 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
232
233 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
234 udelay(2000);
235 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
236 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
237
238 return 0;
239}
240
lawrence rust2e4e98e2010-08-25 09:50:20 -0300241static const struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300242 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200243 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244};
245
lawrence rust2e4e98e2010-08-25 09:50:20 -0300246static const struct mt352_config dntv_live_dvbt_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 .demod_address = 0x0f,
248 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249};
Chris Pascoefc40b262006-01-09 15:25:35 -0200250
lawrence rust2e4e98e2010-08-25 09:50:20 -0300251static const struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300252 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200253 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200254};
255
lawrence rust2e4e98e2010-08-25 09:50:20 -0300256static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
Stephan Wienczny70101a22009-03-10 19:08:06 -0300257 .demod_address = (0x1e >> 1),
258 .no_tuner = 1,
259 .if2 = 45600,
260};
261
Sergey Ivanov111ac842010-08-09 10:18:32 -0300262static struct mb86a16_config twinhan_vp1027 = {
263 .demod_address = 0x08,
264};
265
Trent Piephoecf854d2007-05-05 20:11:32 -0300266#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200267static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
268{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300269 static const u8 clock_config [] = { 0x89, 0x38, 0x38 };
270 static const u8 reset [] = { 0x50, 0x80 };
271 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
272 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200273 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300274 static const u8 dntv_extra[] = { 0xB5, 0x7A };
275 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200276
277 mt352_write(fe, clock_config, sizeof(clock_config));
278 udelay(2000);
279 mt352_write(fe, reset, sizeof(reset));
280 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
281
282 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
283 udelay(2000);
284 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
285 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
286
287 return 0;
288}
289
lawrence rust2e4e98e2010-08-25 09:50:20 -0300290static const struct mt352_config dntv_live_dvbt_pro_config = {
Chris Pascoefc40b262006-01-09 15:25:35 -0200291 .demod_address = 0x0f,
292 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200293 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200294};
295#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296
lawrence rust2e4e98e2010-08-25 09:50:20 -0300297static const struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300298 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300299 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300300};
301
lawrence rust2e4e98e2010-08-25 09:50:20 -0300302static const struct zl10353_config dvico_fusionhdtv_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300303 .demod_address = 0x0f,
304 .if2 = 45600,
305 .no_tuner = 1,
306};
307
lawrence rust2e4e98e2010-08-25 09:50:20 -0300308static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300309 .demod_address = 0x0f,
310 .if2 = 4560,
311 .no_tuner = 1,
312 .demod_init = dvico_fusionhdtv_demod_init,
313};
314
lawrence rust2e4e98e2010-08-25 09:50:20 -0300315static const struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300316 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300317};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300318
lawrence rust2e4e98e2010-08-25 09:50:20 -0300319static const struct cx22702_config connexant_refboard_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700321 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322};
323
lawrence rust2e4e98e2010-08-25 09:50:20 -0300324static const struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300325 .demod_address = 0x63,
326 .output_mode = CX22702_SERIAL_OUTPUT,
327};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328
Michael Krufky4a390552006-12-05 02:00:53 -0300329static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330{
331 struct cx8802_dev *dev= fe->dvb->priv;
332 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
333 return 0;
334}
335
lawrence rust2e4e98e2010-08-25 09:50:20 -0300336static const struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300337 .demod_address = 0x15,
338 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340
Michael Krufky6ddcc912005-07-27 11:46:00 -0700341static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700342{
343 struct cx8802_dev *dev= fe->dvb->priv;
344 struct cx88_core *core = dev->core;
345
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300346 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700347 if (index == 0)
348 cx_clear(MO_GP0_IO, 8);
349 else
350 cx_set(MO_GP0_IO, 8);
351 return 0;
352}
353
Michael Krufky6ddcc912005-07-27 11:46:00 -0700354static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700355{
356 struct cx8802_dev *dev= fe->dvb->priv;
357 if (is_punctured)
358 dev->ts_gen_cntrl |= 0x04;
359 else
360 dev->ts_gen_cntrl &= ~0x04;
361 return 0;
362}
363
Michael Krufky6ddcc912005-07-27 11:46:00 -0700364static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300365 .demod_address = 0x0e,
366 .demod_chip = LGDT3302,
367 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
368 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700369};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700370
lawrence rust2e4e98e2010-08-25 09:50:20 -0300371static const struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300372 .demod_address = 0x0e,
373 .demod_chip = LGDT3303,
374 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
375 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700376};
Rusty Scottda215d22006-04-07 02:21:31 -0300377
lawrence rust2e4e98e2010-08-25 09:50:20 -0300378static const struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300379 .demod_address = 0x59,
380 .demod_chip = LGDT3303,
381 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
382 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300383};
Michael Krufkyf1798492005-07-07 17:58:39 -0700384
Michael Krufky4a390552006-12-05 02:00:53 -0300385static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800386{
387 struct cx8802_dev *dev= fe->dvb->priv;
388 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
389 return 0;
390}
391
lawrence rust2e4e98e2010-08-25 09:50:20 -0300392static const struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300393 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300394 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800395};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800396
Steven Toth0fa14aa2006-01-09 15:25:02 -0200397static int cx24123_set_ts_param(struct dvb_frontend* fe,
398 int is_punctured)
399{
400 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300401 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200402 return 0;
403}
404
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300405static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
406 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200407{
408 struct cx8802_dev *dev= fe->dvb->priv;
409 struct cx88_core *core = dev->core;
410
Michael Krufky4a390552006-12-05 02:00:53 -0300411 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300412 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300413 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300414 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300415
416 if (core->prev_set_voltage)
417 return core->prev_set_voltage(fe, voltage);
418 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200419}
420
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300421static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
422 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300423{
424 struct cx8802_dev *dev= fe->dvb->priv;
425 struct cx88_core *core = dev->core;
426
427 if (voltage == SEC_VOLTAGE_OFF) {
428 dprintk(1,"LNB Voltage OFF\n");
429 cx_write(MO_GP0_IO, 0x0000efff);
430 }
431
432 if (core->prev_set_voltage)
433 return core->prev_set_voltage(fe, voltage);
434 return 0;
435}
436
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300437static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
438 fe_sec_voltage_t voltage)
439{
440 struct cx8802_dev *dev= fe->dvb->priv;
441 struct cx88_core *core = dev->core;
442
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300443 cx_set(MO_GP0_IO, 0x6040);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300444 switch (voltage) {
Sergey Ivanov111ac842010-08-09 10:18:32 -0300445 case SEC_VOLTAGE_13:
446 cx_clear(MO_GP0_IO, 0x20);
447 break;
448 case SEC_VOLTAGE_18:
449 cx_set(MO_GP0_IO, 0x20);
450 break;
451 case SEC_VOLTAGE_OFF:
452 cx_clear(MO_GP0_IO, 0x20);
453 break;
454 }
455
456 if (core->prev_set_voltage)
457 return core->prev_set_voltage(fe, voltage);
458 return 0;
459}
460
461static int vp1027_set_voltage(struct dvb_frontend *fe,
462 fe_sec_voltage_t voltage)
463{
464 struct cx8802_dev *dev = fe->dvb->priv;
465 struct cx88_core *core = dev->core;
466
467 switch (voltage) {
468 case SEC_VOLTAGE_13:
469 dprintk(1, "LNB SEC Voltage=13\n");
470 cx_write(MO_GP0_IO, 0x00001220);
471 break;
472 case SEC_VOLTAGE_18:
473 dprintk(1, "LNB SEC Voltage=18\n");
474 cx_write(MO_GP0_IO, 0x00001222);
475 break;
476 case SEC_VOLTAGE_OFF:
477 dprintk(1, "LNB Voltage OFF\n");
478 cx_write(MO_GP0_IO, 0x00001230);
479 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300480 }
481
482 if (core->prev_set_voltage)
483 return core->prev_set_voltage(fe, voltage);
484 return 0;
485}
486
lawrence rust2e4e98e2010-08-25 09:50:20 -0300487static const struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300488 .demod_address = 0x55,
489 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300490};
491
lawrence rust2e4e98e2010-08-25 09:50:20 -0300492static const struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300493 .demod_address = 0x55,
494 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200495};
496
lawrence rust2e4e98e2010-08-25 09:50:20 -0300497static const struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300498 .demod_address = 0x15,
499 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300500 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200501};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200502
lawrence rust2e4e98e2010-08-25 09:50:20 -0300503static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300504 .demod_address = 0x32 >> 1,
505 .output_mode = S5H1409_PARALLEL_OUTPUT,
506 .gpio = S5H1409_GPIO_ON,
507 .qam_if = 44000,
508 .inversion = S5H1409_INVERSION_OFF,
509 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300510 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300511};
512
lawrence rust2e4e98e2010-08-25 09:50:20 -0300513static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
Steven Toth5c00fac2008-04-22 14:45:14 -0300514 .demod_address = 0x32 >> 1,
515 .output_mode = S5H1409_SERIAL_OUTPUT,
516 .gpio = S5H1409_GPIO_OFF,
517 .inversion = S5H1409_INVERSION_OFF,
518 .status_mode = S5H1409_DEMODLOCKING,
519 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
520};
521
lawrence rust2e4e98e2010-08-25 09:50:20 -0300522static const struct s5h1409_config kworld_atsc_120_config = {
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300523 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300524 .output_mode = S5H1409_SERIAL_OUTPUT,
525 .gpio = S5H1409_GPIO_OFF,
526 .inversion = S5H1409_INVERSION_OFF,
527 .status_mode = S5H1409_DEMODLOCKING,
528 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
529};
530
lawrence rust2e4e98e2010-08-25 09:50:20 -0300531static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300532 .i2c_address = 0x64,
533 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300534};
535
lawrence rust2e4e98e2010-08-25 09:50:20 -0300536static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
Stéphane Voltz3f6014f2008-09-05 14:33:54 -0300537 .demod_address = (0x1e >> 1),
538 .no_tuner = 1,
539 .if2 = 45600,
540};
541
lawrence rust2e4e98e2010-08-25 09:50:20 -0300542static const struct zl10353_config cx88_geniatech_x8000_mt = {
Mauro Carvalho Chehab57069342009-08-20 10:14:45 -0300543 .demod_address = (0x1e >> 1),
544 .no_tuner = 1,
545 .disable_i2c_gate_ctrl = 1,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300546};
547
lawrence rust2e4e98e2010-08-25 09:50:20 -0300548static const struct s5h1411_config dvico_fusionhdtv7_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300549 .output_mode = S5H1411_SERIAL_OUTPUT,
550 .gpio = S5H1411_GPIO_ON,
551 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
552 .qam_if = S5H1411_IF_44000,
553 .vsb_if = S5H1411_IF_44000,
554 .inversion = S5H1411_INVERSION_OFF,
555 .status_mode = S5H1411_DEMODLOCKING
556};
557
lawrence rust2e4e98e2010-08-25 09:50:20 -0300558static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300559 .i2c_address = 0xc2 >> 1,
560 .if_khz = 5380,
Steven Tothd893d5d2008-04-25 03:46:43 -0300561};
562
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300563static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
564{
565 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -0300566 struct videobuf_dvb_frontend *fe0 = NULL;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300567 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300568 struct xc2028_config cfg = {
569 .i2c_adap = &dev->core->i2c_adap,
570 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300571 .ctrl = &ctl,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300572 };
573
Darron Broad92abe9e2008-10-11 11:18:53 -0300574 /* Get the first frontend */
Steven Toth363c35f2008-10-11 11:05:50 -0300575 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
576 if (!fe0)
577 return -EINVAL;
578
579 if (!fe0->dvb.frontend) {
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300580 printk(KERN_ERR "%s/2: dvb frontend not attached. "
581 "Can't attach xc3028\n",
582 dev->core->name);
583 return -EINVAL;
584 }
585
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300586 /*
587 * Some xc3028 devices may be hidden by an I2C gate. This is known
588 * to happen with some s5h1409-based devices.
589 * Now that I2C gate is open, sets up xc3028 configuration
590 */
591 cx88_setup_xc3028(dev->core, &ctl);
592
Steven Toth363c35f2008-10-11 11:05:50 -0300593 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300594 if (!fe) {
595 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
596 dev->core->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300597 dvb_frontend_detach(fe0->dvb.frontend);
598 dvb_unregister_frontend(fe0->dvb.frontend);
599 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300600 return -EINVAL;
601 }
602
603 printk(KERN_INFO "%s/2: xc3028 attached\n",
604 dev->core->name);
605
606 return 0;
607}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300608
istvan_v@mailbox.huc21973e2011-06-07 13:12:29 -0300609static int attach_xc4000(struct cx8802_dev *dev, struct xc4000_config *cfg)
610{
611 struct dvb_frontend *fe;
612 struct videobuf_dvb_frontend *fe0 = NULL;
613
614 /* Get the first frontend */
615 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
616 if (!fe0)
617 return -EINVAL;
618
619 if (!fe0->dvb.frontend) {
620 printk(KERN_ERR "%s/2: dvb frontend not attached. "
621 "Can't attach xc4000\n",
622 dev->core->name);
623 return -EINVAL;
624 }
625
626 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend, &dev->core->i2c_adap,
627 cfg);
628 if (!fe) {
629 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
630 dev->core->name);
631 dvb_frontend_detach(fe0->dvb.frontend);
632 dvb_unregister_frontend(fe0->dvb.frontend);
633 fe0->dvb.frontend = NULL;
634 return -EINVAL;
635 }
636
637 printk(KERN_INFO "%s/2: xc4000 attached\n", dev->core->name);
638
639 return 0;
640}
641
Steven Toth5bd1b662008-09-04 01:17:33 -0300642static int cx24116_set_ts_param(struct dvb_frontend *fe,
643 int is_punctured)
644{
645 struct cx8802_dev *dev = fe->dvb->priv;
646 dev->ts_gen_cntrl = 0x2;
647
648 return 0;
649}
650
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300651static int stv0900_set_ts_param(struct dvb_frontend *fe,
652 int is_punctured)
653{
654 struct cx8802_dev *dev = fe->dvb->priv;
655 dev->ts_gen_cntrl = 0;
656
657 return 0;
658}
659
Steven Toth5bd1b662008-09-04 01:17:33 -0300660static int cx24116_reset_device(struct dvb_frontend *fe)
661{
662 struct cx8802_dev *dev = fe->dvb->priv;
663 struct cx88_core *core = dev->core;
664
665 /* Reset the part */
Steven Toth363c35f2008-10-11 11:05:50 -0300666 /* Put the cx24116 into reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300667 cx_write(MO_SRST_IO, 0);
668 msleep(10);
Steven Toth363c35f2008-10-11 11:05:50 -0300669 /* Take the cx24116 out of reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300670 cx_write(MO_SRST_IO, 1);
671 msleep(10);
672
673 return 0;
674}
675
lawrence rust2e4e98e2010-08-25 09:50:20 -0300676static const struct cx24116_config hauppauge_hvr4000_config = {
Steven Toth5bd1b662008-09-04 01:17:33 -0300677 .demod_address = 0x05,
678 .set_ts_params = cx24116_set_ts_param,
679 .reset_device = cx24116_reset_device,
680};
681
lawrence rust2e4e98e2010-08-25 09:50:20 -0300682static const struct cx24116_config tevii_s460_config = {
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300683 .demod_address = 0x55,
684 .set_ts_params = cx24116_set_ts_param,
685 .reset_device = cx24116_reset_device,
686};
687
Igor M. Liplianin0cb73632011-02-25 18:41:24 -0300688static int ds3000_set_ts_param(struct dvb_frontend *fe,
689 int is_punctured)
690{
691 struct cx8802_dev *dev = fe->dvb->priv;
692 dev->ts_gen_cntrl = 4;
693
694 return 0;
695}
696
697static struct ds3000_config tevii_ds3000_config = {
698 .demod_address = 0x68,
699 .set_ts_params = ds3000_set_ts_param,
700};
701
lawrence rust2e4e98e2010-08-25 09:50:20 -0300702static const struct stv0900_config prof_7301_stv0900_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300703 .demod_address = 0x6a,
704/* demod_mode = 0,*/
705 .xtal = 27000000,
706 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
707 .diseqc_mode = 2,/* 2/3 PWM */
708 .tun1_maddress = 0,/* 0x60 */
709 .tun1_adc = 0,/* 2 Vpp */
710 .path1_mode = 3,
711 .set_ts_params = stv0900_set_ts_param,
712};
713
lawrence rust2e4e98e2010-08-25 09:50:20 -0300714static const struct stb6100_config prof_7301_stb6100_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300715 .tuner_address = 0x60,
716 .refclock = 27000000,
717};
718
lawrence rust2e4e98e2010-08-25 09:50:20 -0300719static const struct stv0299_config tevii_tuner_sharp_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300720 .demod_address = 0x68,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300721 .inittab = sharp_z0194a_inittab,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300722 .mclk = 88000000UL,
723 .invert = 1,
724 .skip_reinit = 0,
725 .lock_output = 1,
726 .volt13_op0_op1 = STV0299_VOLT13_OP1,
727 .min_delay_ms = 100,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300728 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300729 .set_ts_params = cx24116_set_ts_param,
730};
731
lawrence rust2e4e98e2010-08-25 09:50:20 -0300732static const struct stv0288_config tevii_tuner_earda_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300733 .demod_address = 0x68,
734 .min_delay_ms = 100,
735 .set_ts_params = cx24116_set_ts_param,
736};
737
Andy Walls6e0e12f2009-01-11 21:18:04 -0300738static int cx8802_alloc_frontends(struct cx8802_dev *dev)
739{
740 struct cx88_core *core = dev->core;
741 struct videobuf_dvb_frontend *fe = NULL;
742 int i;
743
744 mutex_init(&dev->frontends.lock);
745 INIT_LIST_HEAD(&dev->frontends.felist);
746
747 if (!core->board.num_frontends)
748 return -ENODEV;
749
750 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
751 core->board.num_frontends);
752 for (i = 1; i <= core->board.num_frontends; i++) {
753 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
754 if (!fe) {
755 printk(KERN_ERR "%s() failed to alloc\n", __func__);
756 videobuf_dvb_dealloc_frontends(&dev->frontends);
757 return -ENOMEM;
758 }
759 }
760 return 0;
761}
762
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300763
764
lawrence rust2e4e98e2010-08-25 09:50:20 -0300765static const u8 samsung_smt_7020_inittab[] = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300766 0x01, 0x15,
767 0x02, 0x00,
768 0x03, 0x00,
769 0x04, 0x7D,
770 0x05, 0x0F,
771 0x06, 0x02,
772 0x07, 0x00,
773 0x08, 0x60,
774
775 0x0A, 0xC2,
776 0x0B, 0x00,
777 0x0C, 0x01,
778 0x0D, 0x81,
779 0x0E, 0x44,
780 0x0F, 0x09,
781 0x10, 0x3C,
782 0x11, 0x84,
783 0x12, 0xDA,
784 0x13, 0x99,
785 0x14, 0x8D,
786 0x15, 0xCE,
787 0x16, 0xE8,
788 0x17, 0x43,
789 0x18, 0x1C,
790 0x19, 0x1B,
791 0x1A, 0x1D,
792
793 0x1C, 0x12,
794 0x1D, 0x00,
795 0x1E, 0x00,
796 0x1F, 0x00,
797 0x20, 0x00,
798 0x21, 0x00,
799 0x22, 0x00,
800 0x23, 0x00,
801
802 0x28, 0x02,
803 0x29, 0x28,
804 0x2A, 0x14,
805 0x2B, 0x0F,
806 0x2C, 0x09,
807 0x2D, 0x05,
808
809 0x31, 0x1F,
810 0x32, 0x19,
811 0x33, 0xFC,
812 0x34, 0x13,
813 0xff, 0xff,
814};
815
816
817static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe,
818 struct dvb_frontend_parameters *params)
819{
820 struct cx8802_dev *dev = fe->dvb->priv;
821 u8 buf[4];
822 u32 div;
823 struct i2c_msg msg = {
824 .addr = 0x61,
825 .flags = 0,
826 .buf = buf,
827 .len = sizeof(buf) };
828
829 div = params->frequency / 125;
830
831 buf[0] = (div >> 8) & 0x7f;
832 buf[1] = div & 0xff;
833 buf[2] = 0x84; /* 0xC4 */
834 buf[3] = 0x00;
835
836 if (params->frequency < 1500000)
837 buf[3] |= 0x10;
838
839 if (fe->ops.i2c_gate_ctrl)
840 fe->ops.i2c_gate_ctrl(fe, 1);
841
842 if (i2c_transfer(&dev->core->i2c_adap, &msg, 1) != 1)
843 return -EIO;
844
845 return 0;
846}
847
848static int samsung_smt_7020_set_tone(struct dvb_frontend *fe,
849 fe_sec_tone_mode_t tone)
850{
851 struct cx8802_dev *dev = fe->dvb->priv;
852 struct cx88_core *core = dev->core;
853
854 cx_set(MO_GP0_IO, 0x0800);
855
856 switch (tone) {
857 case SEC_TONE_ON:
858 cx_set(MO_GP0_IO, 0x08);
859 break;
860 case SEC_TONE_OFF:
861 cx_clear(MO_GP0_IO, 0x08);
862 break;
863 default:
864 return -EINVAL;
865 }
866
867 return 0;
868}
869
870static int samsung_smt_7020_set_voltage(struct dvb_frontend *fe,
871 fe_sec_voltage_t voltage)
872{
873 struct cx8802_dev *dev = fe->dvb->priv;
874 struct cx88_core *core = dev->core;
875
876 u8 data;
877 struct i2c_msg msg = {
878 .addr = 8,
879 .flags = 0,
880 .buf = &data,
881 .len = sizeof(data) };
882
883 cx_set(MO_GP0_IO, 0x8000);
884
885 switch (voltage) {
886 case SEC_VOLTAGE_OFF:
887 break;
888 case SEC_VOLTAGE_13:
889 data = ISL6421_EN1 | ISL6421_LLC1;
890 cx_clear(MO_GP0_IO, 0x80);
891 break;
892 case SEC_VOLTAGE_18:
893 data = ISL6421_EN1 | ISL6421_LLC1 | ISL6421_VSEL1;
894 cx_clear(MO_GP0_IO, 0x80);
895 break;
896 default:
897 return -EINVAL;
898 };
899
900 return (i2c_transfer(&dev->core->i2c_adap, &msg, 1) == 1) ? 0 : -EIO;
901}
902
903static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
904 u32 srate, u32 ratio)
905{
906 u8 aclk = 0;
907 u8 bclk = 0;
908
909 if (srate < 1500000) {
910 aclk = 0xb7;
911 bclk = 0x47;
912 } else if (srate < 3000000) {
913 aclk = 0xb7;
914 bclk = 0x4b;
915 } else if (srate < 7000000) {
916 aclk = 0xb7;
917 bclk = 0x4f;
918 } else if (srate < 14000000) {
919 aclk = 0xb7;
920 bclk = 0x53;
921 } else if (srate < 30000000) {
922 aclk = 0xb6;
923 bclk = 0x53;
924 } else if (srate < 45000000) {
925 aclk = 0xb4;
926 bclk = 0x51;
927 }
928
929 stv0299_writereg(fe, 0x13, aclk);
930 stv0299_writereg(fe, 0x14, bclk);
931 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
932 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
933 stv0299_writereg(fe, 0x21, ratio & 0xf0);
934
935 return 0;
936}
937
938
lawrence rust2e4e98e2010-08-25 09:50:20 -0300939static const struct stv0299_config samsung_stv0299_config = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300940 .demod_address = 0x68,
941 .inittab = samsung_smt_7020_inittab,
942 .mclk = 88000000UL,
943 .invert = 0,
944 .skip_reinit = 0,
945 .lock_output = STV0299_LOCKOUTPUT_LK,
946 .volt13_op0_op1 = STV0299_VOLT13_OP1,
947 .min_delay_ms = 100,
948 .set_symbol_rate = samsung_smt_7020_stv0299_set_symbol_rate,
949};
950
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951static int dvb_register(struct cx8802_dev *dev)
952{
Steven Toth363c35f2008-10-11 11:05:50 -0300953 struct cx88_core *core = dev->core;
954 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
Darron Broad59b18422008-10-11 11:44:05 -0300955 int mfe_shared = 0; /* bus not shared by default */
Steven Toth363c35f2008-10-11 11:05:50 -0300956
Matthias Schwarzott0e8bac92008-10-24 10:47:07 -0300957 if (0 != core->i2c_rc) {
958 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
959 goto frontend_detach;
960 }
961
Steven Toth363c35f2008-10-11 11:05:50 -0300962 /* Get the first frontend */
963 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
964 if (!fe0)
Darron Broad60a5a922008-11-11 08:48:27 -0300965 goto frontend_detach;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966
Darron Broad8e739092008-10-11 11:31:41 -0300967 /* multi-frontend gate control is undefined or defaults to fe0 */
968 dev->frontends.gate = 0;
969
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300970 /* Sets the gate control callback to be used by i2c command calls */
971 core->gate_ctrl = cx88_dvb_gate_ctrl;
972
Darron Broad8e739092008-10-11 11:31:41 -0300973 /* init frontend(s) */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300974 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -0300976 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300977 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300978 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300979 if (fe0->dvb.frontend != NULL) {
980 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300981 0x61, &core->i2c_adap,
982 DVB_PLL_THOMSON_DTT759X))
983 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300984 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700986 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200988 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800989 case CX88_BOARD_WINFAST_DTV1000:
Steven Toth363c35f2008-10-11 11:05:50 -0300990 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300991 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300992 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300993 if (fe0->dvb.frontend != NULL) {
994 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300995 0x60, &core->i2c_adap,
996 DVB_PLL_THOMSON_DTT7579))
997 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300998 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -03001000 case CX88_BOARD_WINFAST_DTV2000H:
Vlastimil Labsky4d14c832009-08-10 22:15:54 -03001001 case CX88_BOARD_WINFAST_DTV2000H_J:
Steven Toth611900c2006-01-09 15:25:12 -02001002 case CX88_BOARD_HAUPPAUGE_HVR1100:
1003 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -03001004 case CX88_BOARD_HAUPPAUGE_HVR1300:
Steven Toth363c35f2008-10-11 11:05:50 -03001005 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -03001006 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001007 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001008 if (fe0->dvb.frontend != NULL) {
1009 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001010 &core->i2c_adap, 0x61,
1011 TUNER_PHILIPS_FMD1216ME_MK3))
1012 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001013 }
Steven Toth611900c2006-01-09 15:25:12 -02001014 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001015 case CX88_BOARD_HAUPPAUGE_HVR3000:
Darron Broad60a5a922008-11-11 08:48:27 -03001016 /* MFE frontend 1 */
1017 mfe_shared = 1;
1018 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001019 /* DVB-S init */
1020 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001021 &hauppauge_novas_config,
1022 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001023 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001024 if (!dvb_attach(isl6421_attach,
1025 fe0->dvb.frontend,
1026 &dev->core->i2c_adap,
1027 0x08, ISL6421_DCL, 0x00))
1028 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001029 }
Darron Broad60a5a922008-11-11 08:48:27 -03001030 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001031 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001032 if (!fe1)
1033 goto frontend_detach;
1034 /* DVB-T init */
1035 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1036 &hauppauge_hvr_config,
1037 &dev->core->i2c_adap);
1038 if (fe1->dvb.frontend) {
1039 fe1->dvb.frontend->id = 1;
1040 if (!dvb_attach(simple_tuner_attach,
1041 fe1->dvb.frontend,
1042 &dev->core->i2c_adap,
1043 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1044 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001045 }
1046 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001047 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001048 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001049 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001050 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001051 if (fe0->dvb.frontend != NULL) {
1052 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001053 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1054 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001055 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001056 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001057 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001058 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001059 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001060 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001061 if (fe0->dvb.frontend != NULL) {
1062 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001063 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1064 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001065 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001066 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001067 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001068 /* The tin box says DEE1601, but it seems to be DTT7579
1069 * compatible, with a slightly different MT352 AGC gain. */
Steven Toth363c35f2008-10-11 11:05:50 -03001070 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001071 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001072 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001073 if (fe0->dvb.frontend != NULL) {
1074 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001075 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1076 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001077 break;
1078 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001079 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001080 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001081 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001082 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001083 if (fe0->dvb.frontend != NULL) {
1084 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001085 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1086 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001087 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001088 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -03001090 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001091 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001092 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001093 if (fe0->dvb.frontend != NULL) {
1094 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001095 0x61, NULL, DVB_PLL_LG_Z201))
1096 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001097 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 case CX88_BOARD_KWORLD_DVB_T:
1100 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001101 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Steven Toth363c35f2008-10-11 11:05:50 -03001102 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001103 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001104 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001105 if (fe0->dvb.frontend != NULL) {
1106 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001107 0x61, NULL, DVB_PLL_UNKNOWN_1))
1108 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001109 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 break;
Chris Pascoefc40b262006-01-09 15:25:35 -02001111 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -03001112#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -03001113 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Steven Toth363c35f2008-10-11 11:05:50 -03001114 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -03001115 &dev->vp3054->adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001116 if (fe0->dvb.frontend != NULL) {
1117 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001118 &core->i2c_adap, 0x61,
1119 TUNER_PHILIPS_FMD1216ME_MK3))
1120 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001121 }
Chris Pascoefc40b262006-01-09 15:25:35 -02001122#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001123 printk(KERN_ERR "%s/2: built without vp3054 support\n",
1124 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -02001125#endif
1126 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001127 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001128 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001129 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001130 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001131 if (fe0->dvb.frontend != NULL) {
1132 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001133 &core->i2c_adap, 0x61,
1134 TUNER_THOMSON_FE6600))
1135 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001136 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001137 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001138 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
Steven Toth363c35f2008-10-11 11:05:50 -03001139 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001140 &dvico_fusionhdtv_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001141 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001142 if (fe0->dvb.frontend == NULL)
1143 fe0->dvb.frontend = dvb_attach(mt352_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001144 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001145 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -03001146 /*
1147 * On this board, the demod provides the I2C bus pullup.
1148 * We must not permit gate_ctrl to be performed, or
1149 * the xc3028 cannot communicate on the bus.
1150 */
Steven Toth363c35f2008-10-11 11:05:50 -03001151 if (fe0->dvb.frontend)
1152 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001153 if (attach_xc3028(0x61, dev) < 0)
Darron Broadbecd4302008-10-21 11:47:50 -03001154 goto frontend_detach;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001155 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 case CX88_BOARD_PCHDTV_HD3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001157 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001158 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001159 if (fe0->dvb.frontend != NULL) {
1160 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001161 &core->i2c_adap, 0x61,
1162 TUNER_THOMSON_DTT761X))
1163 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001164 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 break;
Michael Krufkyf1798492005-07-07 17:58:39 -07001166 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
1167 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -07001168
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001169 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -07001170 cx_clear(MO_GP0_IO, 1);
1171 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001172 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -07001173 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001174
1175 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -07001176 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Steven Toth363c35f2008-10-11 11:05:50 -03001177 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001178 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001179 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001180 if (fe0->dvb.frontend != NULL) {
1181 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001182 &core->i2c_adap, 0x61,
1183 TUNER_MICROTUNE_4042FI5))
1184 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -07001185 }
1186 break;
Michael Krufky0d723c02005-07-07 17:58:42 -07001187 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
1188 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -07001189
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001190 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -07001191 cx_clear(MO_GP0_IO, 1);
1192 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -07001193 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -07001194 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001195 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001196 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001197 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001198 if (fe0->dvb.frontend != NULL) {
1199 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001200 &core->i2c_adap, 0x61,
1201 TUNER_THOMSON_DTT761X))
1202 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -07001203 }
1204 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001205 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
1206 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001207
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001208 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001209 cx_clear(MO_GP0_IO, 1);
1210 mdelay(100);
1211 cx_set(MO_GP0_IO, 1);
1212 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001213 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001214 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001215 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001216 if (fe0->dvb.frontend != NULL) {
1217 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001218 &core->i2c_adap, 0x61,
1219 TUNER_LG_TDVS_H06XF))
1220 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001221 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001222 &core->i2c_adap, 0x43))
1223 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001224 }
1225 break;
Rusty Scottda215d22006-04-07 02:21:31 -03001226 case CX88_BOARD_PCHDTV_HD5500:
1227 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -03001228
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001229 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -03001230 cx_clear(MO_GP0_IO, 1);
1231 mdelay(100);
1232 cx_set(MO_GP0_IO, 1);
1233 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001234 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001235 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001236 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001237 if (fe0->dvb.frontend != NULL) {
1238 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001239 &core->i2c_adap, 0x61,
1240 TUNER_LG_TDVS_H06XF))
1241 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001242 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001243 &core->i2c_adap, 0x43))
1244 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -03001245 }
1246 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -08001247 case CX88_BOARD_ATI_HDTVWONDER:
Steven Toth363c35f2008-10-11 11:05:50 -03001248 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001249 &ati_hdtvwonder,
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) {
1252 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001253 &core->i2c_adap, 0x61,
1254 TUNER_PHILIPS_TUV1236D))
1255 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001256 }
Kirk Laprayfde6d312005-11-08 21:38:18 -08001257 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -02001258 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
1259 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Steven Toth363c35f2008-10-11 11:05:50 -03001260 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001261 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001262 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001263 if (fe0->dvb.frontend) {
1264 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
Steven Toth83fe92e2008-09-13 19:22:15 -03001265 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001266 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001267 }
Steven Toth0fa14aa2006-01-09 15:25:02 -02001268 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -02001269 case CX88_BOARD_KWORLD_DVBS_100:
Steven Toth363c35f2008-10-11 11:05:50 -03001270 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001271 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001272 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001273 if (fe0->dvb.frontend) {
1274 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1275 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001276 }
Vadim Catana0e0351e2006-01-09 15:25:02 -02001277 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001278 case CX88_BOARD_GENIATECH_DVBS:
Steven Toth363c35f2008-10-11 11:05:50 -03001279 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001280 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001281 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001282 if (fe0->dvb.frontend) {
1283 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1284 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001285 }
1286 break;
Steven Toth60464da2008-01-05 16:53:01 -03001287 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth363c35f2008-10-11 11:05:50 -03001288 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth60464da2008-01-05 16:53:01 -03001289 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001290 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001291 if (fe0->dvb.frontend != NULL) {
1292 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001293 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001294 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001295 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -03001296 }
1297 break;
Steven Toth5c00fac2008-04-22 14:45:14 -03001298 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
Steven Toth363c35f2008-10-11 11:05:50 -03001299 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth5c00fac2008-04-22 14:45:14 -03001300 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001301 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001302 if (fe0->dvb.frontend != NULL) {
Steven Toth5c00fac2008-04-22 14:45:14 -03001303 struct dvb_frontend *fe;
1304 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001305 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -03001306 .i2c_addr = 0x61,
Steven Toth5c00fac2008-04-22 14:45:14 -03001307 };
1308 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001309 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -03001310 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -03001311 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -03001312 };
1313
1314 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001315 fe0->dvb.frontend, &cfg);
Steven Toth5c00fac2008-04-22 14:45:14 -03001316 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1317 fe->ops.tuner_ops.set_config(fe, &ctl);
1318 }
1319 break;
Ricardo Maraschinid49f7a22010-04-06 02:40:43 -03001320 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
Miroslav Sustek3047a172009-05-31 16:47:28 -03001321 case CX88_BOARD_WINFAST_DTV1800H:
Steven Toth363c35f2008-10-11 11:05:50 -03001322 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001323 &cx88_pinnacle_hybrid_pctv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001324 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001325 if (fe0->dvb.frontend) {
1326 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001327 if (attach_xc3028(0x61, dev) < 0)
1328 goto frontend_detach;
1329 }
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001330 break;
istvan_v@mailbox.hu8eb79c02011-06-07 13:16:56 -03001331 case CX88_BOARD_WINFAST_DTV1800H_XC4000:
istvan_v@mailbox.huf271a3a2011-06-07 13:14:53 -03001332 case CX88_BOARD_WINFAST_DTV2000H_PLUS:
1333 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1334 &cx88_pinnacle_hybrid_pctv,
1335 &core->i2c_adap);
1336 if (fe0->dvb.frontend) {
1337 struct xc4000_config cfg = {
1338 .i2c_address = 0x61,
1339 .default_pm = 0,
1340 .dvb_amplitude = 134,
1341 .set_smoothedcvbs = 1,
1342 .if_khz = 4560
1343 };
1344 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1345 if (attach_xc4000(dev, &cfg) < 0)
1346 goto frontend_detach;
1347 }
1348 break;
1349 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001350 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001351
Steven Toth363c35f2008-10-11 11:05:50 -03001352 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001353 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001354 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001355 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001356 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001357 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001358 case CX88_BOARD_KWORLD_ATSC_120:
Steven Toth363c35f2008-10-11 11:05:50 -03001359 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001360 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001361 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001362 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001363 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001364 break;
Steven Tothd893d5d2008-04-25 03:46:43 -03001365 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
Steven Toth363c35f2008-10-11 11:05:50 -03001366 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Steven Tothd893d5d2008-04-25 03:46:43 -03001367 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001368 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001369 if (fe0->dvb.frontend != NULL) {
1370 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001371 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001372 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001373 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -03001374 }
1375 break;
Steven Toth5bd1b662008-09-04 01:17:33 -03001376 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad60a5a922008-11-11 08:48:27 -03001377 /* MFE frontend 1 */
1378 mfe_shared = 1;
1379 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001380 /* DVB-S/S2 Init */
1381 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001382 &hauppauge_hvr4000_config,
1383 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001384 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001385 if (!dvb_attach(isl6421_attach,
1386 fe0->dvb.frontend,
1387 &dev->core->i2c_adap,
1388 0x08, ISL6421_DCL, 0x00))
1389 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001390 }
Darron Broad60a5a922008-11-11 08:48:27 -03001391 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001392 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001393 if (!fe1)
1394 goto frontend_detach;
1395 /* DVB-T Init */
1396 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1397 &hauppauge_hvr_config,
1398 &dev->core->i2c_adap);
1399 if (fe1->dvb.frontend) {
1400 fe1->dvb.frontend->id = 1;
1401 if (!dvb_attach(simple_tuner_attach,
1402 fe1->dvb.frontend,
1403 &dev->core->i2c_adap,
1404 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1405 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001406 }
1407 break;
1408 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1409 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001410 &hauppauge_hvr4000_config,
1411 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001412 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001413 if (!dvb_attach(isl6421_attach,
1414 fe0->dvb.frontend,
1415 &dev->core->i2c_adap,
1416 0x08, ISL6421_DCL, 0x00))
1417 goto frontend_detach;
Steven Toth5bd1b662008-09-04 01:17:33 -03001418 }
1419 break;
Igor M. Liplianincd3cde12008-11-09 15:26:25 -03001420 case CX88_BOARD_PROF_6200:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001421 case CX88_BOARD_TBS_8910:
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001422 case CX88_BOARD_TEVII_S420:
Steven Toth363c35f2008-10-11 11:05:50 -03001423 fe0->dvb.frontend = dvb_attach(stv0299_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001424 &tevii_tuner_sharp_config,
1425 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001426 if (fe0->dvb.frontend != NULL) {
1427 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001428 &core->i2c_adap, DVB_PLL_OPERA1))
1429 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001430 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1431 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001432
1433 } else {
Steven Toth363c35f2008-10-11 11:05:50 -03001434 fe0->dvb.frontend = dvb_attach(stv0288_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001435 &tevii_tuner_earda_config,
1436 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001437 if (fe0->dvb.frontend != NULL) {
1438 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001439 &core->i2c_adap))
1440 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001441 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1442 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001443 }
1444 }
1445 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001446 case CX88_BOARD_TEVII_S460:
Steven Toth363c35f2008-10-11 11:05:50 -03001447 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001448 &tevii_s460_config,
1449 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001450 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001451 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001452 break;
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001453 case CX88_BOARD_TEVII_S464:
1454 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1455 &tevii_ds3000_config,
1456 &core->i2c_adap);
1457 if (fe0->dvb.frontend != NULL)
1458 fe0->dvb.frontend->ops.set_voltage =
1459 tevii_dvbs_set_voltage;
1460 break;
Oleg Roitburd4cd7fb82008-09-17 11:30:21 -03001461 case CX88_BOARD_OMICOM_SS4_PCI:
Oleg Roitburdee730422008-09-17 11:58:33 -03001462 case CX88_BOARD_TBS_8920:
Oleg Roitburd57f51db2008-10-08 06:48:08 -03001463 case CX88_BOARD_PROF_7300:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001464 case CX88_BOARD_SATTRADE_ST4200:
Steven Toth363c35f2008-10-11 11:05:50 -03001465 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Oleg Roitburdee730422008-09-17 11:58:33 -03001466 &hauppauge_hvr4000_config,
1467 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001468 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001469 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Oleg Roitburdee730422008-09-17 11:58:33 -03001470 break;
Stephan Wienczny70101a22009-03-10 19:08:06 -03001471 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
1472 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1473 &cx88_terratec_cinergy_ht_pci_mkii_config,
1474 &core->i2c_adap);
1475 if (fe0->dvb.frontend) {
1476 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1477 if (attach_xc3028(0x61, dev) < 0)
1478 goto frontend_detach;
1479 }
1480 break;
Igor M. Liplianinb699c272009-11-16 22:22:32 -03001481 case CX88_BOARD_PROF_7301:{
1482 struct dvb_tuner_ops *tuner_ops = NULL;
1483
1484 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1485 &prof_7301_stv0900_config,
1486 &core->i2c_adap, 0);
1487 if (fe0->dvb.frontend != NULL) {
1488 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1489 &prof_7301_stb6100_config,
1490 &core->i2c_adap))
1491 goto frontend_detach;
1492
1493 tuner_ops = &fe0->dvb.frontend->ops.tuner_ops;
1494 tuner_ops->set_frequency = stb6100_set_freq;
1495 tuner_ops->get_frequency = stb6100_get_freq;
1496 tuner_ops->set_bandwidth = stb6100_set_bandw;
1497 tuner_ops->get_bandwidth = stb6100_get_bandw;
1498
1499 core->prev_set_voltage =
1500 fe0->dvb.frontend->ops.set_voltage;
1501 fe0->dvb.frontend->ops.set_voltage =
1502 tevii_dvbs_set_voltage;
1503 }
1504 break;
1505 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001506 case CX88_BOARD_SAMSUNG_SMT_7020:
1507 dev->ts_gen_cntrl = 0x08;
1508
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001509 cx_set(MO_GP0_IO, 0x0101);
1510
1511 cx_clear(MO_GP0_IO, 0x01);
1512 mdelay(100);
1513 cx_set(MO_GP0_IO, 0x01);
1514 mdelay(200);
1515
1516 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1517 &samsung_stv0299_config,
1518 &dev->core->i2c_adap);
1519 if (fe0->dvb.frontend) {
1520 fe0->dvb.frontend->ops.tuner_ops.set_params =
1521 samsung_smt_7020_tuner_set_params;
1522 fe0->dvb.frontend->tuner_priv =
1523 &dev->core->i2c_adap;
1524 fe0->dvb.frontend->ops.set_voltage =
1525 samsung_smt_7020_set_voltage;
1526 fe0->dvb.frontend->ops.set_tone =
1527 samsung_smt_7020_set_tone;
1528 }
1529
1530 break;
Sergey Ivanov111ac842010-08-09 10:18:32 -03001531 case CX88_BOARD_TWINHAN_VP1027_DVBS:
1532 dev->ts_gen_cntrl = 0x00;
1533 fe0->dvb.frontend = dvb_attach(mb86a16_attach,
1534 &twinhan_vp1027,
1535 &core->i2c_adap);
1536 if (fe0->dvb.frontend) {
1537 core->prev_set_voltage =
1538 fe0->dvb.frontend->ops.set_voltage;
1539 fe0->dvb.frontend->ops.set_voltage =
1540 vp1027_set_voltage;
1541 }
1542 break;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001543
Linus Torvalds1da177e2005-04-16 15:20:36 -07001544 default:
Trent Piepho5772f812007-08-15 14:41:59 -03001545 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 -03001546 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547 break;
1548 }
Steven Toth363c35f2008-10-11 11:05:50 -03001549
Mauro Carvalho Chehab2c9bcea2008-11-10 23:35:00 -02001550 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001551 printk(KERN_ERR
1552 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001553 core->name);
Darron Broad60a5a922008-11-11 08:48:27 -03001554 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001555 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001556 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001557 fe0->dvb.frontend->callback = cx88_tuner_callback;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001558
Steven Toth6c5be742006-12-02 21:15:51 -02001559 /* Ensure all frontends negotiate bus access */
Steven Toth363c35f2008-10-11 11:05:50 -03001560 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1561 if (fe1)
1562 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001564 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001565 call_all(core, core, s_power, 0);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001566
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 /* register everything */
Steven Toth363c35f2008-10-11 11:05:50 -03001568 return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001569 &dev->pci->dev, adapter_nr, mfe_shared, NULL);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001570
1571frontend_detach:
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001572 core->gate_ctrl = NULL;
Darron Broadbecd4302008-10-21 11:47:50 -03001573 videobuf_dvb_dealloc_frontends(&dev->frontends);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001574 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575}
1576
1577/* ----------------------------------------------------------- */
1578
Steven Toth6c5be742006-12-02 21:15:51 -02001579/* CX8802 MPEG -> mini driver - We have been given the hardware */
1580static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001581{
Steven Toth6c5be742006-12-02 21:15:51 -02001582 struct cx88_core *core = drv->core;
1583 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001584 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001585
Trent Piepho6a59d642007-08-15 14:41:57 -03001586 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001587 case CX88_BOARD_HAUPPAUGE_HVR1300:
1588 /* We arrive here with either the cx23416 or the cx22702
1589 * on the bus. Take the bus from the cx23416 and enable the
1590 * cx22702 demod
1591 */
Darron Broad79392732008-12-18 06:28:35 -03001592 /* Toggle reset on cx22702 leaving i2c active */
1593 cx_set(MO_GP0_IO, 0x00000080);
1594 udelay(1000);
1595 cx_clear(MO_GP0_IO, 0x00000080);
1596 udelay(50);
1597 cx_set(MO_GP0_IO, 0x00000080);
1598 udelay(1000);
1599 /* enable the cx22702 pins */
Steven Toth6c5be742006-12-02 21:15:51 -02001600 cx_clear(MO_GP0_IO, 0x00000004);
1601 udelay(1000);
1602 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001603
Darron Broad92abe9e2008-10-11 11:18:53 -03001604 case CX88_BOARD_HAUPPAUGE_HVR3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001605 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad79392732008-12-18 06:28:35 -03001606 /* Toggle reset on cx22702 leaving i2c active */
1607 cx_set(MO_GP0_IO, 0x00000080);
1608 udelay(1000);
1609 cx_clear(MO_GP0_IO, 0x00000080);
1610 udelay(50);
1611 cx_set(MO_GP0_IO, 0x00000080);
1612 udelay(1000);
1613 switch (core->dvbdev->frontends.active_fe_id) {
1614 case 1: /* DVB-S/S2 Enabled */
1615 /* tri-state the cx22702 pins */
1616 cx_set(MO_GP0_IO, 0x00000004);
1617 /* Take the cx24116/cx24123 out of reset */
1618 cx_write(MO_SRST_IO, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001619 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
Darron Broad79392732008-12-18 06:28:35 -03001620 break;
1621 case 2: /* DVB-T Enabled */
Steven Toth363c35f2008-10-11 11:05:50 -03001622 /* Put the cx24116/cx24123 into reset */
1623 cx_write(MO_SRST_IO, 0);
Darron Broad79392732008-12-18 06:28:35 -03001624 /* enable the cx22702 pins */
Steven Toth363c35f2008-10-11 11:05:50 -03001625 cx_clear(MO_GP0_IO, 0x00000004);
1626 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
Darron Broad79392732008-12-18 06:28:35 -03001627 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001628 }
Darron Broad79392732008-12-18 06:28:35 -03001629 udelay(1000);
Steven Toth363c35f2008-10-11 11:05:50 -03001630 break;
1631
istvan_v@mailbox.huf271a3a2011-06-07 13:14:53 -03001632 case CX88_BOARD_WINFAST_DTV2000H_PLUS:
1633 /* set RF input to AIR for DVB-T (GPIO 16) */
1634 cx_write(MO_GP2_IO, 0x0101);
1635 break;
1636
Steven Toth6c5be742006-12-02 21:15:51 -02001637 default:
1638 err = -ENODEV;
1639 }
1640 return err;
1641}
1642
1643/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1644static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1645{
1646 struct cx88_core *core = drv->core;
1647 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001648 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001649
Trent Piepho6a59d642007-08-15 14:41:57 -03001650 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001651 case CX88_BOARD_HAUPPAUGE_HVR1300:
1652 /* Do Nothing, leave the cx22702 on the bus. */
1653 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001654 case CX88_BOARD_HAUPPAUGE_HVR3000:
1655 case CX88_BOARD_HAUPPAUGE_HVR4000:
1656 break;
Steven Toth6c5be742006-12-02 21:15:51 -02001657 default:
1658 err = -ENODEV;
1659 }
1660 return err;
1661}
1662
1663static int cx8802_dvb_probe(struct cx8802_driver *drv)
1664{
1665 struct cx88_core *core = drv->core;
1666 struct cx8802_dev *dev = drv->core->dvbdev;
Darron Broadcbd82442008-10-30 05:07:44 -03001667 int err;
Andy Walls6e0e12f2009-01-11 21:18:04 -03001668 struct videobuf_dvb_frontend *fe;
1669 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001670
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001671 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001672 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001673 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001674 core->name,
1675 core->pci_bus,
1676 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677
1678 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001679 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680 goto fail_core;
1681
Trent Piephoecf854d2007-05-05 20:11:32 -03001682 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001683 err = vp3054_i2c_probe(dev);
1684 if (0 != err)
Andy Walls6e0e12f2009-01-11 21:18:04 -03001685 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001686
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001688 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Steven Toth363c35f2008-10-11 11:05:50 -03001689 dev->ts_gen_cntrl = 0x0c;
1690
Andy Walls6e0e12f2009-01-11 21:18:04 -03001691 err = cx8802_alloc_frontends(dev);
1692 if (err)
1693 goto fail_core;
Darron Broadcbd82442008-10-30 05:07:44 -03001694
Andy Walls6e0e12f2009-01-11 21:18:04 -03001695 err = -ENODEV;
1696 for (i = 1; i <= core->board.num_frontends; i++) {
1697 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1698 if (fe == NULL) {
1699 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
Darron Broadcbd82442008-10-30 05:07:44 -03001700 __func__, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001701 goto fail_probe;
1702 }
1703 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
Darron Broadcbd82442008-10-30 05:07:44 -03001704 &dev->pci->dev, &dev->slock,
1705 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1706 V4L2_FIELD_TOP,
1707 sizeof(struct cx88_buffer),
Hans Verkuil08bff032010-09-20 17:39:46 -03001708 dev, NULL);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001709 /* init struct videobuf_dvb */
1710 fe->dvb.name = dev->core->name;
Steven Toth363c35f2008-10-11 11:05:50 -03001711 }
Andy Walls6e0e12f2009-01-11 21:18:04 -03001712
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713 err = dvb_register(dev);
Darron Broadcbd82442008-10-30 05:07:44 -03001714 if (err)
1715 /* frontends/adapter de-allocated in dvb_register */
Trent Piepho5772f812007-08-15 14:41:59 -03001716 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1717 core->name, err);
Darron Broadcbd82442008-10-30 05:07:44 -03001718 return err;
1719fail_probe:
1720 videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
Darron Broad92abe9e2008-10-11 11:18:53 -03001721fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 return err;
1723}
1724
Steven Toth6c5be742006-12-02 21:15:51 -02001725static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726{
Darron Broad0fcd4882008-10-21 11:18:47 -03001727 struct cx88_core *core = drv->core;
Steven Toth6c5be742006-12-02 21:15:51 -02001728 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001729
Darron Broad0fcd4882008-10-21 11:18:47 -03001730 dprintk( 1, "%s\n", __func__);
1731
Steven Toth363c35f2008-10-11 11:05:50 -03001732 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733
Chris Pascoefc40b262006-01-09 15:25:35 -02001734 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001735
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001736 core->gate_ctrl = NULL;
1737
Steven Toth6c5be742006-12-02 21:15:51 -02001738 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739}
1740
Steven Toth6c5be742006-12-02 21:15:51 -02001741static struct cx8802_driver cx8802_dvb_driver = {
1742 .type_id = CX88_MPEG_DVB,
1743 .hw_access = CX8802_DRVCTL_SHARED,
1744 .probe = cx8802_dvb_probe,
1745 .remove = cx8802_dvb_remove,
1746 .advise_acquire = cx8802_dvb_advise_acquire,
1747 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001748};
1749
Peter Huewe31d0f842009-07-17 01:00:01 +02001750static int __init dvb_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751{
Trent Piepho5772f812007-08-15 14:41:59 -03001752 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753 (CX88_VERSION_CODE >> 16) & 0xff,
1754 (CX88_VERSION_CODE >> 8) & 0xff,
1755 CX88_VERSION_CODE & 0xff);
1756#ifdef SNAPSHOT
1757 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1758 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1759#endif
Steven Toth6c5be742006-12-02 21:15:51 -02001760 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761}
1762
Peter Huewe31d0f842009-07-17 01:00:01 +02001763static void __exit dvb_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764{
Steven Toth6c5be742006-12-02 21:15:51 -02001765 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001766}
1767
1768module_init(dvb_init);
1769module_exit(dvb_fini);
1770
1771/*
1772 * Local variables:
1773 * c-basic-offset: 8
1774 * compile-command: "make DVB=1"
1775 * End:
1776 */