Linux 2.6.34-rc3
[pohmelfs.git] / drivers / media / dvb / dvb-usb / dib0700_core.c
blob4f961d2d1817e776699cebd54554f833ae14a66e
1 /* Linux driver for devices based on the DiBcom DiB0700 USB bridge
3 * This program is free software; you can redistribute it and/or modify it
4 * under the terms of the GNU General Public License as published by the Free
5 * Software Foundation, version 2.
7 * Copyright (C) 2005-6 DiBcom, SA
8 */
9 #include "dib0700.h"
11 /* debug */
12 int dvb_usb_dib0700_debug;
13 module_param_named(debug,dvb_usb_dib0700_debug, int, 0644);
14 MODULE_PARM_DESC(debug, "set debugging level (1=info,2=fw,4=fwdata,8=data (or-able))." DVB_USB_DEBUG_STATUS);
16 int dvb_usb_dib0700_ir_proto = 1;
17 module_param(dvb_usb_dib0700_ir_proto, int, 0644);
18 MODULE_PARM_DESC(dvb_usb_dib0700_ir_proto, "set ir protocol (0=NEC, 1=RC5 (default), 2=RC6).");
20 static int nb_packet_buffer_size = 21;
21 module_param(nb_packet_buffer_size, int, 0644);
22 MODULE_PARM_DESC(nb_packet_buffer_size,
23 "Set the dib0700 driver data buffer size. This parameter "
24 "corresponds to the number of TS packets. The actual size of "
25 "the data buffer corresponds to this parameter "
26 "multiplied by 188 (default: 21)");
28 DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr);
31 int dib0700_get_version(struct dvb_usb_device *d, u32 *hwversion,
32 u32 *romversion, u32 *ramversion, u32 *fwtype)
34 u8 b[16];
35 int ret = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev, 0),
36 REQUEST_GET_VERSION,
37 USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
38 b, sizeof(b), USB_CTRL_GET_TIMEOUT);
39 if (hwversion != NULL)
40 *hwversion = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | b[3];
41 if (romversion != NULL)
42 *romversion = (b[4] << 24) | (b[5] << 16) | (b[6] << 8) | b[7];
43 if (ramversion != NULL)
44 *ramversion = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
45 if (fwtype != NULL)
46 *fwtype = (b[12] << 24) | (b[13] << 16) | (b[14] << 8) | b[15];
47 return ret;
50 /* expecting rx buffer: request data[0] data[1] ... data[2] */
51 static int dib0700_ctrl_wr(struct dvb_usb_device *d, u8 *tx, u8 txlen)
53 int status;
55 deb_data(">>> ");
56 debug_dump(tx,txlen,deb_data);
58 status = usb_control_msg(d->udev, usb_sndctrlpipe(d->udev,0),
59 tx[0], USB_TYPE_VENDOR | USB_DIR_OUT, 0, 0, tx, txlen,
60 USB_CTRL_GET_TIMEOUT);
62 if (status != txlen)
63 deb_data("ep 0 write error (status = %d, len: %d)\n",status,txlen);
65 return status < 0 ? status : 0;
68 /* expecting tx buffer: request data[0] ... data[n] (n <= 4) */
69 int dib0700_ctrl_rd(struct dvb_usb_device *d, u8 *tx, u8 txlen, u8 *rx, u8 rxlen)
71 u16 index, value;
72 int status;
74 if (txlen < 2) {
75 err("tx buffer length is smaller than 2. Makes no sense.");
76 return -EINVAL;
78 if (txlen > 4) {
79 err("tx buffer length is larger than 4. Not supported.");
80 return -EINVAL;
83 deb_data(">>> ");
84 debug_dump(tx,txlen,deb_data);
86 value = ((txlen - 2) << 8) | tx[1];
87 index = 0;
88 if (txlen > 2)
89 index |= (tx[2] << 8);
90 if (txlen > 3)
91 index |= tx[3];
93 status = usb_control_msg(d->udev, usb_rcvctrlpipe(d->udev,0), tx[0],
94 USB_TYPE_VENDOR | USB_DIR_IN, value, index, rx, rxlen,
95 USB_CTRL_GET_TIMEOUT);
97 if (status < 0)
98 deb_info("ep 0 read error (status = %d)\n",status);
100 deb_data("<<< ");
101 debug_dump(rx,rxlen,deb_data);
103 return status; /* length in case of success */
106 int dib0700_set_gpio(struct dvb_usb_device *d, enum dib07x0_gpios gpio, u8 gpio_dir, u8 gpio_val)
108 u8 buf[3] = { REQUEST_SET_GPIO, gpio, ((gpio_dir & 0x01) << 7) | ((gpio_val & 0x01) << 6) };
109 return dib0700_ctrl_wr(d,buf,3);
112 static int dib0700_set_usb_xfer_len(struct dvb_usb_device *d, u16 nb_ts_packets)
114 struct dib0700_state *st = d->priv;
115 u8 b[3];
116 int ret;
118 if (st->fw_version >= 0x10201) {
119 b[0] = REQUEST_SET_USB_XFER_LEN;
120 b[1] = (nb_ts_packets >> 8)&0xff;
121 b[2] = nb_ts_packets & 0xff;
123 deb_info("set the USB xfer len to %i Ts packet\n", nb_ts_packets);
125 ret = dib0700_ctrl_wr(d, b, 3);
126 } else {
127 deb_info("this firmware does not allow to change the USB xfer len\n");
128 ret = -EIO;
130 return ret;
134 * I2C master xfer function (supported in 1.20 firmware)
136 static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
137 int num)
139 /* The new i2c firmware messages are more reliable and in particular
140 properly support i2c read calls not preceded by a write */
142 struct dvb_usb_device *d = i2c_get_adapdata(adap);
143 uint8_t bus_mode = 1; /* 0=eeprom bus, 1=frontend bus */
144 uint8_t gen_mode = 0; /* 0=master i2c, 1=gpio i2c */
145 uint8_t en_start = 0;
146 uint8_t en_stop = 0;
147 uint8_t buf[255]; /* TBV: malloc ? */
148 int result, i;
150 /* Ensure nobody else hits the i2c bus while we're sending our
151 sequence of messages, (such as the remote control thread) */
152 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
153 return -EAGAIN;
155 for (i = 0; i < num; i++) {
156 if (i == 0) {
157 /* First message in the transaction */
158 en_start = 1;
159 } else if (!(msg[i].flags & I2C_M_NOSTART)) {
160 /* Device supports repeated-start */
161 en_start = 1;
162 } else {
163 /* Not the first packet and device doesn't support
164 repeated start */
165 en_start = 0;
167 if (i == (num - 1)) {
168 /* Last message in the transaction */
169 en_stop = 1;
172 if (msg[i].flags & I2C_M_RD) {
173 /* Read request */
174 u16 index, value;
175 uint8_t i2c_dest;
177 i2c_dest = (msg[i].addr << 1);
178 value = ((en_start << 7) | (en_stop << 6) |
179 (msg[i].len & 0x3F)) << 8 | i2c_dest;
180 /* I2C ctrl + FE bus; */
181 index = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
183 result = usb_control_msg(d->udev,
184 usb_rcvctrlpipe(d->udev, 0),
185 REQUEST_NEW_I2C_READ,
186 USB_TYPE_VENDOR | USB_DIR_IN,
187 value, index, msg[i].buf,
188 msg[i].len,
189 USB_CTRL_GET_TIMEOUT);
190 if (result < 0) {
191 err("i2c read error (status = %d)\n", result);
192 break;
195 deb_data("<<< ");
196 debug_dump(msg[i].buf, msg[i].len, deb_data);
198 } else {
199 /* Write request */
200 buf[0] = REQUEST_NEW_I2C_WRITE;
201 buf[1] = (msg[i].addr << 1);
202 buf[2] = (en_start << 7) | (en_stop << 6) |
203 (msg[i].len & 0x3F);
204 /* I2C ctrl + FE bus; */
205 buf[3] = ((gen_mode<<6)&0xC0) | ((bus_mode<<4)&0x30);
206 /* The Actual i2c payload */
207 memcpy(&buf[4], msg[i].buf, msg[i].len);
209 deb_data(">>> ");
210 debug_dump(buf, msg[i].len + 4, deb_data);
212 result = usb_control_msg(d->udev,
213 usb_sndctrlpipe(d->udev, 0),
214 REQUEST_NEW_I2C_WRITE,
215 USB_TYPE_VENDOR | USB_DIR_OUT,
216 0, 0, buf, msg[i].len + 4,
217 USB_CTRL_GET_TIMEOUT);
218 if (result < 0) {
219 err("i2c write error (status = %d)\n", result);
220 break;
224 mutex_unlock(&d->i2c_mutex);
225 return i;
229 * I2C master xfer function (pre-1.20 firmware)
231 static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
232 struct i2c_msg *msg, int num)
234 struct dvb_usb_device *d = i2c_get_adapdata(adap);
235 int i,len;
236 u8 buf[255];
238 if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
239 return -EAGAIN;
241 for (i = 0; i < num; i++) {
242 /* fill in the address */
243 buf[1] = (msg[i].addr << 1);
244 /* fill the buffer */
245 memcpy(&buf[2], msg[i].buf, msg[i].len);
247 /* write/read request */
248 if (i+1 < num && (msg[i+1].flags & I2C_M_RD)) {
249 buf[0] = REQUEST_I2C_READ;
250 buf[1] |= 1;
252 /* special thing in the current firmware: when length is zero the read-failed */
253 if ((len = dib0700_ctrl_rd(d, buf, msg[i].len + 2, msg[i+1].buf, msg[i+1].len)) <= 0) {
254 deb_info("I2C read failed on address 0x%02x\n",
255 msg[i].addr);
256 break;
259 msg[i+1].len = len;
261 i++;
262 } else {
263 buf[0] = REQUEST_I2C_WRITE;
264 if (dib0700_ctrl_wr(d, buf, msg[i].len + 2) < 0)
265 break;
269 mutex_unlock(&d->i2c_mutex);
270 return i;
273 static int dib0700_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
274 int num)
276 struct dvb_usb_device *d = i2c_get_adapdata(adap);
277 struct dib0700_state *st = d->priv;
279 if (st->fw_use_new_i2c_api == 1) {
280 /* User running at least fw 1.20 */
281 return dib0700_i2c_xfer_new(adap, msg, num);
282 } else {
283 /* Use legacy calls */
284 return dib0700_i2c_xfer_legacy(adap, msg, num);
288 static u32 dib0700_i2c_func(struct i2c_adapter *adapter)
290 return I2C_FUNC_I2C;
293 struct i2c_algorithm dib0700_i2c_algo = {
294 .master_xfer = dib0700_i2c_xfer,
295 .functionality = dib0700_i2c_func,
298 int dib0700_identify_state(struct usb_device *udev, struct dvb_usb_device_properties *props,
299 struct dvb_usb_device_description **desc, int *cold)
301 u8 b[16];
302 s16 ret = usb_control_msg(udev, usb_rcvctrlpipe(udev,0),
303 REQUEST_GET_VERSION, USB_TYPE_VENDOR | USB_DIR_IN, 0, 0, b, 16, USB_CTRL_GET_TIMEOUT);
305 deb_info("FW GET_VERSION length: %d\n",ret);
307 *cold = ret <= 0;
309 deb_info("cold: %d\n", *cold);
310 return 0;
313 static int dib0700_set_clock(struct dvb_usb_device *d, u8 en_pll,
314 u8 pll_src, u8 pll_range, u8 clock_gpio3, u16 pll_prediv,
315 u16 pll_loopdiv, u16 free_div, u16 dsuScaler)
317 u8 b[10];
318 b[0] = REQUEST_SET_CLOCK;
319 b[1] = (en_pll << 7) | (pll_src << 6) | (pll_range << 5) | (clock_gpio3 << 4);
320 b[2] = (pll_prediv >> 8) & 0xff; // MSB
321 b[3] = pll_prediv & 0xff; // LSB
322 b[4] = (pll_loopdiv >> 8) & 0xff; // MSB
323 b[5] = pll_loopdiv & 0xff; // LSB
324 b[6] = (free_div >> 8) & 0xff; // MSB
325 b[7] = free_div & 0xff; // LSB
326 b[8] = (dsuScaler >> 8) & 0xff; // MSB
327 b[9] = dsuScaler & 0xff; // LSB
329 return dib0700_ctrl_wr(d, b, 10);
332 int dib0700_ctrl_clock(struct dvb_usb_device *d, u32 clk_MHz, u8 clock_out_gp3)
334 switch (clk_MHz) {
335 case 72: dib0700_set_clock(d, 1, 0, 1, clock_out_gp3, 2, 24, 0, 0x4c); break;
336 default: return -EINVAL;
338 return 0;
341 static int dib0700_jumpram(struct usb_device *udev, u32 address)
343 int ret, actlen;
344 u8 buf[8] = { REQUEST_JUMPRAM, 0, 0, 0,
345 (address >> 24) & 0xff,
346 (address >> 16) & 0xff,
347 (address >> 8) & 0xff,
348 address & 0xff };
350 if ((ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, 0x01),buf,8,&actlen,1000)) < 0) {
351 deb_fw("jumpram to 0x%x failed\n",address);
352 return ret;
354 if (actlen != 8) {
355 deb_fw("jumpram to 0x%x failed\n",address);
356 return -EIO;
358 return 0;
361 int dib0700_download_firmware(struct usb_device *udev, const struct firmware *fw)
363 struct hexline hx;
364 int pos = 0, ret, act_len, i, adap_num;
365 u8 b[16];
366 u32 fw_version;
368 u8 buf[260];
370 while ((ret = dvb_usb_get_hexline(fw, &hx, &pos)) > 0) {
371 deb_fwdata("writing to address 0x%08x (buffer: 0x%02x %02x)\n",hx.addr, hx.len, hx.chk);
373 buf[0] = hx.len;
374 buf[1] = (hx.addr >> 8) & 0xff;
375 buf[2] = hx.addr & 0xff;
376 buf[3] = hx.type;
377 memcpy(&buf[4],hx.data,hx.len);
378 buf[4+hx.len] = hx.chk;
380 ret = usb_bulk_msg(udev,
381 usb_sndbulkpipe(udev, 0x01),
382 buf,
383 hx.len + 5,
384 &act_len,
385 1000);
387 if (ret < 0) {
388 err("firmware download failed at %d with %d",pos,ret);
389 return ret;
393 if (ret == 0) {
394 /* start the firmware */
395 if ((ret = dib0700_jumpram(udev, 0x70000000)) == 0) {
396 info("firmware started successfully.");
397 msleep(500);
399 } else
400 ret = -EIO;
402 /* the number of ts packet has to be at least 1 */
403 if (nb_packet_buffer_size < 1)
404 nb_packet_buffer_size = 1;
406 /* get the fimware version */
407 usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
408 REQUEST_GET_VERSION,
409 USB_TYPE_VENDOR | USB_DIR_IN, 0, 0,
410 b, sizeof(b), USB_CTRL_GET_TIMEOUT);
411 fw_version = (b[8] << 24) | (b[9] << 16) | (b[10] << 8) | b[11];
413 /* set the buffer size - DVB-USB is allocating URB buffers
414 * only after the firwmare download was successful */
415 for (i = 0; i < dib0700_device_count; i++) {
416 for (adap_num = 0; adap_num < dib0700_devices[i].num_adapters;
417 adap_num++) {
418 if (fw_version >= 0x10201)
419 dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 188*nb_packet_buffer_size;
420 else {
421 /* for fw version older than 1.20.1,
422 * the buffersize has to be n times 512 */
423 dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = ((188*nb_packet_buffer_size+188/2)/512)*512;
424 if (dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize < 512)
425 dib0700_devices[i].adapter[adap_num].stream.u.bulk.buffersize = 512;
430 return ret;
433 int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
435 struct dib0700_state *st = adap->dev->priv;
436 u8 b[4];
437 int ret;
439 if ((onoff != 0) && (st->fw_version >= 0x10201)) {
440 /* for firmware later than 1.20.1,
441 * the USB xfer length can be set */
442 ret = dib0700_set_usb_xfer_len(adap->dev,
443 st->nb_packet_buffer_size);
444 if (ret < 0) {
445 deb_info("can not set the USB xfer len\n");
446 return ret;
450 b[0] = REQUEST_ENABLE_VIDEO;
451 b[1] = (onoff << 4) | 0x00; /* this bit gives a kind of command, rather than enabling something or not */
453 if (st->disable_streaming_master_mode == 1)
454 b[2] = 0x00;
455 else
456 b[2] = (0x01 << 4); /* Master mode */
458 b[3] = 0x00;
460 deb_info("modifying (%d) streaming state for %d\n", onoff, adap->id);
462 if (onoff)
463 st->channel_state |= 1 << adap->id;
464 else
465 st->channel_state &= ~(1 << adap->id);
467 b[2] |= st->channel_state;
469 deb_info("data for streaming: %x %x\n",b[1],b[2]);
471 return dib0700_ctrl_wr(adap->dev, b, 4);
474 /* Number of keypresses to ignore before start repeating */
475 #define RC_REPEAT_DELAY_V1_20 10
477 /* This is the structure of the RC response packet starting in firmware 1.20 */
478 struct dib0700_rc_response {
479 u8 report_id;
480 u8 data_state;
481 u16 system;
482 u8 data;
483 u8 not_data;
485 #define RC_MSG_SIZE_V1_20 6
487 static void dib0700_rc_urb_completion(struct urb *purb)
489 struct dvb_usb_device *d = purb->context;
490 struct dvb_usb_rc_key *keymap;
491 struct dib0700_state *st;
492 struct dib0700_rc_response poll_reply;
493 u8 *buf;
494 int found = 0;
495 u32 event;
496 int state;
497 int i;
499 deb_info("%s()\n", __func__);
500 if (d == NULL)
501 return;
503 if (d->rc_input_dev == NULL) {
504 /* This will occur if disable_rc_polling=1 */
505 usb_free_urb(purb);
506 return;
509 keymap = d->props.rc_key_map;
510 st = d->priv;
511 buf = (u8 *)purb->transfer_buffer;
513 if (purb->status < 0) {
514 deb_info("discontinuing polling\n");
515 usb_free_urb(purb);
516 return;
519 if (purb->actual_length != RC_MSG_SIZE_V1_20) {
520 deb_info("malformed rc msg size=%d\n", purb->actual_length);
521 goto resubmit;
524 /* Set initial results in case we exit the function early */
525 event = 0;
526 state = REMOTE_NO_KEY_PRESSED;
528 deb_data("IR raw %02X %02X %02X %02X %02X %02X (len %d)\n", buf[0],
529 buf[1], buf[2], buf[3], buf[4], buf[5], purb->actual_length);
531 switch (dvb_usb_dib0700_ir_proto) {
532 case 0:
533 /* NEC Protocol */
534 poll_reply.report_id = 0;
535 poll_reply.data_state = 1;
536 poll_reply.system = buf[2];
537 poll_reply.data = buf[4];
538 poll_reply.not_data = buf[5];
540 /* NEC protocol sends repeat code as 0 0 0 FF */
541 if ((poll_reply.system == 0x00) && (poll_reply.data == 0x00)
542 && (poll_reply.not_data == 0xff)) {
543 poll_reply.data_state = 2;
544 break;
546 break;
547 default:
548 /* RC5 Protocol */
549 poll_reply.report_id = buf[0];
550 poll_reply.data_state = buf[1];
551 poll_reply.system = (buf[2] << 8) | buf[3];
552 poll_reply.data = buf[4];
553 poll_reply.not_data = buf[5];
554 break;
557 if ((poll_reply.data + poll_reply.not_data) != 0xff) {
558 /* Key failed integrity check */
559 err("key failed integrity check: %04x %02x %02x",
560 poll_reply.system,
561 poll_reply.data, poll_reply.not_data);
562 goto resubmit;
565 deb_data("rid=%02x ds=%02x sm=%04x d=%02x nd=%02x\n",
566 poll_reply.report_id, poll_reply.data_state,
567 poll_reply.system, poll_reply.data, poll_reply.not_data);
569 /* Find the key in the map */
570 for (i = 0; i < d->props.rc_key_map_size; i++) {
571 if (rc5_custom(&keymap[i]) == (poll_reply.system & 0xff) &&
572 rc5_data(&keymap[i]) == poll_reply.data) {
573 event = keymap[i].event;
574 found = 1;
575 break;
579 if (found == 0) {
580 err("Unknown remote controller key: %04x %02x %02x",
581 poll_reply.system, poll_reply.data, poll_reply.not_data);
582 d->last_event = 0;
583 goto resubmit;
586 if (poll_reply.data_state == 1) {
587 /* New key hit */
588 st->rc_counter = 0;
589 event = keymap[i].event;
590 state = REMOTE_KEY_PRESSED;
591 d->last_event = keymap[i].event;
592 } else if (poll_reply.data_state == 2) {
593 /* Key repeated */
594 st->rc_counter++;
596 /* prevents unwanted double hits */
597 if (st->rc_counter > RC_REPEAT_DELAY_V1_20) {
598 event = d->last_event;
599 state = REMOTE_KEY_PRESSED;
600 st->rc_counter = RC_REPEAT_DELAY_V1_20;
602 } else {
603 err("Unknown data state [%d]", poll_reply.data_state);
606 switch (state) {
607 case REMOTE_NO_KEY_PRESSED:
608 break;
609 case REMOTE_KEY_PRESSED:
610 deb_info("key pressed\n");
611 d->last_event = event;
612 case REMOTE_KEY_REPEAT:
613 deb_info("key repeated\n");
614 input_event(d->rc_input_dev, EV_KEY, event, 1);
615 input_sync(d->rc_input_dev);
616 input_event(d->rc_input_dev, EV_KEY, d->last_event, 0);
617 input_sync(d->rc_input_dev);
618 break;
619 default:
620 break;
623 resubmit:
624 /* Clean the buffer before we requeue */
625 memset(purb->transfer_buffer, 0, RC_MSG_SIZE_V1_20);
627 /* Requeue URB */
628 usb_submit_urb(purb, GFP_ATOMIC);
631 int dib0700_rc_setup(struct dvb_usb_device *d)
633 struct dib0700_state *st = d->priv;
634 u8 rc_setup[3] = {REQUEST_SET_RC, dvb_usb_dib0700_ir_proto, 0};
635 struct urb *purb;
636 int ret;
637 int i;
639 if (d->props.rc_key_map == NULL)
640 return 0;
642 /* Set the IR mode */
643 i = dib0700_ctrl_wr(d, rc_setup, 3);
644 if (i<0) {
645 err("ir protocol setup failed");
646 return -1;
649 if (st->fw_version < 0x10200)
650 return 0;
652 /* Starting in firmware 1.20, the RC info is provided on a bulk pipe */
653 purb = usb_alloc_urb(0, GFP_KERNEL);
654 if (purb == NULL) {
655 err("rc usb alloc urb failed\n");
656 return -1;
659 purb->transfer_buffer = kzalloc(RC_MSG_SIZE_V1_20, GFP_KERNEL);
660 if (purb->transfer_buffer == NULL) {
661 err("rc kzalloc failed\n");
662 usb_free_urb(purb);
663 return -1;
666 purb->status = -EINPROGRESS;
667 usb_fill_bulk_urb(purb, d->udev, usb_rcvbulkpipe(d->udev, 1),
668 purb->transfer_buffer, RC_MSG_SIZE_V1_20,
669 dib0700_rc_urb_completion, d);
671 ret = usb_submit_urb(purb, GFP_ATOMIC);
672 if (ret != 0) {
673 err("rc submit urb failed\n");
674 return -1;
677 return 0;
680 static int dib0700_probe(struct usb_interface *intf,
681 const struct usb_device_id *id)
683 int i;
684 struct dvb_usb_device *dev;
686 for (i = 0; i < dib0700_device_count; i++)
687 if (dvb_usb_device_init(intf, &dib0700_devices[i], THIS_MODULE,
688 &dev, adapter_nr) == 0) {
689 struct dib0700_state *st = dev->priv;
690 u32 hwversion, romversion, fw_version, fwtype;
692 dib0700_get_version(dev, &hwversion, &romversion,
693 &fw_version, &fwtype);
695 deb_info("Firmware version: %x, %d, 0x%x, %d\n",
696 hwversion, romversion, fw_version, fwtype);
698 st->fw_version = fw_version;
699 st->nb_packet_buffer_size = (u32)nb_packet_buffer_size;
701 dib0700_rc_setup(dev);
703 return 0;
706 return -ENODEV;
709 static struct usb_driver dib0700_driver = {
710 .name = "dvb_usb_dib0700",
711 .probe = dib0700_probe,
712 .disconnect = dvb_usb_device_exit,
713 .id_table = dib0700_usb_id_table,
716 /* module stuff */
717 static int __init dib0700_module_init(void)
719 int result;
720 info("loaded with support for %d different device-types", dib0700_device_count);
721 if ((result = usb_register(&dib0700_driver))) {
722 err("usb_register failed. Error number %d",result);
723 return result;
726 return 0;
729 static void __exit dib0700_module_exit(void)
731 /* deregister this driver from the USB subsystem */
732 usb_deregister(&dib0700_driver);
735 module_init (dib0700_module_init);
736 module_exit (dib0700_module_exit);
738 MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
739 MODULE_DESCRIPTION("Driver for devices based on DiBcom DiB0700 - USB bridge");
740 MODULE_VERSION("1.0");
741 MODULE_LICENSE("GPL");