blob: 9c5ed10b2c5eb8e5d1c03897d2bf5813f68a41fa [file] [log] [blame]
Steven Tothd19770e2007-03-11 20:44:05 -03001/*
2 * Driver for the Conexant CX23885 PCIe bridge
3 *
Steven Toth6d897612008-09-03 17:12:12 -03004 * Copyright (c) 2006 Steven Toth <stoth@linuxtv.org>
Steven Tothd19770e2007-03-11 20:44:05 -03005 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22#include <linux/module.h>
23#include <linux/init.h>
24#include <linux/device.h>
25#include <linux/fs.h>
26#include <linux/kthread.h>
27#include <linux/file.h>
28#include <linux/suspend.h>
29
30#include "cx23885.h"
Steven Tothd19770e2007-03-11 20:44:05 -030031#include <media/v4l2-common.h>
32
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030033#include "dvb_ca_en50221.h"
Steven Tothd19770e2007-03-11 20:44:05 -030034#include "s5h1409.h"
Michael Krufky52b50452008-07-09 02:18:49 -030035#include "s5h1411.h"
Steven Tothd19770e2007-03-11 20:44:05 -030036#include "mt2131.h"
Michael Krufky3ba71d22007-12-07 01:40:36 -030037#include "tda8290.h"
Michael Krufky4041f1a2007-12-24 04:52:08 -030038#include "tda18271.h"
Michael Krufky9bc37ca2007-09-08 15:17:13 -030039#include "lgdt330x.h"
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -030040#include "xc4000.h"
Steven Tothd1987d52007-12-18 01:57:06 -030041#include "xc5000.h"
David T. L. Wongea5697f2009-10-26 08:54:04 -030042#include "max2165.h"
Steven Tothb3ea0162008-04-19 01:14:19 -030043#include "tda10048.h"
Michael Krufky07b4a832007-12-18 01:09:11 -030044#include "tuner-xc2028.h"
Michael Krufky827855d2008-04-22 14:46:16 -030045#include "tuner-simple.h"
Steven Toth66762372008-04-22 15:38:26 -030046#include "dib7000p.h"
47#include "dibx000_common.h"
Steven Tothaef2d182008-08-04 21:39:53 -030048#include "zl10353.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030049#include "stv0900.h"
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -030050#include "stv0900_reg.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030051#include "stv6110.h"
52#include "lnbh24.h"
Igor M. Liplianin96318d02009-01-17 12:11:20 -030053#include "cx24116.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030054#include "cimax2.h"
David Wong493b7122009-05-18 05:25:49 -030055#include "lgs8gxx.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030056#include "netup-eeprom.h"
57#include "netup-init.h"
Michael Krufkya5dbf452009-05-03 23:27:02 -030058#include "lgdt3305.h"
David T. L. Wongea5697f2009-10-26 08:54:04 -030059#include "atbm8830.h"
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -030060#include "ts2020.h"
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -030061#include "ds3000.h"
62#include "cx23885-f300.h"
Igor M. Liplianin78db8542011-01-25 17:04:00 -030063#include "altera-ci.h"
64#include "stv0367.h"
Stefan Ringel722c90e2012-01-07 09:20:48 -030065#include "drxk.h"
66#include "mt2063.h"
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -030067#include "stv090x.h"
68#include "stb6100.h"
69#include "stb6100_cfg.h"
Michael Krufky7c62f5a2012-12-15 23:34:09 -030070#include "tda10071.h"
71#include "a8293.h"
Steven Tothd19770e2007-03-11 20:44:05 -030072
Steven Toth4513fc692008-01-12 11:36:36 -030073static unsigned int debug;
Steven Tothd19770e2007-03-11 20:44:05 -030074
Steven Toth4513fc692008-01-12 11:36:36 -030075#define dprintk(level, fmt, arg...)\
76 do { if (debug >= level)\
77 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
78 } while (0)
Steven Tothd19770e2007-03-11 20:44:05 -030079
80/* ------------------------------------------------------------------ */
81
Michael Krufky3ba71d22007-12-07 01:40:36 -030082static unsigned int alt_tuner;
83module_param(alt_tuner, int, 0644);
84MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
85
Janne Grunau78e92002008-04-09 19:13:13 -030086DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
87
Michael Krufky3ba71d22007-12-07 01:40:36 -030088/* ------------------------------------------------------------------ */
89
Steven Tothd19770e2007-03-11 20:44:05 -030090static int dvb_buf_setup(struct videobuf_queue *q,
91 unsigned int *count, unsigned int *size)
92{
93 struct cx23885_tsport *port = q->priv_data;
94
95 port->ts_packet_size = 188 * 4;
96 port->ts_packet_count = 32;
97
98 *size = port->ts_packet_size * port->ts_packet_count;
99 *count = 32;
100 return 0;
101}
102
Michael Krufky44a64812007-03-20 23:00:18 -0300103static int dvb_buf_prepare(struct videobuf_queue *q,
104 struct videobuf_buffer *vb, enum v4l2_field field)
Steven Tothd19770e2007-03-11 20:44:05 -0300105{
106 struct cx23885_tsport *port = q->priv_data;
Steven Toth9c8ced52008-10-16 20:18:44 -0300107 return cx23885_buf_prepare(q, port, (struct cx23885_buffer *)vb, field);
Steven Tothd19770e2007-03-11 20:44:05 -0300108}
109
110static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
111{
112 struct cx23885_tsport *port = q->priv_data;
Steven Toth9c8ced52008-10-16 20:18:44 -0300113 cx23885_buf_queue(port, (struct cx23885_buffer *)vb);
Steven Tothd19770e2007-03-11 20:44:05 -0300114}
115
Michael Krufky44a64812007-03-20 23:00:18 -0300116static void dvb_buf_release(struct videobuf_queue *q,
117 struct videobuf_buffer *vb)
Steven Tothd19770e2007-03-11 20:44:05 -0300118{
Steven Toth9c8ced52008-10-16 20:18:44 -0300119 cx23885_free_buffer(q, (struct cx23885_buffer *)vb);
Steven Tothd19770e2007-03-11 20:44:05 -0300120}
121
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300122static int cx23885_dvb_set_frontend(struct dvb_frontend *fe);
123
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300124static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open)
125{
126 struct videobuf_dvb_frontends *f;
127 struct videobuf_dvb_frontend *fe;
128
129 f = &port->frontends;
130
131 if (f->gate <= 1) /* undefined or fe0 */
132 fe = videobuf_dvb_get_frontend(f, 1);
133 else
134 fe = videobuf_dvb_get_frontend(f, f->gate);
135
136 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
137 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300138
139 /*
140 * FIXME: Improve this path to avoid calling the
141 * cx23885_dvb_set_frontend() every time it passes here.
142 */
143 cx23885_dvb_set_frontend(fe->dvb.frontend);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300144}
145
Steven Tothd19770e2007-03-11 20:44:05 -0300146static struct videobuf_queue_ops dvb_qops = {
147 .buf_setup = dvb_buf_setup,
148 .buf_prepare = dvb_buf_prepare,
149 .buf_queue = dvb_buf_queue,
150 .buf_release = dvb_buf_release,
151};
152
Steven Toth86184e02007-09-04 21:40:47 -0300153static struct s5h1409_config hauppauge_generic_config = {
Steven Tothd19770e2007-03-11 20:44:05 -0300154 .demod_address = 0x32 >> 1,
155 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothfc959be2007-09-08 19:08:17 -0300156 .gpio = S5H1409_GPIO_ON,
Michael Krufky2b032382007-12-13 10:04:10 -0300157 .qam_if = 44000,
Steven Tothfc959be2007-09-08 19:08:17 -0300158 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300159 .status_mode = S5H1409_DEMODLOCKING,
160 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothfc959be2007-09-08 19:08:17 -0300161};
162
Steven Tothb3ea0162008-04-19 01:14:19 -0300163static struct tda10048_config hauppauge_hvr1200_config = {
164 .demod_address = 0x10 >> 1,
165 .output_mode = TDA10048_SERIAL_OUTPUT,
166 .fwbulkwritelen = TDA10048_BULKWRITE_200,
Steven Toth484d9e02009-05-02 11:08:23 -0300167 .inversion = TDA10048_INVERSION_ON,
Steven Toth8816bef2009-05-15 21:04:18 -0300168 .dtv6_if_freq_khz = TDA10048_IF_3300,
169 .dtv7_if_freq_khz = TDA10048_IF_3800,
170 .dtv8_if_freq_khz = TDA10048_IF_4300,
Steven Toth484d9e02009-05-02 11:08:23 -0300171 .clk_freq_khz = TDA10048_CLK_16000,
Steven Tothb3ea0162008-04-19 01:14:19 -0300172};
173
Michael Krufky6b926ec2009-05-12 17:32:17 -0300174static struct tda10048_config hauppauge_hvr1210_config = {
175 .demod_address = 0x10 >> 1,
176 .output_mode = TDA10048_SERIAL_OUTPUT,
177 .fwbulkwritelen = TDA10048_BULKWRITE_200,
178 .inversion = TDA10048_INVERSION_ON,
Michael Krufkyc27586e2009-05-16 11:00:23 -0300179 .dtv6_if_freq_khz = TDA10048_IF_3300,
180 .dtv7_if_freq_khz = TDA10048_IF_3500,
181 .dtv8_if_freq_khz = TDA10048_IF_4000,
Michael Krufky6b926ec2009-05-12 17:32:17 -0300182 .clk_freq_khz = TDA10048_CLK_16000,
183};
184
Michael Krufky3ba71d22007-12-07 01:40:36 -0300185static struct s5h1409_config hauppauge_ezqam_config = {
186 .demod_address = 0x32 >> 1,
187 .output_mode = S5H1409_SERIAL_OUTPUT,
188 .gpio = S5H1409_GPIO_OFF,
189 .qam_if = 4000,
190 .inversion = S5H1409_INVERSION_ON,
Steven Tothdfc1c082008-01-15 21:35:22 -0300191 .status_mode = S5H1409_DEMODLOCKING,
192 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300193};
194
Steven Tothfc959be2007-09-08 19:08:17 -0300195static struct s5h1409_config hauppauge_hvr1800lp_config = {
196 .demod_address = 0x32 >> 1,
197 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothd19770e2007-03-11 20:44:05 -0300198 .gpio = S5H1409_GPIO_OFF,
Michael Krufky2b032382007-12-13 10:04:10 -0300199 .qam_if = 44000,
Steven Tothfe475162007-03-20 15:27:53 -0300200 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300201 .status_mode = S5H1409_DEMODLOCKING,
202 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd19770e2007-03-11 20:44:05 -0300203};
204
Michael Krufky07b4a832007-12-18 01:09:11 -0300205static struct s5h1409_config hauppauge_hvr1500_config = {
206 .demod_address = 0x32 >> 1,
207 .output_mode = S5H1409_SERIAL_OUTPUT,
208 .gpio = S5H1409_GPIO_OFF,
209 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300210 .status_mode = S5H1409_DEMODLOCKING,
211 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky07b4a832007-12-18 01:09:11 -0300212};
213
Steven Toth86184e02007-09-04 21:40:47 -0300214static struct mt2131_config hauppauge_generic_tunerconfig = {
Steven Totha77743b2007-08-22 21:01:20 -0300215 0x61
216};
217
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300218static struct lgdt330x_config fusionhdtv_5_express = {
219 .demod_address = 0x0e,
220 .demod_chip = LGDT3303,
221 .serial_mpeg = 0x40,
222};
223
Steven Tothd1987d52007-12-18 01:57:06 -0300224static struct s5h1409_config hauppauge_hvr1500q_config = {
225 .demod_address = 0x32 >> 1,
226 .output_mode = S5H1409_SERIAL_OUTPUT,
227 .gpio = S5H1409_GPIO_ON,
228 .qam_if = 44000,
229 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300230 .status_mode = S5H1409_DEMODLOCKING,
231 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd1987d52007-12-18 01:57:06 -0300232};
233
Michael Krufky335377b2008-05-07 01:43:10 -0300234static struct s5h1409_config dvico_s5h1409_config = {
235 .demod_address = 0x32 >> 1,
236 .output_mode = S5H1409_SERIAL_OUTPUT,
237 .gpio = S5H1409_GPIO_ON,
238 .qam_if = 44000,
239 .inversion = S5H1409_INVERSION_OFF,
240 .status_mode = S5H1409_DEMODLOCKING,
241 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
242};
243
Michael Krufky52b50452008-07-09 02:18:49 -0300244static struct s5h1411_config dvico_s5h1411_config = {
245 .output_mode = S5H1411_SERIAL_OUTPUT,
246 .gpio = S5H1411_GPIO_ON,
247 .qam_if = S5H1411_IF_44000,
248 .vsb_if = S5H1411_IF_44000,
249 .inversion = S5H1411_INVERSION_OFF,
250 .status_mode = S5H1411_DEMODLOCKING,
251 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
252};
253
Michael Krufky19bc5792009-05-08 16:05:29 -0300254static struct s5h1411_config hcw_s5h1411_config = {
255 .output_mode = S5H1411_SERIAL_OUTPUT,
256 .gpio = S5H1411_GPIO_OFF,
257 .vsb_if = S5H1411_IF_44000,
258 .qam_if = S5H1411_IF_4000,
259 .inversion = S5H1411_INVERSION_ON,
260 .status_mode = S5H1411_DEMODLOCKING,
261 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
262};
263
Steven Tothd1987d52007-12-18 01:57:06 -0300264static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
Steven Tothe12671c2007-12-20 01:14:43 -0300265 .i2c_address = 0x61,
266 .if_khz = 5380,
Steven Tothd1987d52007-12-18 01:57:06 -0300267};
268
Michael Krufky335377b2008-05-07 01:43:10 -0300269static struct xc5000_config dvico_xc5000_tunerconfig = {
270 .i2c_address = 0x64,
271 .if_khz = 5380,
Michael Krufky335377b2008-05-07 01:43:10 -0300272};
273
Michael Krufky4041f1a2007-12-24 04:52:08 -0300274static struct tda829x_config tda829x_no_probe = {
275 .probe_tuner = TDA829X_DONT_PROBE,
276};
277
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300278static struct tda18271_std_map hauppauge_tda18271_std_map = {
Michael Krufkyc0dc0c12008-04-22 14:46:22 -0300279 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
280 .if_lvl = 6, .rfagc_top = 0x37 },
281 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
282 .if_lvl = 6, .rfagc_top = 0x37 },
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300283};
284
Michael Krufkyb34cdc32009-05-21 12:49:28 -0300285static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
286 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
287 .if_lvl = 1, .rfagc_top = 0x37, },
288 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
289 .if_lvl = 1, .rfagc_top = 0x37, },
290 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
291 .if_lvl = 1, .rfagc_top = 0x37, },
292};
293
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300294static struct tda18271_config hauppauge_tda18271_config = {
295 .std_map = &hauppauge_tda18271_std_map,
296 .gate = TDA18271_GATE_ANALOG,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300297 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300298};
299
Steven Tothb3ea0162008-04-19 01:14:19 -0300300static struct tda18271_config hauppauge_hvr1200_tuner_config = {
Michael Krufkyb34cdc32009-05-21 12:49:28 -0300301 .std_map = &hauppauge_hvr1200_tda18271_std_map,
Steven Tothb3ea0162008-04-19 01:14:19 -0300302 .gate = TDA18271_GATE_ANALOG,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300303 .output_opt = TDA18271_OUTPUT_LT_OFF,
Steven Tothb3ea0162008-04-19 01:14:19 -0300304};
305
Michael Krufky6b926ec2009-05-12 17:32:17 -0300306static struct tda18271_config hauppauge_hvr1210_tuner_config = {
307 .gate = TDA18271_GATE_DIGITAL,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300308 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky6b926ec2009-05-12 17:32:17 -0300309};
310
Michael Krufky247bc542009-05-12 18:53:47 -0300311static struct tda18271_std_map hauppauge_hvr127x_std_map = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300312 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
313 .if_lvl = 1, .rfagc_top = 0x58 },
314 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
315 .if_lvl = 1, .rfagc_top = 0x58 },
316};
317
Michael Krufky247bc542009-05-12 18:53:47 -0300318static struct tda18271_config hauppauge_hvr127x_config = {
319 .std_map = &hauppauge_hvr127x_std_map,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300320 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufkya5dbf452009-05-03 23:27:02 -0300321};
322
Michael Krufky247bc542009-05-12 18:53:47 -0300323static struct lgdt3305_config hauppauge_lgdt3305_config = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300324 .i2c_addr = 0x0e,
325 .mpeg_mode = LGDT3305_MPEG_SERIAL,
326 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
327 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
328 .deny_i2c_rptr = 1,
329 .spectral_inversion = 1,
330 .qam_if_khz = 4000,
331 .vsb_if_khz = 3250,
332};
333
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700334static struct dibx000_agc_config xc3028_agc_config = {
Steven Toth66762372008-04-22 15:38:26 -0300335 BAND_VHF | BAND_UHF, /* band_caps */
336
337 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
338 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
339 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
340 * P_agc_nb_est=2, P_agc_write=0
341 */
342 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
343 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
344
345 712, /* inv_gain */
346 21, /* time_stabiliz */
347
348 0, /* alpha_level */
349 118, /* thlock */
350
351 0, /* wbd_inv */
352 2867, /* wbd_ref */
353 0, /* wbd_sel */
354 2, /* wbd_alpha */
355
356 0, /* agc1_max */
357 0, /* agc1_min */
358 39718, /* agc2_max */
359 9930, /* agc2_min */
360 0, /* agc1_pt1 */
361 0, /* agc1_pt2 */
362 0, /* agc1_pt3 */
363 0, /* agc1_slope1 */
364 0, /* agc1_slope2 */
365 0, /* agc2_pt1 */
366 128, /* agc2_pt2 */
367 29, /* agc2_slope1 */
368 29, /* agc2_slope2 */
369
370 17, /* alpha_mant */
371 27, /* alpha_exp */
372 23, /* beta_mant */
373 51, /* beta_exp */
374
375 1, /* perform_agc_softsplit */
376};
377
378/* PLL Configuration for COFDM BW_MHz = 8.000000
379 * With external clock = 30.000000 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700380static struct dibx000_bandwidth_config xc3028_bw_config = {
Steven Toth66762372008-04-22 15:38:26 -0300381 60000, /* internal */
382 30000, /* sampling */
383 1, /* pll_cfg: prediv */
384 8, /* pll_cfg: ratio */
385 3, /* pll_cfg: range */
386 1, /* pll_cfg: reset */
387 0, /* pll_cfg: bypass */
388 0, /* misc: refdiv */
389 0, /* misc: bypclk_div */
390 1, /* misc: IO_CLK_en_core */
391 1, /* misc: ADClkSrc */
392 0, /* misc: modulo */
393 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
394 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
395 20452225, /* timf */
396 30000000 /* xtal_hz */
397};
398
399static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
400 .output_mpeg2_in_188_bytes = 1,
401 .hostbus_diversity = 1,
402 .tuner_is_baseband = 0,
403 .update_lna = NULL,
404
405 .agc_config_count = 1,
406 .agc = &xc3028_agc_config,
407 .bw = &xc3028_bw_config,
408
409 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
410 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
411 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
412
413 .pwm_freq_div = 0,
414 .agc_control = NULL,
415 .spur_protect = 0,
416
417 .output_mode = OUTMODE_MPEG2_SERIAL,
418};
419
Steven Tothaef2d182008-08-04 21:39:53 -0300420static struct zl10353_config dvico_fusionhdtv_xc3028 = {
421 .demod_address = 0x0f,
422 .if2 = 45600,
423 .no_tuner = 1,
Christopher Pascoed4dc6732009-04-27 11:27:04 -0300424 .disable_i2c_gate_ctrl = 1,
Steven Tothaef2d182008-08-04 21:39:53 -0300425};
426
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -0300427static struct stv0900_reg stv0900_ts_regs[] = {
428 { R0900_TSGENERAL, 0x00 },
429 { R0900_P1_TSSPEED, 0x40 },
430 { R0900_P2_TSSPEED, 0x40 },
431 { R0900_P1_TSCFGM, 0xc0 },
432 { R0900_P2_TSCFGM, 0xc0 },
433 { R0900_P1_TSCFGH, 0xe0 },
434 { R0900_P2_TSCFGH, 0xe0 },
435 { R0900_P1_TSCFGL, 0x20 },
436 { R0900_P2_TSCFGL, 0x20 },
437 { 0xffff, 0xff }, /* terminate */
438};
439
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300440static struct stv0900_config netup_stv0900_config = {
441 .demod_address = 0x68,
Igor M. Liplianin29372a82009-10-17 08:58:26 -0300442 .demod_mode = 1, /* dual */
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300443 .xtal = 8000000,
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300444 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
445 .diseqc_mode = 2,/* 2/3 PWM */
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -0300446 .ts_config_regs = stv0900_ts_regs,
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300447 .tun1_maddress = 0,/* 0x60 */
448 .tun2_maddress = 3,/* 0x63 */
449 .tun1_adc = 1,/* 1 Vpp */
450 .tun2_adc = 1,/* 1 Vpp */
451};
452
453static struct stv6110_config netup_stv6110_tunerconfig_a = {
454 .i2c_address = 0x60,
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300455 .mclk = 16000000,
456 .clk_div = 1,
Abylay Ospan873688c2009-10-17 08:23:00 -0300457 .gain = 8, /* +16 dB - maximum gain */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300458};
459
460static struct stv6110_config netup_stv6110_tunerconfig_b = {
461 .i2c_address = 0x63,
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300462 .mclk = 16000000,
463 .clk_div = 1,
Abylay Ospan873688c2009-10-17 08:23:00 -0300464 .gain = 8, /* +16 dB - maximum gain */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300465};
466
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300467static struct cx24116_config tbs_cx24116_config = {
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -0300468 .demod_address = 0x55,
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300469};
470
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -0300471static struct ds3000_config tevii_ds3000_config = {
472 .demod_address = 0x68,
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300473};
474
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300475static struct ts2020_config tevii_ts2020_config = {
476 .tuner_address = 0x60,
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300477 .clk_out_div = 1,
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -0300478};
479
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300480static struct cx24116_config dvbworld_cx24116_config = {
481 .demod_address = 0x05,
482};
483
David Wong493b7122009-05-18 05:25:49 -0300484static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
485 .prod = LGS8GXX_PROD_LGS8GL5,
486 .demod_address = 0x19,
487 .serial_ts = 0,
488 .ts_clk_pol = 1,
489 .ts_clk_gated = 1,
490 .if_clk_freq = 30400, /* 30.4 MHz */
491 .if_freq = 5380, /* 5.38 MHz */
492 .if_neg_center = 1,
493 .ext_adc = 0,
494 .adc_signed = 0,
495 .if_neg_edge = 0,
496};
497
498static struct xc5000_config mygica_x8506_xc5000_config = {
499 .i2c_address = 0x61,
500 .if_khz = 5380,
501};
502
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300503static struct stv090x_config prof_8000_stv090x_config = {
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300504 .device = STV0903,
505 .demod_mode = STV090x_SINGLE,
506 .clk_mode = STV090x_CLK_EXT,
507 .xtal = 27000000,
508 .address = 0x6A,
509 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
510 .repeater_level = STV090x_RPTLEVEL_64,
511 .adc1_range = STV090x_ADC_2Vpp,
512 .diseqc_envelope_mode = false,
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300513
Igor M. Liplianinb858c332012-12-28 19:40:33 -0300514 .tuner_get_frequency = stb6100_get_frequency,
515 .tuner_set_frequency = stb6100_set_frequency,
516 .tuner_set_bandwidth = stb6100_set_bandwidth,
517 .tuner_get_bandwidth = stb6100_get_bandwidth,
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300518};
519
520static struct stb6100_config prof_8000_stb6100_config = {
521 .tuner_address = 0x60,
522 .refclock = 27000000,
523};
524
525static int p8000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
526{
527 struct cx23885_tsport *port = fe->dvb->priv;
528 struct cx23885_dev *dev = port->dev;
529
530 if (voltage == SEC_VOLTAGE_18)
531 cx_write(MC417_RWD, 0x00001e00);
532 else if (voltage == SEC_VOLTAGE_13)
533 cx_write(MC417_RWD, 0x00001a00);
534 else
535 cx_write(MC417_RWD, 0x00001800);
536 return 0;
537}
538
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300539static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300540{
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300541 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300542 struct cx23885_tsport *port = fe->dvb->priv;
543 struct cx23885_dev *dev = port->dev;
544
545 switch (dev->board) {
546 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300547 switch (p->modulation) {
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300548 case VSB_8:
549 cx23885_gpio_clear(dev, GPIO_5);
550 break;
551 case QAM_64:
552 case QAM_256:
553 default:
554 cx23885_gpio_set(dev, GPIO_5);
555 break;
556 }
557 break;
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300558 case CX23885_BOARD_MYGICA_X8506:
559 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
560 /* Select Digital TV */
561 cx23885_gpio_set(dev, GPIO_0);
562 break;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300563 }
Michael Krufky5bdd3962009-05-08 22:39:24 -0300564 return 0;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300565}
566
David Wong2365b2d2009-06-17 01:38:12 -0300567static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
568 .prod = LGS8GXX_PROD_LGS8G75,
569 .demod_address = 0x19,
570 .serial_ts = 0,
571 .ts_clk_pol = 1,
572 .ts_clk_gated = 1,
573 .if_clk_freq = 30400, /* 30.4 MHz */
574 .if_freq = 6500, /* 6.50 MHz */
575 .if_neg_center = 1,
576 .ext_adc = 0,
577 .adc_signed = 1,
578 .adc_vpp = 2, /* 1.6 Vpp */
579 .if_neg_edge = 1,
580};
581
582static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
583 .i2c_address = 0x61,
584 .if_khz = 6500,
585};
586
David T. L. Wongea5697f2009-10-26 08:54:04 -0300587static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
588 .prod = ATBM8830_PROD_8830,
589 .demod_address = 0x44,
590 .serial_ts = 0,
591 .ts_sampling_edge = 1,
592 .ts_clk_gated = 0,
593 .osc_clk_freq = 30400, /* in kHz */
594 .if_freq = 0, /* zero IF */
595 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300596 .agc_min = 0x2E,
597 .agc_max = 0xFF,
598 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300599};
600
601static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
602 .i2c_address = 0x60,
603 .osc_clk = 20
604};
605
606static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
607 .prod = ATBM8830_PROD_8830,
608 .demod_address = 0x44,
609 .serial_ts = 1,
610 .ts_sampling_edge = 1,
611 .ts_clk_gated = 0,
612 .osc_clk_freq = 30400, /* in kHz */
613 .if_freq = 0, /* zero IF */
614 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300615 .agc_min = 0x2E,
616 .agc_max = 0xFF,
617 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300618};
619
620static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
621 .i2c_address = 0x60,
622 .osc_clk = 20
623};
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300624static struct stv0367_config netup_stv0367_config[] = {
625 {
626 .demod_address = 0x1c,
627 .xtal = 27000000,
628 .if_khz = 4500,
629 .if_iq_mode = 0,
630 .ts_mode = 1,
631 .clk_pol = 0,
632 }, {
633 .demod_address = 0x1d,
634 .xtal = 27000000,
635 .if_khz = 4500,
636 .if_iq_mode = 0,
637 .ts_mode = 1,
638 .clk_pol = 0,
639 },
640};
641
642static struct xc5000_config netup_xc5000_config[] = {
643 {
644 .i2c_address = 0x61,
645 .if_khz = 4500,
646 }, {
647 .i2c_address = 0x64,
648 .if_khz = 4500,
649 },
650};
651
Stefan Ringel722c90e2012-01-07 09:20:48 -0300652static struct drxk_config terratec_drxk_config[] = {
653 {
654 .adr = 0x29,
655 .no_i2c_bridge = 1,
656 }, {
657 .adr = 0x2a,
658 .no_i2c_bridge = 1,
659 },
660};
661
662static struct mt2063_config terratec_mt2063_config[] = {
663 {
664 .tuner_address = 0x60,
665 }, {
666 .tuner_address = 0x67,
667 },
668};
669
Michael Krufky7c62f5a2012-12-15 23:34:09 -0300670static const struct tda10071_config hauppauge_tda10071_config = {
Michael Krufky41f55d52012-12-16 19:37:11 -0300671 .demod_i2c_addr = 0x05,
Michael Krufky7c62f5a2012-12-15 23:34:09 -0300672 .tuner_i2c_addr = 0x54,
673 .i2c_wr_max = 64,
674 .ts_mode = TDA10071_TS_SERIAL,
675 .spec_inv = 0,
676 .xtal = 40444000, /* 40.444 MHz */
677 .pll_multiplier = 20,
678};
679
680static const struct a8293_config hauppauge_a8293_config = {
681 .i2c_addr = 0x0b,
682};
683
Mauro Carvalho Chehabada73ee2012-10-27 11:29:23 -0300684static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300685{
686 struct cx23885_dev *dev = (struct cx23885_dev *)device;
687 unsigned long timeout = jiffies + msecs_to_jiffies(1);
Abylay Ospand1644602011-01-02 09:10:00 -0300688 uint32_t mem = 0;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300689
Abylay Ospand1644602011-01-02 09:10:00 -0300690 mem = cx_read(MC417_RWD);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300691 if (read)
692 cx_set(MC417_OEN, ALT_DATA);
693 else {
694 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300695 mem &= ~ALT_DATA;
696 mem |= (data & ALT_DATA);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300697 }
698
699 if (flag)
Abylay Ospand1644602011-01-02 09:10:00 -0300700 mem |= ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300701 else
Abylay Ospand1644602011-01-02 09:10:00 -0300702 mem &= ~ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300703
Abylay Ospand1644602011-01-02 09:10:00 -0300704 mem &= ~ALT_CS;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300705 if (read)
Abylay Ospand1644602011-01-02 09:10:00 -0300706 mem = (mem & ~ALT_RD) | ALT_WR;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300707 else
Abylay Ospand1644602011-01-02 09:10:00 -0300708 mem = (mem & ~ALT_WR) | ALT_RD;
709
710 cx_write(MC417_RWD, mem); /* start RW cycle */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300711
712 for (;;) {
713 mem = cx_read(MC417_RWD);
714 if ((mem & ALT_RDY) == 0)
715 break;
716 if (time_after(jiffies, timeout))
717 break;
718 udelay(1);
719 }
720
721 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
722 if (read)
723 return mem & ALT_DATA;
724
725 return 0;
726};
David T. L. Wongea5697f2009-10-26 08:54:04 -0300727
Steven Tothd19770e2007-03-11 20:44:05 -0300728static int dvb_register(struct cx23885_tsport *port)
729{
730 struct cx23885_dev *dev = port->dev;
David Wong493b7122009-05-18 05:25:49 -0300731 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300732 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
733 int mfe_shared = 0; /* bus not shared by default */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300734 int ret;
Steven Toth363c35f2008-10-11 11:05:50 -0300735
Darron Broadf972e0b2008-10-11 11:24:30 -0300736 /* Get the first frontend */
Darron Broad92abe9e2008-10-11 11:18:53 -0300737 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300738 if (!fe0)
739 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -0300740
741 /* init struct videobuf_dvb */
Steven Toth363c35f2008-10-11 11:05:50 -0300742 fe0->dvb.name = dev->name;
Steven Tothd19770e2007-03-11 20:44:05 -0300743
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300744 /* multi-frontend gate control is undefined or defaults to fe0 */
745 port->frontends.gate = 0;
746
747 /* Sets the gate control callback to be used by i2c command calls */
748 port->gate_ctrl = cx23885_dvb_gate_ctrl;
749
Steven Tothd19770e2007-03-11 20:44:05 -0300750 /* init frontend */
751 switch (dev->board) {
Steven Totha77743b2007-08-22 21:01:20 -0300752 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300753 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300754 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth86184e02007-09-04 21:40:47 -0300755 &hauppauge_generic_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300756 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300757 if (fe0->dvb.frontend != NULL) {
758 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300759 &i2c_bus->i2c_adap,
Steven Toth86184e02007-09-04 21:40:47 -0300760 &hauppauge_generic_tunerconfig, 0);
Steven Tothd19770e2007-03-11 20:44:05 -0300761 }
762 break;
Michael Krufkya5dbf452009-05-03 23:27:02 -0300763 case CX23885_BOARD_HAUPPAUGE_HVR1270:
Michael Krufkyd099bec2009-05-08 22:39:24 -0300764 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Michael Krufkya5dbf452009-05-03 23:27:02 -0300765 i2c_bus = &dev->i2c_bus[0];
766 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
Michael Krufky247bc542009-05-12 18:53:47 -0300767 &hauppauge_lgdt3305_config,
Michael Krufkya5dbf452009-05-03 23:27:02 -0300768 &i2c_bus->i2c_adap);
769 if (fe0->dvb.frontend != NULL) {
770 dvb_attach(tda18271_attach, fe0->dvb.frontend,
771 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufky247bc542009-05-12 18:53:47 -0300772 &hauppauge_hvr127x_config);
Michael Krufkya5dbf452009-05-03 23:27:02 -0300773 }
774 break;
Michael Krufky19bc5792009-05-08 16:05:29 -0300775 case CX23885_BOARD_HAUPPAUGE_HVR1255:
Devin Heitmueller0ac60ac2012-07-01 16:15:14 -0300776 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
Michael Krufky19bc5792009-05-08 16:05:29 -0300777 i2c_bus = &dev->i2c_bus[0];
778 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
779 &hcw_s5h1411_config,
780 &i2c_bus->i2c_adap);
781 if (fe0->dvb.frontend != NULL) {
782 dvb_attach(tda18271_attach, fe0->dvb.frontend,
783 0x60, &dev->i2c_bus[1].i2c_adap,
784 &hauppauge_tda18271_config);
785 }
Devin Heitmueller0ac60ac2012-07-01 16:15:14 -0300786
787 tda18271_attach(&dev->ts1.analog_fe,
788 0x60, &dev->i2c_bus[1].i2c_adap,
789 &hauppauge_tda18271_config);
790
Michael Krufky19bc5792009-05-08 16:05:29 -0300791 break;
Michael Krufky3ba71d22007-12-07 01:40:36 -0300792 case CX23885_BOARD_HAUPPAUGE_HVR1800:
793 i2c_bus = &dev->i2c_bus[0];
Darron Broad92abe9e2008-10-11 11:18:53 -0300794 switch (alt_tuner) {
Michael Krufky3ba71d22007-12-07 01:40:36 -0300795 case 1:
Steven Toth363c35f2008-10-11 11:05:50 -0300796 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300797 dvb_attach(s5h1409_attach,
798 &hauppauge_ezqam_config,
799 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300800 if (fe0->dvb.frontend != NULL) {
801 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300802 &dev->i2c_bus[1].i2c_adap, 0x42,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300803 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300804 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300805 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300806 &hauppauge_tda18271_config);
Michael Krufky3ba71d22007-12-07 01:40:36 -0300807 }
808 break;
809 case 0:
810 default:
Steven Toth363c35f2008-10-11 11:05:50 -0300811 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300812 dvb_attach(s5h1409_attach,
813 &hauppauge_generic_config,
814 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300815 if (fe0->dvb.frontend != NULL)
816 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300817 &i2c_bus->i2c_adap,
818 &hauppauge_generic_tunerconfig, 0);
819 break;
820 }
821 break;
Steven Tothfc959be2007-09-08 19:08:17 -0300822 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300823 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300824 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothfc959be2007-09-08 19:08:17 -0300825 &hauppauge_hvr1800lp_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300826 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300827 if (fe0->dvb.frontend != NULL) {
828 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300829 &i2c_bus->i2c_adap,
Steven Tothfc959be2007-09-08 19:08:17 -0300830 &hauppauge_generic_tunerconfig, 0);
831 }
832 break;
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300833 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300834 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300835 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300836 &fusionhdtv_5_express,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300837 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300838 if (fe0->dvb.frontend != NULL) {
839 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky827855d2008-04-22 14:46:16 -0300840 &i2c_bus->i2c_adap, 0x61,
841 TUNER_LG_TDVS_H06XF);
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300842 }
843 break;
Steven Tothd1987d52007-12-18 01:57:06 -0300844 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
845 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300846 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothd1987d52007-12-18 01:57:06 -0300847 &hauppauge_hvr1500q_config,
848 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300849 if (fe0->dvb.frontend != NULL)
850 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300851 &i2c_bus->i2c_adap,
852 &hauppauge_hvr1500q_tunerconfig);
Steven Tothd1987d52007-12-18 01:57:06 -0300853 break;
Michael Krufky07b4a832007-12-18 01:09:11 -0300854 case CX23885_BOARD_HAUPPAUGE_HVR1500:
855 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300856 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky07b4a832007-12-18 01:09:11 -0300857 &hauppauge_hvr1500_config,
858 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300859 if (fe0->dvb.frontend != NULL) {
Michael Krufky07b4a832007-12-18 01:09:11 -0300860 struct dvb_frontend *fe;
861 struct xc2028_config cfg = {
862 .i2c_adap = &i2c_bus->i2c_adap,
863 .i2c_addr = 0x61,
Michael Krufky07b4a832007-12-18 01:09:11 -0300864 };
865 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300866 .fname = XC2028_DEFAULT_FIRMWARE,
Michael Krufky07b4a832007-12-18 01:09:11 -0300867 .max_len = 64,
Steven Toth52c3d292009-04-20 22:42:00 -0300868 .demod = XC3028_FE_OREN538,
Michael Krufky07b4a832007-12-18 01:09:11 -0300869 };
870
871 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300872 fe0->dvb.frontend, &cfg);
Michael Krufky07b4a832007-12-18 01:09:11 -0300873 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
874 fe->ops.tuner_ops.set_config(fe, &ctl);
875 }
876 break;
Steven Tothb3ea0162008-04-19 01:14:19 -0300877 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Totha780a312008-04-19 01:25:52 -0300878 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Tothb3ea0162008-04-19 01:14:19 -0300879 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300880 fe0->dvb.frontend = dvb_attach(tda10048_attach,
Steven Tothb3ea0162008-04-19 01:14:19 -0300881 &hauppauge_hvr1200_config,
882 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300883 if (fe0->dvb.frontend != NULL) {
884 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300885 &dev->i2c_bus[1].i2c_adap, 0x42,
886 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300887 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300888 0x60, &dev->i2c_bus[1].i2c_adap,
889 &hauppauge_hvr1200_tuner_config);
890 }
891 break;
Michael Krufky6b926ec2009-05-12 17:32:17 -0300892 case CX23885_BOARD_HAUPPAUGE_HVR1210:
893 i2c_bus = &dev->i2c_bus[0];
894 fe0->dvb.frontend = dvb_attach(tda10048_attach,
895 &hauppauge_hvr1210_config,
896 &i2c_bus->i2c_adap);
897 if (fe0->dvb.frontend != NULL) {
898 dvb_attach(tda18271_attach, fe0->dvb.frontend,
899 0x60, &dev->i2c_bus[1].i2c_adap,
900 &hauppauge_hvr1210_tuner_config);
901 }
902 break;
Steven Toth66762372008-04-22 15:38:26 -0300903 case CX23885_BOARD_HAUPPAUGE_HVR1400:
904 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300905 fe0->dvb.frontend = dvb_attach(dib7000p_attach,
Steven Toth66762372008-04-22 15:38:26 -0300906 &i2c_bus->i2c_adap,
907 0x12, &hauppauge_hvr1400_dib7000_config);
Steven Toth363c35f2008-10-11 11:05:50 -0300908 if (fe0->dvb.frontend != NULL) {
Steven Toth66762372008-04-22 15:38:26 -0300909 struct dvb_frontend *fe;
910 struct xc2028_config cfg = {
911 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
912 .i2c_addr = 0x64,
Steven Toth66762372008-04-22 15:38:26 -0300913 };
914 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300915 .fname = XC3028L_DEFAULT_FIRMWARE,
Steven Toth66762372008-04-22 15:38:26 -0300916 .max_len = 64,
Mauro Carvalho Chehab9bed77e2011-07-28 16:38:54 -0300917 .demod = XC3028_FE_DIBCOM52,
Steven Toth9c8ced52008-10-16 20:18:44 -0300918 /* This is true for all demods with
919 v36 firmware? */
Mauro Carvalho Chehab0975fc62008-09-28 02:24:44 -0300920 .type = XC2028_D2633,
Steven Toth66762372008-04-22 15:38:26 -0300921 };
922
923 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300924 fe0->dvb.frontend, &cfg);
Steven Toth66762372008-04-22 15:38:26 -0300925 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
926 fe->ops.tuner_ops.set_config(fe, &ctl);
927 }
928 break;
Michael Krufky335377b2008-05-07 01:43:10 -0300929 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
930 i2c_bus = &dev->i2c_bus[port->nr - 1];
931
Steven Toth363c35f2008-10-11 11:05:50 -0300932 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky335377b2008-05-07 01:43:10 -0300933 &dvico_s5h1409_config,
934 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300935 if (fe0->dvb.frontend == NULL)
936 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Michael Krufky52b50452008-07-09 02:18:49 -0300937 &dvico_s5h1411_config,
938 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300939 if (fe0->dvb.frontend != NULL)
940 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300941 &i2c_bus->i2c_adap,
942 &dvico_xc5000_tunerconfig);
Michael Krufky335377b2008-05-07 01:43:10 -0300943 break;
Steven Tothaef2d182008-08-04 21:39:53 -0300944 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
945 i2c_bus = &dev->i2c_bus[port->nr - 1];
946
Steven Toth363c35f2008-10-11 11:05:50 -0300947 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Tothaef2d182008-08-04 21:39:53 -0300948 &dvico_fusionhdtv_xc3028,
949 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300950 if (fe0->dvb.frontend != NULL) {
Steven Tothaef2d182008-08-04 21:39:53 -0300951 struct dvb_frontend *fe;
952 struct xc2028_config cfg = {
953 .i2c_adap = &i2c_bus->i2c_adap,
954 .i2c_addr = 0x61,
Steven Tothaef2d182008-08-04 21:39:53 -0300955 };
956 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300957 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Tothaef2d182008-08-04 21:39:53 -0300958 .max_len = 64,
959 .demod = XC3028_FE_ZARLINK456,
960 };
961
Steven Toth363c35f2008-10-11 11:05:50 -0300962 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Tothaef2d182008-08-04 21:39:53 -0300963 &cfg);
964 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
965 fe->ops.tuner_ops.set_config(fe, &ctl);
966 }
967 break;
968 }
Steven Toth4c56b042008-08-12 13:30:03 -0300969 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -0300970 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Vladimir Geroy34e383d2009-09-18 18:55:47 -0300971 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
Steven Toth4c56b042008-08-12 13:30:03 -0300972 i2c_bus = &dev->i2c_bus[0];
973
Steven Toth363c35f2008-10-11 11:05:50 -0300974 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Toth4c56b042008-08-12 13:30:03 -0300975 &dvico_fusionhdtv_xc3028,
976 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300977 if (fe0->dvb.frontend != NULL) {
Steven Toth4c56b042008-08-12 13:30:03 -0300978 struct dvb_frontend *fe;
979 struct xc2028_config cfg = {
980 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
981 .i2c_addr = 0x61,
Steven Toth4c56b042008-08-12 13:30:03 -0300982 };
983 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300984 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth4c56b042008-08-12 13:30:03 -0300985 .max_len = 64,
986 .demod = XC3028_FE_ZARLINK456,
987 };
988
Steven Toth363c35f2008-10-11 11:05:50 -0300989 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Toth4c56b042008-08-12 13:30:03 -0300990 &cfg);
991 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
992 fe->ops.tuner_ops.set_config(fe, &ctl);
993 }
994 break;
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -0300995 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
996 i2c_bus = &dev->i2c_bus[0];
997
998 fe0->dvb.frontend = dvb_attach(zl10353_attach,
999 &dvico_fusionhdtv_xc3028,
1000 &i2c_bus->i2c_adap);
1001 if (fe0->dvb.frontend != NULL) {
1002 struct dvb_frontend *fe;
1003 struct xc4000_config cfg = {
1004 .i2c_address = 0x61,
1005 .default_pm = 0,
1006 .dvb_amplitude = 134,
1007 .set_smoothedcvbs = 1,
1008 .if_khz = 4560
1009 };
1010
1011 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1012 &dev->i2c_bus[1].i2c_adap, &cfg);
Miroslav Slugena7c8aad2011-12-11 18:57:58 -03001013 if (!fe) {
1014 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
1015 dev->name);
1016 goto frontend_detach;
1017 }
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -03001018 }
1019 break;
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001020 case CX23885_BOARD_TBS_6920:
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001021 i2c_bus = &dev->i2c_bus[1];
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001022
1023 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001024 &tbs_cx24116_config,
1025 &i2c_bus->i2c_adap);
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001026 if (fe0->dvb.frontend != NULL)
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001027 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001028
1029 break;
Igor M. Liplianin579943f2009-01-17 12:18:26 -03001030 case CX23885_BOARD_TEVII_S470:
1031 i2c_bus = &dev->i2c_bus[1];
1032
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001033 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1034 &tevii_ds3000_config,
1035 &i2c_bus->i2c_adap);
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001036 if (fe0->dvb.frontend != NULL) {
1037 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1038 &tevii_ts2020_config, &i2c_bus->i2c_adap);
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001039 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001040 }
Igor M. Liplianin579943f2009-01-17 12:18:26 -03001041
1042 break;
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -03001043 case CX23885_BOARD_DVBWORLD_2005:
1044 i2c_bus = &dev->i2c_bus[1];
1045
1046 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1047 &dvbworld_cx24116_config,
1048 &i2c_bus->i2c_adap);
1049 break;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001050 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1051 i2c_bus = &dev->i2c_bus[0];
1052 switch (port->nr) {
1053 /* port B */
1054 case 1:
1055 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1056 &netup_stv0900_config,
1057 &i2c_bus->i2c_adap, 0);
1058 if (fe0->dvb.frontend != NULL) {
1059 if (dvb_attach(stv6110_attach,
1060 fe0->dvb.frontend,
1061 &netup_stv6110_tunerconfig_a,
1062 &i2c_bus->i2c_adap)) {
1063 if (!dvb_attach(lnbh24_attach,
1064 fe0->dvb.frontend,
1065 &i2c_bus->i2c_adap,
Abylay Ospan9329fb52009-10-17 08:38:45 -03001066 LNBH24_PCL | LNBH24_TTX,
1067 LNBH24_TEN, 0x09))
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001068 printk(KERN_ERR
1069 "No LNBH24 found!\n");
1070
1071 }
1072 }
1073 break;
1074 /* port C */
1075 case 2:
1076 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1077 &netup_stv0900_config,
1078 &i2c_bus->i2c_adap, 1);
1079 if (fe0->dvb.frontend != NULL) {
1080 if (dvb_attach(stv6110_attach,
1081 fe0->dvb.frontend,
1082 &netup_stv6110_tunerconfig_b,
1083 &i2c_bus->i2c_adap)) {
1084 if (!dvb_attach(lnbh24_attach,
1085 fe0->dvb.frontend,
1086 &i2c_bus->i2c_adap,
Abylay Ospan9329fb52009-10-17 08:38:45 -03001087 LNBH24_PCL | LNBH24_TTX,
1088 LNBH24_TEN, 0x0a))
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001089 printk(KERN_ERR
1090 "No LNBH24 found!\n");
1091
1092 }
1093 }
1094 break;
1095 }
1096 break;
David Wong493b7122009-05-18 05:25:49 -03001097 case CX23885_BOARD_MYGICA_X8506:
1098 i2c_bus = &dev->i2c_bus[0];
1099 i2c_bus2 = &dev->i2c_bus[1];
1100 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1101 &mygica_x8506_lgs8gl5_config,
1102 &i2c_bus->i2c_adap);
1103 if (fe0->dvb.frontend != NULL) {
1104 dvb_attach(xc5000_attach,
1105 fe0->dvb.frontend,
1106 &i2c_bus2->i2c_adap,
1107 &mygica_x8506_xc5000_config);
1108 }
1109 break;
David Wong2365b2d2009-06-17 01:38:12 -03001110 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1111 i2c_bus = &dev->i2c_bus[0];
1112 i2c_bus2 = &dev->i2c_bus[1];
1113 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1114 &magicpro_prohdtve2_lgs8g75_config,
1115 &i2c_bus->i2c_adap);
1116 if (fe0->dvb.frontend != NULL) {
1117 dvb_attach(xc5000_attach,
1118 fe0->dvb.frontend,
1119 &i2c_bus2->i2c_adap,
1120 &magicpro_prohdtve2_xc5000_config);
1121 }
1122 break;
Steven Toth136973802009-07-20 15:37:25 -03001123 case CX23885_BOARD_HAUPPAUGE_HVR1850:
Steven Toth35045132012-01-04 21:08:35 -03001124 i2c_bus = &dev->i2c_bus[0];
1125 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1126 &hcw_s5h1411_config,
1127 &i2c_bus->i2c_adap);
1128 if (fe0->dvb.frontend != NULL)
1129 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1130 0x60, &dev->i2c_bus[0].i2c_adap,
1131 &hauppauge_tda18271_config);
1132
1133 tda18271_attach(&dev->ts1.analog_fe,
1134 0x60, &dev->i2c_bus[1].i2c_adap,
1135 &hauppauge_tda18271_config);
1136
1137 break;
Michael Krufkyaee0b242009-11-11 01:52:45 -03001138 case CX23885_BOARD_HAUPPAUGE_HVR1290:
Steven Toth136973802009-07-20 15:37:25 -03001139 i2c_bus = &dev->i2c_bus[0];
1140 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1141 &hcw_s5h1411_config,
1142 &i2c_bus->i2c_adap);
1143 if (fe0->dvb.frontend != NULL)
1144 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1145 0x60, &dev->i2c_bus[0].i2c_adap,
1146 &hauppauge_tda18271_config);
1147 break;
David T. L. Wongea5697f2009-10-26 08:54:04 -03001148 case CX23885_BOARD_MYGICA_X8558PRO:
1149 switch (port->nr) {
1150 /* port B */
1151 case 1:
1152 i2c_bus = &dev->i2c_bus[0];
1153 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1154 &mygica_x8558pro_atbm8830_cfg1,
1155 &i2c_bus->i2c_adap);
1156 if (fe0->dvb.frontend != NULL) {
1157 dvb_attach(max2165_attach,
1158 fe0->dvb.frontend,
1159 &i2c_bus->i2c_adap,
1160 &mygic_x8558pro_max2165_cfg1);
1161 }
1162 break;
1163 /* port C */
1164 case 2:
1165 i2c_bus = &dev->i2c_bus[1];
1166 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1167 &mygica_x8558pro_atbm8830_cfg2,
1168 &i2c_bus->i2c_adap);
1169 if (fe0->dvb.frontend != NULL) {
1170 dvb_attach(max2165_attach,
1171 fe0->dvb.frontend,
1172 &i2c_bus->i2c_adap,
1173 &mygic_x8558pro_max2165_cfg2);
1174 }
1175 break;
1176 }
1177 break;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001178 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1179 i2c_bus = &dev->i2c_bus[0];
1180 mfe_shared = 1;/* MFE */
1181 port->frontends.gate = 0;/* not clear for me yet */
1182 /* ports B, C */
1183 /* MFE frontend 1 DVB-T */
1184 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1185 &netup_stv0367_config[port->nr - 1],
1186 &i2c_bus->i2c_adap);
Abylay Ospan4174ebf2011-01-02 09:15:00 -03001187 if (fe0->dvb.frontend != NULL) {
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001188 if (NULL == dvb_attach(xc5000_attach,
1189 fe0->dvb.frontend,
1190 &i2c_bus->i2c_adap,
1191 &netup_xc5000_config[port->nr - 1]))
1192 goto frontend_detach;
Abylay Ospan4174ebf2011-01-02 09:15:00 -03001193 /* load xc5000 firmware */
1194 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1195 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001196 /* MFE frontend 2 */
1197 fe1 = videobuf_dvb_get_frontend(&port->frontends, 2);
1198 if (fe1 == NULL)
1199 goto frontend_detach;
1200 /* DVB-C init */
1201 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1202 &netup_stv0367_config[port->nr - 1],
1203 &i2c_bus->i2c_adap);
1204 if (fe1->dvb.frontend != NULL) {
1205 fe1->dvb.frontend->id = 1;
1206 if (NULL == dvb_attach(xc5000_attach,
1207 fe1->dvb.frontend,
1208 &i2c_bus->i2c_adap,
1209 &netup_xc5000_config[port->nr - 1]))
1210 goto frontend_detach;
1211 }
1212 break;
Stefan Ringel722c90e2012-01-07 09:20:48 -03001213 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1214 i2c_bus = &dev->i2c_bus[0];
1215 i2c_bus2 = &dev->i2c_bus[1];
1216
1217 switch (port->nr) {
1218 /* port b */
1219 case 1:
1220 fe0->dvb.frontend = dvb_attach(drxk_attach,
1221 &terratec_drxk_config[0],
1222 &i2c_bus->i2c_adap);
1223 if (fe0->dvb.frontend != NULL) {
1224 if (!dvb_attach(mt2063_attach,
1225 fe0->dvb.frontend,
1226 &terratec_mt2063_config[0],
1227 &i2c_bus2->i2c_adap))
1228 goto frontend_detach;
1229 }
1230 break;
1231 /* port c */
1232 case 2:
1233 fe0->dvb.frontend = dvb_attach(drxk_attach,
1234 &terratec_drxk_config[1],
1235 &i2c_bus->i2c_adap);
1236 if (fe0->dvb.frontend != NULL) {
1237 if (!dvb_attach(mt2063_attach,
1238 fe0->dvb.frontend,
1239 &terratec_mt2063_config[1],
1240 &i2c_bus2->i2c_adap))
1241 goto frontend_detach;
1242 }
1243 break;
1244 }
1245 break;
Igor M. Liplianin7b134e82012-05-11 11:45:42 -03001246 case CX23885_BOARD_TEVII_S471:
1247 i2c_bus = &dev->i2c_bus[1];
1248
1249 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1250 &tevii_ds3000_config,
1251 &i2c_bus->i2c_adap);
1252 break;
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -03001253 case CX23885_BOARD_PROF_8000:
1254 i2c_bus = &dev->i2c_bus[0];
1255
1256 fe0->dvb.frontend = dvb_attach(stv090x_attach,
1257 &prof_8000_stv090x_config,
1258 &i2c_bus->i2c_adap,
1259 STV090x_DEMODULATOR_0);
1260 if (fe0->dvb.frontend != NULL) {
1261 if (!dvb_attach(stb6100_attach,
1262 fe0->dvb.frontend,
1263 &prof_8000_stb6100_config,
1264 &i2c_bus->i2c_adap))
1265 goto frontend_detach;
1266
1267 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1268 }
1269 break;
Michael Krufky7c62f5a2012-12-15 23:34:09 -03001270 case CX23885_BOARD_HAUPPAUGE_HVR4400:
1271 i2c_bus = &dev->i2c_bus[0];
1272 fe0->dvb.frontend = dvb_attach(tda10071_attach,
1273 &hauppauge_tda10071_config,
1274 &i2c_bus->i2c_adap);
1275 if (fe0->dvb.frontend != NULL) {
1276 dvb_attach(a8293_attach, fe0->dvb.frontend,
1277 &i2c_bus->i2c_adap,
1278 &hauppauge_a8293_config);
1279 }
1280 break;
Steven Tothd19770e2007-03-11 20:44:05 -03001281 default:
Steven Toth9c8ced52008-10-16 20:18:44 -03001282 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
1283 " isn't supported yet\n",
Steven Tothd19770e2007-03-11 20:44:05 -03001284 dev->name);
1285 break;
1286 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001287
1288 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
Steven Toth9c8ced52008-10-16 20:18:44 -03001289 printk(KERN_ERR "%s: frontend initialization failed\n",
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001290 dev->name);
1291 goto frontend_detach;
Steven Tothd19770e2007-03-11 20:44:05 -03001292 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001293
Michael Krufkyd7cba042008-09-12 13:31:45 -03001294 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001295 fe0->dvb.frontend->callback = cx23885_tuner_callback;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001296 if (fe1)
1297 fe1->dvb.frontend->callback = cx23885_tuner_callback;
1298#if 0
1299 /* Ensure all frontends negotiate bus access */
1300 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
1301 if (fe1)
1302 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
1303#endif
Steven Tothd19770e2007-03-11 20:44:05 -03001304
1305 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001306 call_all(dev, core, s_power, 0);
Steven Tothd19770e2007-03-11 20:44:05 -03001307
Steven Toth363c35f2008-10-11 11:05:50 -03001308 if (fe0->dvb.frontend->ops.analog_ops.standby)
1309 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
Michael Krufky3ba71d22007-12-07 01:40:36 -03001310
Steven Tothd19770e2007-03-11 20:44:05 -03001311 /* register everything */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001312 ret = videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port,
Mauro Carvalho Chehab9adf6132012-08-05 14:16:30 -03001313 &dev->pci->dev, adapter_nr, mfe_shared);
Abylay Ospanbee30192010-06-25 08:01:28 -03001314 if (ret)
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001315 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001316
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001317 /* init CI & MAC */
1318 switch (dev->board) {
1319 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1320 static struct netup_card_info cinfo;
1321
1322 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1323 memcpy(port->frontends.adapter.proposed_mac,
1324 cinfo.port[port->nr - 1].mac, 6);
hartleysbe395152009-12-30 16:08:57 -03001325 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1326 port->nr, port->frontends.adapter.proposed_mac);
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001327
1328 netup_ci_init(port);
1329 break;
1330 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001331 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1332 struct altera_ci_config netup_ci_cfg = {
1333 .dev = dev,/* magic number to identify*/
1334 .adapter = &port->frontends.adapter,/* for CI */
1335 .demux = &fe0->dvb.demux,/* for hw pid filter */
1336 .fpga_rw = netup_altera_fpga_rw,
1337 };
1338
1339 altera_ci_init(&netup_ci_cfg, port->nr);
1340 break;
1341 }
Pierre Gronlier16bfdaa42010-04-26 13:26:29 -03001342 case CX23885_BOARD_TEVII_S470: {
1343 u8 eeprom[256]; /* 24C02 i2c eeprom */
1344
1345 if (port->nr != 1)
1346 break;
1347
1348 /* Read entire EEPROM */
1349 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1350 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
Andy Shevchenko5cac1f62010-09-11 14:33:28 -03001351 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0);
Pierre Gronlier16bfdaa42010-04-26 13:26:29 -03001352 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1353 break;
1354 }
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001355 }
1356
1357 return ret;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001358
1359frontend_detach:
1360 port->gate_ctrl = NULL;
1361 videobuf_dvb_dealloc_frontends(&port->frontends);
1362 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03001363}
1364
1365int cx23885_dvb_register(struct cx23885_tsport *port)
1366{
Steven Toth363c35f2008-10-11 11:05:50 -03001367
1368 struct videobuf_dvb_frontend *fe0;
Steven Tothd19770e2007-03-11 20:44:05 -03001369 struct cx23885_dev *dev = port->dev;
Steven Totheb0c58b2008-10-11 12:34:39 -03001370 int err, i;
Steven Tothd19770e2007-03-11 20:44:05 -03001371
Steven Totheb0c58b2008-10-11 12:34:39 -03001372 /* Here we need to allocate the correct number of frontends,
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02001373 * as reflected in the cards struct. The reality is that currently
Steven Totheb0c58b2008-10-11 12:34:39 -03001374 * no cx23885 boards support this - yet. But, if we don't modify this
1375 * code then the second frontend would never be allocated (later)
1376 * and fail with error before the attach in dvb_register().
1377 * Without these changes we risk an OOPS later. The changes here
1378 * are for safety, and should provide a good foundation for the
1379 * future addition of any multi-frontend cx23885 based boards.
1380 */
1381 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
1382 port->num_frontends);
Steven Toth363c35f2008-10-11 11:05:50 -03001383
Steven Totheb0c58b2008-10-11 12:34:39 -03001384 for (i = 1; i <= port->num_frontends; i++) {
Darron Broad96b7a1a2008-10-15 20:26:34 -03001385 if (videobuf_dvb_alloc_frontend(
Steven Toth9c8ced52008-10-16 20:18:44 -03001386 &port->frontends, i) == NULL) {
Steven Totheb0c58b2008-10-11 12:34:39 -03001387 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1388 return -ENOMEM;
1389 }
Steven Tothd19770e2007-03-11 20:44:05 -03001390
Steven Totheb0c58b2008-10-11 12:34:39 -03001391 fe0 = videobuf_dvb_get_frontend(&port->frontends, i);
1392 if (!fe0)
1393 err = -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03001394
Steven Totheb0c58b2008-10-11 12:34:39 -03001395 dprintk(1, "%s\n", __func__);
Steven Toth9c8ced52008-10-16 20:18:44 -03001396 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
Steven Totheb0c58b2008-10-11 12:34:39 -03001397 dev->board,
1398 dev->name,
1399 dev->pci_bus,
1400 dev->pci_slot);
1401
1402 err = -ENODEV;
1403
1404 /* dvb stuff */
1405 /* We have to init the queue for each frontend on a port. */
Steven Toth9c8ced52008-10-16 20:18:44 -03001406 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
1407 videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops,
1408 &dev->pci->dev, &port->slock,
Michael Krufky44a64812007-03-20 23:00:18 -03001409 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
Hans Verkuil08bff032010-09-20 17:39:46 -03001410 sizeof(struct cx23885_buffer), port, NULL);
Steven Totheb0c58b2008-10-11 12:34:39 -03001411 }
Steven Tothd19770e2007-03-11 20:44:05 -03001412 err = dvb_register(port);
1413 if (err != 0)
Steven Toth9c8ced52008-10-16 20:18:44 -03001414 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
1415 __func__, err);
Steven Tothd19770e2007-03-11 20:44:05 -03001416
Steven Tothd19770e2007-03-11 20:44:05 -03001417 return err;
1418}
1419
1420int cx23885_dvb_unregister(struct cx23885_tsport *port)
1421{
Steven Toth363c35f2008-10-11 11:05:50 -03001422 struct videobuf_dvb_frontend *fe0;
1423
Steven Totheb0c58b2008-10-11 12:34:39 -03001424 /* FIXME: in an error condition where the we have
1425 * an expected number of frontends (attach problem)
1426 * then this might not clean up correctly, if 1
1427 * is invalid.
1428 * This comment only applies to future boards IF they
1429 * implement MFE support.
1430 */
Darron Broad92abe9e2008-10-11 11:18:53 -03001431 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Abylay Ospane66131c2011-07-15 15:01:07 -03001432 if (fe0 && fe0->dvb.frontend)
Steven Toth363c35f2008-10-11 11:05:50 -03001433 videobuf_dvb_unregister_bus(&port->frontends);
Steven Tothd19770e2007-03-11 20:44:05 -03001434
Hans Verkuilafd96662009-03-13 13:24:19 -03001435 switch (port->dev->board) {
1436 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1437 netup_ci_exit(port);
1438 break;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001439 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1440 altera_ci_release(port->dev, port->nr);
1441 break;
Hans Verkuilafd96662009-03-13 13:24:19 -03001442 }
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001443
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001444 port->gate_ctrl = NULL;
1445
Steven Tothd19770e2007-03-11 20:44:05 -03001446 return 0;
1447}
Michael Krufky44a64812007-03-20 23:00:18 -03001448