blob: 14a2119912ba5246474c6b249a855f5815c34331 [file] [log] [blame]
Marco Gittler941491f2007-04-19 11:26:47 -03001/* DVB USB framework compliant Linux driver for the Opera1 DVB-S Card
2*
3* Copyright (C) 2006 Mario Hlawitschka (dh1pa@amsat.org)
4* Copyright (C) 2006 Marco Gittler (g.marco@freenet.de)
5*
6* This program is free software; you can redistribute it and/or modify it
7* under the terms of the GNU General Public License as published by the Free
8* Software Foundation, version 2.
9*
10* see Documentation/dvb/README.dvb-usb for more information
11*/
12
Adrian Bunk53133af2007-11-05 14:07:06 -030013#define DVB_USB_LOG_PREFIX "opera"
14
15#include "dvb-usb.h"
Marco Gittler941491f2007-04-19 11:26:47 -030016#include "stv0299.h"
17
18#define OPERA_READ_MSG 0
19#define OPERA_WRITE_MSG 1
20#define OPERA_I2C_TUNER 0xd1
21
22#define READ_FX2_REG_REQ 0xba
23#define READ_MAC_ADDR 0x08
24#define OPERA_WRITE_FX2 0xbb
25#define OPERA_TUNER_REQ 0xb1
26#define REG_1F_SYMBOLRATE_BYTE0 0x1f
27#define REG_20_SYMBOLRATE_BYTE1 0x20
28#define REG_21_SYMBOLRATE_BYTE2 0x21
29
Marco Gittler86534e52007-04-23 17:52:58 -030030#define ADDR_B600_VOLTAGE_13V (0x02)
31#define ADDR_B601_VOLTAGE_18V (0x03)
32#define ADDR_B1A6_STREAM_CTRL (0x04)
33#define ADDR_B880_READ_REMOTE (0x05)
34
Marco Gittler941491f2007-04-19 11:26:47 -030035struct opera1_state {
36 u32 last_key_pressed;
37};
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -030038struct rc_map_opera_table {
Marco Gittler941491f2007-04-19 11:26:47 -030039 u32 keycode;
40 u32 event;
41};
42
Adrian Bunk53133af2007-11-05 14:07:06 -030043static int dvb_usb_opera1_debug;
Marco Gittler941491f2007-04-19 11:26:47 -030044module_param_named(debug, dvb_usb_opera1_debug, int, 0644);
45MODULE_PARM_DESC(debug,
46 "set debugging level (1=info,xfer=2,pll=4,ts=8,err=16,rc=32,fw=64 (or-able))."
47 DVB_USB_DEBUG_STATUS);
48
Janne Grunau78e92002008-04-09 19:13:13 -030049DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
50
51
Marco Gittler941491f2007-04-19 11:26:47 -030052static int opera1_xilinx_rw(struct usb_device *dev, u8 request, u16 value,
53 u8 * data, u16 len, int flags)
54{
55 int ret;
Florian Mickler12fe2a62011-03-21 15:33:46 -030056 u8 tmp;
57 u8 *buf;
Marco Gittler941491f2007-04-19 11:26:47 -030058 unsigned int pipe = (flags == OPERA_READ_MSG) ?
59 usb_rcvctrlpipe(dev,0) : usb_sndctrlpipe(dev, 0);
60 u8 request_type = (flags == OPERA_READ_MSG) ? USB_DIR_IN : USB_DIR_OUT;
61
Florian Mickler12fe2a62011-03-21 15:33:46 -030062 buf = kmalloc(len, GFP_KERNEL);
63 if (!buf)
64 return -ENOMEM;
65
Marco Gittler941491f2007-04-19 11:26:47 -030066 if (flags == OPERA_WRITE_MSG)
Florian Mickler12fe2a62011-03-21 15:33:46 -030067 memcpy(buf, data, len);
68 ret = usb_control_msg(dev, pipe, request,
69 request_type | USB_TYPE_VENDOR, value, 0x0,
70 buf, len, 2000);
Marco Gittler941491f2007-04-19 11:26:47 -030071
72 if (request == OPERA_TUNER_REQ) {
Florian Mickler12fe2a62011-03-21 15:33:46 -030073 tmp = buf[0];
Marco Gittler941491f2007-04-19 11:26:47 -030074 if (usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
Florian Mickler12fe2a62011-03-21 15:33:46 -030075 OPERA_TUNER_REQ, USB_DIR_IN | USB_TYPE_VENDOR,
76 0x01, 0x0, buf, 1, 2000) < 1 || buf[0] != 0x08) {
77 ret = 0;
78 goto out;
79 }
80 buf[0] = tmp;
Marco Gittler941491f2007-04-19 11:26:47 -030081 }
82 if (flags == OPERA_READ_MSG)
Florian Mickler12fe2a62011-03-21 15:33:46 -030083 memcpy(data, buf, len);
84out:
85 kfree(buf);
Marco Gittler941491f2007-04-19 11:26:47 -030086 return ret;
87}
88
89/* I2C */
90
91static int opera1_usb_i2c_msgxfer(struct dvb_usb_device *dev, u16 addr,
Marco Gittler86534e52007-04-23 17:52:58 -030092 u8 * buf, u16 len)
Marco Gittler941491f2007-04-19 11:26:47 -030093{
94 int ret = 0;
95 u8 request;
96 u16 value;
97
98 if (!dev) {
99 info("no usb_device");
100 return -EINVAL;
101 }
102 if (mutex_lock_interruptible(&dev->usb_mutex) < 0)
103 return -EAGAIN;
104
Marco Gittler86534e52007-04-23 17:52:58 -0300105 switch (addr>>1){
106 case ADDR_B600_VOLTAGE_13V:
107 request=0xb6;
108 value=0x00;
109 break;
110 case ADDR_B601_VOLTAGE_18V:
111 request=0xb6;
112 value=0x01;
113 break;
114 case ADDR_B1A6_STREAM_CTRL:
115 request=0xb1;
116 value=0xa6;
117 break;
118 case ADDR_B880_READ_REMOTE:
119 request=0xb8;
120 value=0x80;
121 break;
122 default:
123 request=0xb1;
124 value=addr;
Marco Gittler941491f2007-04-19 11:26:47 -0300125 }
Marco Gittler86534e52007-04-23 17:52:58 -0300126 ret = opera1_xilinx_rw(dev->udev, request,
127 value, buf, len,
128 addr&0x01?OPERA_READ_MSG:OPERA_WRITE_MSG);
Marco Gittler941491f2007-04-19 11:26:47 -0300129
130 mutex_unlock(&dev->usb_mutex);
131 return ret;
132}
133
134static int opera1_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
135 int num)
136{
137 struct dvb_usb_device *d = i2c_get_adapdata(adap);
138 int i = 0, tmp = 0;
139
140 if (!d)
141 return -ENODEV;
142 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
143 return -EAGAIN;
144
145 for (i = 0; i < num; i++) {
146 if ((tmp = opera1_usb_i2c_msgxfer(d,
Marco Gittler86534e52007-04-23 17:52:58 -0300147 (msg[i].addr<<1)|(msg[i].flags&I2C_M_RD?0x01:0),
Marco Gittler941491f2007-04-19 11:26:47 -0300148 msg[i].buf,
Marco Gittler86534e52007-04-23 17:52:58 -0300149 msg[i].len
Roel Kluin1f39b582010-02-15 19:30:38 -0300150 )) != msg[i].len) {
Marco Gittler941491f2007-04-19 11:26:47 -0300151 break;
152 }
153 if (dvb_usb_opera1_debug & 0x10)
Masanari Iida07f42252013-03-20 11:00:34 +0900154 info("sending i2c message %d %d", tmp, msg[i].len);
Marco Gittler941491f2007-04-19 11:26:47 -0300155 }
156 mutex_unlock(&d->i2c_mutex);
157 return num;
158}
159
160static u32 opera1_i2c_func(struct i2c_adapter *adapter)
161{
162 return I2C_FUNC_I2C;
163}
164
165static struct i2c_algorithm opera1_i2c_algo = {
166 .master_xfer = opera1_i2c_xfer,
167 .functionality = opera1_i2c_func,
168};
169
170static int opera1_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage)
171{
172 static u8 command_13v[1]={0x00};
173 static u8 command_18v[1]={0x01};
174 struct i2c_msg msg[] = {
Marco Gittler86534e52007-04-23 17:52:58 -0300175 {.addr = ADDR_B600_VOLTAGE_13V,.flags = 0,.buf = command_13v,.len = 1},
Marco Gittler941491f2007-04-19 11:26:47 -0300176 };
177 struct dvb_usb_adapter *udev_adap =
178 (struct dvb_usb_adapter *)(fe->dvb->priv);
179 if (voltage == SEC_VOLTAGE_18) {
Marco Gittler86534e52007-04-23 17:52:58 -0300180 msg[0].addr = ADDR_B601_VOLTAGE_18V;
Marco Gittler941491f2007-04-19 11:26:47 -0300181 msg[0].buf = command_18v;
182 }
183 i2c_transfer(&udev_adap->dev->i2c_adap, msg, 1);
184 return 0;
185}
186
187static int opera1_stv0299_set_symbol_rate(struct dvb_frontend *fe, u32 srate,
188 u32 ratio)
189{
190 stv0299_writereg(fe, 0x13, 0x98);
191 stv0299_writereg(fe, 0x14, 0x95);
192 stv0299_writereg(fe, REG_1F_SYMBOLRATE_BYTE0, (ratio >> 16) & 0xff);
193 stv0299_writereg(fe, REG_20_SYMBOLRATE_BYTE1, (ratio >> 8) & 0xff);
194 stv0299_writereg(fe, REG_21_SYMBOLRATE_BYTE2, (ratio) & 0xf0);
195 return 0;
196
197}
198static u8 opera1_inittab[] = {
199 0x00, 0xa1,
200 0x01, 0x15,
Malcolm Priestley9d8e1b52011-03-26 22:03:47 -0300201 0x02, 0x30,
Marco Gittler941491f2007-04-19 11:26:47 -0300202 0x03, 0x00,
203 0x04, 0x7d,
204 0x05, 0x05,
205 0x06, 0x02,
206 0x07, 0x00,
207 0x0b, 0x00,
208 0x0c, 0x01,
209 0x0d, 0x81,
210 0x0e, 0x44,
211 0x0f, 0x19,
212 0x10, 0x3f,
213 0x11, 0x84,
214 0x12, 0xda,
215 0x13, 0x98,
216 0x14, 0x95,
217 0x15, 0xc9,
218 0x16, 0xeb,
219 0x17, 0x00,
220 0x18, 0x19,
221 0x19, 0x8b,
222 0x1a, 0x00,
223 0x1b, 0x82,
224 0x1c, 0x7f,
225 0x1d, 0x00,
226 0x1e, 0x00,
227 REG_1F_SYMBOLRATE_BYTE0, 0x06,
228 REG_20_SYMBOLRATE_BYTE1, 0x50,
229 REG_21_SYMBOLRATE_BYTE2, 0x10,
230 0x22, 0x00,
231 0x23, 0x00,
232 0x24, 0x37,
233 0x25, 0xbc,
234 0x26, 0x00,
235 0x27, 0x00,
236 0x28, 0x00,
237 0x29, 0x1e,
238 0x2a, 0x14,
239 0x2b, 0x1f,
240 0x2c, 0x09,
241 0x2d, 0x0a,
242 0x2e, 0x00,
243 0x2f, 0x00,
244 0x30, 0x00,
245 0x31, 0x1f,
246 0x32, 0x19,
247 0x33, 0xfc,
248 0x34, 0x13,
249 0xff, 0xff,
250};
251
252static struct stv0299_config opera1_stv0299_config = {
Marco Gittler86534e52007-04-23 17:52:58 -0300253 .demod_address = 0xd0>>1,
Marco Gittler941491f2007-04-19 11:26:47 -0300254 .min_delay_ms = 100,
255 .mclk = 88000000UL,
256 .invert = 1,
257 .skip_reinit = 0,
Oliver Endrissda2c7f62008-04-20 22:13:37 -0300258 .lock_output = STV0299_LOCKOUTPUT_0,
Marco Gittler941491f2007-04-19 11:26:47 -0300259 .volt13_op0_op1 = STV0299_VOLT13_OP0,
260 .inittab = opera1_inittab,
261 .set_symbol_rate = opera1_stv0299_set_symbol_rate,
262};
263
264static int opera1_frontend_attach(struct dvb_usb_adapter *d)
265{
Michael Krufkyee03a672011-09-17 15:03:26 -0300266 d->fe_adap[0].fe = dvb_attach(stv0299_attach, &opera1_stv0299_config,
267 &d->dev->i2c_adap);
268 if ((d->fe_adap[0].fe) != NULL) {
Michael Krufky77eed212011-09-06 09:31:57 -0300269 d->fe_adap[0].fe->ops.set_voltage = opera1_set_voltage;
Marco Gittler941491f2007-04-19 11:26:47 -0300270 return 0;
271 }
272 info("not attached stv0299");
273 return -EIO;
274}
275
276static int opera1_tuner_attach(struct dvb_usb_adapter *adap)
277{
Marco Gittler86534e52007-04-23 17:52:58 -0300278 dvb_attach(
Michael Krufky77eed212011-09-06 09:31:57 -0300279 dvb_pll_attach, adap->fe_adap[0].fe, 0xc0>>1,
Michael Krufky47a99912007-06-12 16:10:51 -0300280 &adap->dev->i2c_adap, DVB_PLL_OPERA1
Marco Gittler86534e52007-04-23 17:52:58 -0300281 );
Marco Gittler941491f2007-04-19 11:26:47 -0300282 return 0;
283}
284
285static int opera1_power_ctrl(struct dvb_usb_device *d, int onoff)
286{
Marco Gittler941491f2007-04-19 11:26:47 -0300287 u8 val = onoff ? 0x01 : 0x00;
Marco Gittler86534e52007-04-23 17:52:58 -0300288
Marco Gittler941491f2007-04-19 11:26:47 -0300289 if (dvb_usb_opera1_debug)
290 info("power %s", onoff ? "on" : "off");
Marco Gittler86534e52007-04-23 17:52:58 -0300291 return opera1_xilinx_rw(d->udev, 0xb7, val,
292 &val, 1, OPERA_WRITE_MSG);
Marco Gittler941491f2007-04-19 11:26:47 -0300293}
294
295static int opera1_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
296{
297 static u8 buf_start[2] = { 0xff, 0x03 };
298 static u8 buf_stop[2] = { 0xff, 0x00 };
299 struct i2c_msg start_tuner[] = {
Marco Gittler86534e52007-04-23 17:52:58 -0300300 {.addr = ADDR_B1A6_STREAM_CTRL,.buf = onoff ? buf_start : buf_stop,.len = 2},
Marco Gittler941491f2007-04-19 11:26:47 -0300301 };
302 if (dvb_usb_opera1_debug)
303 info("streaming %s", onoff ? "on" : "off");
304 i2c_transfer(&adap->dev->i2c_adap, start_tuner, 1);
305 return 0;
306}
307
308static int opera1_pid_filter(struct dvb_usb_adapter *adap, int index, u16 pid,
309 int onoff)
310{
311 u8 b_pid[3];
312 struct i2c_msg msg[] = {
Marco Gittler86534e52007-04-23 17:52:58 -0300313 {.addr = ADDR_B1A6_STREAM_CTRL,.buf = b_pid,.len = 3},
Marco Gittler941491f2007-04-19 11:26:47 -0300314 };
315 if (dvb_usb_opera1_debug)
316 info("pidfilter index: %d pid: %d %s", index, pid,
317 onoff ? "on" : "off");
318 b_pid[0] = (2 * index) + 4;
319 b_pid[1] = onoff ? (pid & 0xff) : (0x00);
320 b_pid[2] = onoff ? ((pid >> 8) & 0xff) : (0x00);
321 i2c_transfer(&adap->dev->i2c_adap, msg, 1);
322 return 0;
323}
324
325static int opera1_pid_filter_control(struct dvb_usb_adapter *adap, int onoff)
326{
327 int u = 0x04;
328 u8 b_pid[3];
329 struct i2c_msg msg[] = {
Marco Gittler86534e52007-04-23 17:52:58 -0300330 {.addr = ADDR_B1A6_STREAM_CTRL,.buf = b_pid,.len = 3},
Marco Gittler941491f2007-04-19 11:26:47 -0300331 };
332 if (dvb_usb_opera1_debug)
333 info("%s hw-pidfilter", onoff ? "enable" : "disable");
334 for (; u < 0x7e; u += 2) {
335 b_pid[0] = u;
336 b_pid[1] = 0;
337 b_pid[2] = 0x80;
338 i2c_transfer(&adap->dev->i2c_adap, msg, 1);
339 }
340 return 0;
341}
342
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300343static struct rc_map_table rc_map_opera1_table[] = {
Mauro Carvalho Chehab2e365882009-08-29 15:19:31 -0300344 {0x5fa0, KEY_1},
345 {0x51af, KEY_2},
346 {0x5da2, KEY_3},
347 {0x41be, KEY_4},
348 {0x0bf5, KEY_5},
349 {0x43bd, KEY_6},
350 {0x47b8, KEY_7},
351 {0x49b6, KEY_8},
352 {0x05fa, KEY_9},
353 {0x45ba, KEY_0},
Mauro Carvalho Chehab76fd93b2011-01-24 12:18:41 -0300354 {0x09f6, KEY_CHANNELUP}, /*chanup */
355 {0x1be5, KEY_CHANNELDOWN}, /*chandown */
356 {0x5da3, KEY_VOLUMEDOWN}, /*voldown */
357 {0x5fa1, KEY_VOLUMEUP}, /*volup */
358 {0x07f8, KEY_SPACE}, /*tab */
359 {0x1fe1, KEY_OK}, /*play ok */
360 {0x1be4, KEY_ZOOM}, /*zoom */
361 {0x59a6, KEY_MUTE}, /*mute */
362 {0x5ba5, KEY_RADIO}, /*tv/f */
363 {0x19e7, KEY_RECORD}, /*rec */
364 {0x01fe, KEY_STOP}, /*Stop */
365 {0x03fd, KEY_PAUSE}, /*pause */
366 {0x03fc, KEY_SCREEN}, /*<- -> */
367 {0x07f9, KEY_CAMERA}, /*capture */
368 {0x47b9, KEY_ESC}, /*exit */
369 {0x43bc, KEY_POWER2}, /*power */
Marco Gittler941491f2007-04-19 11:26:47 -0300370};
371
372static int opera1_rc_query(struct dvb_usb_device *dev, u32 * event, int *state)
373{
374 struct opera1_state *opst = dev->priv;
375 u8 rcbuffer[32];
376 const u16 startmarker1 = 0x10ed;
377 const u16 startmarker2 = 0x11ec;
378 struct i2c_msg read_remote[] = {
Marco Gittler86534e52007-04-23 17:52:58 -0300379 {.addr = ADDR_B880_READ_REMOTE,.buf = rcbuffer,.flags = I2C_M_RD,.len = 32},
Marco Gittler941491f2007-04-19 11:26:47 -0300380 };
381 int i = 0;
382 u32 send_key = 0;
383
384 if (i2c_transfer(&dev->i2c_adap, read_remote, 1) == 1) {
385 for (i = 0; i < 32; i++) {
386 if (rcbuffer[i])
387 send_key |= 1;
388 if (i < 31)
389 send_key = send_key << 1;
390 }
391 if (send_key & 0x8000)
392 send_key = (send_key << 1) | (send_key >> 15 & 0x01);
393
394 if (send_key == 0xffff && opst->last_key_pressed != 0) {
395 *state = REMOTE_KEY_REPEAT;
396 *event = opst->last_key_pressed;
397 return 0;
398 }
399 for (; send_key != 0;) {
400 if (send_key >> 16 == startmarker2) {
401 break;
402 } else if (send_key >> 16 == startmarker1) {
403 send_key =
404 (send_key & 0xfffeffff) | (startmarker1 << 16);
405 break;
406 } else
407 send_key >>= 1;
408 }
409
410 if (send_key == 0)
411 return 0;
412
413 send_key = (send_key & 0xffff) | 0x0100;
414
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300415 for (i = 0; i < ARRAY_SIZE(rc_map_opera1_table); i++) {
416 if (rc5_scan(&rc_map_opera1_table[i]) == (send_key & 0xffff)) {
Marco Gittler941491f2007-04-19 11:26:47 -0300417 *state = REMOTE_KEY_PRESSED;
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300418 *event = rc_map_opera1_table[i].keycode;
Marco Gittler941491f2007-04-19 11:26:47 -0300419 opst->last_key_pressed =
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300420 rc_map_opera1_table[i].keycode;
Marco Gittler941491f2007-04-19 11:26:47 -0300421 break;
422 }
423 opst->last_key_pressed = 0;
424 }
425 } else
426 *state = REMOTE_NO_KEY_PRESSED;
427 return 0;
428}
429
430static struct usb_device_id opera1_table[] = {
431 {USB_DEVICE(USB_VID_CYPRESS, USB_PID_OPERA1_COLD)},
432 {USB_DEVICE(USB_VID_OPERA1, USB_PID_OPERA1_WARM)},
433 {}
434};
435
436MODULE_DEVICE_TABLE(usb, opera1_table);
437
438static int opera1_read_mac_address(struct dvb_usb_device *d, u8 mac[6])
439{
440 u8 command[] = { READ_MAC_ADDR };
441 opera1_xilinx_rw(d->udev, 0xb1, 0xa0, command, 1, OPERA_WRITE_MSG);
442 opera1_xilinx_rw(d->udev, 0xb1, 0xa1, mac, 6, OPERA_READ_MSG);
443 return 0;
444}
445static int opera1_xilinx_load_firmware(struct usb_device *dev,
446 const char *filename)
447{
448 const struct firmware *fw = NULL;
449 u8 *b, *p;
Marco Gittler59800552007-07-04 19:18:34 -0300450 int ret = 0, i,fpgasize=40;
Marco Gittler941491f2007-04-19 11:26:47 -0300451 u8 testval;
Marco Gittler59800552007-07-04 19:18:34 -0300452 info("start downloading fpga firmware %s",filename);
Marco Gittler941491f2007-04-19 11:26:47 -0300453
454 if ((ret = request_firmware(&fw, filename, &dev->dev)) != 0) {
455 err("did not find the firmware file. (%s) "
456 "Please see linux/Documentation/dvb/ for more details on firmware-problems.",
457 filename);
458 return ret;
459 } else {
460 p = kmalloc(fw->size, GFP_KERNEL);
461 opera1_xilinx_rw(dev, 0xbc, 0x00, &testval, 1, OPERA_READ_MSG);
462 if (p != NULL && testval != 0x67) {
463
464 u8 reset = 0, fpga_command = 0;
465 memcpy(p, fw->data, fw->size);
466 /* clear fpga ? */
467 opera1_xilinx_rw(dev, 0xbc, 0xaa, &fpga_command, 1,
468 OPERA_WRITE_MSG);
Marco Gittler59800552007-07-04 19:18:34 -0300469 for (i = 0; i < fw->size;) {
470 if ( (fw->size - i) <fpgasize){
471 fpgasize=fw->size-i;
472 }
Marco Gittler941491f2007-04-19 11:26:47 -0300473 b = (u8 *) p + i;
474 if (opera1_xilinx_rw
Marco Gittler59800552007-07-04 19:18:34 -0300475 (dev, OPERA_WRITE_FX2, 0x0, b , fpgasize,
476 OPERA_WRITE_MSG) != fpgasize
Marco Gittler941491f2007-04-19 11:26:47 -0300477 ) {
478 err("error while transferring firmware");
479 ret = -EINVAL;
480 break;
481 }
Marco Gittler59800552007-07-04 19:18:34 -0300482 i = i + fpgasize;
Marco Gittler941491f2007-04-19 11:26:47 -0300483 }
484 /* restart the CPU */
485 if (ret || opera1_xilinx_rw
486 (dev, 0xa0, 0xe600, &reset, 1,
487 OPERA_WRITE_MSG) != 1) {
488 err("could not restart the USB controller CPU.");
489 ret = -EINVAL;
490 }
Marco Gittler941491f2007-04-19 11:26:47 -0300491 }
492 }
Adrian Bunk77596052008-02-27 21:21:15 -0300493 kfree(p);
Dan Carpentera8e07122010-08-19 06:47:50 -0300494 release_firmware(fw);
Marco Gittler941491f2007-04-19 11:26:47 -0300495 return ret;
496}
497
498static struct dvb_usb_device_properties opera1_properties = {
499 .caps = DVB_USB_IS_AN_I2C_ADAPTER,
500 .usb_ctrl = CYPRESS_FX2,
Marco Gittler86534e52007-04-23 17:52:58 -0300501 .firmware = "dvb-usb-opera-01.fw",
Marco Gittler941491f2007-04-19 11:26:47 -0300502 .size_of_priv = sizeof(struct opera1_state),
503
504 .power_ctrl = opera1_power_ctrl,
505 .i2c_algo = &opera1_i2c_algo,
506
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -0300507 .rc.legacy = {
Mauro Carvalho Chehab2f4f58d2010-11-17 15:46:09 -0300508 .rc_map_table = rc_map_opera1_table,
509 .rc_map_size = ARRAY_SIZE(rc_map_opera1_table),
Mauro Carvalho Chehabf72a27b2010-07-31 18:04:09 -0300510 .rc_interval = 200,
511 .rc_query = opera1_rc_query,
512 },
Marco Gittler941491f2007-04-19 11:26:47 -0300513 .read_mac_address = opera1_read_mac_address,
514 .generic_bulk_ctrl_endpoint = 0x00,
515 /* parameter for the MPEG2-data transfer */
516 .num_adapters = 1,
517 .adapter = {
518 {
Michael Krufky77eed212011-09-06 09:31:57 -0300519 .num_frontends = 1,
520 .fe = {{
Marco Gittler941491f2007-04-19 11:26:47 -0300521 .frontend_attach = opera1_frontend_attach,
522 .streaming_ctrl = opera1_streaming_ctrl,
523 .tuner_attach = opera1_tuner_attach,
524 .caps =
525 DVB_USB_ADAP_HAS_PID_FILTER |
526 DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF,
527 .pid_filter = opera1_pid_filter,
528 .pid_filter_ctrl = opera1_pid_filter_control,
529 .pid_filter_count = 252,
530 .stream = {
531 .type = USB_BULK,
532 .count = 10,
533 .endpoint = 0x82,
534 .u = {
535 .bulk = {
536 .buffersize = 4096,
537 }
538 }
539 },
Michael Krufky77eed212011-09-06 09:31:57 -0300540 }},
Marco Gittler941491f2007-04-19 11:26:47 -0300541 }
542 },
543 .num_device_descs = 1,
544 .devices = {
545 {"Opera1 DVB-S USB2.0",
546 {&opera1_table[0], NULL},
547 {&opera1_table[1], NULL},
548 },
549 }
550};
551
552static int opera1_probe(struct usb_interface *intf,
553 const struct usb_device_id *id)
554{
Marco Gittler941491f2007-04-19 11:26:47 -0300555 struct usb_device *udev = interface_to_usbdev(intf);
556
Hans Verkuil18d6a282014-08-20 16:50:21 -0300557 if (le16_to_cpu(udev->descriptor.idProduct) == USB_PID_OPERA1_WARM &&
558 le16_to_cpu(udev->descriptor.idVendor) == USB_VID_OPERA1 &&
Marco Gittler59800552007-07-04 19:18:34 -0300559 opera1_xilinx_load_firmware(udev, "dvb-usb-opera1-fpga-01.fw") != 0
Marco Gittlerd06cdbe2007-06-28 10:10:00 -0300560 ) {
Marco Gittler941491f2007-04-19 11:26:47 -0300561 return -EINVAL;
562 }
563
Janne Grunau78e92002008-04-09 19:13:13 -0300564 if (0 != dvb_usb_device_init(intf, &opera1_properties,
565 THIS_MODULE, NULL, adapter_nr))
Marco Gittler941491f2007-04-19 11:26:47 -0300566 return -EINVAL;
567 return 0;
568}
569
570static struct usb_driver opera1_driver = {
571 .name = "opera1",
572 .probe = opera1_probe,
573 .disconnect = dvb_usb_device_exit,
574 .id_table = opera1_table,
575};
576
Greg Kroah-Hartmanecb3b2b2011-11-18 09:46:12 -0800577module_usb_driver(opera1_driver);
Marco Gittler941491f2007-04-19 11:26:47 -0300578
579MODULE_AUTHOR("Mario Hlawitschka (c) dh1pa@amsat.org");
580MODULE_AUTHOR("Marco Gittler (c) g.marco@freenet.de");
581MODULE_DESCRIPTION("Driver for Opera1 DVB-S device");
582MODULE_VERSION("0.1");
583MODULE_LICENSE("GPL");