blob: c4b00660c65fcc2b3526125d76fe123b167a76b1 [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 */
Michael Krufky827855d2008-04-22 14:46:16 -030026#include <media/tuner.h>
27
Patrick Boettcher22c6d932005-07-07 17:58:10 -070028#include "cxusb.h"
29
30#include "cx22702.h"
Michael Krufkyeffee032006-01-09 15:25:47 -020031#include "lgdt330x.h"
Chris Pascoe0029ee12006-01-09 18:21:28 -020032#include "mt352.h"
33#include "mt352_priv.h"
Michael Krufkyc9ce3942006-06-11 04:24:31 -030034#include "zl10353.h"
Chris Pascoeaeb012b2007-11-19 21:57:10 -030035#include "tuner-xc2028.h"
36#include "tuner-xc2028-types.h"
Michael Krufky827855d2008-04-22 14:46:16 -030037#include "tuner-simple.h"
Patrick Boettcher22c6d932005-07-07 17:58:10 -070038
39/* debug */
Adrian Bunk53133af2007-11-05 14:07:06 -030040static int dvb_usb_cxusb_debug;
Michael Krufkyf35db232006-12-05 14:53:39 -030041module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070042MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
Janne Grunau78e92002008-04-09 19:13:13 -030043
44DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
45
Adrian Bunk53133af2007-11-05 14:07:06 -030046#define deb_info(args...) dprintk(dvb_usb_cxusb_debug,0x01,args)
47#define deb_i2c(args...) if (d->udev->descriptor.idVendor == USB_VID_MEDION) \
48 dprintk(dvb_usb_cxusb_debug,0x01,args)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070049
50static int cxusb_ctrl_msg(struct dvb_usb_device *d,
Michael Krufkyf35db232006-12-05 14:53:39 -030051 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070052{
53 int wo = (rbuf == NULL || rlen == 0); /* write-only */
54 u8 sndbuf[1+wlen];
Michael Krufkyf35db232006-12-05 14:53:39 -030055 memset(sndbuf, 0, 1+wlen);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070056
57 sndbuf[0] = cmd;
Michael Krufkyf35db232006-12-05 14:53:39 -030058 memcpy(&sndbuf[1], wbuf, wlen);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070059 if (wo)
Chris Pascoeb17f1092007-11-19 02:42:44 -030060 return dvb_usb_generic_write(d, sndbuf, 1+wlen);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070061 else
Chris Pascoeb17f1092007-11-19 02:42:44 -030062 return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070063}
64
Patrick Boettchere2efeab2005-09-09 13:02:51 -070065/* GPIO */
66static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070067{
68 struct cxusb_state *st = d->priv;
Michael Krufkyf35db232006-12-05 14:53:39 -030069 u8 o[2], i;
Patrick Boettcher22c6d932005-07-07 17:58:10 -070070
Patrick Boettchere2efeab2005-09-09 13:02:51 -070071 if (st->gpio_write_state[GPIO_TUNER] == onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070072 return;
73
Patrick Boettchere2efeab2005-09-09 13:02:51 -070074 o[0] = GPIO_TUNER;
75 o[1] = onoff;
Michael Krufkyf35db232006-12-05 14:53:39 -030076 cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070077
78 if (i != 0x01)
Patrick Boettchere2efeab2005-09-09 13:02:51 -070079 deb_info("gpio_write failed.\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -070080
Patrick Boettchere2efeab2005-09-09 13:02:51 -070081 st->gpio_write_state[GPIO_TUNER] = onoff;
Patrick Boettcher22c6d932005-07-07 17:58:10 -070082}
83
Chris Pascoeaeb012b2007-11-19 21:57:10 -030084static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
85 u8 newval)
86{
87 u8 o[2], gpio_state;
88 int rc;
89
90 o[0] = 0xff & ~changemask; /* mask of bits to keep */
91 o[1] = newval & changemask; /* new values for bits */
92
93 rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
94 if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
95 deb_info("bluebird_gpio_write failed.\n");
96
97 return rc < 0 ? rc : gpio_state;
98}
99
100static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
101{
102 cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
103 msleep(5);
104 cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
105}
106
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300107static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
108{
109 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
110}
111
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700112/* I2C */
Michael Krufkyf35db232006-12-05 14:53:39 -0300113static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
114 int num)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700115{
116 struct dvb_usb_device *d = i2c_get_adapdata(adap);
117 int i;
118
Ingo Molnar3593cab2006-02-07 06:49:14 -0200119 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700120 return -EAGAIN;
121
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700122 for (i = 0; i < num; i++) {
123
Michael Krufky5e805ef2006-03-23 00:01:34 -0300124 if (d->udev->descriptor.idVendor == USB_VID_MEDION)
125 switch (msg[i].addr) {
Michael Krufkyf35db232006-12-05 14:53:39 -0300126 case 0x63:
127 cxusb_gpio_tuner(d, 0);
128 break;
129 default:
130 cxusb_gpio_tuner(d, 1);
131 break;
Michael Krufky5e805ef2006-03-23 00:01:34 -0300132 }
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700133
Chris Pascoe272479d72007-11-19 03:01:22 -0300134 if (msg[i].flags & I2C_M_RD) {
135 /* read only */
136 u8 obuf[3], ibuf[1+msg[i].len];
137 obuf[0] = 0;
138 obuf[1] = msg[i].len;
139 obuf[2] = msg[i].addr;
140 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
141 obuf, 3,
142 ibuf, 1+msg[i].len) < 0) {
143 warn("i2c read failed");
144 break;
145 }
146 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
Chris Pascoea644e4a2007-11-19 03:05:09 -0300147 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
148 msg[i].addr == msg[i+1].addr) {
149 /* write to then read from same address */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700150 u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
151 obuf[0] = msg[i].len;
152 obuf[1] = msg[i+1].len;
153 obuf[2] = msg[i].addr;
Michael Krufkyf35db232006-12-05 14:53:39 -0300154 memcpy(&obuf[3], msg[i].buf, msg[i].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700155
156 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
Michael Krufkyf35db232006-12-05 14:53:39 -0300157 obuf, 3+msg[i].len,
158 ibuf, 1+msg[i+1].len) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700159 break;
160
161 if (ibuf[0] != 0x08)
Michael Krufkyae62e3d2006-03-23 01:11:18 -0300162 deb_i2c("i2c read may have failed\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700163
Michael Krufkyf35db232006-12-05 14:53:39 -0300164 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700165
166 i++;
Chris Pascoe272479d72007-11-19 03:01:22 -0300167 } else {
168 /* write only */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700169 u8 obuf[2+msg[i].len], ibuf;
170 obuf[0] = msg[i].addr;
171 obuf[1] = msg[i].len;
Michael Krufkyf35db232006-12-05 14:53:39 -0300172 memcpy(&obuf[2], msg[i].buf, msg[i].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700173
Michael Krufkyf35db232006-12-05 14:53:39 -0300174 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
175 2+msg[i].len, &ibuf,1) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700176 break;
177 if (ibuf != 0x08)
Michael Krufkyae62e3d2006-03-23 01:11:18 -0300178 deb_i2c("i2c write may have failed\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700179 }
180 }
181
Ingo Molnar3593cab2006-02-07 06:49:14 -0200182 mutex_unlock(&d->i2c_mutex);
Chris Pascoe13e001d2007-11-19 02:48:27 -0300183 return i == num ? num : -EREMOTEIO;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700184}
185
186static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
187{
188 return I2C_FUNC_I2C;
189}
190
191static struct i2c_algorithm cxusb_i2c_algo = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700192 .master_xfer = cxusb_i2c_xfer,
193 .functionality = cxusb_i2c_func,
194};
195
196static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
197{
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700198 u8 b = 0;
199 if (onoff)
200 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
201 else
202 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700203}
204
Michael Krufky5691c842006-04-19 20:40:01 -0300205static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
206{
207 u8 b = 0;
208 if (onoff)
209 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
210 else
211 return 0;
212}
213
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300214static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
215{
216 int rc = 0;
217
218 rc = cxusb_power_ctrl(d, onoff);
219 if (!onoff)
220 cxusb_nano2_led(d, 0);
221
222 return rc;
223}
224
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300225static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700226{
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700227 u8 buf[2] = { 0x03, 0x00 };
228 if (onoff)
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300229 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700230 else
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300231 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700232
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700233 return 0;
234}
235
Chris Pascoe7c239702006-01-09 18:21:29 -0200236static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
237{
238 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
Michael Krufkya07e6092006-01-09 18:21:31 -0200239 u8 ircode[4];
Chris Pascoe7c239702006-01-09 18:21:29 -0200240 int i;
241
Michael Krufkya07e6092006-01-09 18:21:31 -0200242 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
Chris Pascoe7c239702006-01-09 18:21:29 -0200243
244 *event = 0;
245 *state = REMOTE_NO_KEY_PRESSED;
246
247 for (i = 0; i < d->props.rc_key_map_size; i++) {
Michael Krufkya07e6092006-01-09 18:21:31 -0200248 if (keymap[i].custom == ircode[2] &&
249 keymap[i].data == ircode[3]) {
Chris Pascoe7c239702006-01-09 18:21:29 -0200250 *event = keymap[i].event;
251 *state = REMOTE_KEY_PRESSED;
252
253 return 0;
254 }
255 }
256
257 return 0;
258}
259
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300260static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
261 int *state)
262{
263 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
264 u8 ircode[4];
265 int i;
266 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
267 .buf = ircode, .len = 4 };
268
269 *event = 0;
270 *state = REMOTE_NO_KEY_PRESSED;
271
272 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
273 return 0;
274
275 for (i = 0; i < d->props.rc_key_map_size; i++) {
276 if (keymap[i].custom == ircode[1] &&
277 keymap[i].data == ircode[2]) {
278 *event = keymap[i].event;
279 *state = REMOTE_KEY_PRESSED;
280
281 return 0;
282 }
283 }
284
285 return 0;
286}
287
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200288static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
Michael Krufkya07e6092006-01-09 18:21:31 -0200289 { 0xfe, 0x02, KEY_TV },
290 { 0xfe, 0x0e, KEY_MP3 },
291 { 0xfe, 0x1a, KEY_DVD },
292 { 0xfe, 0x1e, KEY_FAVORITES },
293 { 0xfe, 0x16, KEY_SETUP },
294 { 0xfe, 0x46, KEY_POWER2 },
295 { 0xfe, 0x0a, KEY_EPG },
296 { 0xfe, 0x49, KEY_BACK },
297 { 0xfe, 0x4d, KEY_MENU },
298 { 0xfe, 0x51, KEY_UP },
299 { 0xfe, 0x5b, KEY_LEFT },
300 { 0xfe, 0x5f, KEY_RIGHT },
301 { 0xfe, 0x53, KEY_DOWN },
302 { 0xfe, 0x5e, KEY_OK },
303 { 0xfe, 0x59, KEY_INFO },
304 { 0xfe, 0x55, KEY_TAB },
305 { 0xfe, 0x0f, KEY_PREVIOUSSONG },/* Replay */
306 { 0xfe, 0x12, KEY_NEXTSONG }, /* Skip */
307 { 0xfe, 0x42, KEY_ENTER }, /* Windows/Start */
308 { 0xfe, 0x15, KEY_VOLUMEUP },
309 { 0xfe, 0x05, KEY_VOLUMEDOWN },
310 { 0xfe, 0x11, KEY_CHANNELUP },
311 { 0xfe, 0x09, KEY_CHANNELDOWN },
312 { 0xfe, 0x52, KEY_CAMERA },
313 { 0xfe, 0x5a, KEY_TUNER }, /* Live */
314 { 0xfe, 0x19, KEY_OPEN },
315 { 0xfe, 0x0b, KEY_1 },
316 { 0xfe, 0x17, KEY_2 },
317 { 0xfe, 0x1b, KEY_3 },
318 { 0xfe, 0x07, KEY_4 },
319 { 0xfe, 0x50, KEY_5 },
320 { 0xfe, 0x54, KEY_6 },
321 { 0xfe, 0x48, KEY_7 },
322 { 0xfe, 0x4c, KEY_8 },
323 { 0xfe, 0x58, KEY_9 },
324 { 0xfe, 0x13, KEY_ANGLE }, /* Aspect */
325 { 0xfe, 0x03, KEY_0 },
326 { 0xfe, 0x1f, KEY_ZOOM },
327 { 0xfe, 0x43, KEY_REWIND },
328 { 0xfe, 0x47, KEY_PLAYPAUSE },
329 { 0xfe, 0x4f, KEY_FASTFORWARD },
330 { 0xfe, 0x57, KEY_MUTE },
331 { 0xfe, 0x0d, KEY_STOP },
332 { 0xfe, 0x01, KEY_RECORD },
333 { 0xfe, 0x4e, KEY_POWER },
334};
335
Michael Krufkyc1501782006-03-26 05:43:36 -0300336static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
337 { 0xfc, 0x02, KEY_SETUP }, /* Profile */
338 { 0xfc, 0x43, KEY_POWER2 },
339 { 0xfc, 0x06, KEY_EPG },
340 { 0xfc, 0x5a, KEY_BACK },
341 { 0xfc, 0x05, KEY_MENU },
342 { 0xfc, 0x47, KEY_INFO },
343 { 0xfc, 0x01, KEY_TAB },
344 { 0xfc, 0x42, KEY_PREVIOUSSONG },/* Replay */
345 { 0xfc, 0x49, KEY_VOLUMEUP },
346 { 0xfc, 0x09, KEY_VOLUMEDOWN },
347 { 0xfc, 0x54, KEY_CHANNELUP },
348 { 0xfc, 0x0b, KEY_CHANNELDOWN },
Michael Krufkydbcb86e2006-03-26 18:59:45 -0300349 { 0xfc, 0x16, KEY_CAMERA },
Michael Krufkyc1501782006-03-26 05:43:36 -0300350 { 0xfc, 0x40, KEY_TUNER }, /* ATV/DTV */
351 { 0xfc, 0x45, KEY_OPEN },
352 { 0xfc, 0x19, KEY_1 },
353 { 0xfc, 0x18, KEY_2 },
354 { 0xfc, 0x1b, KEY_3 },
355 { 0xfc, 0x1a, KEY_4 },
356 { 0xfc, 0x58, KEY_5 },
357 { 0xfc, 0x59, KEY_6 },
358 { 0xfc, 0x15, KEY_7 },
359 { 0xfc, 0x14, KEY_8 },
360 { 0xfc, 0x17, KEY_9 },
361 { 0xfc, 0x44, KEY_ANGLE }, /* Aspect */
362 { 0xfc, 0x55, KEY_0 },
363 { 0xfc, 0x07, KEY_ZOOM },
364 { 0xfc, 0x0a, KEY_REWIND },
365 { 0xfc, 0x08, KEY_PLAYPAUSE },
366 { 0xfc, 0x4b, KEY_FASTFORWARD },
367 { 0xfc, 0x5b, KEY_MUTE },
368 { 0xfc, 0x04, KEY_STOP },
369 { 0xfc, 0x56, KEY_RECORD },
370 { 0xfc, 0x57, KEY_POWER },
371 { 0xfc, 0x41, KEY_UNKNOWN }, /* INPUT */
372 { 0xfc, 0x00, KEY_UNKNOWN }, /* HD */
373};
374
Chris Pascoe0029ee12006-01-09 18:21:28 -0200375static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
376{
Chris Pascoed9ed8812006-02-07 06:49:11 -0200377 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
Chris Pascoe0029ee12006-01-09 18:21:28 -0200378 static u8 reset [] = { RESET, 0x80 };
379 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
380 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
381 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
382 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
383
384 mt352_write(fe, clock_config, sizeof(clock_config));
385 udelay(200);
386 mt352_write(fe, reset, sizeof(reset));
387 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
388
389 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
390 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
391 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
392
393 return 0;
394}
395
Michael Krufky6f447252006-01-11 19:40:33 -0200396static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
397{ /* used in both lgz201 and th7579 */
Michael Krufkyfb51fd22006-02-07 06:49:12 -0200398 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
Michael Krufky6f447252006-01-11 19:40:33 -0200399 static u8 reset [] = { RESET, 0x80 };
400 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
401 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
402 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
403 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
404
405 mt352_write(fe, clock_config, sizeof(clock_config));
406 udelay(200);
407 mt352_write(fe, reset, sizeof(reset));
408 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
409
410 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
411 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
412 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
413 return 0;
414}
415
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200416static struct cx22702_config cxusb_cx22702_config = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700417 .demod_address = 0x63,
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700418 .output_mode = CX22702_PARALLEL_OUTPUT,
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700419};
420
Michael Krufkyfddd6322006-02-27 00:08:17 -0300421static struct lgdt330x_config cxusb_lgdt3303_config = {
Michael Krufkyeffee032006-01-09 15:25:47 -0200422 .demod_address = 0x0e,
423 .demod_chip = LGDT3303,
Michael Krufkyeffee032006-01-09 15:25:47 -0200424};
425
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200426static struct mt352_config cxusb_dee1601_config = {
Chris Pascoe0029ee12006-01-09 18:21:28 -0200427 .demod_address = 0x0f,
428 .demod_init = cxusb_dee1601_demod_init,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200429};
430
Michael Krufkyc9ce3942006-06-11 04:24:31 -0300431static struct zl10353_config cxusb_zl10353_dee1601_config = {
432 .demod_address = 0x0f,
Chris Pascoe8fb95782006-08-10 03:17:16 -0300433 .parallel_ts = 1,
Michael Krufkyc9ce3942006-06-11 04:24:31 -0300434};
435
Adrian Bunk6fe00b02006-04-19 20:49:28 -0300436static struct mt352_config cxusb_mt352_config = {
Michael Krufky6f447252006-01-11 19:40:33 -0200437 /* used in both lgz201 and th7579 */
438 .demod_address = 0x0f,
439 .demod_init = cxusb_mt352_demod_init,
Michael Krufky6f447252006-01-11 19:40:33 -0200440};
441
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300442static struct zl10353_config cxusb_zl10353_xc3028_config = {
443 .demod_address = 0x0f,
Chris Pascoea1dcd9d2007-11-20 08:17:54 -0300444 .if2 = 45600,
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300445 .no_tuner = 1,
446 .parallel_ts = 1,
447};
448
Chris Pascoe702a6762007-11-20 03:34:11 -0300449static struct mt352_config cxusb_mt352_xc3028_config = {
450 .demod_address = 0x0f,
451 .if2 = 4560,
452 .no_tuner = 1,
453 .demod_init = cxusb_mt352_demod_init,
454};
455
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700456/* Callbacks for DVB USB */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300457static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700458{
Michael Krufkycb89cd32008-04-22 14:46:16 -0300459 dvb_attach(simple_tuner_attach, adap->fe,
460 &adap->dev->i2c_adap, 0x61,
461 TUNER_PHILIPS_FMD1216ME_MK3);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700462 return 0;
463}
464
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300465static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200466{
Michael Krufky79a54cb2006-12-05 14:20:06 -0300467 dvb_attach(dvb_pll_attach, adap->fe, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300468 NULL, DVB_PLL_THOMSON_DTT7579);
Chris Pascoe0029ee12006-01-09 18:21:28 -0200469 return 0;
470}
471
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300472static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky6f447252006-01-11 19:40:33 -0200473{
Michael Krufky47a99912007-06-12 16:10:51 -0300474 dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
Michael Krufky6f447252006-01-11 19:40:33 -0200475 return 0;
476}
477
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300478static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky6f447252006-01-11 19:40:33 -0200479{
Michael Krufky79a54cb2006-12-05 14:20:06 -0300480 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300481 NULL, DVB_PLL_THOMSON_DTT7579);
Patrick Boettcher332bed52006-05-14 04:49:00 -0300482 return 0;
483}
484
Michael Krufkyf71a56c2006-10-13 21:55:57 -0300485static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher332bed52006-05-14 04:49:00 -0300486{
Michael Krufky827855d2008-04-22 14:46:16 -0300487 dvb_attach(simple_tuner_attach, adap->fe,
488 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
Michael Krufky6f447252006-01-11 19:40:33 -0200489 return 0;
490}
491
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300492static int dvico_bluebird_xc2028_callback(void *ptr, int command, int arg)
493{
494 struct dvb_usb_device *d = ptr;
495
496 switch (command) {
497 case XC2028_TUNER_RESET:
Harvey Harrison708bebd2008-04-08 23:20:00 -0300498 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300499 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
500 break;
501 case XC2028_RESET_CLK:
Harvey Harrison708bebd2008-04-08 23:20:00 -0300502 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300503 break;
504 default:
Harvey Harrison708bebd2008-04-08 23:20:00 -0300505 deb_info("%s: unknown command %d, arg %d\n", __func__,
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300506 command, arg);
507 return -EINVAL;
508 }
509
510 return 0;
511}
512
513static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
514{
515 struct dvb_frontend *fe;
516 struct xc2028_config cfg = {
517 .i2c_adap = &adap->dev->i2c_adap,
518 .i2c_addr = 0x61,
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300519 .callback = dvico_bluebird_xc2028_callback,
520 };
521 static struct xc2028_ctrl ctl = {
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300522 .fname = "xc3028-dvico-au-01.fw",
523 .max_len = 64,
524 .scode_table = ZARLINK456,
525 };
526
527 fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
528 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
529 return -EIO;
530
531 fe->ops.tuner_ops.set_config(fe, &ctl);
532
533 return 0;
534}
535
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300536static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700537{
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700538 u8 b;
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300539 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700540 err("set interface failed");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700541
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300542 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700543
Michael Krufkyf35db232006-12-05 14:53:39 -0300544 if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
545 &adap->dev->i2c_adap)) != NULL)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700546 return 0;
547
548 return -EIO;
549}
550
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300551static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufkyeffee032006-01-09 15:25:47 -0200552{
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300553 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
Michael Krufkyeffee032006-01-09 15:25:47 -0200554 err("set interface failed");
555
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300556 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
Michael Krufkyeffee032006-01-09 15:25:47 -0200557
Michael Krufkyf35db232006-12-05 14:53:39 -0300558 if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
559 &adap->dev->i2c_adap)) != NULL)
Michael Krufkyeffee032006-01-09 15:25:47 -0200560 return 0;
561
562 return -EIO;
563}
564
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300565static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200566{
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300567 /* used in both lgz201 and th7579 */
568 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200569 err("set interface failed");
570
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300571 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
Chris Pascoe0029ee12006-01-09 18:21:28 -0200572
Michael Krufkyf35db232006-12-05 14:53:39 -0300573 if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
574 &adap->dev->i2c_adap)) != NULL)
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300575 return 0;
576
577 return -EIO;
578}
579
580static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
581{
582 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
583 err("set interface failed");
584
585 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
586
Michael Krufkyf35db232006-12-05 14:53:39 -0300587 if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
588 &adap->dev->i2c_adap)) != NULL) ||
589 ((adap->fe = dvb_attach(zl10353_attach,
590 &cxusb_zl10353_dee1601_config,
591 &adap->dev->i2c_adap)) != NULL))
Chris Pascoe0029ee12006-01-09 18:21:28 -0200592 return 0;
593
594 return -EIO;
595}
596
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300597static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
598{
599 u8 ircode[4];
600 int i;
601 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
602 .buf = ircode, .len = 4 };
603
604 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
605 err("set interface failed");
606
607 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
608
609 /* reset the tuner and demodulator */
610 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
611 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
612 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
613
614 if ((adap->fe = dvb_attach(zl10353_attach,
615 &cxusb_zl10353_xc3028_config,
616 &adap->dev->i2c_adap)) == NULL)
617 return -EIO;
618
619 /* try to determine if there is no IR decoder on the I2C bus */
620 for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
621 msleep(20);
622 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
623 goto no_IR;
624 if (ircode[0] == 0 && ircode[1] == 0)
625 continue;
626 if (ircode[2] + ircode[3] != 0xff) {
627no_IR:
628 adap->dev->props.rc_key_map = NULL;
629 info("No IR receiver detected on this device.");
630 break;
631 }
632 }
633
634 return 0;
635}
636
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300637static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
638{
639 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
640 err("set interface failed");
641
642 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
643
644 /* reset the tuner and demodulator */
645 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
646 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
647 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
648
649 if ((adap->fe = dvb_attach(zl10353_attach,
650 &cxusb_zl10353_xc3028_config,
651 &adap->dev->i2c_adap)) != NULL)
652 return 0;
653
Chris Pascoe702a6762007-11-20 03:34:11 -0300654 if ((adap->fe = dvb_attach(mt352_attach,
655 &cxusb_mt352_xc3028_config,
656 &adap->dev->i2c_adap)) != NULL)
657 return 0;
658
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300659 return -EIO;
660}
661
Patrick Boettcherf5373782006-01-09 18:21:38 -0200662/*
Chris Pascoe702a6762007-11-20 03:34:11 -0300663 * DViCO has shipped two devices with the same USB ID, but only one of them
664 * needs a firmware download. Check the device class details to see if they
665 * have non-default values to decide whether the device is actually cold or
666 * not, and forget a match if it turns out we selected the wrong device.
667 */
668static int bluebird_fx2_identify_state(struct usb_device *udev,
669 struct dvb_usb_device_properties *props,
670 struct dvb_usb_device_description **desc,
671 int *cold)
672{
673 int wascold = *cold;
674
675 *cold = udev->descriptor.bDeviceClass == 0xff &&
676 udev->descriptor.bDeviceSubClass == 0xff &&
677 udev->descriptor.bDeviceProtocol == 0xff;
678
679 if (*cold && !wascold)
680 *desc = NULL;
681
682 return 0;
683}
684
685/*
Patrick Boettcherf5373782006-01-09 18:21:38 -0200686 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
687 * firmware file before download.
688 */
689
Chris Pascoe702a6762007-11-20 03:34:11 -0300690static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
Michael Krufkyf35db232006-12-05 14:53:39 -0300691static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
692 const struct firmware *fw)
Patrick Boettcherf5373782006-01-09 18:21:38 -0200693{
Chris Pascoe702a6762007-11-20 03:34:11 -0300694 int pos;
Patrick Boettcherf5373782006-01-09 18:21:38 -0200695
Chris Pascoe702a6762007-11-20 03:34:11 -0300696 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
697 int idoff = dvico_firmware_id_offsets[pos];
Patrick Boettcherf5373782006-01-09 18:21:38 -0200698
Chris Pascoe702a6762007-11-20 03:34:11 -0300699 if (fw->size < idoff + 4)
700 continue;
Patrick Boettcherf5373782006-01-09 18:21:38 -0200701
Chris Pascoe702a6762007-11-20 03:34:11 -0300702 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
703 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
704 fw->data[idoff + 2] =
705 le16_to_cpu(udev->descriptor.idProduct) + 1;
706 fw->data[idoff + 3] =
707 le16_to_cpu(udev->descriptor.idProduct) >> 8;
708
709 return usb_cypress_load_firmware(udev, fw, CYPRESS_FX2);
710 }
Patrick Boettcherf5373782006-01-09 18:21:38 -0200711 }
712
713 return -EINVAL;
714}
715
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700716/* DVB USB Driver stuff */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300717static struct dvb_usb_device_properties cxusb_medion_properties;
718static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
719static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
720static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
721static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300722static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300723static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
Chris Pascoe702a6762007-11-20 03:34:11 -0300724static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700725
726static int cxusb_probe(struct usb_interface *intf,
Michael Krufkyf35db232006-12-05 14:53:39 -0300727 const struct usb_device_id *id)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700728{
Janne Grunau78e92002008-04-09 19:13:13 -0300729 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
730 THIS_MODULE, NULL, adapter_nr) ||
731 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
732 THIS_MODULE, NULL, adapter_nr) ||
733 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
734 THIS_MODULE, NULL, adapter_nr) ||
735 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
736 THIS_MODULE, NULL, adapter_nr) ||
737 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
738 THIS_MODULE, NULL, adapter_nr) ||
739 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
740 THIS_MODULE, NULL, adapter_nr) ||
741 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
742 THIS_MODULE, NULL, adapter_nr) ||
743 0 == dvb_usb_device_init(intf,
744 &cxusb_bluebird_nano2_needsfirmware_properties,
745 THIS_MODULE, NULL, adapter_nr))
Michael Krufkyeffee032006-01-09 15:25:47 -0200746 return 0;
Michael Krufkyeffee032006-01-09 15:25:47 -0200747
748 return -EINVAL;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700749}
750
751static struct usb_device_id cxusb_table [] = {
Michael Krufkyf35db232006-12-05 14:53:39 -0300752 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
753 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
754 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
755 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
756 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
757 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
758 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
759 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
760 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
761 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
762 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
763 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
764 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300765 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300766 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
Chris Pascoe702a6762007-11-20 03:34:11 -0300767 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
Michael Krufkyf35db232006-12-05 14:53:39 -0300768 {} /* Terminating entry */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700769};
770MODULE_DEVICE_TABLE (usb, cxusb_table);
771
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300772static struct dvb_usb_device_properties cxusb_medion_properties = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700773 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
774
775 .usb_ctrl = CYPRESS_FX2,
776
777 .size_of_priv = sizeof(struct cxusb_state),
778
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300779 .num_adapters = 1,
780 .adapter = {
781 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300782 .streaming_ctrl = cxusb_streaming_ctrl,
783 .frontend_attach = cxusb_cx22702_frontend_attach,
784 .tuner_attach = cxusb_fmd1216me_tuner_attach,
785 /* parameter for the MPEG2-data transfer */
786 .stream = {
787 .type = USB_BULK,
788 .count = 5,
789 .endpoint = 0x02,
790 .u = {
791 .bulk = {
792 .buffersize = 8192,
793 }
794 }
795 },
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700796
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300797 },
798 },
799 .power_ctrl = cxusb_power_ctrl,
800
801 .i2c_algo = &cxusb_i2c_algo,
802
803 .generic_bulk_ctrl_endpoint = 0x01,
804
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700805 .num_device_descs = 1,
806 .devices = {
807 { "Medion MD95700 (MDUSBTV-HYBRID)",
808 { NULL },
809 { &cxusb_table[0], NULL },
810 },
811 }
812};
813
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300814static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
Michael Krufkyeffee032006-01-09 15:25:47 -0200815 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
816
Patrick Boettcherf5373782006-01-09 18:21:38 -0200817 .usb_ctrl = DEVICE_SPECIFIC,
818 .firmware = "dvb-usb-bluebird-01.fw",
819 .download_firmware = bluebird_patch_dvico_firmware_download,
Michael Krufky37bdfa02006-01-09 15:25:47 -0200820 /* use usb alt setting 0 for EP4 transfer (dvb-t),
821 use usb alt setting 7 for EP2 transfer (atsc) */
Michael Krufkyeffee032006-01-09 15:25:47 -0200822
823 .size_of_priv = sizeof(struct cxusb_state),
824
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300825 .num_adapters = 1,
826 .adapter = {
827 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300828 .streaming_ctrl = cxusb_streaming_ctrl,
829 .frontend_attach = cxusb_lgdt3303_frontend_attach,
Michael Krufkyf71a56c2006-10-13 21:55:57 -0300830 .tuner_attach = cxusb_lgh064f_tuner_attach,
Michael Krufkyeffee032006-01-09 15:25:47 -0200831
Patrick Boettcher01451e72006-10-13 11:34:46 -0300832 /* parameter for the MPEG2-data transfer */
833 .stream = {
834 .type = USB_BULK,
835 .count = 5,
836 .endpoint = 0x02,
837 .u = {
838 .bulk = {
839 .buffersize = 8192,
840 }
841 }
842 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300843 },
844 },
845
846 .power_ctrl = cxusb_bluebird_power_ctrl,
847
Michael Krufkyeffee032006-01-09 15:25:47 -0200848 .i2c_algo = &cxusb_i2c_algo,
849
Michael Krufkyc1501782006-03-26 05:43:36 -0300850 .rc_interval = 100,
851 .rc_key_map = dvico_portable_rc_keys,
852 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
853 .rc_query = cxusb_rc_query,
854
Michael Krufkyeffee032006-01-09 15:25:47 -0200855 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufkyeffee032006-01-09 15:25:47 -0200856
857 .num_device_descs = 1,
858 .devices = {
859 { "DViCO FusionHDTV5 USB Gold",
860 { &cxusb_table[1], NULL },
861 { &cxusb_table[2], NULL },
862 },
863 }
864};
865
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300866static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
Chris Pascoe0029ee12006-01-09 18:21:28 -0200867 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
868
Patrick Boettcherf5373782006-01-09 18:21:38 -0200869 .usb_ctrl = DEVICE_SPECIFIC,
870 .firmware = "dvb-usb-bluebird-01.fw",
871 .download_firmware = bluebird_patch_dvico_firmware_download,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200872 /* use usb alt setting 0 for EP4 transfer (dvb-t),
873 use usb alt setting 7 for EP2 transfer (atsc) */
874
875 .size_of_priv = sizeof(struct cxusb_state),
876
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300877 .num_adapters = 1,
878 .adapter = {
879 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300880 .streaming_ctrl = cxusb_streaming_ctrl,
881 .frontend_attach = cxusb_dee1601_frontend_attach,
882 .tuner_attach = cxusb_dee1601_tuner_attach,
883 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300884 .stream = {
885 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300886 .count = 5,
887 .endpoint = 0x04,
888 .u = {
889 .bulk = {
890 .buffersize = 8192,
891 }
892 }
893 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300894 },
895 },
896
897 .power_ctrl = cxusb_bluebird_power_ctrl,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200898
899 .i2c_algo = &cxusb_i2c_algo,
900
Chris Pascoe7c239702006-01-09 18:21:29 -0200901 .rc_interval = 150,
902 .rc_key_map = dvico_mce_rc_keys,
903 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
904 .rc_query = cxusb_rc_query,
905
Chris Pascoe0029ee12006-01-09 18:21:28 -0200906 .generic_bulk_ctrl_endpoint = 0x01,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200907
Michael Krufky587c03d2006-09-28 02:16:01 -0300908 .num_device_descs = 3,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200909 .devices = {
910 { "DViCO FusionHDTV DVB-T Dual USB",
911 { &cxusb_table[3], NULL },
912 { &cxusb_table[4], NULL },
913 },
Michael Krufkyac9ffb92006-01-11 23:21:00 -0200914 { "DigitalNow DVB-T Dual USB",
915 { &cxusb_table[9], NULL },
916 { &cxusb_table[10], NULL },
917 },
Michael Krufky587c03d2006-09-28 02:16:01 -0300918 { "DViCO FusionHDTV DVB-T Dual Digital 2",
919 { &cxusb_table[11], NULL },
920 { &cxusb_table[12], NULL },
921 },
Chris Pascoe0029ee12006-01-09 18:21:28 -0200922 }
923};
924
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300925static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
Michael Krufky6f447252006-01-11 19:40:33 -0200926 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
927
928 .usb_ctrl = DEVICE_SPECIFIC,
929 .firmware = "dvb-usb-bluebird-01.fw",
930 .download_firmware = bluebird_patch_dvico_firmware_download,
931 /* use usb alt setting 0 for EP4 transfer (dvb-t),
932 use usb alt setting 7 for EP2 transfer (atsc) */
933
934 .size_of_priv = sizeof(struct cxusb_state),
935
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300936 .num_adapters = 2,
937 .adapter = {
938 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300939 .streaming_ctrl = cxusb_streaming_ctrl,
940 .frontend_attach = cxusb_mt352_frontend_attach,
941 .tuner_attach = cxusb_lgz201_tuner_attach,
Michael Krufky6f447252006-01-11 19:40:33 -0200942
Patrick Boettcher01451e72006-10-13 11:34:46 -0300943 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300944 .stream = {
945 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300946 .count = 5,
947 .endpoint = 0x04,
948 .u = {
949 .bulk = {
950 .buffersize = 8192,
951 }
952 }
953 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300954 },
955 },
956 .power_ctrl = cxusb_bluebird_power_ctrl,
957
Michael Krufky6f447252006-01-11 19:40:33 -0200958 .i2c_algo = &cxusb_i2c_algo,
959
Michael Krufkyc1501782006-03-26 05:43:36 -0300960 .rc_interval = 100,
961 .rc_key_map = dvico_portable_rc_keys,
962 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
963 .rc_query = cxusb_rc_query,
964
Michael Krufky6f447252006-01-11 19:40:33 -0200965 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufky6f447252006-01-11 19:40:33 -0200966 .num_device_descs = 1,
967 .devices = {
968 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
969 { &cxusb_table[5], NULL },
970 { &cxusb_table[6], NULL },
971 },
972 }
973};
974
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300975static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
Michael Krufky6f447252006-01-11 19:40:33 -0200976 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
977
978 .usb_ctrl = DEVICE_SPECIFIC,
979 .firmware = "dvb-usb-bluebird-01.fw",
980 .download_firmware = bluebird_patch_dvico_firmware_download,
981 /* use usb alt setting 0 for EP4 transfer (dvb-t),
982 use usb alt setting 7 for EP2 transfer (atsc) */
983
984 .size_of_priv = sizeof(struct cxusb_state),
985
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300986 .num_adapters = 1,
987 .adapter = {
988 {
Patrick Boettcher01451e72006-10-13 11:34:46 -0300989 .streaming_ctrl = cxusb_streaming_ctrl,
990 .frontend_attach = cxusb_mt352_frontend_attach,
991 .tuner_attach = cxusb_dtt7579_tuner_attach,
Michael Krufky6f447252006-01-11 19:40:33 -0200992
Patrick Boettcher01451e72006-10-13 11:34:46 -0300993 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300994 .stream = {
995 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -0300996 .count = 5,
997 .endpoint = 0x04,
998 .u = {
999 .bulk = {
1000 .buffersize = 8192,
1001 }
1002 }
1003 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001004 },
1005 },
1006 .power_ctrl = cxusb_bluebird_power_ctrl,
1007
Michael Krufky6f447252006-01-11 19:40:33 -02001008 .i2c_algo = &cxusb_i2c_algo,
1009
Michael Krufkyc1501782006-03-26 05:43:36 -03001010 .rc_interval = 100,
1011 .rc_key_map = dvico_portable_rc_keys,
1012 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1013 .rc_query = cxusb_rc_query,
1014
Michael Krufky6f447252006-01-11 19:40:33 -02001015 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufky6f447252006-01-11 19:40:33 -02001016
1017 .num_device_descs = 1,
1018 .devices = {
1019 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1020 { &cxusb_table[7], NULL },
1021 { &cxusb_table[8], NULL },
1022 },
1023 }
1024};
1025
Chris Pascoeaeb012b2007-11-19 21:57:10 -03001026static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1027 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1028
1029 .usb_ctrl = CYPRESS_FX2,
1030
1031 .size_of_priv = sizeof(struct cxusb_state),
1032
1033 .num_adapters = 1,
1034 .adapter = {
1035 {
1036 .streaming_ctrl = cxusb_streaming_ctrl,
1037 .frontend_attach = cxusb_dualdig4_frontend_attach,
1038 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1039 /* parameter for the MPEG2-data transfer */
1040 .stream = {
1041 .type = USB_BULK,
1042 .count = 5,
1043 .endpoint = 0x02,
1044 .u = {
1045 .bulk = {
1046 .buffersize = 8192,
1047 }
1048 }
1049 },
1050 },
1051 },
1052
1053 .power_ctrl = cxusb_power_ctrl,
1054
1055 .i2c_algo = &cxusb_i2c_algo,
1056
1057 .generic_bulk_ctrl_endpoint = 0x01,
1058
1059 .rc_interval = 100,
1060 .rc_key_map = dvico_mce_rc_keys,
1061 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
1062 .rc_query = cxusb_bluebird2_rc_query,
1063
1064 .num_device_descs = 1,
1065 .devices = {
1066 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1067 { NULL },
1068 { &cxusb_table[13], NULL },
1069 },
1070 }
1071};
1072
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001073static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1074 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1075
1076 .usb_ctrl = CYPRESS_FX2,
Chris Pascoe702a6762007-11-20 03:34:11 -03001077 .identify_state = bluebird_fx2_identify_state,
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001078
1079 .size_of_priv = sizeof(struct cxusb_state),
1080
1081 .num_adapters = 1,
1082 .adapter = {
1083 {
1084 .streaming_ctrl = cxusb_streaming_ctrl,
1085 .frontend_attach = cxusb_nano2_frontend_attach,
1086 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1087 /* parameter for the MPEG2-data transfer */
1088 .stream = {
1089 .type = USB_BULK,
1090 .count = 5,
1091 .endpoint = 0x02,
1092 .u = {
1093 .bulk = {
1094 .buffersize = 8192,
1095 }
1096 }
1097 },
1098 },
1099 },
1100
1101 .power_ctrl = cxusb_nano2_power_ctrl,
1102
1103 .i2c_algo = &cxusb_i2c_algo,
1104
1105 .generic_bulk_ctrl_endpoint = 0x01,
1106
1107 .rc_interval = 100,
1108 .rc_key_map = dvico_portable_rc_keys,
1109 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1110 .rc_query = cxusb_bluebird2_rc_query,
1111
1112 .num_device_descs = 1,
1113 .devices = {
1114 { "DViCO FusionHDTV DVB-T NANO2",
1115 { NULL },
1116 { &cxusb_table[14], NULL },
1117 },
1118 }
1119};
1120
Chris Pascoe702a6762007-11-20 03:34:11 -03001121static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
1122 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1123
1124 .usb_ctrl = DEVICE_SPECIFIC,
1125 .firmware = "dvb-usb-bluebird-02.fw",
1126 .download_firmware = bluebird_patch_dvico_firmware_download,
1127 .identify_state = bluebird_fx2_identify_state,
1128
1129 .size_of_priv = sizeof(struct cxusb_state),
1130
1131 .num_adapters = 1,
1132 .adapter = {
1133 {
1134 .streaming_ctrl = cxusb_streaming_ctrl,
1135 .frontend_attach = cxusb_nano2_frontend_attach,
1136 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1137 /* parameter for the MPEG2-data transfer */
1138 .stream = {
1139 .type = USB_BULK,
1140 .count = 5,
1141 .endpoint = 0x02,
1142 .u = {
1143 .bulk = {
1144 .buffersize = 8192,
1145 }
1146 }
1147 },
1148 },
1149 },
1150
1151 .power_ctrl = cxusb_nano2_power_ctrl,
1152
1153 .i2c_algo = &cxusb_i2c_algo,
1154
1155 .generic_bulk_ctrl_endpoint = 0x01,
1156
1157 .rc_interval = 100,
1158 .rc_key_map = dvico_portable_rc_keys,
1159 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1160 .rc_query = cxusb_rc_query,
1161
1162 .num_device_descs = 1,
1163 .devices = {
1164 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
1165 { &cxusb_table[14], NULL },
1166 { &cxusb_table[15], NULL },
1167 },
1168 }
1169};
1170
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001171static struct usb_driver cxusb_driver = {
Patrick Boettcher63b5c1c2005-07-07 17:58:30 -07001172 .name = "dvb_usb_cxusb",
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001173 .probe = cxusb_probe,
Michael Krufkyf35db232006-12-05 14:53:39 -03001174 .disconnect = dvb_usb_device_exit,
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001175 .id_table = cxusb_table,
1176};
1177
1178/* module stuff */
1179static int __init cxusb_module_init(void)
1180{
1181 int result;
1182 if ((result = usb_register(&cxusb_driver))) {
1183 err("usb_register failed. Error number %d",result);
1184 return result;
1185 }
1186
1187 return 0;
1188}
1189
1190static void __exit cxusb_module_exit(void)
1191{
1192 /* deregister this driver from the USB subsystem */
1193 usb_deregister(&cxusb_driver);
1194}
1195
1196module_init (cxusb_module_init);
1197module_exit (cxusb_module_exit);
1198
1199MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
Michael Krufky5b9ed282006-10-15 14:51:08 -03001200MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
Michael Krufkyf4efb4d2006-01-13 14:10:25 -02001201MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001202MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
1203MODULE_VERSION("1.0-alpha");
1204MODULE_LICENSE("GPL");