blob: 577e83829adf7b8f8e4f7b3295f2c2bdd5984e15 [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"
Steven Tothd1987d52007-12-18 01:57:06 -030040#include "xc5000.h"
Steven Tothb3ea0162008-04-19 01:14:19 -030041#include "tda10048.h"
Michael Krufky07b4a832007-12-18 01:09:11 -030042#include "tuner-xc2028.h"
Michael Krufky827855d2008-04-22 14:46:16 -030043#include "tuner-simple.h"
Steven Toth66762372008-04-22 15:38:26 -030044#include "dib7000p.h"
45#include "dibx000_common.h"
Steven Tothaef2d182008-08-04 21:39:53 -030046#include "zl10353.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030047#include "stv0900.h"
48#include "stv6110.h"
49#include "lnbh24.h"
Igor M. Liplianin96318d02009-01-17 12:11:20 -030050#include "cx24116.h"
Igor M. Liplianin5a23b072009-03-03 12:06:09 -030051#include "cimax2.h"
52#include "netup-eeprom.h"
53#include "netup-init.h"
Michael Krufkya5dbf452009-05-03 23:27:02 -030054#include "lgdt3305.h"
Steven Tothd19770e2007-03-11 20:44:05 -030055
Steven Toth4513fc692008-01-12 11:36:36 -030056static unsigned int debug;
Steven Tothd19770e2007-03-11 20:44:05 -030057
Steven Toth4513fc692008-01-12 11:36:36 -030058#define dprintk(level, fmt, arg...)\
59 do { if (debug >= level)\
60 printk(KERN_DEBUG "%s/0: " fmt, dev->name, ## arg);\
61 } while (0)
Steven Tothd19770e2007-03-11 20:44:05 -030062
63/* ------------------------------------------------------------------ */
64
Michael Krufky3ba71d22007-12-07 01:40:36 -030065static unsigned int alt_tuner;
66module_param(alt_tuner, int, 0644);
67MODULE_PARM_DESC(alt_tuner, "Enable alternate tuner configuration");
68
Janne Grunau78e92002008-04-09 19:13:13 -030069DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
70
Michael Krufky3ba71d22007-12-07 01:40:36 -030071/* ------------------------------------------------------------------ */
72
Steven Tothd19770e2007-03-11 20:44:05 -030073static int dvb_buf_setup(struct videobuf_queue *q,
74 unsigned int *count, unsigned int *size)
75{
76 struct cx23885_tsport *port = q->priv_data;
77
78 port->ts_packet_size = 188 * 4;
79 port->ts_packet_count = 32;
80
81 *size = port->ts_packet_size * port->ts_packet_count;
82 *count = 32;
83 return 0;
84}
85
Michael Krufky44a64812007-03-20 23:00:18 -030086static int dvb_buf_prepare(struct videobuf_queue *q,
87 struct videobuf_buffer *vb, enum v4l2_field field)
Steven Tothd19770e2007-03-11 20:44:05 -030088{
89 struct cx23885_tsport *port = q->priv_data;
Steven Toth9c8ced52008-10-16 20:18:44 -030090 return cx23885_buf_prepare(q, port, (struct cx23885_buffer *)vb, field);
Steven Tothd19770e2007-03-11 20:44:05 -030091}
92
93static void dvb_buf_queue(struct videobuf_queue *q, struct videobuf_buffer *vb)
94{
95 struct cx23885_tsport *port = q->priv_data;
Steven Toth9c8ced52008-10-16 20:18:44 -030096 cx23885_buf_queue(port, (struct cx23885_buffer *)vb);
Steven Tothd19770e2007-03-11 20:44:05 -030097}
98
Michael Krufky44a64812007-03-20 23:00:18 -030099static void dvb_buf_release(struct videobuf_queue *q,
100 struct videobuf_buffer *vb)
Steven Tothd19770e2007-03-11 20:44:05 -0300101{
Steven Toth9c8ced52008-10-16 20:18:44 -0300102 cx23885_free_buffer(q, (struct cx23885_buffer *)vb);
Steven Tothd19770e2007-03-11 20:44:05 -0300103}
104
105static struct videobuf_queue_ops dvb_qops = {
106 .buf_setup = dvb_buf_setup,
107 .buf_prepare = dvb_buf_prepare,
108 .buf_queue = dvb_buf_queue,
109 .buf_release = dvb_buf_release,
110};
111
Steven Toth86184e02007-09-04 21:40:47 -0300112static struct s5h1409_config hauppauge_generic_config = {
Steven Tothd19770e2007-03-11 20:44:05 -0300113 .demod_address = 0x32 >> 1,
114 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothfc959be2007-09-08 19:08:17 -0300115 .gpio = S5H1409_GPIO_ON,
Michael Krufky2b032382007-12-13 10:04:10 -0300116 .qam_if = 44000,
Steven Tothfc959be2007-09-08 19:08:17 -0300117 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300118 .status_mode = S5H1409_DEMODLOCKING,
119 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothfc959be2007-09-08 19:08:17 -0300120};
121
Steven Tothb3ea0162008-04-19 01:14:19 -0300122static struct tda10048_config hauppauge_hvr1200_config = {
123 .demod_address = 0x10 >> 1,
124 .output_mode = TDA10048_SERIAL_OUTPUT,
125 .fwbulkwritelen = TDA10048_BULKWRITE_200,
Steven Toth484d9e02009-05-02 11:08:23 -0300126 .inversion = TDA10048_INVERSION_ON,
Steven Toth8816bef2009-05-15 21:04:18 -0300127 .dtv6_if_freq_khz = TDA10048_IF_3300,
128 .dtv7_if_freq_khz = TDA10048_IF_3800,
129 .dtv8_if_freq_khz = TDA10048_IF_4300,
Steven Toth484d9e02009-05-02 11:08:23 -0300130 .clk_freq_khz = TDA10048_CLK_16000,
Steven Tothb3ea0162008-04-19 01:14:19 -0300131};
132
Michael Krufky6b926ec2009-05-12 17:32:17 -0300133static struct tda10048_config hauppauge_hvr1210_config = {
134 .demod_address = 0x10 >> 1,
135 .output_mode = TDA10048_SERIAL_OUTPUT,
136 .fwbulkwritelen = TDA10048_BULKWRITE_200,
137 .inversion = TDA10048_INVERSION_ON,
138 .if_freq_khz = TDA10048_IF_4000,
139 .clk_freq_khz = TDA10048_CLK_16000,
140};
141
Michael Krufky3ba71d22007-12-07 01:40:36 -0300142static struct s5h1409_config hauppauge_ezqam_config = {
143 .demod_address = 0x32 >> 1,
144 .output_mode = S5H1409_SERIAL_OUTPUT,
145 .gpio = S5H1409_GPIO_OFF,
146 .qam_if = 4000,
147 .inversion = S5H1409_INVERSION_ON,
Steven Tothdfc1c082008-01-15 21:35:22 -0300148 .status_mode = S5H1409_DEMODLOCKING,
149 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300150};
151
Steven Tothfc959be2007-09-08 19:08:17 -0300152static struct s5h1409_config hauppauge_hvr1800lp_config = {
153 .demod_address = 0x32 >> 1,
154 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothd19770e2007-03-11 20:44:05 -0300155 .gpio = S5H1409_GPIO_OFF,
Michael Krufky2b032382007-12-13 10:04:10 -0300156 .qam_if = 44000,
Steven Tothfe4751632007-03-20 15:27:53 -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 Tothd19770e2007-03-11 20:44:05 -0300160};
161
Michael Krufky07b4a832007-12-18 01:09:11 -0300162static struct s5h1409_config hauppauge_hvr1500_config = {
163 .demod_address = 0x32 >> 1,
164 .output_mode = S5H1409_SERIAL_OUTPUT,
165 .gpio = S5H1409_GPIO_OFF,
166 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300167 .status_mode = S5H1409_DEMODLOCKING,
168 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky07b4a832007-12-18 01:09:11 -0300169};
170
Steven Toth86184e02007-09-04 21:40:47 -0300171static struct mt2131_config hauppauge_generic_tunerconfig = {
Steven Totha77743b2007-08-22 21:01:20 -0300172 0x61
173};
174
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300175static struct lgdt330x_config fusionhdtv_5_express = {
176 .demod_address = 0x0e,
177 .demod_chip = LGDT3303,
178 .serial_mpeg = 0x40,
179};
180
Steven Tothd1987d52007-12-18 01:57:06 -0300181static struct s5h1409_config hauppauge_hvr1500q_config = {
182 .demod_address = 0x32 >> 1,
183 .output_mode = S5H1409_SERIAL_OUTPUT,
184 .gpio = S5H1409_GPIO_ON,
185 .qam_if = 44000,
186 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300187 .status_mode = S5H1409_DEMODLOCKING,
188 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd1987d52007-12-18 01:57:06 -0300189};
190
Michael Krufky335377b2008-05-07 01:43:10 -0300191static struct s5h1409_config dvico_s5h1409_config = {
192 .demod_address = 0x32 >> 1,
193 .output_mode = S5H1409_SERIAL_OUTPUT,
194 .gpio = S5H1409_GPIO_ON,
195 .qam_if = 44000,
196 .inversion = S5H1409_INVERSION_OFF,
197 .status_mode = S5H1409_DEMODLOCKING,
198 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
199};
200
Michael Krufky52b50452008-07-09 02:18:49 -0300201static struct s5h1411_config dvico_s5h1411_config = {
202 .output_mode = S5H1411_SERIAL_OUTPUT,
203 .gpio = S5H1411_GPIO_ON,
204 .qam_if = S5H1411_IF_44000,
205 .vsb_if = S5H1411_IF_44000,
206 .inversion = S5H1411_INVERSION_OFF,
207 .status_mode = S5H1411_DEMODLOCKING,
208 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
209};
210
Michael Krufky19bc5792009-05-08 16:05:29 -0300211static struct s5h1411_config hcw_s5h1411_config = {
212 .output_mode = S5H1411_SERIAL_OUTPUT,
213 .gpio = S5H1411_GPIO_OFF,
214 .vsb_if = S5H1411_IF_44000,
215 .qam_if = S5H1411_IF_4000,
216 .inversion = S5H1411_INVERSION_ON,
217 .status_mode = S5H1411_DEMODLOCKING,
218 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
219};
220
Steven Tothd1987d52007-12-18 01:57:06 -0300221static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
Steven Tothe12671cf2007-12-20 01:14:43 -0300222 .i2c_address = 0x61,
223 .if_khz = 5380,
Steven Tothd1987d52007-12-18 01:57:06 -0300224};
225
Michael Krufky335377b2008-05-07 01:43:10 -0300226static struct xc5000_config dvico_xc5000_tunerconfig = {
227 .i2c_address = 0x64,
228 .if_khz = 5380,
Michael Krufky335377b2008-05-07 01:43:10 -0300229};
230
Michael Krufky4041f1a2007-12-24 04:52:08 -0300231static struct tda829x_config tda829x_no_probe = {
232 .probe_tuner = TDA829X_DONT_PROBE,
233};
234
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300235static struct tda18271_std_map hauppauge_tda18271_std_map = {
Michael Krufkyc0dc0c12008-04-22 14:46:22 -0300236 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
237 .if_lvl = 6, .rfagc_top = 0x37 },
238 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
239 .if_lvl = 6, .rfagc_top = 0x37 },
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300240};
241
242static struct tda18271_config hauppauge_tda18271_config = {
243 .std_map = &hauppauge_tda18271_std_map,
244 .gate = TDA18271_GATE_ANALOG,
245};
246
Steven Tothb3ea0162008-04-19 01:14:19 -0300247static struct tda18271_config hauppauge_hvr1200_tuner_config = {
248 .gate = TDA18271_GATE_ANALOG,
249};
250
Michael Krufky6b926ec2009-05-12 17:32:17 -0300251static struct tda18271_config hauppauge_hvr1210_tuner_config = {
252 .gate = TDA18271_GATE_DIGITAL,
253};
254
Michael Krufky247bc542009-05-12 18:53:47 -0300255static struct tda18271_std_map hauppauge_hvr127x_std_map = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300256 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
257 .if_lvl = 1, .rfagc_top = 0x58 },
258 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
259 .if_lvl = 1, .rfagc_top = 0x58 },
260};
261
Michael Krufky247bc542009-05-12 18:53:47 -0300262static struct tda18271_config hauppauge_hvr127x_config = {
263 .std_map = &hauppauge_hvr127x_std_map,
Michael Krufkya5dbf452009-05-03 23:27:02 -0300264};
265
Michael Krufky247bc542009-05-12 18:53:47 -0300266static struct lgdt3305_config hauppauge_lgdt3305_config = {
Michael Krufkya5dbf452009-05-03 23:27:02 -0300267 .i2c_addr = 0x0e,
268 .mpeg_mode = LGDT3305_MPEG_SERIAL,
269 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
270 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
271 .deny_i2c_rptr = 1,
272 .spectral_inversion = 1,
273 .qam_if_khz = 4000,
274 .vsb_if_khz = 3250,
275};
276
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700277static struct dibx000_agc_config xc3028_agc_config = {
Steven Toth66762372008-04-22 15:38:26 -0300278 BAND_VHF | BAND_UHF, /* band_caps */
279
280 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
281 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
282 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
283 * P_agc_nb_est=2, P_agc_write=0
284 */
285 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
286 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
287
288 712, /* inv_gain */
289 21, /* time_stabiliz */
290
291 0, /* alpha_level */
292 118, /* thlock */
293
294 0, /* wbd_inv */
295 2867, /* wbd_ref */
296 0, /* wbd_sel */
297 2, /* wbd_alpha */
298
299 0, /* agc1_max */
300 0, /* agc1_min */
301 39718, /* agc2_max */
302 9930, /* agc2_min */
303 0, /* agc1_pt1 */
304 0, /* agc1_pt2 */
305 0, /* agc1_pt3 */
306 0, /* agc1_slope1 */
307 0, /* agc1_slope2 */
308 0, /* agc2_pt1 */
309 128, /* agc2_pt2 */
310 29, /* agc2_slope1 */
311 29, /* agc2_slope2 */
312
313 17, /* alpha_mant */
314 27, /* alpha_exp */
315 23, /* beta_mant */
316 51, /* beta_exp */
317
318 1, /* perform_agc_softsplit */
319};
320
321/* PLL Configuration for COFDM BW_MHz = 8.000000
322 * With external clock = 30.000000 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700323static struct dibx000_bandwidth_config xc3028_bw_config = {
Steven Toth66762372008-04-22 15:38:26 -0300324 60000, /* internal */
325 30000, /* sampling */
326 1, /* pll_cfg: prediv */
327 8, /* pll_cfg: ratio */
328 3, /* pll_cfg: range */
329 1, /* pll_cfg: reset */
330 0, /* pll_cfg: bypass */
331 0, /* misc: refdiv */
332 0, /* misc: bypclk_div */
333 1, /* misc: IO_CLK_en_core */
334 1, /* misc: ADClkSrc */
335 0, /* misc: modulo */
336 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
337 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
338 20452225, /* timf */
339 30000000 /* xtal_hz */
340};
341
342static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
343 .output_mpeg2_in_188_bytes = 1,
344 .hostbus_diversity = 1,
345 .tuner_is_baseband = 0,
346 .update_lna = NULL,
347
348 .agc_config_count = 1,
349 .agc = &xc3028_agc_config,
350 .bw = &xc3028_bw_config,
351
352 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
353 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
354 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
355
356 .pwm_freq_div = 0,
357 .agc_control = NULL,
358 .spur_protect = 0,
359
360 .output_mode = OUTMODE_MPEG2_SERIAL,
361};
362
Steven Tothaef2d182008-08-04 21:39:53 -0300363static struct zl10353_config dvico_fusionhdtv_xc3028 = {
364 .demod_address = 0x0f,
365 .if2 = 45600,
366 .no_tuner = 1,
Christopher Pascoed4dc6732009-04-27 11:27:04 -0300367 .disable_i2c_gate_ctrl = 1,
Steven Tothaef2d182008-08-04 21:39:53 -0300368};
369
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300370static struct stv0900_config netup_stv0900_config = {
371 .demod_address = 0x68,
372 .xtal = 27000000,
373 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
374 .diseqc_mode = 2,/* 2/3 PWM */
375 .path1_mode = 2,/*Serial continues clock */
376 .path2_mode = 2,/*Serial continues clock */
377 .tun1_maddress = 0,/* 0x60 */
378 .tun2_maddress = 3,/* 0x63 */
379 .tun1_adc = 1,/* 1 Vpp */
380 .tun2_adc = 1,/* 1 Vpp */
381};
382
383static struct stv6110_config netup_stv6110_tunerconfig_a = {
384 .i2c_address = 0x60,
385 .mclk = 27000000,
386 .iq_wiring = 0,
387};
388
389static struct stv6110_config netup_stv6110_tunerconfig_b = {
390 .i2c_address = 0x63,
391 .mclk = 27000000,
392 .iq_wiring = 1,
393};
394
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300395static int tbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
396{
397 struct cx23885_tsport *port = fe->dvb->priv;
398 struct cx23885_dev *dev = port->dev;
399
400 if (voltage == SEC_VOLTAGE_18)
401 cx_write(MC417_RWD, 0x00001e00);/* GPIO-13 high */
402 else if (voltage == SEC_VOLTAGE_13)
403 cx_write(MC417_RWD, 0x00001a00);/* GPIO-13 low */
404 else
405 cx_write(MC417_RWD, 0x00001800);/* GPIO-12 low */
406 return 0;
407}
408
409static struct cx24116_config tbs_cx24116_config = {
410 .demod_address = 0x05,
411};
412
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300413static struct cx24116_config tevii_cx24116_config = {
414 .demod_address = 0x55,
415};
416
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300417static struct cx24116_config dvbworld_cx24116_config = {
418 .demod_address = 0x05,
419};
420
Steven Tothd19770e2007-03-11 20:44:05 -0300421static int dvb_register(struct cx23885_tsport *port)
422{
423 struct cx23885_dev *dev = port->dev;
Michael Krufkyf139fa72007-09-09 03:55:34 -0300424 struct cx23885_i2c *i2c_bus = NULL;
Steven Toth363c35f2008-10-11 11:05:50 -0300425 struct videobuf_dvb_frontend *fe0;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300426 int ret;
Steven Toth363c35f2008-10-11 11:05:50 -0300427
Darron Broadf972e0bd2008-10-11 11:24:30 -0300428 /* Get the first frontend */
Darron Broad92abe9e2008-10-11 11:18:53 -0300429 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300430 if (!fe0)
431 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -0300432
433 /* init struct videobuf_dvb */
Steven Toth363c35f2008-10-11 11:05:50 -0300434 fe0->dvb.name = dev->name;
Steven Tothd19770e2007-03-11 20:44:05 -0300435
436 /* init frontend */
437 switch (dev->board) {
Steven Totha77743b2007-08-22 21:01:20 -0300438 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300439 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300440 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth86184e02007-09-04 21:40:47 -0300441 &hauppauge_generic_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300442 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300443 if (fe0->dvb.frontend != NULL) {
444 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300445 &i2c_bus->i2c_adap,
Steven Toth86184e02007-09-04 21:40:47 -0300446 &hauppauge_generic_tunerconfig, 0);
Steven Tothd19770e2007-03-11 20:44:05 -0300447 }
448 break;
Michael Krufkya5dbf452009-05-03 23:27:02 -0300449 case CX23885_BOARD_HAUPPAUGE_HVR1270:
Michael Krufkyd099bec2009-05-08 22:39:24 -0300450 case CX23885_BOARD_HAUPPAUGE_HVR1275:
Michael Krufkya5dbf452009-05-03 23:27:02 -0300451 i2c_bus = &dev->i2c_bus[0];
452 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
Michael Krufky247bc542009-05-12 18:53:47 -0300453 &hauppauge_lgdt3305_config,
Michael Krufkya5dbf452009-05-03 23:27:02 -0300454 &i2c_bus->i2c_adap);
455 if (fe0->dvb.frontend != NULL) {
456 dvb_attach(tda18271_attach, fe0->dvb.frontend,
457 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufky247bc542009-05-12 18:53:47 -0300458 &hauppauge_hvr127x_config);
Michael Krufkya5dbf452009-05-03 23:27:02 -0300459 }
460 break;
Michael Krufky19bc5792009-05-08 16:05:29 -0300461 case CX23885_BOARD_HAUPPAUGE_HVR1255:
462 i2c_bus = &dev->i2c_bus[0];
463 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
464 &hcw_s5h1411_config,
465 &i2c_bus->i2c_adap);
466 if (fe0->dvb.frontend != NULL) {
467 dvb_attach(tda18271_attach, fe0->dvb.frontend,
468 0x60, &dev->i2c_bus[1].i2c_adap,
469 &hauppauge_tda18271_config);
470 }
471 break;
Michael Krufky3ba71d22007-12-07 01:40:36 -0300472 case CX23885_BOARD_HAUPPAUGE_HVR1800:
473 i2c_bus = &dev->i2c_bus[0];
Darron Broad92abe9e2008-10-11 11:18:53 -0300474 switch (alt_tuner) {
Michael Krufky3ba71d22007-12-07 01:40:36 -0300475 case 1:
Steven Toth363c35f2008-10-11 11:05:50 -0300476 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300477 dvb_attach(s5h1409_attach,
478 &hauppauge_ezqam_config,
479 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300480 if (fe0->dvb.frontend != NULL) {
481 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300482 &dev->i2c_bus[1].i2c_adap, 0x42,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300483 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300484 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300485 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300486 &hauppauge_tda18271_config);
Michael Krufky3ba71d22007-12-07 01:40:36 -0300487 }
488 break;
489 case 0:
490 default:
Steven Toth363c35f2008-10-11 11:05:50 -0300491 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300492 dvb_attach(s5h1409_attach,
493 &hauppauge_generic_config,
494 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300495 if (fe0->dvb.frontend != NULL)
496 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300497 &i2c_bus->i2c_adap,
498 &hauppauge_generic_tunerconfig, 0);
499 break;
500 }
501 break;
Steven Tothfc959be2007-09-08 19:08:17 -0300502 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300503 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300504 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothfc959be2007-09-08 19:08:17 -0300505 &hauppauge_hvr1800lp_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300506 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300507 if (fe0->dvb.frontend != NULL) {
508 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300509 &i2c_bus->i2c_adap,
Steven Tothfc959be2007-09-08 19:08:17 -0300510 &hauppauge_generic_tunerconfig, 0);
511 }
512 break;
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300513 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300514 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300515 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300516 &fusionhdtv_5_express,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300517 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300518 if (fe0->dvb.frontend != NULL) {
519 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky827855d2008-04-22 14:46:16 -0300520 &i2c_bus->i2c_adap, 0x61,
521 TUNER_LG_TDVS_H06XF);
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300522 }
523 break;
Steven Tothd1987d52007-12-18 01:57:06 -0300524 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
525 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300526 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothd1987d52007-12-18 01:57:06 -0300527 &hauppauge_hvr1500q_config,
528 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300529 if (fe0->dvb.frontend != NULL)
530 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300531 &i2c_bus->i2c_adap,
532 &hauppauge_hvr1500q_tunerconfig);
Steven Tothd1987d52007-12-18 01:57:06 -0300533 break;
Michael Krufky07b4a832007-12-18 01:09:11 -0300534 case CX23885_BOARD_HAUPPAUGE_HVR1500:
535 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300536 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky07b4a832007-12-18 01:09:11 -0300537 &hauppauge_hvr1500_config,
538 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300539 if (fe0->dvb.frontend != NULL) {
Michael Krufky07b4a832007-12-18 01:09:11 -0300540 struct dvb_frontend *fe;
541 struct xc2028_config cfg = {
542 .i2c_adap = &i2c_bus->i2c_adap,
543 .i2c_addr = 0x61,
Michael Krufky07b4a832007-12-18 01:09:11 -0300544 };
545 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfeb2008-09-16 02:15:30 -0300546 .fname = XC2028_DEFAULT_FIRMWARE,
Michael Krufky07b4a832007-12-18 01:09:11 -0300547 .max_len = 64,
Steven Toth52c3d292009-04-20 22:42:00 -0300548 .demod = XC3028_FE_OREN538,
Michael Krufky07b4a832007-12-18 01:09:11 -0300549 };
550
551 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300552 fe0->dvb.frontend, &cfg);
Michael Krufky07b4a832007-12-18 01:09:11 -0300553 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
554 fe->ops.tuner_ops.set_config(fe, &ctl);
555 }
556 break;
Steven Tothb3ea0162008-04-19 01:14:19 -0300557 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Totha780a312008-04-19 01:25:52 -0300558 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Tothb3ea0162008-04-19 01:14:19 -0300559 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300560 fe0->dvb.frontend = dvb_attach(tda10048_attach,
Steven Tothb3ea0162008-04-19 01:14:19 -0300561 &hauppauge_hvr1200_config,
562 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300563 if (fe0->dvb.frontend != NULL) {
564 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300565 &dev->i2c_bus[1].i2c_adap, 0x42,
566 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300567 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300568 0x60, &dev->i2c_bus[1].i2c_adap,
569 &hauppauge_hvr1200_tuner_config);
570 }
571 break;
Michael Krufky6b926ec2009-05-12 17:32:17 -0300572 case CX23885_BOARD_HAUPPAUGE_HVR1210:
573 i2c_bus = &dev->i2c_bus[0];
574 fe0->dvb.frontend = dvb_attach(tda10048_attach,
575 &hauppauge_hvr1210_config,
576 &i2c_bus->i2c_adap);
577 if (fe0->dvb.frontend != NULL) {
578 dvb_attach(tda18271_attach, fe0->dvb.frontend,
579 0x60, &dev->i2c_bus[1].i2c_adap,
580 &hauppauge_hvr1210_tuner_config);
581 }
582 break;
Steven Toth66762372008-04-22 15:38:26 -0300583 case CX23885_BOARD_HAUPPAUGE_HVR1400:
584 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300585 fe0->dvb.frontend = dvb_attach(dib7000p_attach,
Steven Toth66762372008-04-22 15:38:26 -0300586 &i2c_bus->i2c_adap,
587 0x12, &hauppauge_hvr1400_dib7000_config);
Steven Toth363c35f2008-10-11 11:05:50 -0300588 if (fe0->dvb.frontend != NULL) {
Steven Toth66762372008-04-22 15:38:26 -0300589 struct dvb_frontend *fe;
590 struct xc2028_config cfg = {
591 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
592 .i2c_addr = 0x64,
Steven Toth66762372008-04-22 15:38:26 -0300593 };
594 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfeb2008-09-16 02:15:30 -0300595 .fname = XC3028L_DEFAULT_FIRMWARE,
Steven Toth66762372008-04-22 15:38:26 -0300596 .max_len = 64,
597 .demod = 5000,
Steven Toth9c8ced52008-10-16 20:18:44 -0300598 /* This is true for all demods with
599 v36 firmware? */
Mauro Carvalho Chehab0975fc62008-09-28 02:24:44 -0300600 .type = XC2028_D2633,
Steven Toth66762372008-04-22 15:38:26 -0300601 };
602
603 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300604 fe0->dvb.frontend, &cfg);
Steven Toth66762372008-04-22 15:38:26 -0300605 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
606 fe->ops.tuner_ops.set_config(fe, &ctl);
607 }
608 break;
Michael Krufky335377b2008-05-07 01:43:10 -0300609 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
610 i2c_bus = &dev->i2c_bus[port->nr - 1];
611
Steven Toth363c35f2008-10-11 11:05:50 -0300612 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky335377b2008-05-07 01:43:10 -0300613 &dvico_s5h1409_config,
614 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300615 if (fe0->dvb.frontend == NULL)
616 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Michael Krufky52b50452008-07-09 02:18:49 -0300617 &dvico_s5h1411_config,
618 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300619 if (fe0->dvb.frontend != NULL)
620 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300621 &i2c_bus->i2c_adap,
622 &dvico_xc5000_tunerconfig);
Michael Krufky335377b2008-05-07 01:43:10 -0300623 break;
Steven Tothaef2d182008-08-04 21:39:53 -0300624 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
625 i2c_bus = &dev->i2c_bus[port->nr - 1];
626
Steven Toth363c35f2008-10-11 11:05:50 -0300627 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Tothaef2d182008-08-04 21:39:53 -0300628 &dvico_fusionhdtv_xc3028,
629 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300630 if (fe0->dvb.frontend != NULL) {
Steven Tothaef2d182008-08-04 21:39:53 -0300631 struct dvb_frontend *fe;
632 struct xc2028_config cfg = {
633 .i2c_adap = &i2c_bus->i2c_adap,
634 .i2c_addr = 0x61,
Steven Tothaef2d182008-08-04 21:39:53 -0300635 };
636 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfeb2008-09-16 02:15:30 -0300637 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Tothaef2d182008-08-04 21:39:53 -0300638 .max_len = 64,
639 .demod = XC3028_FE_ZARLINK456,
640 };
641
Steven Toth363c35f2008-10-11 11:05:50 -0300642 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Tothaef2d182008-08-04 21:39:53 -0300643 &cfg);
644 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
645 fe->ops.tuner_ops.set_config(fe, &ctl);
646 }
647 break;
648 }
Steven Toth4c56b042008-08-12 13:30:03 -0300649 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -0300650 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Steven Toth4c56b042008-08-12 13:30:03 -0300651 i2c_bus = &dev->i2c_bus[0];
652
Steven Toth363c35f2008-10-11 11:05:50 -0300653 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Toth4c56b042008-08-12 13:30:03 -0300654 &dvico_fusionhdtv_xc3028,
655 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300656 if (fe0->dvb.frontend != NULL) {
Steven Toth4c56b042008-08-12 13:30:03 -0300657 struct dvb_frontend *fe;
658 struct xc2028_config cfg = {
659 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
660 .i2c_addr = 0x61,
Steven Toth4c56b042008-08-12 13:30:03 -0300661 };
662 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfeb2008-09-16 02:15:30 -0300663 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth4c56b042008-08-12 13:30:03 -0300664 .max_len = 64,
665 .demod = XC3028_FE_ZARLINK456,
666 };
667
Steven Toth363c35f2008-10-11 11:05:50 -0300668 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Toth4c56b042008-08-12 13:30:03 -0300669 &cfg);
670 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
671 fe->ops.tuner_ops.set_config(fe, &ctl);
672 }
673 break;
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300674 case CX23885_BOARD_TBS_6920:
675 i2c_bus = &dev->i2c_bus[0];
676
677 fe0->dvb.frontend = dvb_attach(cx24116_attach,
678 &tbs_cx24116_config,
679 &i2c_bus->i2c_adap);
680 if (fe0->dvb.frontend != NULL)
681 fe0->dvb.frontend->ops.set_voltage = tbs_set_voltage;
682
683 break;
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300684 case CX23885_BOARD_TEVII_S470:
685 i2c_bus = &dev->i2c_bus[1];
686
687 fe0->dvb.frontend = dvb_attach(cx24116_attach,
688 &tevii_cx24116_config,
689 &i2c_bus->i2c_adap);
690 if (fe0->dvb.frontend != NULL)
691 fe0->dvb.frontend->ops.set_voltage = tbs_set_voltage;
692
693 break;
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300694 case CX23885_BOARD_DVBWORLD_2005:
695 i2c_bus = &dev->i2c_bus[1];
696
697 fe0->dvb.frontend = dvb_attach(cx24116_attach,
698 &dvbworld_cx24116_config,
699 &i2c_bus->i2c_adap);
700 break;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300701 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
702 i2c_bus = &dev->i2c_bus[0];
703 switch (port->nr) {
704 /* port B */
705 case 1:
706 fe0->dvb.frontend = dvb_attach(stv0900_attach,
707 &netup_stv0900_config,
708 &i2c_bus->i2c_adap, 0);
709 if (fe0->dvb.frontend != NULL) {
710 if (dvb_attach(stv6110_attach,
711 fe0->dvb.frontend,
712 &netup_stv6110_tunerconfig_a,
713 &i2c_bus->i2c_adap)) {
714 if (!dvb_attach(lnbh24_attach,
715 fe0->dvb.frontend,
716 &i2c_bus->i2c_adap,
717 LNBH24_PCL, 0, 0x09))
718 printk(KERN_ERR
719 "No LNBH24 found!\n");
720
721 }
722 }
723 break;
724 /* port C */
725 case 2:
726 fe0->dvb.frontend = dvb_attach(stv0900_attach,
727 &netup_stv0900_config,
728 &i2c_bus->i2c_adap, 1);
729 if (fe0->dvb.frontend != NULL) {
730 if (dvb_attach(stv6110_attach,
731 fe0->dvb.frontend,
732 &netup_stv6110_tunerconfig_b,
733 &i2c_bus->i2c_adap)) {
734 if (!dvb_attach(lnbh24_attach,
735 fe0->dvb.frontend,
736 &i2c_bus->i2c_adap,
737 LNBH24_PCL, 0, 0x0a))
738 printk(KERN_ERR
739 "No LNBH24 found!\n");
740
741 }
742 }
743 break;
744 }
745 break;
Steven Tothd19770e2007-03-11 20:44:05 -0300746 default:
Steven Toth9c8ced52008-10-16 20:18:44 -0300747 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
748 " isn't supported yet\n",
Steven Tothd19770e2007-03-11 20:44:05 -0300749 dev->name);
750 break;
751 }
Steven Toth363c35f2008-10-11 11:05:50 -0300752 if (NULL == fe0->dvb.frontend) {
Steven Toth9c8ced52008-10-16 20:18:44 -0300753 printk(KERN_ERR "%s: frontend initialization failed\n",
754 dev->name);
Steven Tothd19770e2007-03-11 20:44:05 -0300755 return -1;
756 }
Michael Krufkyd7cba042008-09-12 13:31:45 -0300757 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -0300758 fe0->dvb.frontend->callback = cx23885_tuner_callback;
Steven Tothd19770e2007-03-11 20:44:05 -0300759
760 /* Put the analog decoder in standby to keep it quiet */
Hans Verkuil7c9fc9d2009-04-01 03:49:59 -0300761 call_all(dev, tuner, s_standby);
Steven Tothd19770e2007-03-11 20:44:05 -0300762
Steven Toth363c35f2008-10-11 11:05:50 -0300763 if (fe0->dvb.frontend->ops.analog_ops.standby)
764 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
Michael Krufky3ba71d22007-12-07 01:40:36 -0300765
Steven Tothd19770e2007-03-11 20:44:05 -0300766 /* register everything */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300767 ret = videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port,
Darron Broad59b18422008-10-11 11:44:05 -0300768 &dev->pci->dev, adapter_nr, 0);
Steven Toth363c35f2008-10-11 11:05:50 -0300769
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300770 /* init CI & MAC */
771 switch (dev->board) {
772 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
773 static struct netup_card_info cinfo;
774
775 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
776 memcpy(port->frontends.adapter.proposed_mac,
777 cinfo.port[port->nr - 1].mac, 6);
778 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC="
779 "%02X:%02X:%02X:%02X:%02X:%02X\n",
780 port->nr,
781 port->frontends.adapter.proposed_mac[0],
782 port->frontends.adapter.proposed_mac[1],
783 port->frontends.adapter.proposed_mac[2],
784 port->frontends.adapter.proposed_mac[3],
785 port->frontends.adapter.proposed_mac[4],
786 port->frontends.adapter.proposed_mac[5]);
787
788 netup_ci_init(port);
789 break;
790 }
791 }
792
793 return ret;
Steven Tothd19770e2007-03-11 20:44:05 -0300794}
795
796int cx23885_dvb_register(struct cx23885_tsport *port)
797{
Steven Toth363c35f2008-10-11 11:05:50 -0300798
799 struct videobuf_dvb_frontend *fe0;
Steven Tothd19770e2007-03-11 20:44:05 -0300800 struct cx23885_dev *dev = port->dev;
Steven Totheb0c58b2008-10-11 12:34:39 -0300801 int err, i;
Steven Tothd19770e2007-03-11 20:44:05 -0300802
Steven Totheb0c58b2008-10-11 12:34:39 -0300803 /* Here we need to allocate the correct number of frontends,
804 * as reflected in the cards struct. The reality is that currrently
805 * no cx23885 boards support this - yet. But, if we don't modify this
806 * code then the second frontend would never be allocated (later)
807 * and fail with error before the attach in dvb_register().
808 * Without these changes we risk an OOPS later. The changes here
809 * are for safety, and should provide a good foundation for the
810 * future addition of any multi-frontend cx23885 based boards.
811 */
812 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
813 port->num_frontends);
Steven Toth363c35f2008-10-11 11:05:50 -0300814
Steven Totheb0c58b2008-10-11 12:34:39 -0300815 for (i = 1; i <= port->num_frontends; i++) {
Darron Broad96b7a1a2008-10-15 20:26:34 -0300816 if (videobuf_dvb_alloc_frontend(
Steven Toth9c8ced52008-10-16 20:18:44 -0300817 &port->frontends, i) == NULL) {
Steven Totheb0c58b2008-10-11 12:34:39 -0300818 printk(KERN_ERR "%s() failed to alloc\n", __func__);
819 return -ENOMEM;
820 }
Steven Tothd19770e2007-03-11 20:44:05 -0300821
Steven Totheb0c58b2008-10-11 12:34:39 -0300822 fe0 = videobuf_dvb_get_frontend(&port->frontends, i);
823 if (!fe0)
824 err = -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -0300825
Steven Totheb0c58b2008-10-11 12:34:39 -0300826 dprintk(1, "%s\n", __func__);
Steven Toth9c8ced52008-10-16 20:18:44 -0300827 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
Steven Totheb0c58b2008-10-11 12:34:39 -0300828 dev->board,
829 dev->name,
830 dev->pci_bus,
831 dev->pci_slot);
832
833 err = -ENODEV;
834
835 /* dvb stuff */
836 /* We have to init the queue for each frontend on a port. */
Steven Toth9c8ced52008-10-16 20:18:44 -0300837 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
838 videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops,
839 &dev->pci->dev, &port->slock,
Michael Krufky44a64812007-03-20 23:00:18 -0300840 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
841 sizeof(struct cx23885_buffer), port);
Steven Totheb0c58b2008-10-11 12:34:39 -0300842 }
Steven Tothd19770e2007-03-11 20:44:05 -0300843 err = dvb_register(port);
844 if (err != 0)
Steven Toth9c8ced52008-10-16 20:18:44 -0300845 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
846 __func__, err);
Steven Tothd19770e2007-03-11 20:44:05 -0300847
Steven Tothd19770e2007-03-11 20:44:05 -0300848 return err;
849}
850
851int cx23885_dvb_unregister(struct cx23885_tsport *port)
852{
Steven Toth363c35f2008-10-11 11:05:50 -0300853 struct videobuf_dvb_frontend *fe0;
854
Steven Totheb0c58b2008-10-11 12:34:39 -0300855 /* FIXME: in an error condition where the we have
856 * an expected number of frontends (attach problem)
857 * then this might not clean up correctly, if 1
858 * is invalid.
859 * This comment only applies to future boards IF they
860 * implement MFE support.
861 */
Darron Broad92abe9e2008-10-11 11:18:53 -0300862 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Toth9c8ced52008-10-16 20:18:44 -0300863 if (fe0->dvb.frontend)
Steven Toth363c35f2008-10-11 11:05:50 -0300864 videobuf_dvb_unregister_bus(&port->frontends);
Steven Tothd19770e2007-03-11 20:44:05 -0300865
Hans Verkuilafd96662009-03-13 13:24:19 -0300866 switch (port->dev->board) {
867 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
868 netup_ci_exit(port);
869 break;
870 }
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300871
Steven Tothd19770e2007-03-11 20:44:05 -0300872 return 0;
873}
Michael Krufky44a64812007-03-20 23:00:18 -0300874