21 #include <linux/module.h>
24 #include <linux/slab.h>
28 #define DRIVER_NAME "ttusbir"
29 #define DRIVER_DESC "TechnoTrend USB IR Receiver"
36 #define NS_PER_BYTE 62500
37 #define NS_PER_BIT (NS_PER_BYTE/8)
63 static void ttusbir_set_led(
struct ttusbir *
tt)
74 dev_warn(tt->
dev,
"failed to submit bulk urb: %d\n",
81 static void ttusbir_brightness_set(
struct led_classdev *led_dev,
enum
94 static void ttusbir_bulk_complete(
struct urb *
urb)
96 struct ttusbir *tt = urb->context;
100 switch (urb->status) {
110 dev_dbg(tt->
dev,
"Error: urb status = %d\n", urb->status);
128 init_ir_raw_event(&rawir);
130 for (i = 0; i < 128; i++) {
159 rawir.pulse = !rawir.pulse;
172 static void ttusbir_urb_complete(
struct urb *urb)
174 struct ttusbir *tt = urb->context;
177 switch (urb->status) {
179 ttusbir_process_ir_data(tt, urb->transfer_buffer);
188 dev_dbg(tt->
dev,
"Error: urb status = %d\n", urb->status);
194 dev_warn(tt->
dev,
"failed to resubmit urb: %d\n", rc);
215 for (i = 0; i < intf->num_altsetting && altsetting == -1; i++) {
216 int bulk_out_endp = -1, iso_in_endp = -1;
218 idesc = &intf->altsetting[
i].desc;
221 desc = &intf->altsetting[
i].endpoint[
j].desc;
222 if (usb_endpoint_dir_in(desc) &&
223 usb_endpoint_xfer_isoc(desc) &&
226 else if (usb_endpoint_dir_out(desc) &&
227 usb_endpoint_xfer_bulk(desc) &&
231 if (bulk_out_endp != -1 && iso_in_endp != -1) {
240 if (altsetting == -1) {
241 dev_err(&intf->dev,
"cannot find expected altsetting\n");
246 tt->
dev = &intf->dev;
247 tt->
udev = interface_to_usbdev(intf);
274 urb->transfer_flags = URB_NO_TRANSFER_DMA_MAP | URB_ISO_ASAP;
275 urb->transfer_buffer =
buffer;
276 urb->complete = ttusbir_urb_complete;
277 urb->number_of_packets = 8;
278 urb->transfer_buffer_length = 128;
280 for (j = 0; j < 8; j++) {
281 urb->iso_frame_desc[
j].offset = j * 16;
282 urb->iso_frame_desc[
j].length = 16;
301 ttusbir_bulk_complete, tt);
303 tt->
led.name =
"ttusbir:green:power";
304 tt->
led.brightness_set = ttusbir_brightness_set;
305 tt->
led.brightness_get = ttusbir_brightness_get;
317 rc->
dev.parent = &intf->dev;
332 dev_err(&intf->dev,
"failed to register rc device %d\n", ret);
336 usb_set_intfdata(intf, tt);
341 dev_err(tt->
dev,
"failed to submit urb %d\n", ret);
353 for (i = 0; i < NUM_URBS && tt->
urb[
i]; i++) {
354 struct urb *urb = tt->
urb[
i];
372 struct ttusbir *tt = usb_get_intfdata(intf);
383 tt->
urb[i]->transfer_dma);
388 usb_set_intfdata(intf,
NULL);
394 struct ttusbir *tt = usb_get_intfdata(intf);
408 struct ttusbir *tt = usb_get_intfdata(intf);
418 dev_warn(tt->
dev,
"failed to submit urb: %d\n", rc);
427 { USB_DEVICE(0x0b48, 0x2003) },
431 static struct usb_driver ttusbir_driver = {
433 .id_table = ttusbir_table,
434 .probe = ttusbir_probe,
435 .suspend = ttusbir_suspend,
436 .resume = ttusbir_resume,
437 .reset_resume = ttusbir_resume,