blob: 05fb28e9c69e18887b52400219140caaeded92dc [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>
David Woodhousee62f89f2008-05-24 00:12:42 +010027#include <linux/vmalloc.h>
Michael Krufky827855d2008-04-22 14:46:16 -030028
Patrick Boettcher22c6d932005-07-07 17:58:10 -070029#include "cxusb.h"
30
31#include "cx22702.h"
Michael Krufkyeffee032006-01-09 15:25:47 -020032#include "lgdt330x.h"
Chris Pascoe0029ee12006-01-09 18:21:28 -020033#include "mt352.h"
34#include "mt352_priv.h"
Michael Krufkyc9ce3942006-06-11 04:24:31 -030035#include "zl10353.h"
Chris Pascoeaeb012b2007-11-19 21:57:10 -030036#include "tuner-xc2028.h"
Michael Krufky827855d2008-04-22 14:46:16 -030037#include "tuner-simple.h"
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -030038#include "mxl5005s.h"
David Wongb18bd1d2009-10-26 09:41:22 -030039#include "max2165.h"
Anton Blanchard8d798982008-08-09 12:23:15 -030040#include "dib7000p.h"
41#include "dib0070.h"
David T.L. Wong6bf1a992009-08-05 13:07:10 -030042#include "lgs8gxx.h"
David Wongb18bd1d2009-10-26 09:41:22 -030043#include "atbm8830.h"
Patrick Boettcher22c6d932005-07-07 17:58:10 -070044
45/* debug */
Adrian Bunk53133af2007-11-05 14:07:06 -030046static int dvb_usb_cxusb_debug;
Michael Krufkyf35db232006-12-05 14:53:39 -030047module_param_named(debug, dvb_usb_cxusb_debug, int, 0644);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070048MODULE_PARM_DESC(debug, "set debugging level (1=rc (or-able))." DVB_USB_DEBUG_STATUS);
Janne Grunau78e92002008-04-09 19:13:13 -030049
50DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
51
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -030052#define deb_info(args...) dprintk(dvb_usb_cxusb_debug, 0x03, args)
53#define deb_i2c(args...) dprintk(dvb_usb_cxusb_debug, 0x02, args)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070054
55static int cxusb_ctrl_msg(struct dvb_usb_device *d,
Michael Krufkyf35db232006-12-05 14:53:39 -030056 u8 cmd, u8 *wbuf, int wlen, u8 *rbuf, int rlen)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070057{
58 int wo = (rbuf == NULL || rlen == 0); /* write-only */
59 u8 sndbuf[1+wlen];
Michael Krufkyf35db232006-12-05 14:53:39 -030060 memset(sndbuf, 0, 1+wlen);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070061
62 sndbuf[0] = cmd;
Michael Krufkyf35db232006-12-05 14:53:39 -030063 memcpy(&sndbuf[1], wbuf, wlen);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070064 if (wo)
Chris Pascoeb17f1092007-11-19 02:42:44 -030065 return dvb_usb_generic_write(d, sndbuf, 1+wlen);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070066 else
Chris Pascoeb17f1092007-11-19 02:42:44 -030067 return dvb_usb_generic_rw(d, sndbuf, 1+wlen, rbuf, rlen, 0);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070068}
69
Patrick Boettchere2efeab2005-09-09 13:02:51 -070070/* GPIO */
71static void cxusb_gpio_tuner(struct dvb_usb_device *d, int onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070072{
73 struct cxusb_state *st = d->priv;
Michael Krufkyf35db232006-12-05 14:53:39 -030074 u8 o[2], i;
Patrick Boettcher22c6d932005-07-07 17:58:10 -070075
Patrick Boettchere2efeab2005-09-09 13:02:51 -070076 if (st->gpio_write_state[GPIO_TUNER] == onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -070077 return;
78
Patrick Boettchere2efeab2005-09-09 13:02:51 -070079 o[0] = GPIO_TUNER;
80 o[1] = onoff;
Michael Krufkyf35db232006-12-05 14:53:39 -030081 cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
Patrick Boettcher22c6d932005-07-07 17:58:10 -070082
83 if (i != 0x01)
Patrick Boettchere2efeab2005-09-09 13:02:51 -070084 deb_info("gpio_write failed.\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -070085
Patrick Boettchere2efeab2005-09-09 13:02:51 -070086 st->gpio_write_state[GPIO_TUNER] = onoff;
Patrick Boettcher22c6d932005-07-07 17:58:10 -070087}
88
Chris Pascoeaeb012b2007-11-19 21:57:10 -030089static int cxusb_bluebird_gpio_rw(struct dvb_usb_device *d, u8 changemask,
90 u8 newval)
91{
92 u8 o[2], gpio_state;
93 int rc;
94
95 o[0] = 0xff & ~changemask; /* mask of bits to keep */
96 o[1] = newval & changemask; /* new values for bits */
97
98 rc = cxusb_ctrl_msg(d, CMD_BLUEBIRD_GPIO_RW, o, 2, &gpio_state, 1);
99 if (rc < 0 || (gpio_state & changemask) != (newval & changemask))
100 deb_info("bluebird_gpio_write failed.\n");
101
102 return rc < 0 ? rc : gpio_state;
103}
104
105static void cxusb_bluebird_gpio_pulse(struct dvb_usb_device *d, u8 pin, int low)
106{
107 cxusb_bluebird_gpio_rw(d, pin, low ? 0 : pin);
108 msleep(5);
109 cxusb_bluebird_gpio_rw(d, pin, low ? pin : 0);
110}
111
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300112static void cxusb_nano2_led(struct dvb_usb_device *d, int onoff)
113{
114 cxusb_bluebird_gpio_rw(d, 0x40, onoff ? 0 : 0x40);
115}
116
Timothy Leedfbdce02008-08-09 13:36:51 -0300117static int cxusb_d680_dmb_gpio_tuner(struct dvb_usb_device *d,
118 u8 addr, int onoff)
119{
120 u8 o[2] = {addr, onoff};
121 u8 i;
122 int rc;
123
124 rc = cxusb_ctrl_msg(d, CMD_GPIO_WRITE, o, 2, &i, 1);
125
126 if (rc < 0)
127 return rc;
128 if (i == 0x01)
129 return 0;
130 else {
131 deb_info("gpio_write failed.\n");
132 return -EIO;
133 }
134}
135
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700136/* I2C */
Michael Krufkyf35db232006-12-05 14:53:39 -0300137static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
138 int num)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700139{
140 struct dvb_usb_device *d = i2c_get_adapdata(adap);
141 int i;
142
Ingo Molnar3593cab2006-02-07 06:49:14 -0200143 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700144 return -EAGAIN;
145
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700146 for (i = 0; i < num; i++) {
147
Michael Krufky5e805ef2006-03-23 00:01:34 -0300148 if (d->udev->descriptor.idVendor == USB_VID_MEDION)
149 switch (msg[i].addr) {
Michael Krufkyf35db232006-12-05 14:53:39 -0300150 case 0x63:
151 cxusb_gpio_tuner(d, 0);
152 break;
153 default:
154 cxusb_gpio_tuner(d, 1);
155 break;
Michael Krufky5e805ef2006-03-23 00:01:34 -0300156 }
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700157
Chris Pascoe272479d72007-11-19 03:01:22 -0300158 if (msg[i].flags & I2C_M_RD) {
159 /* read only */
160 u8 obuf[3], ibuf[1+msg[i].len];
161 obuf[0] = 0;
162 obuf[1] = msg[i].len;
163 obuf[2] = msg[i].addr;
164 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
165 obuf, 3,
166 ibuf, 1+msg[i].len) < 0) {
167 warn("i2c read failed");
168 break;
169 }
170 memcpy(msg[i].buf, &ibuf[1], msg[i].len);
Chris Pascoea644e4a2007-11-19 03:05:09 -0300171 } else if (i+1 < num && (msg[i+1].flags & I2C_M_RD) &&
172 msg[i].addr == msg[i+1].addr) {
173 /* write to then read from same address */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700174 u8 obuf[3+msg[i].len], ibuf[1+msg[i+1].len];
175 obuf[0] = msg[i].len;
176 obuf[1] = msg[i+1].len;
177 obuf[2] = msg[i].addr;
Michael Krufkyf35db232006-12-05 14:53:39 -0300178 memcpy(&obuf[3], msg[i].buf, msg[i].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700179
180 if (cxusb_ctrl_msg(d, CMD_I2C_READ,
Michael Krufkyf35db232006-12-05 14:53:39 -0300181 obuf, 3+msg[i].len,
182 ibuf, 1+msg[i+1].len) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700183 break;
184
185 if (ibuf[0] != 0x08)
Michael Krufkyae62e3d2006-03-23 01:11:18 -0300186 deb_i2c("i2c read may have failed\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700187
Michael Krufkyf35db232006-12-05 14:53:39 -0300188 memcpy(msg[i+1].buf, &ibuf[1], msg[i+1].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700189
190 i++;
Chris Pascoe272479d72007-11-19 03:01:22 -0300191 } else {
192 /* write only */
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700193 u8 obuf[2+msg[i].len], ibuf;
194 obuf[0] = msg[i].addr;
195 obuf[1] = msg[i].len;
Michael Krufkyf35db232006-12-05 14:53:39 -0300196 memcpy(&obuf[2], msg[i].buf, msg[i].len);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700197
Michael Krufkyf35db232006-12-05 14:53:39 -0300198 if (cxusb_ctrl_msg(d, CMD_I2C_WRITE, obuf,
199 2+msg[i].len, &ibuf,1) < 0)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700200 break;
201 if (ibuf != 0x08)
Michael Krufkyae62e3d2006-03-23 01:11:18 -0300202 deb_i2c("i2c write may have failed\n");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700203 }
204 }
205
Ingo Molnar3593cab2006-02-07 06:49:14 -0200206 mutex_unlock(&d->i2c_mutex);
Chris Pascoe13e001d2007-11-19 02:48:27 -0300207 return i == num ? num : -EREMOTEIO;
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700208}
209
210static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
211{
212 return I2C_FUNC_I2C;
213}
214
215static struct i2c_algorithm cxusb_i2c_algo = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700216 .master_xfer = cxusb_i2c_xfer,
217 .functionality = cxusb_i2c_func,
218};
219
220static int cxusb_power_ctrl(struct dvb_usb_device *d, int onoff)
221{
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700222 u8 b = 0;
223 if (onoff)
224 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
225 else
226 return cxusb_ctrl_msg(d, CMD_POWER_OFF, &b, 1, NULL, 0);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700227}
228
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -0300229static int cxusb_aver_power_ctrl(struct dvb_usb_device *d, int onoff)
230{
231 int ret;
232 if (!onoff)
233 return cxusb_ctrl_msg(d, CMD_POWER_OFF, NULL, 0, NULL, 0);
234 if (d->state == DVB_USB_STATE_INIT &&
235 usb_set_interface(d->udev, 0, 0) < 0)
236 err("set interface failed");
Hans Verkuilc6eb8ea2008-09-03 17:11:54 -0300237 do {} while (!(ret = cxusb_ctrl_msg(d, CMD_POWER_ON, NULL, 0, NULL, 0)) &&
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -0300238 !(ret = cxusb_ctrl_msg(d, 0x15, NULL, 0, NULL, 0)) &&
239 !(ret = cxusb_ctrl_msg(d, 0x17, NULL, 0, NULL, 0)) && 0);
240 if (!ret) {
241 /* FIXME: We don't know why, but we need to configure the
242 * lgdt3303 with the register settings below on resume */
243 int i;
244 u8 buf, bufs[] = {
245 0x0e, 0x2, 0x00, 0x7f,
246 0x0e, 0x2, 0x02, 0xfe,
247 0x0e, 0x2, 0x02, 0x01,
248 0x0e, 0x2, 0x00, 0x03,
249 0x0e, 0x2, 0x0d, 0x40,
250 0x0e, 0x2, 0x0e, 0x87,
251 0x0e, 0x2, 0x0f, 0x8e,
252 0x0e, 0x2, 0x10, 0x01,
253 0x0e, 0x2, 0x14, 0xd7,
254 0x0e, 0x2, 0x47, 0x88,
255 };
256 msleep(20);
257 for (i = 0; i < sizeof(bufs)/sizeof(u8); i += 4/sizeof(u8)) {
258 ret = cxusb_ctrl_msg(d, CMD_I2C_WRITE,
259 bufs+i, 4, &buf, 1);
260 if (ret)
261 break;
262 if (buf != 0x8)
263 return -EREMOTEIO;
264 }
265 }
266 return ret;
267}
268
Michael Krufky5691c842006-04-19 20:40:01 -0300269static int cxusb_bluebird_power_ctrl(struct dvb_usb_device *d, int onoff)
270{
271 u8 b = 0;
272 if (onoff)
273 return cxusb_ctrl_msg(d, CMD_POWER_ON, &b, 1, NULL, 0);
274 else
275 return 0;
276}
277
Chris Pascoe5ccaf902007-11-20 01:53:31 -0300278static int cxusb_nano2_power_ctrl(struct dvb_usb_device *d, int onoff)
279{
280 int rc = 0;
281
282 rc = cxusb_power_ctrl(d, onoff);
283 if (!onoff)
284 cxusb_nano2_led(d, 0);
285
286 return rc;
287}
288
Timothy Leedfbdce02008-08-09 13:36:51 -0300289static int cxusb_d680_dmb_power_ctrl(struct dvb_usb_device *d, int onoff)
290{
291 int ret;
292 u8 b;
293 ret = cxusb_power_ctrl(d, onoff);
294 if (!onoff)
295 return ret;
296
297 msleep(128);
298 cxusb_ctrl_msg(d, CMD_DIGITAL, NULL, 0, &b, 1);
299 msleep(100);
300 return ret;
301}
302
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300303static int cxusb_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700304{
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700305 u8 buf[2] = { 0x03, 0x00 };
306 if (onoff)
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300307 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON, buf, 2, NULL, 0);
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700308 else
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300309 cxusb_ctrl_msg(adap->dev, CMD_STREAMING_OFF, NULL, 0, NULL, 0);
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700310
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700311 return 0;
312}
313
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -0300314static int cxusb_aver_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
315{
316 if (onoff)
317 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_ON, NULL, 0, NULL, 0);
318 else
319 cxusb_ctrl_msg(adap->dev, CMD_AVER_STREAM_OFF,
320 NULL, 0, NULL, 0);
321 return 0;
322}
323
Timothy Leedfbdce02008-08-09 13:36:51 -0300324static void cxusb_d680_dmb_drain_message(struct dvb_usb_device *d)
325{
326 int ep = d->props.generic_bulk_ctrl_endpoint;
327 const int timeout = 100;
328 const int junk_len = 32;
329 u8 *junk;
330 int rd_count;
331
332 /* Discard remaining data in video pipe */
333 junk = kmalloc(junk_len, GFP_KERNEL);
334 if (!junk)
335 return;
336 while (1) {
337 if (usb_bulk_msg(d->udev,
338 usb_rcvbulkpipe(d->udev, ep),
339 junk, junk_len, &rd_count, timeout) < 0)
340 break;
341 if (!rd_count)
342 break;
343 }
344 kfree(junk);
345}
346
347static void cxusb_d680_dmb_drain_video(struct dvb_usb_device *d)
348{
349 struct usb_data_stream_properties *p = &d->props.adapter[0].stream;
350 const int timeout = 100;
351 const int junk_len = p->u.bulk.buffersize;
352 u8 *junk;
353 int rd_count;
354
355 /* Discard remaining data in video pipe */
356 junk = kmalloc(junk_len, GFP_KERNEL);
357 if (!junk)
358 return;
359 while (1) {
360 if (usb_bulk_msg(d->udev,
361 usb_rcvbulkpipe(d->udev, p->endpoint),
362 junk, junk_len, &rd_count, timeout) < 0)
363 break;
364 if (!rd_count)
365 break;
366 }
367 kfree(junk);
368}
369
370static int cxusb_d680_dmb_streaming_ctrl(
371 struct dvb_usb_adapter *adap, int onoff)
372{
373 if (onoff) {
374 u8 buf[2] = { 0x03, 0x00 };
375 cxusb_d680_dmb_drain_video(adap->dev);
376 return cxusb_ctrl_msg(adap->dev, CMD_STREAMING_ON,
377 buf, sizeof(buf), NULL, 0);
378 } else {
379 int ret = cxusb_ctrl_msg(adap->dev,
380 CMD_STREAMING_OFF, NULL, 0, NULL, 0);
381 return ret;
382 }
383}
384
Chris Pascoe7c239702006-01-09 18:21:29 -0200385static int cxusb_rc_query(struct dvb_usb_device *d, u32 *event, int *state)
386{
387 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
Michael Krufkya07e6092006-01-09 18:21:31 -0200388 u8 ircode[4];
Chris Pascoe7c239702006-01-09 18:21:29 -0200389 int i;
390
Michael Krufkya07e6092006-01-09 18:21:31 -0200391 cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4);
Chris Pascoe7c239702006-01-09 18:21:29 -0200392
393 *event = 0;
394 *state = REMOTE_NO_KEY_PRESSED;
395
396 for (i = 0; i < d->props.rc_key_map_size; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300397 if (rc5_custom(&keymap[i]) == ircode[2] &&
398 rc5_data(&keymap[i]) == ircode[3]) {
Chris Pascoe7c239702006-01-09 18:21:29 -0200399 *event = keymap[i].event;
400 *state = REMOTE_KEY_PRESSED;
401
402 return 0;
403 }
404 }
405
406 return 0;
407}
408
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300409static int cxusb_bluebird2_rc_query(struct dvb_usb_device *d, u32 *event,
410 int *state)
411{
412 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
413 u8 ircode[4];
414 int i;
415 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
416 .buf = ircode, .len = 4 };
417
418 *event = 0;
419 *state = REMOTE_NO_KEY_PRESSED;
420
421 if (cxusb_i2c_xfer(&d->i2c_adap, &msg, 1) != 1)
422 return 0;
423
424 for (i = 0; i < d->props.rc_key_map_size; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300425 if (rc5_custom(&keymap[i]) == ircode[1] &&
426 rc5_data(&keymap[i]) == ircode[2]) {
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300427 *event = keymap[i].event;
428 *state = REMOTE_KEY_PRESSED;
429
430 return 0;
431 }
432 }
433
434 return 0;
435}
436
Timothy Leedfbdce02008-08-09 13:36:51 -0300437static int cxusb_d680_dmb_rc_query(struct dvb_usb_device *d, u32 *event,
438 int *state)
439{
440 struct dvb_usb_rc_key *keymap = d->props.rc_key_map;
441 u8 ircode[2];
442 int i;
443
444 *event = 0;
445 *state = REMOTE_NO_KEY_PRESSED;
446
447 if (cxusb_ctrl_msg(d, 0x10, NULL, 0, ircode, 2) < 0)
448 return 0;
449
450 for (i = 0; i < d->props.rc_key_map_size; i++) {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300451 if (rc5_custom(&keymap[i]) == ircode[0] &&
452 rc5_data(&keymap[i]) == ircode[1]) {
Timothy Leedfbdce02008-08-09 13:36:51 -0300453 *event = keymap[i].event;
454 *state = REMOTE_KEY_PRESSED;
455
456 return 0;
457 }
458 }
459
460 return 0;
461}
462
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200463static struct dvb_usb_rc_key dvico_mce_rc_keys[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300464 { 0xfe02, KEY_TV },
465 { 0xfe0e, KEY_MP3 },
466 { 0xfe1a, KEY_DVD },
467 { 0xfe1e, KEY_FAVORITES },
468 { 0xfe16, KEY_SETUP },
469 { 0xfe46, KEY_POWER2 },
470 { 0xfe0a, KEY_EPG },
471 { 0xfe49, KEY_BACK },
472 { 0xfe4d, KEY_MENU },
473 { 0xfe51, KEY_UP },
474 { 0xfe5b, KEY_LEFT },
475 { 0xfe5f, KEY_RIGHT },
476 { 0xfe53, KEY_DOWN },
477 { 0xfe5e, KEY_OK },
478 { 0xfe59, KEY_INFO },
479 { 0xfe55, KEY_TAB },
480 { 0xfe0f, KEY_PREVIOUSSONG },/* Replay */
481 { 0xfe12, KEY_NEXTSONG }, /* Skip */
482 { 0xfe42, KEY_ENTER }, /* Windows/Start */
483 { 0xfe15, KEY_VOLUMEUP },
484 { 0xfe05, KEY_VOLUMEDOWN },
485 { 0xfe11, KEY_CHANNELUP },
486 { 0xfe09, KEY_CHANNELDOWN },
487 { 0xfe52, KEY_CAMERA },
488 { 0xfe5a, KEY_TUNER }, /* Live */
489 { 0xfe19, KEY_OPEN },
490 { 0xfe0b, KEY_1 },
491 { 0xfe17, KEY_2 },
492 { 0xfe1b, KEY_3 },
493 { 0xfe07, KEY_4 },
494 { 0xfe50, KEY_5 },
495 { 0xfe54, KEY_6 },
496 { 0xfe48, KEY_7 },
497 { 0xfe4c, KEY_8 },
498 { 0xfe58, KEY_9 },
499 { 0xfe13, KEY_ANGLE }, /* Aspect */
500 { 0xfe03, KEY_0 },
501 { 0xfe1f, KEY_ZOOM },
502 { 0xfe43, KEY_REWIND },
503 { 0xfe47, KEY_PLAYPAUSE },
504 { 0xfe4f, KEY_FASTFORWARD },
505 { 0xfe57, KEY_MUTE },
506 { 0xfe0d, KEY_STOP },
507 { 0xfe01, KEY_RECORD },
508 { 0xfe4e, KEY_POWER },
Michael Krufkya07e6092006-01-09 18:21:31 -0200509};
510
Michael Krufkyc1501782006-03-26 05:43:36 -0300511static struct dvb_usb_rc_key dvico_portable_rc_keys[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300512 { 0xfc02, KEY_SETUP }, /* Profile */
513 { 0xfc43, KEY_POWER2 },
514 { 0xfc06, KEY_EPG },
515 { 0xfc5a, KEY_BACK },
516 { 0xfc05, KEY_MENU },
517 { 0xfc47, KEY_INFO },
518 { 0xfc01, KEY_TAB },
519 { 0xfc42, KEY_PREVIOUSSONG },/* Replay */
520 { 0xfc49, KEY_VOLUMEUP },
521 { 0xfc09, KEY_VOLUMEDOWN },
522 { 0xfc54, KEY_CHANNELUP },
523 { 0xfc0b, KEY_CHANNELDOWN },
524 { 0xfc16, KEY_CAMERA },
525 { 0xfc40, KEY_TUNER }, /* ATV/DTV */
526 { 0xfc45, KEY_OPEN },
527 { 0xfc19, KEY_1 },
528 { 0xfc18, KEY_2 },
529 { 0xfc1b, KEY_3 },
530 { 0xfc1a, KEY_4 },
531 { 0xfc58, KEY_5 },
532 { 0xfc59, KEY_6 },
533 { 0xfc15, KEY_7 },
534 { 0xfc14, KEY_8 },
535 { 0xfc17, KEY_9 },
536 { 0xfc44, KEY_ANGLE }, /* Aspect */
537 { 0xfc55, KEY_0 },
538 { 0xfc07, KEY_ZOOM },
539 { 0xfc0a, KEY_REWIND },
540 { 0xfc08, KEY_PLAYPAUSE },
541 { 0xfc4b, KEY_FASTFORWARD },
542 { 0xfc5b, KEY_MUTE },
543 { 0xfc04, KEY_STOP },
544 { 0xfc56, KEY_RECORD },
545 { 0xfc57, KEY_POWER },
546 { 0xfc41, KEY_UNKNOWN }, /* INPUT */
547 { 0xfc00, KEY_UNKNOWN }, /* HD */
Michael Krufkyc1501782006-03-26 05:43:36 -0300548};
549
Timothy Leedfbdce02008-08-09 13:36:51 -0300550static struct dvb_usb_rc_key d680_dmb_rc_keys[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300551 { 0x0038, KEY_UNKNOWN }, /* TV/AV */
552 { 0x080c, KEY_ZOOM },
553 { 0x0800, KEY_0 },
554 { 0x0001, KEY_1 },
555 { 0x0802, KEY_2 },
556 { 0x0003, KEY_3 },
557 { 0x0804, KEY_4 },
558 { 0x0005, KEY_5 },
559 { 0x0806, KEY_6 },
560 { 0x0007, KEY_7 },
561 { 0x0808, KEY_8 },
562 { 0x0009, KEY_9 },
563 { 0x000a, KEY_MUTE },
564 { 0x0829, KEY_BACK },
565 { 0x0012, KEY_CHANNELUP },
566 { 0x0813, KEY_CHANNELDOWN },
567 { 0x002b, KEY_VOLUMEUP },
568 { 0x082c, KEY_VOLUMEDOWN },
569 { 0x0020, KEY_UP },
570 { 0x0821, KEY_DOWN },
571 { 0x0011, KEY_LEFT },
572 { 0x0810, KEY_RIGHT },
573 { 0x000d, KEY_OK },
574 { 0x081f, KEY_RECORD },
575 { 0x0017, KEY_PLAYPAUSE },
576 { 0x0816, KEY_PLAYPAUSE },
577 { 0x000b, KEY_STOP },
578 { 0x0827, KEY_FASTFORWARD },
579 { 0x0026, KEY_REWIND },
580 { 0x081e, KEY_UNKNOWN }, /* Time Shift */
581 { 0x000e, KEY_UNKNOWN }, /* Snapshot */
582 { 0x082d, KEY_UNKNOWN }, /* Mouse Cursor */
583 { 0x000f, KEY_UNKNOWN }, /* Minimize/Maximize */
584 { 0x0814, KEY_UNKNOWN }, /* Shuffle */
585 { 0x0025, KEY_POWER },
Timothy Leedfbdce02008-08-09 13:36:51 -0300586};
587
Chris Pascoe0029ee12006-01-09 18:21:28 -0200588static int cxusb_dee1601_demod_init(struct dvb_frontend* fe)
589{
Chris Pascoed9ed8812006-02-07 06:49:11 -0200590 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x28 };
Chris Pascoe0029ee12006-01-09 18:21:28 -0200591 static u8 reset [] = { RESET, 0x80 };
592 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
593 static u8 agc_cfg [] = { AGC_TARGET, 0x28, 0x20 };
594 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
595 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
596
597 mt352_write(fe, clock_config, sizeof(clock_config));
598 udelay(200);
599 mt352_write(fe, reset, sizeof(reset));
600 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
601
602 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
603 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
604 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
605
606 return 0;
607}
608
Michael Krufky6f447252006-01-11 19:40:33 -0200609static int cxusb_mt352_demod_init(struct dvb_frontend* fe)
610{ /* used in both lgz201 and th7579 */
Michael Krufkyfb51fd22006-02-07 06:49:12 -0200611 static u8 clock_config [] = { CLOCK_CTL, 0x38, 0x29 };
Michael Krufky6f447252006-01-11 19:40:33 -0200612 static u8 reset [] = { RESET, 0x80 };
613 static u8 adc_ctl_1_cfg [] = { ADC_CTL_1, 0x40 };
614 static u8 agc_cfg [] = { AGC_TARGET, 0x24, 0x20 };
615 static u8 gpp_ctl_cfg [] = { GPP_CTL, 0x33 };
616 static u8 capt_range_cfg[] = { CAPT_RANGE, 0x32 };
617
618 mt352_write(fe, clock_config, sizeof(clock_config));
619 udelay(200);
620 mt352_write(fe, reset, sizeof(reset));
621 mt352_write(fe, adc_ctl_1_cfg, sizeof(adc_ctl_1_cfg));
622
623 mt352_write(fe, agc_cfg, sizeof(agc_cfg));
624 mt352_write(fe, gpp_ctl_cfg, sizeof(gpp_ctl_cfg));
625 mt352_write(fe, capt_range_cfg, sizeof(capt_range_cfg));
626 return 0;
627}
628
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200629static struct cx22702_config cxusb_cx22702_config = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700630 .demod_address = 0x63,
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700631 .output_mode = CX22702_PARALLEL_OUTPUT,
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700632};
633
Michael Krufkyfddd6322006-02-27 00:08:17 -0300634static struct lgdt330x_config cxusb_lgdt3303_config = {
Michael Krufkyeffee032006-01-09 15:25:47 -0200635 .demod_address = 0x0e,
636 .demod_chip = LGDT3303,
Michael Krufkyeffee032006-01-09 15:25:47 -0200637};
638
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -0300639static struct lgdt330x_config cxusb_aver_lgdt3303_config = {
640 .demod_address = 0x0e,
641 .demod_chip = LGDT3303,
642 .clock_polarity_flip = 2,
643};
644
Adrian Bunk703cb2c2006-01-23 17:11:09 -0200645static struct mt352_config cxusb_dee1601_config = {
Chris Pascoe0029ee12006-01-09 18:21:28 -0200646 .demod_address = 0x0f,
647 .demod_init = cxusb_dee1601_demod_init,
Chris Pascoe0029ee12006-01-09 18:21:28 -0200648};
649
Michael Krufkyc9ce3942006-06-11 04:24:31 -0300650static struct zl10353_config cxusb_zl10353_dee1601_config = {
651 .demod_address = 0x0f,
Chris Pascoe8fb95782006-08-10 03:17:16 -0300652 .parallel_ts = 1,
Michael Krufkyc9ce3942006-06-11 04:24:31 -0300653};
654
Adrian Bunk6fe00b02006-04-19 20:49:28 -0300655static struct mt352_config cxusb_mt352_config = {
Michael Krufky6f447252006-01-11 19:40:33 -0200656 /* used in both lgz201 and th7579 */
657 .demod_address = 0x0f,
658 .demod_init = cxusb_mt352_demod_init,
Michael Krufky6f447252006-01-11 19:40:33 -0200659};
660
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300661static struct zl10353_config cxusb_zl10353_xc3028_config = {
662 .demod_address = 0x0f,
Chris Pascoea1dcd9d2007-11-20 08:17:54 -0300663 .if2 = 45600,
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300664 .no_tuner = 1,
665 .parallel_ts = 1,
666};
667
Robert Lowery0bc35182009-11-08 00:00:11 -0300668static struct zl10353_config cxusb_zl10353_xc3028_config_no_i2c_gate = {
669 .demod_address = 0x0f,
670 .if2 = 45600,
671 .no_tuner = 1,
672 .parallel_ts = 1,
673 .disable_i2c_gate_ctrl = 1,
674};
675
Chris Pascoe702a6762007-11-20 03:34:11 -0300676static struct mt352_config cxusb_mt352_xc3028_config = {
677 .demod_address = 0x0f,
678 .if2 = 4560,
679 .no_tuner = 1,
680 .demod_init = cxusb_mt352_demod_init,
681};
682
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -0300683/* FIXME: needs tweaking */
684static struct mxl5005s_config aver_a868r_tuner = {
685 .i2c_address = 0x63,
686 .if_freq = 6000000UL,
687 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
688 .agc_mode = MXL_SINGLE_AGC,
689 .tracking_filter = MXL_TF_C,
690 .rssi_enable = MXL_RSSI_ENABLE,
691 .cap_select = MXL_CAP_SEL_ENABLE,
692 .div_out = MXL_DIV_OUT_4,
693 .clock_out = MXL_CLOCK_OUT_DISABLE,
694 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
695 .top = MXL5005S_TOP_25P2,
696 .mod_mode = MXL_DIGITAL_MODE,
697 .if_mode = MXL_ZERO_IF,
698 .AgcMasterByte = 0x00,
699};
700
Timothy Leedfbdce02008-08-09 13:36:51 -0300701/* FIXME: needs tweaking */
702static struct mxl5005s_config d680_dmb_tuner = {
703 .i2c_address = 0x63,
704 .if_freq = 36125000UL,
705 .xtal_freq = CRYSTAL_FREQ_16000000HZ,
706 .agc_mode = MXL_SINGLE_AGC,
707 .tracking_filter = MXL_TF_C,
708 .rssi_enable = MXL_RSSI_ENABLE,
709 .cap_select = MXL_CAP_SEL_ENABLE,
710 .div_out = MXL_DIV_OUT_4,
711 .clock_out = MXL_CLOCK_OUT_DISABLE,
712 .output_load = MXL5005S_IF_OUTPUT_LOAD_200_OHM,
713 .top = MXL5005S_TOP_25P2,
714 .mod_mode = MXL_DIGITAL_MODE,
715 .if_mode = MXL_ZERO_IF,
716 .AgcMasterByte = 0x00,
717};
718
David Wongb18bd1d2009-10-26 09:41:22 -0300719static struct max2165_config mygica_d689_max2165_cfg = {
720 .i2c_address = 0x60,
721 .osc_clk = 20
722};
723
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700724/* Callbacks for DVB USB */
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300725static int cxusb_fmd1216me_tuner_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700726{
Michael Krufkycb89cd32008-04-22 14:46:16 -0300727 dvb_attach(simple_tuner_attach, adap->fe,
728 &adap->dev->i2c_adap, 0x61,
729 TUNER_PHILIPS_FMD1216ME_MK3);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700730 return 0;
731}
732
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300733static int cxusb_dee1601_tuner_attach(struct dvb_usb_adapter *adap)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200734{
Michael Krufky79a54cb2006-12-05 14:20:06 -0300735 dvb_attach(dvb_pll_attach, adap->fe, 0x61,
Michael Krufky47a99912007-06-12 16:10:51 -0300736 NULL, DVB_PLL_THOMSON_DTT7579);
Chris Pascoe0029ee12006-01-09 18:21:28 -0200737 return 0;
738}
739
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300740static int cxusb_lgz201_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky6f447252006-01-11 19:40:33 -0200741{
Michael Krufky47a99912007-06-12 16:10:51 -0300742 dvb_attach(dvb_pll_attach, adap->fe, 0x61, NULL, DVB_PLL_LG_Z201);
Michael Krufky6f447252006-01-11 19:40:33 -0200743 return 0;
744}
745
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300746static int cxusb_dtt7579_tuner_attach(struct dvb_usb_adapter *adap)
Michael Krufky6f447252006-01-11 19:40:33 -0200747{
Michael Krufky79a54cb2006-12-05 14:20:06 -0300748 dvb_attach(dvb_pll_attach, adap->fe, 0x60,
Michael Krufky47a99912007-06-12 16:10:51 -0300749 NULL, DVB_PLL_THOMSON_DTT7579);
Patrick Boettcher332bed52006-05-14 04:49:00 -0300750 return 0;
751}
752
Michael Krufkyf71a56c2006-10-13 21:55:57 -0300753static int cxusb_lgh064f_tuner_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher332bed52006-05-14 04:49:00 -0300754{
Michael Krufky827855d2008-04-22 14:46:16 -0300755 dvb_attach(simple_tuner_attach, adap->fe,
756 &adap->dev->i2c_adap, 0x61, TUNER_LG_TDVS_H06XF);
Michael Krufky6f447252006-01-11 19:40:33 -0200757 return 0;
758}
759
Michael Krufkyd7cba042008-09-12 13:31:45 -0300760static int dvico_bluebird_xc2028_callback(void *ptr, int component,
761 int command, int arg)
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300762{
Robert Loweryd483b732008-07-30 19:43:11 -0300763 struct dvb_usb_adapter *adap = ptr;
764 struct dvb_usb_device *d = adap->dev;
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300765
766 switch (command) {
767 case XC2028_TUNER_RESET:
Harvey Harrison708bebd2008-04-08 23:20:00 -0300768 deb_info("%s: XC2028_TUNER_RESET %d\n", __func__, arg);
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300769 cxusb_bluebird_gpio_pulse(d, 0x01, 1);
770 break;
771 case XC2028_RESET_CLK:
Harvey Harrison708bebd2008-04-08 23:20:00 -0300772 deb_info("%s: XC2028_RESET_CLK %d\n", __func__, arg);
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300773 break;
774 default:
Harvey Harrison708bebd2008-04-08 23:20:00 -0300775 deb_info("%s: unknown command %d, arg %d\n", __func__,
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300776 command, arg);
777 return -EINVAL;
778 }
779
780 return 0;
781}
782
783static int cxusb_dvico_xc3028_tuner_attach(struct dvb_usb_adapter *adap)
784{
785 struct dvb_frontend *fe;
786 struct xc2028_config cfg = {
787 .i2c_adap = &adap->dev->i2c_adap,
788 .i2c_addr = 0x61,
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300789 };
790 static struct xc2028_ctrl ctl = {
Michael Krufkyef80bfe2008-09-16 02:15:30 -0300791 .fname = XC2028_DEFAULT_FIRMWARE,
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300792 .max_len = 64,
Robert Loweryd483b732008-07-30 19:43:11 -0300793 .demod = XC3028_FE_ZARLINK456,
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300794 };
795
Michael Krufkyd7cba042008-09-12 13:31:45 -0300796 /* FIXME: generalize & move to common area */
797 adap->fe->callback = dvico_bluebird_xc2028_callback;
798
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300799 fe = dvb_attach(xc2028_attach, adap->fe, &cfg);
800 if (fe == NULL || fe->ops.tuner_ops.set_config == NULL)
801 return -EIO;
802
803 fe->ops.tuner_ops.set_config(fe, &ctl);
804
805 return 0;
806}
807
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -0300808static int cxusb_mxl5003s_tuner_attach(struct dvb_usb_adapter *adap)
809{
810 dvb_attach(mxl5005s_attach, adap->fe,
811 &adap->dev->i2c_adap, &aver_a868r_tuner);
812 return 0;
813}
814
Timothy Leedfbdce02008-08-09 13:36:51 -0300815static int cxusb_d680_dmb_tuner_attach(struct dvb_usb_adapter *adap)
816{
817 struct dvb_frontend *fe;
818 fe = dvb_attach(mxl5005s_attach, adap->fe,
819 &adap->dev->i2c_adap, &d680_dmb_tuner);
820 return (fe == NULL) ? -EIO : 0;
821}
822
David Wongb18bd1d2009-10-26 09:41:22 -0300823static int cxusb_mygica_d689_tuner_attach(struct dvb_usb_adapter *adap)
824{
825 struct dvb_frontend *fe;
826 fe = dvb_attach(max2165_attach, adap->fe,
827 &adap->dev->i2c_adap, &mygica_d689_max2165_cfg);
828 return (fe == NULL) ? -EIO : 0;
829}
830
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300831static int cxusb_cx22702_frontend_attach(struct dvb_usb_adapter *adap)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700832{
Patrick Boettchere2efeab2005-09-09 13:02:51 -0700833 u8 b;
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300834 if (usb_set_interface(adap->dev->udev, 0, 6) < 0)
Patrick Boettcher8257e8a2005-07-07 17:58:15 -0700835 err("set interface failed");
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700836
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300837 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, &b, 1);
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700838
Michael Krufkyf35db232006-12-05 14:53:39 -0300839 if ((adap->fe = dvb_attach(cx22702_attach, &cxusb_cx22702_config,
840 &adap->dev->i2c_adap)) != NULL)
Patrick Boettcher22c6d932005-07-07 17:58:10 -0700841 return 0;
842
843 return -EIO;
844}
845
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300846static int cxusb_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
Michael Krufkyeffee032006-01-09 15:25:47 -0200847{
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300848 if (usb_set_interface(adap->dev->udev, 0, 7) < 0)
Michael Krufkyeffee032006-01-09 15:25:47 -0200849 err("set interface failed");
850
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300851 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
Michael Krufkyeffee032006-01-09 15:25:47 -0200852
Michael Krufkyf35db232006-12-05 14:53:39 -0300853 if ((adap->fe = dvb_attach(lgdt330x_attach, &cxusb_lgdt3303_config,
854 &adap->dev->i2c_adap)) != NULL)
Michael Krufkyeffee032006-01-09 15:25:47 -0200855 return 0;
856
857 return -EIO;
858}
859
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -0300860static int cxusb_aver_lgdt3303_frontend_attach(struct dvb_usb_adapter *adap)
861{
862 adap->fe = dvb_attach(lgdt330x_attach, &cxusb_aver_lgdt3303_config,
863 &adap->dev->i2c_adap);
864 if (adap->fe != NULL)
865 return 0;
866
867 return -EIO;
868}
869
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300870static int cxusb_mt352_frontend_attach(struct dvb_usb_adapter *adap)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200871{
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300872 /* used in both lgz201 and th7579 */
873 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
Chris Pascoe0029ee12006-01-09 18:21:28 -0200874 err("set interface failed");
875
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300876 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
Chris Pascoe0029ee12006-01-09 18:21:28 -0200877
Michael Krufkyf35db232006-12-05 14:53:39 -0300878 if ((adap->fe = dvb_attach(mt352_attach, &cxusb_mt352_config,
879 &adap->dev->i2c_adap)) != NULL)
Patrick Boettcher4d43e132006-09-30 06:53:48 -0300880 return 0;
881
882 return -EIO;
883}
884
885static int cxusb_dee1601_frontend_attach(struct dvb_usb_adapter *adap)
886{
887 if (usb_set_interface(adap->dev->udev, 0, 0) < 0)
888 err("set interface failed");
889
890 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
891
Michael Krufkyf35db232006-12-05 14:53:39 -0300892 if (((adap->fe = dvb_attach(mt352_attach, &cxusb_dee1601_config,
893 &adap->dev->i2c_adap)) != NULL) ||
894 ((adap->fe = dvb_attach(zl10353_attach,
895 &cxusb_zl10353_dee1601_config,
896 &adap->dev->i2c_adap)) != NULL))
Chris Pascoe0029ee12006-01-09 18:21:28 -0200897 return 0;
898
899 return -EIO;
900}
901
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300902static int cxusb_dualdig4_frontend_attach(struct dvb_usb_adapter *adap)
903{
904 u8 ircode[4];
905 int i;
906 struct i2c_msg msg = { .addr = 0x6b, .flags = I2C_M_RD,
907 .buf = ircode, .len = 4 };
908
909 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
910 err("set interface failed");
911
912 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
913
914 /* reset the tuner and demodulator */
915 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
916 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
917 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
918
919 if ((adap->fe = dvb_attach(zl10353_attach,
Robert Lowery0bc35182009-11-08 00:00:11 -0300920 &cxusb_zl10353_xc3028_config_no_i2c_gate,
Chris Pascoeaeb012b2007-11-19 21:57:10 -0300921 &adap->dev->i2c_adap)) == NULL)
922 return -EIO;
923
924 /* try to determine if there is no IR decoder on the I2C bus */
925 for (i = 0; adap->dev->props.rc_key_map != NULL && i < 5; i++) {
926 msleep(20);
927 if (cxusb_i2c_xfer(&adap->dev->i2c_adap, &msg, 1) != 1)
928 goto no_IR;
929 if (ircode[0] == 0 && ircode[1] == 0)
930 continue;
931 if (ircode[2] + ircode[3] != 0xff) {
932no_IR:
933 adap->dev->props.rc_key_map = NULL;
934 info("No IR receiver detected on this device.");
935 break;
936 }
937 }
938
939 return 0;
940}
941
Anton Blanchard8d798982008-08-09 12:23:15 -0300942static struct dibx000_agc_config dib7070_agc_config = {
943 .band_caps = BAND_UHF | BAND_VHF | BAND_LBAND | BAND_SBAND,
944
945 /*
946 * P_agc_use_sd_mod1=0, P_agc_use_sd_mod2=0, P_agc_freq_pwm_div=5,
947 * P_agc_inv_pwm1=0, P_agc_inv_pwm2=0, P_agc_inh_dc_rv_est=0,
948 * P_agc_time_est=3, P_agc_freeze=0, P_agc_nb_est=5, P_agc_write=0
949 */
950 .setup = (0 << 15) | (0 << 14) | (5 << 11) | (0 << 10) | (0 << 9) |
951 (0 << 8) | (3 << 5) | (0 << 4) | (5 << 1) | (0 << 0),
952 .inv_gain = 600,
953 .time_stabiliz = 10,
954 .alpha_level = 0,
955 .thlock = 118,
956 .wbd_inv = 0,
957 .wbd_ref = 3530,
958 .wbd_sel = 1,
959 .wbd_alpha = 5,
960 .agc1_max = 65535,
961 .agc1_min = 0,
962 .agc2_max = 65535,
963 .agc2_min = 0,
964 .agc1_pt1 = 0,
965 .agc1_pt2 = 40,
966 .agc1_pt3 = 183,
967 .agc1_slope1 = 206,
968 .agc1_slope2 = 255,
969 .agc2_pt1 = 72,
970 .agc2_pt2 = 152,
971 .agc2_slope1 = 88,
972 .agc2_slope2 = 90,
973 .alpha_mant = 17,
974 .alpha_exp = 27,
975 .beta_mant = 23,
976 .beta_exp = 51,
977 .perform_agc_softsplit = 0,
978};
979
980static struct dibx000_bandwidth_config dib7070_bw_config_12_mhz = {
981 .internal = 60000,
982 .sampling = 15000,
983 .pll_prediv = 1,
984 .pll_ratio = 20,
985 .pll_range = 3,
986 .pll_reset = 1,
987 .pll_bypass = 0,
988 .enable_refdiv = 0,
989 .bypclk_div = 0,
990 .IO_CLK_en_core = 1,
991 .ADClkSrc = 1,
992 .modulo = 2,
993 /* refsel, sel, freq_15k */
994 .sad_cfg = (3 << 14) | (1 << 12) | (524 << 0),
995 .ifreq = (0 << 25) | 0,
996 .timf = 20452225,
997 .xtal_hz = 12000000,
998};
999
1000static struct dib7000p_config cxusb_dualdig4_rev2_config = {
1001 .output_mode = OUTMODE_MPEG2_PAR_GATED_CLK,
1002 .output_mpeg2_in_188_bytes = 1,
1003
1004 .agc_config_count = 1,
1005 .agc = &dib7070_agc_config,
1006 .bw = &dib7070_bw_config_12_mhz,
1007 .tuner_is_baseband = 1,
1008 .spur_protect = 1,
1009
1010 .gpio_dir = 0xfcef,
1011 .gpio_val = 0x0110,
1012
1013 .gpio_pwm_pos = DIB7000P_GPIO_DEFAULT_PWM_POS,
1014
1015 .hostbus_diversity = 1,
1016};
1017
1018static int cxusb_dualdig4_rev2_frontend_attach(struct dvb_usb_adapter *adap)
1019{
1020 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1021 err("set interface failed");
1022
1023 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1024
1025 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1026
1027 dib7000p_i2c_enumeration(&adap->dev->i2c_adap, 1, 18,
1028 &cxusb_dualdig4_rev2_config);
1029
Michael Krufkya2dc86b2008-08-09 13:06:26 -03001030 adap->fe = dvb_attach(dib7000p_attach, &adap->dev->i2c_adap, 0x80,
1031 &cxusb_dualdig4_rev2_config);
1032 if (adap->fe == NULL)
Anton Blanchard8d798982008-08-09 12:23:15 -03001033 return -EIO;
1034
1035 return 0;
1036}
1037
1038static int dib7070_tuner_reset(struct dvb_frontend *fe, int onoff)
1039{
1040 return dib7000p_set_gpio(fe, 8, 0, !onoff);
1041}
1042
1043static int dib7070_tuner_sleep(struct dvb_frontend *fe, int onoff)
1044{
1045 return 0;
1046}
1047
1048static struct dib0070_config dib7070p_dib0070_config = {
1049 .i2c_address = DEFAULT_DIB0070_I2C_ADDRESS,
1050 .reset = dib7070_tuner_reset,
1051 .sleep = dib7070_tuner_sleep,
1052 .clock_khz = 12000,
1053};
1054
1055struct dib0700_adapter_state {
1056 int (*set_param_save) (struct dvb_frontend *,
1057 struct dvb_frontend_parameters *);
1058};
1059
1060static int dib7070_set_param_override(struct dvb_frontend *fe,
1061 struct dvb_frontend_parameters *fep)
1062{
1063 struct dvb_usb_adapter *adap = fe->dvb->priv;
1064 struct dib0700_adapter_state *state = adap->priv;
1065
1066 u16 offset;
1067 u8 band = BAND_OF_FREQUENCY(fep->frequency/1000);
1068 switch (band) {
Michael Krufkya2dc86b2008-08-09 13:06:26 -03001069 case BAND_VHF: offset = 950; break;
1070 default:
1071 case BAND_UHF: offset = 550; break;
Anton Blanchard8d798982008-08-09 12:23:15 -03001072 }
1073
1074 dib7000p_set_wbd_ref(fe, offset + dib0070_wbd_offset(fe));
1075
1076 return state->set_param_save(fe, fep);
1077}
1078
1079static int cxusb_dualdig4_rev2_tuner_attach(struct dvb_usb_adapter *adap)
1080{
1081 struct dib0700_adapter_state *st = adap->priv;
Michael Krufkya2dc86b2008-08-09 13:06:26 -03001082 struct i2c_adapter *tun_i2c =
1083 dib7000p_get_i2c_master(adap->fe,
1084 DIBX000_I2C_INTERFACE_TUNER, 1);
Anton Blanchard8d798982008-08-09 12:23:15 -03001085
1086 if (dvb_attach(dib0070_attach, adap->fe, tun_i2c,
1087 &dib7070p_dib0070_config) == NULL)
1088 return -ENODEV;
1089
1090 st->set_param_save = adap->fe->ops.tuner_ops.set_params;
1091 adap->fe->ops.tuner_ops.set_params = dib7070_set_param_override;
1092 return 0;
1093}
1094
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001095static int cxusb_nano2_frontend_attach(struct dvb_usb_adapter *adap)
1096{
1097 if (usb_set_interface(adap->dev->udev, 0, 1) < 0)
1098 err("set interface failed");
1099
1100 cxusb_ctrl_msg(adap->dev, CMD_DIGITAL, NULL, 0, NULL, 0);
1101
1102 /* reset the tuner and demodulator */
1103 cxusb_bluebird_gpio_rw(adap->dev, 0x04, 0);
1104 cxusb_bluebird_gpio_pulse(adap->dev, 0x01, 1);
1105 cxusb_bluebird_gpio_pulse(adap->dev, 0x02, 1);
1106
1107 if ((adap->fe = dvb_attach(zl10353_attach,
1108 &cxusb_zl10353_xc3028_config,
1109 &adap->dev->i2c_adap)) != NULL)
1110 return 0;
1111
Chris Pascoe702a6762007-11-20 03:34:11 -03001112 if ((adap->fe = dvb_attach(mt352_attach,
1113 &cxusb_mt352_xc3028_config,
1114 &adap->dev->i2c_adap)) != NULL)
1115 return 0;
1116
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001117 return -EIO;
1118}
1119
David T.L. Wong6bf1a992009-08-05 13:07:10 -03001120static struct lgs8gxx_config d680_lgs8gl5_cfg = {
1121 .prod = LGS8GXX_PROD_LGS8GL5,
Timothy Leedfbdce02008-08-09 13:36:51 -03001122 .demod_address = 0x19,
David T.L. Wong6bf1a992009-08-05 13:07:10 -03001123 .serial_ts = 0,
1124 .ts_clk_pol = 0,
1125 .ts_clk_gated = 1,
1126 .if_clk_freq = 30400, /* 30.4 MHz */
1127 .if_freq = 5725, /* 5.725 MHz */
1128 .if_neg_center = 0,
1129 .ext_adc = 0,
1130 .adc_signed = 0,
1131 .if_neg_edge = 0,
Timothy Leedfbdce02008-08-09 13:36:51 -03001132};
1133
1134static int cxusb_d680_dmb_frontend_attach(struct dvb_usb_adapter *adap)
1135{
1136 struct dvb_usb_device *d = adap->dev;
1137 int n;
1138
1139 /* Select required USB configuration */
1140 if (usb_set_interface(d->udev, 0, 0) < 0)
1141 err("set interface failed");
1142
1143 /* Unblock all USB pipes */
1144 usb_clear_halt(d->udev,
1145 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1146 usb_clear_halt(d->udev,
1147 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1148 usb_clear_halt(d->udev,
1149 usb_rcvbulkpipe(d->udev, d->props.adapter[0].stream.endpoint));
1150
1151 /* Drain USB pipes to avoid hang after reboot */
1152 for (n = 0; n < 5; n++) {
1153 cxusb_d680_dmb_drain_message(d);
1154 cxusb_d680_dmb_drain_video(d);
1155 msleep(200);
1156 }
1157
1158 /* Reset the tuner */
1159 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1160 err("clear tuner gpio failed");
1161 return -EIO;
1162 }
1163 msleep(100);
1164 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1165 err("set tuner gpio failed");
1166 return -EIO;
1167 }
1168 msleep(100);
1169
1170 /* Attach frontend */
David T.L. Wong6bf1a992009-08-05 13:07:10 -03001171 adap->fe = dvb_attach(lgs8gxx_attach, &d680_lgs8gl5_cfg, &d->i2c_adap);
Timothy Leedfbdce02008-08-09 13:36:51 -03001172 if (adap->fe == NULL)
1173 return -EIO;
1174
1175 return 0;
1176}
1177
David Wongb18bd1d2009-10-26 09:41:22 -03001178static struct atbm8830_config mygica_d689_atbm8830_cfg = {
1179 .prod = ATBM8830_PROD_8830,
1180 .demod_address = 0x40,
1181 .serial_ts = 0,
1182 .ts_sampling_edge = 1,
1183 .ts_clk_gated = 0,
1184 .osc_clk_freq = 30400, /* in kHz */
1185 .if_freq = 0, /* zero IF */
1186 .zif_swap_iq = 1,
1187};
1188
1189static int cxusb_mygica_d689_frontend_attach(struct dvb_usb_adapter *adap)
1190{
1191 struct dvb_usb_device *d = adap->dev;
David Wongb18bd1d2009-10-26 09:41:22 -03001192
1193 /* Select required USB configuration */
1194 if (usb_set_interface(d->udev, 0, 0) < 0)
1195 err("set interface failed");
1196
1197 /* Unblock all USB pipes */
1198 usb_clear_halt(d->udev,
1199 usb_sndbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1200 usb_clear_halt(d->udev,
1201 usb_rcvbulkpipe(d->udev, d->props.generic_bulk_ctrl_endpoint));
1202 usb_clear_halt(d->udev,
1203 usb_rcvbulkpipe(d->udev, d->props.adapter[0].stream.endpoint));
1204
1205
1206 /* Reset the tuner */
1207 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 0) < 0) {
1208 err("clear tuner gpio failed");
1209 return -EIO;
1210 }
1211 msleep(100);
1212 if (cxusb_d680_dmb_gpio_tuner(d, 0x07, 1) < 0) {
1213 err("set tuner gpio failed");
1214 return -EIO;
1215 }
1216 msleep(100);
1217
1218 /* Attach frontend */
1219 adap->fe = dvb_attach(atbm8830_attach, &mygica_d689_atbm8830_cfg,
1220 &d->i2c_adap);
1221 if (adap->fe == NULL)
1222 return -EIO;
1223
1224 return 0;
1225}
1226
Patrick Boettcherf5373782006-01-09 18:21:38 -02001227/*
Chris Pascoe702a6762007-11-20 03:34:11 -03001228 * DViCO has shipped two devices with the same USB ID, but only one of them
1229 * needs a firmware download. Check the device class details to see if they
1230 * have non-default values to decide whether the device is actually cold or
1231 * not, and forget a match if it turns out we selected the wrong device.
1232 */
1233static int bluebird_fx2_identify_state(struct usb_device *udev,
1234 struct dvb_usb_device_properties *props,
1235 struct dvb_usb_device_description **desc,
1236 int *cold)
1237{
1238 int wascold = *cold;
1239
1240 *cold = udev->descriptor.bDeviceClass == 0xff &&
1241 udev->descriptor.bDeviceSubClass == 0xff &&
1242 udev->descriptor.bDeviceProtocol == 0xff;
1243
1244 if (*cold && !wascold)
1245 *desc = NULL;
1246
1247 return 0;
1248}
1249
1250/*
Patrick Boettcherf5373782006-01-09 18:21:38 -02001251 * DViCO bluebird firmware needs the "warm" product ID to be patched into the
1252 * firmware file before download.
1253 */
1254
Chris Pascoe702a6762007-11-20 03:34:11 -03001255static const int dvico_firmware_id_offsets[] = { 6638, 3204 };
Michael Krufkyf35db232006-12-05 14:53:39 -03001256static int bluebird_patch_dvico_firmware_download(struct usb_device *udev,
1257 const struct firmware *fw)
Patrick Boettcherf5373782006-01-09 18:21:38 -02001258{
Chris Pascoe702a6762007-11-20 03:34:11 -03001259 int pos;
Patrick Boettcherf5373782006-01-09 18:21:38 -02001260
Chris Pascoe702a6762007-11-20 03:34:11 -03001261 for (pos = 0; pos < ARRAY_SIZE(dvico_firmware_id_offsets); pos++) {
1262 int idoff = dvico_firmware_id_offsets[pos];
Patrick Boettcherf5373782006-01-09 18:21:38 -02001263
Chris Pascoe702a6762007-11-20 03:34:11 -03001264 if (fw->size < idoff + 4)
1265 continue;
Patrick Boettcherf5373782006-01-09 18:21:38 -02001266
Chris Pascoe702a6762007-11-20 03:34:11 -03001267 if (fw->data[idoff] == (USB_VID_DVICO & 0xff) &&
1268 fw->data[idoff + 1] == USB_VID_DVICO >> 8) {
David Woodhousee62f89f2008-05-24 00:12:42 +01001269 struct firmware new_fw;
1270 u8 *new_fw_data = vmalloc(fw->size);
1271 int ret;
1272
1273 if (!new_fw_data)
1274 return -ENOMEM;
1275
1276 memcpy(new_fw_data, fw->data, fw->size);
1277 new_fw.size = fw->size;
1278 new_fw.data = new_fw_data;
1279
1280 new_fw_data[idoff + 2] =
Chris Pascoe702a6762007-11-20 03:34:11 -03001281 le16_to_cpu(udev->descriptor.idProduct) + 1;
David Woodhousee62f89f2008-05-24 00:12:42 +01001282 new_fw_data[idoff + 3] =
Chris Pascoe702a6762007-11-20 03:34:11 -03001283 le16_to_cpu(udev->descriptor.idProduct) >> 8;
1284
David Woodhousee62f89f2008-05-24 00:12:42 +01001285 ret = usb_cypress_load_firmware(udev, &new_fw,
1286 CYPRESS_FX2);
1287 vfree(new_fw_data);
1288 return ret;
Chris Pascoe702a6762007-11-20 03:34:11 -03001289 }
Patrick Boettcherf5373782006-01-09 18:21:38 -02001290 }
1291
1292 return -EINVAL;
1293}
1294
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001295/* DVB USB Driver stuff */
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001296static struct dvb_usb_device_properties cxusb_medion_properties;
1297static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties;
1298static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties;
1299static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties;
1300static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties;
Chris Pascoeaeb012b2007-11-19 21:57:10 -03001301static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties;
Anton Blanchard8d798982008-08-09 12:23:15 -03001302static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties;
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001303static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties;
Chris Pascoe702a6762007-11-20 03:34:11 -03001304static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties;
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -03001305static struct dvb_usb_device_properties cxusb_aver_a868r_properties;
Timothy Leedfbdce02008-08-09 13:36:51 -03001306static struct dvb_usb_device_properties cxusb_d680_dmb_properties;
David Wongb18bd1d2009-10-26 09:41:22 -03001307static struct dvb_usb_device_properties cxusb_mygica_d689_properties;
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001308
1309static int cxusb_probe(struct usb_interface *intf,
Michael Krufkyf35db232006-12-05 14:53:39 -03001310 const struct usb_device_id *id)
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001311{
Janne Grunau78e92002008-04-09 19:13:13 -03001312 if (0 == dvb_usb_device_init(intf, &cxusb_medion_properties,
1313 THIS_MODULE, NULL, adapter_nr) ||
1314 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgh064f_properties,
1315 THIS_MODULE, NULL, adapter_nr) ||
1316 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dee1601_properties,
1317 THIS_MODULE, NULL, adapter_nr) ||
1318 0 == dvb_usb_device_init(intf, &cxusb_bluebird_lgz201_properties,
1319 THIS_MODULE, NULL, adapter_nr) ||
1320 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dtt7579_properties,
1321 THIS_MODULE, NULL, adapter_nr) ||
1322 0 == dvb_usb_device_init(intf, &cxusb_bluebird_dualdig4_properties,
1323 THIS_MODULE, NULL, adapter_nr) ||
1324 0 == dvb_usb_device_init(intf, &cxusb_bluebird_nano2_properties,
1325 THIS_MODULE, NULL, adapter_nr) ||
1326 0 == dvb_usb_device_init(intf,
1327 &cxusb_bluebird_nano2_needsfirmware_properties,
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -03001328 THIS_MODULE, NULL, adapter_nr) ||
1329 0 == dvb_usb_device_init(intf, &cxusb_aver_a868r_properties,
1330 THIS_MODULE, NULL, adapter_nr) ||
Anton Blanchard8d798982008-08-09 12:23:15 -03001331 0 == dvb_usb_device_init(intf,
1332 &cxusb_bluebird_dualdig4_rev2_properties,
1333 THIS_MODULE, NULL, adapter_nr) ||
Timothy Leedfbdce02008-08-09 13:36:51 -03001334 0 == dvb_usb_device_init(intf, &cxusb_d680_dmb_properties,
1335 THIS_MODULE, NULL, adapter_nr) ||
David Wongb18bd1d2009-10-26 09:41:22 -03001336 0 == dvb_usb_device_init(intf, &cxusb_mygica_d689_properties,
1337 THIS_MODULE, NULL, adapter_nr) ||
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -03001338 0)
Michael Krufkyeffee032006-01-09 15:25:47 -02001339 return 0;
Michael Krufkyeffee032006-01-09 15:25:47 -02001340
1341 return -EINVAL;
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001342}
1343
1344static struct usb_device_id cxusb_table [] = {
Michael Krufkyf35db232006-12-05 14:53:39 -03001345 { USB_DEVICE(USB_VID_MEDION, USB_PID_MEDION_MD95700) },
1346 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_COLD) },
1347 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LG064F_WARM) },
1348 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_COLD) },
1349 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_1_WARM) },
1350 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_COLD) },
1351 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_LGZ201_WARM) },
1352 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_COLD) },
1353 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_TH7579_WARM) },
1354 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_COLD) },
1355 { USB_DEVICE(USB_VID_DVICO, USB_PID_DIGITALNOW_BLUEBIRD_DUAL_1_WARM) },
1356 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_COLD) },
1357 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_2_WARM) },
Chris Pascoeaeb012b2007-11-19 21:57:10 -03001358 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4) },
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001359 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2) },
Chris Pascoe702a6762007-11-20 03:34:11 -03001360 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DVB_T_NANO_2_NFW_WARM) },
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -03001361 { USB_DEVICE(USB_VID_AVERMEDIA, USB_PID_AVERMEDIA_VOLAR_A868R) },
Anton Blanchard8d798982008-08-09 12:23:15 -03001362 { USB_DEVICE(USB_VID_DVICO, USB_PID_DVICO_BLUEBIRD_DUAL_4_REV_2) },
Timothy Leedfbdce02008-08-09 13:36:51 -03001363 { USB_DEVICE(USB_VID_CONEXANT, USB_PID_CONEXANT_D680_DMB) },
David Wongb18bd1d2009-10-26 09:41:22 -03001364 { USB_DEVICE(USB_VID_CONEXANT, USB_PID_MYGICA_D689) },
Michael Krufkyf35db232006-12-05 14:53:39 -03001365 {} /* Terminating entry */
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001366};
1367MODULE_DEVICE_TABLE (usb, cxusb_table);
1368
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001369static struct dvb_usb_device_properties cxusb_medion_properties = {
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001370 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1371
1372 .usb_ctrl = CYPRESS_FX2,
1373
1374 .size_of_priv = sizeof(struct cxusb_state),
1375
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001376 .num_adapters = 1,
1377 .adapter = {
1378 {
Patrick Boettcher01451e72006-10-13 11:34:46 -03001379 .streaming_ctrl = cxusb_streaming_ctrl,
1380 .frontend_attach = cxusb_cx22702_frontend_attach,
1381 .tuner_attach = cxusb_fmd1216me_tuner_attach,
1382 /* parameter for the MPEG2-data transfer */
1383 .stream = {
1384 .type = USB_BULK,
1385 .count = 5,
1386 .endpoint = 0x02,
1387 .u = {
1388 .bulk = {
1389 .buffersize = 8192,
1390 }
1391 }
1392 },
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001393
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001394 },
1395 },
1396 .power_ctrl = cxusb_power_ctrl,
1397
1398 .i2c_algo = &cxusb_i2c_algo,
1399
1400 .generic_bulk_ctrl_endpoint = 0x01,
1401
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001402 .num_device_descs = 1,
1403 .devices = {
1404 { "Medion MD95700 (MDUSBTV-HYBRID)",
1405 { NULL },
1406 { &cxusb_table[0], NULL },
1407 },
1408 }
1409};
1410
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001411static struct dvb_usb_device_properties cxusb_bluebird_lgh064f_properties = {
Michael Krufkyeffee032006-01-09 15:25:47 -02001412 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1413
Patrick Boettcherf5373782006-01-09 18:21:38 -02001414 .usb_ctrl = DEVICE_SPECIFIC,
1415 .firmware = "dvb-usb-bluebird-01.fw",
1416 .download_firmware = bluebird_patch_dvico_firmware_download,
Michael Krufky37bdfa02006-01-09 15:25:47 -02001417 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1418 use usb alt setting 7 for EP2 transfer (atsc) */
Michael Krufkyeffee032006-01-09 15:25:47 -02001419
1420 .size_of_priv = sizeof(struct cxusb_state),
1421
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001422 .num_adapters = 1,
1423 .adapter = {
1424 {
Patrick Boettcher01451e72006-10-13 11:34:46 -03001425 .streaming_ctrl = cxusb_streaming_ctrl,
1426 .frontend_attach = cxusb_lgdt3303_frontend_attach,
Michael Krufkyf71a56c2006-10-13 21:55:57 -03001427 .tuner_attach = cxusb_lgh064f_tuner_attach,
Michael Krufkyeffee032006-01-09 15:25:47 -02001428
Patrick Boettcher01451e72006-10-13 11:34:46 -03001429 /* parameter for the MPEG2-data transfer */
1430 .stream = {
1431 .type = USB_BULK,
1432 .count = 5,
1433 .endpoint = 0x02,
1434 .u = {
1435 .bulk = {
1436 .buffersize = 8192,
1437 }
1438 }
1439 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001440 },
1441 },
1442
1443 .power_ctrl = cxusb_bluebird_power_ctrl,
1444
Michael Krufkyeffee032006-01-09 15:25:47 -02001445 .i2c_algo = &cxusb_i2c_algo,
1446
Michael Krufkyc1501782006-03-26 05:43:36 -03001447 .rc_interval = 100,
1448 .rc_key_map = dvico_portable_rc_keys,
1449 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1450 .rc_query = cxusb_rc_query,
1451
Michael Krufkyeffee032006-01-09 15:25:47 -02001452 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufkyeffee032006-01-09 15:25:47 -02001453
1454 .num_device_descs = 1,
1455 .devices = {
1456 { "DViCO FusionHDTV5 USB Gold",
1457 { &cxusb_table[1], NULL },
1458 { &cxusb_table[2], NULL },
1459 },
1460 }
1461};
1462
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001463static struct dvb_usb_device_properties cxusb_bluebird_dee1601_properties = {
Chris Pascoe0029ee12006-01-09 18:21:28 -02001464 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1465
Patrick Boettcherf5373782006-01-09 18:21:38 -02001466 .usb_ctrl = DEVICE_SPECIFIC,
1467 .firmware = "dvb-usb-bluebird-01.fw",
1468 .download_firmware = bluebird_patch_dvico_firmware_download,
Chris Pascoe0029ee12006-01-09 18:21:28 -02001469 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1470 use usb alt setting 7 for EP2 transfer (atsc) */
1471
1472 .size_of_priv = sizeof(struct cxusb_state),
1473
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001474 .num_adapters = 1,
1475 .adapter = {
1476 {
Patrick Boettcher01451e72006-10-13 11:34:46 -03001477 .streaming_ctrl = cxusb_streaming_ctrl,
1478 .frontend_attach = cxusb_dee1601_frontend_attach,
1479 .tuner_attach = cxusb_dee1601_tuner_attach,
1480 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001481 .stream = {
1482 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -03001483 .count = 5,
1484 .endpoint = 0x04,
1485 .u = {
1486 .bulk = {
1487 .buffersize = 8192,
1488 }
1489 }
1490 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001491 },
1492 },
1493
1494 .power_ctrl = cxusb_bluebird_power_ctrl,
Chris Pascoe0029ee12006-01-09 18:21:28 -02001495
1496 .i2c_algo = &cxusb_i2c_algo,
1497
Chris Pascoe7c239702006-01-09 18:21:29 -02001498 .rc_interval = 150,
1499 .rc_key_map = dvico_mce_rc_keys,
1500 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
1501 .rc_query = cxusb_rc_query,
1502
Chris Pascoe0029ee12006-01-09 18:21:28 -02001503 .generic_bulk_ctrl_endpoint = 0x01,
Chris Pascoe0029ee12006-01-09 18:21:28 -02001504
Michael Krufky587c03d2006-09-28 02:16:01 -03001505 .num_device_descs = 3,
Chris Pascoe0029ee12006-01-09 18:21:28 -02001506 .devices = {
1507 { "DViCO FusionHDTV DVB-T Dual USB",
1508 { &cxusb_table[3], NULL },
1509 { &cxusb_table[4], NULL },
1510 },
Michael Krufkyac9ffb92006-01-11 23:21:00 -02001511 { "DigitalNow DVB-T Dual USB",
1512 { &cxusb_table[9], NULL },
1513 { &cxusb_table[10], NULL },
1514 },
Michael Krufky587c03d2006-09-28 02:16:01 -03001515 { "DViCO FusionHDTV DVB-T Dual Digital 2",
1516 { &cxusb_table[11], NULL },
1517 { &cxusb_table[12], NULL },
1518 },
Chris Pascoe0029ee12006-01-09 18:21:28 -02001519 }
1520};
1521
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001522static struct dvb_usb_device_properties cxusb_bluebird_lgz201_properties = {
Michael Krufky6f447252006-01-11 19:40:33 -02001523 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1524
1525 .usb_ctrl = DEVICE_SPECIFIC,
1526 .firmware = "dvb-usb-bluebird-01.fw",
1527 .download_firmware = bluebird_patch_dvico_firmware_download,
1528 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1529 use usb alt setting 7 for EP2 transfer (atsc) */
1530
1531 .size_of_priv = sizeof(struct cxusb_state),
1532
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001533 .num_adapters = 2,
1534 .adapter = {
1535 {
Patrick Boettcher01451e72006-10-13 11:34:46 -03001536 .streaming_ctrl = cxusb_streaming_ctrl,
1537 .frontend_attach = cxusb_mt352_frontend_attach,
1538 .tuner_attach = cxusb_lgz201_tuner_attach,
Michael Krufky6f447252006-01-11 19:40:33 -02001539
Patrick Boettcher01451e72006-10-13 11:34:46 -03001540 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001541 .stream = {
1542 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -03001543 .count = 5,
1544 .endpoint = 0x04,
1545 .u = {
1546 .bulk = {
1547 .buffersize = 8192,
1548 }
1549 }
1550 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001551 },
1552 },
1553 .power_ctrl = cxusb_bluebird_power_ctrl,
1554
Michael Krufky6f447252006-01-11 19:40:33 -02001555 .i2c_algo = &cxusb_i2c_algo,
1556
Michael Krufkyc1501782006-03-26 05:43:36 -03001557 .rc_interval = 100,
1558 .rc_key_map = dvico_portable_rc_keys,
1559 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1560 .rc_query = cxusb_rc_query,
1561
Michael Krufky6f447252006-01-11 19:40:33 -02001562 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufky6f447252006-01-11 19:40:33 -02001563 .num_device_descs = 1,
1564 .devices = {
1565 { "DViCO FusionHDTV DVB-T USB (LGZ201)",
1566 { &cxusb_table[5], NULL },
1567 { &cxusb_table[6], NULL },
1568 },
1569 }
1570};
1571
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001572static struct dvb_usb_device_properties cxusb_bluebird_dtt7579_properties = {
Michael Krufky6f447252006-01-11 19:40:33 -02001573 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1574
1575 .usb_ctrl = DEVICE_SPECIFIC,
1576 .firmware = "dvb-usb-bluebird-01.fw",
1577 .download_firmware = bluebird_patch_dvico_firmware_download,
1578 /* use usb alt setting 0 for EP4 transfer (dvb-t),
1579 use usb alt setting 7 for EP2 transfer (atsc) */
1580
1581 .size_of_priv = sizeof(struct cxusb_state),
1582
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001583 .num_adapters = 1,
1584 .adapter = {
1585 {
Patrick Boettcher01451e72006-10-13 11:34:46 -03001586 .streaming_ctrl = cxusb_streaming_ctrl,
1587 .frontend_attach = cxusb_mt352_frontend_attach,
1588 .tuner_attach = cxusb_dtt7579_tuner_attach,
Michael Krufky6f447252006-01-11 19:40:33 -02001589
Patrick Boettcher01451e72006-10-13 11:34:46 -03001590 /* parameter for the MPEG2-data transfer */
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001591 .stream = {
1592 .type = USB_BULK,
Patrick Boettcher01451e72006-10-13 11:34:46 -03001593 .count = 5,
1594 .endpoint = 0x04,
1595 .u = {
1596 .bulk = {
1597 .buffersize = 8192,
1598 }
1599 }
1600 },
Patrick Boettcher4d43e132006-09-30 06:53:48 -03001601 },
1602 },
1603 .power_ctrl = cxusb_bluebird_power_ctrl,
1604
Michael Krufky6f447252006-01-11 19:40:33 -02001605 .i2c_algo = &cxusb_i2c_algo,
1606
Michael Krufkyc1501782006-03-26 05:43:36 -03001607 .rc_interval = 100,
1608 .rc_key_map = dvico_portable_rc_keys,
1609 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1610 .rc_query = cxusb_rc_query,
1611
Michael Krufky6f447252006-01-11 19:40:33 -02001612 .generic_bulk_ctrl_endpoint = 0x01,
Michael Krufky6f447252006-01-11 19:40:33 -02001613
1614 .num_device_descs = 1,
1615 .devices = {
1616 { "DViCO FusionHDTV DVB-T USB (TH7579)",
1617 { &cxusb_table[7], NULL },
1618 { &cxusb_table[8], NULL },
1619 },
1620 }
1621};
1622
Chris Pascoeaeb012b2007-11-19 21:57:10 -03001623static struct dvb_usb_device_properties cxusb_bluebird_dualdig4_properties = {
1624 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1625
1626 .usb_ctrl = CYPRESS_FX2,
1627
1628 .size_of_priv = sizeof(struct cxusb_state),
1629
1630 .num_adapters = 1,
1631 .adapter = {
1632 {
1633 .streaming_ctrl = cxusb_streaming_ctrl,
1634 .frontend_attach = cxusb_dualdig4_frontend_attach,
1635 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1636 /* parameter for the MPEG2-data transfer */
1637 .stream = {
1638 .type = USB_BULK,
1639 .count = 5,
1640 .endpoint = 0x02,
1641 .u = {
1642 .bulk = {
1643 .buffersize = 8192,
1644 }
1645 }
1646 },
1647 },
1648 },
1649
1650 .power_ctrl = cxusb_power_ctrl,
1651
1652 .i2c_algo = &cxusb_i2c_algo,
1653
1654 .generic_bulk_ctrl_endpoint = 0x01,
1655
1656 .rc_interval = 100,
1657 .rc_key_map = dvico_mce_rc_keys,
1658 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
1659 .rc_query = cxusb_bluebird2_rc_query,
1660
1661 .num_device_descs = 1,
1662 .devices = {
1663 { "DViCO FusionHDTV DVB-T Dual Digital 4",
1664 { NULL },
1665 { &cxusb_table[13], NULL },
1666 },
1667 }
1668};
1669
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001670static struct dvb_usb_device_properties cxusb_bluebird_nano2_properties = {
1671 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1672
1673 .usb_ctrl = CYPRESS_FX2,
Chris Pascoe702a6762007-11-20 03:34:11 -03001674 .identify_state = bluebird_fx2_identify_state,
Chris Pascoe5ccaf902007-11-20 01:53:31 -03001675
1676 .size_of_priv = sizeof(struct cxusb_state),
1677
1678 .num_adapters = 1,
1679 .adapter = {
1680 {
1681 .streaming_ctrl = cxusb_streaming_ctrl,
1682 .frontend_attach = cxusb_nano2_frontend_attach,
1683 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1684 /* parameter for the MPEG2-data transfer */
1685 .stream = {
1686 .type = USB_BULK,
1687 .count = 5,
1688 .endpoint = 0x02,
1689 .u = {
1690 .bulk = {
1691 .buffersize = 8192,
1692 }
1693 }
1694 },
1695 },
1696 },
1697
1698 .power_ctrl = cxusb_nano2_power_ctrl,
1699
1700 .i2c_algo = &cxusb_i2c_algo,
1701
1702 .generic_bulk_ctrl_endpoint = 0x01,
1703
1704 .rc_interval = 100,
1705 .rc_key_map = dvico_portable_rc_keys,
1706 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1707 .rc_query = cxusb_bluebird2_rc_query,
1708
1709 .num_device_descs = 1,
1710 .devices = {
1711 { "DViCO FusionHDTV DVB-T NANO2",
1712 { NULL },
1713 { &cxusb_table[14], NULL },
1714 },
1715 }
1716};
1717
Chris Pascoe702a6762007-11-20 03:34:11 -03001718static struct dvb_usb_device_properties cxusb_bluebird_nano2_needsfirmware_properties = {
1719 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1720
1721 .usb_ctrl = DEVICE_SPECIFIC,
1722 .firmware = "dvb-usb-bluebird-02.fw",
1723 .download_firmware = bluebird_patch_dvico_firmware_download,
1724 .identify_state = bluebird_fx2_identify_state,
1725
1726 .size_of_priv = sizeof(struct cxusb_state),
1727
1728 .num_adapters = 1,
1729 .adapter = {
1730 {
1731 .streaming_ctrl = cxusb_streaming_ctrl,
1732 .frontend_attach = cxusb_nano2_frontend_attach,
1733 .tuner_attach = cxusb_dvico_xc3028_tuner_attach,
1734 /* parameter for the MPEG2-data transfer */
1735 .stream = {
1736 .type = USB_BULK,
1737 .count = 5,
1738 .endpoint = 0x02,
1739 .u = {
1740 .bulk = {
1741 .buffersize = 8192,
1742 }
1743 }
1744 },
1745 },
1746 },
1747
1748 .power_ctrl = cxusb_nano2_power_ctrl,
1749
1750 .i2c_algo = &cxusb_i2c_algo,
1751
1752 .generic_bulk_ctrl_endpoint = 0x01,
1753
1754 .rc_interval = 100,
1755 .rc_key_map = dvico_portable_rc_keys,
1756 .rc_key_map_size = ARRAY_SIZE(dvico_portable_rc_keys),
1757 .rc_query = cxusb_rc_query,
1758
1759 .num_device_descs = 1,
1760 .devices = {
1761 { "DViCO FusionHDTV DVB-T NANO2 w/o firmware",
1762 { &cxusb_table[14], NULL },
1763 { &cxusb_table[15], NULL },
1764 },
1765 }
1766};
1767
Daniel Gimpelevichf5376ad2008-06-28 05:01:30 -03001768static struct dvb_usb_device_properties cxusb_aver_a868r_properties = {
1769 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1770
1771 .usb_ctrl = CYPRESS_FX2,
1772
1773 .size_of_priv = sizeof(struct cxusb_state),
1774
1775 .num_adapters = 1,
1776 .adapter = {
1777 {
1778 .streaming_ctrl = cxusb_aver_streaming_ctrl,
1779 .frontend_attach = cxusb_aver_lgdt3303_frontend_attach,
1780 .tuner_attach = cxusb_mxl5003s_tuner_attach,
1781 /* parameter for the MPEG2-data transfer */
1782 .stream = {
1783 .type = USB_BULK,
1784 .count = 5,
1785 .endpoint = 0x04,
1786 .u = {
1787 .bulk = {
1788 .buffersize = 8192,
1789 }
1790 }
1791 },
1792
1793 },
1794 },
1795 .power_ctrl = cxusb_aver_power_ctrl,
1796
1797 .i2c_algo = &cxusb_i2c_algo,
1798
1799 .generic_bulk_ctrl_endpoint = 0x01,
1800
1801 .num_device_descs = 1,
1802 .devices = {
1803 { "AVerMedia AVerTVHD Volar (A868R)",
1804 { NULL },
1805 { &cxusb_table[16], NULL },
1806 },
1807 }
1808};
1809
Michael Krufkya2dc86b2008-08-09 13:06:26 -03001810static
1811struct dvb_usb_device_properties cxusb_bluebird_dualdig4_rev2_properties = {
Anton Blanchard8d798982008-08-09 12:23:15 -03001812 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1813
1814 .usb_ctrl = CYPRESS_FX2,
1815
1816 .size_of_priv = sizeof(struct cxusb_state),
1817
1818 .num_adapters = 1,
1819 .adapter = {
1820 {
Michael Krufkya2dc86b2008-08-09 13:06:26 -03001821 .streaming_ctrl = cxusb_streaming_ctrl,
1822 .frontend_attach = cxusb_dualdig4_rev2_frontend_attach,
1823 .tuner_attach = cxusb_dualdig4_rev2_tuner_attach,
1824 .size_of_priv = sizeof(struct dib0700_adapter_state),
Anton Blanchard8d798982008-08-09 12:23:15 -03001825 /* parameter for the MPEG2-data transfer */
1826 .stream = {
1827 .type = USB_BULK,
1828 .count = 7,
1829 .endpoint = 0x02,
1830 .u = {
1831 .bulk = {
1832 .buffersize = 4096,
1833 }
1834 }
1835 },
1836 },
1837 },
1838
1839 .power_ctrl = cxusb_bluebird_power_ctrl,
1840
1841 .i2c_algo = &cxusb_i2c_algo,
1842
1843 .generic_bulk_ctrl_endpoint = 0x01,
1844
1845 .rc_interval = 100,
1846 .rc_key_map = dvico_mce_rc_keys,
1847 .rc_key_map_size = ARRAY_SIZE(dvico_mce_rc_keys),
1848 .rc_query = cxusb_rc_query,
1849
1850 .num_device_descs = 1,
1851 .devices = {
1852 { "DViCO FusionHDTV DVB-T Dual Digital 4 (rev 2)",
1853 { NULL },
1854 { &cxusb_table[17], NULL },
1855 },
1856 }
1857};
1858
Timothy Leedfbdce02008-08-09 13:36:51 -03001859static struct dvb_usb_device_properties cxusb_d680_dmb_properties = {
1860 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1861
1862 .usb_ctrl = CYPRESS_FX2,
1863
1864 .size_of_priv = sizeof(struct cxusb_state),
1865
1866 .num_adapters = 1,
1867 .adapter = {
1868 {
1869 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
1870 .frontend_attach = cxusb_d680_dmb_frontend_attach,
1871 .tuner_attach = cxusb_d680_dmb_tuner_attach,
1872
1873 /* parameter for the MPEG2-data transfer */
1874 .stream = {
1875 .type = USB_BULK,
1876 .count = 5,
1877 .endpoint = 0x02,
1878 .u = {
1879 .bulk = {
1880 .buffersize = 8192,
1881 }
1882 }
1883 },
1884 },
1885 },
1886
1887 .power_ctrl = cxusb_d680_dmb_power_ctrl,
1888
1889 .i2c_algo = &cxusb_i2c_algo,
1890
1891 .generic_bulk_ctrl_endpoint = 0x01,
1892
1893 .rc_interval = 100,
1894 .rc_key_map = d680_dmb_rc_keys,
1895 .rc_key_map_size = ARRAY_SIZE(d680_dmb_rc_keys),
1896 .rc_query = cxusb_d680_dmb_rc_query,
1897
1898 .num_device_descs = 1,
1899 .devices = {
1900 {
1901 "Conexant DMB-TH Stick",
1902 { NULL },
1903 { &cxusb_table[18], NULL },
1904 },
1905 }
1906};
1907
David Wongb18bd1d2009-10-26 09:41:22 -03001908static struct dvb_usb_device_properties cxusb_mygica_d689_properties = {
1909 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
1910
1911 .usb_ctrl = CYPRESS_FX2,
1912
1913 .size_of_priv = sizeof(struct cxusb_state),
1914
1915 .num_adapters = 1,
1916 .adapter = {
1917 {
1918 .streaming_ctrl = cxusb_d680_dmb_streaming_ctrl,
1919 .frontend_attach = cxusb_mygica_d689_frontend_attach,
1920 .tuner_attach = cxusb_mygica_d689_tuner_attach,
1921
1922 /* parameter for the MPEG2-data transfer */
1923 .stream = {
1924 .type = USB_BULK,
1925 .count = 5,
1926 .endpoint = 0x02,
1927 .u = {
1928 .bulk = {
1929 .buffersize = 8192,
1930 }
1931 }
1932 },
1933 },
1934 },
1935
1936 .power_ctrl = cxusb_d680_dmb_power_ctrl,
1937
1938 .i2c_algo = &cxusb_i2c_algo,
1939
1940 .generic_bulk_ctrl_endpoint = 0x01,
1941
1942 .rc_interval = 100,
1943 .rc_key_map = d680_dmb_rc_keys,
1944 .rc_key_map_size = ARRAY_SIZE(d680_dmb_rc_keys),
1945 .rc_query = cxusb_d680_dmb_rc_query,
1946
1947 .num_device_descs = 1,
1948 .devices = {
1949 {
1950 "Mygica D689 DMB-TH",
1951 { NULL },
1952 { &cxusb_table[19], NULL },
1953 },
1954 }
1955};
1956
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001957static struct usb_driver cxusb_driver = {
Patrick Boettcher63b5c1c2005-07-07 17:58:30 -07001958 .name = "dvb_usb_cxusb",
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001959 .probe = cxusb_probe,
Michael Krufkyf35db232006-12-05 14:53:39 -03001960 .disconnect = dvb_usb_device_exit,
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001961 .id_table = cxusb_table,
1962};
1963
1964/* module stuff */
1965static int __init cxusb_module_init(void)
1966{
1967 int result;
1968 if ((result = usb_register(&cxusb_driver))) {
1969 err("usb_register failed. Error number %d",result);
1970 return result;
1971 }
1972
1973 return 0;
1974}
1975
1976static void __exit cxusb_module_exit(void)
1977{
1978 /* deregister this driver from the USB subsystem */
1979 usb_deregister(&cxusb_driver);
1980}
1981
1982module_init (cxusb_module_init);
1983module_exit (cxusb_module_exit);
1984
1985MODULE_AUTHOR("Patrick Boettcher <patrick.boettcher@desy.de>");
Michael Krufky5b9ed282006-10-15 14:51:08 -03001986MODULE_AUTHOR("Michael Krufky <mkrufky@linuxtv.org>");
Michael Krufkyf4efb4d2006-01-13 14:10:25 -02001987MODULE_AUTHOR("Chris Pascoe <c.pascoe@itee.uq.edu.au>");
Patrick Boettcher22c6d932005-07-07 17:58:10 -07001988MODULE_DESCRIPTION("Driver for Conexant USB2.0 hybrid reference design");
1989MODULE_VERSION("1.0-alpha");
1990MODULE_LICENSE("GPL");