2 * ati_remote2 - ATI/Philips USB RF remote driver
4 * Copyright (C) 2005-2008 Ville Syrjala <syrjala@sci.fi>
5 * Copyright (C) 2007-2008 Peter Stokes <linux@dadeos.co.uk>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
12 #include <linux/usb/input.h>
13 #include <linux/slab.h>
15 #define DRIVER_DESC "ATI/Philips USB RF remote driver"
16 #define DRIVER_VERSION "0.3"
18 MODULE_DESCRIPTION(DRIVER_DESC);
19 MODULE_VERSION(DRIVER_VERSION);
20 MODULE_AUTHOR("Ville Syrjala <syrjala@sci.fi>");
21 MODULE_LICENSE("GPL");
24 * ATI Remote Wonder II Channel Configuration
26 * The remote control can by assigned one of sixteen "channels" in order to facilitate
27 * the use of multiple remote controls within range of each other.
28 * A remote's "channel" may be altered by pressing and holding the "PC" button for
29 * approximately 3 seconds, after which the button will slowly flash the count of the
30 * currently configured "channel", using the numeric keypad enter a number between 1 and
31 * 16 and then press the "PC" button again, the button will slowly flash the count of the
32 * newly configured "channel".
36 ATI_REMOTE2_MAX_CHANNEL_MASK = 0xFFFF,
37 ATI_REMOTE2_MAX_MODE_MASK = 0x1F,
40 static int ati_remote2_set_mask(const char *val,
41 struct kernel_param *kp, unsigned int max)
49 ret = strict_strtoul(val, 0, &mask);
56 *(unsigned int *)kp->arg = mask;
61 static int ati_remote2_set_channel_mask(const char *val,
62 struct kernel_param *kp)
64 pr_debug("%s()\n", __func__);
66 return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_CHANNEL_MASK);
69 static int ati_remote2_get_channel_mask(char *buffer, struct kernel_param *kp)
71 pr_debug("%s()\n", __func__);
73 return sprintf(buffer, "0x%04x", *(unsigned int *)kp->arg);
76 static int ati_remote2_set_mode_mask(const char *val, struct kernel_param *kp)
78 pr_debug("%s()\n", __func__);
80 return ati_remote2_set_mask(val, kp, ATI_REMOTE2_MAX_MODE_MASK);
83 static int ati_remote2_get_mode_mask(char *buffer, struct kernel_param *kp)
85 pr_debug("%s()\n", __func__);
87 return sprintf(buffer, "0x%02x", *(unsigned int *)kp->arg);
90 static unsigned int channel_mask = ATI_REMOTE2_MAX_CHANNEL_MASK;
91 #define param_check_channel_mask(name, p) __param_check(name, p, unsigned int)
92 #define param_set_channel_mask ati_remote2_set_channel_mask
93 #define param_get_channel_mask ati_remote2_get_channel_mask
94 module_param(channel_mask, channel_mask, 0644);
95 MODULE_PARM_DESC(channel_mask, "Bitmask of channels to accept <15:Channel16>...<1:Channel2><0:Channel1>");
97 static unsigned int mode_mask = ATI_REMOTE2_MAX_MODE_MASK;
98 #define param_check_mode_mask(name, p) __param_check(name, p, unsigned int)
99 #define param_set_mode_mask ati_remote2_set_mode_mask
100 #define param_get_mode_mask ati_remote2_get_mode_mask
101 module_param(mode_mask, mode_mask, 0644);
102 MODULE_PARM_DESC(mode_mask, "Bitmask of modes to accept <4:PC><3:AUX4><2:AUX3><1:AUX2><0:AUX1>");
104 static struct usb_device_id ati_remote2_id_table[] = {
105 { USB_DEVICE(0x0471, 0x0602) }, /* ATI Remote Wonder II */
108 MODULE_DEVICE_TABLE(usb, ati_remote2_id_table);
110 static DEFINE_MUTEX(ati_remote2_mutex);
113 ATI_REMOTE2_OPENED = 0x1,
114 ATI_REMOTE2_SUSPENDED = 0x2,
126 static const struct {
129 } ati_remote2_key_table[] = {
142 { 0x10, KEY_VOLUMEUP },
143 { 0x11, KEY_VOLUMEDOWN },
144 { 0x20, KEY_CHANNELUP },
145 { 0x21, KEY_CHANNELDOWN },
146 { 0x28, KEY_FORWARD },
147 { 0x29, KEY_REWIND },
151 { 0x37, KEY_RECORD },
154 { 0x3f, KEY_PROG1 }, /* AUX1-AUX4 and PC */
168 { 0x8e, KEY_VENDOR },
169 { 0x96, KEY_COFFEE },
172 { 0xbe, KEY_QUESTION },
179 struct input_dev *idev;
180 struct usb_device *udev;
182 struct usb_interface *intf[2];
183 struct usb_endpoint_descriptor *ep[2];
186 dma_addr_t buf_dma[2];
188 unsigned long jiffies;
194 /* Each mode (AUX1-AUX4 and PC) can have an independent keymap. */
195 u16 keycode[ATI_REMOTE2_MODES][ARRAY_SIZE(ati_remote2_key_table)];
199 unsigned int channel_mask;
200 unsigned int mode_mask;
203 static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id);
204 static void ati_remote2_disconnect(struct usb_interface *interface);
205 static int ati_remote2_suspend(struct usb_interface *interface, pm_message_t message);
206 static int ati_remote2_resume(struct usb_interface *interface);
207 static int ati_remote2_reset_resume(struct usb_interface *interface);
208 static int ati_remote2_pre_reset(struct usb_interface *interface);
209 static int ati_remote2_post_reset(struct usb_interface *interface);
211 static struct usb_driver ati_remote2_driver = {
212 .name = "ati_remote2",
213 .probe = ati_remote2_probe,
214 .disconnect = ati_remote2_disconnect,
215 .id_table = ati_remote2_id_table,
216 .suspend = ati_remote2_suspend,
217 .resume = ati_remote2_resume,
218 .reset_resume = ati_remote2_reset_resume,
219 .pre_reset = ati_remote2_pre_reset,
220 .post_reset = ati_remote2_post_reset,
221 .supports_autosuspend = 1,
224 static int ati_remote2_submit_urbs(struct ati_remote2 *ar2)
228 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL);
230 dev_err(&ar2->intf[0]->dev,
231 "%s(): usb_submit_urb() = %d\n", __func__, r);
234 r = usb_submit_urb(ar2->urb[1], GFP_KERNEL);
236 usb_kill_urb(ar2->urb[0]);
237 dev_err(&ar2->intf[1]->dev,
238 "%s(): usb_submit_urb() = %d\n", __func__, r);
245 static void ati_remote2_kill_urbs(struct ati_remote2 *ar2)
247 usb_kill_urb(ar2->urb[1]);
248 usb_kill_urb(ar2->urb[0]);
251 static int ati_remote2_open(struct input_dev *idev)
253 struct ati_remote2 *ar2 = input_get_drvdata(idev);
256 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
258 r = usb_autopm_get_interface(ar2->intf[0]);
260 dev_err(&ar2->intf[0]->dev,
261 "%s(): usb_autopm_get_interface() = %d\n", __func__, r);
265 mutex_lock(&ati_remote2_mutex);
267 if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) {
268 r = ati_remote2_submit_urbs(ar2);
273 ar2->flags |= ATI_REMOTE2_OPENED;
275 mutex_unlock(&ati_remote2_mutex);
277 usb_autopm_put_interface(ar2->intf[0]);
282 mutex_unlock(&ati_remote2_mutex);
283 usb_autopm_put_interface(ar2->intf[0]);
288 static void ati_remote2_close(struct input_dev *idev)
290 struct ati_remote2 *ar2 = input_get_drvdata(idev);
292 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
294 mutex_lock(&ati_remote2_mutex);
296 if (!(ar2->flags & ATI_REMOTE2_SUSPENDED))
297 ati_remote2_kill_urbs(ar2);
299 ar2->flags &= ~ATI_REMOTE2_OPENED;
301 mutex_unlock(&ati_remote2_mutex);
304 static void ati_remote2_input_mouse(struct ati_remote2 *ar2)
306 struct input_dev *idev = ar2->idev;
307 u8 *data = ar2->buf[0];
310 channel = data[0] >> 4;
312 if (!((1 << channel) & ar2->channel_mask))
315 mode = data[0] & 0x0F;
317 if (mode > ATI_REMOTE2_PC) {
318 dev_err(&ar2->intf[0]->dev,
319 "Unknown mode byte (%02x %02x %02x %02x)\n",
320 data[3], data[2], data[1], data[0]);
324 if (!((1 << mode) & ar2->mode_mask))
327 input_event(idev, EV_REL, REL_X, (s8) data[1]);
328 input_event(idev, EV_REL, REL_Y, (s8) data[2]);
332 static int ati_remote2_lookup(unsigned int hw_code)
336 for (i = 0; i < ARRAY_SIZE(ati_remote2_key_table); i++)
337 if (ati_remote2_key_table[i].hw_code == hw_code)
343 static void ati_remote2_input_key(struct ati_remote2 *ar2)
345 struct input_dev *idev = ar2->idev;
346 u8 *data = ar2->buf[1];
347 int channel, mode, hw_code, index;
349 channel = data[0] >> 4;
351 if (!((1 << channel) & ar2->channel_mask))
354 mode = data[0] & 0x0F;
356 if (mode > ATI_REMOTE2_PC) {
357 dev_err(&ar2->intf[1]->dev,
358 "Unknown mode byte (%02x %02x %02x %02x)\n",
359 data[3], data[2], data[1], data[0]);
364 if (hw_code == 0x3f) {
366 * For some incomprehensible reason the mouse pad generates
367 * events which look identical to the events from the last
368 * pressed mode key. Naturally we don't want to generate key
369 * events for the mouse pad so we filter out any subsequent
370 * events from the same mode key.
372 if (ar2->mode == mode)
379 if (!((1 << mode) & ar2->mode_mask))
382 index = ati_remote2_lookup(hw_code);
384 dev_err(&ar2->intf[1]->dev,
385 "Unknown code byte (%02x %02x %02x %02x)\n",
386 data[3], data[2], data[1], data[0]);
391 case 0: /* release */
394 ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_DELAY]);
398 /* No repeat for mouse buttons. */
399 if (ar2->keycode[mode][index] == BTN_LEFT ||
400 ar2->keycode[mode][index] == BTN_RIGHT)
403 if (!time_after_eq(jiffies, ar2->jiffies))
406 ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_PERIOD]);
409 dev_err(&ar2->intf[1]->dev,
410 "Unknown state byte (%02x %02x %02x %02x)\n",
411 data[3], data[2], data[1], data[0]);
415 input_event(idev, EV_KEY, ar2->keycode[mode][index], data[1]);
419 static void ati_remote2_complete_mouse(struct urb *urb)
421 struct ati_remote2 *ar2 = urb->context;
424 switch (urb->status) {
426 usb_mark_last_busy(ar2->udev);
427 ati_remote2_input_mouse(ar2);
433 dev_dbg(&ar2->intf[0]->dev,
434 "%s(): urb status = %d\n", __func__, urb->status);
437 usb_mark_last_busy(ar2->udev);
438 dev_err(&ar2->intf[0]->dev,
439 "%s(): urb status = %d\n", __func__, urb->status);
442 r = usb_submit_urb(urb, GFP_ATOMIC);
444 dev_err(&ar2->intf[0]->dev,
445 "%s(): usb_submit_urb() = %d\n", __func__, r);
448 static void ati_remote2_complete_key(struct urb *urb)
450 struct ati_remote2 *ar2 = urb->context;
453 switch (urb->status) {
455 usb_mark_last_busy(ar2->udev);
456 ati_remote2_input_key(ar2);
462 dev_dbg(&ar2->intf[1]->dev,
463 "%s(): urb status = %d\n", __func__, urb->status);
466 usb_mark_last_busy(ar2->udev);
467 dev_err(&ar2->intf[1]->dev,
468 "%s(): urb status = %d\n", __func__, urb->status);
471 r = usb_submit_urb(urb, GFP_ATOMIC);
473 dev_err(&ar2->intf[1]->dev,
474 "%s(): usb_submit_urb() = %d\n", __func__, r);
477 static int ati_remote2_getkeycode(struct input_dev *idev,
478 unsigned int scancode, unsigned int *keycode)
480 struct ati_remote2 *ar2 = input_get_drvdata(idev);
484 mode = scancode >> 8;
485 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
488 index = ati_remote2_lookup(scancode & 0xFF);
492 *keycode = ar2->keycode[mode][index];
496 static int ati_remote2_setkeycode(struct input_dev *idev,
497 unsigned int scancode, unsigned int keycode)
499 struct ati_remote2 *ar2 = input_get_drvdata(idev);
500 unsigned int mode, old_keycode;
503 mode = scancode >> 8;
504 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
507 index = ati_remote2_lookup(scancode & 0xFF);
511 old_keycode = ar2->keycode[mode][index];
512 ar2->keycode[mode][index] = keycode;
513 __set_bit(keycode, idev->keybit);
515 for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
516 for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
517 if (ar2->keycode[mode][index] == old_keycode)
522 __clear_bit(old_keycode, idev->keybit);
527 static int ati_remote2_input_init(struct ati_remote2 *ar2)
529 struct input_dev *idev;
530 int index, mode, retval;
532 idev = input_allocate_device();
537 input_set_drvdata(idev, ar2);
539 idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_REL);
540 idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) |
542 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y);
544 for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) {
545 for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) {
546 ar2->keycode[mode][index] = ati_remote2_key_table[index].keycode;
547 __set_bit(ar2->keycode[mode][index], idev->keybit);
551 /* AUX1-AUX4 and PC generate the same scancode. */
552 index = ati_remote2_lookup(0x3f);
553 ar2->keycode[ATI_REMOTE2_AUX1][index] = KEY_PROG1;
554 ar2->keycode[ATI_REMOTE2_AUX2][index] = KEY_PROG2;
555 ar2->keycode[ATI_REMOTE2_AUX3][index] = KEY_PROG3;
556 ar2->keycode[ATI_REMOTE2_AUX4][index] = KEY_PROG4;
557 ar2->keycode[ATI_REMOTE2_PC][index] = KEY_PC;
558 __set_bit(KEY_PROG1, idev->keybit);
559 __set_bit(KEY_PROG2, idev->keybit);
560 __set_bit(KEY_PROG3, idev->keybit);
561 __set_bit(KEY_PROG4, idev->keybit);
562 __set_bit(KEY_PC, idev->keybit);
564 idev->rep[REP_DELAY] = 250;
565 idev->rep[REP_PERIOD] = 33;
567 idev->open = ati_remote2_open;
568 idev->close = ati_remote2_close;
570 idev->getkeycode = ati_remote2_getkeycode;
571 idev->setkeycode = ati_remote2_setkeycode;
573 idev->name = ar2->name;
574 idev->phys = ar2->phys;
576 usb_to_input_id(ar2->udev, &idev->id);
577 idev->dev.parent = &ar2->udev->dev;
579 retval = input_register_device(idev);
581 input_free_device(idev);
586 static int ati_remote2_urb_init(struct ati_remote2 *ar2)
588 struct usb_device *udev = ar2->udev;
591 for (i = 0; i < 2; i++) {
592 ar2->buf[i] = usb_alloc_coherent(udev, 4, GFP_KERNEL, &ar2->buf_dma[i]);
596 ar2->urb[i] = usb_alloc_urb(0, GFP_KERNEL);
600 pipe = usb_rcvintpipe(udev, ar2->ep[i]->bEndpointAddress);
601 maxp = usb_maxpacket(udev, pipe, usb_pipeout(pipe));
602 maxp = maxp > 4 ? 4 : maxp;
604 usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp,
605 i ? ati_remote2_complete_key : ati_remote2_complete_mouse,
606 ar2, ar2->ep[i]->bInterval);
607 ar2->urb[i]->transfer_dma = ar2->buf_dma[i];
608 ar2->urb[i]->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
614 static void ati_remote2_urb_cleanup(struct ati_remote2 *ar2)
618 for (i = 0; i < 2; i++) {
619 usb_free_urb(ar2->urb[i]);
620 usb_free_coherent(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]);
624 static int ati_remote2_setup(struct ati_remote2 *ar2, unsigned int ch_mask)
629 * Configure receiver to only accept input from remote "channel"
630 * channel == 0 -> Accept input from any remote channel
631 * channel == 1 -> Only accept input from remote channel 1
632 * channel == 2 -> Only accept input from remote channel 2
634 * channel == 16 -> Only accept input from remote channel 16
638 for (i = 0; i < 16; i++) {
639 if ((1 << i) & ch_mask) {
640 if (!(~(1 << i) & ch_mask))
646 r = usb_control_msg(ar2->udev, usb_sndctrlpipe(ar2->udev, 0),
648 USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_INTERFACE,
649 channel, 0x0, NULL, 0, USB_CTRL_SET_TIMEOUT);
651 dev_err(&ar2->udev->dev, "%s - failed to set channel due to error: %d\n",
659 static ssize_t ati_remote2_show_channel_mask(struct device *dev,
660 struct device_attribute *attr,
663 struct usb_device *udev = to_usb_device(dev);
664 struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
665 struct ati_remote2 *ar2 = usb_get_intfdata(intf);
667 return sprintf(buf, "0x%04x\n", ar2->channel_mask);
670 static ssize_t ati_remote2_store_channel_mask(struct device *dev,
671 struct device_attribute *attr,
672 const char *buf, size_t count)
674 struct usb_device *udev = to_usb_device(dev);
675 struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
676 struct ati_remote2 *ar2 = usb_get_intfdata(intf);
680 if (strict_strtoul(buf, 0, &mask))
683 if (mask & ~ATI_REMOTE2_MAX_CHANNEL_MASK)
686 r = usb_autopm_get_interface(ar2->intf[0]);
688 dev_err(&ar2->intf[0]->dev,
689 "%s(): usb_autopm_get_interface() = %d\n", __func__, r);
693 mutex_lock(&ati_remote2_mutex);
695 if (mask != ar2->channel_mask && !ati_remote2_setup(ar2, mask))
696 ar2->channel_mask = mask;
698 mutex_unlock(&ati_remote2_mutex);
700 usb_autopm_put_interface(ar2->intf[0]);
705 static ssize_t ati_remote2_show_mode_mask(struct device *dev,
706 struct device_attribute *attr,
709 struct usb_device *udev = to_usb_device(dev);
710 struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
711 struct ati_remote2 *ar2 = usb_get_intfdata(intf);
713 return sprintf(buf, "0x%02x\n", ar2->mode_mask);
716 static ssize_t ati_remote2_store_mode_mask(struct device *dev,
717 struct device_attribute *attr,
718 const char *buf, size_t count)
720 struct usb_device *udev = to_usb_device(dev);
721 struct usb_interface *intf = usb_ifnum_to_if(udev, 0);
722 struct ati_remote2 *ar2 = usb_get_intfdata(intf);
725 if (strict_strtoul(buf, 0, &mask))
728 if (mask & ~ATI_REMOTE2_MAX_MODE_MASK)
731 ar2->mode_mask = mask;
736 static DEVICE_ATTR(channel_mask, 0644, ati_remote2_show_channel_mask,
737 ati_remote2_store_channel_mask);
739 static DEVICE_ATTR(mode_mask, 0644, ati_remote2_show_mode_mask,
740 ati_remote2_store_mode_mask);
742 static struct attribute *ati_remote2_attrs[] = {
743 &dev_attr_channel_mask.attr,
744 &dev_attr_mode_mask.attr,
748 static struct attribute_group ati_remote2_attr_group = {
749 .attrs = ati_remote2_attrs,
752 static int ati_remote2_probe(struct usb_interface *interface, const struct usb_device_id *id)
754 struct usb_device *udev = interface_to_usbdev(interface);
755 struct usb_host_interface *alt = interface->cur_altsetting;
756 struct ati_remote2 *ar2;
759 if (alt->desc.bInterfaceNumber)
762 ar2 = kzalloc(sizeof (struct ati_remote2), GFP_KERNEL);
768 ar2->intf[0] = interface;
769 ar2->ep[0] = &alt->endpoint[0].desc;
771 ar2->intf[1] = usb_ifnum_to_if(udev, 1);
772 r = usb_driver_claim_interface(&ati_remote2_driver, ar2->intf[1], ar2);
775 alt = ar2->intf[1]->cur_altsetting;
776 ar2->ep[1] = &alt->endpoint[0].desc;
778 r = ati_remote2_urb_init(ar2);
782 ar2->channel_mask = channel_mask;
783 ar2->mode_mask = mode_mask;
785 r = ati_remote2_setup(ar2, ar2->channel_mask);
789 usb_make_path(udev, ar2->phys, sizeof(ar2->phys));
790 strlcat(ar2->phys, "/input0", sizeof(ar2->phys));
792 strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name));
794 r = sysfs_create_group(&udev->dev.kobj, &ati_remote2_attr_group);
798 r = ati_remote2_input_init(ar2);
802 usb_set_intfdata(interface, ar2);
804 interface->needs_remote_wakeup = 1;
809 sysfs_remove_group(&udev->dev.kobj, &ati_remote2_attr_group);
811 ati_remote2_urb_cleanup(ar2);
812 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
819 static void ati_remote2_disconnect(struct usb_interface *interface)
821 struct ati_remote2 *ar2;
822 struct usb_host_interface *alt = interface->cur_altsetting;
824 if (alt->desc.bInterfaceNumber)
827 ar2 = usb_get_intfdata(interface);
828 usb_set_intfdata(interface, NULL);
830 input_unregister_device(ar2->idev);
832 sysfs_remove_group(&ar2->udev->dev.kobj, &ati_remote2_attr_group);
834 ati_remote2_urb_cleanup(ar2);
836 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]);
841 static int ati_remote2_suspend(struct usb_interface *interface,
842 pm_message_t message)
844 struct ati_remote2 *ar2;
845 struct usb_host_interface *alt = interface->cur_altsetting;
847 if (alt->desc.bInterfaceNumber)
850 ar2 = usb_get_intfdata(interface);
852 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
854 mutex_lock(&ati_remote2_mutex);
856 if (ar2->flags & ATI_REMOTE2_OPENED)
857 ati_remote2_kill_urbs(ar2);
859 ar2->flags |= ATI_REMOTE2_SUSPENDED;
861 mutex_unlock(&ati_remote2_mutex);
866 static int ati_remote2_resume(struct usb_interface *interface)
868 struct ati_remote2 *ar2;
869 struct usb_host_interface *alt = interface->cur_altsetting;
872 if (alt->desc.bInterfaceNumber)
875 ar2 = usb_get_intfdata(interface);
877 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
879 mutex_lock(&ati_remote2_mutex);
881 if (ar2->flags & ATI_REMOTE2_OPENED)
882 r = ati_remote2_submit_urbs(ar2);
885 ar2->flags &= ~ATI_REMOTE2_SUSPENDED;
887 mutex_unlock(&ati_remote2_mutex);
892 static int ati_remote2_reset_resume(struct usb_interface *interface)
894 struct ati_remote2 *ar2;
895 struct usb_host_interface *alt = interface->cur_altsetting;
898 if (alt->desc.bInterfaceNumber)
901 ar2 = usb_get_intfdata(interface);
903 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
905 mutex_lock(&ati_remote2_mutex);
907 r = ati_remote2_setup(ar2, ar2->channel_mask);
911 if (ar2->flags & ATI_REMOTE2_OPENED)
912 r = ati_remote2_submit_urbs(ar2);
915 ar2->flags &= ~ATI_REMOTE2_SUSPENDED;
918 mutex_unlock(&ati_remote2_mutex);
923 static int ati_remote2_pre_reset(struct usb_interface *interface)
925 struct ati_remote2 *ar2;
926 struct usb_host_interface *alt = interface->cur_altsetting;
928 if (alt->desc.bInterfaceNumber)
931 ar2 = usb_get_intfdata(interface);
933 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
935 mutex_lock(&ati_remote2_mutex);
937 if (ar2->flags == ATI_REMOTE2_OPENED)
938 ati_remote2_kill_urbs(ar2);
943 static int ati_remote2_post_reset(struct usb_interface *interface)
945 struct ati_remote2 *ar2;
946 struct usb_host_interface *alt = interface->cur_altsetting;
949 if (alt->desc.bInterfaceNumber)
952 ar2 = usb_get_intfdata(interface);
954 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__);
956 if (ar2->flags == ATI_REMOTE2_OPENED)
957 r = ati_remote2_submit_urbs(ar2);
959 mutex_unlock(&ati_remote2_mutex);
964 static int __init ati_remote2_init(void)
968 r = usb_register(&ati_remote2_driver);
970 printk(KERN_ERR "ati_remote2: usb_register() = %d\n", r);
972 printk(KERN_INFO "ati_remote2: " DRIVER_DESC " " DRIVER_VERSION "\n");
977 static void __exit ati_remote2_exit(void)
979 usb_deregister(&ati_remote2_driver);
982 module_init(ati_remote2_init);
983 module_exit(ati_remote2_exit);