Lines Matching refs:ati_remote
230 struct ati_remote { struct
322 static int ati_remote_open(struct ati_remote *ati_remote) in ati_remote_open() argument
326 mutex_lock(&ati_remote->open_mutex); in ati_remote_open()
328 if (ati_remote->users++ != 0) in ati_remote_open()
332 ati_remote->irq_urb->dev = ati_remote->udev; in ati_remote_open()
333 if (usb_submit_urb(ati_remote->irq_urb, GFP_KERNEL)) { in ati_remote_open()
334 dev_err(&ati_remote->interface->dev, in ati_remote_open()
339 out: mutex_unlock(&ati_remote->open_mutex); in ati_remote_open()
346 static void ati_remote_close(struct ati_remote *ati_remote) in ati_remote_close() argument
348 mutex_lock(&ati_remote->open_mutex); in ati_remote_close()
349 if (--ati_remote->users == 0) in ati_remote_close()
350 usb_kill_urb(ati_remote->irq_urb); in ati_remote_close()
351 mutex_unlock(&ati_remote->open_mutex); in ati_remote_close()
356 struct ati_remote *ati_remote = input_get_drvdata(inputdev); in ati_remote_input_open() local
357 return ati_remote_open(ati_remote); in ati_remote_input_open()
362 struct ati_remote *ati_remote = input_get_drvdata(inputdev); in ati_remote_input_close() local
363 ati_remote_close(ati_remote); in ati_remote_input_close()
368 struct ati_remote *ati_remote = rdev->priv; in ati_remote_rc_open() local
369 return ati_remote_open(ati_remote); in ati_remote_rc_open()
374 struct ati_remote *ati_remote = rdev->priv; in ati_remote_rc_close() local
375 ati_remote_close(ati_remote); in ati_remote_rc_close()
383 struct ati_remote *ati_remote = urb->context; in ati_remote_irq_out() local
386 dev_dbg(&ati_remote->interface->dev, "%s: status %d\n", in ati_remote_irq_out()
391 ati_remote->send_flags |= SEND_FLAG_COMPLETE; in ati_remote_irq_out()
393 wake_up(&ati_remote->wait); in ati_remote_irq_out()
401 static int ati_remote_sendpacket(struct ati_remote *ati_remote, u16 cmd, in ati_remote_sendpacket() argument
407 memcpy(ati_remote->out_urb->transfer_buffer + 1, data, LO(cmd)); in ati_remote_sendpacket()
408 ((char *) ati_remote->out_urb->transfer_buffer)[0] = HI(cmd); in ati_remote_sendpacket()
410 ati_remote->out_urb->transfer_buffer_length = LO(cmd) + 1; in ati_remote_sendpacket()
411 ati_remote->out_urb->dev = ati_remote->udev; in ati_remote_sendpacket()
412 ati_remote->send_flags = SEND_FLAG_IN_PROGRESS; in ati_remote_sendpacket()
414 retval = usb_submit_urb(ati_remote->out_urb, GFP_ATOMIC); in ati_remote_sendpacket()
416 dev_dbg(&ati_remote->interface->dev, in ati_remote_sendpacket()
421 wait_event_timeout(ati_remote->wait, in ati_remote_sendpacket()
422 ((ati_remote->out_urb->status != -EINPROGRESS) || in ati_remote_sendpacket()
423 (ati_remote->send_flags & SEND_FLAG_COMPLETE)), in ati_remote_sendpacket()
425 usb_kill_urb(ati_remote->out_urb); in ati_remote_sendpacket()
454 static int ati_remote_compute_accel(struct ati_remote *ati_remote) in ati_remote_compute_accel() argument
461 if (time_after(now, ati_remote->old_jiffies + reset_time)) { in ati_remote_compute_accel()
462 ati_remote->acc_jiffies = now; in ati_remote_compute_accel()
468 if (time_before(now, ati_remote->acc_jiffies + timeout)) in ati_remote_compute_accel()
479 struct ati_remote *ati_remote = urb->context; in ati_remote_input_report() local
480 unsigned char *data= ati_remote->inbuf; in ati_remote_input_report()
481 struct input_dev *dev = ati_remote->idev; in ati_remote_input_report()
504 dbginfo(&ati_remote->interface->dev, in ati_remote_input_report()
513 dbginfo(&ati_remote->interface->dev, in ati_remote_input_report()
525 dbginfo(&ati_remote->interface->dev, in ati_remote_input_report()
536 wheel_keycode = rc_g_keycode_from_table(ati_remote->rdev, in ati_remote_input_report()
562 ati_remote->old_jiffies = jiffies; in ati_remote_input_report()
568 if (ati_remote->old_data == data[2] && in ati_remote_input_report()
569 time_before(now, ati_remote->old_jiffies + in ati_remote_input_report()
571 ati_remote->repeat_count++; in ati_remote_input_report()
573 ati_remote->repeat_count = 0; in ati_remote_input_report()
574 ati_remote->first_jiffies = now; in ati_remote_input_report()
577 ati_remote->old_jiffies = now; in ati_remote_input_report()
583 if (ati_remote->repeat_count > 0 && in ati_remote_input_report()
584 (ati_remote->repeat_count < 5 || in ati_remote_input_report()
585 time_before(now, ati_remote->first_jiffies + in ati_remote_input_report()
613 rc_keydown_notimeout(ati_remote->rdev, in ati_remote_input_report()
616 rc_keyup(ati_remote->rdev); in ati_remote_input_report()
630 int acc = ati_remote_compute_accel(ati_remote); in ati_remote_input_report()
635 ati_remote->old_jiffies = jiffies; in ati_remote_input_report()
638 dev_dbg(&ati_remote->interface->dev, "ati_remote kind=%d\n", in ati_remote_input_report()
644 ati_remote->old_data = data[2]; in ati_remote_input_report()
652 struct ati_remote *ati_remote = urb->context; in ati_remote_irq_in() local
662 dev_dbg(&ati_remote->interface->dev, in ati_remote_irq_in()
667 dev_dbg(&ati_remote->interface->dev, in ati_remote_irq_in()
674 dev_err(&ati_remote->interface->dev, in ati_remote_irq_in()
683 struct ati_remote *ati_remote) in ati_remote_alloc_buffers() argument
685 ati_remote->inbuf = usb_alloc_coherent(udev, DATA_BUFSIZE, GFP_ATOMIC, in ati_remote_alloc_buffers()
686 &ati_remote->inbuf_dma); in ati_remote_alloc_buffers()
687 if (!ati_remote->inbuf) in ati_remote_alloc_buffers()
690 ati_remote->outbuf = usb_alloc_coherent(udev, DATA_BUFSIZE, GFP_ATOMIC, in ati_remote_alloc_buffers()
691 &ati_remote->outbuf_dma); in ati_remote_alloc_buffers()
692 if (!ati_remote->outbuf) in ati_remote_alloc_buffers()
695 ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL); in ati_remote_alloc_buffers()
696 if (!ati_remote->irq_urb) in ati_remote_alloc_buffers()
699 ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL); in ati_remote_alloc_buffers()
700 if (!ati_remote->out_urb) in ati_remote_alloc_buffers()
709 static void ati_remote_free_buffers(struct ati_remote *ati_remote) in ati_remote_free_buffers() argument
711 usb_free_urb(ati_remote->irq_urb); in ati_remote_free_buffers()
712 usb_free_urb(ati_remote->out_urb); in ati_remote_free_buffers()
714 usb_free_coherent(ati_remote->udev, DATA_BUFSIZE, in ati_remote_free_buffers()
715 ati_remote->inbuf, ati_remote->inbuf_dma); in ati_remote_free_buffers()
717 usb_free_coherent(ati_remote->udev, DATA_BUFSIZE, in ati_remote_free_buffers()
718 ati_remote->outbuf, ati_remote->outbuf_dma); in ati_remote_free_buffers()
721 static void ati_remote_input_init(struct ati_remote *ati_remote) in ati_remote_input_init() argument
723 struct input_dev *idev = ati_remote->idev; in ati_remote_input_init()
735 input_set_drvdata(idev, ati_remote); in ati_remote_input_init()
740 idev->name = ati_remote->mouse_name; in ati_remote_input_init()
741 idev->phys = ati_remote->mouse_phys; in ati_remote_input_init()
743 usb_to_input_id(ati_remote->udev, &idev->id); in ati_remote_input_init()
744 idev->dev.parent = &ati_remote->interface->dev; in ati_remote_input_init()
747 static void ati_remote_rc_init(struct ati_remote *ati_remote) in ati_remote_rc_init() argument
749 struct rc_dev *rdev = ati_remote->rdev; in ati_remote_rc_init()
751 rdev->priv = ati_remote; in ati_remote_rc_init()
758 rdev->device_name = ati_remote->rc_name; in ati_remote_rc_init()
759 rdev->input_phys = ati_remote->rc_phys; in ati_remote_rc_init()
761 usb_to_input_id(ati_remote->udev, &rdev->input_id); in ati_remote_rc_init()
762 rdev->dev.parent = &ati_remote->interface->dev; in ati_remote_rc_init()
765 static int ati_remote_initialize(struct ati_remote *ati_remote) in ati_remote_initialize() argument
767 struct usb_device *udev = ati_remote->udev; in ati_remote_initialize()
770 init_waitqueue_head(&ati_remote->wait); in ati_remote_initialize()
773 pipe = usb_rcvintpipe(udev, ati_remote->endpoint_in->bEndpointAddress); in ati_remote_initialize()
777 usb_fill_int_urb(ati_remote->irq_urb, udev, pipe, ati_remote->inbuf, in ati_remote_initialize()
778 maxp, ati_remote_irq_in, ati_remote, in ati_remote_initialize()
779 ati_remote->endpoint_in->bInterval); in ati_remote_initialize()
780 ati_remote->irq_urb->transfer_dma = ati_remote->inbuf_dma; in ati_remote_initialize()
781 ati_remote->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in ati_remote_initialize()
784 pipe = usb_sndintpipe(udev, ati_remote->endpoint_out->bEndpointAddress); in ati_remote_initialize()
788 usb_fill_int_urb(ati_remote->out_urb, udev, pipe, ati_remote->outbuf, in ati_remote_initialize()
789 maxp, ati_remote_irq_out, ati_remote, in ati_remote_initialize()
790 ati_remote->endpoint_out->bInterval); in ati_remote_initialize()
791 ati_remote->out_urb->transfer_dma = ati_remote->outbuf_dma; in ati_remote_initialize()
792 ati_remote->out_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; in ati_remote_initialize()
795 if ((ati_remote_sendpacket(ati_remote, 0x8004, init1)) || in ati_remote_initialize()
796 (ati_remote_sendpacket(ati_remote, 0x8007, init2))) { in ati_remote_initialize()
797 dev_err(&ati_remote->interface->dev, in ati_remote_initialize()
815 struct ati_remote *ati_remote; in ati_remote_probe() local
842 ati_remote = kzalloc(sizeof (struct ati_remote), GFP_KERNEL); in ati_remote_probe()
844 if (!ati_remote || !rc_dev) in ati_remote_probe()
848 if (ati_remote_alloc_buffers(udev, ati_remote)) in ati_remote_probe()
851 ati_remote->endpoint_in = endpoint_in; in ati_remote_probe()
852 ati_remote->endpoint_out = endpoint_out; in ati_remote_probe()
853 ati_remote->udev = udev; in ati_remote_probe()
854 ati_remote->rdev = rc_dev; in ati_remote_probe()
855 ati_remote->interface = interface; in ati_remote_probe()
857 usb_make_path(udev, ati_remote->rc_phys, sizeof(ati_remote->rc_phys)); in ati_remote_probe()
858 strscpy(ati_remote->mouse_phys, ati_remote->rc_phys, in ati_remote_probe()
859 sizeof(ati_remote->mouse_phys)); in ati_remote_probe()
861 strlcat(ati_remote->rc_phys, "/input0", sizeof(ati_remote->rc_phys)); in ati_remote_probe()
862 strlcat(ati_remote->mouse_phys, "/input1", sizeof(ati_remote->mouse_phys)); in ati_remote_probe()
864 snprintf(ati_remote->rc_name, sizeof(ati_remote->rc_name), "%s%s%s", in ati_remote_probe()
869 if (!strlen(ati_remote->rc_name)) in ati_remote_probe()
870 snprintf(ati_remote->rc_name, sizeof(ati_remote->rc_name), in ati_remote_probe()
872 le16_to_cpu(ati_remote->udev->descriptor.idVendor), in ati_remote_probe()
873 le16_to_cpu(ati_remote->udev->descriptor.idProduct)); in ati_remote_probe()
875 snprintf(ati_remote->mouse_name, sizeof(ati_remote->mouse_name), in ati_remote_probe()
876 "%s mouse", ati_remote->rc_name); in ati_remote_probe()
888 ati_remote_rc_init(ati_remote); in ati_remote_probe()
889 mutex_init(&ati_remote->open_mutex); in ati_remote_probe()
892 err = ati_remote_initialize(ati_remote); in ati_remote_probe()
897 err = rc_register_device(ati_remote->rdev); in ati_remote_probe()
909 ati_remote->idev = input_dev; in ati_remote_probe()
910 ati_remote_input_init(ati_remote); in ati_remote_probe()
917 usb_set_intfdata(interface, ati_remote); in ati_remote_probe()
926 usb_kill_urb(ati_remote->irq_urb); in ati_remote_probe()
927 usb_kill_urb(ati_remote->out_urb); in ati_remote_probe()
929 ati_remote_free_buffers(ati_remote); in ati_remote_probe()
932 kfree(ati_remote); in ati_remote_probe()
941 struct ati_remote *ati_remote; in ati_remote_disconnect() local
943 ati_remote = usb_get_intfdata(interface); in ati_remote_disconnect()
945 if (!ati_remote) { in ati_remote_disconnect()
950 usb_kill_urb(ati_remote->irq_urb); in ati_remote_disconnect()
951 usb_kill_urb(ati_remote->out_urb); in ati_remote_disconnect()
952 if (ati_remote->idev) in ati_remote_disconnect()
953 input_unregister_device(ati_remote->idev); in ati_remote_disconnect()
954 rc_unregister_device(ati_remote->rdev); in ati_remote_disconnect()
955 ati_remote_free_buffers(ati_remote); in ati_remote_disconnect()
956 kfree(ati_remote); in ati_remote_disconnect()