blob: cf84c534f005fa3483d8e6575f7b07fcb0b66253 [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. Liplianin5a23b0762009-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. Liplianin5a23b0762009-03-03 12:06:09 -030049#include "stv0900.h"
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -030050#include "stv0900_reg.h"
Igor M. Liplianin5a23b0762009-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. Liplianin5a23b0762009-03-03 12:06:09 -030054#include "cimax2.h"
David Wong493b7122009-05-18 05:25:49 -030055#include "lgs8gxx.h"
Igor M. Liplianin5a23b0762009-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"
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -030060#include "ds3000.h"
61#include "cx23885-f300.h"
Igor M. Liplianin78db8542011-01-25 17:04:00 -030062#include "altera-ci.h"
63#include "stv0367.h"
Stefan Ringel722c90e2012-01-07 09:20:48 -030064#include "drxk.h"
65#include "mt2063.h"
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -030066#include "stv090x.h"
67#include "stb6100.h"
68#include "stb6100_cfg.h"
Michael Krufky7c62f5a2012-12-15 23:34:09 -030069#include "tda10071.h"
70#include "a8293.h"
Steven Tothd19770e2007-03-11 20:44:05 -030071
Steven Toth4513fc692008-01-12 11:36:36 -030072static unsigned int debug;
Steven Tothd19770e2007-03-11 20:44:05 -030073
Steven Toth4513fc692008-01-12 11:36:36 -030074#define dprintk(level, fmt, arg...)\
75 do { if (debug >= level)\
76 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
77 } while (0)
Steven Tothd19770e2007-03-11 20:44:05 -030078
79/* ------------------------------------------------------------------ */
80
Michael Krufky3ba71d22007-12-07 01:40:36 -030081static unsigned int alt_tuner;
82module_param(alt_tuner, int, 0644);
83MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
84
Janne Grunau78e92002008-04-09 19:13:13 -030085DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
86
Michael Krufky3ba71d22007-12-07 01:40:36 -030087/* ------------------------------------------------------------------ */
88
Steven Tothd19770e2007-03-11 20:44:05 -030089static int dvb_buf_setup(struct videobuf_queue *q,
90 unsigned int *count, unsigned int *size)
91{
92 struct cx23885_tsport *port = q->priv_data;
93
94 port->ts_packet_size = 188 * 4;
95 port->ts_packet_count = 32;
96
97 *size = port->ts_packet_size * port->ts_packet_count;
98 *count = 32;
99 return 0;
100}
101
Michael Krufky44a64812007-03-20 23:00:18 -0300102static int dvb_buf_prepare(struct videobuf_queue *q,
103 struct videobuf_buffer *vb, enum v4l2_field field)
Steven Tothd19770e2007-03-11 20:44:05 -0300104{
105 struct cx23885_tsport *port = q->priv_data;
Steven Toth9c8ced52008-10-16 20:18:44 -0300106 return cx23885_buf_prepare(q, port, (struct cx23885_buffer *)vb, field);
Steven Tothd19770e2007-03-11 20:44:05 -0300107}
108
109static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
110{
111 struct cx23885_tsport *port = q->priv_data;
Steven Toth9c8ced52008-10-16 20:18:44 -0300112 cx23885_buf_queue(port, (struct cx23885_buffer *)vb);
Steven Tothd19770e2007-03-11 20:44:05 -0300113}
114
Michael Krufky44a64812007-03-20 23:00:18 -0300115static void dvb_buf_release(struct videobuf_queue *q,
116 struct videobuf_buffer *vb)
Steven Tothd19770e2007-03-11 20:44:05 -0300117{
Steven Toth9c8ced52008-10-16 20:18:44 -0300118 cx23885_free_buffer(q, (struct cx23885_buffer *)vb);
Steven Tothd19770e2007-03-11 20:44:05 -0300119}
120
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300121static int cx23885_dvb_set_frontend(struct dvb_frontend *fe);
122
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300123static void cx23885_dvb_gate_ctrl(struct cx23885_tsport *port, int open)
124{
125 struct videobuf_dvb_frontends *f;
126 struct videobuf_dvb_frontend *fe;
127
128 f = &port->frontends;
129
130 if (f->gate <= 1) /* undefined or fe0 */
131 fe = videobuf_dvb_get_frontend(f, 1);
132 else
133 fe = videobuf_dvb_get_frontend(f, f->gate);
134
135 if (fe && fe->dvb.frontend && fe->dvb.frontend->ops.i2c_gate_ctrl)
136 fe->dvb.frontend->ops.i2c_gate_ctrl(fe->dvb.frontend, open);
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300137
138 /*
139 * FIXME: Improve this path to avoid calling the
140 * cx23885_dvb_set_frontend() every time it passes here.
141 */
142 cx23885_dvb_set_frontend(fe->dvb.frontend);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300143}
144
Steven Tothd19770e2007-03-11 20:44:05 -0300145static struct videobuf_queue_ops dvb_qops = {
146 .buf_setup = dvb_buf_setup,
147 .buf_prepare = dvb_buf_prepare,
148 .buf_queue = dvb_buf_queue,
149 .buf_release = dvb_buf_release,
150};
151
Steven Toth86184e02007-09-04 21:40:47 -0300152static struct s5h1409_config hauppauge_generic_config = {
Steven Tothd19770e2007-03-11 20:44:05 -0300153 .demod_address = 0x32 >> 1,
154 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothfc959be2007-09-08 19:08:17 -0300155 .gpio = S5H1409_GPIO_ON,
Michael Krufky2b032382007-12-13 10:04:10 -0300156 .qam_if = 44000,
Steven Tothfc959be2007-09-08 19:08:17 -0300157 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300158 .status_mode = S5H1409_DEMODLOCKING,
159 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothfc959be2007-09-08 19:08:17 -0300160};
161
Steven Tothb3ea0162008-04-19 01:14:19 -0300162static struct tda10048_config hauppauge_hvr1200_config = {
163 .demod_address = 0x10 >> 1,
164 .output_mode = TDA10048_SERIAL_OUTPUT,
165 .fwbulkwritelen = TDA10048_BULKWRITE_200,
Steven Toth484d9e02009-05-02 11:08:23 -0300166 .inversion = TDA10048_INVERSION_ON,
Steven Toth8816bef2009-05-15 21:04:18 -0300167 .dtv6_if_freq_khz = TDA10048_IF_3300,
168 .dtv7_if_freq_khz = TDA10048_IF_3800,
169 .dtv8_if_freq_khz = TDA10048_IF_4300,
Steven Toth484d9e02009-05-02 11:08:23 -0300170 .clk_freq_khz = TDA10048_CLK_16000,
Steven Tothb3ea0162008-04-19 01:14:19 -0300171};
172
Michael Krufky6b926ec2009-05-12 17:32:17 -0300173static struct tda10048_config hauppauge_hvr1210_config = {
174 .demod_address = 0x10 >> 1,
175 .output_mode = TDA10048_SERIAL_OUTPUT,
176 .fwbulkwritelen = TDA10048_BULKWRITE_200,
177 .inversion = TDA10048_INVERSION_ON,
Michael Krufkyc27586e2009-05-16 11:00:23 -0300178 .dtv6_if_freq_khz = TDA10048_IF_3300,
179 .dtv7_if_freq_khz = TDA10048_IF_3500,
180 .dtv8_if_freq_khz = TDA10048_IF_4000,
Michael Krufky6b926ec2009-05-12 17:32:17 -0300181 .clk_freq_khz = TDA10048_CLK_16000,
182};
183
Michael Krufky3ba71d22007-12-07 01:40:36 -0300184static struct s5h1409_config hauppauge_ezqam_config = {
185 .demod_address = 0x32 >> 1,
186 .output_mode = S5H1409_SERIAL_OUTPUT,
187 .gpio = S5H1409_GPIO_OFF,
188 .qam_if = 4000,
189 .inversion = S5H1409_INVERSION_ON,
Steven Tothdfc1c082008-01-15 21:35:22 -0300190 .status_mode = S5H1409_DEMODLOCKING,
191 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300192};
193
Steven Tothfc959be2007-09-08 19:08:17 -0300194static struct s5h1409_config hauppauge_hvr1800lp_config = {
195 .demod_address = 0x32 >> 1,
196 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothd19770e2007-03-11 20:44:05 -0300197 .gpio = S5H1409_GPIO_OFF,
Michael Krufky2b032382007-12-13 10:04:10 -0300198 .qam_if = 44000,
Steven Tothfe475162007-03-20 15:27:53 -0300199 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300200 .status_mode = S5H1409_DEMODLOCKING,
201 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd19770e2007-03-11 20:44:05 -0300202};
203
Michael Krufky07b4a832007-12-18 01:09:11 -0300204static struct s5h1409_config hauppauge_hvr1500_config = {
205 .demod_address = 0x32 >> 1,
206 .output_mode = S5H1409_SERIAL_OUTPUT,
207 .gpio = S5H1409_GPIO_OFF,
208 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300209 .status_mode = S5H1409_DEMODLOCKING,
210 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky07b4a832007-12-18 01:09:11 -0300211};
212
Steven Toth86184e02007-09-04 21:40:47 -0300213static struct mt2131_config hauppauge_generic_tunerconfig = {
Steven Totha77743b2007-08-22 21:01:20 -0300214 0x61
215};
216
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300217static struct lgdt330x_config fusionhdtv_5_express = {
218 .demod_address = 0x0e,
219 .demod_chip = LGDT3303,
220 .serial_mpeg = 0x40,
221};
222
Steven Tothd1987d52007-12-18 01:57:06 -0300223static struct s5h1409_config hauppauge_hvr1500q_config = {
224 .demod_address = 0x32 >> 1,
225 .output_mode = S5H1409_SERIAL_OUTPUT,
226 .gpio = S5H1409_GPIO_ON,
227 .qam_if = 44000,
228 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300229 .status_mode = S5H1409_DEMODLOCKING,
230 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd1987d52007-12-18 01:57:06 -0300231};
232
Michael Krufky335377b2008-05-07 01:43:10 -0300233static struct s5h1409_config dvico_s5h1409_config = {
234 .demod_address = 0x32 >> 1,
235 .output_mode = S5H1409_SERIAL_OUTPUT,
236 .gpio = S5H1409_GPIO_ON,
237 .qam_if = 44000,
238 .inversion = S5H1409_INVERSION_OFF,
239 .status_mode = S5H1409_DEMODLOCKING,
240 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
241};
242
Michael Krufky52b50452008-07-09 02:18:49 -0300243static struct s5h1411_config dvico_s5h1411_config = {
244 .output_mode = S5H1411_SERIAL_OUTPUT,
245 .gpio = S5H1411_GPIO_ON,
246 .qam_if = S5H1411_IF_44000,
247 .vsb_if = S5H1411_IF_44000,
248 .inversion = S5H1411_INVERSION_OFF,
249 .status_mode = S5H1411_DEMODLOCKING,
250 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
251};
252
Michael Krufky19bc5792009-05-08 16:05:29 -0300253static struct s5h1411_config hcw_s5h1411_config = {
254 .output_mode = S5H1411_SERIAL_OUTPUT,
255 .gpio = S5H1411_GPIO_OFF,
256 .vsb_if = S5H1411_IF_44000,
257 .qam_if = S5H1411_IF_4000,
258 .inversion = S5H1411_INVERSION_ON,
259 .status_mode = S5H1411_DEMODLOCKING,
260 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
261};
262
Steven Tothd1987d52007-12-18 01:57:06 -0300263static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
Steven Tothe12671c2007-12-20 01:14:43 -0300264 .i2c_address = 0x61,
265 .if_khz = 5380,
Steven Tothd1987d52007-12-18 01:57:06 -0300266};
267
Michael Krufky335377b2008-05-07 01:43:10 -0300268static struct xc5000_config dvico_xc5000_tunerconfig = {
269 .i2c_address = 0x64,
270 .if_khz = 5380,
Michael Krufky335377b2008-05-07 01:43:10 -0300271};
272
Michael Krufky4041f1a2007-12-24 04:52:08 -0300273static struct tda829x_config tda829x_no_probe = {
274 .probe_tuner = TDA829X_DONT_PROBE,
275};
276
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300277static struct tda18271_std_map hauppauge_tda18271_std_map = {
Michael Krufkyc0dc0c12008-04-22 14:46:22 -0300278 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
279 .if_lvl = 6, .rfagc_top = 0x37 },
280 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
281 .if_lvl = 6, .rfagc_top = 0x37 },
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300282};
283
Michael Krufkyb34cdc32009-05-21 12:49:28 -0300284static struct tda18271_std_map hauppauge_hvr1200_tda18271_std_map = {
285 .dvbt_6 = { .if_freq = 3300, .agc_mode = 3, .std = 4,
286 .if_lvl = 1, .rfagc_top = 0x37, },
287 .dvbt_7 = { .if_freq = 3800, .agc_mode = 3, .std = 5,
288 .if_lvl = 1, .rfagc_top = 0x37, },
289 .dvbt_8 = { .if_freq = 4300, .agc_mode = 3, .std = 6,
290 .if_lvl = 1, .rfagc_top = 0x37, },
291};
292
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300293static struct tda18271_config hauppauge_tda18271_config = {
294 .std_map = &hauppauge_tda18271_std_map,
295 .gate = TDA18271_GATE_ANALOG,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300296 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300297};
298
Steven Tothb3ea0162008-04-19 01:14:19 -0300299static struct tda18271_config hauppauge_hvr1200_tuner_config = {
Michael Krufkyb34cdc32009-05-21 12:49:28 -0300300 .std_map = &hauppauge_hvr1200_tda18271_std_map,
Steven Tothb3ea0162008-04-19 01:14:19 -0300301 .gate = TDA18271_GATE_ANALOG,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300302 .output_opt = TDA18271_OUTPUT_LT_OFF,
Steven Tothb3ea0162008-04-19 01:14:19 -0300303};
304
Michael Krufky6b926ec2009-05-12 17:32:17 -0300305static struct tda18271_config hauppauge_hvr1210_tuner_config = {
306 .gate = TDA18271_GATE_DIGITAL,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300307 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufky6b926ec2009-05-12 17:32:17 -0300308};
309
Michael Krufky247bc542009-05-12 18:53:47 -0300310static struct tda18271_std_map hauppauge_hvr127x_std_map = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300311 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
312 .if_lvl = 1, .rfagc_top = 0x58 },
313 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
314 .if_lvl = 1, .rfagc_top = 0x58 },
315};
316
Michael Krufky247bc542009-05-12 18:53:47 -0300317static struct tda18271_config hauppauge_hvr127x_config = {
318 .std_map = &hauppauge_hvr127x_std_map,
Michael Krufky04a68ba2009-09-06 14:11:09 -0300319 .output_opt = TDA18271_OUTPUT_LT_OFF,
Michael Krufkya5dbf452009-05-03 23:27:02 -0300320};
321
Michael Krufky247bc542009-05-12 18:53:47 -0300322static struct lgdt3305_config hauppauge_lgdt3305_config = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300323 .i2c_addr = 0x0e,
324 .mpeg_mode = LGDT3305_MPEG_SERIAL,
325 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
326 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
327 .deny_i2c_rptr = 1,
328 .spectral_inversion = 1,
329 .qam_if_khz = 4000,
330 .vsb_if_khz = 3250,
331};
332
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700333static struct dibx000_agc_config xc3028_agc_config = {
Steven Toth66762372008-04-22 15:38:26 -0300334 BAND_VHF | BAND_UHF, /* band_caps */
335
336 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
337 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
338 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
339 * P_agc_nb_est=2, P_agc_write=0
340 */
341 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
342 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
343
344 712, /* inv_gain */
345 21, /* time_stabiliz */
346
347 0, /* alpha_level */
348 118, /* thlock */
349
350 0, /* wbd_inv */
351 2867, /* wbd_ref */
352 0, /* wbd_sel */
353 2, /* wbd_alpha */
354
355 0, /* agc1_max */
356 0, /* agc1_min */
357 39718, /* agc2_max */
358 9930, /* agc2_min */
359 0, /* agc1_pt1 */
360 0, /* agc1_pt2 */
361 0, /* agc1_pt3 */
362 0, /* agc1_slope1 */
363 0, /* agc1_slope2 */
364 0, /* agc2_pt1 */
365 128, /* agc2_pt2 */
366 29, /* agc2_slope1 */
367 29, /* agc2_slope2 */
368
369 17, /* alpha_mant */
370 27, /* alpha_exp */
371 23, /* beta_mant */
372 51, /* beta_exp */
373
374 1, /* perform_agc_softsplit */
375};
376
377/* PLL Configuration for COFDM BW_MHz = 8.000000
378 * With external clock = 30.000000 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700379static struct dibx000_bandwidth_config xc3028_bw_config = {
Steven Toth66762372008-04-22 15:38:26 -0300380 60000, /* internal */
381 30000, /* sampling */
382 1, /* pll_cfg: prediv */
383 8, /* pll_cfg: ratio */
384 3, /* pll_cfg: range */
385 1, /* pll_cfg: reset */
386 0, /* pll_cfg: bypass */
387 0, /* misc: refdiv */
388 0, /* misc: bypclk_div */
389 1, /* misc: IO_CLK_en_core */
390 1, /* misc: ADClkSrc */
391 0, /* misc: modulo */
392 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
393 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
394 20452225, /* timf */
395 30000000 /* xtal_hz */
396};
397
398static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
399 .output_mpeg2_in_188_bytes = 1,
400 .hostbus_diversity = 1,
401 .tuner_is_baseband = 0,
402 .update_lna = NULL,
403
404 .agc_config_count = 1,
405 .agc = &xc3028_agc_config,
406 .bw = &xc3028_bw_config,
407
408 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
409 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
410 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
411
412 .pwm_freq_div = 0,
413 .agc_control = NULL,
414 .spur_protect = 0,
415
416 .output_mode = OUTMODE_MPEG2_SERIAL,
417};
418
Steven Tothaef2d182008-08-04 21:39:53 -0300419static struct zl10353_config dvico_fusionhdtv_xc3028 = {
420 .demod_address = 0x0f,
421 .if2 = 45600,
422 .no_tuner = 1,
Christopher Pascoed4dc6732009-04-27 11:27:04 -0300423 .disable_i2c_gate_ctrl = 1,
Steven Tothaef2d182008-08-04 21:39:53 -0300424};
425
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -0300426static struct stv0900_reg stv0900_ts_regs[] = {
427 { R0900_TSGENERAL, 0x00 },
428 { R0900_P1_TSSPEED, 0x40 },
429 { R0900_P2_TSSPEED, 0x40 },
430 { R0900_P1_TSCFGM, 0xc0 },
431 { R0900_P2_TSCFGM, 0xc0 },
432 { R0900_P1_TSCFGH, 0xe0 },
433 { R0900_P2_TSCFGH, 0xe0 },
434 { R0900_P1_TSCFGL, 0x20 },
435 { R0900_P2_TSCFGL, 0x20 },
436 { 0xffff, 0xff }, /* terminate */
437};
438
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300439static struct stv0900_config netup_stv0900_config = {
440 .demod_address = 0x68,
Igor M. Liplianin29372a82009-10-17 08:58:26 -0300441 .demod_mode = 1, /* dual */
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300442 .xtal = 8000000,
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300443 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
444 .diseqc_mode = 2,/* 2/3 PWM */
Igor M. Liplianinf867c3f2009-06-19 05:45:23 -0300445 .ts_config_regs = stv0900_ts_regs,
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300446 .tun1_maddress = 0,/* 0x60 */
447 .tun2_maddress = 3,/* 0x63 */
448 .tun1_adc = 1,/* 1 Vpp */
449 .tun2_adc = 1,/* 1 Vpp */
450};
451
452static struct stv6110_config netup_stv6110_tunerconfig_a = {
453 .i2c_address = 0x60,
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300454 .mclk = 16000000,
455 .clk_div = 1,
Abylay Ospan873688c2009-10-17 08:23:00 -0300456 .gain = 8, /* +16 dB - maximum gain */
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300457};
458
459static struct stv6110_config netup_stv6110_tunerconfig_b = {
460 .i2c_address = 0x63,
Abylay Ospan644c7ef02009-07-19 18:06:00 -0300461 .mclk = 16000000,
462 .clk_div = 1,
Abylay Ospan873688c2009-10-17 08:23:00 -0300463 .gain = 8, /* +16 dB - maximum gain */
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300464};
465
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300466static struct cx24116_config tbs_cx24116_config = {
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -0300467 .demod_address = 0x55,
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300468};
469
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -0300470static struct ds3000_config tevii_ds3000_config = {
471 .demod_address = 0x68,
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300472};
473
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300474static struct cx24116_config dvbworld_cx24116_config = {
475 .demod_address = 0x05,
476};
477
David Wong493b7122009-05-18 05:25:49 -0300478static struct lgs8gxx_config mygica_x8506_lgs8gl5_config = {
479 .prod = LGS8GXX_PROD_LGS8GL5,
480 .demod_address = 0x19,
481 .serial_ts = 0,
482 .ts_clk_pol = 1,
483 .ts_clk_gated = 1,
484 .if_clk_freq = 30400, /* 30.4 MHz */
485 .if_freq = 5380, /* 5.38 MHz */
486 .if_neg_center = 1,
487 .ext_adc = 0,
488 .adc_signed = 0,
489 .if_neg_edge = 0,
490};
491
492static struct xc5000_config mygica_x8506_xc5000_config = {
493 .i2c_address = 0x61,
494 .if_khz = 5380,
495};
496
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -0300497static struct stv090x_config prof_8000_stv090x_config = {
498 .device = STV0903,
499 .demod_mode = STV090x_SINGLE,
500 .clk_mode = STV090x_CLK_EXT,
501 .xtal = 27000000,
502 .address = 0x6A,
503 .ts1_mode = STV090x_TSMODE_PARALLEL_PUNCTURED,
504 .repeater_level = STV090x_RPTLEVEL_64,
505 .adc1_range = STV090x_ADC_2Vpp,
506 .diseqc_envelope_mode = false,
507
508 .tuner_get_frequency = stb6100_get_frequency,
509 .tuner_set_frequency = stb6100_set_frequency,
510 .tuner_set_bandwidth = stb6100_set_bandwidth,
511 .tuner_get_bandwidth = stb6100_get_bandwidth,
512};
513
514static struct stb6100_config prof_8000_stb6100_config = {
515 .tuner_address = 0x60,
516 .refclock = 27000000,
517};
518
519static int p8000_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
520{
521 struct cx23885_tsport *port = fe->dvb->priv;
522 struct cx23885_dev *dev = port->dev;
523
524 if (voltage == SEC_VOLTAGE_18)
525 cx_write(MC417_RWD, 0x00001e00);
526 else if (voltage == SEC_VOLTAGE_13)
527 cx_write(MC417_RWD, 0x00001a00);
528 else
529 cx_write(MC417_RWD, 0x00001800);
530 return 0;
531}
532
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300533static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300534{
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300535 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300536 struct cx23885_tsport *port = fe->dvb->priv;
537 struct cx23885_dev *dev = port->dev;
538
539 switch (dev->board) {
540 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Mauro Carvalho Chehaba7d44ba2011-12-26 20:48:54 -0300541 switch (p->modulation) {
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300542 case VSB_8:
543 cx23885_gpio_clear(dev, GPIO_5);
544 break;
545 case QAM_64:
546 case QAM_256:
547 default:
548 cx23885_gpio_set(dev, GPIO_5);
549 break;
550 }
551 break;
David T.L. Wong6f0d8c02009-10-21 13:15:30 -0300552 case CX23885_BOARD_MYGICA_X8506:
553 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
554 /* Select Digital TV */
555 cx23885_gpio_set(dev, GPIO_0);
556 break;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300557 }
Michael Krufky5bdd3962009-05-08 22:39:24 -0300558 return 0;
Michael Krufkyf35b9e82009-05-08 22:39:24 -0300559}
560
David Wong2365b2d2009-06-17 01:38:12 -0300561static struct lgs8gxx_config magicpro_prohdtve2_lgs8g75_config = {
562 .prod = LGS8GXX_PROD_LGS8G75,
563 .demod_address = 0x19,
564 .serial_ts = 0,
565 .ts_clk_pol = 1,
566 .ts_clk_gated = 1,
567 .if_clk_freq = 30400, /* 30.4 MHz */
568 .if_freq = 6500, /* 6.50 MHz */
569 .if_neg_center = 1,
570 .ext_adc = 0,
571 .adc_signed = 1,
572 .adc_vpp = 2, /* 1.6 Vpp */
573 .if_neg_edge = 1,
574};
575
576static struct xc5000_config magicpro_prohdtve2_xc5000_config = {
577 .i2c_address = 0x61,
578 .if_khz = 6500,
579};
580
David T. L. Wongea5697f2009-10-26 08:54:04 -0300581static struct atbm8830_config mygica_x8558pro_atbm8830_cfg1 = {
582 .prod = ATBM8830_PROD_8830,
583 .demod_address = 0x44,
584 .serial_ts = 0,
585 .ts_sampling_edge = 1,
586 .ts_clk_gated = 0,
587 .osc_clk_freq = 30400, /* in kHz */
588 .if_freq = 0, /* zero IF */
589 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300590 .agc_min = 0x2E,
591 .agc_max = 0xFF,
592 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300593};
594
595static struct max2165_config mygic_x8558pro_max2165_cfg1 = {
596 .i2c_address = 0x60,
597 .osc_clk = 20
598};
599
600static struct atbm8830_config mygica_x8558pro_atbm8830_cfg2 = {
601 .prod = ATBM8830_PROD_8830,
602 .demod_address = 0x44,
603 .serial_ts = 1,
604 .ts_sampling_edge = 1,
605 .ts_clk_gated = 0,
606 .osc_clk_freq = 30400, /* in kHz */
607 .if_freq = 0, /* zero IF */
608 .zif_swap_iq = 1,
David Wongc245c752009-11-28 08:36:31 -0300609 .agc_min = 0x2E,
610 .agc_max = 0xFF,
611 .agc_hold_loop = 0,
David T. L. Wongea5697f2009-10-26 08:54:04 -0300612};
613
614static struct max2165_config mygic_x8558pro_max2165_cfg2 = {
615 .i2c_address = 0x60,
616 .osc_clk = 20
617};
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300618static struct stv0367_config netup_stv0367_config[] = {
619 {
620 .demod_address = 0x1c,
621 .xtal = 27000000,
622 .if_khz = 4500,
623 .if_iq_mode = 0,
624 .ts_mode = 1,
625 .clk_pol = 0,
626 }, {
627 .demod_address = 0x1d,
628 .xtal = 27000000,
629 .if_khz = 4500,
630 .if_iq_mode = 0,
631 .ts_mode = 1,
632 .clk_pol = 0,
633 },
634};
635
636static struct xc5000_config netup_xc5000_config[] = {
637 {
638 .i2c_address = 0x61,
639 .if_khz = 4500,
640 }, {
641 .i2c_address = 0x64,
642 .if_khz = 4500,
643 },
644};
645
Stefan Ringel722c90e2012-01-07 09:20:48 -0300646static struct drxk_config terratec_drxk_config[] = {
647 {
648 .adr = 0x29,
649 .no_i2c_bridge = 1,
650 }, {
651 .adr = 0x2a,
652 .no_i2c_bridge = 1,
653 },
654};
655
656static struct mt2063_config terratec_mt2063_config[] = {
657 {
658 .tuner_address = 0x60,
659 }, {
660 .tuner_address = 0x67,
661 },
662};
663
Michael Krufky7c62f5a2012-12-15 23:34:09 -0300664static const struct tda10071_config hauppauge_tda10071_config = {
665 .i2c_address = 0x05,
666 .tuner_i2c_addr = 0x54,
667 .i2c_wr_max = 64,
668 .ts_mode = TDA10071_TS_SERIAL,
669 .spec_inv = 0,
670 .xtal = 40444000, /* 40.444 MHz */
671 .pll_multiplier = 20,
672};
673
674static const struct a8293_config hauppauge_a8293_config = {
675 .i2c_addr = 0x0b,
676};
677
Mauro Carvalho Chehabada73ee2012-10-27 11:29:23 -0300678static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300679{
680 struct cx23885_dev *dev = (struct cx23885_dev *)device;
681 unsigned long timeout = jiffies + msecs_to_jiffies(1);
Abylay Ospand1644602011-01-02 09:10:00 -0300682 uint32_t mem = 0;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300683
Abylay Ospand1644602011-01-02 09:10:00 -0300684 mem = cx_read(MC417_RWD);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300685 if (read)
686 cx_set(MC417_OEN, ALT_DATA);
687 else {
688 cx_clear(MC417_OEN, ALT_DATA);/* D0-D7 out */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300689 mem &= ~ALT_DATA;
690 mem |= (data & ALT_DATA);
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300691 }
692
693 if (flag)
Abylay Ospand1644602011-01-02 09:10:00 -0300694 mem |= ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300695 else
Abylay Ospand1644602011-01-02 09:10:00 -0300696 mem &= ~ALT_AD_RG;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300697
Abylay Ospand1644602011-01-02 09:10:00 -0300698 mem &= ~ALT_CS;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300699 if (read)
Abylay Ospand1644602011-01-02 09:10:00 -0300700 mem = (mem & ~ALT_RD) | ALT_WR;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300701 else
Abylay Ospand1644602011-01-02 09:10:00 -0300702 mem = (mem & ~ALT_WR) | ALT_RD;
703
704 cx_write(MC417_RWD, mem); /* start RW cycle */
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300705
706 for (;;) {
707 mem = cx_read(MC417_RWD);
708 if ((mem & ALT_RDY) == 0)
709 break;
710 if (time_after(jiffies, timeout))
711 break;
712 udelay(1);
713 }
714
715 cx_set(MC417_RWD, ALT_RD | ALT_WR | ALT_CS);
716 if (read)
717 return mem & ALT_DATA;
718
719 return 0;
720};
David T. L. Wongea5697f2009-10-26 08:54:04 -0300721
Steven Tothd19770e2007-03-11 20:44:05 -0300722static int dvb_register(struct cx23885_tsport *port)
723{
724 struct cx23885_dev *dev = port->dev;
David Wong493b7122009-05-18 05:25:49 -0300725 struct cx23885_i2c *i2c_bus = NULL, *i2c_bus2 = NULL;
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300726 struct videobuf_dvb_frontend *fe0, *fe1 = NULL;
727 int mfe_shared = 0; /* bus not shared by default */
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -0300728 int ret;
Steven Toth363c35f2008-10-11 11:05:50 -0300729
Darron Broadf972e0bd2008-10-11 11:24:30 -0300730 /* Get the first frontend */
Darron Broad92abe9e2008-10-11 11:18:53 -0300731 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300732 if (!fe0)
733 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -0300734
735 /* init struct videobuf_dvb */
Steven Toth363c35f2008-10-11 11:05:50 -0300736 fe0->dvb.name = dev->name;
Steven Tothd19770e2007-03-11 20:44:05 -0300737
Igor M. Liplianin78db8542011-01-25 17:04:00 -0300738 /* multi-frontend gate control is undefined or defaults to fe0 */
739 port->frontends.gate = 0;
740
741 /* Sets the gate control callback to be used by i2c command calls */
742 port->gate_ctrl = cx23885_dvb_gate_ctrl;
743
Steven Tothd19770e2007-03-11 20:44:05 -0300744 /* init frontend */
745 switch (dev->board) {
Steven Totha77743b2007-08-22 21:01:20 -0300746 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300747 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300748 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth86184e02007-09-04 21:40:47 -0300749 &hauppauge_generic_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300750 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300751 if (fe0->dvb.frontend != NULL) {
752 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300753 &i2c_bus->i2c_adap,
Steven Toth86184e02007-09-04 21:40:47 -0300754 &hauppauge_generic_tunerconfig, 0);
Steven Tothd19770e2007-03-11 20:44:05 -0300755 }
756 break;
Michael Krufkya5dbf452009-05-03 23:27:02 -0300757 case CX23885_BOARD_HAUPPAUGE_HVR1270:
Michael Krufkyd099bec2009-05-08 22:39:24 -0300758 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Michael Krufkya5dbf452009-05-03 23:27:02 -0300759 i2c_bus = &dev->i2c_bus[0];
760 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
Michael Krufky247bc542009-05-12 18:53:47 -0300761 &hauppauge_lgdt3305_config,
Michael Krufkya5dbf452009-05-03 23:27:02 -0300762 &i2c_bus->i2c_adap);
763 if (fe0->dvb.frontend != NULL) {
764 dvb_attach(tda18271_attach, fe0->dvb.frontend,
765 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufky247bc542009-05-12 18:53:47 -0300766 &hauppauge_hvr127x_config);
Michael Krufkya5dbf452009-05-03 23:27:02 -0300767 }
768 break;
Michael Krufky19bc5792009-05-08 16:05:29 -0300769 case CX23885_BOARD_HAUPPAUGE_HVR1255:
Devin Heitmueller0ac60ac2012-07-01 16:15:14 -0300770 case CX23885_BOARD_HAUPPAUGE_HVR1255_22111:
Michael Krufky19bc5792009-05-08 16:05:29 -0300771 i2c_bus = &dev->i2c_bus[0];
772 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
773 &hcw_s5h1411_config,
774 &i2c_bus->i2c_adap);
775 if (fe0->dvb.frontend != NULL) {
776 dvb_attach(tda18271_attach, fe0->dvb.frontend,
777 0x60, &dev->i2c_bus[1].i2c_adap,
778 &hauppauge_tda18271_config);
779 }
Devin Heitmueller0ac60ac2012-07-01 16:15:14 -0300780
781 tda18271_attach(&dev->ts1.analog_fe,
782 0x60, &dev->i2c_bus[1].i2c_adap,
783 &hauppauge_tda18271_config);
784
Michael Krufky19bc5792009-05-08 16:05:29 -0300785 break;
Michael Krufky3ba71d22007-12-07 01:40:36 -0300786 case CX23885_BOARD_HAUPPAUGE_HVR1800:
787 i2c_bus = &dev->i2c_bus[0];
Darron Broad92abe9e2008-10-11 11:18:53 -0300788 switch (alt_tuner) {
Michael Krufky3ba71d22007-12-07 01:40:36 -0300789 case 1:
Steven Toth363c35f2008-10-11 11:05:50 -0300790 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300791 dvb_attach(s5h1409_attach,
792 &hauppauge_ezqam_config,
793 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300794 if (fe0->dvb.frontend != NULL) {
795 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300796 &dev->i2c_bus[1].i2c_adap, 0x42,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300797 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300798 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300799 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300800 &hauppauge_tda18271_config);
Michael Krufky3ba71d22007-12-07 01:40:36 -0300801 }
802 break;
803 case 0:
804 default:
Steven Toth363c35f2008-10-11 11:05:50 -0300805 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300806 dvb_attach(s5h1409_attach,
807 &hauppauge_generic_config,
808 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300809 if (fe0->dvb.frontend != NULL)
810 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300811 &i2c_bus->i2c_adap,
812 &hauppauge_generic_tunerconfig, 0);
813 break;
814 }
815 break;
Steven Tothfc959be2007-09-08 19:08:17 -0300816 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300817 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300818 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothfc959be2007-09-08 19:08:17 -0300819 &hauppauge_hvr1800lp_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300820 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300821 if (fe0->dvb.frontend != NULL) {
822 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300823 &i2c_bus->i2c_adap,
Steven Tothfc959be2007-09-08 19:08:17 -0300824 &hauppauge_generic_tunerconfig, 0);
825 }
826 break;
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300827 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300828 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300829 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300830 &fusionhdtv_5_express,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300831 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300832 if (fe0->dvb.frontend != NULL) {
833 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky827855d2008-04-22 14:46:16 -0300834 &i2c_bus->i2c_adap, 0x61,
835 TUNER_LG_TDVS_H06XF);
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300836 }
837 break;
Steven Tothd1987d52007-12-18 01:57:06 -0300838 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
839 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300840 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothd1987d52007-12-18 01:57:06 -0300841 &hauppauge_hvr1500q_config,
842 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300843 if (fe0->dvb.frontend != NULL)
844 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300845 &i2c_bus->i2c_adap,
846 &hauppauge_hvr1500q_tunerconfig);
Steven Tothd1987d52007-12-18 01:57:06 -0300847 break;
Michael Krufky07b4a832007-12-18 01:09:11 -0300848 case CX23885_BOARD_HAUPPAUGE_HVR1500:
849 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300850 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky07b4a832007-12-18 01:09:11 -0300851 &hauppauge_hvr1500_config,
852 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300853 if (fe0->dvb.frontend != NULL) {
Michael Krufky07b4a832007-12-18 01:09:11 -0300854 struct dvb_frontend *fe;
855 struct xc2028_config cfg = {
856 .i2c_adap = &i2c_bus->i2c_adap,
857 .i2c_addr = 0x61,
Michael Krufky07b4a832007-12-18 01:09:11 -0300858 };
859 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300860 .fname = XC2028_DEFAULT_FIRMWARE,
Michael Krufky07b4a832007-12-18 01:09:11 -0300861 .max_len = 64,
Steven Toth52c3d292009-04-20 22:42:00 -0300862 .demod = XC3028_FE_OREN538,
Michael Krufky07b4a832007-12-18 01:09:11 -0300863 };
864
865 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300866 fe0->dvb.frontend, &cfg);
Michael Krufky07b4a832007-12-18 01:09:11 -0300867 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
868 fe->ops.tuner_ops.set_config(fe, &ctl);
869 }
870 break;
Steven Tothb3ea0162008-04-19 01:14:19 -0300871 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Totha780a312008-04-19 01:25:52 -0300872 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Tothb3ea0162008-04-19 01:14:19 -0300873 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300874 fe0->dvb.frontend = dvb_attach(tda10048_attach,
Steven Tothb3ea0162008-04-19 01:14:19 -0300875 &hauppauge_hvr1200_config,
876 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300877 if (fe0->dvb.frontend != NULL) {
878 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300879 &dev->i2c_bus[1].i2c_adap, 0x42,
880 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300881 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300882 0x60, &dev->i2c_bus[1].i2c_adap,
883 &hauppauge_hvr1200_tuner_config);
884 }
885 break;
Michael Krufky6b926ec2009-05-12 17:32:17 -0300886 case CX23885_BOARD_HAUPPAUGE_HVR1210:
887 i2c_bus = &dev->i2c_bus[0];
888 fe0->dvb.frontend = dvb_attach(tda10048_attach,
889 &hauppauge_hvr1210_config,
890 &i2c_bus->i2c_adap);
891 if (fe0->dvb.frontend != NULL) {
892 dvb_attach(tda18271_attach, fe0->dvb.frontend,
893 0x60, &dev->i2c_bus[1].i2c_adap,
894 &hauppauge_hvr1210_tuner_config);
895 }
896 break;
Steven Toth66762372008-04-22 15:38:26 -0300897 case CX23885_BOARD_HAUPPAUGE_HVR1400:
898 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300899 fe0->dvb.frontend = dvb_attach(dib7000p_attach,
Steven Toth66762372008-04-22 15:38:26 -0300900 &i2c_bus->i2c_adap,
901 0x12, &hauppauge_hvr1400_dib7000_config);
Steven Toth363c35f2008-10-11 11:05:50 -0300902 if (fe0->dvb.frontend != NULL) {
Steven Toth66762372008-04-22 15:38:26 -0300903 struct dvb_frontend *fe;
904 struct xc2028_config cfg = {
905 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
906 .i2c_addr = 0x64,
Steven Toth66762372008-04-22 15:38:26 -0300907 };
908 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300909 .fname = XC3028L_DEFAULT_FIRMWARE,
Steven Toth66762372008-04-22 15:38:26 -0300910 .max_len = 64,
Mauro Carvalho Chehab9bed77e2011-07-28 16:38:54 -0300911 .demod = XC3028_FE_DIBCOM52,
Steven Toth9c8ced52008-10-16 20:18:44 -0300912 /* This is true for all demods with
913 v36 firmware? */
Mauro Carvalho Chehab0975fc62008-09-28 02:24:44 -0300914 .type = XC2028_D2633,
Steven Toth66762372008-04-22 15:38:26 -0300915 };
916
917 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300918 fe0->dvb.frontend, &cfg);
Steven Toth66762372008-04-22 15:38:26 -0300919 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
920 fe->ops.tuner_ops.set_config(fe, &ctl);
921 }
922 break;
Michael Krufky335377b2008-05-07 01:43:10 -0300923 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
924 i2c_bus = &dev->i2c_bus[port->nr - 1];
925
Steven Toth363c35f2008-10-11 11:05:50 -0300926 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky335377b2008-05-07 01:43:10 -0300927 &dvico_s5h1409_config,
928 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300929 if (fe0->dvb.frontend == NULL)
930 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Michael Krufky52b50452008-07-09 02:18:49 -0300931 &dvico_s5h1411_config,
932 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300933 if (fe0->dvb.frontend != NULL)
934 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300935 &i2c_bus->i2c_adap,
936 &dvico_xc5000_tunerconfig);
Michael Krufky335377b2008-05-07 01:43:10 -0300937 break;
Steven Tothaef2d182008-08-04 21:39:53 -0300938 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
939 i2c_bus = &dev->i2c_bus[port->nr - 1];
940
Steven Toth363c35f2008-10-11 11:05:50 -0300941 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Tothaef2d182008-08-04 21:39:53 -0300942 &dvico_fusionhdtv_xc3028,
943 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300944 if (fe0->dvb.frontend != NULL) {
Steven Tothaef2d182008-08-04 21:39:53 -0300945 struct dvb_frontend *fe;
946 struct xc2028_config cfg = {
947 .i2c_adap = &i2c_bus->i2c_adap,
948 .i2c_addr = 0x61,
Steven Tothaef2d182008-08-04 21:39:53 -0300949 };
950 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300951 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Tothaef2d182008-08-04 21:39:53 -0300952 .max_len = 64,
953 .demod = XC3028_FE_ZARLINK456,
954 };
955
Steven Toth363c35f2008-10-11 11:05:50 -0300956 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Tothaef2d182008-08-04 21:39:53 -0300957 &cfg);
958 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
959 fe->ops.tuner_ops.set_config(fe, &ctl);
960 }
961 break;
962 }
Steven Toth4c56b042008-08-12 13:30:03 -0300963 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -0300964 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Vladimir Geroy34e383d2009-09-18 18:55:47 -0300965 case CX23885_BOARD_COMPRO_VIDEOMATE_E800:
Steven Toth4c56b042008-08-12 13:30:03 -0300966 i2c_bus = &dev->i2c_bus[0];
967
Steven Toth363c35f2008-10-11 11:05:50 -0300968 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Toth4c56b042008-08-12 13:30:03 -0300969 &dvico_fusionhdtv_xc3028,
970 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300971 if (fe0->dvb.frontend != NULL) {
Steven Toth4c56b042008-08-12 13:30:03 -0300972 struct dvb_frontend *fe;
973 struct xc2028_config cfg = {
974 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
975 .i2c_addr = 0x61,
Steven Toth4c56b042008-08-12 13:30:03 -0300976 };
977 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300978 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth4c56b042008-08-12 13:30:03 -0300979 .max_len = 64,
980 .demod = XC3028_FE_ZARLINK456,
981 };
982
Steven Toth363c35f2008-10-11 11:05:50 -0300983 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Toth4c56b042008-08-12 13:30:03 -0300984 &cfg);
985 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
986 fe->ops.tuner_ops.set_config(fe, &ctl);
987 }
988 break;
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -0300989 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H_XC4000:
990 i2c_bus = &dev->i2c_bus[0];
991
992 fe0->dvb.frontend = dvb_attach(zl10353_attach,
993 &dvico_fusionhdtv_xc3028,
994 &i2c_bus->i2c_adap);
995 if (fe0->dvb.frontend != NULL) {
996 struct dvb_frontend *fe;
997 struct xc4000_config cfg = {
998 .i2c_address = 0x61,
999 .default_pm = 0,
1000 .dvb_amplitude = 134,
1001 .set_smoothedcvbs = 1,
1002 .if_khz = 4560
1003 };
1004
1005 fe = dvb_attach(xc4000_attach, fe0->dvb.frontend,
1006 &dev->i2c_bus[1].i2c_adap, &cfg);
Miroslav Slugena7c8aad2011-12-11 18:57:58 -03001007 if (!fe) {
1008 printk(KERN_ERR "%s/2: xc4000 attach failed\n",
1009 dev->name);
1010 goto frontend_detach;
1011 }
istvan_v@mailbox.hu0cf8af52011-07-11 10:58:35 -03001012 }
1013 break;
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001014 case CX23885_BOARD_TBS_6920:
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001015 i2c_bus = &dev->i2c_bus[1];
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001016
1017 fe0->dvb.frontend = dvb_attach(cx24116_attach,
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001018 &tbs_cx24116_config,
1019 &i2c_bus->i2c_adap);
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001020 if (fe0->dvb.frontend != NULL)
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001021 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
Igor M. Liplianin96318d02009-01-17 12:11:20 -03001022
1023 break;
Igor M. Liplianin579943f2009-01-17 12:18:26 -03001024 case CX23885_BOARD_TEVII_S470:
1025 i2c_bus = &dev->i2c_bus[1];
1026
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001027 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1028 &tevii_ds3000_config,
1029 &i2c_bus->i2c_adap);
Igor M. Liplianin579943f2009-01-17 12:18:26 -03001030 if (fe0->dvb.frontend != NULL)
Igor M. Liplianin09ea33e2009-11-24 20:16:04 -03001031 fe0->dvb.frontend->ops.set_voltage = f300_set_voltage;
Igor M. Liplianin579943f2009-01-17 12:18:26 -03001032
1033 break;
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -03001034 case CX23885_BOARD_DVBWORLD_2005:
1035 i2c_bus = &dev->i2c_bus[1];
1036
1037 fe0->dvb.frontend = dvb_attach(cx24116_attach,
1038 &dvbworld_cx24116_config,
1039 &i2c_bus->i2c_adap);
1040 break;
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03001041 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1042 i2c_bus = &dev->i2c_bus[0];
1043 switch (port->nr) {
1044 /* port B */
1045 case 1:
1046 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1047 &netup_stv0900_config,
1048 &i2c_bus->i2c_adap, 0);
1049 if (fe0->dvb.frontend != NULL) {
1050 if (dvb_attach(stv6110_attach,
1051 fe0->dvb.frontend,
1052 &netup_stv6110_tunerconfig_a,
1053 &i2c_bus->i2c_adap)) {
1054 if (!dvb_attach(lnbh24_attach,
1055 fe0->dvb.frontend,
1056 &i2c_bus->i2c_adap,
Abylay Ospan9329fb52009-10-17 08:38:45 -03001057 LNBH24_PCL | LNBH24_TTX,
1058 LNBH24_TEN, 0x09))
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03001059 printk(KERN_ERR
1060 "No LNBH24 found!\n");
1061
1062 }
1063 }
1064 break;
1065 /* port C */
1066 case 2:
1067 fe0->dvb.frontend = dvb_attach(stv0900_attach,
1068 &netup_stv0900_config,
1069 &i2c_bus->i2c_adap, 1);
1070 if (fe0->dvb.frontend != NULL) {
1071 if (dvb_attach(stv6110_attach,
1072 fe0->dvb.frontend,
1073 &netup_stv6110_tunerconfig_b,
1074 &i2c_bus->i2c_adap)) {
1075 if (!dvb_attach(lnbh24_attach,
1076 fe0->dvb.frontend,
1077 &i2c_bus->i2c_adap,
Abylay Ospan9329fb52009-10-17 08:38:45 -03001078 LNBH24_PCL | LNBH24_TTX,
1079 LNBH24_TEN, 0x0a))
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03001080 printk(KERN_ERR
1081 "No LNBH24 found!\n");
1082
1083 }
1084 }
1085 break;
1086 }
1087 break;
David Wong493b7122009-05-18 05:25:49 -03001088 case CX23885_BOARD_MYGICA_X8506:
1089 i2c_bus = &dev->i2c_bus[0];
1090 i2c_bus2 = &dev->i2c_bus[1];
1091 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1092 &mygica_x8506_lgs8gl5_config,
1093 &i2c_bus->i2c_adap);
1094 if (fe0->dvb.frontend != NULL) {
1095 dvb_attach(xc5000_attach,
1096 fe0->dvb.frontend,
1097 &i2c_bus2->i2c_adap,
1098 &mygica_x8506_xc5000_config);
1099 }
1100 break;
David Wong2365b2d2009-06-17 01:38:12 -03001101 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
1102 i2c_bus = &dev->i2c_bus[0];
1103 i2c_bus2 = &dev->i2c_bus[1];
1104 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1105 &magicpro_prohdtve2_lgs8g75_config,
1106 &i2c_bus->i2c_adap);
1107 if (fe0->dvb.frontend != NULL) {
1108 dvb_attach(xc5000_attach,
1109 fe0->dvb.frontend,
1110 &i2c_bus2->i2c_adap,
1111 &magicpro_prohdtve2_xc5000_config);
1112 }
1113 break;
Steven Toth136973802009-07-20 15:37:25 -03001114 case CX23885_BOARD_HAUPPAUGE_HVR1850:
Steven Toth35045132012-01-04 21:08:35 -03001115 i2c_bus = &dev->i2c_bus[0];
1116 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1117 &hcw_s5h1411_config,
1118 &i2c_bus->i2c_adap);
1119 if (fe0->dvb.frontend != NULL)
1120 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1121 0x60, &dev->i2c_bus[0].i2c_adap,
1122 &hauppauge_tda18271_config);
1123
1124 tda18271_attach(&dev->ts1.analog_fe,
1125 0x60, &dev->i2c_bus[1].i2c_adap,
1126 &hauppauge_tda18271_config);
1127
1128 break;
Michael Krufkyaee0b242009-11-11 01:52:45 -03001129 case CX23885_BOARD_HAUPPAUGE_HVR1290:
Steven Toth136973802009-07-20 15:37:25 -03001130 i2c_bus = &dev->i2c_bus[0];
1131 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1132 &hcw_s5h1411_config,
1133 &i2c_bus->i2c_adap);
1134 if (fe0->dvb.frontend != NULL)
1135 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1136 0x60, &dev->i2c_bus[0].i2c_adap,
1137 &hauppauge_tda18271_config);
1138 break;
David T. L. Wongea5697f2009-10-26 08:54:04 -03001139 case CX23885_BOARD_MYGICA_X8558PRO:
1140 switch (port->nr) {
1141 /* port B */
1142 case 1:
1143 i2c_bus = &dev->i2c_bus[0];
1144 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1145 &mygica_x8558pro_atbm8830_cfg1,
1146 &i2c_bus->i2c_adap);
1147 if (fe0->dvb.frontend != NULL) {
1148 dvb_attach(max2165_attach,
1149 fe0->dvb.frontend,
1150 &i2c_bus->i2c_adap,
1151 &mygic_x8558pro_max2165_cfg1);
1152 }
1153 break;
1154 /* port C */
1155 case 2:
1156 i2c_bus = &dev->i2c_bus[1];
1157 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1158 &mygica_x8558pro_atbm8830_cfg2,
1159 &i2c_bus->i2c_adap);
1160 if (fe0->dvb.frontend != NULL) {
1161 dvb_attach(max2165_attach,
1162 fe0->dvb.frontend,
1163 &i2c_bus->i2c_adap,
1164 &mygic_x8558pro_max2165_cfg2);
1165 }
1166 break;
1167 }
1168 break;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001169 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1170 i2c_bus = &dev->i2c_bus[0];
1171 mfe_shared = 1;/* MFE */
1172 port->frontends.gate = 0;/* not clear for me yet */
1173 /* ports B, C */
1174 /* MFE frontend 1 DVB-T */
1175 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1176 &netup_stv0367_config[port->nr - 1],
1177 &i2c_bus->i2c_adap);
Abylay Ospan4174ebf52011-01-02 09:15:00 -03001178 if (fe0->dvb.frontend != NULL) {
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001179 if (NULL == dvb_attach(xc5000_attach,
1180 fe0->dvb.frontend,
1181 &i2c_bus->i2c_adap,
1182 &netup_xc5000_config[port->nr - 1]))
1183 goto frontend_detach;
Abylay Ospan4174ebf52011-01-02 09:15:00 -03001184 /* load xc5000 firmware */
1185 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1186 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001187 /* MFE frontend 2 */
1188 fe1 = videobuf_dvb_get_frontend(&port->frontends, 2);
1189 if (fe1 == NULL)
1190 goto frontend_detach;
1191 /* DVB-C init */
1192 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1193 &netup_stv0367_config[port->nr - 1],
1194 &i2c_bus->i2c_adap);
1195 if (fe1->dvb.frontend != NULL) {
1196 fe1->dvb.frontend->id = 1;
1197 if (NULL == dvb_attach(xc5000_attach,
1198 fe1->dvb.frontend,
1199 &i2c_bus->i2c_adap,
1200 &netup_xc5000_config[port->nr - 1]))
1201 goto frontend_detach;
1202 }
1203 break;
Stefan Ringel722c90e2012-01-07 09:20:48 -03001204 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1205 i2c_bus = &dev->i2c_bus[0];
1206 i2c_bus2 = &dev->i2c_bus[1];
1207
1208 switch (port->nr) {
1209 /* port b */
1210 case 1:
1211 fe0->dvb.frontend = dvb_attach(drxk_attach,
1212 &terratec_drxk_config[0],
1213 &i2c_bus->i2c_adap);
1214 if (fe0->dvb.frontend != NULL) {
1215 if (!dvb_attach(mt2063_attach,
1216 fe0->dvb.frontend,
1217 &terratec_mt2063_config[0],
1218 &i2c_bus2->i2c_adap))
1219 goto frontend_detach;
1220 }
1221 break;
1222 /* port c */
1223 case 2:
1224 fe0->dvb.frontend = dvb_attach(drxk_attach,
1225 &terratec_drxk_config[1],
1226 &i2c_bus->i2c_adap);
1227 if (fe0->dvb.frontend != NULL) {
1228 if (!dvb_attach(mt2063_attach,
1229 fe0->dvb.frontend,
1230 &terratec_mt2063_config[1],
1231 &i2c_bus2->i2c_adap))
1232 goto frontend_detach;
1233 }
1234 break;
1235 }
1236 break;
Igor M. Liplianin7b134e82012-05-11 11:45:42 -03001237 case CX23885_BOARD_TEVII_S471:
1238 i2c_bus = &dev->i2c_bus[1];
1239
1240 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1241 &tevii_ds3000_config,
1242 &i2c_bus->i2c_adap);
1243 break;
Mariusz Bia?o?czykf6671902012-09-12 07:59:18 -03001244 case CX23885_BOARD_PROF_8000:
1245 i2c_bus = &dev->i2c_bus[0];
1246
1247 fe0->dvb.frontend = dvb_attach(stv090x_attach,
1248 &prof_8000_stv090x_config,
1249 &i2c_bus->i2c_adap,
1250 STV090x_DEMODULATOR_0);
1251 if (fe0->dvb.frontend != NULL) {
1252 if (!dvb_attach(stb6100_attach,
1253 fe0->dvb.frontend,
1254 &prof_8000_stb6100_config,
1255 &i2c_bus->i2c_adap))
1256 goto frontend_detach;
1257
1258 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1259 }
1260 break;
Michael Krufky7c62f5a2012-12-15 23:34:09 -03001261 case CX23885_BOARD_HAUPPAUGE_HVR4400:
1262 i2c_bus = &dev->i2c_bus[0];
1263 fe0->dvb.frontend = dvb_attach(tda10071_attach,
1264 &hauppauge_tda10071_config,
1265 &i2c_bus->i2c_adap);
1266 if (fe0->dvb.frontend != NULL) {
1267 dvb_attach(a8293_attach, fe0->dvb.frontend,
1268 &i2c_bus->i2c_adap,
1269 &hauppauge_a8293_config);
1270 }
1271 break;
Steven Tothd19770e2007-03-11 20:44:05 -03001272 default:
Steven Toth9c8ced52008-10-16 20:18:44 -03001273 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
1274 " isn't supported yet\n",
Steven Tothd19770e2007-03-11 20:44:05 -03001275 dev->name);
1276 break;
1277 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001278
1279 if ((NULL == fe0->dvb.frontend) || (fe1 && NULL == fe1->dvb.frontend)) {
Steven Toth9c8ced52008-10-16 20:18:44 -03001280 printk(KERN_ERR "%s: frontend initialization failed\n",
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001281 dev->name);
1282 goto frontend_detach;
Steven Tothd19770e2007-03-11 20:44:05 -03001283 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001284
Michael Krufkyd7cba042008-09-12 13:31:45 -03001285 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -03001286 fe0->dvb.frontend->callback = cx23885_tuner_callback;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001287 if (fe1)
1288 fe1->dvb.frontend->callback = cx23885_tuner_callback;
1289#if 0
1290 /* Ensure all frontends negotiate bus access */
1291 fe0->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
1292 if (fe1)
1293 fe1->dvb.frontend->ops.ts_bus_ctrl = cx23885_dvb_bus_ctrl;
1294#endif
Steven Tothd19770e2007-03-11 20:44:05 -03001295
1296 /* Put the analog decoder in standby to keep it quiet */
Laurent Pinchart622b8282009-10-05 10:48:17 -03001297 call_all(dev, core, s_power, 0);
Steven Tothd19770e2007-03-11 20:44:05 -03001298
Steven Toth363c35f2008-10-11 11:05:50 -03001299 if (fe0->dvb.frontend->ops.analog_ops.standby)
1300 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
Michael Krufky3ba71d22007-12-07 01:40:36 -03001301
Steven Tothd19770e2007-03-11 20:44:05 -03001302 /* register everything */
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03001303 ret = videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port,
Mauro Carvalho Chehab9adf6132012-08-05 14:16:30 -03001304 &dev->pci->dev, adapter_nr, mfe_shared);
Abylay Ospanbee30192010-06-25 08:01:28 -03001305 if (ret)
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001306 goto frontend_detach;
Steven Toth363c35f2008-10-11 11:05:50 -03001307
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03001308 /* init CI & MAC */
1309 switch (dev->board) {
1310 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
1311 static struct netup_card_info cinfo;
1312
1313 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
1314 memcpy(port->frontends.adapter.proposed_mac,
1315 cinfo.port[port->nr - 1].mac, 6);
hartleysbe395152009-12-30 16:08:57 -03001316 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC=%pM\n",
1317 port->nr, port->frontends.adapter.proposed_mac);
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03001318
1319 netup_ci_init(port);
1320 break;
1321 }
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001322 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: {
1323 struct altera_ci_config netup_ci_cfg = {
1324 .dev = dev,/* magic number to identify*/
1325 .adapter = &port->frontends.adapter,/* for CI */
1326 .demux = &fe0->dvb.demux,/* for hw pid filter */
1327 .fpga_rw = netup_altera_fpga_rw,
1328 };
1329
1330 altera_ci_init(&netup_ci_cfg, port->nr);
1331 break;
1332 }
Pierre Gronlier16bfdaa42010-04-26 13:26:29 -03001333 case CX23885_BOARD_TEVII_S470: {
1334 u8 eeprom[256]; /* 24C02 i2c eeprom */
1335
1336 if (port->nr != 1)
1337 break;
1338
1339 /* Read entire EEPROM */
1340 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1341 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, sizeof(eeprom));
Andy Shevchenko5cac1f662010-09-11 14:33:28 -03001342 printk(KERN_INFO "TeVii S470 MAC= %pM\n", eeprom + 0xa0);
Pierre Gronlier16bfdaa42010-04-26 13:26:29 -03001343 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1344 break;
1345 }
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03001346 }
1347
1348 return ret;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001349
1350frontend_detach:
1351 port->gate_ctrl = NULL;
1352 videobuf_dvb_dealloc_frontends(&port->frontends);
1353 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03001354}
1355
1356int cx23885_dvb_register(struct cx23885_tsport *port)
1357{
Steven Toth363c35f2008-10-11 11:05:50 -03001358
1359 struct videobuf_dvb_frontend *fe0;
Steven Tothd19770e2007-03-11 20:44:05 -03001360 struct cx23885_dev *dev = port->dev;
Steven Totheb0c58b2008-10-11 12:34:39 -03001361 int err, i;
Steven Tothd19770e2007-03-11 20:44:05 -03001362
Steven Totheb0c58b2008-10-11 12:34:39 -03001363 /* Here we need to allocate the correct number of frontends,
André Goddard Rosaaf901ca2009-11-14 13:09:05 -02001364 * as reflected in the cards struct. The reality is that currently
Steven Totheb0c58b2008-10-11 12:34:39 -03001365 * no cx23885 boards support this - yet. But, if we don't modify this
1366 * code then the second frontend would never be allocated (later)
1367 * and fail with error before the attach in dvb_register().
1368 * Without these changes we risk an OOPS later. The changes here
1369 * are for safety, and should provide a good foundation for the
1370 * future addition of any multi-frontend cx23885 based boards.
1371 */
1372 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
1373 port->num_frontends);
Steven Toth363c35f2008-10-11 11:05:50 -03001374
Steven Totheb0c58b2008-10-11 12:34:39 -03001375 for (i = 1; i <= port->num_frontends; i++) {
Darron Broad96b7a1a2008-10-15 20:26:34 -03001376 if (videobuf_dvb_alloc_frontend(
Steven Toth9c8ced52008-10-16 20:18:44 -03001377 &port->frontends, i) == NULL) {
Steven Totheb0c58b2008-10-11 12:34:39 -03001378 printk(KERN_ERR "%s() failed to alloc\n", __func__);
1379 return -ENOMEM;
1380 }
Steven Tothd19770e2007-03-11 20:44:05 -03001381
Steven Totheb0c58b2008-10-11 12:34:39 -03001382 fe0 = videobuf_dvb_get_frontend(&port->frontends, i);
1383 if (!fe0)
1384 err = -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -03001385
Steven Totheb0c58b2008-10-11 12:34:39 -03001386 dprintk(1, "%s\n", __func__);
Steven Toth9c8ced52008-10-16 20:18:44 -03001387 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
Steven Totheb0c58b2008-10-11 12:34:39 -03001388 dev->board,
1389 dev->name,
1390 dev->pci_bus,
1391 dev->pci_slot);
1392
1393 err = -ENODEV;
1394
1395 /* dvb stuff */
1396 /* We have to init the queue for each frontend on a port. */
Steven Toth9c8ced52008-10-16 20:18:44 -03001397 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
1398 videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops,
1399 &dev->pci->dev, &port->slock,
Michael Krufky44a64812007-03-20 23:00:18 -03001400 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
Hans Verkuil08bff032010-09-20 17:39:46 -03001401 sizeof(struct cx23885_buffer), port, NULL);
Steven Totheb0c58b2008-10-11 12:34:39 -03001402 }
Steven Tothd19770e2007-03-11 20:44:05 -03001403 err = dvb_register(port);
1404 if (err != 0)
Steven Toth9c8ced52008-10-16 20:18:44 -03001405 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
1406 __func__, err);
Steven Tothd19770e2007-03-11 20:44:05 -03001407
Steven Tothd19770e2007-03-11 20:44:05 -03001408 return err;
1409}
1410
1411int cx23885_dvb_unregister(struct cx23885_tsport *port)
1412{
Steven Toth363c35f2008-10-11 11:05:50 -03001413 struct videobuf_dvb_frontend *fe0;
1414
Steven Totheb0c58b2008-10-11 12:34:39 -03001415 /* FIXME: in an error condition where the we have
1416 * an expected number of frontends (attach problem)
1417 * then this might not clean up correctly, if 1
1418 * is invalid.
1419 * This comment only applies to future boards IF they
1420 * implement MFE support.
1421 */
Darron Broad92abe9e2008-10-11 11:18:53 -03001422 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Abylay Ospane66131c2011-07-15 15:01:07 -03001423 if (fe0 && fe0->dvb.frontend)
Steven Toth363c35f2008-10-11 11:05:50 -03001424 videobuf_dvb_unregister_bus(&port->frontends);
Steven Tothd19770e2007-03-11 20:44:05 -03001425
Hans Verkuilafd96662009-03-13 13:24:19 -03001426 switch (port->dev->board) {
1427 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
1428 netup_ci_exit(port);
1429 break;
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001430 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
1431 altera_ci_release(port->dev, port->nr);
1432 break;
Hans Verkuilafd96662009-03-13 13:24:19 -03001433 }
Igor M. Liplianin5a23b0762009-03-03 12:06:09 -03001434
Igor M. Liplianin78db8542011-01-25 17:04:00 -03001435 port->gate_ctrl = NULL;
1436
Steven Tothd19770e2007-03-11 20:44:05 -03001437 return 0;
1438}
Michael Krufky44a64812007-03-20 23:00:18 -03001439