blob: 48cdf279598578ac9155c4c1c4e9fd65ca0bbeed [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,
127 .if_freq_khz = TDA10048_IF_4300,
128 .clk_freq_khz = TDA10048_CLK_16000,
Steven Tothb3ea0162008-04-19 01:14:19 -0300129};
130
Michael Krufky3ba71d22007-12-07 01:40:36 -0300131static struct s5h1409_config hauppauge_ezqam_config = {
132 .demod_address = 0x32 >> 1,
133 .output_mode = S5H1409_SERIAL_OUTPUT,
134 .gpio = S5H1409_GPIO_OFF,
135 .qam_if = 4000,
136 .inversion = S5H1409_INVERSION_ON,
Steven Tothdfc1c082008-01-15 21:35:22 -0300137 .status_mode = S5H1409_DEMODLOCKING,
138 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300139};
140
Steven Tothfc959be2007-09-08 19:08:17 -0300141static struct s5h1409_config hauppauge_hvr1800lp_config = {
142 .demod_address = 0x32 >> 1,
143 .output_mode = S5H1409_SERIAL_OUTPUT,
Steven Tothd19770e2007-03-11 20:44:05 -0300144 .gpio = S5H1409_GPIO_OFF,
Michael Krufky2b032382007-12-13 10:04:10 -0300145 .qam_if = 44000,
Steven Tothfe475162007-03-20 15:27:53 -0300146 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300147 .status_mode = S5H1409_DEMODLOCKING,
148 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd19770e2007-03-11 20:44:05 -0300149};
150
Michael Krufky07b4a832007-12-18 01:09:11 -0300151static struct s5h1409_config hauppauge_hvr1500_config = {
152 .demod_address = 0x32 >> 1,
153 .output_mode = S5H1409_SERIAL_OUTPUT,
154 .gpio = S5H1409_GPIO_OFF,
155 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300156 .status_mode = S5H1409_DEMODLOCKING,
157 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Michael Krufky07b4a832007-12-18 01:09:11 -0300158};
159
Steven Toth86184e02007-09-04 21:40:47 -0300160static struct mt2131_config hauppauge_generic_tunerconfig = {
Steven Totha77743b2007-08-22 21:01:20 -0300161 0x61
162};
163
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300164static struct lgdt330x_config fusionhdtv_5_express = {
165 .demod_address = 0x0e,
166 .demod_chip = LGDT3303,
167 .serial_mpeg = 0x40,
168};
169
Steven Tothd1987d52007-12-18 01:57:06 -0300170static struct s5h1409_config hauppauge_hvr1500q_config = {
171 .demod_address = 0x32 >> 1,
172 .output_mode = S5H1409_SERIAL_OUTPUT,
173 .gpio = S5H1409_GPIO_ON,
174 .qam_if = 44000,
175 .inversion = S5H1409_INVERSION_OFF,
Steven Tothdfc1c082008-01-15 21:35:22 -0300176 .status_mode = S5H1409_DEMODLOCKING,
177 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
Steven Tothd1987d52007-12-18 01:57:06 -0300178};
179
Michael Krufky335377b2008-05-07 01:43:10 -0300180static struct s5h1409_config dvico_s5h1409_config = {
181 .demod_address = 0x32 >> 1,
182 .output_mode = S5H1409_SERIAL_OUTPUT,
183 .gpio = S5H1409_GPIO_ON,
184 .qam_if = 44000,
185 .inversion = S5H1409_INVERSION_OFF,
186 .status_mode = S5H1409_DEMODLOCKING,
187 .mpeg_timing = S5H1409_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
188};
189
Michael Krufky52b50452008-07-09 02:18:49 -0300190static struct s5h1411_config dvico_s5h1411_config = {
191 .output_mode = S5H1411_SERIAL_OUTPUT,
192 .gpio = S5H1411_GPIO_ON,
193 .qam_if = S5H1411_IF_44000,
194 .vsb_if = S5H1411_IF_44000,
195 .inversion = S5H1411_INVERSION_OFF,
196 .status_mode = S5H1411_DEMODLOCKING,
197 .mpeg_timing = S5H1411_MPEGTIMING_CONTINOUS_NONINVERTING_CLOCK,
198};
199
Steven Tothd1987d52007-12-18 01:57:06 -0300200static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
Steven Tothe12671c2007-12-20 01:14:43 -0300201 .i2c_address = 0x61,
202 .if_khz = 5380,
Steven Tothd1987d52007-12-18 01:57:06 -0300203};
204
Michael Krufky335377b2008-05-07 01:43:10 -0300205static struct xc5000_config dvico_xc5000_tunerconfig = {
206 .i2c_address = 0x64,
207 .if_khz = 5380,
Michael Krufky335377b2008-05-07 01:43:10 -0300208};
209
Michael Krufky4041f1a2007-12-24 04:52:08 -0300210static struct tda829x_config tda829x_no_probe = {
211 .probe_tuner = TDA829X_DONT_PROBE,
212};
213
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300214static struct tda18271_std_map hauppauge_tda18271_std_map = {
Michael Krufkyc0dc0c12008-04-22 14:46:22 -0300215 .atsc_6 = { .if_freq = 5380, .agc_mode = 3, .std = 3,
216 .if_lvl = 6, .rfagc_top = 0x37 },
217 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 0,
218 .if_lvl = 6, .rfagc_top = 0x37 },
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300219};
220
221static struct tda18271_config hauppauge_tda18271_config = {
222 .std_map = &hauppauge_tda18271_std_map,
223 .gate = TDA18271_GATE_ANALOG,
224};
225
Steven Tothb3ea0162008-04-19 01:14:19 -0300226static struct tda18271_config hauppauge_hvr1200_tuner_config = {
227 .gate = TDA18271_GATE_ANALOG,
228};
229
Michael Krufkya5dbf452009-05-03 23:27:02 -0300230static struct tda18271_std_map hcw_lgdt3305_tda18271_std_map = {
231 .atsc_6 = { .if_freq = 3250, .agc_mode = 3, .std = 4,
232 .if_lvl = 1, .rfagc_top = 0x58 },
233 .qam_6 = { .if_freq = 4000, .agc_mode = 3, .std = 5,
234 .if_lvl = 1, .rfagc_top = 0x58 },
235};
236
237static struct tda18271_config hcw_lgdt3305_tda18271_config = {
238 .std_map = &hcw_lgdt3305_tda18271_std_map,
239};
240
241static struct lgdt3305_config hcw_lgdt3305_config = {
242 .i2c_addr = 0x0e,
243 .mpeg_mode = LGDT3305_MPEG_SERIAL,
244 .tpclk_edge = LGDT3305_TPCLK_FALLING_EDGE,
245 .tpvalid_polarity = LGDT3305_TP_VALID_HIGH,
246 .deny_i2c_rptr = 1,
247 .spectral_inversion = 1,
248 .qam_if_khz = 4000,
249 .vsb_if_khz = 3250,
250};
251
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700252static struct dibx000_agc_config xc3028_agc_config = {
Steven Toth66762372008-04-22 15:38:26 -0300253 BAND_VHF | BAND_UHF, /* band_caps */
254
255 /* P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=0,
256 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0,
257 * P_agc_inh_dc_rv_est=0, P_agc_time_est=3, P_agc_freeze=0,
258 * P_agc_nb_est=2, P_agc_write=0
259 */
260 (0 << 15) | (0 << 14) | (0 << 11) | (0 << 10) | (0 << 9) | (0 << 8) |
261 (3 << 5) | (0 << 4) | (2 << 1) | (0 << 0), /* setup */
262
263 712, /* inv_gain */
264 21, /* time_stabiliz */
265
266 0, /* alpha_level */
267 118, /* thlock */
268
269 0, /* wbd_inv */
270 2867, /* wbd_ref */
271 0, /* wbd_sel */
272 2, /* wbd_alpha */
273
274 0, /* agc1_max */
275 0, /* agc1_min */
276 39718, /* agc2_max */
277 9930, /* agc2_min */
278 0, /* agc1_pt1 */
279 0, /* agc1_pt2 */
280 0, /* agc1_pt3 */
281 0, /* agc1_slope1 */
282 0, /* agc1_slope2 */
283 0, /* agc2_pt1 */
284 128, /* agc2_pt2 */
285 29, /* agc2_slope1 */
286 29, /* agc2_slope2 */
287
288 17, /* alpha_mant */
289 27, /* alpha_exp */
290 23, /* beta_mant */
291 51, /* beta_exp */
292
293 1, /* perform_agc_softsplit */
294};
295
296/* PLL Configuration for COFDM BW_MHz = 8.000000
297 * With external clock = 30.000000 */
Harvey Harrisonb1721d02008-04-25 19:03:08 -0700298static struct dibx000_bandwidth_config xc3028_bw_config = {
Steven Toth66762372008-04-22 15:38:26 -0300299 60000, /* internal */
300 30000, /* sampling */
301 1, /* pll_cfg: prediv */
302 8, /* pll_cfg: ratio */
303 3, /* pll_cfg: range */
304 1, /* pll_cfg: reset */
305 0, /* pll_cfg: bypass */
306 0, /* misc: refdiv */
307 0, /* misc: bypclk_div */
308 1, /* misc: IO_CLK_en_core */
309 1, /* misc: ADClkSrc */
310 0, /* misc: modulo */
311 (3 << 14) | (1 << 12) | (524 << 0), /* sad_cfg: refsel, sel, freq_15k */
312 (1 << 25) | 5816102, /* ifreq = 5.200000 MHz */
313 20452225, /* timf */
314 30000000 /* xtal_hz */
315};
316
317static struct dib7000p_config hauppauge_hvr1400_dib7000_config = {
318 .output_mpeg2_in_188_bytes = 1,
319 .hostbus_diversity = 1,
320 .tuner_is_baseband = 0,
321 .update_lna = NULL,
322
323 .agc_config_count = 1,
324 .agc = &xc3028_agc_config,
325 .bw = &xc3028_bw_config,
326
327 .gpio_dir = DIB7000P_GPIO_DEFAULT_DIRECTIONS,
328 .gpio_val = DIB7000P_GPIO_DEFAULT_VALUES,
329 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
330
331 .pwm_freq_div = 0,
332 .agc_control = NULL,
333 .spur_protect = 0,
334
335 .output_mode = OUTMODE_MPEG2_SERIAL,
336};
337
Steven Tothaef2d182008-08-04 21:39:53 -0300338static struct zl10353_config dvico_fusionhdtv_xc3028 = {
339 .demod_address = 0x0f,
340 .if2 = 45600,
341 .no_tuner = 1,
Christopher Pascoed4dc6732009-04-27 11:27:04 -0300342 .disable_i2c_gate_ctrl = 1,
Steven Tothaef2d182008-08-04 21:39:53 -0300343};
344
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300345static struct stv0900_config netup_stv0900_config = {
346 .demod_address = 0x68,
347 .xtal = 27000000,
348 .clkmode = 3,/* 0-CLKI, 2-XTALI, else AUTO */
349 .diseqc_mode = 2,/* 2/3 PWM */
350 .path1_mode = 2,/*Serial continues clock */
351 .path2_mode = 2,/*Serial continues clock */
352 .tun1_maddress = 0,/* 0x60 */
353 .tun2_maddress = 3,/* 0x63 */
354 .tun1_adc = 1,/* 1 Vpp */
355 .tun2_adc = 1,/* 1 Vpp */
356};
357
358static struct stv6110_config netup_stv6110_tunerconfig_a = {
359 .i2c_address = 0x60,
360 .mclk = 27000000,
361 .iq_wiring = 0,
362};
363
364static struct stv6110_config netup_stv6110_tunerconfig_b = {
365 .i2c_address = 0x63,
366 .mclk = 27000000,
367 .iq_wiring = 1,
368};
369
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300370static int tbs_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
371{
372 struct cx23885_tsport *port = fe->dvb->priv;
373 struct cx23885_dev *dev = port->dev;
374
375 if (voltage == SEC_VOLTAGE_18)
376 cx_write(MC417_RWD, 0x00001e00);/* GPIO-13 high */
377 else if (voltage == SEC_VOLTAGE_13)
378 cx_write(MC417_RWD, 0x00001a00);/* GPIO-13 low */
379 else
380 cx_write(MC417_RWD, 0x00001800);/* GPIO-12 low */
381 return 0;
382}
383
384static struct cx24116_config tbs_cx24116_config = {
385 .demod_address = 0x05,
386};
387
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300388static struct cx24116_config tevii_cx24116_config = {
389 .demod_address = 0x55,
390};
391
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300392static struct cx24116_config dvbworld_cx24116_config = {
393 .demod_address = 0x05,
394};
395
Steven Tothd19770e2007-03-11 20:44:05 -0300396static int dvb_register(struct cx23885_tsport *port)
397{
398 struct cx23885_dev *dev = port->dev;
Michael Krufkyf139fa72007-09-09 03:55:34 -0300399 struct cx23885_i2c *i2c_bus = NULL;
Steven Toth363c35f2008-10-11 11:05:50 -0300400 struct videobuf_dvb_frontend *fe0;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300401 int ret;
Steven Toth363c35f2008-10-11 11:05:50 -0300402
Darron Broadf972e0b2008-10-11 11:24:30 -0300403 /* Get the first frontend */
Darron Broad92abe9e2008-10-11 11:18:53 -0300404 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Toth363c35f2008-10-11 11:05:50 -0300405 if (!fe0)
406 return -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -0300407
408 /* init struct videobuf_dvb */
Steven Toth363c35f2008-10-11 11:05:50 -0300409 fe0->dvb.name = dev->name;
Steven Tothd19770e2007-03-11 20:44:05 -0300410
411 /* init frontend */
412 switch (dev->board) {
Steven Totha77743b2007-08-22 21:01:20 -0300413 case CX23885_BOARD_HAUPPAUGE_HVR1250:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300414 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300415 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Toth86184e02007-09-04 21:40:47 -0300416 &hauppauge_generic_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300417 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300418 if (fe0->dvb.frontend != NULL) {
419 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300420 &i2c_bus->i2c_adap,
Steven Toth86184e02007-09-04 21:40:47 -0300421 &hauppauge_generic_tunerconfig, 0);
Steven Tothd19770e2007-03-11 20:44:05 -0300422 }
423 break;
Michael Krufkya5dbf452009-05-03 23:27:02 -0300424 case CX23885_BOARD_HAUPPAUGE_HVR1270:
425 i2c_bus = &dev->i2c_bus[0];
426 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
427 &hcw_lgdt3305_config,
428 &i2c_bus->i2c_adap);
429 if (fe0->dvb.frontend != NULL) {
430 dvb_attach(tda18271_attach, fe0->dvb.frontend,
431 0x60, &dev->i2c_bus[1].i2c_adap,
432 &hcw_lgdt3305_tda18271_config);
433 }
434 break;
Michael Krufky3ba71d22007-12-07 01:40:36 -0300435 case CX23885_BOARD_HAUPPAUGE_HVR1800:
436 i2c_bus = &dev->i2c_bus[0];
Darron Broad92abe9e2008-10-11 11:18:53 -0300437 switch (alt_tuner) {
Michael Krufky3ba71d22007-12-07 01:40:36 -0300438 case 1:
Steven Toth363c35f2008-10-11 11:05:50 -0300439 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300440 dvb_attach(s5h1409_attach,
441 &hauppauge_ezqam_config,
442 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300443 if (fe0->dvb.frontend != NULL) {
444 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300445 &dev->i2c_bus[1].i2c_adap, 0x42,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300446 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300447 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Michael Krufky4041f1a2007-12-24 04:52:08 -0300448 0x60, &dev->i2c_bus[1].i2c_adap,
Michael Krufkyf21e0d72008-01-02 03:01:54 -0300449 &hauppauge_tda18271_config);
Michael Krufky3ba71d22007-12-07 01:40:36 -0300450 }
451 break;
452 case 0:
453 default:
Steven Toth363c35f2008-10-11 11:05:50 -0300454 fe0->dvb.frontend =
Michael Krufky3ba71d22007-12-07 01:40:36 -0300455 dvb_attach(s5h1409_attach,
456 &hauppauge_generic_config,
457 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300458 if (fe0->dvb.frontend != NULL)
459 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufky3ba71d22007-12-07 01:40:36 -0300460 &i2c_bus->i2c_adap,
461 &hauppauge_generic_tunerconfig, 0);
462 break;
463 }
464 break;
Steven Tothfc959be2007-09-08 19:08:17 -0300465 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300466 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300467 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothfc959be2007-09-08 19:08:17 -0300468 &hauppauge_hvr1800lp_config,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300469 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300470 if (fe0->dvb.frontend != NULL) {
471 dvb_attach(mt2131_attach, fe0->dvb.frontend,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300472 &i2c_bus->i2c_adap,
Steven Tothfc959be2007-09-08 19:08:17 -0300473 &hauppauge_generic_tunerconfig, 0);
474 }
475 break;
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300476 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
Michael Krufkyf139fa72007-09-09 03:55:34 -0300477 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300478 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300479 &fusionhdtv_5_express,
Michael Krufkyf139fa72007-09-09 03:55:34 -0300480 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300481 if (fe0->dvb.frontend != NULL) {
482 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
Michael Krufky827855d2008-04-22 14:46:16 -0300483 &i2c_bus->i2c_adap, 0x61,
484 TUNER_LG_TDVS_H06XF);
Michael Krufky9bc37ca2007-09-08 15:17:13 -0300485 }
486 break;
Steven Tothd1987d52007-12-18 01:57:06 -0300487 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
488 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300489 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Steven Tothd1987d52007-12-18 01:57:06 -0300490 &hauppauge_hvr1500q_config,
491 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300492 if (fe0->dvb.frontend != NULL)
493 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300494 &i2c_bus->i2c_adap,
495 &hauppauge_hvr1500q_tunerconfig);
Steven Tothd1987d52007-12-18 01:57:06 -0300496 break;
Michael Krufky07b4a832007-12-18 01:09:11 -0300497 case CX23885_BOARD_HAUPPAUGE_HVR1500:
498 i2c_bus = &dev->i2c_bus[1];
Steven Toth363c35f2008-10-11 11:05:50 -0300499 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky07b4a832007-12-18 01:09:11 -0300500 &hauppauge_hvr1500_config,
501 &dev->i2c_bus[0].i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300502 if (fe0->dvb.frontend != NULL) {
Michael Krufky07b4a832007-12-18 01:09:11 -0300503 struct dvb_frontend *fe;
504 struct xc2028_config cfg = {
505 .i2c_adap = &i2c_bus->i2c_adap,
506 .i2c_addr = 0x61,
Michael Krufky07b4a832007-12-18 01:09:11 -0300507 };
508 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300509 .fname = XC2028_DEFAULT_FIRMWARE,
Michael Krufky07b4a832007-12-18 01:09:11 -0300510 .max_len = 64,
Steven Toth52c3d292009-04-20 22:42:00 -0300511 .demod = XC3028_FE_OREN538,
Michael Krufky07b4a832007-12-18 01:09:11 -0300512 };
513
514 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300515 fe0->dvb.frontend, &cfg);
Michael Krufky07b4a832007-12-18 01:09:11 -0300516 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
517 fe->ops.tuner_ops.set_config(fe, &ctl);
518 }
519 break;
Steven Tothb3ea0162008-04-19 01:14:19 -0300520 case CX23885_BOARD_HAUPPAUGE_HVR1200:
Steven Totha780a312008-04-19 01:25:52 -0300521 case CX23885_BOARD_HAUPPAUGE_HVR1700:
Steven Tothb3ea0162008-04-19 01:14:19 -0300522 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300523 fe0->dvb.frontend = dvb_attach(tda10048_attach,
Steven Tothb3ea0162008-04-19 01:14:19 -0300524 &hauppauge_hvr1200_config,
525 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300526 if (fe0->dvb.frontend != NULL) {
527 dvb_attach(tda829x_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300528 &dev->i2c_bus[1].i2c_adap, 0x42,
529 &tda829x_no_probe);
Steven Toth363c35f2008-10-11 11:05:50 -0300530 dvb_attach(tda18271_attach, fe0->dvb.frontend,
Steven Tothb3ea0162008-04-19 01:14:19 -0300531 0x60, &dev->i2c_bus[1].i2c_adap,
532 &hauppauge_hvr1200_tuner_config);
533 }
534 break;
Steven Toth66762372008-04-22 15:38:26 -0300535 case CX23885_BOARD_HAUPPAUGE_HVR1400:
536 i2c_bus = &dev->i2c_bus[0];
Steven Toth363c35f2008-10-11 11:05:50 -0300537 fe0->dvb.frontend = dvb_attach(dib7000p_attach,
Steven Toth66762372008-04-22 15:38:26 -0300538 &i2c_bus->i2c_adap,
539 0x12, &hauppauge_hvr1400_dib7000_config);
Steven Toth363c35f2008-10-11 11:05:50 -0300540 if (fe0->dvb.frontend != NULL) {
Steven Toth66762372008-04-22 15:38:26 -0300541 struct dvb_frontend *fe;
542 struct xc2028_config cfg = {
543 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
544 .i2c_addr = 0x64,
Steven Toth66762372008-04-22 15:38:26 -0300545 };
546 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300547 .fname = XC3028L_DEFAULT_FIRMWARE,
Steven Toth66762372008-04-22 15:38:26 -0300548 .max_len = 64,
549 .demod = 5000,
Steven Toth9c8ced52008-10-16 20:18:44 -0300550 /* This is true for all demods with
551 v36 firmware? */
Mauro Carvalho Chehab0975fc62008-09-28 02:24:44 -0300552 .type = XC2028_D2633,
Steven Toth66762372008-04-22 15:38:26 -0300553 };
554
555 fe = dvb_attach(xc2028_attach,
Steven Toth363c35f2008-10-11 11:05:50 -0300556 fe0->dvb.frontend, &cfg);
Steven Toth66762372008-04-22 15:38:26 -0300557 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
558 fe->ops.tuner_ops.set_config(fe, &ctl);
559 }
560 break;
Michael Krufky335377b2008-05-07 01:43:10 -0300561 case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
562 i2c_bus = &dev->i2c_bus[port->nr - 1];
563
Steven Toth363c35f2008-10-11 11:05:50 -0300564 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
Michael Krufky335377b2008-05-07 01:43:10 -0300565 &dvico_s5h1409_config,
566 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300567 if (fe0->dvb.frontend == NULL)
568 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
Michael Krufky52b50452008-07-09 02:18:49 -0300569 &dvico_s5h1411_config,
570 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300571 if (fe0->dvb.frontend != NULL)
572 dvb_attach(xc5000_attach, fe0->dvb.frontend,
Michael Krufky30650962008-09-06 14:56:58 -0300573 &i2c_bus->i2c_adap,
574 &dvico_xc5000_tunerconfig);
Michael Krufky335377b2008-05-07 01:43:10 -0300575 break;
Steven Tothaef2d182008-08-04 21:39:53 -0300576 case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP: {
577 i2c_bus = &dev->i2c_bus[port->nr - 1];
578
Steven Toth363c35f2008-10-11 11:05:50 -0300579 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Tothaef2d182008-08-04 21:39:53 -0300580 &dvico_fusionhdtv_xc3028,
581 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300582 if (fe0->dvb.frontend != NULL) {
Steven Tothaef2d182008-08-04 21:39:53 -0300583 struct dvb_frontend *fe;
584 struct xc2028_config cfg = {
585 .i2c_adap = &i2c_bus->i2c_adap,
586 .i2c_addr = 0x61,
Steven Tothaef2d182008-08-04 21:39:53 -0300587 };
588 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300589 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Tothaef2d182008-08-04 21:39:53 -0300590 .max_len = 64,
591 .demod = XC3028_FE_ZARLINK456,
592 };
593
Steven Toth363c35f2008-10-11 11:05:50 -0300594 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Tothaef2d182008-08-04 21:39:53 -0300595 &cfg);
596 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
597 fe->ops.tuner_ops.set_config(fe, &ctl);
598 }
599 break;
600 }
Steven Toth4c56b042008-08-12 13:30:03 -0300601 case CX23885_BOARD_LEADTEK_WINFAST_PXDVR3200_H:
Igor M. Liplianin9bb1b7e2008-11-23 14:11:16 -0300602 case CX23885_BOARD_COMPRO_VIDEOMATE_E650F:
Steven Toth4c56b042008-08-12 13:30:03 -0300603 i2c_bus = &dev->i2c_bus[0];
604
Steven Toth363c35f2008-10-11 11:05:50 -0300605 fe0->dvb.frontend = dvb_attach(zl10353_attach,
Steven Toth4c56b042008-08-12 13:30:03 -0300606 &dvico_fusionhdtv_xc3028,
607 &i2c_bus->i2c_adap);
Steven Toth363c35f2008-10-11 11:05:50 -0300608 if (fe0->dvb.frontend != NULL) {
Steven Toth4c56b042008-08-12 13:30:03 -0300609 struct dvb_frontend *fe;
610 struct xc2028_config cfg = {
611 .i2c_adap = &dev->i2c_bus[1].i2c_adap,
612 .i2c_addr = 0x61,
Steven Toth4c56b042008-08-12 13:30:03 -0300613 };
614 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300615 .fname = XC2028_DEFAULT_FIRMWARE,
Steven Toth4c56b042008-08-12 13:30:03 -0300616 .max_len = 64,
617 .demod = XC3028_FE_ZARLINK456,
618 };
619
Steven Toth363c35f2008-10-11 11:05:50 -0300620 fe = dvb_attach(xc2028_attach, fe0->dvb.frontend,
Steven Toth4c56b042008-08-12 13:30:03 -0300621 &cfg);
622 if (fe != NULL && fe->ops.tuner_ops.set_config != NULL)
623 fe->ops.tuner_ops.set_config(fe, &ctl);
624 }
625 break;
Igor M. Liplianin96318d02009-01-17 12:11:20 -0300626 case CX23885_BOARD_TBS_6920:
627 i2c_bus = &dev->i2c_bus[0];
628
629 fe0->dvb.frontend = dvb_attach(cx24116_attach,
630 &tbs_cx24116_config,
631 &i2c_bus->i2c_adap);
632 if (fe0->dvb.frontend != NULL)
633 fe0->dvb.frontend->ops.set_voltage = tbs_set_voltage;
634
635 break;
Igor M. Liplianin579943f2009-01-17 12:18:26 -0300636 case CX23885_BOARD_TEVII_S470:
637 i2c_bus = &dev->i2c_bus[1];
638
639 fe0->dvb.frontend = dvb_attach(cx24116_attach,
640 &tevii_cx24116_config,
641 &i2c_bus->i2c_adap);
642 if (fe0->dvb.frontend != NULL)
643 fe0->dvb.frontend->ops.set_voltage = tbs_set_voltage;
644
645 break;
Igor M. Liplianinc9b8b042009-01-17 12:23:31 -0300646 case CX23885_BOARD_DVBWORLD_2005:
647 i2c_bus = &dev->i2c_bus[1];
648
649 fe0->dvb.frontend = dvb_attach(cx24116_attach,
650 &dvbworld_cx24116_config,
651 &i2c_bus->i2c_adap);
652 break;
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300653 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
654 i2c_bus = &dev->i2c_bus[0];
655 switch (port->nr) {
656 /* port B */
657 case 1:
658 fe0->dvb.frontend = dvb_attach(stv0900_attach,
659 &netup_stv0900_config,
660 &i2c_bus->i2c_adap, 0);
661 if (fe0->dvb.frontend != NULL) {
662 if (dvb_attach(stv6110_attach,
663 fe0->dvb.frontend,
664 &netup_stv6110_tunerconfig_a,
665 &i2c_bus->i2c_adap)) {
666 if (!dvb_attach(lnbh24_attach,
667 fe0->dvb.frontend,
668 &i2c_bus->i2c_adap,
669 LNBH24_PCL, 0, 0x09))
670 printk(KERN_ERR
671 "No LNBH24 found!\n");
672
673 }
674 }
675 break;
676 /* port C */
677 case 2:
678 fe0->dvb.frontend = dvb_attach(stv0900_attach,
679 &netup_stv0900_config,
680 &i2c_bus->i2c_adap, 1);
681 if (fe0->dvb.frontend != NULL) {
682 if (dvb_attach(stv6110_attach,
683 fe0->dvb.frontend,
684 &netup_stv6110_tunerconfig_b,
685 &i2c_bus->i2c_adap)) {
686 if (!dvb_attach(lnbh24_attach,
687 fe0->dvb.frontend,
688 &i2c_bus->i2c_adap,
689 LNBH24_PCL, 0, 0x0a))
690 printk(KERN_ERR
691 "No LNBH24 found!\n");
692
693 }
694 }
695 break;
696 }
697 break;
Steven Tothd19770e2007-03-11 20:44:05 -0300698 default:
Steven Toth9c8ced52008-10-16 20:18:44 -0300699 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
700 " isn't supported yet\n",
Steven Tothd19770e2007-03-11 20:44:05 -0300701 dev->name);
702 break;
703 }
Steven Toth363c35f2008-10-11 11:05:50 -0300704 if (NULL == fe0->dvb.frontend) {
Steven Toth9c8ced52008-10-16 20:18:44 -0300705 printk(KERN_ERR "%s: frontend initialization failed\n",
706 dev->name);
Steven Tothd19770e2007-03-11 20:44:05 -0300707 return -1;
708 }
Michael Krufkyd7cba042008-09-12 13:31:45 -0300709 /* define general-purpose callback pointer */
Steven Toth363c35f2008-10-11 11:05:50 -0300710 fe0->dvb.frontend->callback = cx23885_tuner_callback;
Steven Tothd19770e2007-03-11 20:44:05 -0300711
712 /* Put the analog decoder in standby to keep it quiet */
Hans Verkuil7c9fc9d2009-04-01 03:49:59 -0300713 call_all(dev, tuner, s_standby);
Steven Tothd19770e2007-03-11 20:44:05 -0300714
Steven Toth363c35f2008-10-11 11:05:50 -0300715 if (fe0->dvb.frontend->ops.analog_ops.standby)
716 fe0->dvb.frontend->ops.analog_ops.standby(fe0->dvb.frontend);
Michael Krufky3ba71d22007-12-07 01:40:36 -0300717
Steven Tothd19770e2007-03-11 20:44:05 -0300718 /* register everything */
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300719 ret = videobuf_dvb_register_bus(&port->frontends, THIS_MODULE, port,
Darron Broad59b18422008-10-11 11:44:05 -0300720 &dev->pci->dev, adapter_nr, 0);
Steven Toth363c35f2008-10-11 11:05:50 -0300721
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300722 /* init CI & MAC */
723 switch (dev->board) {
724 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI: {
725 static struct netup_card_info cinfo;
726
727 netup_get_card_info(&dev->i2c_bus[0].i2c_adap, &cinfo);
728 memcpy(port->frontends.adapter.proposed_mac,
729 cinfo.port[port->nr - 1].mac, 6);
730 printk(KERN_INFO "NetUP Dual DVB-S2 CI card port%d MAC="
731 "%02X:%02X:%02X:%02X:%02X:%02X\n",
732 port->nr,
733 port->frontends.adapter.proposed_mac[0],
734 port->frontends.adapter.proposed_mac[1],
735 port->frontends.adapter.proposed_mac[2],
736 port->frontends.adapter.proposed_mac[3],
737 port->frontends.adapter.proposed_mac[4],
738 port->frontends.adapter.proposed_mac[5]);
739
740 netup_ci_init(port);
741 break;
742 }
743 }
744
745 return ret;
Steven Tothd19770e2007-03-11 20:44:05 -0300746}
747
748int cx23885_dvb_register(struct cx23885_tsport *port)
749{
Steven Toth363c35f2008-10-11 11:05:50 -0300750
751 struct videobuf_dvb_frontend *fe0;
Steven Tothd19770e2007-03-11 20:44:05 -0300752 struct cx23885_dev *dev = port->dev;
Steven Totheb0c58b2008-10-11 12:34:39 -0300753 int err, i;
Steven Tothd19770e2007-03-11 20:44:05 -0300754
Steven Totheb0c58b2008-10-11 12:34:39 -0300755 /* Here we need to allocate the correct number of frontends,
756 * as reflected in the cards struct. The reality is that currrently
757 * no cx23885 boards support this - yet. But, if we don't modify this
758 * code then the second frontend would never be allocated (later)
759 * and fail with error before the attach in dvb_register().
760 * Without these changes we risk an OOPS later. The changes here
761 * are for safety, and should provide a good foundation for the
762 * future addition of any multi-frontend cx23885 based boards.
763 */
764 printk(KERN_INFO "%s() allocating %d frontend(s)\n", __func__,
765 port->num_frontends);
Steven Toth363c35f2008-10-11 11:05:50 -0300766
Steven Totheb0c58b2008-10-11 12:34:39 -0300767 for (i = 1; i <= port->num_frontends; i++) {
Darron Broad96b7a1a2008-10-15 20:26:34 -0300768 if (videobuf_dvb_alloc_frontend(
Steven Toth9c8ced52008-10-16 20:18:44 -0300769 &port->frontends, i) == NULL) {
Steven Totheb0c58b2008-10-11 12:34:39 -0300770 printk(KERN_ERR "%s() failed to alloc\n", __func__);
771 return -ENOMEM;
772 }
Steven Tothd19770e2007-03-11 20:44:05 -0300773
Steven Totheb0c58b2008-10-11 12:34:39 -0300774 fe0 = videobuf_dvb_get_frontend(&port->frontends, i);
775 if (!fe0)
776 err = -EINVAL;
Steven Tothd19770e2007-03-11 20:44:05 -0300777
Steven Totheb0c58b2008-10-11 12:34:39 -0300778 dprintk(1, "%s\n", __func__);
Steven Toth9c8ced52008-10-16 20:18:44 -0300779 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
Steven Totheb0c58b2008-10-11 12:34:39 -0300780 dev->board,
781 dev->name,
782 dev->pci_bus,
783 dev->pci_slot);
784
785 err = -ENODEV;
786
787 /* dvb stuff */
788 /* We have to init the queue for each frontend on a port. */
Steven Toth9c8ced52008-10-16 20:18:44 -0300789 printk(KERN_INFO "%s: cx23885 based dvb card\n", dev->name);
790 videobuf_queue_sg_init(&fe0->dvb.dvbq, &dvb_qops,
791 &dev->pci->dev, &port->slock,
Michael Krufky44a64812007-03-20 23:00:18 -0300792 V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_TOP,
793 sizeof(struct cx23885_buffer), port);
Steven Totheb0c58b2008-10-11 12:34:39 -0300794 }
Steven Tothd19770e2007-03-11 20:44:05 -0300795 err = dvb_register(port);
796 if (err != 0)
Steven Toth9c8ced52008-10-16 20:18:44 -0300797 printk(KERN_ERR "%s() dvb_register failed err = %d\n",
798 __func__, err);
Steven Tothd19770e2007-03-11 20:44:05 -0300799
Steven Tothd19770e2007-03-11 20:44:05 -0300800 return err;
801}
802
803int cx23885_dvb_unregister(struct cx23885_tsport *port)
804{
Steven Toth363c35f2008-10-11 11:05:50 -0300805 struct videobuf_dvb_frontend *fe0;
806
Steven Totheb0c58b2008-10-11 12:34:39 -0300807 /* FIXME: in an error condition where the we have
808 * an expected number of frontends (attach problem)
809 * then this might not clean up correctly, if 1
810 * is invalid.
811 * This comment only applies to future boards IF they
812 * implement MFE support.
813 */
Darron Broad92abe9e2008-10-11 11:18:53 -0300814 fe0 = videobuf_dvb_get_frontend(&port->frontends, 1);
Steven Toth9c8ced52008-10-16 20:18:44 -0300815 if (fe0->dvb.frontend)
Steven Toth363c35f2008-10-11 11:05:50 -0300816 videobuf_dvb_unregister_bus(&port->frontends);
Steven Tothd19770e2007-03-11 20:44:05 -0300817
Hans Verkuilafd96662009-03-13 13:24:19 -0300818 switch (port->dev->board) {
819 case CX23885_BOARD_NETUP_DUAL_DVBS2_CI:
820 netup_ci_exit(port);
821 break;
822 }
Igor M. Liplianin5a23b072009-03-03 12:06:09 -0300823
Steven Tothd19770e2007-03-11 20:44:05 -0300824 return 0;
825}
Michael Krufky44a64812007-03-20 23:00:18 -0300826