27 #include <linux/kernel.h>
28 #include <linux/errno.h>
30 #include <linux/slab.h>
31 #include <linux/tty.h>
34 #include <linux/module.h>
42 #define DRIVER_DESC "USB IR Dongle driver"
46 static int buffer_size;
55 static void ir_process_read_urb(
struct urb *
urb);
56 static void ir_set_termios(
struct tty_struct *tty,
65 { USB_DEVICE(0x050f, 0x0180) },
66 { USB_DEVICE(0x08e9, 0x0100) },
67 { USB_DEVICE(0x09c4, 0x0011) },
79 .description =
"IR Dongle",
80 .id_table = ir_id_table,
82 .set_termios = ir_set_termios,
85 .prepare_write_buffer = ir_prepare_write_buffer,
86 .process_read_urb = ir_process_read_urb,
123 irda_usb_find_class_desc(
struct usb_serial *serial,
unsigned int ifnum)
125 struct usb_device *dev = serial->
dev;
136 0, ifnum, desc,
sizeof(*desc), 1000);
138 dev_dbg(&serial->
dev->dev,
"%s - ret=%d\n", __func__, ret);
139 if (ret <
sizeof(*desc)) {
141 "%s - class descriptor read %s (%d)\n", __func__,
142 (ret < 0) ?
"failed" :
"too short", ret);
146 dev_dbg(&serial->
dev->dev,
"%s - bad class descriptor type\n",
151 irda_usb_dump_class_desc(serial, desc);
159 static u8 ir_xbof_change(
u8 xbof)
197 static int ir_startup(
struct usb_serial *serial)
201 irda_desc = irda_usb_find_class_desc(serial, 0);
204 "IRDA class descriptor not found, device not bound\n");
209 "%s - Baud rates supported:%s%s%s%s%s%s%s%s%s\n",
260 port->
write_urbs[i]->transfer_flags = URB_ZERO_PACKET;
279 *buf = ir_xbof | ir_baud;
286 static void ir_process_read_urb(
struct urb *
urb)
289 unsigned char *
data = urb->transfer_buffer;
292 if (!urb->actual_length)
300 ir_baud = *data & 0x0f;
302 if (urb->actual_length == 1)
308 tty_insert_flip_string(tty, data + 1, urb->actual_length - 1);
313 static void ir_set_termios_callback(
struct urb *urb)
315 kfree(urb->transfer_buffer);
318 dev_dbg(&urb->dev->dev,
"%s - non-zero urb status: %d\n",
319 __func__, urb->status);
322 static void ir_set_termios(
struct tty_struct *tty,
373 ir_xbof = ir_xbof_change(ir_add_bof);
375 ir_xbof = ir_xbof_change(xbof) ;
386 dev_err(&port->
dev,
"%s - no more urbs\n", __func__);
390 if (!transfer_buffer) {
391 dev_err(&port->
dev,
"%s - out of memory\n", __func__);
395 *transfer_buffer = ir_xbof | ir_baud;
400 usb_sndbulkpipe(port->
serial->dev,
404 ir_set_termios_callback,
407 urb->transfer_flags = URB_ZERO_PACKET;
411 dev_err(&port->
dev,
"%s - failed to submit urb: %d\n",
420 kfree(transfer_buffer);
425 static int __init ir_init(
void)
435 static void __exit ir_exit(
void)