Lines Matching +full:hi +full:- +full:fi

1 // SPDX-License-Identifier: GPL-2.0-or-later
5 * Copyright (c) 2011, 2012 Anssi Hannula <anssi.hannula@iki.fi>
24 * Vincent Vanackere <vanackere@lif.univ-mrs.fr>
35 * "All-In-Wonder" video card packages. The receiver self-identifies as a
51 * - Press and hold the "hand icon" button.
52 * - When the red LED starts to blink, let go of the "hand icon" button.
53 * - When it stops blinking, input the channel code as two digits, from 01
58 * and mask. Note: debugging prints remote numbers as zero-based hexadecimal.
71 * The default is 0 (respond to all channels). Bit 0 and bits 17-32 of this
84 #include <media/rc-core.h>
155 if (udev->manufacturer && udev->product) { in get_medion_keymap()
156 if (udev->actconfig->desc.bmAttributes & USB_CONFIG_ATT_WAKEUP) { in get_medion_keymap()
158 if (!strcmp(udev->manufacturer, "X10 Wireless Technology Inc") in get_medion_keymap()
159 && !strcmp(udev->product, "USB Receiver")) in get_medion_keymap()
162 if (!strcmp(udev->manufacturer, "X10 WTI") in get_medion_keymap()
163 && !strcmp(udev->product, "RF receiver")) in get_medion_keymap()
167 if (!strcmp(udev->manufacturer, "X10 Wireless Technology Inc") in get_medion_keymap()
168 && !strcmp(udev->product, "USB Receiver")) in get_medion_keymap()
173 dev_info(&interface->dev, in get_medion_keymap()
219 /* Get hi and low bytes of a 16-bits int */
220 #define HI(a) ((unsigned char)((a) >> 8)) macro
260 int users; /* 0-2, users are rc and input */
267 #define KIND_FILTERED 2 /* Add artificial key-up events, drop keyrepeats */
268 #define KIND_ACCEL 3 /* Translate to EV_REL mouse-move events */
295 /* Artificial "double-click" events are generated by the hardware.
300 /* Non-mouse events are handled by rc-core */
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()
336 err = -EIO; in ati_remote_open()
339 out: mutex_unlock(&ati_remote->open_mutex); in ati_remote_open()
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()
368 struct ati_remote *ati_remote = rdev->priv; in ati_remote_rc_open()
374 struct ati_remote *ati_remote = rdev->priv; in ati_remote_rc_close()
383 struct ati_remote *ati_remote = urb->context; in ati_remote_irq_out()
385 if (urb->status) { in ati_remote_irq_out()
386 dev_dbg(&ati_remote->interface->dev, "%s: status %d\n", in ati_remote_irq_out()
387 __func__, urb->status); 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()
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()
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()
465 for (i = 0; i < ARRAY_SIZE(accel) - 1; i++) { 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()
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()
482 int index = -1; in ati_remote_input_report()
496 if ( urb->actual_length != 4 || data[0] != 0x14 || in ati_remote_input_report()
499 ati_remote_dump(&urb->dev->dev, data, urb->actual_length); in ati_remote_input_report()
504 dbginfo(&ati_remote->interface->dev, in ati_remote_input_report()
510 /* note: remote_num is 0-based, channel 1 on remote == 0 here */ 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()
593 /* Not a mouse event, hand it to rc-core. */ in ati_remote_input_report()
607 while (count--) { in ati_remote_input_report()
609 * We don't use the rc-core repeat handling yet as 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()
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()
655 switch (urb->status) { in ati_remote_irq_in()
659 case -ECONNRESET: /* unlink */ in ati_remote_irq_in()
660 case -ENOENT: in ati_remote_irq_in()
661 case -ESHUTDOWN: in ati_remote_irq_in()
662 dev_dbg(&ati_remote->interface->dev, in ati_remote_irq_in()
667 dev_dbg(&ati_remote->interface->dev, in ati_remote_irq_in()
669 __func__, urb->status); in ati_remote_irq_in()
674 dev_err(&ati_remote->interface->dev, in ati_remote_irq_in()
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()
688 return -1; 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()
693 return -1; 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()
697 return -1; 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()
701 return -1; in ati_remote_alloc_buffers()
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()
723 struct input_dev *idev = ati_remote->idev; in ati_remote_input_init()
726 idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); in ati_remote_input_init()
727 idev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | in ati_remote_input_init()
729 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); in ati_remote_input_init()
733 __set_bit(ati_remote_tbl[i].code, idev->keybit); in ati_remote_input_init()
737 idev->open = ati_remote_input_open; in ati_remote_input_init()
738 idev->close = ati_remote_input_close; 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()
749 struct rc_dev *rdev = ati_remote->rdev; in ati_remote_rc_init()
751 rdev->priv = ati_remote; in ati_remote_rc_init()
752 rdev->allowed_protocols = RC_PROTO_BIT_OTHER; in ati_remote_rc_init()
753 rdev->driver_name = "ati_remote"; in ati_remote_rc_init()
755 rdev->open = ati_remote_rc_open; in ati_remote_rc_init()
756 rdev->close = ati_remote_rc_close; 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()
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()
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()
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()
797 dev_err(&ati_remote->interface->dev, in ati_remote_initialize()
799 return -EIO; in ati_remote_initialize()
812 struct usb_host_interface *iface_host = interface->cur_altsetting; in ati_remote_probe()
814 struct ati_receiver_type *type = (struct ati_receiver_type *)id->driver_info; in ati_remote_probe()
817 struct device *device = &interface->dev; in ati_remote_probe()
819 int err = -ENOMEM; in ati_remote_probe()
821 if (iface_host->desc.bNumEndpoints != 2) { in ati_remote_probe()
823 return -ENODEV; in ati_remote_probe()
826 endpoint_in = &iface_host->endpoint[0].desc; in ati_remote_probe()
827 endpoint_out = &iface_host->endpoint[1].desc; in ati_remote_probe()
831 return -ENODEV; in ati_remote_probe()
833 if (le16_to_cpu(endpoint_in->wMaxPacketSize) == 0) { in ati_remote_probe()
835 return -ENODEV; in ati_remote_probe()
839 return -ENODEV; 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()
865 udev->manufacturer ?: "", in ati_remote_probe()
866 udev->manufacturer && udev->product ? " " : "", in ati_remote_probe()
867 udev->product ?: ""); 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()
878 rc_dev->map_name = RC_MAP_ATI_X10; /* default map */ in ati_remote_probe()
882 if (type->default_keymap) in ati_remote_probe()
883 rc_dev->map_name = type->default_keymap; in ati_remote_probe()
884 else if (type->get_default_keymap) in ati_remote_probe()
885 rc_dev->map_name = type->get_default_keymap(interface); in ati_remote_probe()
889 mutex_init(&ati_remote->open_mutex); in ati_remote_probe()
891 /* Device Hardware Initialization - fills in ati_remote->idev from udev. */ in ati_remote_probe()
897 err = rc_register_device(ati_remote->rdev); in ati_remote_probe()
905 err = -ENOMEM; in ati_remote_probe()
909 ati_remote->idev = input_dev; 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()
946 dev_warn(&interface->dev, "%s - null device?\n", __func__); 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()