blob: 7b8c9d3b6efcc54a349b7584293b36a77384db56 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * device driver for Conexant 2388x based TV cards
4 * MPEG Transport Stream (DVB) routines
5 *
Chris Pascoefc40b262006-01-09 15:25:35 -02006 * (c) 2004, 2005 Chris Pascoe <c.pascoe@itee.uq.edu.au>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 */
23
24#include <linux/module.h>
25#include <linux/init.h>
26#include <linux/device.h>
27#include <linux/fs.h>
28#include <linux/kthread.h>
29#include <linux/file.h>
30#include <linux/suspend.h>
31
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include "cx88.h"
33#include "dvb-pll.h"
Michael Krufky5e453dc2006-01-09 15:32:31 -020034#include <media/v4l2-common.h>
Mauro Carvalho Chehab41ef7c12005-07-12 13:58:44 -070035
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030036#include "mt352.h"
37#include "mt352_priv.h"
Trent Piephoecf854d2007-05-05 20:11:32 -030038#include "cx88-vp3054-i2c.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030039#include "zl10353.h"
40#include "cx22702.h"
41#include "or51132.h"
42#include "lgdt330x.h"
Steven Toth60464da2008-01-05 16:53:01 -030043#include "s5h1409.h"
44#include "xc5000.h"
Andrew de Quincey1f10c7a2006-08-08 09:10:09 -030045#include "nxt200x.h"
46#include "cx24123.h"
Andrew de Quinceycd20ca92006-05-12 20:31:51 -030047#include "isl6421.h"
Michael Krufky0df31f82008-04-22 14:46:13 -030048#include "tuner-simple.h"
Michael Krufky827855d2008-04-22 14:46:16 -030049#include "tda9887.h"
Steven Tothd893d5d2008-04-25 03:46:43 -030050#include "s5h1411.h"
Igor M. Liplianine4aab642008-09-23 15:43:57 -030051#include "stv0299.h"
52#include "z0194a.h"
53#include "stv0288.h"
54#include "stb6000.h"
Steven Toth5bd1b662008-09-04 01:17:33 -030055#include "cx24116.h"
Igor M. Liplianinb699c272009-11-16 22:22:32 -030056#include "stv0900.h"
57#include "stb6100.h"
58#include "stb6100_proc.h"
Sergey Ivanov111ac842010-08-09 10:18:32 -030059#include "mb86a16.h"
Igor M. Liplianin0cb73632011-02-25 18:41:24 -030060#include "ds3000.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070061
62MODULE_DESCRIPTION("driver for cx2388x based DVB cards");
63MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
64MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
65MODULE_LICENSE("GPL");
66
Douglas Schilling Landgrafff699e62008-04-22 14:41:48 -030067static unsigned int debug;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068module_param(debug, int, 0644);
69MODULE_PARM_DESC(debug,"enable debug messages [dvb]");
70
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030071static unsigned int dvb_buf_tscnt = 32;
72module_param(dvb_buf_tscnt, int, 0644);
73MODULE_PARM_DESC(dvb_buf_tscnt, "DVB Buffer TS count [dvb]");
74
Janne Grunau78e92002008-04-09 19:13:13 -030075DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
76
Linus Torvalds1da177e2005-04-16 15:20:36 -070077#define dprintk(level,fmt, arg...) if (debug >= level) \
Steven Toth6c5be742006-12-02 21:15:51 -020078 printk(KERN_DEBUG "%s/2-dvb: " fmt, core->name, ## arg)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80/* ------------------------------------------------------------------ */
81
82static int dvb_buf_setup(struct videobuf_queue *q,
83 unsigned int *count, unsigned int *size)
84{
85 struct cx8802_dev *dev = q->priv_data;
86
87 dev->ts_packet_size = 188 * 4;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030088 dev->ts_packet_count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070089
90 *size = dev->ts_packet_size * dev->ts_packet_count;
Ang Way Chuang44c6e2a72010-12-24 02:40:46 -030091 *count = dvb_buf_tscnt;
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 return 0;
93}
94
Michael Krufky4a390552006-12-05 02:00:53 -030095static int dvb_buf_prepare(struct videobuf_queue *q,
96 struct videobuf_buffer *vb, enum v4l2_field field)
Linus Torvalds1da177e2005-04-16 15:20:36 -070097{
98 struct cx8802_dev *dev = q->priv_data;
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -030099 return cx8802_buf_prepare(q, dev, (struct cx88_buffer*)vb,field);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100}
101
102static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
103{
104 struct cx8802_dev *dev = q->priv_data;
105 cx8802_buf_queue(dev, (struct cx88_buffer*)vb);
106}
107
Michael Krufky4a390552006-12-05 02:00:53 -0300108static void dvb_buf_release(struct videobuf_queue *q,
109 struct videobuf_buffer *vb)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110{
Mauro Carvalho Chehabc7b0ac02006-03-10 12:29:15 -0300111 cx88_free_buffer(q, (struct cx88_buffer*)vb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112}
113
lawrence rust2e4e98e2010-08-25 09:50:20 -0300114static const struct videobuf_queue_ops dvb_qops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 .buf_setup = dvb_buf_setup,
116 .buf_prepare = dvb_buf_prepare,
117 .buf_queue = dvb_buf_queue,
118 .buf_release = dvb_buf_release,
119};
120
121/* ------------------------------------------------------------------ */
Michael Krufky22f3f172006-12-05 01:38:58 -0300122
123static int cx88_dvb_bus_ctrl(struct dvb_frontend* fe, int acquire)
124{
125 struct cx8802_dev *dev= fe->dvb->priv;
126 struct cx8802_driver *drv = NULL;
127 int ret = 0;
Steven Toth363c35f2008-10-11 11:05:50 -0300128 int fe_id;
129
130 fe_id = videobuf_dvb_find_frontend(&dev->frontends, fe);
131 if (!fe_id) {
Steven Toth2af03ee2008-10-16 20:17:31 -0300132 printk(KERN_ERR "%s() No frontend found\n", __func__);
Steven Toth363c35f2008-10-11 11:05:50 -0300133 return -EINVAL;
134 }
135
Michael Krufky22f3f172006-12-05 01:38:58 -0300136 drv = cx8802_get_driver(dev, CX88_MPEG_DVB);
137 if (drv) {
Steven Toth363c35f2008-10-11 11:05:50 -0300138 if (acquire){
139 dev->frontends.active_fe_id = fe_id;
Michael Krufky22f3f172006-12-05 01:38:58 -0300140 ret = drv->request_acquire(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300141 } else {
Michael Krufky22f3f172006-12-05 01:38:58 -0300142 ret = drv->request_release(drv);
Steven Toth363c35f2008-10-11 11:05:50 -0300143 dev->frontends.active_fe_id = 0;
144 }
Michael Krufky22f3f172006-12-05 01:38:58 -0300145 }
146
147 return ret;
148}
149
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300150static void cx88_dvb_gate_ctrl(struct cx88_core *core, int open)
151{
152 struct videobuf_dvb_frontends *f;
153 struct videobuf_dvb_frontend *fe;
154
155 if (!core->dvbdev)
156 return;
157
158 f = &core->dvbdev->frontends;
159
160 if (!f)
161 return;
162
163 if (f->gate <= 1) /* undefined or fe0 */
164 fe = videobuf_dvb_get_frontend(f, 1);
165 else
166 fe = videobuf_dvb_get_frontend(f, f->gate);
167
168 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
169 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
170}
171
Michael Krufky22f3f172006-12-05 01:38:58 -0300172/* ------------------------------------------------------------------ */
173
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200174static int dvico_fusionhdtv_demod_init(struct dvb_frontend* fe)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300176 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x39 };
177 static const u8 reset [] = { RESET, 0x80 };
178 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
179 static const u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
180 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
181 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
183 mt352_write(fe, clock_config, sizeof(clock_config));
184 udelay(200);
185 mt352_write(fe, reset, sizeof(reset));
186 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
187
188 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
189 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
190 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
191 return 0;
192}
193
Chris Pascoe43eabb42006-01-09 18:21:28 -0200194static int dvico_dual_demod_init(struct dvb_frontend *fe)
195{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300196 static const u8 clock_config [] = { CLOCK_CTL, 0x38, 0x38 };
197 static const u8 reset [] = { RESET, 0x80 };
198 static const u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
199 static const u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
200 static const u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
201 static const u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
Chris Pascoe43eabb42006-01-09 18:21:28 -0200202
203 mt352_write(fe, clock_config, sizeof(clock_config));
204 udelay(200);
205 mt352_write(fe, reset, sizeof(reset));
206 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
207
208 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
209 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
210 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
211
212 return 0;
213}
214
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215static int dntv_live_dvbt_demod_init(struct dvb_frontend* fe)
216{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300217 static const u8 clock_config [] = { 0x89, 0x38, 0x39 };
218 static const u8 reset [] = { 0x50, 0x80 };
219 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
220 static const u8 agc_cfg [] = { 0x67, 0x10, 0x23, 0x00, 0xFF, 0xFF,
Mauro Carvalho Chehabf2421ca2005-11-08 21:37:45 -0800221 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300222 static const u8 dntv_extra[] = { 0xB5, 0x7A };
223 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
225 mt352_write(fe, clock_config, sizeof(clock_config));
226 udelay(2000);
227 mt352_write(fe, reset, sizeof(reset));
228 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
229
230 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
231 udelay(2000);
232 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
233 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
234
235 return 0;
236}
237
lawrence rust2e4e98e2010-08-25 09:50:20 -0300238static const struct mt352_config dvico_fusionhdtv = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300239 .demod_address = 0x0f,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200240 .demod_init = dvico_fusionhdtv_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241};
242
lawrence rust2e4e98e2010-08-25 09:50:20 -0300243static const struct mt352_config dntv_live_dvbt_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 .demod_address = 0x0f,
245 .demod_init = dntv_live_dvbt_demod_init,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246};
Chris Pascoefc40b262006-01-09 15:25:35 -0200247
lawrence rust2e4e98e2010-08-25 09:50:20 -0300248static const struct mt352_config dvico_fusionhdtv_dual = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300249 .demod_address = 0x0f,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200250 .demod_init = dvico_dual_demod_init,
Chris Pascoe43eabb42006-01-09 18:21:28 -0200251};
252
lawrence rust2e4e98e2010-08-25 09:50:20 -0300253static const struct zl10353_config cx88_terratec_cinergy_ht_pci_mkii_config = {
Stephan Wienczny70101a22009-03-10 19:08:06 -0300254 .demod_address = (0x1e >> 1),
255 .no_tuner = 1,
256 .if2 = 45600,
257};
258
Sergey Ivanov111ac842010-08-09 10:18:32 -0300259static struct mb86a16_config twinhan_vp1027 = {
260 .demod_address = 0x08,
261};
262
Trent Piephoecf854d2007-05-05 20:11:32 -0300263#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200264static int dntv_live_dvbt_pro_demod_init(struct dvb_frontend* fe)
265{
lawrence rust2e4e98e2010-08-25 09:50:20 -0300266 static const u8 clock_config [] = { 0x89, 0x38, 0x38 };
267 static const u8 reset [] = { 0x50, 0x80 };
268 static const u8 adc_ctl_1_cfg [] = { 0x8E, 0x40 };
269 static const u8 agc_cfg [] = { 0x67, 0x10, 0x20, 0x00, 0xFF, 0xFF,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200270 0x00, 0xFF, 0x00, 0x40, 0x40 };
lawrence rust2e4e98e2010-08-25 09:50:20 -0300271 static const u8 dntv_extra[] = { 0xB5, 0x7A };
272 static const u8 capt_range_cfg[] = { 0x75, 0x32 };
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200273
274 mt352_write(fe, clock_config, sizeof(clock_config));
275 udelay(2000);
276 mt352_write(fe, reset, sizeof(reset));
277 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
278
279 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
280 udelay(2000);
281 mt352_write(fe, dntv_extra, sizeof(dntv_extra));
282 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
283
284 return 0;
285}
286
lawrence rust2e4e98e2010-08-25 09:50:20 -0300287static const struct mt352_config dntv_live_dvbt_pro_config = {
Chris Pascoefc40b262006-01-09 15:25:35 -0200288 .demod_address = 0x0f,
289 .no_tuner = 1,
Chris Pascoe3d7d0272006-01-09 18:21:31 -0200290 .demod_init = dntv_live_dvbt_pro_demod_init,
Chris Pascoefc40b262006-01-09 15:25:35 -0200291};
292#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293
lawrence rust2e4e98e2010-08-25 09:50:20 -0300294static const struct zl10353_config dvico_fusionhdtv_hybrid = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300295 .demod_address = 0x0f,
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300296 .no_tuner = 1,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300297};
298
lawrence rust2e4e98e2010-08-25 09:50:20 -0300299static const struct zl10353_config dvico_fusionhdtv_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300300 .demod_address = 0x0f,
301 .if2 = 45600,
302 .no_tuner = 1,
303};
304
lawrence rust2e4e98e2010-08-25 09:50:20 -0300305static const struct mt352_config dvico_fusionhdtv_mt352_xc3028 = {
Chris Pascoeb3fb91d2008-04-22 14:45:15 -0300306 .demod_address = 0x0f,
307 .if2 = 4560,
308 .no_tuner = 1,
309 .demod_init = dvico_fusionhdtv_demod_init,
310};
311
lawrence rust2e4e98e2010-08-25 09:50:20 -0300312static const struct zl10353_config dvico_fusionhdtv_plus_v1_1 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300313 .demod_address = 0x0f,
Chris Pascoe780dfef2006-02-28 08:34:59 -0300314};
Chris Pascoe780dfef2006-02-28 08:34:59 -0300315
lawrence rust2e4e98e2010-08-25 09:50:20 -0300316static const struct cx22702_config connexant_refboard_config = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 .demod_address = 0x43,
Patrick Boettcher38d84c32005-07-15 12:20:26 -0700318 .output_mode = CX22702_SERIAL_OUTPUT,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319};
320
lawrence rust2e4e98e2010-08-25 09:50:20 -0300321static const struct cx22702_config hauppauge_hvr_config = {
Steven Tothaa481a62006-09-14 15:41:13 -0300322 .demod_address = 0x63,
323 .output_mode = CX22702_SERIAL_OUTPUT,
324};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325
Michael Krufky4a390552006-12-05 02:00:53 -0300326static int or51132_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
328 struct cx8802_dev *dev= fe->dvb->priv;
329 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
330 return 0;
331}
332
lawrence rust2e4e98e2010-08-25 09:50:20 -0300333static const struct or51132_config pchdtv_hd3000 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300334 .demod_address = 0x15,
335 .set_ts_params = or51132_set_ts_param,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337
Michael Krufky6ddcc912005-07-27 11:46:00 -0700338static int lgdt330x_pll_rf_set(struct dvb_frontend* fe, int index)
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700339{
340 struct cx8802_dev *dev= fe->dvb->priv;
341 struct cx88_core *core = dev->core;
342
Harvey Harrison32d83ef2008-04-08 23:20:00 -0300343 dprintk(1, "%s: index = %d\n", __func__, index);
Michael Krufky0ccef6d2005-07-27 11:45:55 -0700344 if (index == 0)
345 cx_clear(MO_GP0_IO, 8);
346 else
347 cx_set(MO_GP0_IO, 8);
348 return 0;
349}
350
Michael Krufky6ddcc912005-07-27 11:46:00 -0700351static int lgdt330x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Michael Krufkyf1798492005-07-07 17:58:39 -0700352{
353 struct cx8802_dev *dev= fe->dvb->priv;
354 if (is_punctured)
355 dev->ts_gen_cntrl |= 0x04;
356 else
357 dev->ts_gen_cntrl &= ~0x04;
358 return 0;
359}
360
Michael Krufky6ddcc912005-07-27 11:46:00 -0700361static struct lgdt330x_config fusionhdtv_3_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300362 .demod_address = 0x0e,
363 .demod_chip = LGDT3302,
364 .serial_mpeg = 0x04, /* TPSERIAL for 3302 in TOP_CONTROL */
365 .set_ts_params = lgdt330x_set_ts_param,
Michael Krufky0d723c02005-07-07 17:58:42 -0700366};
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700367
lawrence rust2e4e98e2010-08-25 09:50:20 -0300368static const struct lgdt330x_config fusionhdtv_5_gold = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300369 .demod_address = 0x0e,
370 .demod_chip = LGDT3303,
371 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
372 .set_ts_params = lgdt330x_set_ts_param,
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -0700373};
Rusty Scottda215d22006-04-07 02:21:31 -0300374
lawrence rust2e4e98e2010-08-25 09:50:20 -0300375static const struct lgdt330x_config pchdtv_hd5500 = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300376 .demod_address = 0x59,
377 .demod_chip = LGDT3303,
378 .serial_mpeg = 0x40, /* TPSERIAL for 3303 in TOP_CONTROL */
379 .set_ts_params = lgdt330x_set_ts_param,
Rusty Scottda215d22006-04-07 02:21:31 -0300380};
Michael Krufkyf1798492005-07-07 17:58:39 -0700381
Michael Krufky4a390552006-12-05 02:00:53 -0300382static int nxt200x_set_ts_param(struct dvb_frontend* fe, int is_punctured)
Kirk Laprayfde6d312005-11-08 21:38:18 -0800383{
384 struct cx8802_dev *dev= fe->dvb->priv;
385 dev->ts_gen_cntrl = is_punctured ? 0x04 : 0x00;
386 return 0;
387}
388
lawrence rust2e4e98e2010-08-25 09:50:20 -0300389static const struct nxt200x_config ati_hdtvwonder = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300390 .demod_address = 0x0a,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300391 .set_ts_params = nxt200x_set_ts_param,
Kirk Laprayfde6d312005-11-08 21:38:18 -0800392};
Kirk Laprayfde6d312005-11-08 21:38:18 -0800393
Steven Toth0fa14aa2006-01-09 15:25:02 -0200394static int cx24123_set_ts_param(struct dvb_frontend* fe,
395 int is_punctured)
396{
397 struct cx8802_dev *dev= fe->dvb->priv;
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300398 dev->ts_gen_cntrl = 0x02;
Steven Toth0fa14aa2006-01-09 15:25:02 -0200399 return 0;
400}
401
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300402static int kworld_dvbs_100_set_voltage(struct dvb_frontend* fe,
403 fe_sec_voltage_t voltage)
Vadim Catana0e0351e2006-01-09 15:25:02 -0200404{
405 struct cx8802_dev *dev= fe->dvb->priv;
406 struct cx88_core *core = dev->core;
407
Michael Krufky4a390552006-12-05 02:00:53 -0300408 if (voltage == SEC_VOLTAGE_OFF)
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300409 cx_write(MO_GP0_IO, 0x000006fb);
Michael Krufky4a390552006-12-05 02:00:53 -0300410 else
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300411 cx_write(MO_GP0_IO, 0x000006f9);
Andrew de Quinceycd20ca92006-05-12 20:31:51 -0300412
413 if (core->prev_set_voltage)
414 return core->prev_set_voltage(fe, voltage);
415 return 0;
Vadim Catana0e0351e2006-01-09 15:25:02 -0200416}
417
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300418static int geniatech_dvbs_set_voltage(struct dvb_frontend *fe,
419 fe_sec_voltage_t voltage)
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300420{
421 struct cx8802_dev *dev= fe->dvb->priv;
422 struct cx88_core *core = dev->core;
423
424 if (voltage == SEC_VOLTAGE_OFF) {
425 dprintk(1,"LNB Voltage OFF\n");
426 cx_write(MO_GP0_IO, 0x0000efff);
427 }
428
429 if (core->prev_set_voltage)
430 return core->prev_set_voltage(fe, voltage);
431 return 0;
432}
433
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300434static int tevii_dvbs_set_voltage(struct dvb_frontend *fe,
435 fe_sec_voltage_t voltage)
436{
437 struct cx8802_dev *dev= fe->dvb->priv;
438 struct cx88_core *core = dev->core;
439
Igor M. Liplianinad5f74c2009-07-29 19:18:28 -0300440 cx_set(MO_GP0_IO, 0x6040);
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300441 switch (voltage) {
Sergey Ivanov111ac842010-08-09 10:18:32 -0300442 case SEC_VOLTAGE_13:
443 cx_clear(MO_GP0_IO, 0x20);
444 break;
445 case SEC_VOLTAGE_18:
446 cx_set(MO_GP0_IO, 0x20);
447 break;
448 case SEC_VOLTAGE_OFF:
449 cx_clear(MO_GP0_IO, 0x20);
450 break;
451 }
452
453 if (core->prev_set_voltage)
454 return core->prev_set_voltage(fe, voltage);
455 return 0;
456}
457
458static int vp1027_set_voltage(struct dvb_frontend *fe,
459 fe_sec_voltage_t voltage)
460{
461 struct cx8802_dev *dev = fe->dvb->priv;
462 struct cx88_core *core = dev->core;
463
464 switch (voltage) {
465 case SEC_VOLTAGE_13:
466 dprintk(1, "LNB SEC Voltage=13\n");
467 cx_write(MO_GP0_IO, 0x00001220);
468 break;
469 case SEC_VOLTAGE_18:
470 dprintk(1, "LNB SEC Voltage=18\n");
471 cx_write(MO_GP0_IO, 0x00001222);
472 break;
473 case SEC_VOLTAGE_OFF:
474 dprintk(1, "LNB Voltage OFF\n");
475 cx_write(MO_GP0_IO, 0x00001230);
476 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300477 }
478
479 if (core->prev_set_voltage)
480 return core->prev_set_voltage(fe, voltage);
481 return 0;
482}
483
lawrence rust2e4e98e2010-08-25 09:50:20 -0300484static const struct cx24123_config geniatech_dvbs_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300485 .demod_address = 0x55,
486 .set_ts_params = cx24123_set_ts_param,
Saqeb Akhterc02a34f2006-06-29 20:29:33 -0300487};
488
lawrence rust2e4e98e2010-08-25 09:50:20 -0300489static const struct cx24123_config hauppauge_novas_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300490 .demod_address = 0x55,
491 .set_ts_params = cx24123_set_ts_param,
Vadim Catana0e0351e2006-01-09 15:25:02 -0200492};
493
lawrence rust2e4e98e2010-08-25 09:50:20 -0300494static const struct cx24123_config kworld_dvbs_100_config = {
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300495 .demod_address = 0x15,
496 .set_ts_params = cx24123_set_ts_param,
Yeasah Pellef768562006-09-26 12:30:14 -0300497 .lnb_polarity = 1,
Steven Toth0fa14aa2006-01-09 15:25:02 -0200498};
Steven Toth0fa14aa2006-01-09 15:25:02 -0200499
lawrence rust2e4e98e2010-08-25 09:50:20 -0300500static const struct s5h1409_config pinnacle_pctv_hd_800i_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300501 .demod_address = 0x32 >> 1,
502 .output_mode = S5H1409_PARALLEL_OUTPUT,
503 .gpio = S5H1409_GPIO_ON,
504 .qam_if = 44000,
505 .inversion = S5H1409_INVERSION_OFF,
506 .status_mode = S5H1409_DEMODLOCKING,
Steven Toth49170192008-01-15 21:57:14 -0300507 .mpeg_timing = S5H1409_MPEGTIMING_NONCONTINOUS_NONINVERTING_CLOCK,
Steven Toth60464da2008-01-05 16:53:01 -0300508};
509
lawrence rust2e4e98e2010-08-25 09:50:20 -0300510static const struct s5h1409_config dvico_hdtv5_pci_nano_config = {
Steven Toth5c00fac2008-04-22 14:45:14 -0300511 .demod_address = 0x32 >> 1,
512 .output_mode = S5H1409_SERIAL_OUTPUT,
513 .gpio = S5H1409_GPIO_OFF,
514 .inversion = S5H1409_INVERSION_OFF,
515 .status_mode = S5H1409_DEMODLOCKING,
516 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
517};
518
lawrence rust2e4e98e2010-08-25 09:50:20 -0300519static const struct s5h1409_config kworld_atsc_120_config = {
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300520 .demod_address = 0x32 >> 1,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300521 .output_mode = S5H1409_SERIAL_OUTPUT,
522 .gpio = S5H1409_GPIO_OFF,
523 .inversion = S5H1409_INVERSION_OFF,
524 .status_mode = S5H1409_DEMODLOCKING,
525 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
526};
527
lawrence rust2e4e98e2010-08-25 09:50:20 -0300528static const struct xc5000_config pinnacle_pctv_hd_800i_tuner_config = {
Steven Toth60464da2008-01-05 16:53:01 -0300529 .i2c_address = 0x64,
530 .if_khz = 5380,
Steven Toth60464da2008-01-05 16:53:01 -0300531};
532
lawrence rust2e4e98e2010-08-25 09:50:20 -0300533static const struct zl10353_config cx88_pinnacle_hybrid_pctv = {
Stéphane Voltz3f6014f2008-09-05 14:33:54 -0300534 .demod_address = (0x1e >> 1),
535 .no_tuner = 1,
536 .if2 = 45600,
537};
538
lawrence rust2e4e98e2010-08-25 09:50:20 -0300539static const struct zl10353_config cx88_geniatech_x8000_mt = {
Mauro Carvalho Chehab57069342009-08-20 10:14:45 -0300540 .demod_address = (0x1e >> 1),
541 .no_tuner = 1,
542 .disable_i2c_gate_ctrl = 1,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300543};
544
lawrence rust2e4e98e2010-08-25 09:50:20 -0300545static const struct s5h1411_config dvico_fusionhdtv7_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300546 .output_mode = S5H1411_SERIAL_OUTPUT,
547 .gpio = S5H1411_GPIO_ON,
548 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
549 .qam_if = S5H1411_IF_44000,
550 .vsb_if = S5H1411_IF_44000,
551 .inversion = S5H1411_INVERSION_OFF,
552 .status_mode = S5H1411_DEMODLOCKING
553};
554
lawrence rust2e4e98e2010-08-25 09:50:20 -0300555static const struct xc5000_config dvico_fusionhdtv7_tuner_config = {
Steven Tothd893d5d2008-04-25 03:46:43 -0300556 .i2c_address = 0xc2 >> 1,
557 .if_khz = 5380,
Steven Tothd893d5d2008-04-25 03:46:43 -0300558};
559
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300560static int attach_xc3028(u8 addr, struct cx8802_dev *dev)
561{
562 struct dvb_frontend *fe;
Steven Toth363c35f2008-10-11 11:05:50 -0300563 struct videobuf_dvb_frontend *fe0 = NULL;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300564 struct xc2028_ctrl ctl;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300565 struct xc2028_config cfg = {
566 .i2c_adap = &dev->core->i2c_adap,
567 .i2c_addr = addr,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300568 .ctrl = &ctl,
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300569 };
570
Darron Broad92abe9e2008-10-11 11:18:53 -0300571 /* Get the first frontend */
Steven Toth363c35f2008-10-11 11:05:50 -0300572 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
573 if (!fe0)
574 return -EINVAL;
575
576 if (!fe0->dvb.frontend) {
Mauro Carvalho Chehabddd54412008-04-22 14:45:46 -0300577 printk(KERN_ERR "%s/2: dvb frontend not attached. "
578 "Can't attach xc3028\n",
579 dev->core->name);
580 return -EINVAL;
581 }
582
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -0300583 /*
584 * Some xc3028 devices may be hidden by an I2C gate. This is known
585 * to happen with some s5h1409-based devices.
586 * Now that I2C gate is open, sets up xc3028 configuration
587 */
588 cx88_setup_xc3028(dev->core, &ctl);
589
Steven Toth363c35f2008-10-11 11:05:50 -0300590 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend, &cfg);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300591 if (!fe) {
592 printk(KERN_ERR "%s/2: xc3028 attach failed\n",
593 dev->core->name);
Steven Toth363c35f2008-10-11 11:05:50 -0300594 dvb_frontend_detach(fe0->dvb.frontend);
595 dvb_unregister_frontend(fe0->dvb.frontend);
596 fe0->dvb.frontend = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -0300597 return -EINVAL;
598 }
599
600 printk(KERN_INFO "%s/2: xc3028 attached\n",
601 dev->core->name);
602
603 return 0;
604}
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -0300605
Steven Toth5bd1b662008-09-04 01:17:33 -0300606static int cx24116_set_ts_param(struct dvb_frontend *fe,
607 int is_punctured)
608{
609 struct cx8802_dev *dev = fe->dvb->priv;
610 dev->ts_gen_cntrl = 0x2;
611
612 return 0;
613}
614
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300615static int stv0900_set_ts_param(struct dvb_frontend *fe,
616 int is_punctured)
617{
618 struct cx8802_dev *dev = fe->dvb->priv;
619 dev->ts_gen_cntrl = 0;
620
621 return 0;
622}
623
Steven Toth5bd1b662008-09-04 01:17:33 -0300624static int cx24116_reset_device(struct dvb_frontend *fe)
625{
626 struct cx8802_dev *dev = fe->dvb->priv;
627 struct cx88_core *core = dev->core;
628
629 /* Reset the part */
Steven Toth363c35f2008-10-11 11:05:50 -0300630 /* Put the cx24116 into reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300631 cx_write(MO_SRST_IO, 0);
632 msleep(10);
Steven Toth363c35f2008-10-11 11:05:50 -0300633 /* Take the cx24116 out of reset */
Steven Toth5bd1b662008-09-04 01:17:33 -0300634 cx_write(MO_SRST_IO, 1);
635 msleep(10);
636
637 return 0;
638}
639
lawrence rust2e4e98e2010-08-25 09:50:20 -0300640static const struct cx24116_config hauppauge_hvr4000_config = {
Steven Toth5bd1b662008-09-04 01:17:33 -0300641 .demod_address = 0x05,
642 .set_ts_params = cx24116_set_ts_param,
643 .reset_device = cx24116_reset_device,
644};
645
lawrence rust2e4e98e2010-08-25 09:50:20 -0300646static const struct cx24116_config tevii_s460_config = {
Igor M. Liplianinaf832622008-09-04 17:24:14 -0300647 .demod_address = 0x55,
648 .set_ts_params = cx24116_set_ts_param,
649 .reset_device = cx24116_reset_device,
650};
651
Igor M. Liplianin0cb73632011-02-25 18:41:24 -0300652static int ds3000_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 = 4;
657
658 return 0;
659}
660
661static struct ds3000_config tevii_ds3000_config = {
662 .demod_address = 0x68,
663 .set_ts_params = ds3000_set_ts_param,
664};
665
lawrence rust2e4e98e2010-08-25 09:50:20 -0300666static const struct stv0900_config prof_7301_stv0900_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300667 .demod_address = 0x6a,
668/* demod_mode = 0,*/
669 .xtal = 27000000,
670 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
671 .diseqc_mode = 2,/* 2/3 PWM */
672 .tun1_maddress = 0,/* 0x60 */
673 .tun1_adc = 0,/* 2 Vpp */
674 .path1_mode = 3,
675 .set_ts_params = stv0900_set_ts_param,
676};
677
lawrence rust2e4e98e2010-08-25 09:50:20 -0300678static const struct stb6100_config prof_7301_stb6100_config = {
Igor M. Liplianinb699c272009-11-16 22:22:32 -0300679 .tuner_address = 0x60,
680 .refclock = 27000000,
681};
682
lawrence rust2e4e98e2010-08-25 09:50:20 -0300683static const struct stv0299_config tevii_tuner_sharp_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300684 .demod_address = 0x68,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300685 .inittab = sharp_z0194a_inittab,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300686 .mclk = 88000000UL,
687 .invert = 1,
688 .skip_reinit = 0,
689 .lock_output = 1,
690 .volt13_op0_op1 = STV0299_VOLT13_OP1,
691 .min_delay_ms = 100,
Igor M. Liplianind4305c62008-10-17 13:45:55 -0300692 .set_symbol_rate = sharp_z0194a_set_symbol_rate,
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300693 .set_ts_params = cx24116_set_ts_param,
694};
695
lawrence rust2e4e98e2010-08-25 09:50:20 -0300696static const struct stv0288_config tevii_tuner_earda_config = {
Igor M. Liplianine4aab642008-09-23 15:43:57 -0300697 .demod_address = 0x68,
698 .min_delay_ms = 100,
699 .set_ts_params = cx24116_set_ts_param,
700};
701
Andy Walls6e0e12f2009-01-11 21:18:04 -0300702static int cx8802_alloc_frontends(struct cx8802_dev *dev)
703{
704 struct cx88_core *core = dev->core;
705 struct videobuf_dvb_frontend *fe = NULL;
706 int i;
707
708 mutex_init(&dev->frontends.lock);
709 INIT_LIST_HEAD(&dev->frontends.felist);
710
711 if (!core->board.num_frontends)
712 return -ENODEV;
713
714 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
715 core->board.num_frontends);
716 for (i = 1; i <= core->board.num_frontends; i++) {
717 fe = videobuf_dvb_alloc_frontend(&dev->frontends, i);
718 if (!fe) {
719 printk(KERN_ERR "%s() failed to alloc\n", __func__);
720 videobuf_dvb_dealloc_frontends(&dev->frontends);
721 return -ENOMEM;
722 }
723 }
724 return 0;
725}
726
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300727
728
lawrence rust2e4e98e2010-08-25 09:50:20 -0300729static const u8 samsung_smt_7020_inittab[] = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300730 0x01, 0x15,
731 0x02, 0x00,
732 0x03, 0x00,
733 0x04, 0x7D,
734 0x05, 0x0F,
735 0x06, 0x02,
736 0x07, 0x00,
737 0x08, 0x60,
738
739 0x0A, 0xC2,
740 0x0B, 0x00,
741 0x0C, 0x01,
742 0x0D, 0x81,
743 0x0E, 0x44,
744 0x0F, 0x09,
745 0x10, 0x3C,
746 0x11, 0x84,
747 0x12, 0xDA,
748 0x13, 0x99,
749 0x14, 0x8D,
750 0x15, 0xCE,
751 0x16, 0xE8,
752 0x17, 0x43,
753 0x18, 0x1C,
754 0x19, 0x1B,
755 0x1A, 0x1D,
756
757 0x1C, 0x12,
758 0x1D, 0x00,
759 0x1E, 0x00,
760 0x1F, 0x00,
761 0x20, 0x00,
762 0x21, 0x00,
763 0x22, 0x00,
764 0x23, 0x00,
765
766 0x28, 0x02,
767 0x29, 0x28,
768 0x2A, 0x14,
769 0x2B, 0x0F,
770 0x2C, 0x09,
771 0x2D, 0x05,
772
773 0x31, 0x1F,
774 0x32, 0x19,
775 0x33, 0xFC,
776 0x34, 0x13,
777 0xff, 0xff,
778};
779
780
781static int samsung_smt_7020_tuner_set_params(struct dvb_frontend *fe,
782 struct dvb_frontend_parameters *params)
783{
784 struct cx8802_dev *dev = fe->dvb->priv;
785 u8 buf[4];
786 u32 div;
787 struct i2c_msg msg = {
788 .addr = 0x61,
789 .flags = 0,
790 .buf = buf,
791 .len = sizeof(buf) };
792
793 div = params->frequency / 125;
794
795 buf[0] = (div >> 8) & 0x7f;
796 buf[1] = div & 0xff;
797 buf[2] = 0x84; /* 0xC4 */
798 buf[3] = 0x00;
799
800 if (params->frequency < 1500000)
801 buf[3] |= 0x10;
802
803 if (fe->ops.i2c_gate_ctrl)
804 fe->ops.i2c_gate_ctrl(fe, 1);
805
806 if (i2c_transfer(&dev->core->i2c_adap, &msg, 1) != 1)
807 return -EIO;
808
809 return 0;
810}
811
812static int samsung_smt_7020_set_tone(struct dvb_frontend *fe,
813 fe_sec_tone_mode_t tone)
814{
815 struct cx8802_dev *dev = fe->dvb->priv;
816 struct cx88_core *core = dev->core;
817
818 cx_set(MO_GP0_IO, 0x0800);
819
820 switch (tone) {
821 case SEC_TONE_ON:
822 cx_set(MO_GP0_IO, 0x08);
823 break;
824 case SEC_TONE_OFF:
825 cx_clear(MO_GP0_IO, 0x08);
826 break;
827 default:
828 return -EINVAL;
829 }
830
831 return 0;
832}
833
834static int samsung_smt_7020_set_voltage(struct dvb_frontend *fe,
835 fe_sec_voltage_t voltage)
836{
837 struct cx8802_dev *dev = fe->dvb->priv;
838 struct cx88_core *core = dev->core;
839
840 u8 data;
841 struct i2c_msg msg = {
842 .addr = 8,
843 .flags = 0,
844 .buf = &data,
845 .len = sizeof(data) };
846
847 cx_set(MO_GP0_IO, 0x8000);
848
849 switch (voltage) {
850 case SEC_VOLTAGE_OFF:
851 break;
852 case SEC_VOLTAGE_13:
853 data = ISL6421_EN1 | ISL6421_LLC1;
854 cx_clear(MO_GP0_IO, 0x80);
855 break;
856 case SEC_VOLTAGE_18:
857 data = ISL6421_EN1 | ISL6421_LLC1 | ISL6421_VSEL1;
858 cx_clear(MO_GP0_IO, 0x80);
859 break;
860 default:
861 return -EINVAL;
862 };
863
864 return (i2c_transfer(&dev->core->i2c_adap, &msg, 1) == 1) ? 0 : -EIO;
865}
866
867static int samsung_smt_7020_stv0299_set_symbol_rate(struct dvb_frontend *fe,
868 u32 srate, u32 ratio)
869{
870 u8 aclk = 0;
871 u8 bclk = 0;
872
873 if (srate < 1500000) {
874 aclk = 0xb7;
875 bclk = 0x47;
876 } else if (srate < 3000000) {
877 aclk = 0xb7;
878 bclk = 0x4b;
879 } else if (srate < 7000000) {
880 aclk = 0xb7;
881 bclk = 0x4f;
882 } else if (srate < 14000000) {
883 aclk = 0xb7;
884 bclk = 0x53;
885 } else if (srate < 30000000) {
886 aclk = 0xb6;
887 bclk = 0x53;
888 } else if (srate < 45000000) {
889 aclk = 0xb4;
890 bclk = 0x51;
891 }
892
893 stv0299_writereg(fe, 0x13, aclk);
894 stv0299_writereg(fe, 0x14, bclk);
895 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
896 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
897 stv0299_writereg(fe, 0x21, ratio & 0xf0);
898
899 return 0;
900}
901
902
lawrence rust2e4e98e2010-08-25 09:50:20 -0300903static const struct stv0299_config samsung_stv0299_config = {
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -0300904 .demod_address = 0x68,
905 .inittab = samsung_smt_7020_inittab,
906 .mclk = 88000000UL,
907 .invert = 0,
908 .skip_reinit = 0,
909 .lock_output = STV0299_LOCKOUTPUT_LK,
910 .volt13_op0_op1 = STV0299_VOLT13_OP1,
911 .min_delay_ms = 100,
912 .set_symbol_rate = samsung_smt_7020_stv0299_set_symbol_rate,
913};
914
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915static int dvb_register(struct cx8802_dev *dev)
916{
Steven Toth363c35f2008-10-11 11:05:50 -0300917 struct cx88_core *core = dev->core;
918 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
Darron Broad59b18422008-10-11 11:44:05 -0300919 int mfe_shared = 0; /* bus not shared by default */
Steven Toth363c35f2008-10-11 11:05:50 -0300920
Matthias Schwarzott0e8bac92008-10-24 10:47:07 -0300921 if (0 != core->i2c_rc) {
922 printk(KERN_ERR "%s/2: no i2c-bus available, cannot attach dvb drivers\n", core->name);
923 goto frontend_detach;
924 }
925
Steven Toth363c35f2008-10-11 11:05:50 -0300926 /* Get the first frontend */
927 fe0 = videobuf_dvb_get_frontend(&dev->frontends, 1);
928 if (!fe0)
Darron Broad60a5a922008-11-11 08:48:27 -0300929 goto frontend_detach;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930
Darron Broad8e739092008-10-11 11:31:41 -0300931 /* multi-frontend gate control is undefined or defaults to fe0 */
932 dev->frontends.gate = 0;
933
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -0300934 /* Sets the gate control callback to be used by i2c command calls */
935 core->gate_ctrl = cx88_dvb_gate_ctrl;
936
Darron Broad8e739092008-10-11 11:31:41 -0300937 /* init frontend(s) */
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300938 switch (core->boardnr) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939 case CX88_BOARD_HAUPPAUGE_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -0300940 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300941 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300942 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300943 if (fe0->dvb.frontend != NULL) {
944 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300945 0x61, &core->i2c_adap,
946 DVB_PLL_THOMSON_DTT759X))
947 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300948 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 break;
Michael Krufkye057ee12005-07-07 17:58:40 -0700950 case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 case CX88_BOARD_CONEXANT_DVB_T1:
Manenti Marcof39624f2006-01-09 15:32:45 -0200952 case CX88_BOARD_KWORLD_DVB_T_CX22702:
David Shirley2b5200a2005-11-08 21:37:22 -0800953 case CX88_BOARD_WINFAST_DTV1000:
Steven Toth363c35f2008-10-11 11:05:50 -0300954 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -0300955 &connexant_refboard_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300956 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300957 if (fe0->dvb.frontend != NULL) {
958 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300959 0x60, &core->i2c_adap,
960 DVB_PLL_THOMSON_DTT7579))
961 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300962 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963 break;
Malcolm Valentine4bd6e9d2006-05-29 13:51:59 -0300964 case CX88_BOARD_WINFAST_DTV2000H:
Vlastimil Labsky4d14c832009-08-10 22:15:54 -0300965 case CX88_BOARD_WINFAST_DTV2000H_J:
Steven Toth611900c2006-01-09 15:25:12 -0200966 case CX88_BOARD_HAUPPAUGE_HVR1100:
967 case CX88_BOARD_HAUPPAUGE_HVR1100LP:
Trent Piephoa5a2ecf2007-03-09 15:07:07 -0300968 case CX88_BOARD_HAUPPAUGE_HVR1300:
Steven Toth363c35f2008-10-11 11:05:50 -0300969 fe0->dvb.frontend = dvb_attach(cx22702_attach,
Michael Krufkyed355262006-12-05 01:34:56 -0300970 &hauppauge_hvr_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300971 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300972 if (fe0->dvb.frontend != NULL) {
973 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -0300974 &core->i2c_adap, 0x61,
975 TUNER_PHILIPS_FMD1216ME_MK3))
976 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -0300977 }
Steven Toth611900c2006-01-09 15:25:12 -0200978 break;
Steven Toth363c35f2008-10-11 11:05:50 -0300979 case CX88_BOARD_HAUPPAUGE_HVR3000:
Darron Broad60a5a922008-11-11 08:48:27 -0300980 /* MFE frontend 1 */
981 mfe_shared = 1;
982 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -0300983 /* DVB-S init */
984 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Darron Broad60a5a922008-11-11 08:48:27 -0300985 &hauppauge_novas_config,
986 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300987 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -0300988 if (!dvb_attach(isl6421_attach,
989 fe0->dvb.frontend,
990 &dev->core->i2c_adap,
991 0x08, ISL6421_DCL, 0x00))
992 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -0300993 }
Darron Broad60a5a922008-11-11 08:48:27 -0300994 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -0300995 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -0300996 if (!fe1)
997 goto frontend_detach;
998 /* DVB-T init */
999 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1000 &hauppauge_hvr_config,
1001 &dev->core->i2c_adap);
1002 if (fe1->dvb.frontend) {
1003 fe1->dvb.frontend->id = 1;
1004 if (!dvb_attach(simple_tuner_attach,
1005 fe1->dvb.frontend,
1006 &dev->core->i2c_adap,
1007 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1008 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001009 }
1010 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001011 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PLUS:
Steven Toth363c35f2008-10-11 11:05:50 -03001012 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001013 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001014 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001015 if (fe0->dvb.frontend != NULL) {
1016 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001017 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1018 goto frontend_detach;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001019 break;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001020 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001021 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001022 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001023 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001024 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001025 if (fe0->dvb.frontend != NULL) {
1026 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001027 0x60, NULL, DVB_PLL_THOMSON_DTT7579))
1028 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001029 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001030 break;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001031 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL:
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001032 /* The tin box says DEE1601, but it seems to be DTT7579
1033 * compatible, with a slightly different MT352 AGC gain. */
Steven Toth363c35f2008-10-11 11:05:50 -03001034 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001035 &dvico_fusionhdtv_dual,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001036 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001037 if (fe0->dvb.frontend != NULL) {
1038 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001039 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1040 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001041 break;
1042 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001043 /* ZL10353 replaces MT352 on later cards */
Steven Toth363c35f2008-10-11 11:05:50 -03001044 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001045 &dvico_fusionhdtv_plus_v1_1,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001046 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001047 if (fe0->dvb.frontend != NULL) {
1048 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001049 0x61, NULL, DVB_PLL_THOMSON_DTT7579))
1050 goto frontend_detach;
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001051 }
Michael Krufkyc2af3cd2006-06-12 14:06:22 -03001052 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T1:
Steven Toth363c35f2008-10-11 11:05:50 -03001054 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001055 &dvico_fusionhdtv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001056 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001057 if (fe0->dvb.frontend != NULL) {
1058 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001059 0x61, NULL, DVB_PLL_LG_Z201))
1060 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001061 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001062 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 case CX88_BOARD_KWORLD_DVB_T:
1064 case CX88_BOARD_DNTV_LIVE_DVB_T:
Mauro Carvalho Chehaba82decf2005-07-07 17:58:36 -07001065 case CX88_BOARD_ADSTECH_DVB_T_PCI:
Steven Toth363c35f2008-10-11 11:05:50 -03001066 fe0->dvb.frontend = dvb_attach(mt352_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001067 &dntv_live_dvbt_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001068 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001069 if (fe0->dvb.frontend != NULL) {
1070 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001071 0x61, NULL, DVB_PLL_UNKNOWN_1))
1072 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001073 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074 break;
Chris Pascoefc40b262006-01-09 15:25:35 -02001075 case CX88_BOARD_DNTV_LIVE_DVB_T_PRO:
Trent Piephoecf854d2007-05-05 20:11:32 -03001076#if defined(CONFIG_VIDEO_CX88_VP3054) || (defined(CONFIG_VIDEO_CX88_VP3054_MODULE) && defined(MODULE))
Trent Piephof0ad9092007-10-14 02:52:16 -03001077 /* MT352 is on a secondary I2C bus made from some GPIO lines */
Steven Toth363c35f2008-10-11 11:05:50 -03001078 fe0->dvb.frontend = dvb_attach(mt352_attach, &dntv_live_dvbt_pro_config,
Trent Piephof0ad9092007-10-14 02:52:16 -03001079 &dev->vp3054->adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001080 if (fe0->dvb.frontend != NULL) {
1081 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001082 &core->i2c_adap, 0x61,
1083 TUNER_PHILIPS_FMD1216ME_MK3))
1084 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001085 }
Chris Pascoefc40b262006-01-09 15:25:35 -02001086#else
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001087 printk(KERN_ERR "%s/2: built without vp3054 support\n",
1088 core->name);
Chris Pascoefc40b262006-01-09 15:25:35 -02001089#endif
1090 break;
Chris Pascoe780dfef2006-02-28 08:34:59 -03001091 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_HYBRID:
Steven Toth363c35f2008-10-11 11:05:50 -03001092 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001093 &dvico_fusionhdtv_hybrid,
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(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001097 &core->i2c_adap, 0x61,
1098 TUNER_THOMSON_FE6600))
1099 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001100 }
Chris Pascoe780dfef2006-02-28 08:34:59 -03001101 break;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001102 case CX88_BOARD_DVICO_FUSIONHDTV_DVB_T_PRO:
Steven Toth363c35f2008-10-11 11:05:50 -03001103 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001104 &dvico_fusionhdtv_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001105 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001106 if (fe0->dvb.frontend == NULL)
1107 fe0->dvb.frontend = dvb_attach(mt352_attach,
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001108 &dvico_fusionhdtv_mt352_xc3028,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001109 &core->i2c_adap);
Chris Pascoe87655612008-04-22 14:45:15 -03001110 /*
1111 * On this board, the demod provides the I2C bus pullup.
1112 * We must not permit gate_ctrl to be performed, or
1113 * the xc3028 cannot communicate on the bus.
1114 */
Steven Toth363c35f2008-10-11 11:05:50 -03001115 if (fe0->dvb.frontend)
1116 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001117 if (attach_xc3028(0x61, dev) < 0)
Darron Broadbecd4302008-10-21 11:47:50 -03001118 goto frontend_detach;
Chris Pascoeb3fb91d2008-04-22 14:45:15 -03001119 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 case CX88_BOARD_PCHDTV_HD3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001121 fe0->dvb.frontend = dvb_attach(or51132_attach, &pchdtv_hd3000,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001122 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001123 if (fe0->dvb.frontend != NULL) {
1124 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001125 &core->i2c_adap, 0x61,
1126 TUNER_THOMSON_DTT761X))
1127 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001128 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 break;
Michael Krufkyf1798492005-07-07 17:58:39 -07001130 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_Q:
1131 dev->ts_gen_cntrl = 0x08;
Michael Krufkyf1798492005-07-07 17:58:39 -07001132
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001133 /* Do a hardware reset of chip before using it. */
Michael Krufkyf1798492005-07-07 17:58:39 -07001134 cx_clear(MO_GP0_IO, 1);
1135 mdelay(100);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001136 cx_set(MO_GP0_IO, 1);
Michael Krufkyf1798492005-07-07 17:58:39 -07001137 mdelay(200);
Michael Krufky0ccef6d2005-07-27 11:45:55 -07001138
1139 /* Select RF connector callback */
Michael Krufky6ddcc912005-07-27 11:46:00 -07001140 fusionhdtv_3_gold.pll_rf_set = lgdt330x_pll_rf_set;
Steven Toth363c35f2008-10-11 11:05:50 -03001141 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001142 &fusionhdtv_3_gold,
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 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001146 &core->i2c_adap, 0x61,
1147 TUNER_MICROTUNE_4042FI5))
1148 goto frontend_detach;
Michael Krufkyf1798492005-07-07 17:58:39 -07001149 }
1150 break;
Michael Krufky0d723c02005-07-07 17:58:42 -07001151 case CX88_BOARD_DVICO_FUSIONHDTV_3_GOLD_T:
1152 dev->ts_gen_cntrl = 0x08;
Michael Krufky0d723c02005-07-07 17:58:42 -07001153
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001154 /* Do a hardware reset of chip before using it. */
Michael Krufky0d723c02005-07-07 17:58:42 -07001155 cx_clear(MO_GP0_IO, 1);
1156 mdelay(100);
Michael Krufkyd9758722005-07-27 11:45:56 -07001157 cx_set(MO_GP0_IO, 9);
Michael Krufky0d723c02005-07-07 17:58:42 -07001158 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001159 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001160 &fusionhdtv_3_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001161 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001162 if (fe0->dvb.frontend != NULL) {
1163 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001164 &core->i2c_adap, 0x61,
1165 TUNER_THOMSON_DTT761X))
1166 goto frontend_detach;
Michael Krufky0d723c02005-07-07 17:58:42 -07001167 }
1168 break;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001169 case CX88_BOARD_DVICO_FUSIONHDTV_5_GOLD:
1170 dev->ts_gen_cntrl = 0x08;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001171
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001172 /* Do a hardware reset of chip before using it. */
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001173 cx_clear(MO_GP0_IO, 1);
1174 mdelay(100);
1175 cx_set(MO_GP0_IO, 1);
1176 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001177 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001178 &fusionhdtv_5_gold,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001179 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001180 if (fe0->dvb.frontend != NULL) {
1181 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001182 &core->i2c_adap, 0x61,
1183 TUNER_LG_TDVS_H06XF))
1184 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001185 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001186 &core->i2c_adap, 0x43))
1187 goto frontend_detach;
Mauro Carvalho Chehabe52e98a2005-09-09 13:03:41 -07001188 }
1189 break;
Rusty Scottda215d22006-04-07 02:21:31 -03001190 case CX88_BOARD_PCHDTV_HD5500:
1191 dev->ts_gen_cntrl = 0x08;
Rusty Scottda215d22006-04-07 02:21:31 -03001192
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001193 /* Do a hardware reset of chip before using it. */
Rusty Scottda215d22006-04-07 02:21:31 -03001194 cx_clear(MO_GP0_IO, 1);
1195 mdelay(100);
1196 cx_set(MO_GP0_IO, 1);
1197 mdelay(200);
Steven Toth363c35f2008-10-11 11:05:50 -03001198 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001199 &pchdtv_hd5500,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001200 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001201 if (fe0->dvb.frontend != NULL) {
1202 if (!dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001203 &core->i2c_adap, 0x61,
1204 TUNER_LG_TDVS_H06XF))
1205 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001206 if (!dvb_attach(tda9887_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001207 &core->i2c_adap, 0x43))
1208 goto frontend_detach;
Rusty Scottda215d22006-04-07 02:21:31 -03001209 }
1210 break;
Kirk Laprayfde6d312005-11-08 21:38:18 -08001211 case CX88_BOARD_ATI_HDTVWONDER:
Steven Toth363c35f2008-10-11 11:05:50 -03001212 fe0->dvb.frontend = dvb_attach(nxt200x_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001213 &ati_hdtvwonder,
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_PHILIPS_TUV1236D))
1219 goto frontend_detach;
Andrew de Quinceyf54376e2006-04-18 17:56:10 -03001220 }
Kirk Laprayfde6d312005-11-08 21:38:18 -08001221 break;
Steven Toth0fa14aa2006-01-09 15:25:02 -02001222 case CX88_BOARD_HAUPPAUGE_NOVASPLUS_S1:
1223 case CX88_BOARD_HAUPPAUGE_NOVASE2_S1:
Steven Toth363c35f2008-10-11 11:05:50 -03001224 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001225 &hauppauge_novas_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001226 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001227 if (fe0->dvb.frontend) {
1228 if (!dvb_attach(isl6421_attach, fe0->dvb.frontend,
Steven Toth83fe92e2008-09-13 19:22:15 -03001229 &core->i2c_adap, 0x08, ISL6421_DCL, 0x00))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001230 goto frontend_detach;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001231 }
Steven Toth0fa14aa2006-01-09 15:25:02 -02001232 break;
Vadim Catana0e0351e2006-01-09 15:25:02 -02001233 case CX88_BOARD_KWORLD_DVBS_100:
Steven Toth363c35f2008-10-11 11:05:50 -03001234 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001235 &kworld_dvbs_100_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001236 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001237 if (fe0->dvb.frontend) {
1238 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1239 fe0->dvb.frontend->ops.set_voltage = kworld_dvbs_100_set_voltage;
Andrew de Quinceycd20ca92006-05-12 20:31:51 -03001240 }
Vadim Catana0e0351e2006-01-09 15:25:02 -02001241 break;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001242 case CX88_BOARD_GENIATECH_DVBS:
Steven Toth363c35f2008-10-11 11:05:50 -03001243 fe0->dvb.frontend = dvb_attach(cx24123_attach,
Michael Krufkyf7b54b12006-08-08 15:48:08 -03001244 &geniatech_dvbs_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001245 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001246 if (fe0->dvb.frontend) {
1247 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1248 fe0->dvb.frontend->ops.set_voltage = geniatech_dvbs_set_voltage;
Saqeb Akhterc02a34f2006-06-29 20:29:33 -03001249 }
1250 break;
Steven Toth60464da2008-01-05 16:53:01 -03001251 case CX88_BOARD_PINNACLE_PCTV_HD_800i:
Steven Toth363c35f2008-10-11 11:05:50 -03001252 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth60464da2008-01-05 16:53:01 -03001253 &pinnacle_pctv_hd_800i_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001254 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001255 if (fe0->dvb.frontend != NULL) {
1256 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001257 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001258 &pinnacle_pctv_hd_800i_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001259 goto frontend_detach;
Steven Toth60464da2008-01-05 16:53:01 -03001260 }
1261 break;
Steven Toth5c00fac2008-04-22 14:45:14 -03001262 case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO:
Steven Toth363c35f2008-10-11 11:05:50 -03001263 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth5c00fac2008-04-22 14:45:14 -03001264 &dvico_hdtv5_pci_nano_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001265 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001266 if (fe0->dvb.frontend != NULL) {
Steven Toth5c00fac2008-04-22 14:45:14 -03001267 struct dvb_frontend *fe;
1268 struct xc2028_config cfg = {
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001269 .i2c_adap = &core->i2c_adap,
Steven Toth5c00fac2008-04-22 14:45:14 -03001270 .i2c_addr = 0x61,
Steven Toth5c00fac2008-04-22 14:45:14 -03001271 };
1272 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -03001273 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth5c00fac2008-04-22 14:45:14 -03001274 .max_len = 64,
Mauro Carvalho Chehab33e53162008-04-21 06:58:48 -03001275 .scode_table = XC3028_FE_OREN538,
Steven Toth5c00fac2008-04-22 14:45:14 -03001276 };
1277
1278 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -03001279 fe0->dvb.frontend, &cfg);
Steven Toth5c00fac2008-04-22 14:45:14 -03001280 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
1281 fe->ops.tuner_ops.set_config(fe, &ctl);
1282 }
1283 break;
Ricardo Maraschinid49f7a22010-04-06 02:40:43 -03001284 case CX88_BOARD_PINNACLE_HYBRID_PCTV:
Miroslav Sustek3047a172009-05-31 16:47:28 -03001285 case CX88_BOARD_WINFAST_DTV1800H:
Steven Toth363c35f2008-10-11 11:05:50 -03001286 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001287 &cx88_pinnacle_hybrid_pctv,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001288 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001289 if (fe0->dvb.frontend) {
1290 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
Stéphane Voltz3f6014f2008-09-05 14:33:54 -03001291 if (attach_xc3028(0x61, dev) < 0)
1292 goto frontend_detach;
1293 }
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001294 break;
1295 case CX88_BOARD_GENIATECH_X8000_MT:
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001296 dev->ts_gen_cntrl = 0x00;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001297
Steven Toth363c35f2008-10-11 11:05:50 -03001298 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001299 &cx88_geniatech_x8000_mt,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001300 &core->i2c_adap);
Mauro Carvalho Chehab23fb3482008-04-22 14:45:30 -03001301 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001302 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001303 break;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001304 case CX88_BOARD_KWORLD_ATSC_120:
Steven Toth363c35f2008-10-11 11:05:50 -03001305 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001306 &kworld_atsc_120_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001307 &core->i2c_adap);
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001308 if (attach_xc3028(0x61, dev) < 0)
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001309 goto frontend_detach;
Mauro Carvalho Chehab99e09ea2008-03-27 23:18:30 -03001310 break;
Steven Tothd893d5d2008-04-25 03:46:43 -03001311 case CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:
Steven Toth363c35f2008-10-11 11:05:50 -03001312 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Steven Tothd893d5d2008-04-25 03:46:43 -03001313 &dvico_fusionhdtv7_config,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001314 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001315 if (fe0->dvb.frontend != NULL) {
1316 if (!dvb_attach(xc5000_attach, fe0->dvb.frontend,
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001317 &core->i2c_adap,
Michael Krufky30650962008-09-06 14:56:58 -03001318 &dvico_fusionhdtv7_tuner_config))
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001319 goto frontend_detach;
Steven Tothd893d5d2008-04-25 03:46:43 -03001320 }
1321 break;
Steven Toth5bd1b662008-09-04 01:17:33 -03001322 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad60a5a922008-11-11 08:48:27 -03001323 /* MFE frontend 1 */
1324 mfe_shared = 1;
1325 dev->frontends.gate = 2;
Steven Toth363c35f2008-10-11 11:05:50 -03001326 /* DVB-S/S2 Init */
1327 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001328 &hauppauge_hvr4000_config,
1329 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001330 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001331 if (!dvb_attach(isl6421_attach,
1332 fe0->dvb.frontend,
1333 &dev->core->i2c_adap,
1334 0x08, ISL6421_DCL, 0x00))
1335 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001336 }
Darron Broad60a5a922008-11-11 08:48:27 -03001337 /* MFE frontend 2 */
Steven Toth363c35f2008-10-11 11:05:50 -03001338 fe1 = videobuf_dvb_get_frontend(&dev->frontends, 2);
Darron Broad60a5a922008-11-11 08:48:27 -03001339 if (!fe1)
1340 goto frontend_detach;
1341 /* DVB-T Init */
1342 fe1->dvb.frontend = dvb_attach(cx22702_attach,
1343 &hauppauge_hvr_config,
1344 &dev->core->i2c_adap);
1345 if (fe1->dvb.frontend) {
1346 fe1->dvb.frontend->id = 1;
1347 if (!dvb_attach(simple_tuner_attach,
1348 fe1->dvb.frontend,
1349 &dev->core->i2c_adap,
1350 0x61, TUNER_PHILIPS_FMD1216ME_MK3))
1351 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001352 }
1353 break;
1354 case CX88_BOARD_HAUPPAUGE_HVR4000LITE:
1355 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Darron Broad60a5a922008-11-11 08:48:27 -03001356 &hauppauge_hvr4000_config,
1357 &dev->core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001358 if (fe0->dvb.frontend) {
Darron Broad60a5a922008-11-11 08:48:27 -03001359 if (!dvb_attach(isl6421_attach,
1360 fe0->dvb.frontend,
1361 &dev->core->i2c_adap,
1362 0x08, ISL6421_DCL, 0x00))
1363 goto frontend_detach;
Steven Toth5bd1b662008-09-04 01:17:33 -03001364 }
1365 break;
Igor M. Liplianincd3cde12008-11-09 15:26:25 -03001366 case CX88_BOARD_PROF_6200:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001367 case CX88_BOARD_TBS_8910:
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001368 case CX88_BOARD_TEVII_S420:
Steven Toth363c35f2008-10-11 11:05:50 -03001369 fe0->dvb.frontend = dvb_attach(stv0299_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001370 &tevii_tuner_sharp_config,
1371 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001372 if (fe0->dvb.frontend != NULL) {
1373 if (!dvb_attach(dvb_pll_attach, fe0->dvb.frontend, 0x60,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001374 &core->i2c_adap, DVB_PLL_OPERA1))
1375 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001376 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1377 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001378
1379 } else {
Steven Toth363c35f2008-10-11 11:05:50 -03001380 fe0->dvb.frontend = dvb_attach(stv0288_attach,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001381 &tevii_tuner_earda_config,
1382 &core->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -03001383 if (fe0->dvb.frontend != NULL) {
1384 if (!dvb_attach(stb6000_attach, fe0->dvb.frontend, 0x61,
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001385 &core->i2c_adap))
1386 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001387 core->prev_set_voltage = fe0->dvb.frontend->ops.set_voltage;
1388 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianine4aab642008-09-23 15:43:57 -03001389 }
1390 }
1391 break;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001392 case CX88_BOARD_TEVII_S460:
Steven Toth363c35f2008-10-11 11:05:50 -03001393 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001394 &tevii_s460_config,
1395 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001396 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001397 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Igor M. Liplianinaf832622008-09-04 17:24:14 -03001398 break;
Igor M. Liplianin0cb73632011-02-25 18:41:24 -03001399 case CX88_BOARD_TEVII_S464:
1400 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1401 &tevii_ds3000_config,
1402 &core->i2c_adap);
1403 if (fe0->dvb.frontend != NULL)
1404 fe0->dvb.frontend->ops.set_voltage =
1405 tevii_dvbs_set_voltage;
1406 break;
Oleg Roitburd4cd7fb82008-09-17 11:30:21 -03001407 case CX88_BOARD_OMICOM_SS4_PCI:
Oleg Roitburdee730422008-09-17 11:58:33 -03001408 case CX88_BOARD_TBS_8920:
Oleg Roitburd57f51db2008-10-08 06:48:08 -03001409 case CX88_BOARD_PROF_7300:
Igor M. Liplianin4b296312008-11-09 15:25:31 -03001410 case CX88_BOARD_SATTRADE_ST4200:
Steven Toth363c35f2008-10-11 11:05:50 -03001411 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Oleg Roitburdee730422008-09-17 11:58:33 -03001412 &hauppauge_hvr4000_config,
1413 &core->i2c_adap);
Igor M. Liplianin93f26c12008-11-09 14:59:33 -03001414 if (fe0->dvb.frontend != NULL)
Steven Toth363c35f2008-10-11 11:05:50 -03001415 fe0->dvb.frontend->ops.set_voltage = tevii_dvbs_set_voltage;
Oleg Roitburdee730422008-09-17 11:58:33 -03001416 break;
Stephan Wienczny70101a22009-03-10 19:08:06 -03001417 case CX88_BOARD_TERRATEC_CINERGY_HT_PCI_MKII:
1418 fe0->dvb.frontend = dvb_attach(zl10353_attach,
1419 &cx88_terratec_cinergy_ht_pci_mkii_config,
1420 &core->i2c_adap);
1421 if (fe0->dvb.frontend) {
1422 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1423 if (attach_xc3028(0x61, dev) < 0)
1424 goto frontend_detach;
1425 }
1426 break;
Igor M. Liplianinb699c272009-11-16 22:22:32 -03001427 case CX88_BOARD_PROF_7301:{
1428 struct dvb_tuner_ops *tuner_ops = NULL;
1429
1430 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1431 &prof_7301_stv0900_config,
1432 &core->i2c_adap, 0);
1433 if (fe0->dvb.frontend != NULL) {
1434 if (!dvb_attach(stb6100_attach, fe0->dvb.frontend,
1435 &prof_7301_stb6100_config,
1436 &core->i2c_adap))
1437 goto frontend_detach;
1438
1439 tuner_ops = &fe0->dvb.frontend->ops.tuner_ops;
1440 tuner_ops->set_frequency = stb6100_set_freq;
1441 tuner_ops->get_frequency = stb6100_get_freq;
1442 tuner_ops->set_bandwidth = stb6100_set_bandw;
1443 tuner_ops->get_bandwidth = stb6100_get_bandw;
1444
1445 core->prev_set_voltage =
1446 fe0->dvb.frontend->ops.set_voltage;
1447 fe0->dvb.frontend->ops.set_voltage =
1448 tevii_dvbs_set_voltage;
1449 }
1450 break;
1451 }
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001452 case CX88_BOARD_SAMSUNG_SMT_7020:
1453 dev->ts_gen_cntrl = 0x08;
1454
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001455 cx_set(MO_GP0_IO, 0x0101);
1456
1457 cx_clear(MO_GP0_IO, 0x01);
1458 mdelay(100);
1459 cx_set(MO_GP0_IO, 0x01);
1460 mdelay(200);
1461
1462 fe0->dvb.frontend = dvb_attach(stv0299_attach,
1463 &samsung_stv0299_config,
1464 &dev->core->i2c_adap);
1465 if (fe0->dvb.frontend) {
1466 fe0->dvb.frontend->ops.tuner_ops.set_params =
1467 samsung_smt_7020_tuner_set_params;
1468 fe0->dvb.frontend->tuner_priv =
1469 &dev->core->i2c_adap;
1470 fe0->dvb.frontend->ops.set_voltage =
1471 samsung_smt_7020_set_voltage;
1472 fe0->dvb.frontend->ops.set_tone =
1473 samsung_smt_7020_set_tone;
1474 }
1475
1476 break;
Sergey Ivanov111ac842010-08-09 10:18:32 -03001477 case CX88_BOARD_TWINHAN_VP1027_DVBS:
1478 dev->ts_gen_cntrl = 0x00;
1479 fe0->dvb.frontend = dvb_attach(mb86a16_attach,
1480 &twinhan_vp1027,
1481 &core->i2c_adap);
1482 if (fe0->dvb.frontend) {
1483 core->prev_set_voltage =
1484 fe0->dvb.frontend->ops.set_voltage;
1485 fe0->dvb.frontend->ops.set_voltage =
1486 vp1027_set_voltage;
1487 }
1488 break;
Dirk Herrendoerfer4f3ca2f12010-02-11 18:06:34 -03001489
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 default:
Trent Piepho5772f812007-08-15 14:41:59 -03001491 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 -03001492 core->name);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 break;
1494 }
Steven Toth363c35f2008-10-11 11:05:50 -03001495
Mauro Carvalho Chehab2c9bcea2008-11-10 23:35:00 -02001496 if ( (NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend) ) {
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001497 printk(KERN_ERR
1498 "%s/2: frontend initialization failed\n",
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001499 core->name);
Darron Broad60a5a922008-11-11 08:48:27 -03001500 goto frontend_detach;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001501 }
Michael Krufkyd7cba042008-09-12 13:31:45 -03001502 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001503 fe0->dvb.frontend->callback = cx88_tuner_callback;
Mauro Carvalho Chehab95079012008-04-22 14:45:15 -03001504
Steven Toth6c5be742006-12-02 21:15:51 -02001505 /* Ensure all frontends negotiate bus access */
Steven Toth363c35f2008-10-11 11:05:50 -03001506 fe0->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
1507 if (fe1)
1508 fe1->dvb.frontend->ops.ts_bus_ctrl = cx88_dvb_bus_ctrl;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001510 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001511 call_all(core, core, s_power, 0);
Mauro Carvalho Chehab93352f52005-09-13 01:25:42 -07001512
Linus Torvalds1da177e2005-04-16 15:20:36 -07001513 /* register everything */
Steven Toth363c35f2008-10-11 11:05:50 -03001514 return videobuf_dvb_register_bus(&dev->frontends, THIS_MODULE, dev,
Michael Krufky9133aee2009-05-23 18:00:59 -03001515 &dev->pci->dev, adapter_nr, mfe_shared, NULL);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001516
1517frontend_detach:
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001518 core->gate_ctrl = NULL;
Darron Broadbecd4302008-10-21 11:47:50 -03001519 videobuf_dvb_dealloc_frontends(&dev->frontends);
Mauro Carvalho Chehab0590d912008-04-30 18:14:36 -03001520 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001521}
1522
1523/* ----------------------------------------------------------- */
1524
Steven Toth6c5be742006-12-02 21:15:51 -02001525/* CX8802 MPEG -> mini driver - We have been given the hardware */
1526static int cx8802_dvb_advise_acquire(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527{
Steven Toth6c5be742006-12-02 21:15:51 -02001528 struct cx88_core *core = drv->core;
1529 int err = 0;
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001530 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001531
Trent Piepho6a59d642007-08-15 14:41:57 -03001532 switch (core->boardnr) {
Steven Toth6c5be742006-12-02 21:15:51 -02001533 case CX88_BOARD_HAUPPAUGE_HVR1300:
1534 /* We arrive here with either the cx23416 or the cx22702
1535 * on the bus. Take the bus from the cx23416 and enable the
1536 * cx22702 demod
1537 */
Darron Broad79392732008-12-18 06:28:35 -03001538 /* Toggle reset on cx22702 leaving i2c active */
1539 cx_set(MO_GP0_IO, 0x00000080);
1540 udelay(1000);
1541 cx_clear(MO_GP0_IO, 0x00000080);
1542 udelay(50);
1543 cx_set(MO_GP0_IO, 0x00000080);
1544 udelay(1000);
1545 /* enable the cx22702 pins */
Steven Toth6c5be742006-12-02 21:15:51 -02001546 cx_clear(MO_GP0_IO, 0x00000004);
1547 udelay(1000);
1548 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001549
Darron Broad92abe9e2008-10-11 11:18:53 -03001550 case CX88_BOARD_HAUPPAUGE_HVR3000:
Steven Toth363c35f2008-10-11 11:05:50 -03001551 case CX88_BOARD_HAUPPAUGE_HVR4000:
Darron Broad79392732008-12-18 06:28:35 -03001552 /* Toggle reset on cx22702 leaving i2c active */
1553 cx_set(MO_GP0_IO, 0x00000080);
1554 udelay(1000);
1555 cx_clear(MO_GP0_IO, 0x00000080);
1556 udelay(50);
1557 cx_set(MO_GP0_IO, 0x00000080);
1558 udelay(1000);
1559 switch (core->dvbdev->frontends.active_fe_id) {
1560 case 1: /* DVB-S/S2 Enabled */
1561 /* tri-state the cx22702 pins */
1562 cx_set(MO_GP0_IO, 0x00000004);
1563 /* Take the cx24116/cx24123 out of reset */
1564 cx_write(MO_SRST_IO, 1);
Steven Toth363c35f2008-10-11 11:05:50 -03001565 core->dvbdev->ts_gen_cntrl = 0x02; /* Parallel IO */
Darron Broad79392732008-12-18 06:28:35 -03001566 break;
1567 case 2: /* DVB-T Enabled */
Steven Toth363c35f2008-10-11 11:05:50 -03001568 /* Put the cx24116/cx24123 into reset */
1569 cx_write(MO_SRST_IO, 0);
Darron Broad79392732008-12-18 06:28:35 -03001570 /* enable the cx22702 pins */
Steven Toth363c35f2008-10-11 11:05:50 -03001571 cx_clear(MO_GP0_IO, 0x00000004);
1572 core->dvbdev->ts_gen_cntrl = 0x0c; /* Serial IO */
Darron Broad79392732008-12-18 06:28:35 -03001573 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001574 }
Darron Broad79392732008-12-18 06:28:35 -03001575 udelay(1000);
Steven Toth363c35f2008-10-11 11:05:50 -03001576 break;
1577
Steven Toth6c5be742006-12-02 21:15:51 -02001578 default:
1579 err = -ENODEV;
1580 }
1581 return err;
1582}
1583
1584/* CX8802 MPEG -> mini driver - We no longer have the hardware */
1585static int cx8802_dvb_advise_release(struct cx8802_driver *drv)
1586{
1587 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 /* Do Nothing, leave the cx22702 on the bus. */
1594 break;
Steven Toth363c35f2008-10-11 11:05:50 -03001595 case CX88_BOARD_HAUPPAUGE_HVR3000:
1596 case CX88_BOARD_HAUPPAUGE_HVR4000:
1597 break;
Steven Toth6c5be742006-12-02 21:15:51 -02001598 default:
1599 err = -ENODEV;
1600 }
1601 return err;
1602}
1603
1604static int cx8802_dvb_probe(struct cx8802_driver *drv)
1605{
1606 struct cx88_core *core = drv->core;
1607 struct cx8802_dev *dev = drv->core->dvbdev;
Darron Broadcbd82442008-10-30 05:07:44 -03001608 int err;
Andy Walls6e0e12f2009-01-11 21:18:04 -03001609 struct videobuf_dvb_frontend *fe;
1610 int i;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001611
Harvey Harrison32d83ef2008-04-08 23:20:00 -03001612 dprintk( 1, "%s\n", __func__);
Steven Toth6c5be742006-12-02 21:15:51 -02001613 dprintk( 1, " ->being probed by Card=%d Name=%s, PCI %02x:%02x\n",
Trent Piepho6a59d642007-08-15 14:41:57 -03001614 core->boardnr,
Steven Toth6c5be742006-12-02 21:15:51 -02001615 core->name,
1616 core->pci_bus,
1617 core->pci_slot);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001618
1619 err = -ENODEV;
Trent Piepho6a59d642007-08-15 14:41:57 -03001620 if (!(core->board.mpeg & CX88_MPEG_DVB))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001621 goto fail_core;
1622
Trent Piephoecf854d2007-05-05 20:11:32 -03001623 /* If vp3054 isn't enabled, a stub will just return 0 */
Chris Pascoefc40b262006-01-09 15:25:35 -02001624 err = vp3054_i2c_probe(dev);
1625 if (0 != err)
Andy Walls6e0e12f2009-01-11 21:18:04 -03001626 goto fail_core;
Chris Pascoefc40b262006-01-09 15:25:35 -02001627
Linus Torvalds1da177e2005-04-16 15:20:36 -07001628 /* dvb stuff */
Trent Piepho5772f812007-08-15 14:41:59 -03001629 printk(KERN_INFO "%s/2: cx2388x based DVB/ATSC card\n", core->name);
Steven Toth363c35f2008-10-11 11:05:50 -03001630 dev->ts_gen_cntrl = 0x0c;
1631
Andy Walls6e0e12f2009-01-11 21:18:04 -03001632 err = cx8802_alloc_frontends(dev);
1633 if (err)
1634 goto fail_core;
Darron Broadcbd82442008-10-30 05:07:44 -03001635
Andy Walls6e0e12f2009-01-11 21:18:04 -03001636 err = -ENODEV;
1637 for (i = 1; i <= core->board.num_frontends; i++) {
1638 fe = videobuf_dvb_get_frontend(&core->dvbdev->frontends, i);
1639 if (fe == NULL) {
1640 printk(KERN_ERR "%s() failed to get frontend(%d)\n",
Darron Broadcbd82442008-10-30 05:07:44 -03001641 __func__, i);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001642 goto fail_probe;
1643 }
1644 videobuf_queue_sg_init(&fe->dvb.dvbq, &dvb_qops,
Darron Broadcbd82442008-10-30 05:07:44 -03001645 &dev->pci->dev, &dev->slock,
1646 V4L2_BUF_TYPE_VIDEO_CAPTURE,
1647 V4L2_FIELD_TOP,
1648 sizeof(struct cx88_buffer),
Hans Verkuil08bff032010-09-20 17:39:46 -03001649 dev, NULL);
Andy Walls6e0e12f2009-01-11 21:18:04 -03001650 /* init struct videobuf_dvb */
1651 fe->dvb.name = dev->core->name;
Steven Toth363c35f2008-10-11 11:05:50 -03001652 }
Andy Walls6e0e12f2009-01-11 21:18:04 -03001653
Linus Torvalds1da177e2005-04-16 15:20:36 -07001654 err = dvb_register(dev);
Darron Broadcbd82442008-10-30 05:07:44 -03001655 if (err)
1656 /* frontends/adapter de-allocated in dvb_register */
Trent Piepho5772f812007-08-15 14:41:59 -03001657 printk(KERN_ERR "%s/2: dvb_register failed (err = %d)\n",
1658 core->name, err);
Darron Broadcbd82442008-10-30 05:07:44 -03001659 return err;
1660fail_probe:
1661 videobuf_dvb_dealloc_frontends(&core->dvbdev->frontends);
Darron Broad92abe9e2008-10-11 11:18:53 -03001662fail_core:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663 return err;
1664}
1665
Steven Toth6c5be742006-12-02 21:15:51 -02001666static int cx8802_dvb_remove(struct cx8802_driver *drv)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667{
Darron Broad0fcd4882008-10-21 11:18:47 -03001668 struct cx88_core *core = drv->core;
Steven Toth6c5be742006-12-02 21:15:51 -02001669 struct cx8802_dev *dev = drv->core->dvbdev;
Steven Toth611900c2006-01-09 15:25:12 -02001670
Darron Broad0fcd4882008-10-21 11:18:47 -03001671 dprintk( 1, "%s\n", __func__);
1672
Steven Toth363c35f2008-10-11 11:05:50 -03001673 videobuf_dvb_unregister_bus(&dev->frontends);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674
Chris Pascoefc40b262006-01-09 15:25:35 -02001675 vp3054_i2c_remove(dev);
Chris Pascoefc40b262006-01-09 15:25:35 -02001676
Mauro Carvalho Chehabe32fadc2009-01-06 16:06:07 -03001677 core->gate_ctrl = NULL;
1678
Steven Toth6c5be742006-12-02 21:15:51 -02001679 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680}
1681
Steven Toth6c5be742006-12-02 21:15:51 -02001682static struct cx8802_driver cx8802_dvb_driver = {
1683 .type_id = CX88_MPEG_DVB,
1684 .hw_access = CX8802_DRVCTL_SHARED,
1685 .probe = cx8802_dvb_probe,
1686 .remove = cx8802_dvb_remove,
1687 .advise_acquire = cx8802_dvb_advise_acquire,
1688 .advise_release = cx8802_dvb_advise_release,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001689};
1690
Peter Huewe31d0f842009-07-17 01:00:01 +02001691static int __init dvb_init(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692{
Trent Piepho5772f812007-08-15 14:41:59 -03001693 printk(KERN_INFO "cx88/2: cx2388x dvb driver version %d.%d.%d loaded\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001694 (CX88_VERSION_CODE >> 16) & 0xff,
1695 (CX88_VERSION_CODE >> 8) & 0xff,
1696 CX88_VERSION_CODE & 0xff);
1697#ifdef SNAPSHOT
1698 printk(KERN_INFO "cx2388x: snapshot date %04d-%02d-%02d\n",
1699 SNAPSHOT/10000, (SNAPSHOT/100)%100, SNAPSHOT%100);
1700#endif
Steven Toth6c5be742006-12-02 21:15:51 -02001701 return cx8802_register_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702}
1703
Peter Huewe31d0f842009-07-17 01:00:01 +02001704static void __exit dvb_fini(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705{
Steven Toth6c5be742006-12-02 21:15:51 -02001706 cx8802_unregister_driver(&cx8802_dvb_driver);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001707}
1708
1709module_init(dvb_init);
1710module_exit(dvb_fini);
1711
1712/*
1713 * Local variables:
1714 * c-basic-offset: 8
1715 * compile-command: "make DVB=1"
1716 * End:
1717 */