blob: 1e4c68a5cecfedfa24c2053dd1b67db88f83e5a3 [file] [log] [blame]
Sean Young26ff6312012-07-15 13:31:00 -03001/*
2 * IguanaWorks USB IR Transceiver support
3 *
4 * Copyright (C) 2012 Sean Young <sean@mess.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/device.h>
22#include <linux/kernel.h>
23#include <linux/module.h>
24#include <linux/usb.h>
25#include <linux/usb/input.h>
26#include <linux/slab.h>
27#include <linux/completion.h>
28#include <media/rc-core.h>
29
30#define DRIVER_NAME "iguanair"
31
32struct iguanair {
33 struct rc_dev *rc;
34
35 struct device *dev;
36 struct usb_device *udev;
37
Sean Younge99a7cf2012-08-13 08:59:39 -030038 int pipe_out;
Sean Young0797b482012-08-13 08:59:40 -030039 uint16_t version;
Sean Young26ff6312012-07-15 13:31:00 -030040 uint8_t bufsize;
Sean Young26ff6312012-07-15 13:31:00 -030041
42 struct mutex lock;
43
44 /* receiver support */
45 bool receiver_on;
46 dma_addr_t dma_in;
47 uint8_t *buf_in;
48 struct urb *urb_in;
49 struct completion completion;
50
51 /* transmit support */
52 bool tx_overflow;
53 uint32_t carrier;
54 uint8_t cycle_overhead;
55 uint8_t channels;
56 uint8_t busy4;
57 uint8_t busy7;
58
59 char name[64];
60 char phys[64];
61};
62
63#define CMD_GET_VERSION 0x01
64#define CMD_GET_BUFSIZE 0x11
65#define CMD_GET_FEATURES 0x10
66#define CMD_SEND 0x15
67#define CMD_EXECUTE 0x1f
68#define CMD_RX_OVERFLOW 0x31
69#define CMD_TX_OVERFLOW 0x32
70#define CMD_RECEIVER_ON 0x12
71#define CMD_RECEIVER_OFF 0x14
72
73#define DIR_IN 0xdc
74#define DIR_OUT 0xcd
75
76#define MAX_PACKET_SIZE 8u
77#define TIMEOUT 1000
Sean Young2eec6762012-08-13 08:59:41 -030078#define RX_RESOLUTION 21333
Sean Young26ff6312012-07-15 13:31:00 -030079
80struct packet {
81 uint16_t start;
82 uint8_t direction;
83 uint8_t cmd;
84};
85
Sean Young26ff6312012-07-15 13:31:00 -030086struct send_packet {
87 struct packet header;
88 uint8_t length;
89 uint8_t channels;
90 uint8_t busy7;
91 uint8_t busy4;
92 uint8_t payload[0];
93};
94
95static void process_ir_data(struct iguanair *ir, unsigned len)
96{
97 if (len >= 4 && ir->buf_in[0] == 0 && ir->buf_in[1] == 0) {
98 switch (ir->buf_in[3]) {
Sean Younge99a7cf2012-08-13 08:59:39 -030099 case CMD_GET_VERSION:
100 if (len == 6) {
Sean Young0797b482012-08-13 08:59:40 -0300101 ir->version = (ir->buf_in[5] << 8) |
102 ir->buf_in[4];
Sean Younge99a7cf2012-08-13 08:59:39 -0300103 complete(&ir->completion);
104 }
105 break;
106 case CMD_GET_BUFSIZE:
107 if (len >= 5) {
108 ir->bufsize = ir->buf_in[4];
109 complete(&ir->completion);
110 }
111 break;
112 case CMD_GET_FEATURES:
113 if (len > 5) {
Sean Young0797b482012-08-13 08:59:40 -0300114 ir->cycle_overhead = ir->buf_in[5];
Sean Younge99a7cf2012-08-13 08:59:39 -0300115 complete(&ir->completion);
116 }
117 break;
Sean Young26ff6312012-07-15 13:31:00 -0300118 case CMD_TX_OVERFLOW:
119 ir->tx_overflow = true;
120 case CMD_RECEIVER_OFF:
121 case CMD_RECEIVER_ON:
122 case CMD_SEND:
123 complete(&ir->completion);
124 break;
125 case CMD_RX_OVERFLOW:
126 dev_warn(ir->dev, "receive overflow\n");
Sean Young116e4f52012-08-13 08:59:44 -0300127 ir_raw_event_reset(ir->rc);
Sean Young26ff6312012-07-15 13:31:00 -0300128 break;
129 default:
130 dev_warn(ir->dev, "control code %02x received\n",
131 ir->buf_in[3]);
132 break;
133 }
134 } else if (len >= 7) {
135 DEFINE_IR_RAW_EVENT(rawir);
136 unsigned i;
Sean Youngb83bfd12012-08-13 08:59:47 -0300137 bool event = false;
Sean Young26ff6312012-07-15 13:31:00 -0300138
139 init_ir_raw_event(&rawir);
140
141 for (i = 0; i < 7; i++) {
142 if (ir->buf_in[i] == 0x80) {
143 rawir.pulse = false;
144 rawir.duration = US_TO_NS(21845);
145 } else {
146 rawir.pulse = (ir->buf_in[i] & 0x80) == 0;
147 rawir.duration = ((ir->buf_in[i] & 0x7f) + 1) *
Sean Young2eec6762012-08-13 08:59:41 -0300148 RX_RESOLUTION;
Sean Young26ff6312012-07-15 13:31:00 -0300149 }
150
Sean Youngb83bfd12012-08-13 08:59:47 -0300151 if (ir_raw_event_store_with_filter(ir->rc, &rawir))
152 event = true;
Sean Young26ff6312012-07-15 13:31:00 -0300153 }
154
Sean Youngb83bfd12012-08-13 08:59:47 -0300155 if (event)
156 ir_raw_event_handle(ir->rc);
Sean Young26ff6312012-07-15 13:31:00 -0300157 }
158}
159
160static void iguanair_rx(struct urb *urb)
161{
162 struct iguanair *ir;
Sean Young7c0bd962012-08-13 08:59:43 -0300163 int rc;
Sean Young26ff6312012-07-15 13:31:00 -0300164
165 if (!urb)
166 return;
167
168 ir = urb->context;
169 if (!ir) {
170 usb_unlink_urb(urb);
171 return;
172 }
173
174 switch (urb->status) {
175 case 0:
176 process_ir_data(ir, urb->actual_length);
177 break;
178 case -ECONNRESET:
179 case -ENOENT:
180 case -ESHUTDOWN:
181 usb_unlink_urb(urb);
182 return;
183 case -EPIPE:
184 default:
185 dev_dbg(ir->dev, "Error: urb status = %d\n", urb->status);
186 break;
187 }
188
Sean Young7c0bd962012-08-13 08:59:43 -0300189 rc = usb_submit_urb(urb, GFP_ATOMIC);
190 if (rc && rc != -ENODEV)
191 dev_warn(ir->dev, "failed to resubmit urb: %d\n", rc);
Sean Young26ff6312012-07-15 13:31:00 -0300192}
193
Sean Younge99a7cf2012-08-13 08:59:39 -0300194static int iguanair_send(struct iguanair *ir, void *data, unsigned size)
Sean Young26ff6312012-07-15 13:31:00 -0300195{
Sean Young26ff6312012-07-15 13:31:00 -0300196 int rc, transferred;
197
Sean Younge99a7cf2012-08-13 08:59:39 -0300198 INIT_COMPLETION(ir->completion);
Sean Young26ff6312012-07-15 13:31:00 -0300199
Sean Younge99a7cf2012-08-13 08:59:39 -0300200 rc = usb_interrupt_msg(ir->udev, ir->pipe_out, data, size,
201 &transferred, TIMEOUT);
202 if (rc)
203 return rc;
Sean Young26ff6312012-07-15 13:31:00 -0300204
Sean Younge99a7cf2012-08-13 08:59:39 -0300205 if (transferred != size)
206 return -EIO;
Sean Young26ff6312012-07-15 13:31:00 -0300207
Sean Younge99a7cf2012-08-13 08:59:39 -0300208 if (wait_for_completion_timeout(&ir->completion, TIMEOUT) == 0)
209 return -ETIMEDOUT;
Sean Young26ff6312012-07-15 13:31:00 -0300210
211 return rc;
212}
213
214static int iguanair_get_features(struct iguanair *ir)
215{
216 struct packet packet;
Sean Younge99a7cf2012-08-13 08:59:39 -0300217 int rc;
Sean Young26ff6312012-07-15 13:31:00 -0300218
219 packet.start = 0;
220 packet.direction = DIR_OUT;
221 packet.cmd = CMD_GET_VERSION;
222
Sean Younge99a7cf2012-08-13 08:59:39 -0300223 rc = iguanair_send(ir, &packet, sizeof(packet));
Sean Young26ff6312012-07-15 13:31:00 -0300224 if (rc) {
225 dev_info(ir->dev, "failed to get version\n");
226 goto out;
227 }
228
Sean Young0797b482012-08-13 08:59:40 -0300229 if (ir->version < 0x205) {
230 dev_err(ir->dev, "firmware 0x%04x is too old\n", ir->version);
231 rc = -ENODEV;
232 goto out;
233 }
234
Sean Young26ff6312012-07-15 13:31:00 -0300235 ir->bufsize = 150;
236 ir->cycle_overhead = 65;
237
238 packet.cmd = CMD_GET_BUFSIZE;
239
Sean Younge99a7cf2012-08-13 08:59:39 -0300240 rc = iguanair_send(ir, &packet, sizeof(packet));
Sean Young26ff6312012-07-15 13:31:00 -0300241 if (rc) {
242 dev_info(ir->dev, "failed to get buffer size\n");
243 goto out;
244 }
245
Sean Young26ff6312012-07-15 13:31:00 -0300246 packet.cmd = CMD_GET_FEATURES;
247
Sean Younge99a7cf2012-08-13 08:59:39 -0300248 rc = iguanair_send(ir, &packet, sizeof(packet));
Sean Young26ff6312012-07-15 13:31:00 -0300249 if (rc) {
250 dev_info(ir->dev, "failed to get features\n");
251 goto out;
252 }
253
Sean Young26ff6312012-07-15 13:31:00 -0300254out:
255 return rc;
256}
257
258static int iguanair_receiver(struct iguanair *ir, bool enable)
259{
260 struct packet packet = { 0, DIR_OUT, enable ?
261 CMD_RECEIVER_ON : CMD_RECEIVER_OFF };
Sean Young26ff6312012-07-15 13:31:00 -0300262
Sean Young116e4f52012-08-13 08:59:44 -0300263 if (enable)
264 ir_raw_event_reset(ir->rc);
265
Sean Younge99a7cf2012-08-13 08:59:39 -0300266 return iguanair_send(ir, &packet, sizeof(packet));
Sean Young26ff6312012-07-15 13:31:00 -0300267}
268
269/*
270 * The iguana ir creates the carrier by busy spinning after each pulse or
271 * space. This is counted in CPU cycles, with the CPU running at 24MHz. It is
272 * broken down into 7-cycles and 4-cyles delays, with a preference for
273 * 4-cycle delays.
274 */
275static int iguanair_set_tx_carrier(struct rc_dev *dev, uint32_t carrier)
276{
277 struct iguanair *ir = dev->priv;
278
279 if (carrier < 25000 || carrier > 150000)
280 return -EINVAL;
281
282 mutex_lock(&ir->lock);
283
284 if (carrier != ir->carrier) {
285 uint32_t cycles, fours, sevens;
286
287 ir->carrier = carrier;
288
289 cycles = DIV_ROUND_CLOSEST(24000000, carrier * 2) -
290 ir->cycle_overhead;
291
292 /* make up the the remainer of 4-cycle blocks */
293 switch (cycles & 3) {
294 case 0:
295 sevens = 0;
296 break;
297 case 1:
298 sevens = 3;
299 break;
300 case 2:
301 sevens = 2;
302 break;
303 case 3:
304 sevens = 1;
305 break;
306 }
307
308 fours = (cycles - sevens * 7) / 4;
309
310 /* magic happens here */
311 ir->busy7 = (4 - sevens) * 2;
312 ir->busy4 = 110 - fours;
313 }
314
315 mutex_unlock(&ir->lock);
316
317 return carrier;
318}
319
320static int iguanair_set_tx_mask(struct rc_dev *dev, uint32_t mask)
321{
322 struct iguanair *ir = dev->priv;
323
324 if (mask > 15)
325 return 4;
326
327 mutex_lock(&ir->lock);
328 ir->channels = mask;
329 mutex_unlock(&ir->lock);
330
331 return 0;
332}
333
334static int iguanair_tx(struct rc_dev *dev, unsigned *txbuf, unsigned count)
335{
336 struct iguanair *ir = dev->priv;
Sean Young39206312012-08-25 07:01:45 -0300337 uint8_t space;
338 unsigned i, size, periods, bytes;
339 int rc;
Sean Young26ff6312012-07-15 13:31:00 -0300340 struct send_packet *packet;
341
342 mutex_lock(&ir->lock);
343
Sean Young39206312012-08-25 07:01:45 -0300344 packet = kmalloc(sizeof(*packet) + ir->bufsize, GFP_KERNEL);
345 if (!packet) {
346 rc = -ENOMEM;
347 goto out;
348 }
349
Sean Young26ff6312012-07-15 13:31:00 -0300350 /* convert from us to carrier periods */
Sean Young39206312012-08-25 07:01:45 -0300351 for (i = space = size = 0; i < count; i++) {
352 periods = DIV_ROUND_CLOSEST(txbuf[i] * ir->carrier, 1000000);
353 bytes = DIV_ROUND_UP(periods, 127);
Sean Young884bfd02012-08-13 08:59:42 -0300354 if (size + bytes > ir->bufsize) {
355 count = i;
356 break;
357 }
Sean Young39206312012-08-25 07:01:45 -0300358 while (periods > 127) {
359 packet->payload[size++] = 127 | space;
360 periods -= 127;
361 }
362
363 packet->payload[size++] = periods | space;
364 space ^= 0x80;
Sean Young884bfd02012-08-13 08:59:42 -0300365 }
366
367 if (count == 0) {
368 rc = -EINVAL;
369 goto out;
Sean Young26ff6312012-07-15 13:31:00 -0300370 }
371
Sean Young26ff6312012-07-15 13:31:00 -0300372 packet->header.start = 0;
373 packet->header.direction = DIR_OUT;
374 packet->header.cmd = CMD_SEND;
375 packet->length = size;
376 packet->channels = ir->channels << 4;
377 packet->busy7 = ir->busy7;
378 packet->busy4 = ir->busy4;
379
Sean Young26ff6312012-07-15 13:31:00 -0300380 if (ir->receiver_on) {
381 rc = iguanair_receiver(ir, false);
382 if (rc) {
383 dev_warn(ir->dev, "disable receiver before transmit failed\n");
Sean Young39206312012-08-25 07:01:45 -0300384 goto out;
Sean Young26ff6312012-07-15 13:31:00 -0300385 }
386 }
387
388 ir->tx_overflow = false;
389
Sean Younge99a7cf2012-08-13 08:59:39 -0300390 rc = iguanair_send(ir, packet, size + 8);
Sean Young26ff6312012-07-15 13:31:00 -0300391
Sean Younge99a7cf2012-08-13 08:59:39 -0300392 if (rc == 0 && ir->tx_overflow)
393 rc = -EOVERFLOW;
Sean Young26ff6312012-07-15 13:31:00 -0300394
395 if (ir->receiver_on) {
396 if (iguanair_receiver(ir, true))
397 dev_warn(ir->dev, "re-enable receiver after transmit failed\n");
398 }
399
400out:
Sean Young39206312012-08-25 07:01:45 -0300401 kfree(packet);
Sean Young26ff6312012-07-15 13:31:00 -0300402 mutex_unlock(&ir->lock);
Sean Young26ff6312012-07-15 13:31:00 -0300403
Sean Young884bfd02012-08-13 08:59:42 -0300404 return rc ? rc : count;
Sean Young26ff6312012-07-15 13:31:00 -0300405}
406
407static int iguanair_open(struct rc_dev *rdev)
408{
409 struct iguanair *ir = rdev->priv;
410 int rc;
411
412 mutex_lock(&ir->lock);
413
Sean Young26ff6312012-07-15 13:31:00 -0300414 BUG_ON(ir->receiver_on);
415
416 rc = iguanair_receiver(ir, true);
417 if (rc == 0)
418 ir->receiver_on = true;
419
420 mutex_unlock(&ir->lock);
421
422 return rc;
423}
424
425static void iguanair_close(struct rc_dev *rdev)
426{
427 struct iguanair *ir = rdev->priv;
428 int rc;
429
430 mutex_lock(&ir->lock);
431
432 rc = iguanair_receiver(ir, false);
433 ir->receiver_on = false;
Sean Young7c0bd962012-08-13 08:59:43 -0300434 if (rc && rc != -ENODEV)
Sean Young26ff6312012-07-15 13:31:00 -0300435 dev_warn(ir->dev, "failed to disable receiver: %d\n", rc);
436
Sean Young26ff6312012-07-15 13:31:00 -0300437 mutex_unlock(&ir->lock);
438}
439
440static int __devinit iguanair_probe(struct usb_interface *intf,
441 const struct usb_device_id *id)
442{
443 struct usb_device *udev = interface_to_usbdev(intf);
444 struct iguanair *ir;
445 struct rc_dev *rc;
Sean Younge99a7cf2012-08-13 08:59:39 -0300446 int ret, pipein;
Sean Young26ff6312012-07-15 13:31:00 -0300447 struct usb_host_interface *idesc;
448
449 ir = kzalloc(sizeof(*ir), GFP_KERNEL);
450 rc = rc_allocate_device();
451 if (!ir || !rc) {
Sean Young884bfd02012-08-13 08:59:42 -0300452 ret = -ENOMEM;
Sean Young26ff6312012-07-15 13:31:00 -0300453 goto out;
454 }
455
Sean Younge99a7cf2012-08-13 08:59:39 -0300456 ir->buf_in = usb_alloc_coherent(udev, MAX_PACKET_SIZE, GFP_KERNEL,
Sean Young26ff6312012-07-15 13:31:00 -0300457 &ir->dma_in);
458 ir->urb_in = usb_alloc_urb(0, GFP_KERNEL);
459
460 if (!ir->buf_in || !ir->urb_in) {
Sean Young884bfd02012-08-13 08:59:42 -0300461 ret = -ENOMEM;
Sean Young26ff6312012-07-15 13:31:00 -0300462 goto out;
463 }
464
465 idesc = intf->altsetting;
466
467 if (idesc->desc.bNumEndpoints < 2) {
468 ret = -ENODEV;
469 goto out;
470 }
471
472 ir->rc = rc;
473 ir->dev = &intf->dev;
474 ir->udev = udev;
Sean Young26ff6312012-07-15 13:31:00 -0300475 ir->pipe_out = usb_sndintpipe(udev,
476 idesc->endpoint[1].desc.bEndpointAddress);
477 mutex_init(&ir->lock);
478 init_completion(&ir->completion);
479
Sean Younge99a7cf2012-08-13 08:59:39 -0300480 pipein = usb_rcvintpipe(udev, idesc->endpoint[0].desc.bEndpointAddress);
Sean Young64058382012-08-13 08:59:45 -0300481 usb_fill_int_urb(ir->urb_in, udev, pipein, ir->buf_in, MAX_PACKET_SIZE,
482 iguanair_rx, ir, 1);
Sean Young26ff6312012-07-15 13:31:00 -0300483 ir->urb_in->transfer_dma = ir->dma_in;
484 ir->urb_in->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
485
Sean Younge99a7cf2012-08-13 08:59:39 -0300486 ret = usb_submit_urb(ir->urb_in, GFP_KERNEL);
487 if (ret) {
488 dev_warn(&intf->dev, "failed to submit urb: %d\n", ret);
489 goto out;
490 }
491
492 ret = iguanair_get_features(ir);
493 if (ret)
494 goto out2;
495
Sean Young26ff6312012-07-15 13:31:00 -0300496 snprintf(ir->name, sizeof(ir->name),
Sean Young0797b482012-08-13 08:59:40 -0300497 "IguanaWorks USB IR Transceiver version 0x%04x", ir->version);
Sean Young26ff6312012-07-15 13:31:00 -0300498
499 usb_make_path(ir->udev, ir->phys, sizeof(ir->phys));
500
501 rc->input_name = ir->name;
502 rc->input_phys = ir->phys;
503 usb_to_input_id(ir->udev, &rc->input_id);
504 rc->dev.parent = &intf->dev;
505 rc->driver_type = RC_DRIVER_IR_RAW;
506 rc->allowed_protos = RC_TYPE_ALL;
507 rc->priv = ir;
508 rc->open = iguanair_open;
509 rc->close = iguanair_close;
510 rc->s_tx_mask = iguanair_set_tx_mask;
511 rc->s_tx_carrier = iguanair_set_tx_carrier;
512 rc->tx_ir = iguanair_tx;
513 rc->driver_name = DRIVER_NAME;
Sean Young2eec6762012-08-13 08:59:41 -0300514 rc->map_name = RC_MAP_RC6_MCE;
515 rc->timeout = MS_TO_NS(100);
516 rc->rx_resolution = RX_RESOLUTION;
Sean Young26ff6312012-07-15 13:31:00 -0300517
518 iguanair_set_tx_carrier(rc, 38000);
519
520 ret = rc_register_device(rc);
521 if (ret < 0) {
522 dev_err(&intf->dev, "failed to register rc device %d", ret);
Sean Younge99a7cf2012-08-13 08:59:39 -0300523 goto out2;
Sean Young26ff6312012-07-15 13:31:00 -0300524 }
525
526 usb_set_intfdata(intf, ir);
527
Sean Young26ff6312012-07-15 13:31:00 -0300528 return 0;
Sean Younge99a7cf2012-08-13 08:59:39 -0300529out2:
530 usb_kill_urb(ir->urb_in);
Sean Young26ff6312012-07-15 13:31:00 -0300531out:
532 if (ir) {
533 usb_free_urb(ir->urb_in);
534 usb_free_coherent(udev, MAX_PACKET_SIZE, ir->buf_in,
535 ir->dma_in);
536 }
537 rc_free_device(rc);
538 kfree(ir);
539 return ret;
540}
541
542static void __devexit iguanair_disconnect(struct usb_interface *intf)
543{
544 struct iguanair *ir = usb_get_intfdata(intf);
545
Sean Young7c0bd962012-08-13 08:59:43 -0300546 rc_unregister_device(ir->rc);
Sean Young26ff6312012-07-15 13:31:00 -0300547 usb_set_intfdata(intf, NULL);
Sean Young26ff6312012-07-15 13:31:00 -0300548 usb_kill_urb(ir->urb_in);
549 usb_free_urb(ir->urb_in);
550 usb_free_coherent(ir->udev, MAX_PACKET_SIZE, ir->buf_in, ir->dma_in);
Sean Young26ff6312012-07-15 13:31:00 -0300551 kfree(ir);
552}
553
554static int iguanair_suspend(struct usb_interface *intf, pm_message_t message)
555{
556 struct iguanair *ir = usb_get_intfdata(intf);
557 int rc = 0;
558
559 mutex_lock(&ir->lock);
560
561 if (ir->receiver_on) {
562 rc = iguanair_receiver(ir, false);
563 if (rc)
564 dev_warn(ir->dev, "failed to disable receiver for suspend\n");
565 }
566
Sean Young7c0bd962012-08-13 08:59:43 -0300567 usb_kill_urb(ir->urb_in);
568
Sean Young26ff6312012-07-15 13:31:00 -0300569 mutex_unlock(&ir->lock);
570
571 return rc;
572}
573
574static int iguanair_resume(struct usb_interface *intf)
575{
576 struct iguanair *ir = usb_get_intfdata(intf);
577 int rc = 0;
578
579 mutex_lock(&ir->lock);
580
Sean Young7c0bd962012-08-13 08:59:43 -0300581 rc = usb_submit_urb(ir->urb_in, GFP_KERNEL);
582 if (rc)
583 dev_warn(&intf->dev, "failed to submit urb: %d\n", rc);
584
Sean Young26ff6312012-07-15 13:31:00 -0300585 if (ir->receiver_on) {
586 rc = iguanair_receiver(ir, true);
587 if (rc)
588 dev_warn(ir->dev, "failed to enable receiver after resume\n");
589 }
590
591 mutex_unlock(&ir->lock);
592
593 return rc;
594}
595
596static const struct usb_device_id iguanair_table[] = {
597 { USB_DEVICE(0x1781, 0x0938) },
598 { }
599};
600
601static struct usb_driver iguanair_driver = {
602 .name = DRIVER_NAME,
603 .probe = iguanair_probe,
604 .disconnect = __devexit_p(iguanair_disconnect),
605 .suspend = iguanair_suspend,
606 .resume = iguanair_resume,
607 .reset_resume = iguanair_resume,
Sean Young7c0bd962012-08-13 08:59:43 -0300608 .id_table = iguanair_table,
609 .soft_unbind = 1 /* we want to disable receiver on unbind */
Sean Young26ff6312012-07-15 13:31:00 -0300610};
611
612module_usb_driver(iguanair_driver);
613
614MODULE_DESCRIPTION("IguanaWorks USB IR Transceiver");
615MODULE_AUTHOR("Sean Young <sean@mess.org>");
616MODULE_LICENSE("GPL");
617MODULE_DEVICE_TABLE(usb, iguanair_table);
618