]>
Commit | Line | Data |
---|---|---|
c942fddf | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
19770693 JW |
2 | /* |
3 | * Streamzap Remote Control driver | |
4 | * | |
5 | * Copyright (c) 2005 Christoph Bartelmus <lirc@bartelmus.de> | |
8e9e6064 | 6 | * Copyright (c) 2010 Jarod Wilson <jarod@wilsonet.com> |
19770693 JW |
7 | * |
8 | * This driver was based on the work of Greg Wickham and Adrian | |
9 | * Dewhurst. It was substantially rewritten to support correct signal | |
10 | * gaps and now maintains a delay buffer, which is used to present | |
11 | * consistent timing behaviour to user space applications. Without the | |
12 | * delay buffer an ugly hack would be required in lircd, which can | |
13 | * cause sluggish signal decoding in certain situations. | |
14 | * | |
8e9e6064 JW |
15 | * Ported to in-kernel ir-core interface by Jarod Wilson |
16 | * | |
19770693 JW |
17 | * This driver is based on the USB skeleton driver packaged with the |
18 | * kernel; copyright (C) 2001-2003 Greg Kroah-Hartman (greg@kroah.com) | |
19770693 JW |
19 | */ |
20 | ||
8e9e6064 | 21 | #include <linux/device.h> |
19770693 | 22 | #include <linux/module.h> |
8e9e6064 | 23 | #include <linux/slab.h> |
dd4c22a6 | 24 | #include <linux/ktime.h> |
635f76b2 PB |
25 | #include <linux/usb.h> |
26 | #include <linux/usb/input.h> | |
6bda9644 | 27 | #include <media/rc-core.h> |
19770693 | 28 | |
7a569f52 | 29 | #define DRIVER_VERSION "1.61" |
8e9e6064 | 30 | #define DRIVER_NAME "streamzap" |
19770693 JW |
31 | #define DRIVER_DESC "Streamzap Remote Control driver" |
32 | ||
19770693 JW |
33 | #define USB_STREAMZAP_VENDOR_ID 0x0e9c |
34 | #define USB_STREAMZAP_PRODUCT_ID 0x0000 | |
35 | ||
19770693 | 36 | /* table of devices that work with this driver */ |
5fad16b5 | 37 | static const struct usb_device_id streamzap_table[] = { |
19770693 JW |
38 | /* Streamzap Remote Control */ |
39 | { USB_DEVICE(USB_STREAMZAP_VENDOR_ID, USB_STREAMZAP_PRODUCT_ID) }, | |
40 | /* Terminating entry */ | |
41 | { } | |
42 | }; | |
43 | ||
44 | MODULE_DEVICE_TABLE(usb, streamzap_table); | |
45 | ||
b768d47e JW |
46 | #define SZ_PULSE_MASK 0xf0 |
47 | #define SZ_SPACE_MASK 0x0f | |
48 | #define SZ_TIMEOUT 0xff | |
49 | #define SZ_RESOLUTION 256 | |
19770693 JW |
50 | |
51 | /* number of samples buffered */ | |
8e9e6064 | 52 | #define SZ_BUF_LEN 128 |
19770693 JW |
53 | |
54 | enum StreamzapDecoderState { | |
55 | PulseSpace, | |
56 | FullPulse, | |
57 | FullSpace, | |
58 | IgnorePulse | |
59 | }; | |
60 | ||
8e9e6064 JW |
61 | /* structure to hold our device specific stuff */ |
62 | struct streamzap_ir { | |
8e9e6064 | 63 | /* ir-core */ |
d8b4b582 | 64 | struct rc_dev *rdev; |
8e9e6064 JW |
65 | |
66 | /* core device info */ | |
67 | struct device *dev; | |
19770693 JW |
68 | |
69 | /* usb */ | |
8e9e6064 | 70 | struct usb_device *usbdev; |
19770693 | 71 | struct usb_interface *interface; |
8e9e6064 JW |
72 | struct usb_endpoint_descriptor *endpoint; |
73 | struct urb *urb_in; | |
19770693 JW |
74 | |
75 | /* buffer & dma */ | |
76 | unsigned char *buf_in; | |
77 | dma_addr_t dma_in; | |
78 | unsigned int buf_in_len; | |
79 | ||
8e9e6064 JW |
80 | /* track what state we're in */ |
81 | enum StreamzapDecoderState decoder_state; | |
19770693 | 82 | /* tracks whether we are currently receiving some signal */ |
8e9e6064 | 83 | bool idle; |
19770693 JW |
84 | /* sum of signal lengths received since signal start */ |
85 | unsigned long sum; | |
86 | /* start time of signal; necessary for gap tracking */ | |
dd4c22a6 TR |
87 | ktime_t signal_last; |
88 | ktime_t signal_start; | |
7a569f52 | 89 | bool timeout_enabled; |
8e9e6064 JW |
90 | |
91 | char name[128]; | |
92 | char phys[64]; | |
19770693 JW |
93 | }; |
94 | ||
95 | ||
96 | /* local function prototypes */ | |
97 | static int streamzap_probe(struct usb_interface *interface, | |
98 | const struct usb_device_id *id); | |
99 | static void streamzap_disconnect(struct usb_interface *interface); | |
8e9e6064 | 100 | static void streamzap_callback(struct urb *urb); |
19770693 JW |
101 | static int streamzap_suspend(struct usb_interface *intf, pm_message_t message); |
102 | static int streamzap_resume(struct usb_interface *intf); | |
103 | ||
104 | /* usb specific object needed to register this driver with the usb subsystem */ | |
19770693 JW |
105 | static struct usb_driver streamzap_driver = { |
106 | .name = DRIVER_NAME, | |
107 | .probe = streamzap_probe, | |
108 | .disconnect = streamzap_disconnect, | |
109 | .suspend = streamzap_suspend, | |
110 | .resume = streamzap_resume, | |
111 | .id_table = streamzap_table, | |
112 | }; | |
113 | ||
7a569f52 | 114 | static void sz_push(struct streamzap_ir *sz, struct ir_raw_event rawir) |
19770693 | 115 | { |
1338c925 JW |
116 | dev_dbg(sz->dev, "Storing %s with duration %u us\n", |
117 | (rawir.pulse ? "pulse" : "space"), rawir.duration); | |
d8b4b582 | 118 | ir_raw_event_store_with_filter(sz->rdev, &rawir); |
19770693 JW |
119 | } |
120 | ||
8e9e6064 JW |
121 | static void sz_push_full_pulse(struct streamzap_ir *sz, |
122 | unsigned char value) | |
19770693 | 123 | { |
183e19f5 | 124 | struct ir_raw_event rawir = {}; |
7a569f52 | 125 | |
19770693 | 126 | if (sz->idle) { |
dd4c22a6 | 127 | int delta; |
19770693 JW |
128 | |
129 | sz->signal_last = sz->signal_start; | |
dd4c22a6 | 130 | sz->signal_start = ktime_get_real(); |
19770693 | 131 | |
dd4c22a6 | 132 | delta = ktime_us_delta(sz->signal_start, sz->signal_last); |
7a569f52 | 133 | rawir.pulse = false; |
dd4c22a6 | 134 | if (delta > (15 * USEC_PER_SEC)) { |
19770693 | 135 | /* really long time */ |
7a569f52 | 136 | rawir.duration = IR_MAX_DURATION; |
19770693 | 137 | } else { |
dd4c22a6 | 138 | rawir.duration = delta; |
7a569f52 | 139 | rawir.duration -= sz->sum; |
95cf60aa MCC |
140 | rawir.duration = (rawir.duration > IR_MAX_DURATION) ? |
141 | IR_MAX_DURATION : rawir.duration; | |
19770693 | 142 | } |
7a569f52 | 143 | sz_push(sz, rawir); |
19770693 | 144 | |
7a569f52 | 145 | sz->idle = false; |
19770693 JW |
146 | sz->sum = 0; |
147 | } | |
148 | ||
7a569f52 | 149 | rawir.pulse = true; |
b768d47e JW |
150 | rawir.duration = ((int) value) * SZ_RESOLUTION; |
151 | rawir.duration += SZ_RESOLUTION / 2; | |
7a569f52 | 152 | sz->sum += rawir.duration; |
95cf60aa MCC |
153 | rawir.duration = (rawir.duration > IR_MAX_DURATION) ? |
154 | IR_MAX_DURATION : rawir.duration; | |
7a569f52 | 155 | sz_push(sz, rawir); |
19770693 JW |
156 | } |
157 | ||
8e9e6064 JW |
158 | static void sz_push_half_pulse(struct streamzap_ir *sz, |
159 | unsigned char value) | |
19770693 | 160 | { |
b768d47e | 161 | sz_push_full_pulse(sz, (value & SZ_PULSE_MASK) >> 4); |
19770693 JW |
162 | } |
163 | ||
8e9e6064 JW |
164 | static void sz_push_full_space(struct streamzap_ir *sz, |
165 | unsigned char value) | |
19770693 | 166 | { |
183e19f5 | 167 | struct ir_raw_event rawir = {}; |
7a569f52 JW |
168 | |
169 | rawir.pulse = false; | |
b768d47e JW |
170 | rawir.duration = ((int) value) * SZ_RESOLUTION; |
171 | rawir.duration += SZ_RESOLUTION / 2; | |
7a569f52 | 172 | sz->sum += rawir.duration; |
7a569f52 | 173 | sz_push(sz, rawir); |
19770693 JW |
174 | } |
175 | ||
8e9e6064 JW |
176 | static void sz_push_half_space(struct streamzap_ir *sz, |
177 | unsigned long value) | |
19770693 | 178 | { |
b768d47e | 179 | sz_push_full_space(sz, value & SZ_SPACE_MASK); |
19770693 JW |
180 | } |
181 | ||
cba862dc | 182 | /* |
8e9e6064 | 183 | * streamzap_callback - usb IRQ handler callback |
19770693 JW |
184 | * |
185 | * This procedure is invoked on reception of data from | |
186 | * the usb remote. | |
187 | */ | |
8e9e6064 | 188 | static void streamzap_callback(struct urb *urb) |
19770693 | 189 | { |
8e9e6064 JW |
190 | struct streamzap_ir *sz; |
191 | unsigned int i; | |
192 | int len; | |
19770693 JW |
193 | |
194 | if (!urb) | |
195 | return; | |
196 | ||
197 | sz = urb->context; | |
198 | len = urb->actual_length; | |
199 | ||
200 | switch (urb->status) { | |
201 | case -ECONNRESET: | |
202 | case -ENOENT: | |
203 | case -ESHUTDOWN: | |
204 | /* | |
205 | * this urb is terminated, clean up. | |
206 | * sz might already be invalid at this point | |
207 | */ | |
8e9e6064 | 208 | dev_err(sz->dev, "urb terminated, status: %d\n", urb->status); |
19770693 JW |
209 | return; |
210 | default: | |
211 | break; | |
212 | } | |
213 | ||
8e9e6064 | 214 | dev_dbg(sz->dev, "%s: received urb, len %d\n", __func__, len); |
7a569f52 | 215 | for (i = 0; i < len; i++) { |
1338c925 | 216 | dev_dbg(sz->dev, "sz->buf_in[%d]: %x\n", |
7a569f52 JW |
217 | i, (unsigned char)sz->buf_in[i]); |
218 | switch (sz->decoder_state) { | |
219 | case PulseSpace: | |
b768d47e JW |
220 | if ((sz->buf_in[i] & SZ_PULSE_MASK) == |
221 | SZ_PULSE_MASK) { | |
7a569f52 JW |
222 | sz->decoder_state = FullPulse; |
223 | continue; | |
b768d47e JW |
224 | } else if ((sz->buf_in[i] & SZ_SPACE_MASK) |
225 | == SZ_SPACE_MASK) { | |
7a569f52 JW |
226 | sz_push_half_pulse(sz, sz->buf_in[i]); |
227 | sz->decoder_state = FullSpace; | |
228 | continue; | |
229 | } else { | |
230 | sz_push_half_pulse(sz, sz->buf_in[i]); | |
8e9e6064 | 231 | sz_push_half_space(sz, sz->buf_in[i]); |
19770693 | 232 | } |
7a569f52 JW |
233 | break; |
234 | case FullPulse: | |
235 | sz_push_full_pulse(sz, sz->buf_in[i]); | |
236 | sz->decoder_state = IgnorePulse; | |
237 | break; | |
238 | case FullSpace: | |
b768d47e | 239 | if (sz->buf_in[i] == SZ_TIMEOUT) { |
183e19f5 SY |
240 | struct ir_raw_event rawir = { |
241 | .pulse = false, | |
242 | .duration = sz->rdev->timeout | |
243 | }; | |
7a569f52 JW |
244 | sz->idle = true; |
245 | if (sz->timeout_enabled) | |
246 | sz_push(sz, rawir); | |
d8b4b582 | 247 | ir_raw_event_handle(sz->rdev); |
56b0ec30 | 248 | ir_raw_event_reset(sz->rdev); |
7a569f52 JW |
249 | } else { |
250 | sz_push_full_space(sz, sz->buf_in[i]); | |
251 | } | |
252 | sz->decoder_state = PulseSpace; | |
253 | break; | |
254 | case IgnorePulse: | |
b768d47e JW |
255 | if ((sz->buf_in[i] & SZ_SPACE_MASK) == |
256 | SZ_SPACE_MASK) { | |
7a569f52 JW |
257 | sz->decoder_state = FullSpace; |
258 | continue; | |
259 | } | |
260 | sz_push_half_space(sz, sz->buf_in[i]); | |
261 | sz->decoder_state = PulseSpace; | |
262 | break; | |
19770693 JW |
263 | } |
264 | } | |
265 | ||
56b0ec30 | 266 | ir_raw_event_handle(sz->rdev); |
19770693 | 267 | usb_submit_urb(urb, GFP_ATOMIC); |
19770693 JW |
268 | } |
269 | ||
d8b4b582 | 270 | static struct rc_dev *streamzap_init_rc_dev(struct streamzap_ir *sz) |
8e9e6064 | 271 | { |
d8b4b582 | 272 | struct rc_dev *rdev; |
8e9e6064 JW |
273 | struct device *dev = sz->dev; |
274 | int ret; | |
275 | ||
0f7499fd | 276 | rdev = rc_allocate_device(RC_DRIVER_IR_RAW); |
d8b4b582 DH |
277 | if (!rdev) { |
278 | dev_err(dev, "remote dev allocation failed\n"); | |
279 | goto out; | |
8e9e6064 JW |
280 | } |
281 | ||
25ec587c | 282 | snprintf(sz->name, sizeof(sz->name), "Streamzap PC Remote Infrared Receiver (%04x:%04x)", |
8e9e6064 JW |
283 | le16_to_cpu(sz->usbdev->descriptor.idVendor), |
284 | le16_to_cpu(sz->usbdev->descriptor.idProduct)); | |
8e9e6064 JW |
285 | usb_make_path(sz->usbdev, sz->phys, sizeof(sz->phys)); |
286 | strlcat(sz->phys, "/input0", sizeof(sz->phys)); | |
8e9e6064 | 287 | |
518f4b26 | 288 | rdev->device_name = sz->name; |
d8b4b582 | 289 | rdev->input_phys = sz->phys; |
5ad1a555 PB |
290 | usb_to_input_id(sz->usbdev, &rdev->input_id); |
291 | rdev->dev.parent = dev; | |
d8b4b582 | 292 | rdev->priv = sz; |
6d741bfe | 293 | rdev->allowed_protocols = RC_PROTO_BIT_ALL_IR_DECODER; |
d8b4b582 DH |
294 | rdev->driver_name = DRIVER_NAME; |
295 | rdev->map_name = RC_MAP_STREAMZAP; | |
635f76b2 | 296 | |
d8b4b582 | 297 | ret = rc_register_device(rdev); |
8e9e6064 JW |
298 | if (ret < 0) { |
299 | dev_err(dev, "remote input device register failed\n"); | |
d8b4b582 | 300 | goto out; |
8e9e6064 JW |
301 | } |
302 | ||
d8b4b582 | 303 | return rdev; |
8e9e6064 | 304 | |
d8b4b582 DH |
305 | out: |
306 | rc_free_device(rdev); | |
8e9e6064 JW |
307 | return NULL; |
308 | } | |
309 | ||
cba862dc | 310 | /* |
19770693 JW |
311 | * streamzap_probe |
312 | * | |
313 | * Called by usb-core to associated with a candidate device | |
314 | * On any failure the return value is the ERROR | |
315 | * On success return 0 | |
316 | */ | |
4c62e976 GKH |
317 | static int streamzap_probe(struct usb_interface *intf, |
318 | const struct usb_device_id *id) | |
19770693 | 319 | { |
8e9e6064 | 320 | struct usb_device *usbdev = interface_to_usbdev(intf); |
19770693 | 321 | struct usb_host_interface *iface_host; |
8e9e6064 | 322 | struct streamzap_ir *sz = NULL; |
19770693 JW |
323 | char buf[63], name[128] = ""; |
324 | int retval = -ENOMEM; | |
8e9e6064 | 325 | int pipe, maxp; |
19770693 JW |
326 | |
327 | /* Allocate space for device driver specific data */ | |
8e9e6064 JW |
328 | sz = kzalloc(sizeof(struct streamzap_ir), GFP_KERNEL); |
329 | if (!sz) | |
19770693 JW |
330 | return -ENOMEM; |
331 | ||
8e9e6064 JW |
332 | sz->usbdev = usbdev; |
333 | sz->interface = intf; | |
19770693 JW |
334 | |
335 | /* Check to ensure endpoint information matches requirements */ | |
8e9e6064 | 336 | iface_host = intf->cur_altsetting; |
19770693 JW |
337 | |
338 | if (iface_host->desc.bNumEndpoints != 1) { | |
8e9e6064 JW |
339 | dev_err(&intf->dev, "%s: Unexpected desc.bNumEndpoints (%d)\n", |
340 | __func__, iface_host->desc.bNumEndpoints); | |
19770693 JW |
341 | retval = -ENODEV; |
342 | goto free_sz; | |
343 | } | |
344 | ||
345 | sz->endpoint = &(iface_host->endpoint[0].desc); | |
5611588b | 346 | if (!usb_endpoint_dir_in(sz->endpoint)) { |
25ec587c MCC |
347 | dev_err(&intf->dev, "%s: endpoint doesn't match input device 02%02x\n", |
348 | __func__, sz->endpoint->bEndpointAddress); | |
19770693 JW |
349 | retval = -ENODEV; |
350 | goto free_sz; | |
351 | } | |
352 | ||
5611588b | 353 | if (!usb_endpoint_xfer_int(sz->endpoint)) { |
25ec587c MCC |
354 | dev_err(&intf->dev, "%s: endpoint attributes don't match xfer 02%02x\n", |
355 | __func__, sz->endpoint->bmAttributes); | |
19770693 JW |
356 | retval = -ENODEV; |
357 | goto free_sz; | |
358 | } | |
359 | ||
8e9e6064 JW |
360 | pipe = usb_rcvintpipe(usbdev, sz->endpoint->bEndpointAddress); |
361 | maxp = usb_maxpacket(usbdev, pipe, usb_pipeout(pipe)); | |
362 | ||
363 | if (maxp == 0) { | |
364 | dev_err(&intf->dev, "%s: endpoint Max Packet Size is 0!?!\n", | |
365 | __func__); | |
19770693 JW |
366 | retval = -ENODEV; |
367 | goto free_sz; | |
368 | } | |
369 | ||
370 | /* Allocate the USB buffer and IRQ URB */ | |
8e9e6064 JW |
371 | sz->buf_in = usb_alloc_coherent(usbdev, maxp, GFP_ATOMIC, &sz->dma_in); |
372 | if (!sz->buf_in) | |
19770693 JW |
373 | goto free_sz; |
374 | ||
375 | sz->urb_in = usb_alloc_urb(0, GFP_KERNEL); | |
8e9e6064 JW |
376 | if (!sz->urb_in) |
377 | goto free_buf_in; | |
19770693 | 378 | |
8e9e6064 JW |
379 | sz->dev = &intf->dev; |
380 | sz->buf_in_len = maxp; | |
19770693 | 381 | |
8e9e6064 JW |
382 | if (usbdev->descriptor.iManufacturer |
383 | && usb_string(usbdev, usbdev->descriptor.iManufacturer, | |
19770693 | 384 | buf, sizeof(buf)) > 0) |
c0decac1 | 385 | strscpy(name, buf, sizeof(name)); |
19770693 | 386 | |
8e9e6064 JW |
387 | if (usbdev->descriptor.iProduct |
388 | && usb_string(usbdev, usbdev->descriptor.iProduct, | |
19770693 JW |
389 | buf, sizeof(buf)) > 0) |
390 | snprintf(name + strlen(name), sizeof(name) - strlen(name), | |
391 | " %s", buf); | |
392 | ||
d8b4b582 DH |
393 | sz->rdev = streamzap_init_rc_dev(sz); |
394 | if (!sz->rdev) | |
395 | goto rc_dev_fail; | |
19770693 | 396 | |
8e9e6064 JW |
397 | sz->idle = true; |
398 | sz->decoder_state = PulseSpace; | |
7a569f52 JW |
399 | /* FIXME: don't yet have a way to set this */ |
400 | sz->timeout_enabled = true; | |
528222d8 | 401 | sz->rdev->timeout = SZ_TIMEOUT * SZ_RESOLUTION; |
8e9e6064 JW |
402 | #if 0 |
403 | /* not yet supported, depends on patches from maxim */ | |
404 | /* see also: LIRC_GET_REC_RESOLUTION and LIRC_SET_REC_TIMEOUT */ | |
528222d8 SY |
405 | sz->min_timeout = SZ_TIMEOUT * SZ_RESOLUTION; |
406 | sz->max_timeout = SZ_TIMEOUT * SZ_RESOLUTION; | |
8e9e6064 | 407 | #endif |
19770693 | 408 | |
dd4c22a6 | 409 | sz->signal_start = ktime_get_real(); |
19770693 | 410 | |
8e9e6064 JW |
411 | /* Complete final initialisations */ |
412 | usb_fill_int_urb(sz->urb_in, usbdev, pipe, sz->buf_in, | |
413 | maxp, (usb_complete_t)streamzap_callback, | |
414 | sz, sz->endpoint->bInterval); | |
415 | sz->urb_in->transfer_dma = sz->dma_in; | |
416 | sz->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; | |
19770693 | 417 | |
8e9e6064 | 418 | usb_set_intfdata(intf, sz); |
19770693 | 419 | |
7a569f52 JW |
420 | if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) |
421 | dev_err(sz->dev, "urb submit failed\n"); | |
19770693 | 422 | |
8e9e6064 JW |
423 | dev_info(sz->dev, "Registered %s on usb%d:%d\n", name, |
424 | usbdev->bus->busnum, usbdev->devnum); | |
19770693 | 425 | |
8e9e6064 | 426 | return 0; |
19770693 | 427 | |
d8b4b582 | 428 | rc_dev_fail: |
8e9e6064 JW |
429 | usb_free_urb(sz->urb_in); |
430 | free_buf_in: | |
431 | usb_free_coherent(usbdev, maxp, sz->buf_in, sz->dma_in); | |
432 | free_sz: | |
433 | kfree(sz); | |
19770693 | 434 | |
8e9e6064 | 435 | return retval; |
19770693 JW |
436 | } |
437 | ||
cba862dc | 438 | /* |
19770693 JW |
439 | * streamzap_disconnect |
440 | * | |
441 | * Called by the usb core when the device is removed from the system. | |
442 | * | |
443 | * This routine guarantees that the driver will not submit any more urbs | |
8e9e6064 | 444 | * by clearing dev->usbdev. It is also supposed to terminate any currently |
19770693 JW |
445 | * active urbs. Unfortunately, usb_bulk_msg(), used in streamzap_read(), |
446 | * does not provide any way to do this. | |
447 | */ | |
448 | static void streamzap_disconnect(struct usb_interface *interface) | |
449 | { | |
8e9e6064 JW |
450 | struct streamzap_ir *sz = usb_get_intfdata(interface); |
451 | struct usb_device *usbdev = interface_to_usbdev(interface); | |
19770693 | 452 | |
8e9e6064 | 453 | usb_set_intfdata(interface, NULL); |
19770693 | 454 | |
8e9e6064 JW |
455 | if (!sz) |
456 | return; | |
19770693 | 457 | |
8e9e6064 | 458 | sz->usbdev = NULL; |
d8b4b582 | 459 | rc_unregister_device(sz->rdev); |
8e9e6064 | 460 | usb_kill_urb(sz->urb_in); |
19770693 | 461 | usb_free_urb(sz->urb_in); |
8e9e6064 | 462 | usb_free_coherent(usbdev, sz->buf_in_len, sz->buf_in, sz->dma_in); |
19770693 | 463 | |
19770693 | 464 | kfree(sz); |
19770693 JW |
465 | } |
466 | ||
467 | static int streamzap_suspend(struct usb_interface *intf, pm_message_t message) | |
468 | { | |
8e9e6064 | 469 | struct streamzap_ir *sz = usb_get_intfdata(intf); |
19770693 | 470 | |
8e9e6064 | 471 | usb_kill_urb(sz->urb_in); |
19770693 | 472 | |
19770693 JW |
473 | return 0; |
474 | } | |
475 | ||
476 | static int streamzap_resume(struct usb_interface *intf) | |
477 | { | |
8e9e6064 | 478 | struct streamzap_ir *sz = usb_get_intfdata(intf); |
19770693 | 479 | |
8e9e6064 | 480 | if (usb_submit_urb(sz->urb_in, GFP_ATOMIC)) { |
1c195cb1 | 481 | dev_err(sz->dev, "Error submitting urb\n"); |
8e9e6064 | 482 | return -EIO; |
19770693 | 483 | } |
8e9e6064 | 484 | |
19770693 JW |
485 | return 0; |
486 | } | |
487 | ||
ecb3b2b3 | 488 | module_usb_driver(streamzap_driver); |
19770693 | 489 | |
8e9e6064 | 490 | MODULE_AUTHOR("Jarod Wilson <jarod@wilsonet.com>"); |
19770693 JW |
491 | MODULE_DESCRIPTION(DRIVER_DESC); |
492 | MODULE_LICENSE("GPL"); |