blob: 0829a4f65f6ec31017e0b3661aece21cbb4e2049 [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");
Mauro Carvalho Chehab1990d502011-06-24 14:45:49 -030067MODULE_VERSION(CX88_VERSION);
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030069static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070module_param(debug, int, 0644);
71MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
72
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030073static unsigned int dvb_buf_tscnt = 32;
74module_param(dvb_buf_tscnt, int, 0644);
75MODULE_PARM_DESC(dvb_buf_tscnt, "DVB Buffer TS count [dvb]");
76
Janne Grunau78e92002008-04-09 19:13:13 -030077DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020080 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070081
82/* ------------------------------------------------------------------ */
83
84static int dvb_buf_setup(struct videobuf_queue *q,
85 unsigned int *count, unsigned int *size)
86{
87 struct cx8802_dev *dev = q->priv_data;
88
89 dev->ts_packet_size = 188 * 4;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030090 dev->ts_packet_count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92 *size = dev->ts_packet_size * dev->ts_packet_count;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030093 *count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070094 return 0;
95}
96
Michael Krufky4a390552006-12-05 02:00:53 -030097static int dvb_buf_prepare(struct videobuf_queue *q,
98 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070099{
100 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300101 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102}
103
104static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
105{
106 struct cx8802_dev *dev = q->priv_data;
107 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
108}
109
Michael Krufky4a390552006-12-05 02:00:53 -0300110static void dvb_buf_release(struct videobuf_queue *q,
111 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300113 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114}
115
lawrence rust2e4e98e2010-08-25 09:50:20 -0300116static const struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 .buf_setup = dvb_buf_setup,
118 .buf_prepare = dvb_buf_prepare,
119 .buf_queue = dvb_buf_queue,
120 .buf_release = dvb_buf_release,
121};
122
123/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300124
125static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
126{
127 struct cx8802_dev *dev= fe->dvb->priv;
128 struct cx8802_driver *drv = NULL;
129 int ret = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300130 int fe_id;
131
132 fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
133 if (!fe_id) {
Steven Toth2af03ee2008-10-16 20:17:31 -0300134 printk(KERN_ERR "%s() No frontend found\n", __func__);
Steven Toth363c35f2008-10-11 11:05:50 -0300135 return -EINVAL;
136 }
137
Jonathan Nieder8a317a82011-05-01 06:29:16 -0300138 mutex_lock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300139 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
140 if (drv) {
Steven Toth363c35f2008-10-11 11:05:50 -0300141 if (acquire){
142 dev->frontends.active_fe_id = fe_id;
Michael Krufky22f3f172006-12-05 01:38:58 -0300143 ret = drv->request_acquire(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300144 } else {
Michael Krufky22f3f172006-12-05 01:38:58 -0300145 ret = drv->request_release(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300146 dev->frontends.active_fe_id = 0;
147 }
Michael Krufky22f3f172006-12-05 01:38:58 -0300148 }
Jonathan Nieder1fe70e92011-05-01 06:29:37 -0300149 mutex_unlock(&dev->core->lock);
Michael Krufky22f3f172006-12-05 01:38:58 -0300150
151 return ret;
152}
153
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300154static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
155{
156 struct videobuf_dvb_frontends *f;
157 struct videobuf_dvb_frontend *fe;
158
159 if (!core->dvbdev)
160 return;
161
162 f = &core->dvbdev->frontends;
163
164 if (!f)
165 return;
166
167 if (f->gate <= 1) /* undefined or fe0 */
168 fe = videobuf_dvb_get_frontend(f, 1);
169 else
170 fe = videobuf_dvb_get_frontend(f, f->gate);
171
172 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
173 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
174}
175
Michael Krufky22f3f172006-12-05 01:38:58 -0300176/* ------------------------------------------------------------------ */
177
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200178static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300180 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
181 static const u8 reset [] = { RESET, 0x80 };
182 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
183 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
184 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
185 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
187 mt352_write(fe, clock_config, sizeof(clock_config));
188 udelay(200);
189 mt352_write(fe, reset, sizeof(reset));
190 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
191
192 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
193 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
194 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
195 return 0;
196}
197
Chris Pascoe43eabb42006-01-09 18:21:28 -0200198static int dvico_dual_demod_init(struct dvb_frontend *fe)
199{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300200 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
201 static const u8 reset [] = { RESET, 0x80 };
202 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
203 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
204 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
205 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Chris Pascoe43eabb42006-01-09 18:21:28 -0200206
207 mt352_write(fe, clock_config, sizeof(clock_config));
208 udelay(200);
209 mt352_write(fe, reset, sizeof(reset));
210 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
211
212 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
213 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
214 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
215
216 return 0;
217}
218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
220{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300221 static const u8 clock_config [] = { 0x89, 0x38, 0x39 };
222 static const u8 reset [] = { 0x50, 0x80 };
223 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
224 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800225 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300226 static const u8 dntv_extra[] = { 0xB5, 0x7A };
227 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228
229 mt352_write(fe, clock_config, sizeof(clock_config));
230 udelay(2000);
231 mt352_write(fe, reset, sizeof(reset));
232 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
233
234 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
235 udelay(2000);
236 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
237 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
238
239 return 0;
240}
241
lawrence rust2e4e98e2010-08-25 09:50:20 -0300242static const struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300243 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200244 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245};
246
lawrence rust2e4e98e2010-08-25 09:50:20 -0300247static const struct mt352_config dntv_live_dvbt_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .demod_address = 0x0f,
249 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250};
Chris Pascoefc40b262006-01-09 15:25:35 -0200251
lawrence rust2e4e98e2010-08-25 09:50:20 -0300252static const struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300253 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200254 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200255};
256
lawrence rust2e4e98e2010-08-25 09:50:20 -0300257static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
Stephan Wienczny70101a22009-03-10 19:08:06 -0300258 .demod_address = (0x1e >> 1),
259 .no_tuner = 1,
260 .if2 = 45600,
261};
262
Sergey Ivanov111ac842010-08-09 10:18:32 -0300263static struct mb86a16_config twinhan_vp1027 = {
264 .demod_address = 0x08,
265};
266
Trent Piephoecf854d2007-05-05 20:11:32 -0300267#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200268static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
269{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300270 static const u8 clock_config [] = { 0x89, 0x38, 0x38 };
271 static const u8 reset [] = { 0x50, 0x80 };
272 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
273 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200274 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300275 static const u8 dntv_extra[] = { 0xB5, 0x7A };
276 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200277
278 mt352_write(fe, clock_config, sizeof(clock_config));
279 udelay(2000);
280 mt352_write(fe, reset, sizeof(reset));
281 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
282
283 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
284 udelay(2000);
285 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
286 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
287
288 return 0;
289}
290
lawrence rust2e4e98e2010-08-25 09:50:20 -0300291static const struct mt352_config dntv_live_dvbt_pro_config = {
Chris Pascoefc40b262006-01-09 15:25:35 -0200292 .demod_address = 0x0f,
293 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200294 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200295};
296#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
lawrence rust2e4e98e2010-08-25 09:50:20 -0300298static const struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300299 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300300 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300301};
302
lawrence rust2e4e98e2010-08-25 09:50:20 -0300303static const struct zl10353_config dvico_fusionhdtv_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300304 .demod_address = 0x0f,
305 .if2 = 45600,
306 .no_tuner = 1,
307};
308
lawrence rust2e4e98e2010-08-25 09:50:20 -0300309static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300310 .demod_address = 0x0f,
311 .if2 = 4560,
312 .no_tuner = 1,
313 .demod_init = dvico_fusionhdtv_demod_init,
314};
315
lawrence rust2e4e98e2010-08-25 09:50:20 -0300316static const struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300317 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300318};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300319
lawrence rust2e4e98e2010-08-25 09:50:20 -0300320static const struct cx22702_config connexant_refboard_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700322 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323};
324
lawrence rust2e4e98e2010-08-25 09:50:20 -0300325static const struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300326 .demod_address = 0x63,
327 .output_mode = CX22702_SERIAL_OUTPUT,
328};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329
Michael Krufky4a390552006-12-05 02:00:53 -0300330static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331{
332 struct cx8802_dev *dev= fe->dvb->priv;
333 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
334 return 0;
335}
336
lawrence rust2e4e98e2010-08-25 09:50:20 -0300337static const struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300338 .demod_address = 0x15,
339 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341
Michael Krufky6ddcc912005-07-27 11:46:00 -0700342static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700343{
344 struct cx8802_dev *dev= fe->dvb->priv;
345 struct cx88_core *core = dev->core;
346
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300347 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700348 if (index == 0)
349 cx_clear(MO_GP0_IO, 8);
350 else
351 cx_set(MO_GP0_IO, 8);
352 return 0;
353}
354
Michael Krufky6ddcc912005-07-27 11:46:00 -0700355static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700356{
357 struct cx8802_dev *dev= fe->dvb->priv;
358 if (is_punctured)
359 dev->ts_gen_cntrl |= 0x04;
360 else
361 dev->ts_gen_cntrl &= ~0x04;
362 return 0;
363}
364
Michael Krufky6ddcc912005-07-27 11:46:00 -0700365static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300366 .demod_address = 0x0e,
367 .demod_chip = LGDT3302,
368 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
369 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700370};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700371
lawrence rust2e4e98e2010-08-25 09:50:20 -0300372static const struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300373 .demod_address = 0x0e,
374 .demod_chip = LGDT3303,
375 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
376 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700377};
Rusty Scottda215d22006-04-07 02:21:31 -0300378
lawrence rust2e4e98e2010-08-25 09:50:20 -0300379static const struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300380 .demod_address = 0x59,
381 .demod_chip = LGDT3303,
382 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
383 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300384};
Michael Krufkyf1798492005-07-07 17:58:39 -0700385
Michael Krufky4a390552006-12-05 02:00:53 -0300386static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800387{
388 struct cx8802_dev *dev= fe->dvb->priv;
389 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
390 return 0;
391}
392
lawrence rust2e4e98e2010-08-25 09:50:20 -0300393static const struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300394 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300395 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800396};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800397
Steven Toth0fa14aa2006-01-09 15:25:02 -0200398static int cx24123_set_ts_param(struct dvb_frontend* fe,
399 int is_punctured)
400{
401 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300402 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200403 return 0;
404}
405
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300406static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
407 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200408{
409 struct cx8802_dev *dev= fe->dvb->priv;
410 struct cx88_core *core = dev->core;
411
Michael Krufky4a390552006-12-05 02:00:53 -0300412 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300413 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300414 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300415 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300416
417 if (core->prev_set_voltage)
418 return core->prev_set_voltage(fe, voltage);
419 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200420}
421
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300422static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
423 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300424{
425 struct cx8802_dev *dev= fe->dvb->priv;
426 struct cx88_core *core = dev->core;
427
428 if (voltage == SEC_VOLTAGE_OFF) {
429 dprintk(1,"LNB Voltage OFF\n");
430 cx_write(MO_GP0_IO, 0x0000efff);
431 }
432
433 if (core->prev_set_voltage)
434 return core->prev_set_voltage(fe, voltage);
435 return 0;
436}
437
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300438static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
439 fe_sec_voltage_t voltage)
440{
441 struct cx8802_dev *dev= fe->dvb->priv;
442 struct cx88_core *core = dev->core;
443
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300444 cx_set(MO_GP0_IO, 0x6040);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300445 switch (voltage) {
Sergey Ivanov111ac842010-08-09 10:18:32 -0300446 case SEC_VOLTAGE_13:
447 cx_clear(MO_GP0_IO, 0x20);
448 break;
449 case SEC_VOLTAGE_18:
450 cx_set(MO_GP0_IO, 0x20);
451 break;
452 case SEC_VOLTAGE_OFF:
453 cx_clear(MO_GP0_IO, 0x20);
454 break;
455 }
456
457 if (core->prev_set_voltage)
458 return core->prev_set_voltage(fe, voltage);
459 return 0;
460}
461
462static int vp1027_set_voltage(struct dvb_frontend *fe,
463 fe_sec_voltage_t voltage)
464{
465 struct cx8802_dev *dev = fe->dvb->priv;
466 struct cx88_core *core = dev->core;
467
468 switch (voltage) {
469 case SEC_VOLTAGE_13:
470 dprintk(1, "LNB SEC Voltage=13\n");
471 cx_write(MO_GP0_IO, 0x00001220);
472 break;
473 case SEC_VOLTAGE_18:
474 dprintk(1, "LNB SEC Voltage=18\n");
475 cx_write(MO_GP0_IO, 0x00001222);
476 break;
477 case SEC_VOLTAGE_OFF:
478 dprintk(1, "LNB Voltage OFF\n");
479 cx_write(MO_GP0_IO, 0x00001230);
480 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300481 }
482
483 if (core->prev_set_voltage)
484 return core->prev_set_voltage(fe, voltage);
485 return 0;
486}
487
lawrence rust2e4e98e2010-08-25 09:50:20 -0300488static const struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300489 .demod_address = 0x55,
490 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300491};
492
lawrence rust2e4e98e2010-08-25 09:50:20 -0300493static const struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300494 .demod_address = 0x55,
495 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200496};
497
lawrence rust2e4e98e2010-08-25 09:50:20 -0300498static const struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300499 .demod_address = 0x15,
500 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300501 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200502};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200503
lawrence rust2e4e98e2010-08-25 09:50:20 -0300504static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300505 .demod_address = 0x32 >> 1,
506 .output_mode = S5H1409_PARALLEL_OUTPUT,
507 .gpio = S5H1409_GPIO_ON,
508 .qam_if = 44000,
509 .inversion = S5H1409_INVERSION_OFF,
510 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300511 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300512};
513
lawrence rust2e4e98e2010-08-25 09:50:20 -0300514static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
Steven Toth5c00fac2008-04-22 14:45:14 -0300515 .demod_address = 0x32 >> 1,
516 .output_mode = S5H1409_SERIAL_OUTPUT,
517 .gpio = S5H1409_GPIO_OFF,
518 .inversion = S5H1409_INVERSION_OFF,
519 .status_mode = S5H1409_DEMODLOCKING,
520 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
521};
522
lawrence rust2e4e98e2010-08-25 09:50:20 -0300523static const struct s5h1409_config kworld_atsc_120_config = {
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300524 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300525 .output_mode = S5H1409_SERIAL_OUTPUT,
526 .gpio = S5H1409_GPIO_OFF,
527 .inversion = S5H1409_INVERSION_OFF,
528 .status_mode = S5H1409_DEMODLOCKING,
529 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
530};
531
lawrence rust2e4e98e2010-08-25 09:50:20 -0300532static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300533 .i2c_address = 0x64,
534 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300535};
536
lawrence rust2e4e98e2010-08-25 09:50:20 -0300537static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
Stéphane Voltz3f6014f2008-09-05 14:33:54 -0300538 .demod_address = (0x1e >> 1),
539 .no_tuner = 1,
540 .if2 = 45600,
541};
542
lawrence rust2e4e98e2010-08-25 09:50:20 -0300543static const struct zl10353_config cx88_geniatech_x8000_mt = {
Mauro Carvalho Chehab57069342009-08-20 10:14:45 -0300544 .demod_address = (0x1e >> 1),
545 .no_tuner = 1,
546 .disable_i2c_gate_ctrl = 1,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300547};
548
lawrence rust2e4e98e2010-08-25 09:50:20 -0300549static const struct s5h1411_config dvico_fusionhdtv7_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300550 .output_mode = S5H1411_SERIAL_OUTPUT,
551 .gpio = S5H1411_GPIO_ON,
552 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
553 .qam_if = S5H1411_IF_44000,
554 .vsb_if = S5H1411_IF_44000,
555 .inversion = S5H1411_INVERSION_OFF,
556 .status_mode = S5H1411_DEMODLOCKING
557};
558
lawrence rust2e4e98e2010-08-25 09:50:20 -0300559static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300560 .i2c_address = 0xc2 >> 1,
561 .if_khz = 5380,
Steven Tothd893d5d2008-04-25 03:46:43 -0300562};
563
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300564static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
565{
566 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -0300567 struct videobuf_dvb_frontend *fe0 = NULL;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300568 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300569 struct xc2028_config cfg = {
570 .i2c_adap = &dev->core->i2c_adap,
571 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300572 .ctrl = &ctl,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300573 };
574
Darron Broad92abe9e2008-10-11 11:18:53 -0300575 /* Get the first frontend */
Steven Toth363c35f2008-10-11 11:05:50 -0300576 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
577 if (!fe0)
578 return -EINVAL;
579
580 if (!fe0->dvb.frontend) {
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300581 printk(KERN_ERR "%s/2: dvb frontend not attached. "
582 "Can't attach xc3028\n",
583 dev->core->name);
584 return -EINVAL;
585 }
586
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300587 /*
588 * Some xc3028 devices may be hidden by an I2C gate. This is known
589 * to happen with some s5h1409-based devices.
590 * Now that I2C gate is open, sets up xc3028 configuration
591 */
592 cx88_setup_xc3028(dev->core, &ctl);
593
Steven Toth363c35f2008-10-11 11:05:50 -0300594 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300595 if (!fe) {
596 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
597 dev->core->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300598 dvb_frontend_detach(fe0->dvb.frontend);
599 dvb_unregister_frontend(fe0->dvb.frontend);
600 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300601 return -EINVAL;
602 }
603
604 printk(KERN_INFO "%s/2: xc3028 attached\n",
605 dev->core->name);
606
607 return 0;
608}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300609
istvan_v@mailbox.huc21973e2011-06-07 13:12:29 -0300610static int attach_xc4000(struct cx8802_dev *dev, struct xc4000_config *cfg)
611{
612 struct dvb_frontend *fe;
613 struct videobuf_dvb_frontend *fe0 = NULL;
614
615 /* Get the first frontend */
616 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
617 if (!fe0)
618 return -EINVAL;
619
620 if (!fe0->dvb.frontend) {
621 printk(KERN_ERR "%s/2: dvb frontend not attached. "
622 "Can't attach xc4000\n",
623 dev->core->name);
624 return -EINVAL;
625 }
626
627 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend, &dev->core->i2c_adap,
628 cfg);
629 if (!fe) {
630 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
631 dev->core->name);
632 dvb_frontend_detach(fe0->dvb.frontend);
633 dvb_unregister_frontend(fe0->dvb.frontend);
634 fe0->dvb.frontend = NULL;
635 return -EINVAL;
636 }
637
638 printk(KERN_INFO "%s/2: xc4000 attached\n", dev->core->name);
639
640 return 0;
641}
642
Steven Toth5bd1b662008-09-04 01:17:33 -0300643static int cx24116_set_ts_param(struct dvb_frontend *fe,
644 int is_punctured)
645{
646 struct cx8802_dev *dev = fe->dvb->priv;
647 dev->ts_gen_cntrl = 0x2;
648
649 return 0;
650}
651
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300652static int stv0900_set_ts_param(struct dvb_frontend *fe,
653 int is_punctured)
654{
655 struct cx8802_dev *dev = fe->dvb->priv;
656 dev->ts_gen_cntrl = 0;
657
658 return 0;
659}
660
Steven Toth5bd1b662008-09-04 01:17:33 -0300661static int cx24116_reset_device(struct dvb_frontend *fe)
662{
663 struct cx8802_dev *dev = fe->dvb->priv;
664 struct cx88_core *core = dev->core;
665
666 /* Reset the part */
Steven Toth363c35f2008-10-11 11:05:50 -0300667 /* Put the cx24116 into reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300668 cx_write(MO_SRST_IO, 0);
669 msleep(10);
Steven Toth363c35f2008-10-11 11:05:50 -0300670 /* Take the cx24116 out of reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300671 cx_write(MO_SRST_IO, 1);
672 msleep(10);
673
674 return 0;
675}
676
lawrence rust2e4e98e2010-08-25 09:50:20 -0300677static const struct cx24116_config hauppauge_hvr4000_config = {
Steven Toth5bd1b662008-09-04 01:17:33 -0300678 .demod_address = 0x05,
679 .set_ts_params = cx24116_set_ts_param,
680 .reset_device = cx24116_reset_device,
681};
682
lawrence rust2e4e98e2010-08-25 09:50:20 -0300683static const struct cx24116_config tevii_s460_config = {
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300684 .demod_address = 0x55,
685 .set_ts_params = cx24116_set_ts_param,
686 .reset_device = cx24116_reset_device,
687};
688
Igor M. Liplianin0cb73632011-02-25 18:41:24 -0300689static int ds3000_set_ts_param(struct dvb_frontend *fe,
690 int is_punctured)
691{
692 struct cx8802_dev *dev = fe->dvb->priv;
693 dev->ts_gen_cntrl = 4;
694
695 return 0;
696}
697
698static struct ds3000_config tevii_ds3000_config = {
699 .demod_address = 0x68,
700 .set_ts_params = ds3000_set_ts_param,
701};
702
lawrence rust2e4e98e2010-08-25 09:50:20 -0300703static const struct stv0900_config prof_7301_stv0900_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300704 .demod_address = 0x6a,
705/* demod_mode = 0,*/
706 .xtal = 27000000,
707 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
708 .diseqc_mode = 2,/* 2/3 PWM */
709 .tun1_maddress = 0,/* 0x60 */
710 .tun1_adc = 0,/* 2 Vpp */
711 .path1_mode = 3,
712 .set_ts_params = stv0900_set_ts_param,
713};
714
lawrence rust2e4e98e2010-08-25 09:50:20 -0300715static const struct stb6100_config prof_7301_stb6100_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300716 .tuner_address = 0x60,
717 .refclock = 27000000,
718};
719
lawrence rust2e4e98e2010-08-25 09:50:20 -0300720static const struct stv0299_config tevii_tuner_sharp_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300721 .demod_address = 0x68,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300722 .inittab = sharp_z0194a_inittab,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300723 .mclk = 88000000UL,
724 .invert = 1,
725 .skip_reinit = 0,
726 .lock_output = 1,
727 .volt13_op0_op1 = STV0299_VOLT13_OP1,
728 .min_delay_ms = 100,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300729 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300730 .set_ts_params = cx24116_set_ts_param,
731};
732
lawrence rust2e4e98e2010-08-25 09:50:20 -0300733static const struct stv0288_config tevii_tuner_earda_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300734 .demod_address = 0x68,
735 .min_delay_ms = 100,
736 .set_ts_params = cx24116_set_ts_param,
737};
738
Andy Walls6e0e12f2009-01-11 21:18:04 -0300739static int cx8802_alloc_frontends(struct cx8802_dev *dev)
740{
741 struct cx88_core *core = dev->core;
742 struct videobuf_dvb_frontend *fe = NULL;
743 int i;
744
745 mutex_init(&dev->frontends.lock);
746 INIT_LIST_HEAD(&dev->frontends.felist);
747
748 if (!core->board.num_frontends)
749 return -ENODEV;
750
751 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
752 core->board.num_frontends);
753 for (i = 1; i <= core->board.num_frontends; i++) {
754 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
755 if (!fe) {
756 printk(KERN_ERR "%s() failed to alloc\n", __func__);
757 videobuf_dvb_dealloc_frontends(&dev->frontends);
758 return -ENOMEM;
759 }
760 }
761 return 0;
762}
763
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300764
765
lawrence rust2e4e98e2010-08-25 09:50:20 -0300766static const u8 samsung_smt_7020_inittab[] = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300767 0x01, 0x15,
768 0x02, 0x00,
769 0x03, 0x00,
770 0x04, 0x7D,
771 0x05, 0x0F,
772 0x06, 0x02,
773 0x07, 0x00,
774 0x08, 0x60,
775
776 0x0A, 0xC2,
777 0x0B, 0x00,
778 0x0C, 0x01,
779 0x0D, 0x81,
780 0x0E, 0x44,
781 0x0F, 0x09,
782 0x10, 0x3C,
783 0x11, 0x84,
784 0x12, 0xDA,
785 0x13, 0x99,
786 0x14, 0x8D,
787 0x15, 0xCE,
788 0x16, 0xE8,
789 0x17, 0x43,
790 0x18, 0x1C,
791 0x19, 0x1B,
792 0x1A, 0x1D,
793
794 0x1C, 0x12,
795 0x1D, 0x00,
796 0x1E, 0x00,
797 0x1F, 0x00,
798 0x20, 0x00,
799 0x21, 0x00,
800 0x22, 0x00,
801 0x23, 0x00,
802
803 0x28, 0x02,
804 0x29, 0x28,
805 0x2A, 0x14,
806 0x2B, 0x0F,
807 0x2C, 0x09,
808 0x2D, 0x05,
809
810 0x31, 0x1F,
811 0x32, 0x19,
812 0x33, 0xFC,
813 0x34, 0x13,
814 0xff, 0xff,
815};
816
817
Mauro Carvalho Chehab14d24d12011-12-24 12:24:33 -0300818static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe)
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300819{
Mauro Carvalho Chehabb738ae12011-12-23 12:33:05 -0300820 struct dtv_frontend_properties *c = &fe->dtv_property_cache;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300821 struct cx8802_dev *dev = fe->dvb->priv;
822 u8 buf[4];
823 u32 div;
824 struct i2c_msg msg = {
825 .addr = 0x61,
826 .flags = 0,
827 .buf = buf,
828 .len = sizeof(buf) };
829
Mauro Carvalho Chehabb738ae12011-12-23 12:33:05 -0300830 div = c->frequency / 125;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300831
832 buf[0] = (div >> 8) & 0x7f;
833 buf[1] = div & 0xff;
834 buf[2] = 0x84; /* 0xC4 */
835 buf[3] = 0x00;
836
Mauro Carvalho Chehabb738ae12011-12-23 12:33:05 -0300837 if (c->frequency < 1500000)
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300838 buf[3] |= 0x10;
839
840 if (fe->ops.i2c_gate_ctrl)
841 fe->ops.i2c_gate_ctrl(fe, 1);
842
843 if (i2c_transfer(&dev->core->i2c_adap, &msg, 1) != 1)
844 return -EIO;
845
846 return 0;
847}
848
849static int samsung_smt_7020_set_tone(struct dvb_frontend *fe,
850 fe_sec_tone_mode_t tone)
851{
852 struct cx8802_dev *dev = fe->dvb->priv;
853 struct cx88_core *core = dev->core;
854
855 cx_set(MO_GP0_IO, 0x0800);
856
857 switch (tone) {
858 case SEC_TONE_ON:
859 cx_set(MO_GP0_IO, 0x08);
860 break;
861 case SEC_TONE_OFF:
862 cx_clear(MO_GP0_IO, 0x08);
863 break;
864 default:
865 return -EINVAL;
866 }
867
868 return 0;
869}
870
871static int samsung_smt_7020_set_voltage(struct dvb_frontend *fe,
872 fe_sec_voltage_t voltage)
873{
874 struct cx8802_dev *dev = fe->dvb->priv;
875 struct cx88_core *core = dev->core;
876
877 u8 data;
878 struct i2c_msg msg = {
879 .addr = 8,
880 .flags = 0,
881 .buf = &data,
882 .len = sizeof(data) };
883
884 cx_set(MO_GP0_IO, 0x8000);
885
886 switch (voltage) {
887 case SEC_VOLTAGE_OFF:
888 break;
889 case SEC_VOLTAGE_13:
890 data = ISL6421_EN1 | ISL6421_LLC1;
891 cx_clear(MO_GP0_IO, 0x80);
892 break;
893 case SEC_VOLTAGE_18:
894 data = ISL6421_EN1 | ISL6421_LLC1 | ISL6421_VSEL1;
895 cx_clear(MO_GP0_IO, 0x80);
896 break;
897 default:
898 return -EINVAL;
899 };
900
901 return (i2c_transfer(&dev->core->i2c_adap, &msg, 1) == 1) ? 0 : -EIO;
902}
903
904static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
905 u32 srate, u32 ratio)
906{
907 u8 aclk = 0;
908 u8 bclk = 0;
909
910 if (srate < 1500000) {
911 aclk = 0xb7;
912 bclk = 0x47;
913 } else if (srate < 3000000) {
914 aclk = 0xb7;
915 bclk = 0x4b;
916 } else if (srate < 7000000) {
917 aclk = 0xb7;
918 bclk = 0x4f;
919 } else if (srate < 14000000) {
920 aclk = 0xb7;
921 bclk = 0x53;
922 } else if (srate < 30000000) {
923 aclk = 0xb6;
924 bclk = 0x53;
925 } else if (srate < 45000000) {
926 aclk = 0xb4;
927 bclk = 0x51;
928 }
929
930 stv0299_writereg(fe, 0x13, aclk);
931 stv0299_writereg(fe, 0x14, bclk);
932 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
933 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
934 stv0299_writereg(fe, 0x21, ratio & 0xf0);
935
936 return 0;
937}
938
939
lawrence rust2e4e98e2010-08-25 09:50:20 -0300940static const struct stv0299_config samsung_stv0299_config = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300941 .demod_address = 0x68,
942 .inittab = samsung_smt_7020_inittab,
943 .mclk = 88000000UL,
944 .invert = 0,
945 .skip_reinit = 0,
946 .lock_output = STV0299_LOCKOUTPUT_LK,
947 .volt13_op0_op1 = STV0299_VOLT13_OP1,
948 .min_delay_ms = 100,
949 .set_symbol_rate = samsung_smt_7020_stv0299_set_symbol_rate,
950};
951
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952static int dvb_register(struct cx8802_dev *dev)
953{
Steven Toth363c35f2008-10-11 11:05:50 -0300954 struct cx88_core *core = dev->core;
955 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
Darron Broad59b18422008-10-11 11:44:05 -0300956 int mfe_shared = 0; /* bus not shared by default */
David Fries7b0962d2011-12-15 01:59:20 -0300957 int res = -EINVAL;
Steven Toth363c35f2008-10-11 11:05:50 -0300958
Matthias Schwarzott0e8bac92008-10-24 10:47:07 -0300959 if (0 != core->i2c_rc) {
960 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
961 goto frontend_detach;
962 }
963
Steven Toth363c35f2008-10-11 11:05:50 -0300964 /* Get the first frontend */
965 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
966 if (!fe0)
Darron Broad60a5a922008-11-11 08:48:27 -0300967 goto frontend_detach;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968
Darron Broad8e739092008-10-11 11:31:41 -0300969 /* multi-frontend gate control is undefined or defaults to fe0 */
970 dev->frontends.gate = 0;
971
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300972 /* Sets the gate control callback to be used by i2c command calls */
973 core->gate_ctrl = cx88_dvb_gate_ctrl;
974
Darron Broad8e739092008-10-11 11:31:41 -0300975 /* init frontend(s) */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300976 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -0300978 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300979 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300980 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300981 if (fe0->dvb.frontend != NULL) {
982 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300983 0x61, &core->i2c_adap,
984 DVB_PLL_THOMSON_DTT759X))
985 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300986 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700988 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200990 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800991 case CX88_BOARD_WINFAST_DTV1000:
Steven Toth363c35f2008-10-11 11:05:50 -0300992 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300993 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300994 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300995 if (fe0->dvb.frontend != NULL) {
996 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300997 0x60, &core->i2c_adap,
998 DVB_PLL_THOMSON_DTT7579))
999 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001000 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -03001002 case CX88_BOARD_WINFAST_DTV2000H:
Vlastimil Labsky4d14c832009-08-10 22:15:54 -03001003 case CX88_BOARD_WINFAST_DTV2000H_J:
Steven Toth611900c2006-01-09 15:25:12 -02001004 case CX88_BOARD_HAUPPAUGE_HVR1100:
1005 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -03001006 case CX88_BOARD_HAUPPAUGE_HVR1300:
Steven Toth363c35f2008-10-11 11:05:50 -03001007 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -03001008 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001009 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001010 if (fe0->dvb.frontend != NULL) {
1011 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001012 &core->i2c_adap, 0x61,
1013 TUNER_PHILIPS_FMD1216ME_MK3))
1014 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001015 }
Steven Toth611900c2006-01-09 15:25:12 -02001016 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001017 case CX88_BOARD_HAUPPAUGE_HVR3000:
Darron Broad60a5a922008-11-11 08:48:27 -03001018 /* MFE frontend 1 */
1019 mfe_shared = 1;
1020 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001021 /* DVB-S init */
1022 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001023 &hauppauge_novas_config,
1024 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001025 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001026 if (!dvb_attach(isl6421_attach,
1027 fe0->dvb.frontend,
1028 &dev->core->i2c_adap,
1029 0x08, ISL6421_DCL, 0x00))
1030 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001031 }
Darron Broad60a5a922008-11-11 08:48:27 -03001032 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001033 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001034 if (!fe1)
1035 goto frontend_detach;
1036 /* DVB-T init */
1037 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1038 &hauppauge_hvr_config,
1039 &dev->core->i2c_adap);
1040 if (fe1->dvb.frontend) {
1041 fe1->dvb.frontend->id = 1;
1042 if (!dvb_attach(simple_tuner_attach,
1043 fe1->dvb.frontend,
1044 &dev->core->i2c_adap,
1045 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1046 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001047 }
1048 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001049 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001050 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001051 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001052 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001053 if (fe0->dvb.frontend != NULL) {
1054 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001055 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1056 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001057 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001058 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001059 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001060 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001061 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001062 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001063 if (fe0->dvb.frontend != NULL) {
1064 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001065 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1066 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001067 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001068 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001069 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001070 /* The tin box says DEE1601, but it seems to be DTT7579
1071 * compatible, with a slightly different MT352 AGC gain. */
Steven Toth363c35f2008-10-11 11:05:50 -03001072 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001073 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001074 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001075 if (fe0->dvb.frontend != NULL) {
1076 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001077 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1078 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001079 break;
1080 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001081 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001082 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001083 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001084 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001085 if (fe0->dvb.frontend != NULL) {
1086 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001087 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1088 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001089 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001090 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -03001092 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001093 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001094 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001095 if (fe0->dvb.frontend != NULL) {
1096 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001097 0x61, NULL, DVB_PLL_LG_Z201))
1098 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001099 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 case CX88_BOARD_KWORLD_DVB_T:
1102 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001103 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Steven Toth363c35f2008-10-11 11:05:50 -03001104 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001105 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001106 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001107 if (fe0->dvb.frontend != NULL) {
1108 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001109 0x61, NULL, DVB_PLL_UNKNOWN_1))
1110 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001111 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 break;
Chris Pascoefc40b262006-01-09 15:25:35 -02001113 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -03001114#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -03001115 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Steven Toth363c35f2008-10-11 11:05:50 -03001116 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -03001117 &dev->vp3054->adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001118 if (fe0->dvb.frontend != NULL) {
1119 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001120 &core->i2c_adap, 0x61,
1121 TUNER_PHILIPS_FMD1216ME_MK3))
1122 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001123 }
Chris Pascoefc40b262006-01-09 15:25:35 -02001124#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001125 printk(KERN_ERR "%s/2: built without vp3054 support\n",
1126 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -02001127#endif
1128 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001129 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001130 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001131 &dvico_fusionhdtv_hybrid,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001132 &core->i2c_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_THOMSON_FE6600))
1137 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001138 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001139 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001140 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
Steven Toth363c35f2008-10-11 11:05:50 -03001141 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001142 &dvico_fusionhdtv_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001143 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001144 if (fe0->dvb.frontend == NULL)
1145 fe0->dvb.frontend = dvb_attach(mt352_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001146 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001147 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -03001148 /*
1149 * On this board, the demod provides the I2C bus pullup.
1150 * We must not permit gate_ctrl to be performed, or
1151 * the xc3028 cannot communicate on the bus.
1152 */
Steven Toth363c35f2008-10-11 11:05:50 -03001153 if (fe0->dvb.frontend)
1154 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001155 if (attach_xc3028(0x61, dev) < 0)
Darron Broadbecd4302008-10-21 11:47:50 -03001156 goto frontend_detach;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001157 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 case CX88_BOARD_PCHDTV_HD3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001159 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001160 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001161 if (fe0->dvb.frontend != NULL) {
1162 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001163 &core->i2c_adap, 0x61,
1164 TUNER_THOMSON_DTT761X))
1165 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001166 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 break;
Michael Krufkyf1798492005-07-07 17:58:39 -07001168 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
1169 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -07001170
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001171 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -07001172 cx_clear(MO_GP0_IO, 1);
1173 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001174 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -07001175 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001176
1177 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -07001178 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Steven Toth363c35f2008-10-11 11:05:50 -03001179 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001180 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001181 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001182 if (fe0->dvb.frontend != NULL) {
1183 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001184 &core->i2c_adap, 0x61,
1185 TUNER_MICROTUNE_4042FI5))
1186 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -07001187 }
1188 break;
Michael Krufky0d723c02005-07-07 17:58:42 -07001189 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
1190 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -07001191
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001192 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -07001193 cx_clear(MO_GP0_IO, 1);
1194 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -07001195 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -07001196 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001197 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001198 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001199 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001200 if (fe0->dvb.frontend != NULL) {
1201 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001202 &core->i2c_adap, 0x61,
1203 TUNER_THOMSON_DTT761X))
1204 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -07001205 }
1206 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001207 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
1208 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001209
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001210 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001211 cx_clear(MO_GP0_IO, 1);
1212 mdelay(100);
1213 cx_set(MO_GP0_IO, 1);
1214 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001215 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001216 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001217 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001218 if (fe0->dvb.frontend != NULL) {
1219 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001220 &core->i2c_adap, 0x61,
1221 TUNER_LG_TDVS_H06XF))
1222 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001223 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001224 &core->i2c_adap, 0x43))
1225 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001226 }
1227 break;
Rusty Scottda215d22006-04-07 02:21:31 -03001228 case CX88_BOARD_PCHDTV_HD5500:
1229 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -03001230
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001231 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -03001232 cx_clear(MO_GP0_IO, 1);
1233 mdelay(100);
1234 cx_set(MO_GP0_IO, 1);
1235 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001236 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001237 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001238 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001239 if (fe0->dvb.frontend != NULL) {
1240 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001241 &core->i2c_adap, 0x61,
1242 TUNER_LG_TDVS_H06XF))
1243 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001244 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001245 &core->i2c_adap, 0x43))
1246 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -03001247 }
1248 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -08001249 case CX88_BOARD_ATI_HDTVWONDER:
Steven Toth363c35f2008-10-11 11:05:50 -03001250 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001251 &ati_hdtvwonder,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001252 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001253 if (fe0->dvb.frontend != NULL) {
1254 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001255 &core->i2c_adap, 0x61,
1256 TUNER_PHILIPS_TUV1236D))
1257 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001258 }
Kirk Laprayfde6d312005-11-08 21:38:18 -08001259 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -02001260 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
1261 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Steven Toth363c35f2008-10-11 11:05:50 -03001262 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001263 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001264 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001265 if (fe0->dvb.frontend) {
1266 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
Steven Toth83fe92e2008-09-13 19:22:15 -03001267 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001268 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001269 }
Steven Toth0fa14aa2006-01-09 15:25:02 -02001270 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -02001271 case CX88_BOARD_KWORLD_DVBS_100:
Steven Toth363c35f2008-10-11 11:05:50 -03001272 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001273 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001274 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001275 if (fe0->dvb.frontend) {
1276 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1277 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001278 }
Vadim Catana0e0351e2006-01-09 15:25:02 -02001279 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001280 case CX88_BOARD_GENIATECH_DVBS:
Steven Toth363c35f2008-10-11 11:05:50 -03001281 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001282 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001283 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001284 if (fe0->dvb.frontend) {
1285 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1286 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001287 }
1288 break;
Steven Toth60464da2008-01-05 16:53:01 -03001289 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth363c35f2008-10-11 11:05:50 -03001290 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth60464da2008-01-05 16:53:01 -03001291 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001292 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001293 if (fe0->dvb.frontend != NULL) {
1294 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001295 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001296 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001297 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -03001298 }
1299 break;
Steven Toth5c00fac2008-04-22 14:45:14 -03001300 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
Steven Toth363c35f2008-10-11 11:05:50 -03001301 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth5c00fac2008-04-22 14:45:14 -03001302 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001303 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001304 if (fe0->dvb.frontend != NULL) {
Steven Toth5c00fac2008-04-22 14:45:14 -03001305 struct dvb_frontend *fe;
1306 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001307 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -03001308 .i2c_addr = 0x61,
Steven Toth5c00fac2008-04-22 14:45:14 -03001309 };
1310 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001311 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -03001312 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -03001313 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -03001314 };
1315
1316 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001317 fe0->dvb.frontend, &cfg);
Steven Toth5c00fac2008-04-22 14:45:14 -03001318 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1319 fe->ops.tuner_ops.set_config(fe, &ctl);
1320 }
1321 break;
Ricardo Maraschinid49f7a22010-04-06 02:40:43 -03001322 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
Miroslav Sustek3047a172009-05-31 16:47:28 -03001323 case CX88_BOARD_WINFAST_DTV1800H:
Steven Toth363c35f2008-10-11 11:05:50 -03001324 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001325 &cx88_pinnacle_hybrid_pctv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001326 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001327 if (fe0->dvb.frontend) {
1328 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001329 if (attach_xc3028(0x61, dev) < 0)
1330 goto frontend_detach;
1331 }
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001332 break;
istvan_v@mailbox.hu8eb79c02011-06-07 13:16:56 -03001333 case CX88_BOARD_WINFAST_DTV1800H_XC4000:
istvan_v@mailbox.huf271a3a2011-06-07 13:14:53 -03001334 case CX88_BOARD_WINFAST_DTV2000H_PLUS:
1335 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1336 &cx88_pinnacle_hybrid_pctv,
1337 &core->i2c_adap);
1338 if (fe0->dvb.frontend) {
1339 struct xc4000_config cfg = {
1340 .i2c_address = 0x61,
1341 .default_pm = 0,
1342 .dvb_amplitude = 134,
1343 .set_smoothedcvbs = 1,
1344 .if_khz = 4560
1345 };
1346 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1347 if (attach_xc4000(dev, &cfg) < 0)
1348 goto frontend_detach;
1349 }
1350 break;
1351 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001352 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001353
Steven Toth363c35f2008-10-11 11:05:50 -03001354 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001355 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001356 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001357 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001358 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001359 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001360 case CX88_BOARD_KWORLD_ATSC_120:
Steven Toth363c35f2008-10-11 11:05:50 -03001361 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001362 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001363 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001364 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001365 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001366 break;
Steven Tothd893d5d2008-04-25 03:46:43 -03001367 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
Steven Toth363c35f2008-10-11 11:05:50 -03001368 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Steven Tothd893d5d2008-04-25 03:46:43 -03001369 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001370 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001371 if (fe0->dvb.frontend != NULL) {
1372 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001373 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001374 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001375 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -03001376 }
1377 break;
Steven Toth5bd1b662008-09-04 01:17:33 -03001378 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad60a5a922008-11-11 08:48:27 -03001379 /* MFE frontend 1 */
1380 mfe_shared = 1;
1381 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001382 /* DVB-S/S2 Init */
1383 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001384 &hauppauge_hvr4000_config,
1385 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001386 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001387 if (!dvb_attach(isl6421_attach,
1388 fe0->dvb.frontend,
1389 &dev->core->i2c_adap,
1390 0x08, ISL6421_DCL, 0x00))
1391 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001392 }
Darron Broad60a5a922008-11-11 08:48:27 -03001393 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001394 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001395 if (!fe1)
1396 goto frontend_detach;
1397 /* DVB-T Init */
1398 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1399 &hauppauge_hvr_config,
1400 &dev->core->i2c_adap);
1401 if (fe1->dvb.frontend) {
1402 fe1->dvb.frontend->id = 1;
1403 if (!dvb_attach(simple_tuner_attach,
1404 fe1->dvb.frontend,
1405 &dev->core->i2c_adap,
1406 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1407 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001408 }
1409 break;
1410 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1411 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001412 &hauppauge_hvr4000_config,
1413 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001414 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001415 if (!dvb_attach(isl6421_attach,
1416 fe0->dvb.frontend,
1417 &dev->core->i2c_adap,
1418 0x08, ISL6421_DCL, 0x00))
1419 goto frontend_detach;
Steven Toth5bd1b662008-09-04 01:17:33 -03001420 }
1421 break;
Igor M. Liplianincd3cde12008-11-09 15:26:25 -03001422 case CX88_BOARD_PROF_6200:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001423 case CX88_BOARD_TBS_8910:
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001424 case CX88_BOARD_TEVII_S420:
Steven Toth363c35f2008-10-11 11:05:50 -03001425 fe0->dvb.frontend = dvb_attach(stv0299_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001426 &tevii_tuner_sharp_config,
1427 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001428 if (fe0->dvb.frontend != NULL) {
1429 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001430 &core->i2c_adap, DVB_PLL_OPERA1))
1431 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001432 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1433 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001434
1435 } else {
Steven Toth363c35f2008-10-11 11:05:50 -03001436 fe0->dvb.frontend = dvb_attach(stv0288_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001437 &tevii_tuner_earda_config,
1438 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001439 if (fe0->dvb.frontend != NULL) {
1440 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001441 &core->i2c_adap))
1442 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001443 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1444 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001445 }
1446 }
1447 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001448 case CX88_BOARD_TEVII_S460:
Steven Toth363c35f2008-10-11 11:05:50 -03001449 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001450 &tevii_s460_config,
1451 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001452 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001453 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001454 break;
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001455 case CX88_BOARD_TEVII_S464:
1456 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1457 &tevii_ds3000_config,
1458 &core->i2c_adap);
1459 if (fe0->dvb.frontend != NULL)
1460 fe0->dvb.frontend->ops.set_voltage =
1461 tevii_dvbs_set_voltage;
1462 break;
Oleg Roitburd4cd7fb82008-09-17 11:30:21 -03001463 case CX88_BOARD_OMICOM_SS4_PCI:
Oleg Roitburdee730422008-09-17 11:58:33 -03001464 case CX88_BOARD_TBS_8920:
Oleg Roitburd57f51db2008-10-08 06:48:08 -03001465 case CX88_BOARD_PROF_7300:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001466 case CX88_BOARD_SATTRADE_ST4200:
Steven Toth363c35f2008-10-11 11:05:50 -03001467 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Oleg Roitburdee730422008-09-17 11:58:33 -03001468 &hauppauge_hvr4000_config,
1469 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001470 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001471 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Oleg Roitburdee730422008-09-17 11:58:33 -03001472 break;
Stephan Wienczny70101a22009-03-10 19:08:06 -03001473 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
1474 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1475 &cx88_terratec_cinergy_ht_pci_mkii_config,
1476 &core->i2c_adap);
1477 if (fe0->dvb.frontend) {
1478 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1479 if (attach_xc3028(0x61, dev) < 0)
1480 goto frontend_detach;
1481 }
1482 break;
Igor M. Liplianinb699c272009-11-16 22:22:32 -03001483 case CX88_BOARD_PROF_7301:{
1484 struct dvb_tuner_ops *tuner_ops = NULL;
1485
1486 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1487 &prof_7301_stv0900_config,
1488 &core->i2c_adap, 0);
1489 if (fe0->dvb.frontend != NULL) {
1490 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1491 &prof_7301_stb6100_config,
1492 &core->i2c_adap))
1493 goto frontend_detach;
1494
1495 tuner_ops = &fe0->dvb.frontend->ops.tuner_ops;
1496 tuner_ops->set_frequency = stb6100_set_freq;
1497 tuner_ops->get_frequency = stb6100_get_freq;
1498 tuner_ops->set_bandwidth = stb6100_set_bandw;
1499 tuner_ops->get_bandwidth = stb6100_get_bandw;
1500
1501 core->prev_set_voltage =
1502 fe0->dvb.frontend->ops.set_voltage;
1503 fe0->dvb.frontend->ops.set_voltage =
1504 tevii_dvbs_set_voltage;
1505 }
1506 break;
1507 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001508 case CX88_BOARD_SAMSUNG_SMT_7020:
1509 dev->ts_gen_cntrl = 0x08;
1510
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001511 cx_set(MO_GP0_IO, 0x0101);
1512
1513 cx_clear(MO_GP0_IO, 0x01);
1514 mdelay(100);
1515 cx_set(MO_GP0_IO, 0x01);
1516 mdelay(200);
1517
1518 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1519 &samsung_stv0299_config,
1520 &dev->core->i2c_adap);
1521 if (fe0->dvb.frontend) {
1522 fe0->dvb.frontend->ops.tuner_ops.set_params =
1523 samsung_smt_7020_tuner_set_params;
1524 fe0->dvb.frontend->tuner_priv =
1525 &dev->core->i2c_adap;
1526 fe0->dvb.frontend->ops.set_voltage =
1527 samsung_smt_7020_set_voltage;
1528 fe0->dvb.frontend->ops.set_tone =
1529 samsung_smt_7020_set_tone;
1530 }
1531
1532 break;
Sergey Ivanov111ac842010-08-09 10:18:32 -03001533 case CX88_BOARD_TWINHAN_VP1027_DVBS:
1534 dev->ts_gen_cntrl = 0x00;
1535 fe0->dvb.frontend = dvb_attach(mb86a16_attach,
1536 &twinhan_vp1027,
1537 &core->i2c_adap);
1538 if (fe0->dvb.frontend) {
1539 core->prev_set_voltage =
1540 fe0->dvb.frontend->ops.set_voltage;
1541 fe0->dvb.frontend->ops.set_voltage =
1542 vp1027_set_voltage;
1543 }
1544 break;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001545
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546 default:
Trent Piepho5772f812007-08-15 14:41:59 -03001547 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 -03001548 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549 break;
1550 }
Steven Toth363c35f2008-10-11 11:05:50 -03001551
Mauro Carvalho Chehab2c9bcea2008-11-10 23:35:00 -02001552 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001553 printk(KERN_ERR
1554 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001555 core->name);
Darron Broad60a5a922008-11-11 08:48:27 -03001556 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001557 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001558 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001559 fe0->dvb.frontend->callback = cx88_tuner_callback;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001560
Steven Toth6c5be742006-12-02 21:15:51 -02001561 /* Ensure all frontends negotiate bus access */
Steven Toth363c35f2008-10-11 11:05:50 -03001562 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1563 if (fe1)
1564 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001566 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001567 call_all(core, core, s_power, 0);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001568
Linus Torvalds1da177e2005-04-16 15:20:36 -07001569 /* register everything */
David Fries7b0962d2011-12-15 01:59:20 -03001570 res = videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
1571 &dev->pci->dev, adapter_nr, mfe_shared, NULL);
1572 if (res)
1573 goto frontend_detach;
1574 return res;
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001575
1576frontend_detach:
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001577 core->gate_ctrl = NULL;
Darron Broadbecd4302008-10-21 11:47:50 -03001578 videobuf_dvb_dealloc_frontends(&dev->frontends);
David Fries7b0962d2011-12-15 01:59:20 -03001579 return res;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001580}
1581
1582/* ----------------------------------------------------------- */
1583
Steven Toth6c5be742006-12-02 21:15:51 -02001584/* CX8802 MPEG -> mini driver - We have been given the hardware */
1585static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586{
Steven Toth6c5be742006-12-02 21:15:51 -02001587 struct cx88_core *core = drv->core;
1588 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001589 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001590
Trent Piepho6a59d642007-08-15 14:41:57 -03001591 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001592 case CX88_BOARD_HAUPPAUGE_HVR1300:
1593 /* We arrive here with either the cx23416 or the cx22702
1594 * on the bus. Take the bus from the cx23416 and enable the
1595 * cx22702 demod
1596 */
Darron Broad79392732008-12-18 06:28:35 -03001597 /* Toggle reset on cx22702 leaving i2c active */
1598 cx_set(MO_GP0_IO, 0x00000080);
1599 udelay(1000);
1600 cx_clear(MO_GP0_IO, 0x00000080);
1601 udelay(50);
1602 cx_set(MO_GP0_IO, 0x00000080);
1603 udelay(1000);
1604 /* enable the cx22702 pins */
Steven Toth6c5be742006-12-02 21:15:51 -02001605 cx_clear(MO_GP0_IO, 0x00000004);
1606 udelay(1000);
1607 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001608
Darron Broad92abe9e2008-10-11 11:18:53 -03001609 case CX88_BOARD_HAUPPAUGE_HVR3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001610 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad79392732008-12-18 06:28:35 -03001611 /* Toggle reset on cx22702 leaving i2c active */
1612 cx_set(MO_GP0_IO, 0x00000080);
1613 udelay(1000);
1614 cx_clear(MO_GP0_IO, 0x00000080);
1615 udelay(50);
1616 cx_set(MO_GP0_IO, 0x00000080);
1617 udelay(1000);
1618 switch (core->dvbdev->frontends.active_fe_id) {
1619 case 1: /* DVB-S/S2 Enabled */
1620 /* tri-state the cx22702 pins */
1621 cx_set(MO_GP0_IO, 0x00000004);
1622 /* Take the cx24116/cx24123 out of reset */
1623 cx_write(MO_SRST_IO, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001624 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
Darron Broad79392732008-12-18 06:28:35 -03001625 break;
1626 case 2: /* DVB-T Enabled */
Steven Toth363c35f2008-10-11 11:05:50 -03001627 /* Put the cx24116/cx24123 into reset */
1628 cx_write(MO_SRST_IO, 0);
Darron Broad79392732008-12-18 06:28:35 -03001629 /* enable the cx22702 pins */
Steven Toth363c35f2008-10-11 11:05:50 -03001630 cx_clear(MO_GP0_IO, 0x00000004);
1631 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
Darron Broad79392732008-12-18 06:28:35 -03001632 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001633 }
Darron Broad79392732008-12-18 06:28:35 -03001634 udelay(1000);
Steven Toth363c35f2008-10-11 11:05:50 -03001635 break;
1636
istvan_v@mailbox.huf271a3a2011-06-07 13:14:53 -03001637 case CX88_BOARD_WINFAST_DTV2000H_PLUS:
1638 /* set RF input to AIR for DVB-T (GPIO 16) */
1639 cx_write(MO_GP2_IO, 0x0101);
1640 break;
1641
Steven Toth6c5be742006-12-02 21:15:51 -02001642 default:
1643 err = -ENODEV;
1644 }
1645 return err;
1646}
1647
1648/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1649static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1650{
1651 struct cx88_core *core = drv->core;
1652 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001653 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001654
Trent Piepho6a59d642007-08-15 14:41:57 -03001655 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001656 case CX88_BOARD_HAUPPAUGE_HVR1300:
1657 /* Do Nothing, leave the cx22702 on the bus. */
1658 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001659 case CX88_BOARD_HAUPPAUGE_HVR3000:
1660 case CX88_BOARD_HAUPPAUGE_HVR4000:
1661 break;
Steven Toth6c5be742006-12-02 21:15:51 -02001662 default:
1663 err = -ENODEV;
1664 }
1665 return err;
1666}
1667
1668static int cx8802_dvb_probe(struct cx8802_driver *drv)
1669{
1670 struct cx88_core *core = drv->core;
1671 struct cx8802_dev *dev = drv->core->dvbdev;
Darron Broadcbd82442008-10-30 05:07:44 -03001672 int err;
Andy Walls6e0e12f2009-01-11 21:18:04 -03001673 struct videobuf_dvb_frontend *fe;
1674 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001675
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001676 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001677 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001678 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001679 core->name,
1680 core->pci_bus,
1681 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682
1683 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001684 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 goto fail_core;
1686
Trent Piephoecf854d2007-05-05 20:11:32 -03001687 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001688 err = vp3054_i2c_probe(dev);
1689 if (0 != err)
Andy Walls6e0e12f2009-01-11 21:18:04 -03001690 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001691
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001693 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Steven Toth363c35f2008-10-11 11:05:50 -03001694 dev->ts_gen_cntrl = 0x0c;
1695
Andy Walls6e0e12f2009-01-11 21:18:04 -03001696 err = cx8802_alloc_frontends(dev);
1697 if (err)
1698 goto fail_core;
Darron Broadcbd82442008-10-30 05:07:44 -03001699
Andy Walls6e0e12f2009-01-11 21:18:04 -03001700 err = -ENODEV;
1701 for (i = 1; i <= core->board.num_frontends; i++) {
1702 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1703 if (fe == NULL) {
1704 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
Darron Broadcbd82442008-10-30 05:07:44 -03001705 __func__, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001706 goto fail_probe;
1707 }
1708 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
Darron Broadcbd82442008-10-30 05:07:44 -03001709 &dev->pci->dev, &dev->slock,
1710 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1711 V4L2_FIELD_TOP,
1712 sizeof(struct cx88_buffer),
Hans Verkuil08bff032010-09-20 17:39:46 -03001713 dev, NULL);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001714 /* init struct videobuf_dvb */
1715 fe->dvb.name = dev->core->name;
Steven Toth363c35f2008-10-11 11:05:50 -03001716 }
Andy Walls6e0e12f2009-01-11 21:18:04 -03001717
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718 err = dvb_register(dev);
Darron Broadcbd82442008-10-30 05:07:44 -03001719 if (err)
1720 /* frontends/adapter de-allocated in dvb_register */
Trent Piepho5772f812007-08-15 14:41:59 -03001721 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1722 core->name, err);
Darron Broadcbd82442008-10-30 05:07:44 -03001723 return err;
1724fail_probe:
1725 videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
Darron Broad92abe9e2008-10-11 11:18:53 -03001726fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727 return err;
1728}
1729
Steven Toth6c5be742006-12-02 21:15:51 -02001730static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731{
Darron Broad0fcd4882008-10-21 11:18:47 -03001732 struct cx88_core *core = drv->core;
Steven Toth6c5be742006-12-02 21:15:51 -02001733 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001734
Darron Broad0fcd4882008-10-21 11:18:47 -03001735 dprintk( 1, "%s\n", __func__);
1736
Steven Toth363c35f2008-10-11 11:05:50 -03001737 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738
Chris Pascoefc40b262006-01-09 15:25:35 -02001739 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001740
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001741 core->gate_ctrl = NULL;
1742
Steven Toth6c5be742006-12-02 21:15:51 -02001743 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001744}
1745
Steven Toth6c5be742006-12-02 21:15:51 -02001746static struct cx8802_driver cx8802_dvb_driver = {
1747 .type_id = CX88_MPEG_DVB,
1748 .hw_access = CX8802_DRVCTL_SHARED,
1749 .probe = cx8802_dvb_probe,
1750 .remove = cx8802_dvb_remove,
1751 .advise_acquire = cx8802_dvb_advise_acquire,
1752 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753};
1754
Peter Huewe31d0f842009-07-17 01:00:01 +02001755static int __init dvb_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001756{
Mauro Carvalho Chehab1990d502011-06-24 14:45:49 -03001757 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %s loaded\n",
1758 CX88_VERSION);
Steven Toth6c5be742006-12-02 21:15:51 -02001759 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760}
1761
Peter Huewe31d0f842009-07-17 01:00:01 +02001762static void __exit dvb_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001763{
Steven Toth6c5be742006-12-02 21:15:51 -02001764 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765}
1766
1767module_init(dvb_init);
1768module_exit(dvb_fini);