Lines Matching refs:ar2
209 static int ati_remote2_submit_urbs(struct ati_remote2 *ar2) in ati_remote2_submit_urbs() argument
213 r = usb_submit_urb(ar2->urb[0], GFP_KERNEL); in ati_remote2_submit_urbs()
215 dev_err(&ar2->intf[0]->dev, in ati_remote2_submit_urbs()
219 r = usb_submit_urb(ar2->urb[1], GFP_KERNEL); in ati_remote2_submit_urbs()
221 usb_kill_urb(ar2->urb[0]); in ati_remote2_submit_urbs()
222 dev_err(&ar2->intf[1]->dev, in ati_remote2_submit_urbs()
230 static void ati_remote2_kill_urbs(struct ati_remote2 *ar2) in ati_remote2_kill_urbs() argument
232 usb_kill_urb(ar2->urb[1]); in ati_remote2_kill_urbs()
233 usb_kill_urb(ar2->urb[0]); in ati_remote2_kill_urbs()
238 struct ati_remote2 *ar2 = input_get_drvdata(idev); in ati_remote2_open() local
241 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); in ati_remote2_open()
243 r = usb_autopm_get_interface(ar2->intf[0]); in ati_remote2_open()
245 dev_err(&ar2->intf[0]->dev, in ati_remote2_open()
251 if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) { in ati_remote2_open()
252 r = ati_remote2_submit_urbs(ar2); in ati_remote2_open()
257 ar2->flags |= ATI_REMOTE2_OPENED; in ati_remote2_open()
260 usb_autopm_put_interface(ar2->intf[0]); in ati_remote2_open()
267 struct ati_remote2 *ar2 = input_get_drvdata(idev); in ati_remote2_close() local
269 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); in ati_remote2_close()
273 if (!(ar2->flags & ATI_REMOTE2_SUSPENDED)) in ati_remote2_close()
274 ati_remote2_kill_urbs(ar2); in ati_remote2_close()
276 ar2->flags &= ~ATI_REMOTE2_OPENED; in ati_remote2_close()
279 static void ati_remote2_input_mouse(struct ati_remote2 *ar2) in ati_remote2_input_mouse() argument
281 struct input_dev *idev = ar2->idev; in ati_remote2_input_mouse()
282 u8 *data = ar2->buf[0]; in ati_remote2_input_mouse()
287 if (!((1 << channel) & ar2->channel_mask)) in ati_remote2_input_mouse()
293 dev_err(&ar2->intf[0]->dev, in ati_remote2_input_mouse()
299 if (!((1 << mode) & ar2->mode_mask)) in ati_remote2_input_mouse()
318 static void ati_remote2_input_key(struct ati_remote2 *ar2) in ati_remote2_input_key() argument
320 struct input_dev *idev = ar2->idev; in ati_remote2_input_key()
321 u8 *data = ar2->buf[1]; in ati_remote2_input_key()
326 if (!((1 << channel) & ar2->channel_mask)) in ati_remote2_input_key()
332 dev_err(&ar2->intf[1]->dev, in ati_remote2_input_key()
347 if (ar2->mode == mode) in ati_remote2_input_key()
351 ar2->mode = mode; in ati_remote2_input_key()
354 if (!((1 << mode) & ar2->mode_mask)) in ati_remote2_input_key()
359 dev_err(&ar2->intf[1]->dev, in ati_remote2_input_key()
369 ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_DELAY]); in ati_remote2_input_key()
374 if (ar2->keycode[mode][index] == BTN_LEFT || in ati_remote2_input_key()
375 ar2->keycode[mode][index] == BTN_RIGHT) in ati_remote2_input_key()
378 if (!time_after_eq(jiffies, ar2->jiffies)) in ati_remote2_input_key()
381 ar2->jiffies = jiffies + msecs_to_jiffies(idev->rep[REP_PERIOD]); in ati_remote2_input_key()
384 dev_err(&ar2->intf[1]->dev, in ati_remote2_input_key()
390 input_event(idev, EV_KEY, ar2->keycode[mode][index], data[1]); in ati_remote2_input_key()
396 struct ati_remote2 *ar2 = urb->context; in ati_remote2_complete_mouse() local
401 usb_mark_last_busy(ar2->udev); in ati_remote2_complete_mouse()
402 ati_remote2_input_mouse(ar2); in ati_remote2_complete_mouse()
408 dev_dbg(&ar2->intf[0]->dev, in ati_remote2_complete_mouse()
412 usb_mark_last_busy(ar2->udev); in ati_remote2_complete_mouse()
413 dev_err(&ar2->intf[0]->dev, in ati_remote2_complete_mouse()
419 dev_err(&ar2->intf[0]->dev, in ati_remote2_complete_mouse()
425 struct ati_remote2 *ar2 = urb->context; in ati_remote2_complete_key() local
430 usb_mark_last_busy(ar2->udev); in ati_remote2_complete_key()
431 ati_remote2_input_key(ar2); in ati_remote2_complete_key()
437 dev_dbg(&ar2->intf[1]->dev, in ati_remote2_complete_key()
441 usb_mark_last_busy(ar2->udev); in ati_remote2_complete_key()
442 dev_err(&ar2->intf[1]->dev, in ati_remote2_complete_key()
448 dev_err(&ar2->intf[1]->dev, in ati_remote2_complete_key()
455 struct ati_remote2 *ar2 = input_get_drvdata(idev); in ati_remote2_getkeycode() local
485 ke->keycode = ar2->keycode[mode][offset]; in ati_remote2_getkeycode()
497 struct ati_remote2 *ar2 = input_get_drvdata(idev); in ati_remote2_setkeycode() local
523 *old_keycode = ar2->keycode[mode][offset]; in ati_remote2_setkeycode()
524 ar2->keycode[mode][offset] = ke->keycode; in ati_remote2_setkeycode()
529 if (ar2->keycode[mode][index] == *old_keycode) in ati_remote2_setkeycode()
539 static int ati_remote2_input_init(struct ati_remote2 *ar2) in ati_remote2_input_init() argument
548 ar2->idev = idev; in ati_remote2_input_init()
549 input_set_drvdata(idev, ar2); in ati_remote2_input_init()
558 ar2->keycode[mode][index] = ati_remote2_key_table[index].keycode; in ati_remote2_input_init()
559 __set_bit(ar2->keycode[mode][index], idev->keybit); in ati_remote2_input_init()
565 ar2->keycode[ATI_REMOTE2_AUX1][index] = KEY_PROG1; in ati_remote2_input_init()
566 ar2->keycode[ATI_REMOTE2_AUX2][index] = KEY_PROG2; in ati_remote2_input_init()
567 ar2->keycode[ATI_REMOTE2_AUX3][index] = KEY_PROG3; in ati_remote2_input_init()
568 ar2->keycode[ATI_REMOTE2_AUX4][index] = KEY_PROG4; in ati_remote2_input_init()
569 ar2->keycode[ATI_REMOTE2_PC][index] = KEY_PC; in ati_remote2_input_init()
585 idev->name = ar2->name; in ati_remote2_input_init()
586 idev->phys = ar2->phys; in ati_remote2_input_init()
588 usb_to_input_id(ar2->udev, &idev->id); in ati_remote2_input_init()
589 idev->dev.parent = &ar2->udev->dev; in ati_remote2_input_init()
598 static int ati_remote2_urb_init(struct ati_remote2 *ar2) in ati_remote2_urb_init() argument
600 struct usb_device *udev = ar2->udev; in ati_remote2_urb_init()
604 ar2->buf[i] = usb_alloc_coherent(udev, 4, GFP_KERNEL, &ar2->buf_dma[i]); in ati_remote2_urb_init()
605 if (!ar2->buf[i]) in ati_remote2_urb_init()
608 ar2->urb[i] = usb_alloc_urb(0, GFP_KERNEL); in ati_remote2_urb_init()
609 if (!ar2->urb[i]) in ati_remote2_urb_init()
612 pipe = usb_rcvintpipe(udev, ar2->ep[i]->bEndpointAddress); in ati_remote2_urb_init()
616 usb_fill_int_urb(ar2->urb[i], udev, pipe, ar2->buf[i], maxp, in ati_remote2_urb_init()
618 ar2, ar2->ep[i]->bInterval); in ati_remote2_urb_init()
619 ar2->urb[i]->transfer_dma = ar2->buf_dma[i]; in ati_remote2_urb_init()
620 ar2->urb[i]->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in ati_remote2_urb_init()
626 static void ati_remote2_urb_cleanup(struct ati_remote2 *ar2) in ati_remote2_urb_cleanup() argument
631 usb_free_urb(ar2->urb[i]); in ati_remote2_urb_cleanup()
632 usb_free_coherent(ar2->udev, 4, ar2->buf[i], ar2->buf_dma[i]); in ati_remote2_urb_cleanup()
636 static int ati_remote2_setup(struct ati_remote2 *ar2, unsigned int ch_mask) in ati_remote2_setup() argument
658 r = usb_control_msg(ar2->udev, usb_sndctrlpipe(ar2->udev, 0), in ati_remote2_setup()
663 dev_err(&ar2->udev->dev, "%s - failed to set channel due to error: %d\n", in ati_remote2_setup()
677 struct ati_remote2 *ar2 = usb_get_intfdata(intf); in ati_remote2_show_channel_mask() local
679 return sprintf(buf, "0x%04x\n", ar2->channel_mask); in ati_remote2_show_channel_mask()
688 struct ati_remote2 *ar2 = usb_get_intfdata(intf); in ati_remote2_store_channel_mask() local
699 r = usb_autopm_get_interface(ar2->intf[0]); in ati_remote2_store_channel_mask()
701 dev_err(&ar2->intf[0]->dev, in ati_remote2_store_channel_mask()
707 if (mask != ar2->channel_mask) { in ati_remote2_store_channel_mask()
708 r = ati_remote2_setup(ar2, mask); in ati_remote2_store_channel_mask()
710 ar2->channel_mask = mask; in ati_remote2_store_channel_mask()
714 usb_autopm_put_interface(ar2->intf[0]); in ati_remote2_store_channel_mask()
725 struct ati_remote2 *ar2 = usb_get_intfdata(intf); in ati_remote2_show_mode_mask() local
727 return sprintf(buf, "0x%02x\n", ar2->mode_mask); in ati_remote2_show_mode_mask()
736 struct ati_remote2 *ar2 = usb_get_intfdata(intf); in ati_remote2_store_mode_mask() local
747 ar2->mode_mask = mask; in ati_remote2_store_mode_mask()
769 struct ati_remote2 *ar2; in ati_remote2_probe() local
775 ar2 = kzalloc(sizeof (struct ati_remote2), GFP_KERNEL); in ati_remote2_probe()
776 if (!ar2) in ati_remote2_probe()
779 ar2->udev = udev; in ati_remote2_probe()
788 ar2->intf[0] = interface; in ati_remote2_probe()
789 ar2->ep[0] = &alt->endpoint[0].desc; in ati_remote2_probe()
792 ar2->intf[1] = usb_ifnum_to_if(udev, 1); in ati_remote2_probe()
793 if ((udev->actconfig->desc.bNumInterfaces < 2) || !ar2->intf[1]) { in ati_remote2_probe()
800 r = usb_driver_claim_interface(&ati_remote2_driver, ar2->intf[1], ar2); in ati_remote2_probe()
805 alt = ar2->intf[1]->cur_altsetting; in ati_remote2_probe()
812 ar2->ep[1] = &alt->endpoint[0].desc; in ati_remote2_probe()
814 r = ati_remote2_urb_init(ar2); in ati_remote2_probe()
818 ar2->channel_mask = channel_mask; in ati_remote2_probe()
819 ar2->mode_mask = mode_mask; in ati_remote2_probe()
821 r = ati_remote2_setup(ar2, ar2->channel_mask); in ati_remote2_probe()
825 usb_make_path(udev, ar2->phys, sizeof(ar2->phys)); in ati_remote2_probe()
826 strlcat(ar2->phys, "/input0", sizeof(ar2->phys)); in ati_remote2_probe()
828 strlcat(ar2->name, "ATI Remote Wonder II", sizeof(ar2->name)); in ati_remote2_probe()
830 r = ati_remote2_input_init(ar2); in ati_remote2_probe()
834 usb_set_intfdata(interface, ar2); in ati_remote2_probe()
841 ati_remote2_urb_cleanup(ar2); in ati_remote2_probe()
843 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); in ati_remote2_probe()
845 kfree(ar2); in ati_remote2_probe()
852 struct ati_remote2 *ar2; in ati_remote2_disconnect() local
858 ar2 = usb_get_intfdata(interface); in ati_remote2_disconnect()
861 input_unregister_device(ar2->idev); in ati_remote2_disconnect()
863 ati_remote2_urb_cleanup(ar2); in ati_remote2_disconnect()
865 usb_driver_release_interface(&ati_remote2_driver, ar2->intf[1]); in ati_remote2_disconnect()
867 kfree(ar2); in ati_remote2_disconnect()
873 struct ati_remote2 *ar2; in ati_remote2_suspend() local
879 ar2 = usb_get_intfdata(interface); in ati_remote2_suspend()
881 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); in ati_remote2_suspend()
885 if (ar2->flags & ATI_REMOTE2_OPENED) in ati_remote2_suspend()
886 ati_remote2_kill_urbs(ar2); in ati_remote2_suspend()
888 ar2->flags |= ATI_REMOTE2_SUSPENDED; in ati_remote2_suspend()
895 struct ati_remote2 *ar2; in ati_remote2_resume() local
902 ar2 = usb_get_intfdata(interface); in ati_remote2_resume()
904 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); in ati_remote2_resume()
908 if (ar2->flags & ATI_REMOTE2_OPENED) in ati_remote2_resume()
909 r = ati_remote2_submit_urbs(ar2); in ati_remote2_resume()
912 ar2->flags &= ~ATI_REMOTE2_SUSPENDED; in ati_remote2_resume()
919 struct ati_remote2 *ar2; in ati_remote2_reset_resume() local
926 ar2 = usb_get_intfdata(interface); in ati_remote2_reset_resume()
928 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); in ati_remote2_reset_resume()
932 r = ati_remote2_setup(ar2, ar2->channel_mask); in ati_remote2_reset_resume()
936 if (ar2->flags & ATI_REMOTE2_OPENED) in ati_remote2_reset_resume()
937 r = ati_remote2_submit_urbs(ar2); in ati_remote2_reset_resume()
940 ar2->flags &= ~ATI_REMOTE2_SUSPENDED; in ati_remote2_reset_resume()
947 struct ati_remote2 *ar2; in ati_remote2_pre_reset() local
953 ar2 = usb_get_intfdata(interface); in ati_remote2_pre_reset()
955 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); in ati_remote2_pre_reset()
959 if (ar2->flags == ATI_REMOTE2_OPENED) in ati_remote2_pre_reset()
960 ati_remote2_kill_urbs(ar2); in ati_remote2_pre_reset()
967 struct ati_remote2 *ar2; in ati_remote2_post_reset() local
974 ar2 = usb_get_intfdata(interface); in ati_remote2_post_reset()
976 dev_dbg(&ar2->intf[0]->dev, "%s()\n", __func__); in ati_remote2_post_reset()
978 if (ar2->flags == ATI_REMOTE2_OPENED) in ati_remote2_post_reset()
979 r = ati_remote2_submit_urbs(ar2); in ati_remote2_post_reset()