34 #include <linux/device.h>
35 #include <linux/module.h>
36 #include <linux/slab.h>
41 #define DRIVER_VERSION "1.61"
42 #define DRIVER_NAME "streamzap"
43 #define DRIVER_DESC "Streamzap Remote Control driver"
45 #ifdef CONFIG_USB_DEBUG
46 static bool debug = 1;
51 #define USB_STREAMZAP_VENDOR_ID 0x0e9c
52 #define USB_STREAMZAP_PRODUCT_ID 0x0000
64 #define SZ_PULSE_MASK 0xf0
65 #define SZ_SPACE_MASK 0x0f
66 #define SZ_TIMEOUT 0xff
67 #define SZ_RESOLUTION 256
70 #define SZ_BUF_LEN 128
73 #ifdef CONFIG_IR_RC5_SZ_DECODER_MODULE
74 #define load_rc5_sz_decode() request_module("ir-rc5-sz-decoder")
76 #define load_rc5_sz_decode() {}
125 static void streamzap_callback(
struct urb *
urb);
130 static struct usb_driver streamzap_driver = {
132 .probe = streamzap_probe,
133 .disconnect = streamzap_disconnect,
134 .suspend = streamzap_suspend,
135 .resume = streamzap_resume,
136 .id_table = streamzap_table,
141 dev_dbg(sz->
dev,
"Storing %s with duration %u us\n",
163 rawir.duration = (
int)(deltv * 1000000 +
166 rawir.duration -= sz->
sum;
167 rawir.duration =
US_TO_NS(rawir.duration);
179 sz->
sum += rawir.duration;
180 rawir.duration =
US_TO_NS(rawir.duration);
199 sz->
sum += rawir.duration;
200 rawir.duration =
US_TO_NS(rawir.duration);
216 static void streamzap_callback(
struct urb *
urb)
226 len = urb->actual_length;
228 switch (urb->status) {
236 dev_err(sz->
dev,
"urb terminated, status: %d\n", urb->status);
242 dev_dbg(sz->
dev,
"%s: received urb, len %d\n", __func__, len);
243 for (i = 0; i < len; i++) {
245 i, (
unsigned char)sz->
buf_in[i]);
254 sz_push_half_pulse(sz, sz->
buf_in[i]);
258 sz_push_half_pulse(sz, sz->
buf_in[i]);
259 sz_push_half_space(sz, sz->
buf_in[i]);
263 sz_push_full_pulse(sz, sz->
buf_in[i]);
271 rawir.duration = sz->
rdev->timeout;
276 ir_raw_event_reset(sz->
rdev);
278 sz_push_full_space(sz, sz->
buf_in[i]);
283 if ((sz->
buf_in[i] & SZ_SPACE_MASK) ==
288 sz_push_half_space(sz, sz->
buf_in[i]);
308 dev_err(dev,
"remote dev allocation failed\n");
313 "Receiver (%04x:%04x)",
331 dev_err(dev,
"remote input device register failed\n");
352 struct usb_device *usbdev = interface_to_usbdev(intf);
353 struct usb_host_interface *iface_host;
368 iface_host = intf->cur_altsetting;
370 if (iface_host->desc.bNumEndpoints != 1) {
371 dev_err(&intf->dev,
"%s: Unexpected desc.bNumEndpoints (%d)\n",
372 __func__, iface_host->desc.bNumEndpoints);
377 sz->
endpoint = &(iface_host->endpoint[0].desc);
380 dev_err(&intf->dev,
"%s: endpoint doesn't match input device "
381 "02%02x\n", __func__, sz->
endpoint->bEndpointAddress);
388 dev_err(&intf->dev,
"%s: endpoint attributes don't match xfer "
389 "02%02x\n", __func__, sz->
endpoint->bmAttributes);
394 pipe = usb_rcvintpipe(usbdev, sz->
endpoint->bEndpointAddress);
395 maxp = usb_maxpacket(usbdev, pipe, usb_pipeout(pipe));
398 dev_err(&intf->dev,
"%s: endpoint Max Packet Size is 0!?!\n",
413 sz->
dev = &intf->dev;
416 if (usbdev->descriptor.iManufacturer
417 &&
usb_string(usbdev, usbdev->descriptor.iManufacturer,
418 buf,
sizeof(buf)) > 0)
419 strlcpy(name, buf,
sizeof(name));
421 if (usbdev->descriptor.iProduct
422 &&
usb_string(usbdev, usbdev->descriptor.iProduct,
423 buf,
sizeof(buf)) > 0)
427 sz->
rdev = streamzap_init_rc_dev(sz);
448 maxp, (usb_complete_t)streamzap_callback,
451 sz->
urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
453 usb_set_intfdata(intf, sz);
458 dev_info(sz->
dev,
"Registered %s on usb%d:%d\n", name,
459 usbdev->bus->busnum, usbdev->devnum);
489 struct usb_device *usbdev = interface_to_usbdev(interface);
491 usb_set_intfdata(interface,
NULL);