43 #include <linux/module.h>
44 #include <linux/kernel.h>
46 #include <linux/sched.h>
47 #include <linux/errno.h>
50 #include <linux/time.h>
57 #define DRIVER_VERSION "0.2"
58 #define DRIVER_AUTHOR \
60 #define DRIVER_DESC "Igorplug USB remote driver for LIRC"
61 #define DRIVER_NAME "lirc_igorplugusb"
64 #ifdef CONFIG_USB_DEBUG
65 static bool debug = 1;
70 #define dprintk(fmt, args...) \
73 printk(KERN_DEBUG fmt, ## args); \
77 #define CODE_LENGTH sizeof(int)
80 #define DEVICE_BUFLEN 36
88 #define DEVICE_HEADERLEN 3
91 #define ADDITIONAL_LIRC_BYTES 2
94 #define SAMPLE_RATE 100
100 #define SET_INFRABUFFER_EMPTY 1
106 #define GET_INFRACODE 2
114 #define SET_DATAPORT_DIRECTION 3
122 #define GET_DATAPORT_DIRECTION 4
129 #define SET_OUT_DATAPORT 5
137 #define GET_OUT_DATAPORT 6
144 #define GET_IN_DATAPORT 7
151 #define READ_EEPROM 8
159 #define WRITE_EEPROM 9
168 #define SEND_RS232 10
176 #define RECV_RS232 11
183 #define SET_RS232_BAUD 12
191 #define GET_RS232_BAUD 13
220 static int unregister_from_lirc(
struct igorplug *
ir)
267 static void set_use_dec(
void *data)
287 code = (
unsigned int)ir->
buf_in[i] * 85 +
288 (
unsigned int)ir->
buf_in[
i] / 3;
292 lirc_buffer_write(buf, (
unsigned char *)&code);
305 static int igorplugusb_remote_poll(
void *data,
struct lirc_buffer *buf)
319 HZ * USB_CTRL_GET_TIMEOUT);
332 timediff = now.tv_sec - ir->
last_time.tv_sec;
337 timediff += now.tv_usec - ir->
last_time.tv_usec;
344 lirc_buffer_write(buf, (
unsigned char *)&code);
351 "[%d]: Device buffer overrun.\n", ir->
devnum);
357 send_fragment(ir, buf, DEVICE_HEADERLEN +
359 send_fragment(ir, buf, DEVICE_HEADERLEN,
360 DEVICE_HEADERLEN + ir->
buf_in[2]);
368 HZ * USB_CTRL_GET_TIMEOUT);
371 "error %d\n", ir->
devnum, ret);
386 struct usb_host_interface *idesc =
NULL;
392 char buf[63],
name[128] =
"";
398 dev = interface_to_usbdev(intf);
400 idesc = intf->cur_altsetting;
402 if (idesc->desc.bNumEndpoints != 1)
405 ep = &idesc->endpoint->desc;
413 devnum = dev->devnum;
414 maxp = usb_maxpacket(dev, pipe, usb_pipeout(pipe));
423 goto mem_failure_switch;
428 goto mem_failure_switch;
435 goto mem_failure_switch;
448 driver->
add_to_buf = &igorplugusb_remote_poll;
449 driver->
dev = &intf->dev;
458 switch (mem_failure) {
468 devnum, mem_failure);
480 if (dev->descriptor.iManufacturer
481 &&
usb_string(dev, dev->descriptor.iManufacturer,
482 buf,
sizeof(buf)) > 0)
483 strlcpy(name, buf,
sizeof(name));
484 if (dev->descriptor.iProduct
485 &&
usb_string(dev, dev->descriptor.iProduct, buf,
sizeof(buf)) > 0)
489 dev->bus->busnum, devnum);
496 HZ * USB_CTRL_GET_TIMEOUT);
501 usb_set_intfdata(intf, ir);
506 static void igorplugusb_remote_disconnect(
struct usb_interface *intf)
508 struct usb_device *usbdev = interface_to_usbdev(intf);
509 struct igorplug *ir = usb_get_intfdata(intf);
510 struct device *dev = &intf->dev;
513 usb_set_intfdata(intf,
NULL);
522 devnum = unregister_from_lirc(ir);
527 static struct usb_device_id igorplugusb_remote_id_table[] = {
529 { USB_DEVICE(0x03eb, 0x0002) },
531 { USB_DEVICE(0x03eb, 0x21fe) },
537 static struct usb_driver igorplugusb_remote_driver = {
539 .probe = igorplugusb_remote_probe,
540 .disconnect = igorplugusb_remote_disconnect,
541 .id_table = igorplugusb_remote_id_table