blob: e085851d6872adef06ddecc86b662442f238080f [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"
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -030061#include "ts2020.h"
Igor M. Liplianin0cb73632011-02-25 18:41:24 -030062#include "ds3000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070063
64MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
65MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
66MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
67MODULE_LICENSE("GPL");
Mauro Carvalho Chehab1990d502011-06-24 14:45:49 -030068MODULE_VERSION(CX88_VERSION);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030070static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071module_param(debug, int, 0644);
72MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
73
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030074static unsigned int dvb_buf_tscnt = 32;
75module_param(dvb_buf_tscnt, int, 0644);
76MODULE_PARM_DESC(dvb_buf_tscnt, "DVB Buffer TS count [dvb]");
77
Janne Grunau78e92002008-04-09 19:13:13 -030078DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020081 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/* ------------------------------------------------------------------ */
84
85static int dvb_buf_setup(struct videobuf_queue *q,
86 unsigned int *count, unsigned int *size)
87{
88 struct cx8802_dev *dev = q->priv_data;
89
90 dev->ts_packet_size = 188 * 4;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030091 dev->ts_packet_count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93 *size = dev->ts_packet_size * dev->ts_packet_count;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030094 *count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 return 0;
96}
97
Michael Krufky4a390552006-12-05 02:00:53 -030098static int dvb_buf_prepare(struct videobuf_queue *q,
99 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
101 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300102 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103}
104
105static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
106{
107 struct cx8802_dev *dev = q->priv_data;
108 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
109}
110
Michael Krufky4a390552006-12-05 02:00:53 -0300111static void dvb_buf_release(struct videobuf_queue *q,
112 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300114 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115}
116
lawrence rust2e4e98e2010-08-25 09:50:20 -0300117static const struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 .buf_setup = dvb_buf_setup,
119 .buf_prepare = dvb_buf_prepare,
120 .buf_queue = dvb_buf_queue,
121 .buf_release = dvb_buf_release,
122};
123
124/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300125
126static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
127{
128 struct cx8802_dev *dev= fe->dvb->priv;
129 struct cx8802_driver *drv = NULL;
130 int ret = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300131 int fe_id;
132
133 fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
134 if (!fe_id) {
Steven Toth2af03ee2008-10-16 20:17:31 -0300135 printk(KERN_ERR "%s() No frontend found\n", __func__);
Steven Toth363c35f2008-10-11 11:05:50 -0300136 return -EINVAL;
137 }
138
Jonathan Nieder8a317a82011-05-01 06:29:16 -0300139 mutex_lock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300140 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
141 if (drv) {
Steven Toth363c35f2008-10-11 11:05:50 -0300142 if (acquire){
143 dev->frontends.active_fe_id = fe_id;
Michael Krufky22f3f172006-12-05 01:38:58 -0300144 ret = drv->request_acquire(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300145 } else {
Michael Krufky22f3f172006-12-05 01:38:58 -0300146 ret = drv->request_release(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300147 dev->frontends.active_fe_id = 0;
148 }
Michael Krufky22f3f172006-12-05 01:38:58 -0300149 }
Jonathan Nieder1fe70e92011-05-01 06:29:37 -0300150 mutex_unlock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300151
152 return ret;
153}
154
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300155static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
156{
157 struct videobuf_dvb_frontends *f;
158 struct videobuf_dvb_frontend *fe;
159
160 if (!core->dvbdev)
161 return;
162
163 f = &core->dvbdev->frontends;
164
165 if (!f)
166 return;
167
168 if (f->gate <= 1) /* undefined or fe0 */
169 fe = videobuf_dvb_get_frontend(f, 1);
170 else
171 fe = videobuf_dvb_get_frontend(f, f->gate);
172
173 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
174 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
175}
176
Michael Krufky22f3f172006-12-05 01:38:58 -0300177/* ------------------------------------------------------------------ */
178
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200179static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300181 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
182 static const u8 reset [] = { RESET, 0x80 };
183 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
184 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
185 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
186 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
188 mt352_write(fe, clock_config, sizeof(clock_config));
189 udelay(200);
190 mt352_write(fe, reset, sizeof(reset));
191 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
192
193 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
194 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
195 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
196 return 0;
197}
198
Chris Pascoe43eabb42006-01-09 18:21:28 -0200199static int dvico_dual_demod_init(struct dvb_frontend *fe)
200{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300201 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
202 static const u8 reset [] = { RESET, 0x80 };
203 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
204 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
205 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
206 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Chris Pascoe43eabb42006-01-09 18:21:28 -0200207
208 mt352_write(fe, clock_config, sizeof(clock_config));
209 udelay(200);
210 mt352_write(fe, reset, sizeof(reset));
211 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
212
213 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
214 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
215 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
216
217 return 0;
218}
219
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
221{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300222 static const u8 clock_config [] = { 0x89, 0x38, 0x39 };
223 static const u8 reset [] = { 0x50, 0x80 };
224 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
225 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800226 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300227 static const u8 dntv_extra[] = { 0xB5, 0x7A };
228 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
230 mt352_write(fe, clock_config, sizeof(clock_config));
231 udelay(2000);
232 mt352_write(fe, reset, sizeof(reset));
233 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
234
235 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
236 udelay(2000);
237 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
238 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
239
240 return 0;
241}
242
lawrence rust2e4e98e2010-08-25 09:50:20 -0300243static const struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300244 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200245 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246};
247
lawrence rust2e4e98e2010-08-25 09:50:20 -0300248static const struct mt352_config dntv_live_dvbt_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 .demod_address = 0x0f,
250 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251};
Chris Pascoefc40b262006-01-09 15:25:35 -0200252
lawrence rust2e4e98e2010-08-25 09:50:20 -0300253static const struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300254 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200255 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200256};
257
lawrence rust2e4e98e2010-08-25 09:50:20 -0300258static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
Stephan Wienczny70101a22009-03-10 19:08:06 -0300259 .demod_address = (0x1e >> 1),
260 .no_tuner = 1,
261 .if2 = 45600,
262};
263
Sergey Ivanov111ac842010-08-09 10:18:32 -0300264static struct mb86a16_config twinhan_vp1027 = {
265 .demod_address = 0x08,
266};
267
Trent Piephoecf854d2007-05-05 20:11:32 -0300268#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200269static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
270{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300271 static const u8 clock_config [] = { 0x89, 0x38, 0x38 };
272 static const u8 reset [] = { 0x50, 0x80 };
273 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
274 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200275 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300276 static const u8 dntv_extra[] = { 0xB5, 0x7A };
277 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200278
279 mt352_write(fe, clock_config, sizeof(clock_config));
280 udelay(2000);
281 mt352_write(fe, reset, sizeof(reset));
282 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
283
284 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
285 udelay(2000);
286 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
287 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
288
289 return 0;
290}
291
lawrence rust2e4e98e2010-08-25 09:50:20 -0300292static const struct mt352_config dntv_live_dvbt_pro_config = {
Chris Pascoefc40b262006-01-09 15:25:35 -0200293 .demod_address = 0x0f,
294 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200295 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200296};
297#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298
lawrence rust2e4e98e2010-08-25 09:50:20 -0300299static const struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300300 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300301 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300302};
303
lawrence rust2e4e98e2010-08-25 09:50:20 -0300304static const struct zl10353_config dvico_fusionhdtv_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300305 .demod_address = 0x0f,
306 .if2 = 45600,
307 .no_tuner = 1,
308};
309
lawrence rust2e4e98e2010-08-25 09:50:20 -0300310static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300311 .demod_address = 0x0f,
312 .if2 = 4560,
313 .no_tuner = 1,
314 .demod_init = dvico_fusionhdtv_demod_init,
315};
316
lawrence rust2e4e98e2010-08-25 09:50:20 -0300317static const struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300318 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300319};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300320
lawrence rust2e4e98e2010-08-25 09:50:20 -0300321static const struct cx22702_config connexant_refboard_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700323 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324};
325
lawrence rust2e4e98e2010-08-25 09:50:20 -0300326static const struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300327 .demod_address = 0x63,
328 .output_mode = CX22702_SERIAL_OUTPUT,
329};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330
Michael Krufky4a390552006-12-05 02:00:53 -0300331static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332{
333 struct cx8802_dev *dev= fe->dvb->priv;
334 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
335 return 0;
336}
337
lawrence rust2e4e98e2010-08-25 09:50:20 -0300338static const struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300339 .demod_address = 0x15,
340 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342
Michael Krufky6ddcc912005-07-27 11:46:00 -0700343static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700344{
345 struct cx8802_dev *dev= fe->dvb->priv;
346 struct cx88_core *core = dev->core;
347
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300348 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700349 if (index == 0)
350 cx_clear(MO_GP0_IO, 8);
351 else
352 cx_set(MO_GP0_IO, 8);
353 return 0;
354}
355
Michael Krufky6ddcc912005-07-27 11:46:00 -0700356static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700357{
358 struct cx8802_dev *dev= fe->dvb->priv;
359 if (is_punctured)
360 dev->ts_gen_cntrl |= 0x04;
361 else
362 dev->ts_gen_cntrl &= ~0x04;
363 return 0;
364}
365
Michael Krufky6ddcc912005-07-27 11:46:00 -0700366static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300367 .demod_address = 0x0e,
368 .demod_chip = LGDT3302,
369 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
370 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700371};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700372
lawrence rust2e4e98e2010-08-25 09:50:20 -0300373static const struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300374 .demod_address = 0x0e,
375 .demod_chip = LGDT3303,
376 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
377 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700378};
Rusty Scottda215d22006-04-07 02:21:31 -0300379
lawrence rust2e4e98e2010-08-25 09:50:20 -0300380static const struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300381 .demod_address = 0x59,
382 .demod_chip = LGDT3303,
383 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
384 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300385};
Michael Krufkyf1798492005-07-07 17:58:39 -0700386
Michael Krufky4a390552006-12-05 02:00:53 -0300387static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800388{
389 struct cx8802_dev *dev= fe->dvb->priv;
390 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
391 return 0;
392}
393
lawrence rust2e4e98e2010-08-25 09:50:20 -0300394static const struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300395 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300396 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800397};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800398
Steven Toth0fa14aa2006-01-09 15:25:02 -0200399static int cx24123_set_ts_param(struct dvb_frontend* fe,
400 int is_punctured)
401{
402 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300403 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200404 return 0;
405}
406
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300407static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
408 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200409{
410 struct cx8802_dev *dev= fe->dvb->priv;
411 struct cx88_core *core = dev->core;
412
Michael Krufky4a390552006-12-05 02:00:53 -0300413 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300414 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300415 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300416 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300417
418 if (core->prev_set_voltage)
419 return core->prev_set_voltage(fe, voltage);
420 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200421}
422
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300423static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
424 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300425{
426 struct cx8802_dev *dev= fe->dvb->priv;
427 struct cx88_core *core = dev->core;
428
429 if (voltage == SEC_VOLTAGE_OFF) {
430 dprintk(1,"LNB Voltage OFF\n");
431 cx_write(MO_GP0_IO, 0x0000efff);
432 }
433
434 if (core->prev_set_voltage)
435 return core->prev_set_voltage(fe, voltage);
436 return 0;
437}
438
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300439static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
440 fe_sec_voltage_t voltage)
441{
442 struct cx8802_dev *dev= fe->dvb->priv;
443 struct cx88_core *core = dev->core;
444
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300445 cx_set(MO_GP0_IO, 0x6040);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300446 switch (voltage) {
Sergey Ivanov111ac842010-08-09 10:18:32 -0300447 case SEC_VOLTAGE_13:
448 cx_clear(MO_GP0_IO, 0x20);
449 break;
450 case SEC_VOLTAGE_18:
451 cx_set(MO_GP0_IO, 0x20);
452 break;
453 case SEC_VOLTAGE_OFF:
454 cx_clear(MO_GP0_IO, 0x20);
455 break;
456 }
457
458 if (core->prev_set_voltage)
459 return core->prev_set_voltage(fe, voltage);
460 return 0;
461}
462
463static int vp1027_set_voltage(struct dvb_frontend *fe,
464 fe_sec_voltage_t voltage)
465{
466 struct cx8802_dev *dev = fe->dvb->priv;
467 struct cx88_core *core = dev->core;
468
469 switch (voltage) {
470 case SEC_VOLTAGE_13:
471 dprintk(1, "LNB SEC Voltage=13\n");
472 cx_write(MO_GP0_IO, 0x00001220);
473 break;
474 case SEC_VOLTAGE_18:
475 dprintk(1, "LNB SEC Voltage=18\n");
476 cx_write(MO_GP0_IO, 0x00001222);
477 break;
478 case SEC_VOLTAGE_OFF:
479 dprintk(1, "LNB Voltage OFF\n");
480 cx_write(MO_GP0_IO, 0x00001230);
481 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300482 }
483
484 if (core->prev_set_voltage)
485 return core->prev_set_voltage(fe, voltage);
486 return 0;
487}
488
lawrence rust2e4e98e2010-08-25 09:50:20 -0300489static const struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300490 .demod_address = 0x55,
491 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300492};
493
lawrence rust2e4e98e2010-08-25 09:50:20 -0300494static const struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300495 .demod_address = 0x55,
496 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200497};
498
lawrence rust2e4e98e2010-08-25 09:50:20 -0300499static const struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300500 .demod_address = 0x15,
501 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300502 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200503};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200504
lawrence rust2e4e98e2010-08-25 09:50:20 -0300505static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300506 .demod_address = 0x32 >> 1,
507 .output_mode = S5H1409_PARALLEL_OUTPUT,
508 .gpio = S5H1409_GPIO_ON,
509 .qam_if = 44000,
510 .inversion = S5H1409_INVERSION_OFF,
511 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300512 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300513};
514
lawrence rust2e4e98e2010-08-25 09:50:20 -0300515static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
Steven Toth5c00fac2008-04-22 14:45:14 -0300516 .demod_address = 0x32 >> 1,
517 .output_mode = S5H1409_SERIAL_OUTPUT,
518 .gpio = S5H1409_GPIO_OFF,
519 .inversion = S5H1409_INVERSION_OFF,
520 .status_mode = S5H1409_DEMODLOCKING,
521 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
522};
523
lawrence rust2e4e98e2010-08-25 09:50:20 -0300524static const struct s5h1409_config kworld_atsc_120_config = {
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300525 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300526 .output_mode = S5H1409_SERIAL_OUTPUT,
527 .gpio = S5H1409_GPIO_OFF,
528 .inversion = S5H1409_INVERSION_OFF,
529 .status_mode = S5H1409_DEMODLOCKING,
530 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
531};
532
lawrence rust2e4e98e2010-08-25 09:50:20 -0300533static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300534 .i2c_address = 0x64,
535 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300536};
537
lawrence rust2e4e98e2010-08-25 09:50:20 -0300538static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
Stéphane Voltz3f6014f2008-09-05 14:33:54 -0300539 .demod_address = (0x1e >> 1),
540 .no_tuner = 1,
541 .if2 = 45600,
542};
543
lawrence rust2e4e98e2010-08-25 09:50:20 -0300544static const struct zl10353_config cx88_geniatech_x8000_mt = {
Mauro Carvalho Chehab57069342009-08-20 10:14:45 -0300545 .demod_address = (0x1e >> 1),
546 .no_tuner = 1,
547 .disable_i2c_gate_ctrl = 1,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300548};
549
lawrence rust2e4e98e2010-08-25 09:50:20 -0300550static const struct s5h1411_config dvico_fusionhdtv7_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300551 .output_mode = S5H1411_SERIAL_OUTPUT,
552 .gpio = S5H1411_GPIO_ON,
553 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
554 .qam_if = S5H1411_IF_44000,
555 .vsb_if = S5H1411_IF_44000,
556 .inversion = S5H1411_INVERSION_OFF,
557 .status_mode = S5H1411_DEMODLOCKING
558};
559
lawrence rust2e4e98e2010-08-25 09:50:20 -0300560static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300561 .i2c_address = 0xc2 >> 1,
562 .if_khz = 5380,
Steven Tothd893d5d2008-04-25 03:46:43 -0300563};
564
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300565static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
566{
567 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -0300568 struct videobuf_dvb_frontend *fe0 = NULL;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300569 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300570 struct xc2028_config cfg = {
571 .i2c_adap = &dev->core->i2c_adap,
572 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300573 .ctrl = &ctl,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300574 };
575
Darron Broad92abe9e2008-10-11 11:18:53 -0300576 /* Get the first frontend */
Steven Toth363c35f2008-10-11 11:05:50 -0300577 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
578 if (!fe0)
579 return -EINVAL;
580
581 if (!fe0->dvb.frontend) {
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300582 printk(KERN_ERR "%s/2: dvb frontend not attached. "
583 "Can't attach xc3028\n",
584 dev->core->name);
585 return -EINVAL;
586 }
587
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300588 /*
589 * Some xc3028 devices may be hidden by an I2C gate. This is known
590 * to happen with some s5h1409-based devices.
591 * Now that I2C gate is open, sets up xc3028 configuration
592 */
593 cx88_setup_xc3028(dev->core, &ctl);
594
Steven Toth363c35f2008-10-11 11:05:50 -0300595 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300596 if (!fe) {
597 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
598 dev->core->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300599 dvb_frontend_detach(fe0->dvb.frontend);
600 dvb_unregister_frontend(fe0->dvb.frontend);
601 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300602 return -EINVAL;
603 }
604
605 printk(KERN_INFO "%s/2: xc3028 attached\n",
606 dev->core->name);
607
608 return 0;
609}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300610
istvan_v@mailbox.huc21973e2011-06-07 13:12:29 -0300611static int attach_xc4000(struct cx8802_dev *dev, struct xc4000_config *cfg)
612{
613 struct dvb_frontend *fe;
614 struct videobuf_dvb_frontend *fe0 = NULL;
615
616 /* Get the first frontend */
617 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
618 if (!fe0)
619 return -EINVAL;
620
621 if (!fe0->dvb.frontend) {
622 printk(KERN_ERR "%s/2: dvb frontend not attached. "
623 "Can't attach xc4000\n",
624 dev->core->name);
625 return -EINVAL;
626 }
627
628 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend, &dev->core->i2c_adap,
629 cfg);
630 if (!fe) {
631 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
632 dev->core->name);
633 dvb_frontend_detach(fe0->dvb.frontend);
634 dvb_unregister_frontend(fe0->dvb.frontend);
635 fe0->dvb.frontend = NULL;
636 return -EINVAL;
637 }
638
639 printk(KERN_INFO "%s/2: xc4000 attached\n", dev->core->name);
640
641 return 0;
642}
643
Steven Toth5bd1b662008-09-04 01:17:33 -0300644static int cx24116_set_ts_param(struct dvb_frontend *fe,
645 int is_punctured)
646{
647 struct cx8802_dev *dev = fe->dvb->priv;
648 dev->ts_gen_cntrl = 0x2;
649
650 return 0;
651}
652
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300653static int stv0900_set_ts_param(struct dvb_frontend *fe,
654 int is_punctured)
655{
656 struct cx8802_dev *dev = fe->dvb->priv;
657 dev->ts_gen_cntrl = 0;
658
659 return 0;
660}
661
Steven Toth5bd1b662008-09-04 01:17:33 -0300662static int cx24116_reset_device(struct dvb_frontend *fe)
663{
664 struct cx8802_dev *dev = fe->dvb->priv;
665 struct cx88_core *core = dev->core;
666
667 /* Reset the part */
Steven Toth363c35f2008-10-11 11:05:50 -0300668 /* Put the cx24116 into reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300669 cx_write(MO_SRST_IO, 0);
670 msleep(10);
Steven Toth363c35f2008-10-11 11:05:50 -0300671 /* Take the cx24116 out of reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300672 cx_write(MO_SRST_IO, 1);
673 msleep(10);
674
675 return 0;
676}
677
lawrence rust2e4e98e2010-08-25 09:50:20 -0300678static const struct cx24116_config hauppauge_hvr4000_config = {
Steven Toth5bd1b662008-09-04 01:17:33 -0300679 .demod_address = 0x05,
680 .set_ts_params = cx24116_set_ts_param,
681 .reset_device = cx24116_reset_device,
682};
683
lawrence rust2e4e98e2010-08-25 09:50:20 -0300684static const struct cx24116_config tevii_s460_config = {
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300685 .demod_address = 0x55,
686 .set_ts_params = cx24116_set_ts_param,
687 .reset_device = cx24116_reset_device,
688};
689
Igor M. Liplianin0cb73632011-02-25 18:41:24 -0300690static int ds3000_set_ts_param(struct dvb_frontend *fe,
691 int is_punctured)
692{
693 struct cx8802_dev *dev = fe->dvb->priv;
694 dev->ts_gen_cntrl = 4;
695
696 return 0;
697}
698
699static struct ds3000_config tevii_ds3000_config = {
700 .demod_address = 0x68,
701 .set_ts_params = ds3000_set_ts_param,
702};
703
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300704static struct ts2020_config tevii_ts2020_config = {
705 .tuner_address = 0x60,
706};
707
lawrence rust2e4e98e2010-08-25 09:50:20 -0300708static const struct stv0900_config prof_7301_stv0900_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300709 .demod_address = 0x6a,
710/* demod_mode = 0,*/
711 .xtal = 27000000,
712 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
713 .diseqc_mode = 2,/* 2/3 PWM */
714 .tun1_maddress = 0,/* 0x60 */
715 .tun1_adc = 0,/* 2 Vpp */
716 .path1_mode = 3,
717 .set_ts_params = stv0900_set_ts_param,
718};
719
lawrence rust2e4e98e2010-08-25 09:50:20 -0300720static const struct stb6100_config prof_7301_stb6100_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300721 .tuner_address = 0x60,
722 .refclock = 27000000,
723};
724
lawrence rust2e4e98e2010-08-25 09:50:20 -0300725static const struct stv0299_config tevii_tuner_sharp_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300726 .demod_address = 0x68,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300727 .inittab = sharp_z0194a_inittab,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300728 .mclk = 88000000UL,
729 .invert = 1,
730 .skip_reinit = 0,
731 .lock_output = 1,
732 .volt13_op0_op1 = STV0299_VOLT13_OP1,
733 .min_delay_ms = 100,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300734 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300735 .set_ts_params = cx24116_set_ts_param,
736};
737
lawrence rust2e4e98e2010-08-25 09:50:20 -0300738static const struct stv0288_config tevii_tuner_earda_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300739 .demod_address = 0x68,
740 .min_delay_ms = 100,
741 .set_ts_params = cx24116_set_ts_param,
742};
743
Andy Walls6e0e12f2009-01-11 21:18:04 -0300744static int cx8802_alloc_frontends(struct cx8802_dev *dev)
745{
746 struct cx88_core *core = dev->core;
747 struct videobuf_dvb_frontend *fe = NULL;
748 int i;
749
750 mutex_init(&dev->frontends.lock);
751 INIT_LIST_HEAD(&dev->frontends.felist);
752
753 if (!core->board.num_frontends)
754 return -ENODEV;
755
756 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
757 core->board.num_frontends);
758 for (i = 1; i <= core->board.num_frontends; i++) {
759 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
760 if (!fe) {
761 printk(KERN_ERR "%s() failed to alloc\n", __func__);
762 videobuf_dvb_dealloc_frontends(&dev->frontends);
763 return -ENOMEM;
764 }
765 }
766 return 0;
767}
768
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300769
770
lawrence rust2e4e98e2010-08-25 09:50:20 -0300771static const u8 samsung_smt_7020_inittab[] = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300772 0x01, 0x15,
773 0x02, 0x00,
774 0x03, 0x00,
775 0x04, 0x7D,
776 0x05, 0x0F,
777 0x06, 0x02,
778 0x07, 0x00,
779 0x08, 0x60,
780
781 0x0A, 0xC2,
782 0x0B, 0x00,
783 0x0C, 0x01,
784 0x0D, 0x81,
785 0x0E, 0x44,
786 0x0F, 0x09,
787 0x10, 0x3C,
788 0x11, 0x84,
789 0x12, 0xDA,
790 0x13, 0x99,
791 0x14, 0x8D,
792 0x15, 0xCE,
793 0x16, 0xE8,
794 0x17, 0x43,
795 0x18, 0x1C,
796 0x19, 0x1B,
797 0x1A, 0x1D,
798
799 0x1C, 0x12,
800 0x1D, 0x00,
801 0x1E, 0x00,
802 0x1F, 0x00,
803 0x20, 0x00,
804 0x21, 0x00,
805 0x22, 0x00,
806 0x23, 0x00,
807
808 0x28, 0x02,
809 0x29, 0x28,
810 0x2A, 0x14,
811 0x2B, 0x0F,
812 0x2C, 0x09,
813 0x2D, 0x05,
814
815 0x31, 0x1F,
816 0x32, 0x19,
817 0x33, 0xFC,
818 0x34, 0x13,
819 0xff, 0xff,
820};
821
822
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300823static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe)
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300824{
Mauro Carvalho Chehabb738ae12011-12-23 12:33:05 -0300825 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300826 struct cx8802_dev *dev = fe->dvb->priv;
827 u8 buf[4];
828 u32 div;
829 struct i2c_msg msg = {
830 .addr = 0x61,
831 .flags = 0,
832 .buf = buf,
833 .len = sizeof(buf) };
834
Mauro Carvalho Chehabb738ae12011-12-23 12:33:05 -0300835 div = c->frequency / 125;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300836
837 buf[0] = (div >> 8) & 0x7f;
838 buf[1] = div & 0xff;
839 buf[2] = 0x84; /* 0xC4 */
840 buf[3] = 0x00;
841
Mauro Carvalho Chehabb738ae12011-12-23 12:33:05 -0300842 if (c->frequency < 1500000)
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300843 buf[3] |= 0x10;
844
845 if (fe->ops.i2c_gate_ctrl)
846 fe->ops.i2c_gate_ctrl(fe, 1);
847
848 if (i2c_transfer(&dev->core->i2c_adap, &msg, 1) != 1)
849 return -EIO;
850
851 return 0;
852}
853
854static int samsung_smt_7020_set_tone(struct dvb_frontend *fe,
855 fe_sec_tone_mode_t tone)
856{
857 struct cx8802_dev *dev = fe->dvb->priv;
858 struct cx88_core *core = dev->core;
859
860 cx_set(MO_GP0_IO, 0x0800);
861
862 switch (tone) {
863 case SEC_TONE_ON:
864 cx_set(MO_GP0_IO, 0x08);
865 break;
866 case SEC_TONE_OFF:
867 cx_clear(MO_GP0_IO, 0x08);
868 break;
869 default:
870 return -EINVAL;
871 }
872
873 return 0;
874}
875
876static int samsung_smt_7020_set_voltage(struct dvb_frontend *fe,
877 fe_sec_voltage_t voltage)
878{
879 struct cx8802_dev *dev = fe->dvb->priv;
880 struct cx88_core *core = dev->core;
881
882 u8 data;
883 struct i2c_msg msg = {
884 .addr = 8,
885 .flags = 0,
886 .buf = &data,
887 .len = sizeof(data) };
888
889 cx_set(MO_GP0_IO, 0x8000);
890
891 switch (voltage) {
892 case SEC_VOLTAGE_OFF:
893 break;
894 case SEC_VOLTAGE_13:
895 data = ISL6421_EN1 | ISL6421_LLC1;
896 cx_clear(MO_GP0_IO, 0x80);
897 break;
898 case SEC_VOLTAGE_18:
899 data = ISL6421_EN1 | ISL6421_LLC1 | ISL6421_VSEL1;
900 cx_clear(MO_GP0_IO, 0x80);
901 break;
902 default:
903 return -EINVAL;
Peter Senna Tschudinc2c1b412012-09-28 05:37:22 -0300904 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300905
906 return (i2c_transfer(&dev->core->i2c_adap, &msg, 1) == 1) ? 0 : -EIO;
907}
908
909static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
910 u32 srate, u32 ratio)
911{
912 u8 aclk = 0;
913 u8 bclk = 0;
914
915 if (srate < 1500000) {
916 aclk = 0xb7;
917 bclk = 0x47;
918 } else if (srate < 3000000) {
919 aclk = 0xb7;
920 bclk = 0x4b;
921 } else if (srate < 7000000) {
922 aclk = 0xb7;
923 bclk = 0x4f;
924 } else if (srate < 14000000) {
925 aclk = 0xb7;
926 bclk = 0x53;
927 } else if (srate < 30000000) {
928 aclk = 0xb6;
929 bclk = 0x53;
930 } else if (srate < 45000000) {
931 aclk = 0xb4;
932 bclk = 0x51;
933 }
934
935 stv0299_writereg(fe, 0x13, aclk);
936 stv0299_writereg(fe, 0x14, bclk);
937 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
938 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
939 stv0299_writereg(fe, 0x21, ratio & 0xf0);
940
941 return 0;
942}
943
944
lawrence rust2e4e98e2010-08-25 09:50:20 -0300945static const struct stv0299_config samsung_stv0299_config = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300946 .demod_address = 0x68,
947 .inittab = samsung_smt_7020_inittab,
948 .mclk = 88000000UL,
949 .invert = 0,
950 .skip_reinit = 0,
951 .lock_output = STV0299_LOCKOUTPUT_LK,
952 .volt13_op0_op1 = STV0299_VOLT13_OP1,
953 .min_delay_ms = 100,
954 .set_symbol_rate = samsung_smt_7020_stv0299_set_symbol_rate,
955};
956
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957static int dvb_register(struct cx8802_dev *dev)
958{
Steven Toth363c35f2008-10-11 11:05:50 -0300959 struct cx88_core *core = dev->core;
960 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
Darron Broad59b18422008-10-11 11:44:05 -0300961 int mfe_shared = 0; /* bus not shared by default */
David Fries7b0962d2011-12-15 01:59:20 -0300962 int res = -EINVAL;
Steven Toth363c35f2008-10-11 11:05:50 -0300963
Matthias Schwarzott0e8bac92008-10-24 10:47:07 -0300964 if (0 != core->i2c_rc) {
965 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
966 goto frontend_detach;
967 }
968
Steven Toth363c35f2008-10-11 11:05:50 -0300969 /* Get the first frontend */
970 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
971 if (!fe0)
Darron Broad60a5a922008-11-11 08:48:27 -0300972 goto frontend_detach;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973
Darron Broad8e739092008-10-11 11:31:41 -0300974 /* multi-frontend gate control is undefined or defaults to fe0 */
975 dev->frontends.gate = 0;
976
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300977 /* Sets the gate control callback to be used by i2c command calls */
978 core->gate_ctrl = cx88_dvb_gate_ctrl;
979
Darron Broad8e739092008-10-11 11:31:41 -0300980 /* init frontend(s) */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300981 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700982 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -0300983 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300984 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300985 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300986 if (fe0->dvb.frontend != NULL) {
987 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300988 0x61, &core->i2c_adap,
989 DVB_PLL_THOMSON_DTT759X))
990 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300991 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700993 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200995 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800996 case CX88_BOARD_WINFAST_DTV1000:
Steven Toth363c35f2008-10-11 11:05:50 -0300997 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300998 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300999 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001000 if (fe0->dvb.frontend != NULL) {
1001 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001002 0x60, &core->i2c_adap,
1003 DVB_PLL_THOMSON_DTT7579))
1004 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001005 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -03001007 case CX88_BOARD_WINFAST_DTV2000H:
Steven Toth611900c2006-01-09 15:25:12 -02001008 case CX88_BOARD_HAUPPAUGE_HVR1100:
1009 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -03001010 case CX88_BOARD_HAUPPAUGE_HVR1300:
Steven Toth363c35f2008-10-11 11:05:50 -03001011 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -03001012 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001013 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001014 if (fe0->dvb.frontend != NULL) {
1015 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001016 &core->i2c_adap, 0x61,
1017 TUNER_PHILIPS_FMD1216ME_MK3))
1018 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001019 }
Steven Toth611900c2006-01-09 15:25:12 -02001020 break;
Miroslav Slugen27b93d82011-12-13 15:36:15 -03001021 case CX88_BOARD_WINFAST_DTV2000H_J:
1022 fe0->dvb.frontend = dvb_attach(cx22702_attach,
1023 &hauppauge_hvr_config,
1024 &core->i2c_adap);
1025 if (fe0->dvb.frontend != NULL) {
1026 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1027 &core->i2c_adap, 0x61,
1028 TUNER_PHILIPS_FMD1216MEX_MK3))
1029 goto frontend_detach;
1030 }
1031 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001032 case CX88_BOARD_HAUPPAUGE_HVR3000:
Darron Broad60a5a922008-11-11 08:48:27 -03001033 /* MFE frontend 1 */
1034 mfe_shared = 1;
1035 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001036 /* DVB-S init */
1037 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001038 &hauppauge_novas_config,
1039 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001040 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001041 if (!dvb_attach(isl6421_attach,
1042 fe0->dvb.frontend,
1043 &dev->core->i2c_adap,
1044 0x08, ISL6421_DCL, 0x00))
1045 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001046 }
Darron Broad60a5a922008-11-11 08:48:27 -03001047 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001048 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001049 if (!fe1)
1050 goto frontend_detach;
1051 /* DVB-T init */
1052 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1053 &hauppauge_hvr_config,
1054 &dev->core->i2c_adap);
1055 if (fe1->dvb.frontend) {
1056 fe1->dvb.frontend->id = 1;
1057 if (!dvb_attach(simple_tuner_attach,
1058 fe1->dvb.frontend,
1059 &dev->core->i2c_adap,
1060 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1061 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001062 }
1063 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001064 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001065 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001066 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001067 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001068 if (fe0->dvb.frontend != NULL) {
1069 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001070 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1071 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001072 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001073 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001074 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001075 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001076 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001077 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001078 if (fe0->dvb.frontend != NULL) {
1079 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001080 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1081 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001082 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001083 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001084 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001085 /* The tin box says DEE1601, but it seems to be DTT7579
1086 * compatible, with a slightly different MT352 AGC gain. */
Steven Toth363c35f2008-10-11 11:05:50 -03001087 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001088 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001089 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001090 if (fe0->dvb.frontend != NULL) {
1091 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001092 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1093 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001094 break;
1095 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001096 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001097 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001098 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001099 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001100 if (fe0->dvb.frontend != NULL) {
1101 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001102 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1103 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001104 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001105 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -03001107 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001108 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001109 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001110 if (fe0->dvb.frontend != NULL) {
1111 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001112 0x61, NULL, DVB_PLL_LG_Z201))
1113 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001114 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 case CX88_BOARD_KWORLD_DVB_T:
1117 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001118 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Steven Toth363c35f2008-10-11 11:05:50 -03001119 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001120 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001121 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001122 if (fe0->dvb.frontend != NULL) {
1123 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001124 0x61, NULL, DVB_PLL_UNKNOWN_1))
1125 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001126 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 break;
Chris Pascoefc40b262006-01-09 15:25:35 -02001128 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -03001129#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -03001130 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Steven Toth363c35f2008-10-11 11:05:50 -03001131 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -03001132 &dev->vp3054->adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001133 if (fe0->dvb.frontend != NULL) {
1134 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001135 &core->i2c_adap, 0x61,
1136 TUNER_PHILIPS_FMD1216ME_MK3))
1137 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001138 }
Chris Pascoefc40b262006-01-09 15:25:35 -02001139#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001140 printk(KERN_ERR "%s/2: built without vp3054 support\n",
1141 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -02001142#endif
1143 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001144 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001145 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001146 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001147 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001148 if (fe0->dvb.frontend != NULL) {
1149 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001150 &core->i2c_adap, 0x61,
1151 TUNER_THOMSON_FE6600))
1152 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001153 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001154 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001155 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
Steven Toth363c35f2008-10-11 11:05:50 -03001156 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001157 &dvico_fusionhdtv_xc3028,
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 fe0->dvb.frontend = dvb_attach(mt352_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001161 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001162 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -03001163 /*
1164 * On this board, the demod provides the I2C bus pullup.
1165 * We must not permit gate_ctrl to be performed, or
1166 * the xc3028 cannot communicate on the bus.
1167 */
Steven Toth363c35f2008-10-11 11:05:50 -03001168 if (fe0->dvb.frontend)
1169 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001170 if (attach_xc3028(0x61, dev) < 0)
Darron Broadbecd4302008-10-21 11:47:50 -03001171 goto frontend_detach;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001172 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 case CX88_BOARD_PCHDTV_HD3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001174 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001175 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001176 if (fe0->dvb.frontend != NULL) {
1177 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001178 &core->i2c_adap, 0x61,
1179 TUNER_THOMSON_DTT761X))
1180 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001181 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 break;
Michael Krufkyf1798492005-07-07 17:58:39 -07001183 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
1184 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -07001185
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001186 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -07001187 cx_clear(MO_GP0_IO, 1);
1188 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001189 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -07001190 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001191
1192 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -07001193 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Steven Toth363c35f2008-10-11 11:05:50 -03001194 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001195 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001196 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001197 if (fe0->dvb.frontend != NULL) {
1198 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001199 &core->i2c_adap, 0x61,
1200 TUNER_MICROTUNE_4042FI5))
1201 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -07001202 }
1203 break;
Michael Krufky0d723c02005-07-07 17:58:42 -07001204 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
1205 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -07001206
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001207 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -07001208 cx_clear(MO_GP0_IO, 1);
1209 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -07001210 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -07001211 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001212 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001213 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001214 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001215 if (fe0->dvb.frontend != NULL) {
1216 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001217 &core->i2c_adap, 0x61,
1218 TUNER_THOMSON_DTT761X))
1219 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -07001220 }
1221 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001222 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
1223 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001224
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001225 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001226 cx_clear(MO_GP0_IO, 1);
1227 mdelay(100);
1228 cx_set(MO_GP0_IO, 1);
1229 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001230 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001231 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001232 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001233 if (fe0->dvb.frontend != NULL) {
1234 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001235 &core->i2c_adap, 0x61,
1236 TUNER_LG_TDVS_H06XF))
1237 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001238 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001239 &core->i2c_adap, 0x43))
1240 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001241 }
1242 break;
Rusty Scottda215d22006-04-07 02:21:31 -03001243 case CX88_BOARD_PCHDTV_HD5500:
1244 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -03001245
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001246 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -03001247 cx_clear(MO_GP0_IO, 1);
1248 mdelay(100);
1249 cx_set(MO_GP0_IO, 1);
1250 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001251 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001252 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001253 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001254 if (fe0->dvb.frontend != NULL) {
1255 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001256 &core->i2c_adap, 0x61,
1257 TUNER_LG_TDVS_H06XF))
1258 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001259 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001260 &core->i2c_adap, 0x43))
1261 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -03001262 }
1263 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -08001264 case CX88_BOARD_ATI_HDTVWONDER:
Steven Toth363c35f2008-10-11 11:05:50 -03001265 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001266 &ati_hdtvwonder,
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) {
1269 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001270 &core->i2c_adap, 0x61,
1271 TUNER_PHILIPS_TUV1236D))
1272 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001273 }
Kirk Laprayfde6d312005-11-08 21:38:18 -08001274 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -02001275 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
1276 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Steven Toth363c35f2008-10-11 11:05:50 -03001277 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001278 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001279 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001280 if (fe0->dvb.frontend) {
1281 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
Steven Toth83fe92e2008-09-13 19:22:15 -03001282 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001283 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001284 }
Steven Toth0fa14aa2006-01-09 15:25:02 -02001285 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -02001286 case CX88_BOARD_KWORLD_DVBS_100:
Steven Toth363c35f2008-10-11 11:05:50 -03001287 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001288 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001289 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001290 if (fe0->dvb.frontend) {
1291 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1292 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001293 }
Vadim Catana0e0351e2006-01-09 15:25:02 -02001294 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001295 case CX88_BOARD_GENIATECH_DVBS:
Steven Toth363c35f2008-10-11 11:05:50 -03001296 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001297 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001298 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001299 if (fe0->dvb.frontend) {
1300 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1301 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001302 }
1303 break;
Steven Toth60464da2008-01-05 16:53:01 -03001304 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth363c35f2008-10-11 11:05:50 -03001305 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth60464da2008-01-05 16:53:01 -03001306 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001307 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001308 if (fe0->dvb.frontend != NULL) {
1309 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001310 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001311 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001312 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -03001313 }
1314 break;
Steven Toth5c00fac2008-04-22 14:45:14 -03001315 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
Steven Toth363c35f2008-10-11 11:05:50 -03001316 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth5c00fac2008-04-22 14:45:14 -03001317 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001318 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001319 if (fe0->dvb.frontend != NULL) {
Steven Toth5c00fac2008-04-22 14:45:14 -03001320 struct dvb_frontend *fe;
1321 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001322 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -03001323 .i2c_addr = 0x61,
Steven Toth5c00fac2008-04-22 14:45:14 -03001324 };
1325 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001326 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -03001327 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -03001328 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -03001329 };
1330
1331 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001332 fe0->dvb.frontend, &cfg);
Steven Toth5c00fac2008-04-22 14:45:14 -03001333 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1334 fe->ops.tuner_ops.set_config(fe, &ctl);
1335 }
1336 break;
Ricardo Maraschinid49f7a22010-04-06 02:40:43 -03001337 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
Miroslav Sustek3047a172009-05-31 16:47:28 -03001338 case CX88_BOARD_WINFAST_DTV1800H:
Steven Toth363c35f2008-10-11 11:05:50 -03001339 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001340 &cx88_pinnacle_hybrid_pctv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001341 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001342 if (fe0->dvb.frontend) {
1343 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001344 if (attach_xc3028(0x61, dev) < 0)
1345 goto frontend_detach;
1346 }
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001347 break;
istvan_v@mailbox.hu8eb79c02011-06-07 13:16:56 -03001348 case CX88_BOARD_WINFAST_DTV1800H_XC4000:
istvan_v@mailbox.huf271a3a2011-06-07 13:14:53 -03001349 case CX88_BOARD_WINFAST_DTV2000H_PLUS:
1350 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1351 &cx88_pinnacle_hybrid_pctv,
1352 &core->i2c_adap);
1353 if (fe0->dvb.frontend) {
1354 struct xc4000_config cfg = {
1355 .i2c_address = 0x61,
1356 .default_pm = 0,
1357 .dvb_amplitude = 134,
1358 .set_smoothedcvbs = 1,
1359 .if_khz = 4560
1360 };
1361 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1362 if (attach_xc4000(dev, &cfg) < 0)
1363 goto frontend_detach;
1364 }
1365 break;
1366 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001367 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001368
Steven Toth363c35f2008-10-11 11:05:50 -03001369 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001370 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001371 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001372 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001373 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001374 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001375 case CX88_BOARD_KWORLD_ATSC_120:
Steven Toth363c35f2008-10-11 11:05:50 -03001376 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001377 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001378 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001379 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001380 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001381 break;
Steven Tothd893d5d2008-04-25 03:46:43 -03001382 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
Steven Toth363c35f2008-10-11 11:05:50 -03001383 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Steven Tothd893d5d2008-04-25 03:46:43 -03001384 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001385 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001386 if (fe0->dvb.frontend != NULL) {
1387 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001388 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001389 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001390 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -03001391 }
1392 break;
Steven Toth5bd1b662008-09-04 01:17:33 -03001393 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad60a5a922008-11-11 08:48:27 -03001394 /* MFE frontend 1 */
1395 mfe_shared = 1;
1396 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001397 /* DVB-S/S2 Init */
1398 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001399 &hauppauge_hvr4000_config,
1400 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001401 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001402 if (!dvb_attach(isl6421_attach,
1403 fe0->dvb.frontend,
1404 &dev->core->i2c_adap,
1405 0x08, ISL6421_DCL, 0x00))
1406 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001407 }
Darron Broad60a5a922008-11-11 08:48:27 -03001408 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001409 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001410 if (!fe1)
1411 goto frontend_detach;
1412 /* DVB-T Init */
1413 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1414 &hauppauge_hvr_config,
1415 &dev->core->i2c_adap);
1416 if (fe1->dvb.frontend) {
1417 fe1->dvb.frontend->id = 1;
1418 if (!dvb_attach(simple_tuner_attach,
1419 fe1->dvb.frontend,
1420 &dev->core->i2c_adap,
1421 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1422 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001423 }
1424 break;
1425 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1426 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001427 &hauppauge_hvr4000_config,
1428 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001429 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001430 if (!dvb_attach(isl6421_attach,
1431 fe0->dvb.frontend,
1432 &dev->core->i2c_adap,
1433 0x08, ISL6421_DCL, 0x00))
1434 goto frontend_detach;
Steven Toth5bd1b662008-09-04 01:17:33 -03001435 }
1436 break;
Igor M. Liplianincd3cde12008-11-09 15:26:25 -03001437 case CX88_BOARD_PROF_6200:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001438 case CX88_BOARD_TBS_8910:
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001439 case CX88_BOARD_TEVII_S420:
Steven Toth363c35f2008-10-11 11:05:50 -03001440 fe0->dvb.frontend = dvb_attach(stv0299_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001441 &tevii_tuner_sharp_config,
1442 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001443 if (fe0->dvb.frontend != NULL) {
1444 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001445 &core->i2c_adap, DVB_PLL_OPERA1))
1446 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001447 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1448 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001449
1450 } else {
Steven Toth363c35f2008-10-11 11:05:50 -03001451 fe0->dvb.frontend = dvb_attach(stv0288_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001452 &tevii_tuner_earda_config,
1453 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001454 if (fe0->dvb.frontend != NULL) {
1455 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001456 &core->i2c_adap))
1457 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001458 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1459 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001460 }
1461 }
1462 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001463 case CX88_BOARD_TEVII_S460:
Steven Toth363c35f2008-10-11 11:05:50 -03001464 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001465 &tevii_s460_config,
1466 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001467 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001468 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001469 break;
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001470 case CX88_BOARD_TEVII_S464:
1471 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1472 &tevii_ds3000_config,
1473 &core->i2c_adap);
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001474 if (fe0->dvb.frontend != NULL) {
1475 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1476 &tevii_ts2020_config, &core->i2c_adap);
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001477 fe0->dvb.frontend->ops.set_voltage =
1478 tevii_dvbs_set_voltage;
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001479 }
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001480 break;
Oleg Roitburd4cd7fb82008-09-17 11:30:21 -03001481 case CX88_BOARD_OMICOM_SS4_PCI:
Oleg Roitburdee730422008-09-17 11:58:33 -03001482 case CX88_BOARD_TBS_8920:
Oleg Roitburd57f51db2008-10-08 06:48:08 -03001483 case CX88_BOARD_PROF_7300:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001484 case CX88_BOARD_SATTRADE_ST4200:
Steven Toth363c35f2008-10-11 11:05:50 -03001485 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Oleg Roitburdee730422008-09-17 11:58:33 -03001486 &hauppauge_hvr4000_config,
1487 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001488 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001489 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Oleg Roitburdee730422008-09-17 11:58:33 -03001490 break;
Stephan Wienczny70101a22009-03-10 19:08:06 -03001491 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
1492 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1493 &cx88_terratec_cinergy_ht_pci_mkii_config,
1494 &core->i2c_adap);
1495 if (fe0->dvb.frontend) {
1496 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1497 if (attach_xc3028(0x61, dev) < 0)
1498 goto frontend_detach;
1499 }
1500 break;
Igor M. Liplianinb699c272009-11-16 22:22:32 -03001501 case CX88_BOARD_PROF_7301:{
1502 struct dvb_tuner_ops *tuner_ops = NULL;
1503
1504 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1505 &prof_7301_stv0900_config,
1506 &core->i2c_adap, 0);
1507 if (fe0->dvb.frontend != NULL) {
1508 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1509 &prof_7301_stb6100_config,
1510 &core->i2c_adap))
1511 goto frontend_detach;
1512
1513 tuner_ops = &fe0->dvb.frontend->ops.tuner_ops;
1514 tuner_ops->set_frequency = stb6100_set_freq;
1515 tuner_ops->get_frequency = stb6100_get_freq;
1516 tuner_ops->set_bandwidth = stb6100_set_bandw;
1517 tuner_ops->get_bandwidth = stb6100_get_bandw;
1518
1519 core->prev_set_voltage =
1520 fe0->dvb.frontend->ops.set_voltage;
1521 fe0->dvb.frontend->ops.set_voltage =
1522 tevii_dvbs_set_voltage;
1523 }
1524 break;
1525 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001526 case CX88_BOARD_SAMSUNG_SMT_7020:
1527 dev->ts_gen_cntrl = 0x08;
1528
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001529 cx_set(MO_GP0_IO, 0x0101);
1530
1531 cx_clear(MO_GP0_IO, 0x01);
1532 mdelay(100);
1533 cx_set(MO_GP0_IO, 0x01);
1534 mdelay(200);
1535
1536 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1537 &samsung_stv0299_config,
1538 &dev->core->i2c_adap);
1539 if (fe0->dvb.frontend) {
1540 fe0->dvb.frontend->ops.tuner_ops.set_params =
1541 samsung_smt_7020_tuner_set_params;
1542 fe0->dvb.frontend->tuner_priv =
1543 &dev->core->i2c_adap;
1544 fe0->dvb.frontend->ops.set_voltage =
1545 samsung_smt_7020_set_voltage;
1546 fe0->dvb.frontend->ops.set_tone =
1547 samsung_smt_7020_set_tone;
1548 }
1549
1550 break;
Sergey Ivanov111ac842010-08-09 10:18:32 -03001551 case CX88_BOARD_TWINHAN_VP1027_DVBS:
1552 dev->ts_gen_cntrl = 0x00;
1553 fe0->dvb.frontend = dvb_attach(mb86a16_attach,
1554 &twinhan_vp1027,
1555 &core->i2c_adap);
1556 if (fe0->dvb.frontend) {
1557 core->prev_set_voltage =
1558 fe0->dvb.frontend->ops.set_voltage;
1559 fe0->dvb.frontend->ops.set_voltage =
1560 vp1027_set_voltage;
1561 }
1562 break;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001563
Linus Torvalds1da177e2005-04-16 15:20:36 -07001564 default:
Trent Piepho5772f812007-08-15 14:41:59 -03001565 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 -03001566 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 break;
1568 }
Steven Toth363c35f2008-10-11 11:05:50 -03001569
Mauro Carvalho Chehab2c9bcea2008-11-10 23:35:00 -02001570 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001571 printk(KERN_ERR
1572 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001573 core->name);
Darron Broad60a5a922008-11-11 08:48:27 -03001574 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001575 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001576 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001577 fe0->dvb.frontend->callback = cx88_tuner_callback;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001578
Steven Toth6c5be742006-12-02 21:15:51 -02001579 /* Ensure all frontends negotiate bus access */
Steven Toth363c35f2008-10-11 11:05:50 -03001580 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1581 if (fe1)
1582 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001583
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001584 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001585 call_all(core, core, s_power, 0);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001586
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587 /* register everything */
David Fries7b0962d2011-12-15 01:59:20 -03001588 res = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Mauro Carvalho Chehab9adf6132012-08-05 14:16:30 -03001589 &dev->pci->dev, adapter_nr, mfe_shared);
David Fries7b0962d2011-12-15 01:59:20 -03001590 if (res)
1591 goto frontend_detach;
1592 return res;
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001593
1594frontend_detach:
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001595 core->gate_ctrl = NULL;
Darron Broadbecd4302008-10-21 11:47:50 -03001596 videobuf_dvb_dealloc_frontends(&dev->frontends);
David Fries7b0962d2011-12-15 01:59:20 -03001597 return res;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598}
1599
1600/* ----------------------------------------------------------- */
1601
Steven Toth6c5be742006-12-02 21:15:51 -02001602/* CX8802 MPEG -> mini driver - We have been given the hardware */
1603static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604{
Steven Toth6c5be742006-12-02 21:15:51 -02001605 struct cx88_core *core = drv->core;
1606 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001607 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001608
Trent Piepho6a59d642007-08-15 14:41:57 -03001609 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001610 case CX88_BOARD_HAUPPAUGE_HVR1300:
1611 /* We arrive here with either the cx23416 or the cx22702
1612 * on the bus. Take the bus from the cx23416 and enable the
1613 * cx22702 demod
1614 */
Darron Broad79392732008-12-18 06:28:35 -03001615 /* Toggle reset on cx22702 leaving i2c active */
1616 cx_set(MO_GP0_IO, 0x00000080);
1617 udelay(1000);
1618 cx_clear(MO_GP0_IO, 0x00000080);
1619 udelay(50);
1620 cx_set(MO_GP0_IO, 0x00000080);
1621 udelay(1000);
1622 /* enable the cx22702 pins */
Steven Toth6c5be742006-12-02 21:15:51 -02001623 cx_clear(MO_GP0_IO, 0x00000004);
1624 udelay(1000);
1625 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001626
Darron Broad92abe9e2008-10-11 11:18:53 -03001627 case CX88_BOARD_HAUPPAUGE_HVR3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001628 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad79392732008-12-18 06:28:35 -03001629 /* Toggle reset on cx22702 leaving i2c active */
1630 cx_set(MO_GP0_IO, 0x00000080);
1631 udelay(1000);
1632 cx_clear(MO_GP0_IO, 0x00000080);
1633 udelay(50);
1634 cx_set(MO_GP0_IO, 0x00000080);
1635 udelay(1000);
1636 switch (core->dvbdev->frontends.active_fe_id) {
1637 case 1: /* DVB-S/S2 Enabled */
1638 /* tri-state the cx22702 pins */
1639 cx_set(MO_GP0_IO, 0x00000004);
1640 /* Take the cx24116/cx24123 out of reset */
1641 cx_write(MO_SRST_IO, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001642 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
Darron Broad79392732008-12-18 06:28:35 -03001643 break;
1644 case 2: /* DVB-T Enabled */
Steven Toth363c35f2008-10-11 11:05:50 -03001645 /* Put the cx24116/cx24123 into reset */
1646 cx_write(MO_SRST_IO, 0);
Darron Broad79392732008-12-18 06:28:35 -03001647 /* enable the cx22702 pins */
Steven Toth363c35f2008-10-11 11:05:50 -03001648 cx_clear(MO_GP0_IO, 0x00000004);
1649 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
Darron Broad79392732008-12-18 06:28:35 -03001650 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001651 }
Darron Broad79392732008-12-18 06:28:35 -03001652 udelay(1000);
Steven Toth363c35f2008-10-11 11:05:50 -03001653 break;
1654
istvan_v@mailbox.huf271a3a2011-06-07 13:14:53 -03001655 case CX88_BOARD_WINFAST_DTV2000H_PLUS:
1656 /* set RF input to AIR for DVB-T (GPIO 16) */
1657 cx_write(MO_GP2_IO, 0x0101);
1658 break;
1659
Steven Toth6c5be742006-12-02 21:15:51 -02001660 default:
1661 err = -ENODEV;
1662 }
1663 return err;
1664}
1665
1666/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1667static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1668{
1669 struct cx88_core *core = drv->core;
1670 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001671 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001672
Trent Piepho6a59d642007-08-15 14:41:57 -03001673 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001674 case CX88_BOARD_HAUPPAUGE_HVR1300:
1675 /* Do Nothing, leave the cx22702 on the bus. */
1676 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001677 case CX88_BOARD_HAUPPAUGE_HVR3000:
1678 case CX88_BOARD_HAUPPAUGE_HVR4000:
1679 break;
Steven Toth6c5be742006-12-02 21:15:51 -02001680 default:
1681 err = -ENODEV;
1682 }
1683 return err;
1684}
1685
1686static int cx8802_dvb_probe(struct cx8802_driver *drv)
1687{
1688 struct cx88_core *core = drv->core;
1689 struct cx8802_dev *dev = drv->core->dvbdev;
Darron Broadcbd82442008-10-30 05:07:44 -03001690 int err;
Andy Walls6e0e12f2009-01-11 21:18:04 -03001691 struct videobuf_dvb_frontend *fe;
1692 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001693
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001694 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001695 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001696 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001697 core->name,
1698 core->pci_bus,
1699 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700
1701 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001702 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703 goto fail_core;
1704
Trent Piephoecf854d2007-05-05 20:11:32 -03001705 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001706 err = vp3054_i2c_probe(dev);
1707 if (0 != err)
Andy Walls6e0e12f2009-01-11 21:18:04 -03001708 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001709
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001711 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Steven Toth363c35f2008-10-11 11:05:50 -03001712 dev->ts_gen_cntrl = 0x0c;
1713
Andy Walls6e0e12f2009-01-11 21:18:04 -03001714 err = cx8802_alloc_frontends(dev);
1715 if (err)
1716 goto fail_core;
Darron Broadcbd82442008-10-30 05:07:44 -03001717
Andy Walls6e0e12f2009-01-11 21:18:04 -03001718 err = -ENODEV;
1719 for (i = 1; i <= core->board.num_frontends; i++) {
1720 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1721 if (fe == NULL) {
1722 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
Darron Broadcbd82442008-10-30 05:07:44 -03001723 __func__, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001724 goto fail_probe;
1725 }
1726 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
Darron Broadcbd82442008-10-30 05:07:44 -03001727 &dev->pci->dev, &dev->slock,
1728 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1729 V4L2_FIELD_TOP,
1730 sizeof(struct cx88_buffer),
Hans Verkuil08bff032010-09-20 17:39:46 -03001731 dev, NULL);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001732 /* init struct videobuf_dvb */
1733 fe->dvb.name = dev->core->name;
Steven Toth363c35f2008-10-11 11:05:50 -03001734 }
Andy Walls6e0e12f2009-01-11 21:18:04 -03001735
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 err = dvb_register(dev);
Darron Broadcbd82442008-10-30 05:07:44 -03001737 if (err)
1738 /* frontends/adapter de-allocated in dvb_register */
Trent Piepho5772f812007-08-15 14:41:59 -03001739 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1740 core->name, err);
Darron Broadcbd82442008-10-30 05:07:44 -03001741 return err;
1742fail_probe:
1743 videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
Darron Broad92abe9e2008-10-11 11:18:53 -03001744fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745 return err;
1746}
1747
Steven Toth6c5be742006-12-02 21:15:51 -02001748static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749{
Darron Broad0fcd4882008-10-21 11:18:47 -03001750 struct cx88_core *core = drv->core;
Steven Toth6c5be742006-12-02 21:15:51 -02001751 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001752
Darron Broad0fcd4882008-10-21 11:18:47 -03001753 dprintk( 1, "%s\n", __func__);
1754
Steven Toth363c35f2008-10-11 11:05:50 -03001755 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001756
Chris Pascoefc40b262006-01-09 15:25:35 -02001757 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001758
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001759 core->gate_ctrl = NULL;
1760
Steven Toth6c5be742006-12-02 21:15:51 -02001761 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762}
1763
Steven Toth6c5be742006-12-02 21:15:51 -02001764static struct cx8802_driver cx8802_dvb_driver = {
1765 .type_id = CX88_MPEG_DVB,
1766 .hw_access = CX8802_DRVCTL_SHARED,
1767 .probe = cx8802_dvb_probe,
1768 .remove = cx8802_dvb_remove,
1769 .advise_acquire = cx8802_dvb_advise_acquire,
1770 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001771};
1772
Peter Huewe31d0f842009-07-17 01:00:01 +02001773static int __init dvb_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774{
Mauro Carvalho Chehab1990d502011-06-24 14:45:49 -03001775 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %s loaded\n",
1776 CX88_VERSION);
Steven Toth6c5be742006-12-02 21:15:51 -02001777 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778}
1779
Peter Huewe31d0f842009-07-17 01:00:01 +02001780static void __exit dvb_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001781{
Steven Toth6c5be742006-12-02 21:15:51 -02001782 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783}
1784
1785module_init(dvb_init);
1786module_exit(dvb_fini);