blob: a2ed0f759b0a1f9a7a4f76d4e2a192261c7a5db3 [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,
477};
478
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300479static struct cx24116_config dvbworld_cx24116_config = {
480 .demod_address = 0x05,
481};
482
David Wong493b7122009-05-18 05:25:49 -0300483static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
484 .prod = LGS8GXX_PROD_LGS8GL5,
485 .demod_address = 0x19,
486 .serial_ts = 0,
487 .ts_clk_pol = 1,
488 .ts_clk_gated = 1,
489 .if_clk_freq = 30400, /* 30.4 MHz */
490 .if_freq = 5380, /* 5.38 MHz */
491 .if_neg_center = 1,
492 .ext_adc = 0,
493 .adc_signed = 0,
494 .if_neg_edge = 0,
495};
496
497static struct xc5000_config mygica_x8506_xc5000_config = {
498 .i2c_address = 0x61,
499 .if_khz = 5380,
500};
501
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300502static struct stv090x_config prof_8000_stv090x_config = {
503 .device = STV0903,
504 .demod_mode = STV090x_SINGLE,
505 .clk_mode = STV090x_CLK_EXT,
506 .xtal = 27000000,
507 .address = 0x6A,
508 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
509 .repeater_level = STV090x_RPTLEVEL_64,
510 .adc1_range = STV090x_ADC_2Vpp,
511 .diseqc_envelope_mode = false,
512
513 .tuner_get_frequency = stb6100_get_frequency,
514 .tuner_set_frequency = stb6100_set_frequency,
515 .tuner_set_bandwidth = stb6100_set_bandwidth,
516 .tuner_get_bandwidth = stb6100_get_bandwidth,
517};
518
519static struct stb6100_config prof_8000_stb6100_config = {
520 .tuner_address = 0x60,
521 .refclock = 27000000,
522};
523
524static int p8000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
525{
526 struct cx23885_tsport *port = fe->dvb->priv;
527 struct cx23885_dev *dev = port->dev;
528
529 if (voltage == SEC_VOLTAGE_18)
530 cx_write(MC417_RWD, 0x00001e00);
531 else if (voltage == SEC_VOLTAGE_13)
532 cx_write(MC417_RWD, 0x00001a00);
533 else
534 cx_write(MC417_RWD, 0x00001800);
535 return 0;
536}
537
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300538static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300539{
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300540 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300541 struct cx23885_tsport *port = fe->dvb->priv;
542 struct cx23885_dev *dev = port->dev;
543
544 switch (dev->board) {
545 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300546 switch (p->modulation) {
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300547 case VSB_8:
548 cx23885_gpio_clear(dev, GPIO_5);
549 break;
550 case QAM_64:
551 case QAM_256:
552 default:
553 cx23885_gpio_set(dev, GPIO_5);
554 break;
555 }
556 break;
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300557 case CX23885_BOARD_MYGICA_X8506:
558 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
559 /* Select Digital TV */
560 cx23885_gpio_set(dev, GPIO_0);
561 break;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300562 }
Michael Krufky5bdd3962009-05-08 22:39:24 -0300563 return 0;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300564}
565
David Wong2365b2d2009-06-17 01:38:12 -0300566static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
567 .prod = LGS8GXX_PROD_LGS8G75,
568 .demod_address = 0x19,
569 .serial_ts = 0,
570 .ts_clk_pol = 1,
571 .ts_clk_gated = 1,
572 .if_clk_freq = 30400, /* 30.4 MHz */
573 .if_freq = 6500, /* 6.50 MHz */
574 .if_neg_center = 1,
575 .ext_adc = 0,
576 .adc_signed = 1,
577 .adc_vpp = 2, /* 1.6 Vpp */
578 .if_neg_edge = 1,
579};
580
581static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
582 .i2c_address = 0x61,
583 .if_khz = 6500,
584};
585
David T. L. Wongea5697f2009-10-26 08:54:04 -0300586static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
587 .prod = ATBM8830_PROD_8830,
588 .demod_address = 0x44,
589 .serial_ts = 0,
590 .ts_sampling_edge = 1,
591 .ts_clk_gated = 0,
592 .osc_clk_freq = 30400, /* in kHz */
593 .if_freq = 0, /* zero IF */
594 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300595 .agc_min = 0x2E,
596 .agc_max = 0xFF,
597 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300598};
599
600static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
601 .i2c_address = 0x60,
602 .osc_clk = 20
603};
604
605static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
606 .prod = ATBM8830_PROD_8830,
607 .demod_address = 0x44,
608 .serial_ts = 1,
609 .ts_sampling_edge = 1,
610 .ts_clk_gated = 0,
611 .osc_clk_freq = 30400, /* in kHz */
612 .if_freq = 0, /* zero IF */
613 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300614 .agc_min = 0x2E,
615 .agc_max = 0xFF,
616 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300617};
618
619static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
620 .i2c_address = 0x60,
621 .osc_clk = 20
622};
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300623static struct stv0367_config netup_stv0367_config[] = {
624 {
625 .demod_address = 0x1c,
626 .xtal = 27000000,
627 .if_khz = 4500,
628 .if_iq_mode = 0,
629 .ts_mode = 1,
630 .clk_pol = 0,
631 }, {
632 .demod_address = 0x1d,
633 .xtal = 27000000,
634 .if_khz = 4500,
635 .if_iq_mode = 0,
636 .ts_mode = 1,
637 .clk_pol = 0,
638 },
639};
640
641static struct xc5000_config netup_xc5000_config[] = {
642 {
643 .i2c_address = 0x61,
644 .if_khz = 4500,
645 }, {
646 .i2c_address = 0x64,
647 .if_khz = 4500,
648 },
649};
650
Stefan Ringel722c90e2012-01-07 09:20:48 -0300651static struct drxk_config terratec_drxk_config[] = {
652 {
653 .adr = 0x29,
654 .no_i2c_bridge = 1,
655 }, {
656 .adr = 0x2a,
657 .no_i2c_bridge = 1,
658 },
659};
660
661static struct mt2063_config terratec_mt2063_config[] = {
662 {
663 .tuner_address = 0x60,
664 }, {
665 .tuner_address = 0x67,
666 },
667};
668
Michael Krufky7c62f5a2012-12-15 23:34:09 -0300669static const struct tda10071_config hauppauge_tda10071_config = {
Michael Krufky41f55d52012-12-16 19:37:11 -0300670 .demod_i2c_addr = 0x05,
Michael Krufky7c62f5a2012-12-15 23:34:09 -0300671 .tuner_i2c_addr = 0x54,
672 .i2c_wr_max = 64,
673 .ts_mode = TDA10071_TS_SERIAL,
674 .spec_inv = 0,
675 .xtal = 40444000, /* 40.444 MHz */
676 .pll_multiplier = 20,
677};
678
679static const struct a8293_config hauppauge_a8293_config = {
680 .i2c_addr = 0x0b,
681};
682
Mauro Carvalho Chehabada73ee2012-10-27 11:29:23 -0300683static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300684{
685 struct cx23885_dev *dev = (struct cx23885_dev *)device;
686 unsigned long timeout = jiffies + msecs_to_jiffies(1);
Abylay Ospand1644602011-01-02 09:10:00 -0300687 uint32_t mem = 0;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300688
Abylay Ospand1644602011-01-02 09:10:00 -0300689 mem = cx_read(MC417_RWD);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300690 if (read)
691 cx_set(MC417_OEN, ALT_DATA);
692 else {
693 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300694 mem &= ~ALT_DATA;
695 mem |= (data & ALT_DATA);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300696 }
697
698 if (flag)
Abylay Ospand1644602011-01-02 09:10:00 -0300699 mem |= ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300700 else
Abylay Ospand1644602011-01-02 09:10:00 -0300701 mem &= ~ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300702
Abylay Ospand1644602011-01-02 09:10:00 -0300703 mem &= ~ALT_CS;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300704 if (read)
Abylay Ospand1644602011-01-02 09:10:00 -0300705 mem = (mem & ~ALT_RD) | ALT_WR;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300706 else
Abylay Ospand1644602011-01-02 09:10:00 -0300707 mem = (mem & ~ALT_WR) | ALT_RD;
708
709 cx_write(MC417_RWD, mem); /* start RW cycle */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300710
711 for (;;) {
712 mem = cx_read(MC417_RWD);
713 if ((mem & ALT_RDY) == 0)
714 break;
715 if (time_after(jiffies, timeout))
716 break;
717 udelay(1);
718 }
719
720 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
721 if (read)
722 return mem & ALT_DATA;
723
724 return 0;
725};
David T. L. Wongea5697f2009-10-26 08:54:04 -0300726
Steven Tothd19770e2007-03-11 20:44:05 -0300727static int dvb_register(struct cx23885_tsport *port)
728{
729 struct cx23885_dev *dev = port->dev;
David Wong493b7122009-05-18 05:25:49 -0300730 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300731 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
732 int mfe_shared = 0; /* bus not shared by default */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300733 int ret;
Steven Toth363c35f2008-10-11 11:05:50 -0300734
Darron Broadf972e0b2008-10-11 11:24:30 -0300735 /* Get the first frontend */
Darron Broad92abe9e2008-10-11 11:18:53 -0300736 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300737 if (!fe0)
738 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -0300739
740 /* init struct videobuf_dvb */
Steven Toth363c35f2008-10-11 11:05:50 -0300741 fe0->dvb.name = dev->name;
Steven Tothd19770e2007-03-11 20:44:05 -0300742
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300743 /* multi-frontend gate control is undefined or defaults to fe0 */
744 port->frontends.gate = 0;
745
746 /* Sets the gate control callback to be used by i2c command calls */
747 port->gate_ctrl = cx23885_dvb_gate_ctrl;
748
Steven Tothd19770e2007-03-11 20:44:05 -0300749 /* init frontend */
750 switch (dev->board) {
Steven Totha77743b2007-08-22 21:01:20 -0300751 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300752 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300753 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth86184e02007-09-04 21:40:47 -0300754 &hauppauge_generic_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300755 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300756 if (fe0->dvb.frontend != NULL) {
757 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300758 &i2c_bus->i2c_adap,
Steven Toth86184e02007-09-04 21:40:47 -0300759 &hauppauge_generic_tunerconfig, 0);
Steven Tothd19770e2007-03-11 20:44:05 -0300760 }
761 break;
Michael Krufkya5dbf452009-05-03 23:27:02 -0300762 case CX23885_BOARD_HAUPPAUGE_HVR1270:
Michael Krufkyd099bec2009-05-08 22:39:24 -0300763 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Michael Krufkya5dbf452009-05-03 23:27:02 -0300764 i2c_bus = &dev->i2c_bus[0];
765 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
Michael Krufky247bc542009-05-12 18:53:47 -0300766 &hauppauge_lgdt3305_config,
Michael Krufkya5dbf452009-05-03 23:27:02 -0300767 &i2c_bus->i2c_adap);
768 if (fe0->dvb.frontend != NULL) {
769 dvb_attach(tda18271_attach, fe0->dvb.frontend,
770 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufky247bc542009-05-12 18:53:47 -0300771 &hauppauge_hvr127x_config);
Michael Krufkya5dbf452009-05-03 23:27:02 -0300772 }
773 break;
Michael Krufky19bc5792009-05-08 16:05:29 -0300774 case CX23885_BOARD_HAUPPAUGE_HVR1255:
Devin Heitmueller0ac60ac2012-07-01 16:15:14 -0300775 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
Michael Krufky19bc5792009-05-08 16:05:29 -0300776 i2c_bus = &dev->i2c_bus[0];
777 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
778 &hcw_s5h1411_config,
779 &i2c_bus->i2c_adap);
780 if (fe0->dvb.frontend != NULL) {
781 dvb_attach(tda18271_attach, fe0->dvb.frontend,
782 0x60, &dev->i2c_bus[1].i2c_adap,
783 &hauppauge_tda18271_config);
784 }
Devin Heitmueller0ac60ac2012-07-01 16:15:14 -0300785
786 tda18271_attach(&dev->ts1.analog_fe,
787 0x60, &dev->i2c_bus[1].i2c_adap,
788 &hauppauge_tda18271_config);
789
Michael Krufky19bc5792009-05-08 16:05:29 -0300790 break;
Michael Krufky3ba71d22007-12-07 01:40:36 -0300791 case CX23885_BOARD_HAUPPAUGE_HVR1800:
792 i2c_bus = &dev->i2c_bus[0];
Darron Broad92abe9e2008-10-11 11:18:53 -0300793 switch (alt_tuner) {
Michael Krufky3ba71d22007-12-07 01:40:36 -0300794 case 1:
Steven Toth363c35f2008-10-11 11:05:50 -0300795 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300796 dvb_attach(s5h1409_attach,
797 &hauppauge_ezqam_config,
798 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300799 if (fe0->dvb.frontend != NULL) {
800 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300801 &dev->i2c_bus[1].i2c_adap, 0x42,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300802 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300803 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300804 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300805 &hauppauge_tda18271_config);
Michael Krufky3ba71d22007-12-07 01:40:36 -0300806 }
807 break;
808 case 0:
809 default:
Steven Toth363c35f2008-10-11 11:05:50 -0300810 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300811 dvb_attach(s5h1409_attach,
812 &hauppauge_generic_config,
813 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300814 if (fe0->dvb.frontend != NULL)
815 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300816 &i2c_bus->i2c_adap,
817 &hauppauge_generic_tunerconfig, 0);
818 break;
819 }
820 break;
Steven Tothfc959be2007-09-08 19:08:17 -0300821 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300822 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300823 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothfc959be2007-09-08 19:08:17 -0300824 &hauppauge_hvr1800lp_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300825 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300826 if (fe0->dvb.frontend != NULL) {
827 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300828 &i2c_bus->i2c_adap,
Steven Tothfc959be2007-09-08 19:08:17 -0300829 &hauppauge_generic_tunerconfig, 0);
830 }
831 break;
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300832 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300833 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300834 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300835 &fusionhdtv_5_express,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300836 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300837 if (fe0->dvb.frontend != NULL) {
838 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky827855d2008-04-22 14:46:16 -0300839 &i2c_bus->i2c_adap, 0x61,
840 TUNER_LG_TDVS_H06XF);
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300841 }
842 break;
Steven Tothd1987d52007-12-18 01:57:06 -0300843 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
844 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300845 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothd1987d52007-12-18 01:57:06 -0300846 &hauppauge_hvr1500q_config,
847 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300848 if (fe0->dvb.frontend != NULL)
849 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300850 &i2c_bus->i2c_adap,
851 &hauppauge_hvr1500q_tunerconfig);
Steven Tothd1987d52007-12-18 01:57:06 -0300852 break;
Michael Krufky07b4a832007-12-18 01:09:11 -0300853 case CX23885_BOARD_HAUPPAUGE_HVR1500:
854 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300855 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky07b4a832007-12-18 01:09:11 -0300856 &hauppauge_hvr1500_config,
857 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300858 if (fe0->dvb.frontend != NULL) {
Michael Krufky07b4a832007-12-18 01:09:11 -0300859 struct dvb_frontend *fe;
860 struct xc2028_config cfg = {
861 .i2c_adap = &i2c_bus->i2c_adap,
862 .i2c_addr = 0x61,
Michael Krufky07b4a832007-12-18 01:09:11 -0300863 };
864 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300865 .fname = XC2028_DEFAULT_FIRMWARE,
Michael Krufky07b4a832007-12-18 01:09:11 -0300866 .max_len = 64,
Steven Toth52c3d292009-04-20 22:42:00 -0300867 .demod = XC3028_FE_OREN538,
Michael Krufky07b4a832007-12-18 01:09:11 -0300868 };
869
870 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300871 fe0->dvb.frontend, &cfg);
Michael Krufky07b4a832007-12-18 01:09:11 -0300872 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
873 fe->ops.tuner_ops.set_config(fe, &ctl);
874 }
875 break;
Steven Tothb3ea0162008-04-19 01:14:19 -0300876 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Totha780a312008-04-19 01:25:52 -0300877 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Tothb3ea0162008-04-19 01:14:19 -0300878 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300879 fe0->dvb.frontend = dvb_attach(tda10048_attach,
Steven Tothb3ea0162008-04-19 01:14:19 -0300880 &hauppauge_hvr1200_config,
881 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300882 if (fe0->dvb.frontend != NULL) {
883 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300884 &dev->i2c_bus[1].i2c_adap, 0x42,
885 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300886 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300887 0x60, &dev->i2c_bus[1].i2c_adap,
888 &hauppauge_hvr1200_tuner_config);
889 }
890 break;
Michael Krufky6b926ec2009-05-12 17:32:17 -0300891 case CX23885_BOARD_HAUPPAUGE_HVR1210:
892 i2c_bus = &dev->i2c_bus[0];
893 fe0->dvb.frontend = dvb_attach(tda10048_attach,
894 &hauppauge_hvr1210_config,
895 &i2c_bus->i2c_adap);
896 if (fe0->dvb.frontend != NULL) {
897 dvb_attach(tda18271_attach, fe0->dvb.frontend,
898 0x60, &dev->i2c_bus[1].i2c_adap,
899 &hauppauge_hvr1210_tuner_config);
900 }
901 break;
Steven Toth66762372008-04-22 15:38:26 -0300902 case CX23885_BOARD_HAUPPAUGE_HVR1400:
903 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300904 fe0->dvb.frontend = dvb_attach(dib7000p_attach,
Steven Toth66762372008-04-22 15:38:26 -0300905 &i2c_bus->i2c_adap,
906 0x12, &hauppauge_hvr1400_dib7000_config);
Steven Toth363c35f2008-10-11 11:05:50 -0300907 if (fe0->dvb.frontend != NULL) {
Steven Toth66762372008-04-22 15:38:26 -0300908 struct dvb_frontend *fe;
909 struct xc2028_config cfg = {
910 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
911 .i2c_addr = 0x64,
Steven Toth66762372008-04-22 15:38:26 -0300912 };
913 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300914 .fname = XC3028L_DEFAULT_FIRMWARE,
Steven Toth66762372008-04-22 15:38:26 -0300915 .max_len = 64,
Mauro Carvalho Chehab9bed77e2011-07-28 16:38:54 -0300916 .demod = XC3028_FE_DIBCOM52,
Steven Toth9c8ced52008-10-16 20:18:44 -0300917 /* This is true for all demods with
918 v36 firmware? */
Mauro Carvalho Chehab0975fc62008-09-28 02:24:44 -0300919 .type = XC2028_D2633,
Steven Toth66762372008-04-22 15:38:26 -0300920 };
921
922 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300923 fe0->dvb.frontend, &cfg);
Steven Toth66762372008-04-22 15:38:26 -0300924 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
925 fe->ops.tuner_ops.set_config(fe, &ctl);
926 }
927 break;
Michael Krufky335377b2008-05-07 01:43:10 -0300928 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
929 i2c_bus = &dev->i2c_bus[port->nr - 1];
930
Steven Toth363c35f2008-10-11 11:05:50 -0300931 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky335377b2008-05-07 01:43:10 -0300932 &dvico_s5h1409_config,
933 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300934 if (fe0->dvb.frontend == NULL)
935 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Michael Krufky52b50452008-07-09 02:18:49 -0300936 &dvico_s5h1411_config,
937 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300938 if (fe0->dvb.frontend != NULL)
939 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300940 &i2c_bus->i2c_adap,
941 &dvico_xc5000_tunerconfig);
Michael Krufky335377b2008-05-07 01:43:10 -0300942 break;
Steven Tothaef2d182008-08-04 21:39:53 -0300943 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
944 i2c_bus = &dev->i2c_bus[port->nr - 1];
945
Steven Toth363c35f2008-10-11 11:05:50 -0300946 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Tothaef2d182008-08-04 21:39:53 -0300947 &dvico_fusionhdtv_xc3028,
948 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300949 if (fe0->dvb.frontend != NULL) {
Steven Tothaef2d182008-08-04 21:39:53 -0300950 struct dvb_frontend *fe;
951 struct xc2028_config cfg = {
952 .i2c_adap = &i2c_bus->i2c_adap,
953 .i2c_addr = 0x61,
Steven Tothaef2d182008-08-04 21:39:53 -0300954 };
955 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300956 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Tothaef2d182008-08-04 21:39:53 -0300957 .max_len = 64,
958 .demod = XC3028_FE_ZARLINK456,
959 };
960
Steven Toth363c35f2008-10-11 11:05:50 -0300961 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Tothaef2d182008-08-04 21:39:53 -0300962 &cfg);
963 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
964 fe->ops.tuner_ops.set_config(fe, &ctl);
965 }
966 break;
967 }
Steven Toth4c56b042008-08-12 13:30:03 -0300968 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -0300969 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Vladimir Geroy34e383d2009-09-18 18:55:47 -0300970 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
Steven Toth4c56b042008-08-12 13:30:03 -0300971 i2c_bus = &dev->i2c_bus[0];
972
Steven Toth363c35f2008-10-11 11:05:50 -0300973 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Toth4c56b042008-08-12 13:30:03 -0300974 &dvico_fusionhdtv_xc3028,
975 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300976 if (fe0->dvb.frontend != NULL) {
Steven Toth4c56b042008-08-12 13:30:03 -0300977 struct dvb_frontend *fe;
978 struct xc2028_config cfg = {
979 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
980 .i2c_addr = 0x61,
Steven Toth4c56b042008-08-12 13:30:03 -0300981 };
982 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300983 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth4c56b042008-08-12 13:30:03 -0300984 .max_len = 64,
985 .demod = XC3028_FE_ZARLINK456,
986 };
987
Steven Toth363c35f2008-10-11 11:05:50 -0300988 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Toth4c56b042008-08-12 13:30:03 -0300989 &cfg);
990 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
991 fe->ops.tuner_ops.set_config(fe, &ctl);
992 }
993 break;
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -0300994 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
995 i2c_bus = &dev->i2c_bus[0];
996
997 fe0->dvb.frontend = dvb_attach(zl10353_attach,
998 &dvico_fusionhdtv_xc3028,
999 &i2c_bus->i2c_adap);
1000 if (fe0->dvb.frontend != NULL) {
1001 struct dvb_frontend *fe;
1002 struct xc4000_config cfg = {
1003 .i2c_address = 0x61,
1004 .default_pm = 0,
1005 .dvb_amplitude = 134,
1006 .set_smoothedcvbs = 1,
1007 .if_khz = 4560
1008 };
1009
1010 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1011 &dev->i2c_bus[1].i2c_adap, &cfg);
Miroslav Slugena7c8aad2011-12-11 18:57:58 -03001012 if (!fe) {
1013 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
1014 dev->name);
1015 goto frontend_detach;
1016 }
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -03001017 }
1018 break;
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001019 case CX23885_BOARD_TBS_6920:
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001020 i2c_bus = &dev->i2c_bus[1];
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001021
1022 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001023 &tbs_cx24116_config,
1024 &i2c_bus->i2c_adap);
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001025 if (fe0->dvb.frontend != NULL)
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001026 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001027
1028 break;
Igor M. Liplianin579943f2009-01-17 12:18:26 -03001029 case CX23885_BOARD_TEVII_S470:
1030 i2c_bus = &dev->i2c_bus[1];
1031
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001032 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1033 &tevii_ds3000_config,
1034 &i2c_bus->i2c_adap);
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001035 if (fe0->dvb.frontend != NULL) {
1036 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1037 &tevii_ts2020_config, &i2c_bus->i2c_adap);
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001038 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
Konstantin Dimitrov73f0af42012-12-23 19:25:38 -03001039 }
Igor M. Liplianin579943f2009-01-17 12:18:26 -03001040
1041 break;
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -03001042 case CX23885_BOARD_DVBWORLD_2005:
1043 i2c_bus = &dev->i2c_bus[1];
1044
1045 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1046 &dvbworld_cx24116_config,
1047 &i2c_bus->i2c_adap);
1048 break;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001049 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1050 i2c_bus = &dev->i2c_bus[0];
1051 switch (port->nr) {
1052 /* port B */
1053 case 1:
1054 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1055 &netup_stv0900_config,
1056 &i2c_bus->i2c_adap, 0);
1057 if (fe0->dvb.frontend != NULL) {
1058 if (dvb_attach(stv6110_attach,
1059 fe0->dvb.frontend,
1060 &netup_stv6110_tunerconfig_a,
1061 &i2c_bus->i2c_adap)) {
1062 if (!dvb_attach(lnbh24_attach,
1063 fe0->dvb.frontend,
1064 &i2c_bus->i2c_adap,
Abylay Ospan9329fb52009-10-17 08:38:45 -03001065 LNBH24_PCL | LNBH24_TTX,
1066 LNBH24_TEN, 0x09))
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001067 printk(KERN_ERR
1068 "No LNBH24 found!\n");
1069
1070 }
1071 }
1072 break;
1073 /* port C */
1074 case 2:
1075 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1076 &netup_stv0900_config,
1077 &i2c_bus->i2c_adap, 1);
1078 if (fe0->dvb.frontend != NULL) {
1079 if (dvb_attach(stv6110_attach,
1080 fe0->dvb.frontend,
1081 &netup_stv6110_tunerconfig_b,
1082 &i2c_bus->i2c_adap)) {
1083 if (!dvb_attach(lnbh24_attach,
1084 fe0->dvb.frontend,
1085 &i2c_bus->i2c_adap,
Abylay Ospan9329fb52009-10-17 08:38:45 -03001086 LNBH24_PCL | LNBH24_TTX,
1087 LNBH24_TEN, 0x0a))
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001088 printk(KERN_ERR
1089 "No LNBH24 found!\n");
1090
1091 }
1092 }
1093 break;
1094 }
1095 break;
David Wong493b7122009-05-18 05:25:49 -03001096 case CX23885_BOARD_MYGICA_X8506:
1097 i2c_bus = &dev->i2c_bus[0];
1098 i2c_bus2 = &dev->i2c_bus[1];
1099 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1100 &mygica_x8506_lgs8gl5_config,
1101 &i2c_bus->i2c_adap);
1102 if (fe0->dvb.frontend != NULL) {
1103 dvb_attach(xc5000_attach,
1104 fe0->dvb.frontend,
1105 &i2c_bus2->i2c_adap,
1106 &mygica_x8506_xc5000_config);
1107 }
1108 break;
David Wong2365b2d2009-06-17 01:38:12 -03001109 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1110 i2c_bus = &dev->i2c_bus[0];
1111 i2c_bus2 = &dev->i2c_bus[1];
1112 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1113 &magicpro_prohdtve2_lgs8g75_config,
1114 &i2c_bus->i2c_adap);
1115 if (fe0->dvb.frontend != NULL) {
1116 dvb_attach(xc5000_attach,
1117 fe0->dvb.frontend,
1118 &i2c_bus2->i2c_adap,
1119 &magicpro_prohdtve2_xc5000_config);
1120 }
1121 break;
Steven Toth136973802009-07-20 15:37:25 -03001122 case CX23885_BOARD_HAUPPAUGE_HVR1850:
Steven Toth35045132012-01-04 21:08:35 -03001123 i2c_bus = &dev->i2c_bus[0];
1124 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1125 &hcw_s5h1411_config,
1126 &i2c_bus->i2c_adap);
1127 if (fe0->dvb.frontend != NULL)
1128 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1129 0x60, &dev->i2c_bus[0].i2c_adap,
1130 &hauppauge_tda18271_config);
1131
1132 tda18271_attach(&dev->ts1.analog_fe,
1133 0x60, &dev->i2c_bus[1].i2c_adap,
1134 &hauppauge_tda18271_config);
1135
1136 break;
Michael Krufkyaee0b242009-11-11 01:52:45 -03001137 case CX23885_BOARD_HAUPPAUGE_HVR1290:
Steven Toth136973802009-07-20 15:37:25 -03001138 i2c_bus = &dev->i2c_bus[0];
1139 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1140 &hcw_s5h1411_config,
1141 &i2c_bus->i2c_adap);
1142 if (fe0->dvb.frontend != NULL)
1143 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1144 0x60, &dev->i2c_bus[0].i2c_adap,
1145 &hauppauge_tda18271_config);
1146 break;
David T. L. Wongea5697f2009-10-26 08:54:04 -03001147 case CX23885_BOARD_MYGICA_X8558PRO:
1148 switch (port->nr) {
1149 /* port B */
1150 case 1:
1151 i2c_bus = &dev->i2c_bus[0];
1152 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1153 &mygica_x8558pro_atbm8830_cfg1,
1154 &i2c_bus->i2c_adap);
1155 if (fe0->dvb.frontend != NULL) {
1156 dvb_attach(max2165_attach,
1157 fe0->dvb.frontend,
1158 &i2c_bus->i2c_adap,
1159 &mygic_x8558pro_max2165_cfg1);
1160 }
1161 break;
1162 /* port C */
1163 case 2:
1164 i2c_bus = &dev->i2c_bus[1];
1165 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1166 &mygica_x8558pro_atbm8830_cfg2,
1167 &i2c_bus->i2c_adap);
1168 if (fe0->dvb.frontend != NULL) {
1169 dvb_attach(max2165_attach,
1170 fe0->dvb.frontend,
1171 &i2c_bus->i2c_adap,
1172 &mygic_x8558pro_max2165_cfg2);
1173 }
1174 break;
1175 }
1176 break;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001177 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1178 i2c_bus = &dev->i2c_bus[0];
1179 mfe_shared = 1;/* MFE */
1180 port->frontends.gate = 0;/* not clear for me yet */
1181 /* ports B, C */
1182 /* MFE frontend 1 DVB-T */
1183 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1184 &netup_stv0367_config[port->nr - 1],
1185 &i2c_bus->i2c_adap);
Abylay Ospan4174ebf2011-01-02 09:15:00 -03001186 if (fe0->dvb.frontend != NULL) {
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001187 if (NULL == dvb_attach(xc5000_attach,
1188 fe0->dvb.frontend,
1189 &i2c_bus->i2c_adap,
1190 &netup_xc5000_config[port->nr - 1]))
1191 goto frontend_detach;
Abylay Ospan4174ebf2011-01-02 09:15:00 -03001192 /* load xc5000 firmware */
1193 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1194 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001195 /* MFE frontend 2 */
1196 fe1 = videobuf_dvb_get_frontend(&port->frontends, 2);
1197 if (fe1 == NULL)
1198 goto frontend_detach;
1199 /* DVB-C init */
1200 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1201 &netup_stv0367_config[port->nr - 1],
1202 &i2c_bus->i2c_adap);
1203 if (fe1->dvb.frontend != NULL) {
1204 fe1->dvb.frontend->id = 1;
1205 if (NULL == dvb_attach(xc5000_attach,
1206 fe1->dvb.frontend,
1207 &i2c_bus->i2c_adap,
1208 &netup_xc5000_config[port->nr - 1]))
1209 goto frontend_detach;
1210 }
1211 break;
Stefan Ringel722c90e2012-01-07 09:20:48 -03001212 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1213 i2c_bus = &dev->i2c_bus[0];
1214 i2c_bus2 = &dev->i2c_bus[1];
1215
1216 switch (port->nr) {
1217 /* port b */
1218 case 1:
1219 fe0->dvb.frontend = dvb_attach(drxk_attach,
1220 &terratec_drxk_config[0],
1221 &i2c_bus->i2c_adap);
1222 if (fe0->dvb.frontend != NULL) {
1223 if (!dvb_attach(mt2063_attach,
1224 fe0->dvb.frontend,
1225 &terratec_mt2063_config[0],
1226 &i2c_bus2->i2c_adap))
1227 goto frontend_detach;
1228 }
1229 break;
1230 /* port c */
1231 case 2:
1232 fe0->dvb.frontend = dvb_attach(drxk_attach,
1233 &terratec_drxk_config[1],
1234 &i2c_bus->i2c_adap);
1235 if (fe0->dvb.frontend != NULL) {
1236 if (!dvb_attach(mt2063_attach,
1237 fe0->dvb.frontend,
1238 &terratec_mt2063_config[1],
1239 &i2c_bus2->i2c_adap))
1240 goto frontend_detach;
1241 }
1242 break;
1243 }
1244 break;
Igor M. Liplianin7b134e82012-05-11 11:45:42 -03001245 case CX23885_BOARD_TEVII_S471:
1246 i2c_bus = &dev->i2c_bus[1];
1247
1248 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1249 &tevii_ds3000_config,
1250 &i2c_bus->i2c_adap);
1251 break;
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -03001252 case CX23885_BOARD_PROF_8000:
1253 i2c_bus = &dev->i2c_bus[0];
1254
1255 fe0->dvb.frontend = dvb_attach(stv090x_attach,
1256 &prof_8000_stv090x_config,
1257 &i2c_bus->i2c_adap,
1258 STV090x_DEMODULATOR_0);
1259 if (fe0->dvb.frontend != NULL) {
1260 if (!dvb_attach(stb6100_attach,
1261 fe0->dvb.frontend,
1262 &prof_8000_stb6100_config,
1263 &i2c_bus->i2c_adap))
1264 goto frontend_detach;
1265
1266 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1267 }
1268 break;
Michael Krufky7c62f5a2012-12-15 23:34:09 -03001269 case CX23885_BOARD_HAUPPAUGE_HVR4400:
1270 i2c_bus = &dev->i2c_bus[0];
1271 fe0->dvb.frontend = dvb_attach(tda10071_attach,
1272 &hauppauge_tda10071_config,
1273 &i2c_bus->i2c_adap);
1274 if (fe0->dvb.frontend != NULL) {
1275 dvb_attach(a8293_attach, fe0->dvb.frontend,
1276 &i2c_bus->i2c_adap,
1277 &hauppauge_a8293_config);
1278 }
1279 break;
Steven Tothd19770e2007-03-11 20:44:05 -03001280 default:
Steven Toth9c8ced52008-10-16 20:18:44 -03001281 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
1282 " isn't supported yet\n",
Steven Tothd19770e2007-03-11 20:44:05 -03001283 dev->name);
1284 break;
1285 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001286
1287 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
Steven Toth9c8ced52008-10-16 20:18:44 -03001288 printk(KERN_ERR "%s: frontend initialization failed\n",
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001289 dev->name);
1290 goto frontend_detach;
Steven Tothd19770e2007-03-11 20:44:05 -03001291 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001292
Michael Krufkyd7cba042008-09-12 13:31:45 -03001293 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001294 fe0->dvb.frontend->callback = cx23885_tuner_callback;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001295 if (fe1)
1296 fe1->dvb.frontend->callback = cx23885_tuner_callback;
1297#if 0
1298 /* Ensure all frontends negotiate bus access */
1299 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
1300 if (fe1)
1301 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
1302#endif
Steven Tothd19770e2007-03-11 20:44:05 -03001303
1304 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001305 call_all(dev, core, s_power, 0);
Steven Tothd19770e2007-03-11 20:44:05 -03001306
Steven Toth363c35f2008-10-11 11:05:50 -03001307 if (fe0->dvb.frontend->ops.analog_ops.standby)
1308 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
Michael Krufky3ba71d22007-12-07 01:40:36 -03001309
Steven Tothd19770e2007-03-11 20:44:05 -03001310 /* register everything */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001311 ret = videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port,
Mauro Carvalho Chehab9adf6132012-08-05 14:16:30 -03001312 &dev->pci->dev, adapter_nr, mfe_shared);
Abylay Ospanbee30192010-06-25 08:01:28 -03001313 if (ret)
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001314 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001315
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001316 /* init CI & MAC */
1317 switch (dev->board) {
1318 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1319 static struct netup_card_info cinfo;
1320
1321 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1322 memcpy(port->frontends.adapter.proposed_mac,
1323 cinfo.port[port->nr - 1].mac, 6);
hartleysbe395152009-12-30 16:08:57 -03001324 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1325 port->nr, port->frontends.adapter.proposed_mac);
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001326
1327 netup_ci_init(port);
1328 break;
1329 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001330 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1331 struct altera_ci_config netup_ci_cfg = {
1332 .dev = dev,/* magic number to identify*/
1333 .adapter = &port->frontends.adapter,/* for CI */
1334 .demux = &fe0->dvb.demux,/* for hw pid filter */
1335 .fpga_rw = netup_altera_fpga_rw,
1336 };
1337
1338 altera_ci_init(&netup_ci_cfg, port->nr);
1339 break;
1340 }
Pierre Gronlier16bfdaa42010-04-26 13:26:29 -03001341 case CX23885_BOARD_TEVII_S470: {
1342 u8 eeprom[256]; /* 24C02 i2c eeprom */
1343
1344 if (port->nr != 1)
1345 break;
1346
1347 /* Read entire EEPROM */
1348 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1349 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
Andy Shevchenko5cac1f62010-09-11 14:33:28 -03001350 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0);
Pierre Gronlier16bfdaa42010-04-26 13:26:29 -03001351 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1352 break;
1353 }
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001354 }
1355
1356 return ret;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001357
1358frontend_detach:
1359 port->gate_ctrl = NULL;
1360 videobuf_dvb_dealloc_frontends(&port->frontends);
1361 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03001362}
1363
1364int cx23885_dvb_register(struct cx23885_tsport *port)
1365{
Steven Toth363c35f2008-10-11 11:05:50 -03001366
1367 struct videobuf_dvb_frontend *fe0;
Steven Tothd19770e2007-03-11 20:44:05 -03001368 struct cx23885_dev *dev = port->dev;
Steven Totheb0c58b2008-10-11 12:34:39 -03001369 int err, i;
Steven Tothd19770e2007-03-11 20:44:05 -03001370
Steven Totheb0c58b2008-10-11 12:34:39 -03001371 /* Here we need to allocate the correct number of frontends,
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02001372 * as reflected in the cards struct. The reality is that currently
Steven Totheb0c58b2008-10-11 12:34:39 -03001373 * no cx23885 boards support this - yet. But, if we don't modify this
1374 * code then the second frontend would never be allocated (later)
1375 * and fail with error before the attach in dvb_register().
1376 * Without these changes we risk an OOPS later. The changes here
1377 * are for safety, and should provide a good foundation for the
1378 * future addition of any multi-frontend cx23885 based boards.
1379 */
1380 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
1381 port->num_frontends);
Steven Toth363c35f2008-10-11 11:05:50 -03001382
Steven Totheb0c58b2008-10-11 12:34:39 -03001383 for (i = 1; i <= port->num_frontends; i++) {
Darron Broad96b7a1a2008-10-15 20:26:34 -03001384 if (videobuf_dvb_alloc_frontend(
Steven Toth9c8ced52008-10-16 20:18:44 -03001385 &port->frontends, i) == NULL) {
Steven Totheb0c58b2008-10-11 12:34:39 -03001386 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1387 return -ENOMEM;
1388 }
Steven Tothd19770e2007-03-11 20:44:05 -03001389
Steven Totheb0c58b2008-10-11 12:34:39 -03001390 fe0 = videobuf_dvb_get_frontend(&port->frontends, i);
1391 if (!fe0)
1392 err = -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03001393
Steven Totheb0c58b2008-10-11 12:34:39 -03001394 dprintk(1, "%s\n", __func__);
Steven Toth9c8ced52008-10-16 20:18:44 -03001395 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
Steven Totheb0c58b2008-10-11 12:34:39 -03001396 dev->board,
1397 dev->name,
1398 dev->pci_bus,
1399 dev->pci_slot);
1400
1401 err = -ENODEV;
1402
1403 /* dvb stuff */
1404 /* We have to init the queue for each frontend on a port. */
Steven Toth9c8ced52008-10-16 20:18:44 -03001405 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
1406 videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops,
1407 &dev->pci->dev, &port->slock,
Michael Krufky44a64812007-03-20 23:00:18 -03001408 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
Hans Verkuil08bff032010-09-20 17:39:46 -03001409 sizeof(struct cx23885_buffer), port, NULL);
Steven Totheb0c58b2008-10-11 12:34:39 -03001410 }
Steven Tothd19770e2007-03-11 20:44:05 -03001411 err = dvb_register(port);
1412 if (err != 0)
Steven Toth9c8ced52008-10-16 20:18:44 -03001413 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
1414 __func__, err);
Steven Tothd19770e2007-03-11 20:44:05 -03001415
Steven Tothd19770e2007-03-11 20:44:05 -03001416 return err;
1417}
1418
1419int cx23885_dvb_unregister(struct cx23885_tsport *port)
1420{
Steven Toth363c35f2008-10-11 11:05:50 -03001421 struct videobuf_dvb_frontend *fe0;
1422
Steven Totheb0c58b2008-10-11 12:34:39 -03001423 /* FIXME: in an error condition where the we have
1424 * an expected number of frontends (attach problem)
1425 * then this might not clean up correctly, if 1
1426 * is invalid.
1427 * This comment only applies to future boards IF they
1428 * implement MFE support.
1429 */
Darron Broad92abe9e2008-10-11 11:18:53 -03001430 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Abylay Ospane66131c2011-07-15 15:01:07 -03001431 if (fe0 && fe0->dvb.frontend)
Steven Toth363c35f2008-10-11 11:05:50 -03001432 videobuf_dvb_unregister_bus(&port->frontends);
Steven Tothd19770e2007-03-11 20:44:05 -03001433
Hans Verkuilafd96662009-03-13 13:24:19 -03001434 switch (port->dev->board) {
1435 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1436 netup_ci_exit(port);
1437 break;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001438 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1439 altera_ci_release(port->dev, port->nr);
1440 break;
Hans Verkuilafd96662009-03-13 13:24:19 -03001441 }
Igor M. Liplianin5a23b072009-03-03 12:06:09 -03001442
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001443 port->gate_ctrl = NULL;
1444
Steven Tothd19770e2007-03-11 20:44:05 -03001445 return 0;
1446}
Michael Krufky44a64812007-03-20 23:00:18 -03001447