blob: c44b9799efaa34dca76f222c665718e9e567a750 [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
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300101static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
102{
103 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
104}
105
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700106/* I2C */
Michael Krufkyf35db232006-12-05 14:53:39 -0300107static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
108 int num)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700109{
110 struct dvb_usb_device *d = i2c_get_adapdata(adap);
111 int i;
112
Ingo Molnar3593cab2006-02-07 06:49:14 -0200113 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700114 return -EAGAIN;
115
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700116 for (i = 0; i < num; i++) {
117
Michael Krufky5e805ef2006-03-23 00:01:34 -0300118 if (d->udev->descriptor.idVendor == USB_VID_MEDION)
119 switch (msg[i].addr) {
Michael Krufkyf35db232006-12-05 14:53:39 -0300120 case 0x63:
121 cxusb_gpio_tuner(d, 0);
122 break;
123 default:
124 cxusb_gpio_tuner(d, 1);
125 break;
Michael Krufky5e805ef2006-03-23 00:01:34 -0300126 }
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700127
Chris Pascoe272479d72007-11-19 03:01:22 -0300128 if (msg[i].flags & I2C_M_RD) {
129 /* read only */
130 u8 obuf[3], ibuf[1+msg[i].len];
131 obuf[0] = 0;
132 obuf[1] = msg[i].len;
133 obuf[2] = msg[i].addr;
134 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
135 obuf, 3,
136 ibuf, 1+msg[i].len) < 0) {
137 warn("i2c read failed");
138 break;
139 }
140 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
Chris Pascoea644e4a2007-11-19 03:05:09 -0300141 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
142 msg[i].addr == msg[i+1].addr) {
143 /* write to then read from same address */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700144 u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
145 obuf[0] = msg[i].len;
146 obuf[1] = msg[i+1].len;
147 obuf[2] = msg[i].addr;
Michael Krufkyf35db232006-12-05 14:53:39 -0300148 memcpy(&obuf[3], msg[i].buf, msg[i].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700149
150 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
Michael Krufkyf35db232006-12-05 14:53:39 -0300151 obuf, 3+msg[i].len,
152 ibuf, 1+msg[i+1].len) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700153 break;
154
155 if (ibuf[0] != 0x08)
Michael Krufkyae62e3d2006-03-23 01:11:18 -0300156 deb_i2c("i2c read may have failed\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700157
Michael Krufkyf35db232006-12-05 14:53:39 -0300158 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700159
160 i++;
Chris Pascoe272479d72007-11-19 03:01:22 -0300161 } else {
162 /* write only */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700163 u8 obuf[2+msg[i].len], ibuf;
164 obuf[0] = msg[i].addr;
165 obuf[1] = msg[i].len;
Michael Krufkyf35db232006-12-05 14:53:39 -0300166 memcpy(&obuf[2], msg[i].buf, msg[i].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700167
Michael Krufkyf35db232006-12-05 14:53:39 -0300168 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
169 2+msg[i].len, &ibuf,1) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700170 break;
171 if (ibuf != 0x08)
Michael Krufkyae62e3d2006-03-23 01:11:18 -0300172 deb_i2c("i2c write may have failed\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700173 }
174 }
175
Ingo Molnar3593cab2006-02-07 06:49:14 -0200176 mutex_unlock(&d->i2c_mutex);
Chris Pascoe13e001d2007-11-19 02:48:27 -0300177 return i == num ? num : -EREMOTEIO;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700178}
179
180static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
181{
182 return I2C_FUNC_I2C;
183}
184
185static struct i2c_algorithm cxusb_i2c_algo = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700186 .master_xfer = cxusb_i2c_xfer,
187 .functionality = cxusb_i2c_func,
188};
189
190static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
191{
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700192 u8 b = 0;
193 if (onoff)
194 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
195 else
196 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700197}
198
Michael Krufky5691c842006-04-19 20:40:01 -0300199static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
200{
201 u8 b = 0;
202 if (onoff)
203 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
204 else
205 return 0;
206}
207
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300208static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
209{
210 int rc = 0;
211
212 rc = cxusb_power_ctrl(d, onoff);
213 if (!onoff)
214 cxusb_nano2_led(d, 0);
215
216 return rc;
217}
218
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300219static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700220{
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700221 u8 buf[2] = { 0x03, 0x00 };
222 if (onoff)
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300223 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700224 else
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300225 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700226
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700227 return 0;
228}
229
Chris Pascoe7c239702006-01-09 18:21:29 -0200230static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
231{
232 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
Michael Krufkya07e6092006-01-09 18:21:31 -0200233 u8 ircode[4];
Chris Pascoe7c239702006-01-09 18:21:29 -0200234 int i;
235
Michael Krufkya07e6092006-01-09 18:21:31 -0200236 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
Chris Pascoe7c239702006-01-09 18:21:29 -0200237
238 *event = 0;
239 *state = REMOTE_NO_KEY_PRESSED;
240
241 for (i = 0; i < d->props.rc_key_map_size; i++) {
Michael Krufkya07e6092006-01-09 18:21:31 -0200242 if (keymap[i].custom == ircode[2] &&
243 keymap[i].data == ircode[3]) {
Chris Pascoe7c239702006-01-09 18:21:29 -0200244 *event = keymap[i].event;
245 *state = REMOTE_KEY_PRESSED;
246
247 return 0;
248 }
249 }
250
251 return 0;
252}
253
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300254static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
255 int *state)
256{
257 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
258 u8 ircode[4];
259 int i;
260 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
261 .buf = ircode, .len = 4 };
262
263 *event = 0;
264 *state = REMOTE_NO_KEY_PRESSED;
265
266 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
267 return 0;
268
269 for (i = 0; i < d->props.rc_key_map_size; i++) {
270 if (keymap[i].custom == ircode[1] &&
271 keymap[i].data == ircode[2]) {
272 *event = keymap[i].event;
273 *state = REMOTE_KEY_PRESSED;
274
275 return 0;
276 }
277 }
278
279 return 0;
280}
281
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200282static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
Michael Krufkya07e6092006-01-09 18:21:31 -0200283 { 0xfe, 0x02, KEY_TV },
284 { 0xfe, 0x0e, KEY_MP3 },
285 { 0xfe, 0x1a, KEY_DVD },
286 { 0xfe, 0x1e, KEY_FAVORITES },
287 { 0xfe, 0x16, KEY_SETUP },
288 { 0xfe, 0x46, KEY_POWER2 },
289 { 0xfe, 0x0a, KEY_EPG },
290 { 0xfe, 0x49, KEY_BACK },
291 { 0xfe, 0x4d, KEY_MENU },
292 { 0xfe, 0x51, KEY_UP },
293 { 0xfe, 0x5b, KEY_LEFT },
294 { 0xfe, 0x5f, KEY_RIGHT },
295 { 0xfe, 0x53, KEY_DOWN },
296 { 0xfe, 0x5e, KEY_OK },
297 { 0xfe, 0x59, KEY_INFO },
298 { 0xfe, 0x55, KEY_TAB },
299 { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
300 { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */
301 { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */
302 { 0xfe, 0x15, KEY_VOLUMEUP },
303 { 0xfe, 0x05, KEY_VOLUMEDOWN },
304 { 0xfe, 0x11, KEY_CHANNELUP },
305 { 0xfe, 0x09, KEY_CHANNELDOWN },
306 { 0xfe, 0x52, KEY_CAMERA },
307 { 0xfe, 0x5a, KEY_TUNER }, /* Live */
308 { 0xfe, 0x19, KEY_OPEN },
309 { 0xfe, 0x0b, KEY_1 },
310 { 0xfe, 0x17, KEY_2 },
311 { 0xfe, 0x1b, KEY_3 },
312 { 0xfe, 0x07, KEY_4 },
313 { 0xfe, 0x50, KEY_5 },
314 { 0xfe, 0x54, KEY_6 },
315 { 0xfe, 0x48, KEY_7 },
316 { 0xfe, 0x4c, KEY_8 },
317 { 0xfe, 0x58, KEY_9 },
318 { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */
319 { 0xfe, 0x03, KEY_0 },
320 { 0xfe, 0x1f, KEY_ZOOM },
321 { 0xfe, 0x43, KEY_REWIND },
322 { 0xfe, 0x47, KEY_PLAYPAUSE },
323 { 0xfe, 0x4f, KEY_FASTFORWARD },
324 { 0xfe, 0x57, KEY_MUTE },
325 { 0xfe, 0x0d, KEY_STOP },
326 { 0xfe, 0x01, KEY_RECORD },
327 { 0xfe, 0x4e, KEY_POWER },
328};
329
Michael Krufkyc1501782006-03-26 05:43:36 -0300330static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
331 { 0xfc, 0x02, KEY_SETUP }, /* Profile */
332 { 0xfc, 0x43, KEY_POWER2 },
333 { 0xfc, 0x06, KEY_EPG },
334 { 0xfc, 0x5a, KEY_BACK },
335 { 0xfc, 0x05, KEY_MENU },
336 { 0xfc, 0x47, KEY_INFO },
337 { 0xfc, 0x01, KEY_TAB },
338 { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
339 { 0xfc, 0x49, KEY_VOLUMEUP },
340 { 0xfc, 0x09, KEY_VOLUMEDOWN },
341 { 0xfc, 0x54, KEY_CHANNELUP },
342 { 0xfc, 0x0b, KEY_CHANNELDOWN },
Michael Krufkydbcb86e2006-03-26 18:59:45 -0300343 { 0xfc, 0x16, KEY_CAMERA },
Michael Krufkyc1501782006-03-26 05:43:36 -0300344 { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */
345 { 0xfc, 0x45, KEY_OPEN },
346 { 0xfc, 0x19, KEY_1 },
347 { 0xfc, 0x18, KEY_2 },
348 { 0xfc, 0x1b, KEY_3 },
349 { 0xfc, 0x1a, KEY_4 },
350 { 0xfc, 0x58, KEY_5 },
351 { 0xfc, 0x59, KEY_6 },
352 { 0xfc, 0x15, KEY_7 },
353 { 0xfc, 0x14, KEY_8 },
354 { 0xfc, 0x17, KEY_9 },
355 { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */
356 { 0xfc, 0x55, KEY_0 },
357 { 0xfc, 0x07, KEY_ZOOM },
358 { 0xfc, 0x0a, KEY_REWIND },
359 { 0xfc, 0x08, KEY_PLAYPAUSE },
360 { 0xfc, 0x4b, KEY_FASTFORWARD },
361 { 0xfc, 0x5b, KEY_MUTE },
362 { 0xfc, 0x04, KEY_STOP },
363 { 0xfc, 0x56, KEY_RECORD },
364 { 0xfc, 0x57, KEY_POWER },
365 { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */
366 { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
367};
368
Chris Pascoe0029ee12006-01-09 18:21:28 -0200369static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
370{
Chris Pascoed9ed8812006-02-07 06:49:11 -0200371 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
Chris Pascoe0029ee12006-01-09 18:21:28 -0200372 static u8 reset [] = { RESET, 0x80 };
373 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
374 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
375 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
376 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
377
378 mt352_write(fe, clock_config, sizeof(clock_config));
379 udelay(200);
380 mt352_write(fe, reset, sizeof(reset));
381 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
382
383 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
384 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
385 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
386
387 return 0;
388}
389
Michael Krufky6f447252006-01-11 19:40:33 -0200390static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
391{ /* used in both lgz201 and th7579 */
Michael Krufkyfb51fd22006-02-07 06:49:12 -0200392 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
Michael Krufky6f447252006-01-11 19:40:33 -0200393 static u8 reset [] = { RESET, 0x80 };
394 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
395 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
396 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
397 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
398
399 mt352_write(fe, clock_config, sizeof(clock_config));
400 udelay(200);
401 mt352_write(fe, reset, sizeof(reset));
402 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
403
404 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
405 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
406 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
407 return 0;
408}
409
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200410static struct cx22702_config cxusb_cx22702_config = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700411 .demod_address = 0x63,
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700412 .output_mode = CX22702_PARALLEL_OUTPUT,
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700413};
414
Michael Krufkyfddd6322006-02-27 00:08:17 -0300415static struct lgdt330x_config cxusb_lgdt3303_config = {
Michael Krufkyeffee032006-01-09 15:25:47 -0200416 .demod_address = 0x0e,
417 .demod_chip = LGDT3303,
Michael Krufkyeffee032006-01-09 15:25:47 -0200418};
419
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200420static struct mt352_config cxusb_dee1601_config = {
Chris Pascoe0029ee12006-01-09 18:21:28 -0200421 .demod_address = 0x0f,
422 .demod_init = cxusb_dee1601_demod_init,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200423};
424
Michael Krufkyc9ce3942006-06-11 04:24:31 -0300425static struct zl10353_config cxusb_zl10353_dee1601_config = {
426 .demod_address = 0x0f,
Chris Pascoe8fb95782006-08-10 03:17:16 -0300427 .parallel_ts = 1,
Michael Krufkyc9ce3942006-06-11 04:24:31 -0300428};
429
Adrian Bunk6fe00b02006-04-19 20:49:28 -0300430static struct mt352_config cxusb_mt352_config = {
Michael Krufky6f447252006-01-11 19:40:33 -0200431 /* used in both lgz201 and th7579 */
432 .demod_address = 0x0f,
433 .demod_init = cxusb_mt352_demod_init,
Michael Krufky6f447252006-01-11 19:40:33 -0200434};
435
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300436static struct zl10353_config cxusb_zl10353_xc3028_config = {
437 .demod_address = 0x0f,
438 .if2 = 4560,
439 .no_tuner = 1,
440 .parallel_ts = 1,
441};
442
Chris Pascoe702a6762007-11-20 03:34:11 -0300443static struct mt352_config cxusb_mt352_xc3028_config = {
444 .demod_address = 0x0f,
445 .if2 = 4560,
446 .no_tuner = 1,
447 .demod_init = cxusb_mt352_demod_init,
448};
449
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700450/* Callbacks for DVB USB */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300451static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700452{
Trent Piephob7754d72007-05-08 18:05:16 -0300453 dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300454 DVB_PLL_FMD1216ME);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700455 return 0;
456}
457
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300458static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200459{
Michael Krufky79a54cb2006-12-05 14:20:06 -0300460 dvb_attach(dvb_pll_attach, adap->fe, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300461 NULL, DVB_PLL_THOMSON_DTT7579);
Chris Pascoe0029ee12006-01-09 18:21:28 -0200462 return 0;
463}
464
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300465static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky6f447252006-01-11 19:40:33 -0200466{
Michael Krufky47a99912007-06-12 16:10:51 -0300467 dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
Michael Krufky6f447252006-01-11 19:40:33 -0200468 return 0;
469}
470
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300471static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky6f447252006-01-11 19:40:33 -0200472{
Michael Krufky79a54cb2006-12-05 14:20:06 -0300473 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300474 NULL, DVB_PLL_THOMSON_DTT7579);
Patrick Boettcher332bed52006-05-14 04:49:00 -0300475 return 0;
476}
477
Michael Krufkyf71a56c2006-10-13 21:55:57 -0300478static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher332bed52006-05-14 04:49:00 -0300479{
Trent Piepho6bdcc6e2007-04-27 12:31:30 -0300480 dvb_attach(dvb_pll_attach, adap->fe, 0x61, &adap->dev->i2c_adap,
Michael Krufky47a99912007-06-12 16:10:51 -0300481 DVB_PLL_LG_TDVS_H06XF);
Michael Krufky6f447252006-01-11 19:40:33 -0200482 return 0;
483}
484
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300485static int dvico_bluebird_xc2028_callback(void *ptr, int command, int arg)
486{
487 struct dvb_usb_device *d = ptr;
488
489 switch (command) {
490 case XC2028_TUNER_RESET:
491 deb_info("%s: XC2028_TUNER_RESET %d\n", __FUNCTION__, arg);
492 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
493 break;
494 case XC2028_RESET_CLK:
495 deb_info("%s: XC2028_RESET_CLK %d\n", __FUNCTION__, arg);
496 break;
497 default:
498 deb_info("%s: unknown command %d, arg %d\n", __FUNCTION__,
499 command, arg);
500 return -EINVAL;
501 }
502
503 return 0;
504}
505
506static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
507{
508 struct dvb_frontend *fe;
509 struct xc2028_config cfg = {
510 .i2c_adap = &adap->dev->i2c_adap,
511 .i2c_addr = 0x61,
512 .video_dev = adap->dev,
513 .callback = dvico_bluebird_xc2028_callback,
514 };
515 static struct xc2028_ctrl ctl = {
516 .type = XC2028_FIRM_NORMAL,
517 .fname = "xc3028-dvico-au-01.fw",
518 .max_len = 64,
519 .scode_table = ZARLINK456,
520 };
521
522 fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
523 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
524 return -EIO;
525
526 fe->ops.tuner_ops.set_config(fe, &ctl);
527
528 return 0;
529}
530
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300531static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700532{
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700533 u8 b;
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300534 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700535 err("set interface failed");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700536
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300537 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700538
Michael Krufkyf35db232006-12-05 14:53:39 -0300539 if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
540 &adap->dev->i2c_adap)) != NULL)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700541 return 0;
542
543 return -EIO;
544}
545
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300546static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufkyeffee032006-01-09 15:25:47 -0200547{
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300548 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
Michael Krufkyeffee032006-01-09 15:25:47 -0200549 err("set interface failed");
550
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300551 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
Michael Krufkyeffee032006-01-09 15:25:47 -0200552
Michael Krufkyf35db232006-12-05 14:53:39 -0300553 if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
554 &adap->dev->i2c_adap)) != NULL)
Michael Krufkyeffee032006-01-09 15:25:47 -0200555 return 0;
556
557 return -EIO;
558}
559
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300560static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200561{
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300562 /* used in both lgz201 and th7579 */
563 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200564 err("set interface failed");
565
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300566 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
Chris Pascoe0029ee12006-01-09 18:21:28 -0200567
Michael Krufkyf35db232006-12-05 14:53:39 -0300568 if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
569 &adap->dev->i2c_adap)) != NULL)
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300570 return 0;
571
572 return -EIO;
573}
574
575static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
576{
577 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
578 err("set interface failed");
579
580 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
581
Michael Krufkyf35db232006-12-05 14:53:39 -0300582 if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
583 &adap->dev->i2c_adap)) != NULL) ||
584 ((adap->fe = dvb_attach(zl10353_attach,
585 &cxusb_zl10353_dee1601_config,
586 &adap->dev->i2c_adap)) != NULL))
Chris Pascoe0029ee12006-01-09 18:21:28 -0200587 return 0;
588
589 return -EIO;
590}
591
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300592static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
593{
594 u8 ircode[4];
595 int i;
596 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
597 .buf = ircode, .len = 4 };
598
599 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
600 err("set interface failed");
601
602 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
603
604 /* reset the tuner and demodulator */
605 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
606 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
607 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
608
609 if ((adap->fe = dvb_attach(zl10353_attach,
610 &cxusb_zl10353_xc3028_config,
611 &adap->dev->i2c_adap)) == NULL)
612 return -EIO;
613
614 /* try to determine if there is no IR decoder on the I2C bus */
615 for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
616 msleep(20);
617 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
618 goto no_IR;
619 if (ircode[0] == 0 && ircode[1] == 0)
620 continue;
621 if (ircode[2] + ircode[3] != 0xff) {
622no_IR:
623 adap->dev->props.rc_key_map = NULL;
624 info("No IR receiver detected on this device.");
625 break;
626 }
627 }
628
629 return 0;
630}
631
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300632static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
633{
634 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
635 err("set interface failed");
636
637 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
638
639 /* reset the tuner and demodulator */
640 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
641 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
642 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
643
644 if ((adap->fe = dvb_attach(zl10353_attach,
645 &cxusb_zl10353_xc3028_config,
646 &adap->dev->i2c_adap)) != NULL)
647 return 0;
648
Chris Pascoe702a6762007-11-20 03:34:11 -0300649 if ((adap->fe = dvb_attach(mt352_attach,
650 &cxusb_mt352_xc3028_config,
651 &adap->dev->i2c_adap)) != NULL)
652 return 0;
653
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300654 return -EIO;
655}
656
Patrick Boettcherf5373782006-01-09 18:21:38 -0200657/*
Chris Pascoe702a6762007-11-20 03:34:11 -0300658 * DViCO has shipped two devices with the same USB ID, but only one of them
659 * needs a firmware download. Check the device class details to see if they
660 * have non-default values to decide whether the device is actually cold or
661 * not, and forget a match if it turns out we selected the wrong device.
662 */
663static int bluebird_fx2_identify_state(struct usb_device *udev,
664 struct dvb_usb_device_properties *props,
665 struct dvb_usb_device_description **desc,
666 int *cold)
667{
668 int wascold = *cold;
669
670 *cold = udev->descriptor.bDeviceClass == 0xff &&
671 udev->descriptor.bDeviceSubClass == 0xff &&
672 udev->descriptor.bDeviceProtocol == 0xff;
673
674 if (*cold && !wascold)
675 *desc = NULL;
676
677 return 0;
678}
679
680/*
Patrick Boettcherf5373782006-01-09 18:21:38 -0200681 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
682 * firmware file before download.
683 */
684
Chris Pascoe702a6762007-11-20 03:34:11 -0300685static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
Michael Krufkyf35db232006-12-05 14:53:39 -0300686static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
687 const struct firmware *fw)
Patrick Boettcherf5373782006-01-09 18:21:38 -0200688{
Chris Pascoe702a6762007-11-20 03:34:11 -0300689 int pos;
Patrick Boettcherf5373782006-01-09 18:21:38 -0200690
Chris Pascoe702a6762007-11-20 03:34:11 -0300691 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
692 int idoff = dvico_firmware_id_offsets[pos];
Patrick Boettcherf5373782006-01-09 18:21:38 -0200693
Chris Pascoe702a6762007-11-20 03:34:11 -0300694 if (fw->size < idoff + 4)
695 continue;
Patrick Boettcherf5373782006-01-09 18:21:38 -0200696
Chris Pascoe702a6762007-11-20 03:34:11 -0300697 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
698 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
699 fw->data[idoff + 2] =
700 le16_to_cpu(udev->descriptor.idProduct) + 1;
701 fw->data[idoff + 3] =
702 le16_to_cpu(udev->descriptor.idProduct) >> 8;
703
704 return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
705 }
Patrick Boettcherf5373782006-01-09 18:21:38 -0200706 }
707
708 return -EINVAL;
709}
710
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700711/* DVB USB Driver stuff */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300712static struct dvb_usb_device_properties cxusb_medion_properties;
713static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
714static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
715static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
716static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300717static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300718static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
Chris Pascoe702a6762007-11-20 03:34:11 -0300719static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700720
721static int cxusb_probe(struct usb_interface *intf,
Michael Krufkyf35db232006-12-05 14:53:39 -0300722 const struct usb_device_id *id)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700723{
Michael Krufkyeffee032006-01-09 15:25:47 -0200724 if (dvb_usb_device_init(intf,&cxusb_medion_properties,THIS_MODULE,NULL) == 0 ||
Chris Pascoe0029ee12006-01-09 18:21:28 -0200725 dvb_usb_device_init(intf,&cxusb_bluebird_lgh064f_properties,THIS_MODULE,NULL) == 0 ||
Michael Krufky6f447252006-01-11 19:40:33 -0200726 dvb_usb_device_init(intf,&cxusb_bluebird_dee1601_properties,THIS_MODULE,NULL) == 0 ||
727 dvb_usb_device_init(intf,&cxusb_bluebird_lgz201_properties,THIS_MODULE,NULL) == 0 ||
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300728 dvb_usb_device_init(intf,&cxusb_bluebird_dtt7579_properties,THIS_MODULE,NULL) == 0 ||
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300729 dvb_usb_device_init(intf,&cxusb_bluebird_dualdig4_properties,THIS_MODULE,NULL) == 0 ||
Chris Pascoe702a6762007-11-20 03:34:11 -0300730 dvb_usb_device_init(intf,&cxusb_bluebird_nano2_properties,THIS_MODULE,NULL) == 0 ||
731 dvb_usb_device_init(intf,&cxusb_bluebird_nano2_needsfirmware_properties,THIS_MODULE,NULL) == 0) {
Michael Krufkyeffee032006-01-09 15:25:47 -0200732 return 0;
733 }
734
735 return -EINVAL;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700736}
737
738static struct usb_device_id cxusb_table [] = {
Michael Krufkyf35db232006-12-05 14:53:39 -0300739 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
740 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
741 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
742 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
743 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
744 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
745 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
746 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
747 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
748 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
749 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
750 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
751 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300752 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300753 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
Chris Pascoe702a6762007-11-20 03:34:11 -0300754 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
Michael Krufkyf35db232006-12-05 14:53:39 -0300755 {} /* Terminating entry */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700756};
757MODULE_DEVICE_TABLE (usb, cxusb_table);
758
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300759static struct dvb_usb_device_properties cxusb_medion_properties = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700760 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
761
762 .usb_ctrl = CYPRESS_FX2,
763
764 .size_of_priv = sizeof(struct cxusb_state),
765
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300766 .num_adapters = 1,
767 .adapter = {
768 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300769 .streaming_ctrl = cxusb_streaming_ctrl,
770 .frontend_attach = cxusb_cx22702_frontend_attach,
771 .tuner_attach = cxusb_fmd1216me_tuner_attach,
772 /* parameter for the MPEG2-data transfer */
773 .stream = {
774 .type = USB_BULK,
775 .count = 5,
776 .endpoint = 0x02,
777 .u = {
778 .bulk = {
779 .buffersize = 8192,
780 }
781 }
782 },
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700783
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300784 },
785 },
786 .power_ctrl = cxusb_power_ctrl,
787
788 .i2c_algo = &cxusb_i2c_algo,
789
790 .generic_bulk_ctrl_endpoint = 0x01,
791
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700792 .num_device_descs = 1,
793 .devices = {
794 { "Medion MD95700 (MDUSBTV-HYBRID)",
795 { NULL },
796 { &cxusb_table[0], NULL },
797 },
798 }
799};
800
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300801static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
Michael Krufkyeffee032006-01-09 15:25:47 -0200802 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
803
Patrick Boettcherf5373782006-01-09 18:21:38 -0200804 .usb_ctrl = DEVICE_SPECIFIC,
805 .firmware = "dvb-usb-bluebird-01.fw",
806 .download_firmware = bluebird_patch_dvico_firmware_download,
Michael Krufky37bdfa02006-01-09 15:25:47 -0200807 /* use usb alt setting 0 for EP4 transfer (dvb-t),
808 use usb alt setting 7 for EP2 transfer (atsc) */
Michael Krufkyeffee032006-01-09 15:25:47 -0200809
810 .size_of_priv = sizeof(struct cxusb_state),
811
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300812 .num_adapters = 1,
813 .adapter = {
814 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300815 .streaming_ctrl = cxusb_streaming_ctrl,
816 .frontend_attach = cxusb_lgdt3303_frontend_attach,
Michael Krufkyf71a56c2006-10-13 21:55:57 -0300817 .tuner_attach = cxusb_lgh064f_tuner_attach,
Michael Krufkyeffee032006-01-09 15:25:47 -0200818
Patrick Boettcher01451e72006-10-13 11:34:46 -0300819 /* parameter for the MPEG2-data transfer */
820 .stream = {
821 .type = USB_BULK,
822 .count = 5,
823 .endpoint = 0x02,
824 .u = {
825 .bulk = {
826 .buffersize = 8192,
827 }
828 }
829 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300830 },
831 },
832
833 .power_ctrl = cxusb_bluebird_power_ctrl,
834
Michael Krufkyeffee032006-01-09 15:25:47 -0200835 .i2c_algo = &cxusb_i2c_algo,
836
Michael Krufkyc1501782006-03-26 05:43:36 -0300837 .rc_interval = 100,
838 .rc_key_map = dvico_portable_rc_keys,
839 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
840 .rc_query = cxusb_rc_query,
841
Michael Krufkyeffee032006-01-09 15:25:47 -0200842 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufkyeffee032006-01-09 15:25:47 -0200843
844 .num_device_descs = 1,
845 .devices = {
846 { "DViCO FusionHDTV5 USB Gold",
847 { &cxusb_table[1], NULL },
848 { &cxusb_table[2], NULL },
849 },
850 }
851};
852
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300853static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
Chris Pascoe0029ee12006-01-09 18:21:28 -0200854 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
855
Patrick Boettcherf5373782006-01-09 18:21:38 -0200856 .usb_ctrl = DEVICE_SPECIFIC,
857 .firmware = "dvb-usb-bluebird-01.fw",
858 .download_firmware = bluebird_patch_dvico_firmware_download,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200859 /* use usb alt setting 0 for EP4 transfer (dvb-t),
860 use usb alt setting 7 for EP2 transfer (atsc) */
861
862 .size_of_priv = sizeof(struct cxusb_state),
863
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300864 .num_adapters = 1,
865 .adapter = {
866 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300867 .streaming_ctrl = cxusb_streaming_ctrl,
868 .frontend_attach = cxusb_dee1601_frontend_attach,
869 .tuner_attach = cxusb_dee1601_tuner_attach,
870 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300871 .stream = {
872 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300873 .count = 5,
874 .endpoint = 0x04,
875 .u = {
876 .bulk = {
877 .buffersize = 8192,
878 }
879 }
880 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300881 },
882 },
883
884 .power_ctrl = cxusb_bluebird_power_ctrl,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200885
886 .i2c_algo = &cxusb_i2c_algo,
887
Chris Pascoe7c239702006-01-09 18:21:29 -0200888 .rc_interval = 150,
889 .rc_key_map = dvico_mce_rc_keys,
890 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
891 .rc_query = cxusb_rc_query,
892
Chris Pascoe0029ee12006-01-09 18:21:28 -0200893 .generic_bulk_ctrl_endpoint = 0x01,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200894
Michael Krufky587c03d2006-09-28 02:16:01 -0300895 .num_device_descs = 3,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200896 .devices = {
897 { "DViCO FusionHDTV DVB-T Dual USB",
898 { &cxusb_table[3], NULL },
899 { &cxusb_table[4], NULL },
900 },
Michael Krufkyac9ffb92006-01-11 23:21:00 -0200901 { "DigitalNow DVB-T Dual USB",
902 { &cxusb_table[9], NULL },
903 { &cxusb_table[10], NULL },
904 },
Michael Krufky587c03d2006-09-28 02:16:01 -0300905 { "DViCO FusionHDTV DVB-T Dual Digital 2",
906 { &cxusb_table[11], NULL },
907 { &cxusb_table[12], NULL },
908 },
Chris Pascoe0029ee12006-01-09 18:21:28 -0200909 }
910};
911
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300912static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
Michael Krufky6f447252006-01-11 19:40:33 -0200913 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
914
915 .usb_ctrl = DEVICE_SPECIFIC,
916 .firmware = "dvb-usb-bluebird-01.fw",
917 .download_firmware = bluebird_patch_dvico_firmware_download,
918 /* use usb alt setting 0 for EP4 transfer (dvb-t),
919 use usb alt setting 7 for EP2 transfer (atsc) */
920
921 .size_of_priv = sizeof(struct cxusb_state),
922
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300923 .num_adapters = 2,
924 .adapter = {
925 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300926 .streaming_ctrl = cxusb_streaming_ctrl,
927 .frontend_attach = cxusb_mt352_frontend_attach,
928 .tuner_attach = cxusb_lgz201_tuner_attach,
Michael Krufky6f447252006-01-11 19:40:33 -0200929
Patrick Boettcher01451e72006-10-13 11:34:46 -0300930 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300931 .stream = {
932 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300933 .count = 5,
934 .endpoint = 0x04,
935 .u = {
936 .bulk = {
937 .buffersize = 8192,
938 }
939 }
940 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300941 },
942 },
943 .power_ctrl = cxusb_bluebird_power_ctrl,
944
Michael Krufky6f447252006-01-11 19:40:33 -0200945 .i2c_algo = &cxusb_i2c_algo,
946
Michael Krufkyc1501782006-03-26 05:43:36 -0300947 .rc_interval = 100,
948 .rc_key_map = dvico_portable_rc_keys,
949 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
950 .rc_query = cxusb_rc_query,
951
Michael Krufky6f447252006-01-11 19:40:33 -0200952 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufky6f447252006-01-11 19:40:33 -0200953 .num_device_descs = 1,
954 .devices = {
955 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
956 { &cxusb_table[5], NULL },
957 { &cxusb_table[6], NULL },
958 },
959 }
960};
961
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300962static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
Michael Krufky6f447252006-01-11 19:40:33 -0200963 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
964
965 .usb_ctrl = DEVICE_SPECIFIC,
966 .firmware = "dvb-usb-bluebird-01.fw",
967 .download_firmware = bluebird_patch_dvico_firmware_download,
968 /* use usb alt setting 0 for EP4 transfer (dvb-t),
969 use usb alt setting 7 for EP2 transfer (atsc) */
970
971 .size_of_priv = sizeof(struct cxusb_state),
972
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300973 .num_adapters = 1,
974 .adapter = {
975 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300976 .streaming_ctrl = cxusb_streaming_ctrl,
977 .frontend_attach = cxusb_mt352_frontend_attach,
978 .tuner_attach = cxusb_dtt7579_tuner_attach,
Michael Krufky6f447252006-01-11 19:40:33 -0200979
Patrick Boettcher01451e72006-10-13 11:34:46 -0300980 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300981 .stream = {
982 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300983 .count = 5,
984 .endpoint = 0x04,
985 .u = {
986 .bulk = {
987 .buffersize = 8192,
988 }
989 }
990 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300991 },
992 },
993 .power_ctrl = cxusb_bluebird_power_ctrl,
994
Michael Krufky6f447252006-01-11 19:40:33 -0200995 .i2c_algo = &cxusb_i2c_algo,
996
Michael Krufkyc1501782006-03-26 05:43:36 -0300997 .rc_interval = 100,
998 .rc_key_map = dvico_portable_rc_keys,
999 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1000 .rc_query = cxusb_rc_query,
1001
Michael Krufky6f447252006-01-11 19:40:33 -02001002 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufky6f447252006-01-11 19:40:33 -02001003
1004 .num_device_descs = 1,
1005 .devices = {
1006 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1007 { &cxusb_table[7], NULL },
1008 { &cxusb_table[8], NULL },
1009 },
1010 }
1011};
1012
Chris Pascoeaeb012b2007-11-19 21:57:10 -03001013static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1014 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1015
1016 .usb_ctrl = CYPRESS_FX2,
1017
1018 .size_of_priv = sizeof(struct cxusb_state),
1019
1020 .num_adapters = 1,
1021 .adapter = {
1022 {
1023 .streaming_ctrl = cxusb_streaming_ctrl,
1024 .frontend_attach = cxusb_dualdig4_frontend_attach,
1025 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1026 /* parameter for the MPEG2-data transfer */
1027 .stream = {
1028 .type = USB_BULK,
1029 .count = 5,
1030 .endpoint = 0x02,
1031 .u = {
1032 .bulk = {
1033 .buffersize = 8192,
1034 }
1035 }
1036 },
1037 },
1038 },
1039
1040 .power_ctrl = cxusb_power_ctrl,
1041
1042 .i2c_algo = &cxusb_i2c_algo,
1043
1044 .generic_bulk_ctrl_endpoint = 0x01,
1045
1046 .rc_interval = 100,
1047 .rc_key_map = dvico_mce_rc_keys,
1048 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
1049 .rc_query = cxusb_bluebird2_rc_query,
1050
1051 .num_device_descs = 1,
1052 .devices = {
1053 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1054 { NULL },
1055 { &cxusb_table[13], NULL },
1056 },
1057 }
1058};
1059
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001060static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1061 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1062
1063 .usb_ctrl = CYPRESS_FX2,
Chris Pascoe702a6762007-11-20 03:34:11 -03001064 .identify_state = bluebird_fx2_identify_state,
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001065
1066 .size_of_priv = sizeof(struct cxusb_state),
1067
1068 .num_adapters = 1,
1069 .adapter = {
1070 {
1071 .streaming_ctrl = cxusb_streaming_ctrl,
1072 .frontend_attach = cxusb_nano2_frontend_attach,
1073 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1074 /* parameter for the MPEG2-data transfer */
1075 .stream = {
1076 .type = USB_BULK,
1077 .count = 5,
1078 .endpoint = 0x02,
1079 .u = {
1080 .bulk = {
1081 .buffersize = 8192,
1082 }
1083 }
1084 },
1085 },
1086 },
1087
1088 .power_ctrl = cxusb_nano2_power_ctrl,
1089
1090 .i2c_algo = &cxusb_i2c_algo,
1091
1092 .generic_bulk_ctrl_endpoint = 0x01,
1093
1094 .rc_interval = 100,
1095 .rc_key_map = dvico_portable_rc_keys,
1096 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1097 .rc_query = cxusb_bluebird2_rc_query,
1098
1099 .num_device_descs = 1,
1100 .devices = {
1101 { "DViCO FusionHDTV DVB-T NANO2",
1102 { NULL },
1103 { &cxusb_table[14], NULL },
1104 },
1105 }
1106};
1107
Chris Pascoe702a6762007-11-20 03:34:11 -03001108static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
1109 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1110
1111 .usb_ctrl = DEVICE_SPECIFIC,
1112 .firmware = "dvb-usb-bluebird-02.fw",
1113 .download_firmware = bluebird_patch_dvico_firmware_download,
1114 .identify_state = bluebird_fx2_identify_state,
1115
1116 .size_of_priv = sizeof(struct cxusb_state),
1117
1118 .num_adapters = 1,
1119 .adapter = {
1120 {
1121 .streaming_ctrl = cxusb_streaming_ctrl,
1122 .frontend_attach = cxusb_nano2_frontend_attach,
1123 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1124 /* parameter for the MPEG2-data transfer */
1125 .stream = {
1126 .type = USB_BULK,
1127 .count = 5,
1128 .endpoint = 0x02,
1129 .u = {
1130 .bulk = {
1131 .buffersize = 8192,
1132 }
1133 }
1134 },
1135 },
1136 },
1137
1138 .power_ctrl = cxusb_nano2_power_ctrl,
1139
1140 .i2c_algo = &cxusb_i2c_algo,
1141
1142 .generic_bulk_ctrl_endpoint = 0x01,
1143
1144 .rc_interval = 100,
1145 .rc_key_map = dvico_portable_rc_keys,
1146 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1147 .rc_query = cxusb_rc_query,
1148
1149 .num_device_descs = 1,
1150 .devices = {
1151 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
1152 { &cxusb_table[14], NULL },
1153 { &cxusb_table[15], NULL },
1154 },
1155 }
1156};
1157
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001158static struct usb_driver cxusb_driver = {
Patrick Boettcher63b5c1c2005-07-07 17:58:30 -07001159 .name = "dvb_usb_cxusb",
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001160 .probe = cxusb_probe,
Michael Krufkyf35db232006-12-05 14:53:39 -03001161 .disconnect = dvb_usb_device_exit,
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001162 .id_table = cxusb_table,
1163};
1164
1165/* module stuff */
1166static int __init cxusb_module_init(void)
1167{
1168 int result;
1169 if ((result = usb_register(&cxusb_driver))) {
1170 err("usb_register failed. Error number %d",result);
1171 return result;
1172 }
1173
1174 return 0;
1175}
1176
1177static void __exit cxusb_module_exit(void)
1178{
1179 /* deregister this driver from the USB subsystem */
1180 usb_deregister(&cxusb_driver);
1181}
1182
1183module_init (cxusb_module_init);
1184module_exit (cxusb_module_exit);
1185
1186MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
Michael Krufky5b9ed282006-10-15 14:51:08 -03001187MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
Michael Krufkyf4efb4d2006-01-13 14:10:25 -02001188MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001189MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
1190MODULE_VERSION("1.0-alpha");
1191MODULE_LICENSE("GPL");