Lines Matching +full:long +full:- +full:press +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-or-later
12 * also to the numerous 0xffdc device owners that tested auto-config
30 #include <media/rc-core.h>
127 struct rc_dev *rdev; /* rc-core device for remote */
160 * "struct file"->private_data, we need to remember
171 * display_open() to safely check ->disconnected and increment ->users.
368 * each new device until the 0x0034-0x0046 devices, which all use the same
369 * driver. Some of the devices in the 34-46 range haven't been definitively
383 .driver_info = (unsigned long)&imon_default_table },
392 .driver_info = (unsigned long)&imon_DH102 },
395 .driver_info = (unsigned long)&imon_default_table},
398 .driver_info = (unsigned long)&imon_OEM_VFD },
401 .driver_info = (unsigned long)&imon_default_table},
404 .driver_info = (unsigned long)&imon_default_table},
407 .driver_info = (unsigned long)&imon_default_table},
410 .driver_info = (unsigned long)&imon_default_table},
413 .driver_info = (unsigned long)&imon_default_table},
416 .driver_info = (unsigned long)&imon_default_table},
419 .driver_info = (unsigned long)&imon_default_table},
422 .driver_info = (unsigned long)&imon_default_table},
425 .driver_info = (unsigned long)&imon_default_table},
428 .driver_info = (unsigned long)&imon_default_table},
431 .driver_info = (unsigned long)&imon_default_table},
434 .driver_info = (unsigned long)&imon_default_table},
437 .driver_info = (unsigned long)&imon_default_table},
440 .driver_info = (unsigned long)&imon_default_table},
443 .driver_info = (unsigned long)&imon_default_table},
446 .driver_info = (unsigned long)&imon_default_table},
471 /* lcd, vfd, vga or none? should be auto-detected, but can be overridden... */
496 struct device *dev = ictx->dev; in free_imon_context()
498 usb_free_urb(ictx->tx_urb); in free_imon_context()
499 WARN_ON(ictx->dev_present_intf0); in free_imon_context()
500 usb_free_urb(ictx->rx_urb_intf0); in free_imon_context()
501 WARN_ON(ictx->dev_present_intf1); in free_imon_context()
502 usb_free_urb(ictx->rx_urb_intf1); in free_imon_context()
523 retval = -ENODEV; in display_open()
529 if (!ictx || ictx->disconnected || !refcount_inc_not_zero(&ictx->users)) { in display_open()
532 retval = -ENODEV; in display_open()
537 mutex_lock(&ictx->lock); in display_open()
539 if (!ictx->display_supported) { in display_open()
541 retval = -ENODEV; in display_open()
542 } else if (ictx->display_isopen) { in display_open()
544 retval = -EBUSY; in display_open()
546 ictx->display_isopen = true; in display_open()
547 file->private_data = ictx; in display_open()
548 dev_dbg(ictx->dev, "display port opened\n"); in display_open()
551 mutex_unlock(&ictx->lock); in display_open()
553 if (retval && refcount_dec_and_test(&ictx->users)) in display_open()
566 struct imon_context *ictx = file->private_data; in display_close()
569 mutex_lock(&ictx->lock); in display_close()
571 if (!ictx->display_supported) { in display_close()
573 retval = -ENODEV; in display_close()
574 } else if (!ictx->display_isopen) { in display_close()
576 retval = -EIO; in display_close()
578 ictx->display_isopen = false; in display_close()
579 dev_dbg(ictx->dev, "display port closed\n"); in display_close()
582 mutex_unlock(&ictx->lock); in display_close()
583 if (refcount_dec_and_test(&ictx->users)) in display_close()
589 * Sends a packet to the device -- this function must be called with
590 * ictx->lock held, or its unlock/lock sequence while waiting for tx
596 unsigned long timeout; in send_packet()
602 if (!ictx->tx_control) { in send_packet()
603 pipe = usb_sndintpipe(ictx->usbdev_intf0, in send_packet()
604 ictx->tx_endpoint->bEndpointAddress); in send_packet()
605 interval = ictx->tx_endpoint->bInterval; in send_packet()
607 usb_fill_int_urb(ictx->tx_urb, ictx->usbdev_intf0, pipe, in send_packet()
608 ictx->usb_tx_buf, in send_packet()
609 sizeof(ictx->usb_tx_buf), in send_packet()
612 ictx->tx_urb->actual_length = 0; in send_packet()
617 return -ENOMEM; in send_packet()
620 control_req->bRequestType = 0x21; in send_packet()
621 control_req->bRequest = 0x09; in send_packet()
622 control_req->wValue = cpu_to_le16(0x0200); in send_packet()
623 control_req->wIndex = cpu_to_le16(0x0001); in send_packet()
624 control_req->wLength = cpu_to_le16(0x0008); in send_packet()
627 pipe = usb_sndctrlpipe(ictx->usbdev_intf0, 0); in send_packet()
630 usb_fill_control_urb(ictx->tx_urb, ictx->usbdev_intf0, in send_packet()
632 ictx->usb_tx_buf, in send_packet()
633 sizeof(ictx->usb_tx_buf), in send_packet()
635 ictx->tx_urb->actual_length = 0; in send_packet()
638 reinit_completion(&ictx->tx.finished); in send_packet()
639 ictx->tx.busy = true; in send_packet()
642 retval = usb_submit_urb(ictx->tx_urb, GFP_KERNEL); in send_packet()
644 ictx->tx.busy = false; in send_packet()
649 mutex_unlock(&ictx->lock); in send_packet()
651 &ictx->tx.finished); in send_packet()
653 usb_kill_urb(ictx->tx_urb); in send_packet()
656 mutex_lock(&ictx->lock); in send_packet()
658 retval = ictx->tx.status; in send_packet()
670 timeout = msecs_to_jiffies(ictx->send_packet_delay); in send_packet()
692 return -ENODEV; in send_associate_24g()
695 if (!ictx->dev_present_intf0) { in send_associate_24g()
697 return -ENODEV; in send_associate_24g()
700 memcpy(ictx->usb_tx_buf, packet, sizeof(packet)); in send_associate_24g()
708 * Arguments: year - last 2 digits of year, month - 1..12,
709 * day - 1..31, dow - day of the week (0-Sun...6-Sat),
710 * hour - 0..23, minute - 0..59, second - 0..59
724 return -ENODEV; in send_set_imon_clock()
727 switch (ictx->display_type) { in send_set_imon_clock()
731 clock_enable_pkt[0][2] = month-1; in send_set_imon_clock()
745 if (ictx->product == 0xffdc) { in send_set_imon_clock()
757 clock_enable_pkt[0][1] = month-1; in send_set_imon_clock()
777 return -ENODEV; in send_set_imon_clock()
781 memcpy(ictx->usb_tx_buf, clock_enable_pkt[i], 8); in send_set_imon_clock()
802 return -ENODEV; in associate_remote_show()
804 mutex_lock(&ictx->lock); in associate_remote_show()
805 if (ictx->rf_isassociating) in associate_remote_show()
810 …dev_info(d, "Visit https://www.lirc.org/html/imon-24g.html for instructions on how to associate yo… in associate_remote_show()
811 mutex_unlock(&ictx->lock); in associate_remote_show()
824 return -ENODEV; in associate_remote_store()
826 mutex_lock(&ictx->lock); in associate_remote_store()
827 ictx->rf_isassociating = true; in associate_remote_store()
829 mutex_unlock(&ictx->lock); in associate_remote_store()
844 return -ENODEV; in imon_clock_show()
846 mutex_lock(&ictx->lock); in imon_clock_show()
848 if (!ictx->display_supported) { in imon_clock_show()
854 "%s", ictx->display_isopen ? in imon_clock_show()
858 mutex_unlock(&ictx->lock); in imon_clock_show()
872 return -ENODEV; in imon_clock_store()
874 mutex_lock(&ictx->lock); in imon_clock_store()
876 if (!ictx->display_supported) { in imon_clock_store()
877 retval = -ENODEV; in imon_clock_store()
879 } else if (ictx->display_isopen) { in imon_clock_store()
880 retval = -EBUSY; in imon_clock_store()
886 retval = -EINVAL; in imon_clock_store()
893 retval = -EINVAL; in imon_clock_store()
904 mutex_unlock(&ictx->lock); in imon_clock_store()
949 struct imon_context *ictx = file->private_data; in vfd_write()
953 if (ictx->disconnected) in vfd_write()
954 return -ENODEV; in vfd_write()
956 mutex_lock(&ictx->lock); in vfd_write()
958 if (!ictx->dev_present_intf0) { in vfd_write()
960 retval = -ENODEV; in vfd_write()
966 retval = -EINVAL; in vfd_write()
970 if (copy_from_user(ictx->tx.data_buf, buf, n_bytes)) { in vfd_write()
971 retval = -EFAULT; in vfd_write()
977 ictx->tx.data_buf[i] = ' '; in vfd_write()
980 ictx->tx.data_buf[i] = 0xFF; in vfd_write()
986 memcpy(ictx->usb_tx_buf, ictx->tx.data_buf + offset, 7); in vfd_write()
987 ictx->usb_tx_buf[7] = (unsigned char) seq; in vfd_write()
1001 memcpy(ictx->usb_tx_buf, &vfd_packet6, sizeof(vfd_packet6)); in vfd_write()
1002 ictx->usb_tx_buf[7] = (unsigned char) seq; in vfd_write()
1008 mutex_unlock(&ictx->lock); in vfd_write()
1014 * Writes data to the LCD. The iMON OEM LCD screen expects 8-byte
1016 * newline (to make it easy to drive the device from a command-line
1017 * -- even though the actual binary data is a bit complicated).
1019 * The device itself is not a "traditional" text-mode display. It's
1030 struct imon_context *ictx = file->private_data; in lcd_write()
1032 if (ictx->disconnected) in lcd_write()
1033 return -ENODEV; in lcd_write()
1035 mutex_lock(&ictx->lock); in lcd_write()
1037 if (!ictx->display_supported) { in lcd_write()
1039 retval = -ENODEV; in lcd_write()
1046 retval = -EINVAL; in lcd_write()
1050 if (copy_from_user(ictx->usb_tx_buf, buf, 8)) { in lcd_write()
1051 retval = -EFAULT; in lcd_write()
1060 dev_dbg(ictx->dev, "%s: write %d bytes to LCD\n", in lcd_write()
1064 mutex_unlock(&ictx->lock); in lcd_write()
1077 ictx = (struct imon_context *)urb->context; in usb_tx_callback()
1081 ictx->tx.status = urb->status; in usb_tx_callback()
1084 ictx->tx.busy = false; in usb_tx_callback()
1086 complete(&ictx->tx.finished); in usb_tx_callback()
1096 if (ictx->display_type != IMON_DISPLAY_TYPE_VGA) in imon_touch_display_timeout()
1099 input_report_abs(ictx->touch, ABS_X, ictx->touch_x); in imon_touch_display_timeout()
1100 input_report_abs(ictx->touch, ABS_Y, ictx->touch_y); in imon_touch_display_timeout()
1101 input_report_key(ictx->touch, BTN_TOUCH, 0x00); in imon_touch_display_timeout()
1102 input_sync(ictx->touch); in imon_touch_display_timeout()
1106 * iMON IR receivers support two different signal sets -- those used by
1108 * really just RC-6), but only one or the other at a time, as the signals
1113 * via a userspace-initiated protocol change request, either by direct sysfs
1114 * prodding or by something like ir-keytable. In the rc_register_device case,
1122 struct imon_context *ictx = rc->priv; in imon_ir_change_protocol()
1123 struct device *dev = ictx->dev; in imon_ir_change_protocol()
1128 if (*rc_proto && !(*rc_proto & rc->allowed_protocols)) in imon_ir_change_protocol()
1149 memcpy(ictx->usb_tx_buf, &ir_proto_packet, sizeof(ir_proto_packet)); in imon_ir_change_protocol()
1151 if (!mutex_is_locked(&ictx->lock)) { in imon_ir_change_protocol()
1153 mutex_lock(&ictx->lock); in imon_ir_change_protocol()
1160 ictx->rc_proto = *rc_proto; in imon_ir_change_protocol()
1161 ictx->pad_mouse = false; in imon_ir_change_protocol()
1165 mutex_unlock(&ictx->lock); in imon_ir_change_protocol()
1185 long msec, msec_hit; in stabilize()
1220 y -= 17 * threshold / 30; in stabilize()
1226 x -= 17 * threshold / 30; in stabilize()
1251 /* Look for the initial press of a button */ in imon_remote_key_lookup()
1252 keycode = rc_g_keycode_from_table(ictx->rdev, scancode); in imon_remote_key_lookup()
1253 ictx->rc_toggle = 0x0; in imon_remote_key_lookup()
1254 ictx->rc_scancode = scancode; in imon_remote_key_lookup()
1259 keycode = rc_g_keycode_from_table(ictx->rdev, release); in imon_remote_key_lookup()
1264 ictx->release_code = is_release_code; in imon_remote_key_lookup()
1287 ictx->rc_scancode = scancode; in imon_mce_key_lookup()
1288 keycode = rc_g_keycode_from_table(ictx->rdev, scancode); in imon_mce_key_lookup()
1291 ictx->release_code = false; in imon_mce_key_lookup()
1302 key_table = ictx->dev_descr->key_table; in imon_panel_key_lookup()
1310 ictx->release_code = false; in imon_panel_key_lookup()
1321 unsigned long flags; in imon_mouse_event()
1323 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_mouse_event()
1326 if (ictx->product != 0xffdc && (buf[0] & 0x01) && len == 5) { in imon_mouse_event()
1331 } else if (ictx->product == 0xffdc && (buf[0] & 0x40) && in imon_mouse_event()
1345 } else if (ictx->product == 0xffdc && (buf[0] == 0x68)) { in imon_mouse_event()
1347 /* ch+/- buttons, which we use for an emulated scroll wheel */ in imon_mouse_event()
1348 } else if (ictx->kc == KEY_CHANNELUP && (buf[2] & 0x40) != 0x40) { in imon_mouse_event()
1350 } else if (ictx->kc == KEY_CHANNELDOWN && (buf[2] & 0x40) != 0x40) { in imon_mouse_event()
1351 dir = -1; in imon_mouse_event()
1355 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_mouse_event()
1358 dev_dbg(ictx->dev, "sending mouse data via input subsystem\n"); in imon_mouse_event()
1361 input_report_rel(ictx->idev, REL_WHEEL, dir); in imon_mouse_event()
1363 input_report_rel(ictx->idev, REL_X, rel_x); in imon_mouse_event()
1364 input_report_rel(ictx->idev, REL_Y, rel_y); in imon_mouse_event()
1366 input_report_key(ictx->idev, BTN_LEFT, buf[1] & 0x1); in imon_mouse_event()
1367 input_report_key(ictx->idev, BTN_RIGHT, in imon_mouse_event()
1370 input_sync(ictx->idev); in imon_mouse_event()
1371 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_mouse_event()
1372 ictx->last_keycode = ictx->kc; in imon_mouse_event()
1373 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_mouse_event()
1381 mod_timer(&ictx->ttimer, jiffies + TOUCH_TIMEOUT); in imon_touch_event()
1382 ictx->touch_x = (buf[0] << 4) | (buf[1] >> 4); in imon_touch_event()
1383 ictx->touch_y = 0xfff - ((buf[2] << 4) | (buf[1] & 0xf)); in imon_touch_event()
1384 input_report_abs(ictx->touch, ABS_X, ictx->touch_x); in imon_touch_event()
1385 input_report_abs(ictx->touch, ABS_Y, ictx->touch_y); in imon_touch_event()
1386 input_report_key(ictx->touch, BTN_TOUCH, 0x01); in imon_touch_event()
1387 input_sync(ictx->touch); in imon_touch_event()
1396 unsigned long flags; in imon_pad_to_keys()
1401 * from -14 to 14. We want to down-sample this to only 4 discrete values in imon_pad_to_keys()
1406 if (ictx->product != 0xffdc) { in imon_pad_to_keys()
1415 if (ictx->rc_proto == RC_PROTO_BIT_IMON && pad_stabilize) { in imon_pad_to_keys()
1420 spin_lock_irqsave(&ictx->kc_lock, in imon_pad_to_keys()
1422 ictx->kc = KEY_UNKNOWN; in imon_pad_to_keys()
1423 spin_unlock_irqrestore(&ictx->kc_lock, in imon_pad_to_keys()
1434 * to use hard-coded scancodes here... in imon_pad_to_keys()
1454 * Handle on-board decoded pad events for e.g. older VFD/iMON-Pad in imon_pad_to_keys()
1482 if (ictx->rc_proto == RC_PROTO_BIT_IMON && pad_stabilize) { in imon_pad_to_keys()
1486 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_pad_to_keys()
1487 ictx->kc = KEY_UNKNOWN; in imon_pad_to_keys()
1488 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_pad_to_keys()
1497 * to use hard-coded scancodes here... in imon_pad_to_keys()
1518 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_pad_to_keys()
1519 ictx->kc = imon_remote_key_lookup(ictx, scancode); in imon_pad_to_keys()
1520 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_pad_to_keys()
1525 * figure out if these is a press or a release. We don't actually
1526 * care about repeats, as those will be auto-generated within the IR
1533 unsigned long flags; in imon_parse_press_type()
1535 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_parse_press_type()
1538 if (ictx->kc == KEY_RESERVED && buf[0] == 0x02 && buf[3] == 0x00) in imon_parse_press_type()
1539 ictx->kc = ictx->last_keycode; in imon_parse_press_type()
1542 else if (ictx->kc == KEY_RESERVED && buf[0] == 0x68 && buf[1] == 0x82 && in imon_parse_press_type()
1544 ictx->kc = ictx->last_keycode; in imon_parse_press_type()
1547 else if (ictx->kc == KEY_RESERVED && buf[0] == 0x01 && buf[1] == 0x00 && in imon_parse_press_type()
1549 ictx->kc = ictx->last_keycode; in imon_parse_press_type()
1551 /* mce-specific button handling, no keyup events */ in imon_parse_press_type()
1553 ictx->rc_toggle = buf[2]; in imon_parse_press_type()
1557 } else if (ictx->kc == KEY_RESERVED) in imon_parse_press_type()
1558 press_type = -EINVAL; in imon_parse_press_type()
1561 else if (ictx->release_code) in imon_parse_press_type()
1564 /* this is a button press */ in imon_parse_press_type()
1568 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_parse_press_type()
1579 int len = urb->actual_length; in imon_incoming_packet()
1580 unsigned char *buf = urb->transfer_buffer; in imon_incoming_packet()
1581 struct device *dev = ictx->dev; in imon_incoming_packet()
1582 unsigned long flags; in imon_incoming_packet()
1599 ictx->release_code = false; in imon_incoming_packet()
1602 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE) { in imon_incoming_packet()
1613 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_incoming_packet()
1615 if (kc == KEY_KEYBOARD && !ictx->release_code) { in imon_incoming_packet()
1616 ictx->last_keycode = kc; in imon_incoming_packet()
1618 ictx->pad_mouse = !ictx->pad_mouse; in imon_incoming_packet()
1620 ictx->pad_mouse ? "mouse" : "keyboard"); in imon_incoming_packet()
1621 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1624 ictx->pad_mouse = false; in imon_incoming_packet()
1629 ictx->kc = kc; in imon_incoming_packet()
1630 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1633 if (ictx->touch && len == 8 && buf[7] == 0x86) { in imon_incoming_packet()
1638 } else if (ictx->pad_mouse) { in imon_incoming_packet()
1662 rc_keyup(ictx->rdev); in imon_incoming_packet()
1666 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE) in imon_incoming_packet()
1668 else if (ictx->rc_proto == RC_PROTO_BIT_IMON) in imon_incoming_packet()
1673 rc_keydown(ictx->rdev, proto, ictx->rc_scancode, in imon_incoming_packet()
1674 ictx->rc_toggle); in imon_incoming_packet()
1676 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_incoming_packet()
1677 ictx->last_keycode = ictx->kc; in imon_incoming_packet()
1678 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1684 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_incoming_packet()
1688 if (ictx->kc == KEY_MUTE || in imon_incoming_packet()
1689 ictx->dev_descr->flags & IMON_SUPPRESS_REPEATED_KEYS) { in imon_incoming_packet()
1690 if (ictx->kc == ictx->last_keycode && in imon_incoming_packet()
1691 ktime_ms_delta(t, prev_time) < ictx->idev->rep[REP_DELAY]) { in imon_incoming_packet()
1692 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1698 kc = ictx->kc; in imon_incoming_packet()
1700 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1702 input_report_key(ictx->idev, kc, press_type); in imon_incoming_packet()
1703 input_sync(ictx->idev); in imon_incoming_packet()
1706 input_report_key(ictx->idev, kc, 0); in imon_incoming_packet()
1707 input_sync(ictx->idev); in imon_incoming_packet()
1709 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_incoming_packet()
1710 ictx->last_keycode = kc; in imon_incoming_packet()
1711 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1732 ictx->rf_isassociating = false; in imon_incoming_packet()
1747 ictx = (struct imon_context *)urb->context; in usb_rx_callback_intf0()
1756 if (!ictx->dev_present_intf0) in usb_rx_callback_intf0()
1759 switch (urb->status) { in usb_rx_callback_intf0()
1760 case -ENOENT: /* usbcore unlink successful! */ in usb_rx_callback_intf0()
1763 case -ESHUTDOWN: /* transport endpoint was shut down */ in usb_rx_callback_intf0()
1771 dev_warn(ictx->dev, "imon %s: status(%d): ignored\n", in usb_rx_callback_intf0()
1772 __func__, urb->status); in usb_rx_callback_intf0()
1777 usb_submit_urb(ictx->rx_urb_intf0, GFP_ATOMIC); in usb_rx_callback_intf0()
1788 ictx = (struct imon_context *)urb->context; in usb_rx_callback_intf1()
1797 if (!ictx->dev_present_intf1) in usb_rx_callback_intf1()
1800 switch (urb->status) { in usb_rx_callback_intf1()
1801 case -ENOENT: /* usbcore unlink successful! */ in usb_rx_callback_intf1()
1804 case -ESHUTDOWN: /* transport endpoint was shut down */ in usb_rx_callback_intf1()
1812 dev_warn(ictx->dev, "imon %s: status(%d): ignored\n", in usb_rx_callback_intf1()
1813 __func__, urb->status); in usb_rx_callback_intf1()
1818 usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC); in usb_rx_callback_intf1()
1827 * actually supports. These devices have their IR protocol hard-coded into
1832 u8 ffdc_cfg_byte = ictx->usb_rx_buf[6]; in imon_get_ffdc_type()
1839 dev_info(ictx->dev, "0xffdc iMON Knob, iMON IR"); in imon_get_ffdc_type()
1840 ictx->display_supported = false; in imon_get_ffdc_type()
1844 dev_info(ictx->dev, "0xffdc iMON 2.4G LT, iMON RF"); in imon_get_ffdc_type()
1845 ictx->display_supported = false; in imon_get_ffdc_type()
1846 ictx->rf_device = true; in imon_get_ffdc_type()
1850 dev_info(ictx->dev, "0xffdc iMON VFD + knob, no IR"); in imon_get_ffdc_type()
1857 dev_info(ictx->dev, "0xffdc iMON VFD, iMON IR"); in imon_get_ffdc_type()
1863 dev_info(ictx->dev, "0xffdc iMON VFD, MCE IR"); in imon_get_ffdc_type()
1869 dev_info(ictx->dev, "0xffdc iMON VFD, iMON or MCE IR"); in imon_get_ffdc_type()
1875 dev_info(ictx->dev, "0xffdc iMON LCD, MCE IR"); in imon_get_ffdc_type()
1881 dev_info(ictx->dev, "0xffdc iMON Inside, iMON IR"); in imon_get_ffdc_type()
1882 ictx->display_supported = false; in imon_get_ffdc_type()
1886 dev_info(ictx->dev, "0xffdc iMON UltraBay, LCD + IR"); in imon_get_ffdc_type()
1889 ictx->dev_descr = &ultrabay_table; in imon_get_ffdc_type()
1893 dev_info(ictx->dev, "Unknown 0xffdc device, defaulting to VFD and iMON IR"); in imon_get_ffdc_type()
1905 ictx->display_type = detected_display_type; in imon_get_ffdc_type()
1906 ictx->rc_proto = allowed_protos; in imon_get_ffdc_type()
1914 * Try to auto-detect the type of display if the user hasn't set in imon_set_display_type()
1919 switch (ictx->product) { in imon_set_display_type()
1922 configured_display_type = ictx->display_type; in imon_set_display_type()
1938 ictx->display_supported = false; in imon_set_display_type()
1949 ictx->display_supported = false; in imon_set_display_type()
1951 ictx->display_supported = true; in imon_set_display_type()
1952 dev_info(ictx->dev, "%s: overriding display type to %d via modparam\n", in imon_set_display_type()
1956 ictx->display_type = configured_display_type; in imon_set_display_type()
1968 dev_err(ictx->dev, "remote control dev allocation failed\n"); in imon_init_rdev()
1972 snprintf(ictx->name_rdev, sizeof(ictx->name_rdev), in imon_init_rdev()
1973 "iMON Remote (%04x:%04x)", ictx->vendor, ictx->product); in imon_init_rdev()
1974 usb_make_path(ictx->usbdev_intf0, ictx->phys_rdev, in imon_init_rdev()
1975 sizeof(ictx->phys_rdev)); in imon_init_rdev()
1976 strlcat(ictx->phys_rdev, "/input0", sizeof(ictx->phys_rdev)); in imon_init_rdev()
1978 rdev->device_name = ictx->name_rdev; in imon_init_rdev()
1979 rdev->input_phys = ictx->phys_rdev; in imon_init_rdev()
1980 usb_to_input_id(ictx->usbdev_intf0, &rdev->input_id); in imon_init_rdev()
1981 rdev->dev.parent = ictx->dev; in imon_init_rdev()
1983 rdev->priv = ictx; in imon_init_rdev()
1985 rdev->allowed_protocols = RC_PROTO_BIT_IMON | RC_PROTO_BIT_RC6_MCE; in imon_init_rdev()
1986 rdev->change_protocol = imon_ir_change_protocol; in imon_init_rdev()
1987 rdev->driver_name = MOD_NAME; in imon_init_rdev()
1989 /* Enable front-panel buttons and/or knobs */ in imon_init_rdev()
1990 memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet)); in imon_init_rdev()
1994 dev_info(ictx->dev, "panel buttons/knobs setup failed\n"); in imon_init_rdev()
1996 if (ictx->product == 0xffdc) { in imon_init_rdev()
1998 rdev->allowed_protocols = ictx->rc_proto; in imon_init_rdev()
2003 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE) in imon_init_rdev()
2004 rdev->map_name = RC_MAP_IMON_MCE; in imon_init_rdev()
2006 rdev->map_name = RC_MAP_IMON_PAD; in imon_init_rdev()
2010 dev_err(ictx->dev, "remote input dev register failed\n"); in imon_init_rdev()
2027 key_table = ictx->dev_descr->key_table; in imon_init_idev()
2033 snprintf(ictx->name_idev, sizeof(ictx->name_idev), in imon_init_idev()
2035 ictx->vendor, ictx->product); in imon_init_idev()
2036 idev->name = ictx->name_idev; in imon_init_idev()
2038 usb_make_path(ictx->usbdev_intf0, ictx->phys_idev, in imon_init_idev()
2039 sizeof(ictx->phys_idev)); in imon_init_idev()
2040 strlcat(ictx->phys_idev, "/input1", sizeof(ictx->phys_idev)); in imon_init_idev()
2041 idev->phys = ictx->phys_idev; in imon_init_idev()
2043 idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_REL); in imon_init_idev()
2045 idev->keybit[BIT_WORD(BTN_MOUSE)] = in imon_init_idev()
2047 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y) | in imon_init_idev()
2053 __set_bit(kc, idev->keybit); in imon_init_idev()
2056 usb_to_input_id(ictx->usbdev_intf0, &idev->id); in imon_init_idev()
2057 idev->dev.parent = ictx->dev; in imon_init_idev()
2062 dev_err(ictx->dev, "input dev register failed\n"); in imon_init_idev()
2082 snprintf(ictx->name_touch, sizeof(ictx->name_touch), in imon_init_touch()
2084 ictx->vendor, ictx->product); in imon_init_touch()
2085 touch->name = ictx->name_touch; in imon_init_touch()
2087 usb_make_path(ictx->usbdev_intf1, ictx->phys_touch, in imon_init_touch()
2088 sizeof(ictx->phys_touch)); in imon_init_touch()
2089 strlcat(ictx->phys_touch, "/input2", sizeof(ictx->phys_touch)); in imon_init_touch()
2090 touch->phys = ictx->phys_touch; in imon_init_touch()
2092 touch->evbit[0] = in imon_init_touch()
2094 touch->keybit[BIT_WORD(BTN_TOUCH)] = in imon_init_touch()
2103 usb_to_input_id(ictx->usbdev_intf1, &touch->id); in imon_init_touch()
2104 touch->dev.parent = ictx->dev; in imon_init_touch()
2107 dev_info(ictx->dev, "touchscreen input dev register failed\n"); in imon_init_touch()
2126 int ifnum = iface_desc->desc.bInterfaceNumber; in imon_find_endpoints()
2127 int num_endpts = iface_desc->desc.bNumEndpoints; in imon_find_endpoints()
2139 ep = &iface_desc->endpoint[i].desc; in imon_find_endpoints()
2140 ep_dir = ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK; in imon_find_endpoints()
2148 dev_dbg(ictx->dev, "%s: found IR endpoint\n", __func__); in imon_find_endpoints()
2154 dev_dbg(ictx->dev, "%s: found display endpoint\n", __func__); in imon_find_endpoints()
2159 ictx->rx_endpoint_intf0 = rx_endpoint; in imon_find_endpoints()
2164 ictx->tx_endpoint = tx_endpoint; in imon_find_endpoints()
2166 ictx->rx_endpoint_intf1 = rx_endpoint; in imon_find_endpoints()
2176 dev_dbg(ictx->dev, "%s: device uses control endpoint, not interface OUT endpoint\n", in imon_find_endpoints()
2185 if (ictx->display_type == IMON_DISPLAY_TYPE_NONE) { in imon_find_endpoints()
2187 dev_dbg(ictx->dev, "%s: device has no display\n", __func__); in imon_find_endpoints()
2194 if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { in imon_find_endpoints()
2196 dev_dbg(ictx->dev, "%s: iMON Touch device found\n", __func__); in imon_find_endpoints()
2203 ictx->tx_control = tx_control; in imon_find_endpoints()
2206 ictx->display_supported = true; in imon_find_endpoints()
2218 struct device *dev = &intf->dev; in imon_init_intf0()
2220 int ret = -ENOMEM; in imon_init_intf0()
2233 mutex_init(&ictx->lock); in imon_init_intf0()
2234 spin_lock_init(&ictx->kc_lock); in imon_init_intf0()
2236 mutex_lock(&ictx->lock); in imon_init_intf0()
2238 ictx->dev = dev; in imon_init_intf0()
2239 ictx->usbdev_intf0 = usb_get_dev(interface_to_usbdev(intf)); in imon_init_intf0()
2240 ictx->rx_urb_intf0 = rx_urb; in imon_init_intf0()
2241 ictx->tx_urb = tx_urb; in imon_init_intf0()
2242 ictx->rf_device = false; in imon_init_intf0()
2244 init_completion(&ictx->tx.finished); in imon_init_intf0()
2246 ictx->vendor = le16_to_cpu(ictx->usbdev_intf0->descriptor.idVendor); in imon_init_intf0()
2247 ictx->product = le16_to_cpu(ictx->usbdev_intf0->descriptor.idProduct); in imon_init_intf0()
2250 ictx->dev_descr = (struct imon_usb_dev_descr *)id->driver_info; in imon_init_intf0()
2251 /* default send_packet delay is 5ms but some devices need more */ in imon_init_intf0()
2252 ictx->send_packet_delay = ictx->dev_descr->flags & in imon_init_intf0()
2255 ret = -ENODEV; in imon_init_intf0()
2256 iface_desc = intf->cur_altsetting; in imon_init_intf0()
2261 usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, in imon_init_intf0()
2262 usb_rcvintpipe(ictx->usbdev_intf0, in imon_init_intf0()
2263 ictx->rx_endpoint_intf0->bEndpointAddress), in imon_init_intf0()
2264 ictx->usb_rx_buf, sizeof(ictx->usb_rx_buf), in imon_init_intf0()
2266 ictx->rx_endpoint_intf0->bInterval); in imon_init_intf0()
2268 ret = usb_submit_urb(ictx->rx_urb_intf0, GFP_KERNEL); in imon_init_intf0()
2274 ictx->idev = imon_init_idev(ictx); in imon_init_intf0()
2275 if (!ictx->idev) { in imon_init_intf0()
2280 ictx->rdev = imon_init_rdev(ictx); in imon_init_intf0()
2281 if (!ictx->rdev) { in imon_init_intf0()
2286 ictx->dev_present_intf0 = true; in imon_init_intf0()
2288 mutex_unlock(&ictx->lock); in imon_init_intf0()
2292 input_unregister_device(ictx->idev); in imon_init_intf0()
2294 usb_kill_urb(ictx->rx_urb_intf0); in imon_init_intf0()
2297 usb_put_dev(ictx->usbdev_intf0); in imon_init_intf0()
2298 mutex_unlock(&ictx->lock); in imon_init_intf0()
2315 int ret = -ENOMEM; in imon_init_intf1()
2321 mutex_lock(&ictx->lock); in imon_init_intf1()
2323 if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { in imon_init_intf1()
2324 timer_setup(&ictx->ttimer, imon_touch_display_timeout, 0); in imon_init_intf1()
2327 ictx->usbdev_intf1 = usb_get_dev(interface_to_usbdev(intf)); in imon_init_intf1()
2328 ictx->rx_urb_intf1 = rx_urb; in imon_init_intf1()
2330 ret = -ENODEV; in imon_init_intf1()
2331 iface_desc = intf->cur_altsetting; in imon_init_intf1()
2335 if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { in imon_init_intf1()
2336 ictx->touch = imon_init_touch(ictx); in imon_init_intf1()
2337 if (!ictx->touch) in imon_init_intf1()
2340 ictx->touch = NULL; in imon_init_intf1()
2342 usb_fill_int_urb(ictx->rx_urb_intf1, ictx->usbdev_intf1, in imon_init_intf1()
2343 usb_rcvintpipe(ictx->usbdev_intf1, in imon_init_intf1()
2344 ictx->rx_endpoint_intf1->bEndpointAddress), in imon_init_intf1()
2345 ictx->usb_rx_buf, sizeof(ictx->usb_rx_buf), in imon_init_intf1()
2347 ictx->rx_endpoint_intf1->bInterval); in imon_init_intf1()
2349 ret = usb_submit_urb(ictx->rx_urb_intf1, GFP_KERNEL); in imon_init_intf1()
2356 ictx->dev_present_intf1 = true; in imon_init_intf1()
2358 mutex_unlock(&ictx->lock); in imon_init_intf1()
2362 if (ictx->touch) in imon_init_intf1()
2363 input_unregister_device(ictx->touch); in imon_init_intf1()
2366 usb_put_dev(ictx->usbdev_intf1); in imon_init_intf1()
2367 ictx->usbdev_intf1 = NULL; in imon_init_intf1()
2368 mutex_unlock(&ictx->lock); in imon_init_intf1()
2370 ictx->rx_urb_intf1 = NULL; in imon_init_intf1()
2372 dev_err(ictx->dev, "unable to initialize intf1, err %d\n", ret); in imon_init_intf1()
2382 dev_dbg(ictx->dev, "Registering iMON display with sysfs\n"); in imon_init_display()
2384 /* set up sysfs entry for built-in clock */ in imon_init_display()
2385 ret = sysfs_create_group(&intf->dev.kobj, &imon_display_attr_group); in imon_init_display()
2387 dev_err(ictx->dev, "Could not create display sysfs entries(%d)", in imon_init_display()
2390 if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) in imon_init_display()
2396 dev_info(ictx->dev, "could not get a minor number for display\n"); in imon_init_display()
2409 struct device *dev = &interface->dev; in imon_probe()
2416 iface_desc = interface->cur_altsetting; in imon_probe()
2417 ifnum = iface_desc->desc.bInterfaceNumber; in imon_probe()
2418 vendor = le16_to_cpu(usbdev->descriptor.idVendor); in imon_probe()
2419 product = le16_to_cpu(usbdev->descriptor.idProduct); in imon_probe()
2426 ret = -ENODEV; in imon_probe()
2434 ret = -ENODEV; in imon_probe()
2437 refcount_set(&ictx->users, 1); in imon_probe()
2445 ret = -ENODEV; in imon_probe()
2452 ret = -ENODEV; in imon_probe()
2455 refcount_inc(&ictx->users); in imon_probe()
2462 if (product == 0xffdc && ictx->rf_device) { in imon_probe()
2463 sysfs_err = sysfs_create_group(&interface->dev.kobj, in imon_probe()
2470 if (ictx->display_supported) in imon_probe()
2476 usbdev->bus->busnum, usbdev->devnum); in imon_probe()
2499 ictx->disconnected = true; in imon_disconnect()
2500 dev = ictx->dev; in imon_disconnect()
2501 ifnum = interface->cur_altsetting->desc.bInterfaceNumber; in imon_disconnect()
2507 sysfs_remove_group(&interface->dev.kobj, &imon_display_attr_group); in imon_disconnect()
2508 sysfs_remove_group(&interface->dev.kobj, &imon_rf_attr_group); in imon_disconnect()
2513 if (ictx->tx.busy) { in imon_disconnect()
2514 usb_kill_urb(ictx->tx_urb); in imon_disconnect()
2515 complete(&ictx->tx.finished); in imon_disconnect()
2519 ictx->dev_present_intf0 = false; in imon_disconnect()
2520 usb_kill_urb(ictx->rx_urb_intf0); in imon_disconnect()
2521 input_unregister_device(ictx->idev); in imon_disconnect()
2522 rc_unregister_device(ictx->rdev); in imon_disconnect()
2523 if (ictx->display_supported) { in imon_disconnect()
2524 if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) in imon_disconnect()
2526 else if (ictx->display_type == IMON_DISPLAY_TYPE_VFD) in imon_disconnect()
2529 usb_put_dev(ictx->usbdev_intf0); in imon_disconnect()
2531 ictx->dev_present_intf1 = false; in imon_disconnect()
2532 usb_kill_urb(ictx->rx_urb_intf1); in imon_disconnect()
2533 if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { in imon_disconnect()
2534 del_timer_sync(&ictx->ttimer); in imon_disconnect()
2535 input_unregister_device(ictx->touch); in imon_disconnect()
2537 usb_put_dev(ictx->usbdev_intf1); in imon_disconnect()
2540 if (refcount_dec_and_test(&ictx->users)) in imon_disconnect()
2550 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in imon_suspend()
2553 usb_kill_urb(ictx->rx_urb_intf0); in imon_suspend()
2555 usb_kill_urb(ictx->rx_urb_intf1); in imon_suspend()
2564 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in imon_resume()
2567 usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, in imon_resume()
2568 usb_rcvintpipe(ictx->usbdev_intf0, in imon_resume()
2569 ictx->rx_endpoint_intf0->bEndpointAddress), in imon_resume()
2570 ictx->usb_rx_buf, sizeof(ictx->usb_rx_buf), in imon_resume()
2572 ictx->rx_endpoint_intf0->bInterval); in imon_resume()
2574 rc = usb_submit_urb(ictx->rx_urb_intf0, GFP_NOIO); in imon_resume()
2577 usb_fill_int_urb(ictx->rx_urb_intf1, ictx->usbdev_intf1, in imon_resume()
2578 usb_rcvintpipe(ictx->usbdev_intf1, in imon_resume()
2579 ictx->rx_endpoint_intf1->bEndpointAddress), in imon_resume()
2580 ictx->usb_rx_buf, sizeof(ictx->usb_rx_buf), in imon_resume()
2582 ictx->rx_endpoint_intf1->bInterval); in imon_resume()
2584 rc = usb_submit_urb(ictx->rx_urb_intf1, GFP_NOIO); in imon_resume()