blob: ec8516ac810505d37e62198c78ca3d74a0ef6bb4 [file] [log] [blame]
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001/* DVB USB compliant linux driver for Conexant USB reference design.
2 *
3 * The Conexant reference design I saw on their website was only for analogue
4 * capturing (using the cx25842). The box I took to write this driver (reverse
5 * engineered) is the one labeled Medion MD95700. In addition to the cx25842
6 * for analogue capturing it also has a cx22702 DVB-T demodulator on the main
7 * board. Besides it has a atiremote (X10) and a USB2.0 hub onboard.
8 *
9 * Maybe it is a little bit premature to call this driver cxusb, but I assume
10 * the USB protocol is identical or at least inherited from the reference
11 * design, so it can be reused for the "analogue-only" device (if it will
12 * appear at all).
13 *
Michael Krufky81481e92006-01-09 18:21:38 -020014 * TODO: Use the cx25840-driver for the analogue part
Patrick Boettcher22c6d932005-07-07 17:58:10 -070015 *
Patrick Boettcher22c6d932005-07-07 17:58:10 -070016 * Copyright (C) 2005 Patrick Boettcher (patrick.boettcher@desy.de)
Michael Krufky5b9ed282006-10-15 14:51:08 -030017 * Copyright (C) 2006 Michael Krufky (mkrufky@linuxtv.org)
Chris Pascoeaeb012b2007-11-19 21:57:10 -030018 * Copyright (C) 2006, 2007 Chris Pascoe (c.pascoe@itee.uq.edu.au)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070019 *
Michael Krufkyf35db232006-12-05 14:53:39 -030020 * This program is free software; you can redistribute it and/or modify it
21 * under the terms of the GNU General Public License as published by the Free
22 * Software Foundation, version 2.
Patrick Boettcher22c6d932005-07-07 17:58:10 -070023 *
24 * see Documentation/dvb/README.dvb-usb for more information
25 */
26#include "cxusb.h"
27
28#include "cx22702.h"
Michael Krufkyeffee032006-01-09 15:25:47 -020029#include "lgdt330x.h"
Chris Pascoe0029ee12006-01-09 18:21:28 -020030#include "mt352.h"
31#include "mt352_priv.h"
Michael Krufkyc9ce3942006-06-11 04:24:31 -030032#include "zl10353.h"
Chris Pascoeaeb012b2007-11-19 21:57:10 -030033#include "tuner-xc2028.h"
34#include "tuner-xc2028-types.h"
Patrick Boettcher22c6d932005-07-07 17:58:10 -070035
36/* debug */
Adrian Bunk53133af2007-11-05 14:07:06 -030037static int dvb_usb_cxusb_debug;
Michael Krufkyf35db232006-12-05 14:53:39 -030038module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070039MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
Adrian Bunk53133af2007-11-05 14:07:06 -030040#define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
41#define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
42 dprintk(dvb_usb_cxusb_debug,0x01,args)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070043
44static int cxusb_ctrl_msg(struct dvb_usb_device *d,
Michael Krufkyf35db232006-12-05 14:53:39 -030045 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070046{
47 int wo = (rbuf == NULL || rlen == 0); /* write-only */
48 u8 sndbuf[1+wlen];
Michael Krufkyf35db232006-12-05 14:53:39 -030049 memset(sndbuf, 0, 1+wlen);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070050
51 sndbuf[0] = cmd;
Michael Krufkyf35db232006-12-05 14:53:39 -030052 memcpy(&sndbuf[1], wbuf, wlen);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070053 if (wo)
Chris Pascoeb17f1092007-11-19 02:42:44 -030054 return dvb_usb_generic_write(d, sndbuf, 1+wlen);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070055 else
Chris Pascoeb17f1092007-11-19 02:42:44 -030056 return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070057}
58
Patrick Boettchere2efeab2005-09-09 13:02:51 -070059/* GPIO */
60static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070061{
62 struct cxusb_state *st = d->priv;
Michael Krufkyf35db232006-12-05 14:53:39 -030063 u8 o[2], i;
Patrick Boettcher22c6d932005-07-07 17:58:10 -070064
Patrick Boettchere2efeab2005-09-09 13:02:51 -070065 if (st->gpio_write_state[GPIO_TUNER] == onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070066 return;
67
Patrick Boettchere2efeab2005-09-09 13:02:51 -070068 o[0] = GPIO_TUNER;
69 o[1] = onoff;
Michael Krufkyf35db232006-12-05 14:53:39 -030070 cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070071
72 if (i != 0x01)
Patrick Boettchere2efeab2005-09-09 13:02:51 -070073 deb_info("gpio_write failed.\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -070074
Patrick Boettchere2efeab2005-09-09 13:02:51 -070075 st->gpio_write_state[GPIO_TUNER] = onoff;
Patrick Boettcher22c6d932005-07-07 17:58:10 -070076}
77
Chris Pascoeaeb012b2007-11-19 21:57:10 -030078static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
79 u8 newval)
80{
81 u8 o[2], gpio_state;
82 int rc;
83
84 o[0] = 0xff & ~changemask; /* mask of bits to keep */
85 o[1] = newval & changemask; /* new values for bits */
86
87 rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
88 if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
89 deb_info("bluebird_gpio_write failed.\n");
90
91 return rc < 0 ? rc : gpio_state;
92}
93
94static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
95{
96 cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
97 msleep(5);
98 cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
99}
100
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700101/* I2C */
Michael Krufkyf35db232006-12-05 14:53:39 -0300102static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
103 int num)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700104{
105 struct dvb_usb_device *d = i2c_get_adapdata(adap);
106 int i;
107
Ingo Molnar3593cab2006-02-07 06:49:14 -0200108 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700109 return -EAGAIN;
110
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700111 for (i = 0; i < num; i++) {
112
Michael Krufky5e805ef2006-03-23 00:01:34 -0300113 if (d->udev->descriptor.idVendor == USB_VID_MEDION)
114 switch (msg[i].addr) {
Michael Krufkyf35db232006-12-05 14:53:39 -0300115 case 0x63:
116 cxusb_gpio_tuner(d, 0);
117 break;
118 default:
119 cxusb_gpio_tuner(d, 1);
120 break;
Michael Krufky5e805ef2006-03-23 00:01:34 -0300121 }
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700122
Chris Pascoe272479d72007-11-19 03:01:22 -0300123 if (msg[i].flags & I2C_M_RD) {
124 /* read only */
125 u8 obuf[3], ibuf[1+msg[i].len];
126 obuf[0] = 0;
127 obuf[1] = msg[i].len;
128 obuf[2] = msg[i].addr;
129 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
130 obuf, 3,
131 ibuf, 1+msg[i].len) < 0) {
132 warn("i2c read failed");
133 break;
134 }
135 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
Chris Pascoea644e4a2007-11-19 03:05:09 -0300136 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
137 msg[i].addr == msg[i+1].addr) {
138 /* write to then read from same address */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700139 u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
140 obuf[0] = msg[i].len;
141 obuf[1] = msg[i+1].len;
142 obuf[2] = msg[i].addr;
Michael Krufkyf35db232006-12-05 14:53:39 -0300143 memcpy(&obuf[3], msg[i].buf, msg[i].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700144
145 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
Michael Krufkyf35db232006-12-05 14:53:39 -0300146 obuf, 3+msg[i].len,
147 ibuf, 1+msg[i+1].len) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700148 break;
149
150 if (ibuf[0] != 0x08)
Michael Krufkyae62e3d2006-03-23 01:11:18 -0300151 deb_i2c("i2c read may have failed\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700152
Michael Krufkyf35db232006-12-05 14:53:39 -0300153 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700154
155 i++;
Chris Pascoe272479d72007-11-19 03:01:22 -0300156 } else {
157 /* write only */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700158 u8 obuf[2+msg[i].len], ibuf;
159 obuf[0] = msg[i].addr;
160 obuf[1] = msg[i].len;
Michael Krufkyf35db232006-12-05 14:53:39 -0300161 memcpy(&obuf[2], msg[i].buf, msg[i].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700162
Michael Krufkyf35db232006-12-05 14:53:39 -0300163 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
164 2+msg[i].len, &ibuf,1) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700165 break;
166 if (ibuf != 0x08)
Michael Krufkyae62e3d2006-03-23 01:11:18 -0300167 deb_i2c("i2c write may have failed\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700168 }
169 }
170
Ingo Molnar3593cab2006-02-07 06:49:14 -0200171 mutex_unlock(&d->i2c_mutex);
Chris Pascoe13e001d2007-11-19 02:48:27 -0300172 return i == num ? num : -EREMOTEIO;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700173}
174
175static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
176{
177 return I2C_FUNC_I2C;
178}
179
180static struct i2c_algorithm cxusb_i2c_algo = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700181 .master_xfer = cxusb_i2c_xfer,
182 .functionality = cxusb_i2c_func,
183};
184
185static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
186{
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700187 u8 b = 0;
188 if (onoff)
189 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
190 else
191 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700192}
193
Michael Krufky5691c842006-04-19 20:40:01 -0300194static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
195{
196 u8 b = 0;
197 if (onoff)
198 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
199 else
200 return 0;
201}
202
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300203static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700204{
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700205 u8 buf[2] = { 0x03, 0x00 };
206 if (onoff)
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300207 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700208 else
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300209 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700210
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700211 return 0;
212}
213
Chris Pascoe7c239702006-01-09 18:21:29 -0200214static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
215{
216 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
Michael Krufkya07e6092006-01-09 18:21:31 -0200217 u8 ircode[4];
Chris Pascoe7c239702006-01-09 18:21:29 -0200218 int i;
219
Michael Krufkya07e6092006-01-09 18:21:31 -0200220 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
Chris Pascoe7c239702006-01-09 18:21:29 -0200221
222 *event = 0;
223 *state = REMOTE_NO_KEY_PRESSED;
224
225 for (i = 0; i < d->props.rc_key_map_size; i++) {
Michael Krufkya07e6092006-01-09 18:21:31 -0200226 if (keymap[i].custom == ircode[2] &&
227 keymap[i].data == ircode[3]) {
Chris Pascoe7c239702006-01-09 18:21:29 -0200228 *event = keymap[i].event;
229 *state = REMOTE_KEY_PRESSED;
230
231 return 0;
232 }
233 }
234
235 return 0;
236}
237
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300238static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
239 int *state)
240{
241 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
242 u8 ircode[4];
243 int i;
244 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
245 .buf = ircode, .len = 4 };
246
247 *event = 0;
248 *state = REMOTE_NO_KEY_PRESSED;
249
250 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
251 return 0;
252
253 for (i = 0; i < d->props.rc_key_map_size; i++) {
254 if (keymap[i].custom == ircode[1] &&
255 keymap[i].data == ircode[2]) {
256 *event = keymap[i].event;
257 *state = REMOTE_KEY_PRESSED;
258
259 return 0;
260 }
261 }
262
263 return 0;
264}
265
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200266static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
Michael Krufkya07e6092006-01-09 18:21:31 -0200267 { 0xfe, 0x02, KEY_TV },
268 { 0xfe, 0x0e, KEY_MP3 },
269 { 0xfe, 0x1a, KEY_DVD },
270 { 0xfe, 0x1e, KEY_FAVORITES },
271 { 0xfe, 0x16, KEY_SETUP },
272 { 0xfe, 0x46, KEY_POWER2 },
273 { 0xfe, 0x0a, KEY_EPG },
274 { 0xfe, 0x49, KEY_BACK },
275 { 0xfe, 0x4d, KEY_MENU },
276 { 0xfe, 0x51, KEY_UP },
277 { 0xfe, 0x5b, KEY_LEFT },
278 { 0xfe, 0x5f, KEY_RIGHT },
279 { 0xfe, 0x53, KEY_DOWN },
280 { 0xfe, 0x5e, KEY_OK },
281 { 0xfe, 0x59, KEY_INFO },
282 { 0xfe, 0x55, KEY_TAB },
283 { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
284 { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */
285 { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */
286 { 0xfe, 0x15, KEY_VOLUMEUP },
287 { 0xfe, 0x05, KEY_VOLUMEDOWN },
288 { 0xfe, 0x11, KEY_CHANNELUP },
289 { 0xfe, 0x09, KEY_CHANNELDOWN },
290 { 0xfe, 0x52, KEY_CAMERA },
291 { 0xfe, 0x5a, KEY_TUNER }, /* Live */
292 { 0xfe, 0x19, KEY_OPEN },
293 { 0xfe, 0x0b, KEY_1 },
294 { 0xfe, 0x17, KEY_2 },
295 { 0xfe, 0x1b, KEY_3 },
296 { 0xfe, 0x07, KEY_4 },
297 { 0xfe, 0x50, KEY_5 },
298 { 0xfe, 0x54, KEY_6 },
299 { 0xfe, 0x48, KEY_7 },
300 { 0xfe, 0x4c, KEY_8 },
301 { 0xfe, 0x58, KEY_9 },
302 { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */
303 { 0xfe, 0x03, KEY_0 },
304 { 0xfe, 0x1f, KEY_ZOOM },
305 { 0xfe, 0x43, KEY_REWIND },
306 { 0xfe, 0x47, KEY_PLAYPAUSE },
307 { 0xfe, 0x4f, KEY_FASTFORWARD },
308 { 0xfe, 0x57, KEY_MUTE },
309 { 0xfe, 0x0d, KEY_STOP },
310 { 0xfe, 0x01, KEY_RECORD },
311 { 0xfe, 0x4e, KEY_POWER },
312};
313
Michael Krufkyc1501782006-03-26 05:43:36 -0300314static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
315 { 0xfc, 0x02, KEY_SETUP }, /* Profile */
316 { 0xfc, 0x43, KEY_POWER2 },
317 { 0xfc, 0x06, KEY_EPG },
318 { 0xfc, 0x5a, KEY_BACK },
319 { 0xfc, 0x05, KEY_MENU },
320 { 0xfc, 0x47, KEY_INFO },
321 { 0xfc, 0x01, KEY_TAB },
322 { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
323 { 0xfc, 0x49, KEY_VOLUMEUP },
324 { 0xfc, 0x09, KEY_VOLUMEDOWN },
325 { 0xfc, 0x54, KEY_CHANNELUP },
326 { 0xfc, 0x0b, KEY_CHANNELDOWN },
Michael Krufkydbcb86e2006-03-26 18:59:45 -0300327 { 0xfc, 0x16, KEY_CAMERA },
Michael Krufkyc1501782006-03-26 05:43:36 -0300328 { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */
329 { 0xfc, 0x45, KEY_OPEN },
330 { 0xfc, 0x19, KEY_1 },
331 { 0xfc, 0x18, KEY_2 },
332 { 0xfc, 0x1b, KEY_3 },
333 { 0xfc, 0x1a, KEY_4 },
334 { 0xfc, 0x58, KEY_5 },
335 { 0xfc, 0x59, KEY_6 },
336 { 0xfc, 0x15, KEY_7 },
337 { 0xfc, 0x14, KEY_8 },
338 { 0xfc, 0x17, KEY_9 },
339 { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */
340 { 0xfc, 0x55, KEY_0 },
341 { 0xfc, 0x07, KEY_ZOOM },
342 { 0xfc, 0x0a, KEY_REWIND },
343 { 0xfc, 0x08, KEY_PLAYPAUSE },
344 { 0xfc, 0x4b, KEY_FASTFORWARD },
345 { 0xfc, 0x5b, KEY_MUTE },
346 { 0xfc, 0x04, KEY_STOP },
347 { 0xfc, 0x56, KEY_RECORD },
348 { 0xfc, 0x57, KEY_POWER },
349 { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */
350 { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
351};
352
Chris Pascoe0029ee12006-01-09 18:21:28 -0200353static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
354{
Chris Pascoed9ed8812006-02-07 06:49:11 -0200355 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
Chris Pascoe0029ee12006-01-09 18:21:28 -0200356 static u8 reset [] = { RESET, 0x80 };
357 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
358 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
359 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
360 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
361
362 mt352_write(fe, clock_config, sizeof(clock_config));
363 udelay(200);
364 mt352_write(fe, reset, sizeof(reset));
365 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
366
367 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
368 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
369 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
370
371 return 0;
372}
373
Michael Krufky6f447252006-01-11 19:40:33 -0200374static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
375{ /* used in both lgz201 and th7579 */
Michael Krufkyfb51fd22006-02-07 06:49:12 -0200376 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
Michael Krufky6f447252006-01-11 19:40:33 -0200377 static u8 reset [] = { RESET, 0x80 };
378 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
379 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
380 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
381 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
382
383 mt352_write(fe, clock_config, sizeof(clock_config));
384 udelay(200);
385 mt352_write(fe, reset, sizeof(reset));
386 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
387
388 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
389 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
390 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
391 return 0;
392}
393
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200394static struct cx22702_config cxusb_cx22702_config = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700395 .demod_address = 0x63,
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700396 .output_mode = CX22702_PARALLEL_OUTPUT,
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700397};
398
Michael Krufkyfddd6322006-02-27 00:08:17 -0300399static struct lgdt330x_config cxusb_lgdt3303_config = {
Michael Krufkyeffee032006-01-09 15:25:47 -0200400 .demod_address = 0x0e,
401 .demod_chip = LGDT3303,
Michael Krufkyeffee032006-01-09 15:25:47 -0200402};
403
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200404static struct mt352_config cxusb_dee1601_config = {
Chris Pascoe0029ee12006-01-09 18:21:28 -0200405 .demod_address = 0x0f,
406 .demod_init = cxusb_dee1601_demod_init,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200407};
408
Michael Krufkyc9ce3942006-06-11 04:24:31 -0300409static struct zl10353_config cxusb_zl10353_dee1601_config = {
410 .demod_address = 0x0f,
Chris Pascoe8fb95782006-08-10 03:17:16 -0300411 .parallel_ts = 1,
Michael Krufkyc9ce3942006-06-11 04:24:31 -0300412};
413
Adrian Bunk6fe00b02006-04-19 20:49:28 -0300414static struct mt352_config cxusb_mt352_config = {
Michael Krufky6f447252006-01-11 19:40:33 -0200415 /* used in both lgz201 and th7579 */
416 .demod_address = 0x0f,
417 .demod_init = cxusb_mt352_demod_init,
Michael Krufky6f447252006-01-11 19:40:33 -0200418};
419
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300420static struct zl10353_config cxusb_zl10353_xc3028_config = {
421 .demod_address = 0x0f,
422 .if2 = 4560,
423 .no_tuner = 1,
424 .parallel_ts = 1,
425};
426
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700427/* Callbacks for DVB USB */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300428static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700429{
Trent Piephob7754d72007-05-08 18:05:16 -0300430 dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300431 DVB_PLL_FMD1216ME);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700432 return 0;
433}
434
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300435static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200436{
Michael Krufky79a54cb2006-12-05 14:20:06 -0300437 dvb_attach(dvb_pll_attach, adap->fe, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300438 NULL, DVB_PLL_THOMSON_DTT7579);
Chris Pascoe0029ee12006-01-09 18:21:28 -0200439 return 0;
440}
441
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300442static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky6f447252006-01-11 19:40:33 -0200443{
Michael Krufky47a99912007-06-12 16:10:51 -0300444 dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
Michael Krufky6f447252006-01-11 19:40:33 -0200445 return 0;
446}
447
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300448static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky6f447252006-01-11 19:40:33 -0200449{
Michael Krufky79a54cb2006-12-05 14:20:06 -0300450 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300451 NULL, DVB_PLL_THOMSON_DTT7579);
Patrick Boettcher332bed52006-05-14 04:49:00 -0300452 return 0;
453}
454
Michael Krufkyf71a56c2006-10-13 21:55:57 -0300455static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher332bed52006-05-14 04:49:00 -0300456{
Trent Piepho6bdcc6e2007-04-27 12:31:30 -0300457 dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300458 DVB_PLL_LG_TDVS_H06XF);
Michael Krufky6f447252006-01-11 19:40:33 -0200459 return 0;
460}
461
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300462static int dvico_bluebird_xc2028_callback(void *ptr, int command, int arg)
463{
464 struct dvb_usb_device *d = ptr;
465
466 switch (command) {
467 case XC2028_TUNER_RESET:
468 deb_info("%s: XC2028_TUNER_RESET %d\n", __FUNCTION__, arg);
469 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
470 break;
471 case XC2028_RESET_CLK:
472 deb_info("%s: XC2028_RESET_CLK %d\n", __FUNCTION__, arg);
473 break;
474 default:
475 deb_info("%s: unknown command %d, arg %d\n", __FUNCTION__,
476 command, arg);
477 return -EINVAL;
478 }
479
480 return 0;
481}
482
483static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
484{
485 struct dvb_frontend *fe;
486 struct xc2028_config cfg = {
487 .i2c_adap = &adap->dev->i2c_adap,
488 .i2c_addr = 0x61,
489 .video_dev = adap->dev,
490 .callback = dvico_bluebird_xc2028_callback,
491 };
492 static struct xc2028_ctrl ctl = {
493 .type = XC2028_FIRM_NORMAL,
494 .fname = "xc3028-dvico-au-01.fw",
495 .max_len = 64,
496 .scode_table = ZARLINK456,
497 };
498
499 fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
500 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
501 return -EIO;
502
503 fe->ops.tuner_ops.set_config(fe, &ctl);
504
505 return 0;
506}
507
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300508static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700509{
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700510 u8 b;
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300511 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700512 err("set interface failed");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700513
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300514 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700515
Michael Krufkyf35db232006-12-05 14:53:39 -0300516 if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
517 &adap->dev->i2c_adap)) != NULL)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700518 return 0;
519
520 return -EIO;
521}
522
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300523static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufkyeffee032006-01-09 15:25:47 -0200524{
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300525 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
Michael Krufkyeffee032006-01-09 15:25:47 -0200526 err("set interface failed");
527
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300528 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
Michael Krufkyeffee032006-01-09 15:25:47 -0200529
Michael Krufkyf35db232006-12-05 14:53:39 -0300530 if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
531 &adap->dev->i2c_adap)) != NULL)
Michael Krufkyeffee032006-01-09 15:25:47 -0200532 return 0;
533
534 return -EIO;
535}
536
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300537static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200538{
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300539 /* used in both lgz201 and th7579 */
540 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200541 err("set interface failed");
542
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300543 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
Chris Pascoe0029ee12006-01-09 18:21:28 -0200544
Michael Krufkyf35db232006-12-05 14:53:39 -0300545 if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
546 &adap->dev->i2c_adap)) != NULL)
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300547 return 0;
548
549 return -EIO;
550}
551
552static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
553{
554 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
555 err("set interface failed");
556
557 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
558
Michael Krufkyf35db232006-12-05 14:53:39 -0300559 if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
560 &adap->dev->i2c_adap)) != NULL) ||
561 ((adap->fe = dvb_attach(zl10353_attach,
562 &cxusb_zl10353_dee1601_config,
563 &adap->dev->i2c_adap)) != NULL))
Chris Pascoe0029ee12006-01-09 18:21:28 -0200564 return 0;
565
566 return -EIO;
567}
568
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300569static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
570{
571 u8 ircode[4];
572 int i;
573 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
574 .buf = ircode, .len = 4 };
575
576 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
577 err("set interface failed");
578
579 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
580
581 /* reset the tuner and demodulator */
582 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
583 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
584 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
585
586 if ((adap->fe = dvb_attach(zl10353_attach,
587 &cxusb_zl10353_xc3028_config,
588 &adap->dev->i2c_adap)) == NULL)
589 return -EIO;
590
591 /* try to determine if there is no IR decoder on the I2C bus */
592 for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
593 msleep(20);
594 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
595 goto no_IR;
596 if (ircode[0] == 0 && ircode[1] == 0)
597 continue;
598 if (ircode[2] + ircode[3] != 0xff) {
599no_IR:
600 adap->dev->props.rc_key_map = NULL;
601 info("No IR receiver detected on this device.");
602 break;
603 }
604 }
605
606 return 0;
607}
608
Patrick Boettcherf5373782006-01-09 18:21:38 -0200609/*
610 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
611 * firmware file before download.
612 */
613
614#define BLUEBIRD_01_ID_OFFSET 6638
Michael Krufkyf35db232006-12-05 14:53:39 -0300615static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
616 const struct firmware *fw)
Patrick Boettcherf5373782006-01-09 18:21:38 -0200617{
618 if (fw->size < BLUEBIRD_01_ID_OFFSET + 4)
619 return -EINVAL;
620
621 if (fw->data[BLUEBIRD_01_ID_OFFSET] == (USB_VID_DVICO & 0xff) &&
622 fw->data[BLUEBIRD_01_ID_OFFSET + 1] == USB_VID_DVICO >> 8) {
623
Michael Krufkyf35db232006-12-05 14:53:39 -0300624 fw->data[BLUEBIRD_01_ID_OFFSET + 2] =
Jin-Bong lee1d1370a2007-02-20 23:10:34 -0300625 le16_to_cpu(udev->descriptor.idProduct) + 1;
Michael Krufkyf35db232006-12-05 14:53:39 -0300626 fw->data[BLUEBIRD_01_ID_OFFSET + 3] =
Jin-Bong lee1d1370a2007-02-20 23:10:34 -0300627 le16_to_cpu(udev->descriptor.idProduct) >> 8;
Patrick Boettcherf5373782006-01-09 18:21:38 -0200628
Michael Krufkyf35db232006-12-05 14:53:39 -0300629 return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
Patrick Boettcherf5373782006-01-09 18:21:38 -0200630 }
631
632 return -EINVAL;
633}
634
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700635/* DVB USB Driver stuff */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300636static struct dvb_usb_device_properties cxusb_medion_properties;
637static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
638static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
639static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
640static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300641static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700642
643static int cxusb_probe(struct usb_interface *intf,
Michael Krufkyf35db232006-12-05 14:53:39 -0300644 const struct usb_device_id *id)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700645{
Michael Krufkyeffee032006-01-09 15:25:47 -0200646 if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 ||
Chris Pascoe0029ee12006-01-09 18:21:28 -0200647 dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 ||
Michael Krufky6f447252006-01-11 19:40:33 -0200648 dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 ||
649 dvb_usb_device_init(intf,&cxusb_bluebird_lgz201_properties,THIS_MODULE,NULL) == 0 ||
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300650 dvb_usb_device_init(intf,&cxusb_bluebird_dtt7579_properties,THIS_MODULE,NULL) == 0 ||
651 dvb_usb_device_init(intf,&cxusb_bluebird_dualdig4_properties,THIS_MODULE,NULL) == 0) {
Michael Krufkyeffee032006-01-09 15:25:47 -0200652 return 0;
653 }
654
655 return -EINVAL;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700656}
657
658static struct usb_device_id cxusb_table [] = {
Michael Krufkyf35db232006-12-05 14:53:39 -0300659 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
660 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
661 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
662 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
663 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
664 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
665 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
666 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
667 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
668 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
669 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
670 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
671 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300672 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
Michael Krufkyf35db232006-12-05 14:53:39 -0300673 {} /* Terminating entry */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700674};
675MODULE_DEVICE_TABLE (usb, cxusb_table);
676
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300677static struct dvb_usb_device_properties cxusb_medion_properties = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700678 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
679
680 .usb_ctrl = CYPRESS_FX2,
681
682 .size_of_priv = sizeof(struct cxusb_state),
683
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300684 .num_adapters = 1,
685 .adapter = {
686 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300687 .streaming_ctrl = cxusb_streaming_ctrl,
688 .frontend_attach = cxusb_cx22702_frontend_attach,
689 .tuner_attach = cxusb_fmd1216me_tuner_attach,
690 /* parameter for the MPEG2-data transfer */
691 .stream = {
692 .type = USB_BULK,
693 .count = 5,
694 .endpoint = 0x02,
695 .u = {
696 .bulk = {
697 .buffersize = 8192,
698 }
699 }
700 },
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700701
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300702 },
703 },
704 .power_ctrl = cxusb_power_ctrl,
705
706 .i2c_algo = &cxusb_i2c_algo,
707
708 .generic_bulk_ctrl_endpoint = 0x01,
709
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700710 .num_device_descs = 1,
711 .devices = {
712 { "Medion MD95700 (MDUSBTV-HYBRID)",
713 { NULL },
714 { &cxusb_table[0], NULL },
715 },
716 }
717};
718
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300719static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
Michael Krufkyeffee032006-01-09 15:25:47 -0200720 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
721
Patrick Boettcherf5373782006-01-09 18:21:38 -0200722 .usb_ctrl = DEVICE_SPECIFIC,
723 .firmware = "dvb-usb-bluebird-01.fw",
724 .download_firmware = bluebird_patch_dvico_firmware_download,
Michael Krufky37bdfa02006-01-09 15:25:47 -0200725 /* use usb alt setting 0 for EP4 transfer (dvb-t),
726 use usb alt setting 7 for EP2 transfer (atsc) */
Michael Krufkyeffee032006-01-09 15:25:47 -0200727
728 .size_of_priv = sizeof(struct cxusb_state),
729
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300730 .num_adapters = 1,
731 .adapter = {
732 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300733 .streaming_ctrl = cxusb_streaming_ctrl,
734 .frontend_attach = cxusb_lgdt3303_frontend_attach,
Michael Krufkyf71a56c2006-10-13 21:55:57 -0300735 .tuner_attach = cxusb_lgh064f_tuner_attach,
Michael Krufkyeffee032006-01-09 15:25:47 -0200736
Patrick Boettcher01451e72006-10-13 11:34:46 -0300737 /* parameter for the MPEG2-data transfer */
738 .stream = {
739 .type = USB_BULK,
740 .count = 5,
741 .endpoint = 0x02,
742 .u = {
743 .bulk = {
744 .buffersize = 8192,
745 }
746 }
747 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300748 },
749 },
750
751 .power_ctrl = cxusb_bluebird_power_ctrl,
752
Michael Krufkyeffee032006-01-09 15:25:47 -0200753 .i2c_algo = &cxusb_i2c_algo,
754
Michael Krufkyc1501782006-03-26 05:43:36 -0300755 .rc_interval = 100,
756 .rc_key_map = dvico_portable_rc_keys,
757 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
758 .rc_query = cxusb_rc_query,
759
Michael Krufkyeffee032006-01-09 15:25:47 -0200760 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufkyeffee032006-01-09 15:25:47 -0200761
762 .num_device_descs = 1,
763 .devices = {
764 { "DViCO FusionHDTV5 USB Gold",
765 { &cxusb_table[1], NULL },
766 { &cxusb_table[2], NULL },
767 },
768 }
769};
770
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300771static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
Chris Pascoe0029ee12006-01-09 18:21:28 -0200772 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
773
Patrick Boettcherf5373782006-01-09 18:21:38 -0200774 .usb_ctrl = DEVICE_SPECIFIC,
775 .firmware = "dvb-usb-bluebird-01.fw",
776 .download_firmware = bluebird_patch_dvico_firmware_download,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200777 /* use usb alt setting 0 for EP4 transfer (dvb-t),
778 use usb alt setting 7 for EP2 transfer (atsc) */
779
780 .size_of_priv = sizeof(struct cxusb_state),
781
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300782 .num_adapters = 1,
783 .adapter = {
784 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300785 .streaming_ctrl = cxusb_streaming_ctrl,
786 .frontend_attach = cxusb_dee1601_frontend_attach,
787 .tuner_attach = cxusb_dee1601_tuner_attach,
788 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300789 .stream = {
790 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300791 .count = 5,
792 .endpoint = 0x04,
793 .u = {
794 .bulk = {
795 .buffersize = 8192,
796 }
797 }
798 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300799 },
800 },
801
802 .power_ctrl = cxusb_bluebird_power_ctrl,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200803
804 .i2c_algo = &cxusb_i2c_algo,
805
Chris Pascoe7c239702006-01-09 18:21:29 -0200806 .rc_interval = 150,
807 .rc_key_map = dvico_mce_rc_keys,
808 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
809 .rc_query = cxusb_rc_query,
810
Chris Pascoe0029ee12006-01-09 18:21:28 -0200811 .generic_bulk_ctrl_endpoint = 0x01,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200812
Michael Krufky587c03d2006-09-28 02:16:01 -0300813 .num_device_descs = 3,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200814 .devices = {
815 { "DViCO FusionHDTV DVB-T Dual USB",
816 { &cxusb_table[3], NULL },
817 { &cxusb_table[4], NULL },
818 },
Michael Krufkyac9ffb92006-01-11 23:21:00 -0200819 { "DigitalNow DVB-T Dual USB",
820 { &cxusb_table[9], NULL },
821 { &cxusb_table[10], NULL },
822 },
Michael Krufky587c03d2006-09-28 02:16:01 -0300823 { "DViCO FusionHDTV DVB-T Dual Digital 2",
824 { &cxusb_table[11], NULL },
825 { &cxusb_table[12], NULL },
826 },
Chris Pascoe0029ee12006-01-09 18:21:28 -0200827 }
828};
829
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300830static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
Michael Krufky6f447252006-01-11 19:40:33 -0200831 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
832
833 .usb_ctrl = DEVICE_SPECIFIC,
834 .firmware = "dvb-usb-bluebird-01.fw",
835 .download_firmware = bluebird_patch_dvico_firmware_download,
836 /* use usb alt setting 0 for EP4 transfer (dvb-t),
837 use usb alt setting 7 for EP2 transfer (atsc) */
838
839 .size_of_priv = sizeof(struct cxusb_state),
840
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300841 .num_adapters = 2,
842 .adapter = {
843 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300844 .streaming_ctrl = cxusb_streaming_ctrl,
845 .frontend_attach = cxusb_mt352_frontend_attach,
846 .tuner_attach = cxusb_lgz201_tuner_attach,
Michael Krufky6f447252006-01-11 19:40:33 -0200847
Patrick Boettcher01451e72006-10-13 11:34:46 -0300848 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300849 .stream = {
850 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300851 .count = 5,
852 .endpoint = 0x04,
853 .u = {
854 .bulk = {
855 .buffersize = 8192,
856 }
857 }
858 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300859 },
860 },
861 .power_ctrl = cxusb_bluebird_power_ctrl,
862
Michael Krufky6f447252006-01-11 19:40:33 -0200863 .i2c_algo = &cxusb_i2c_algo,
864
Michael Krufkyc1501782006-03-26 05:43:36 -0300865 .rc_interval = 100,
866 .rc_key_map = dvico_portable_rc_keys,
867 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
868 .rc_query = cxusb_rc_query,
869
Michael Krufky6f447252006-01-11 19:40:33 -0200870 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufky6f447252006-01-11 19:40:33 -0200871 .num_device_descs = 1,
872 .devices = {
873 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
874 { &cxusb_table[5], NULL },
875 { &cxusb_table[6], NULL },
876 },
877 }
878};
879
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300880static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
Michael Krufky6f447252006-01-11 19:40:33 -0200881 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
882
883 .usb_ctrl = DEVICE_SPECIFIC,
884 .firmware = "dvb-usb-bluebird-01.fw",
885 .download_firmware = bluebird_patch_dvico_firmware_download,
886 /* use usb alt setting 0 for EP4 transfer (dvb-t),
887 use usb alt setting 7 for EP2 transfer (atsc) */
888
889 .size_of_priv = sizeof(struct cxusb_state),
890
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300891 .num_adapters = 1,
892 .adapter = {
893 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300894 .streaming_ctrl = cxusb_streaming_ctrl,
895 .frontend_attach = cxusb_mt352_frontend_attach,
896 .tuner_attach = cxusb_dtt7579_tuner_attach,
Michael Krufky6f447252006-01-11 19:40:33 -0200897
Patrick Boettcher01451e72006-10-13 11:34:46 -0300898 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300899 .stream = {
900 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300901 .count = 5,
902 .endpoint = 0x04,
903 .u = {
904 .bulk = {
905 .buffersize = 8192,
906 }
907 }
908 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300909 },
910 },
911 .power_ctrl = cxusb_bluebird_power_ctrl,
912
Michael Krufky6f447252006-01-11 19:40:33 -0200913 .i2c_algo = &cxusb_i2c_algo,
914
Michael Krufkyc1501782006-03-26 05:43:36 -0300915 .rc_interval = 100,
916 .rc_key_map = dvico_portable_rc_keys,
917 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
918 .rc_query = cxusb_rc_query,
919
Michael Krufky6f447252006-01-11 19:40:33 -0200920 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufky6f447252006-01-11 19:40:33 -0200921
922 .num_device_descs = 1,
923 .devices = {
924 { "DViCO FusionHDTV DVB-T USB (TH7579)",
925 { &cxusb_table[7], NULL },
926 { &cxusb_table[8], NULL },
927 },
928 }
929};
930
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300931static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
932 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
933
934 .usb_ctrl = CYPRESS_FX2,
935
936 .size_of_priv = sizeof(struct cxusb_state),
937
938 .num_adapters = 1,
939 .adapter = {
940 {
941 .streaming_ctrl = cxusb_streaming_ctrl,
942 .frontend_attach = cxusb_dualdig4_frontend_attach,
943 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
944 /* parameter for the MPEG2-data transfer */
945 .stream = {
946 .type = USB_BULK,
947 .count = 5,
948 .endpoint = 0x02,
949 .u = {
950 .bulk = {
951 .buffersize = 8192,
952 }
953 }
954 },
955 },
956 },
957
958 .power_ctrl = cxusb_power_ctrl,
959
960 .i2c_algo = &cxusb_i2c_algo,
961
962 .generic_bulk_ctrl_endpoint = 0x01,
963
964 .rc_interval = 100,
965 .rc_key_map = dvico_mce_rc_keys,
966 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
967 .rc_query = cxusb_bluebird2_rc_query,
968
969 .num_device_descs = 1,
970 .devices = {
971 { "DViCO FusionHDTV DVB-T Dual Digital 4",
972 { NULL },
973 { &cxusb_table[13], NULL },
974 },
975 }
976};
977
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700978static struct usb_driver cxusb_driver = {
Patrick Boettcher63b5c1c2005-07-07 17:58:30 -0700979 .name = "dvb_usb_cxusb",
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700980 .probe = cxusb_probe,
Michael Krufkyf35db232006-12-05 14:53:39 -0300981 .disconnect = dvb_usb_device_exit,
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700982 .id_table = cxusb_table,
983};
984
985/* module stuff */
986static int __init cxusb_module_init(void)
987{
988 int result;
989 if ((result = usb_register(&cxusb_driver))) {
990 err("usb_register failed. Error number %d",result);
991 return result;
992 }
993
994 return 0;
995}
996
997static void __exit cxusb_module_exit(void)
998{
999 /* deregister this driver from the USB subsystem */
1000 usb_deregister(&cxusb_driver);
1001}
1002
1003module_init (cxusb_module_init);
1004module_exit (cxusb_module_exit);
1005
1006MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
Michael Krufky5b9ed282006-10-15 14:51:08 -03001007MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
Michael Krufkyf4efb4d2006-01-13 14:10:25 -02001008MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001009MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
1010MODULE_VERSION("1.0-alpha");
1011MODULE_LICENSE("GPL");