Lines Matching +full:touch +full:- +full:keys
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 */
129 struct input_dev *touch; /* input device for touchscreen */ member
137 bool release_code; /* some keys send a release code */
148 char name_touch[128]; /* touch screen name */
149 char phys_touch[64]; /* touch screen phys path */
150 struct timer_list ttimer; /* touch screen timer */
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
390 /* SoundGraph iMON OEM Touch LCD (IR & 7" VGA LCD) */
393 /* SoundGraph iMON OEM Touch LCD (IR & 4.3" VGA LCD) */
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
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()
650 &ictx->tx.finished); in send_packet()
652 usb_kill_urb(ictx->tx_urb); in send_packet()
656 ictx->tx.busy = false; in send_packet()
657 retval = ictx->tx.status; in send_packet()
669 timeout = msecs_to_jiffies(ictx->send_packet_delay); in send_packet()
691 return -ENODEV; in send_associate_24g()
694 if (!ictx->dev_present_intf0) { in send_associate_24g()
696 return -ENODEV; in send_associate_24g()
699 memcpy(ictx->usb_tx_buf, packet, sizeof(packet)); in send_associate_24g()
707 * Arguments: year - last 2 digits of year, month - 1..12,
708 * day - 1..31, dow - day of the week (0-Sun...6-Sat),
709 * hour - 0..23, minute - 0..59, second - 0..59
723 return -ENODEV; in send_set_imon_clock()
726 switch (ictx->display_type) { in send_set_imon_clock()
730 clock_enable_pkt[0][2] = month-1; in send_set_imon_clock()
744 if (ictx->product == 0xffdc) { in send_set_imon_clock()
756 clock_enable_pkt[0][1] = month-1; in send_set_imon_clock()
776 return -ENODEV; in send_set_imon_clock()
780 memcpy(ictx->usb_tx_buf, clock_enable_pkt[i], 8); in send_set_imon_clock()
801 return -ENODEV; in associate_remote_show()
803 mutex_lock(&ictx->lock); in associate_remote_show()
804 if (ictx->rf_isassociating) in associate_remote_show()
809 …dev_info(d, "Visit https://www.lirc.org/html/imon-24g.html for instructions on how to associate yo… in associate_remote_show()
810 mutex_unlock(&ictx->lock); in associate_remote_show()
823 return -ENODEV; in associate_remote_store()
825 mutex_lock(&ictx->lock); in associate_remote_store()
826 ictx->rf_isassociating = true; in associate_remote_store()
828 mutex_unlock(&ictx->lock); in associate_remote_store()
843 return -ENODEV; in imon_clock_show()
845 mutex_lock(&ictx->lock); in imon_clock_show()
847 if (!ictx->display_supported) { in imon_clock_show()
853 "%s", ictx->display_isopen ? in imon_clock_show()
857 mutex_unlock(&ictx->lock); in imon_clock_show()
871 return -ENODEV; in imon_clock_store()
873 mutex_lock(&ictx->lock); in imon_clock_store()
875 if (!ictx->display_supported) { in imon_clock_store()
876 retval = -ENODEV; in imon_clock_store()
878 } else if (ictx->display_isopen) { in imon_clock_store()
879 retval = -EBUSY; in imon_clock_store()
885 retval = -EINVAL; in imon_clock_store()
892 retval = -EINVAL; in imon_clock_store()
903 mutex_unlock(&ictx->lock); in imon_clock_store()
948 struct imon_context *ictx = file->private_data; in vfd_write()
952 if (ictx->disconnected) in vfd_write()
953 return -ENODEV; in vfd_write()
955 if (mutex_lock_interruptible(&ictx->lock)) in vfd_write()
956 return -ERESTARTSYS; 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 unlock = mutex_trylock(&ictx->lock); in imon_ir_change_protocol()
1157 ictx->rc_proto = *rc_proto; in imon_ir_change_protocol()
1158 ictx->pad_mouse = false; in imon_ir_change_protocol()
1162 mutex_unlock(&ictx->lock); in imon_ir_change_protocol()
1217 y -= 17 * threshold / 30; in stabilize()
1223 x -= 17 * threshold / 30; in stabilize()
1249 keycode = rc_g_keycode_from_table(ictx->rdev, scancode); in imon_remote_key_lookup()
1250 ictx->rc_toggle = 0x0; in imon_remote_key_lookup()
1251 ictx->rc_scancode = scancode; in imon_remote_key_lookup()
1256 keycode = rc_g_keycode_from_table(ictx->rdev, release); in imon_remote_key_lookup()
1261 ictx->release_code = is_release_code; in imon_remote_key_lookup()
1274 * On some receivers, mce keys decode to 0x8000f04xx and 0x8000f84xx in imon_mce_key_lookup()
1278 * but we can't or them into all codes, as some keys are decoded in in imon_mce_key_lookup()
1284 ictx->rc_scancode = scancode; in imon_mce_key_lookup()
1285 keycode = rc_g_keycode_from_table(ictx->rdev, scancode); in imon_mce_key_lookup()
1288 ictx->release_code = false; in imon_mce_key_lookup()
1299 key_table = ictx->dev_descr->key_table; in imon_panel_key_lookup()
1307 ictx->release_code = false; in imon_panel_key_lookup()
1320 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_mouse_event()
1323 if (ictx->product != 0xffdc && (buf[0] & 0x01) && len == 5) { in imon_mouse_event()
1328 } else if (ictx->product == 0xffdc && (buf[0] & 0x40) && in imon_mouse_event()
1342 } else if (ictx->product == 0xffdc && (buf[0] == 0x68)) { in imon_mouse_event()
1344 /* ch+/- buttons, which we use for an emulated scroll wheel */ in imon_mouse_event()
1345 } else if (ictx->kc == KEY_CHANNELUP && (buf[2] & 0x40) != 0x40) { in imon_mouse_event()
1347 } else if (ictx->kc == KEY_CHANNELDOWN && (buf[2] & 0x40) != 0x40) { in imon_mouse_event()
1348 dir = -1; in imon_mouse_event()
1352 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_mouse_event()
1355 dev_dbg(ictx->dev, "sending mouse data via input subsystem\n"); in imon_mouse_event()
1358 input_report_rel(ictx->idev, REL_WHEEL, dir); in imon_mouse_event()
1360 input_report_rel(ictx->idev, REL_X, rel_x); in imon_mouse_event()
1361 input_report_rel(ictx->idev, REL_Y, rel_y); in imon_mouse_event()
1363 input_report_key(ictx->idev, BTN_LEFT, buf[1] & 0x1); in imon_mouse_event()
1364 input_report_key(ictx->idev, BTN_RIGHT, in imon_mouse_event()
1367 input_sync(ictx->idev); in imon_mouse_event()
1368 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_mouse_event()
1369 ictx->last_keycode = ictx->kc; in imon_mouse_event()
1370 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_mouse_event()
1378 mod_timer(&ictx->ttimer, jiffies + TOUCH_TIMEOUT); in imon_touch_event()
1379 ictx->touch_x = (buf[0] << 4) | (buf[1] >> 4); in imon_touch_event()
1380 ictx->touch_y = 0xfff - ((buf[2] << 4) | (buf[1] & 0xf)); in imon_touch_event()
1381 input_report_abs(ictx->touch, ABS_X, ictx->touch_x); in imon_touch_event()
1382 input_report_abs(ictx->touch, ABS_Y, ictx->touch_y); in imon_touch_event()
1383 input_report_key(ictx->touch, BTN_TOUCH, 0x01); in imon_touch_event()
1384 input_sync(ictx->touch); in imon_touch_event()
1398 * from -14 to 14. We want to down-sample this to only 4 discrete values in imon_pad_to_keys()
1399 * for up/down/left/right arrow keys. Also, when you get too close to in imon_pad_to_keys()
1403 if (ictx->product != 0xffdc) { in imon_pad_to_keys()
1412 if (ictx->rc_proto == RC_PROTO_BIT_IMON && pad_stabilize) { in imon_pad_to_keys()
1417 spin_lock_irqsave(&ictx->kc_lock, in imon_pad_to_keys()
1419 ictx->kc = KEY_UNKNOWN; in imon_pad_to_keys()
1420 spin_unlock_irqrestore(&ictx->kc_lock, in imon_pad_to_keys()
1431 * to use hard-coded scancodes here... in imon_pad_to_keys()
1451 * Handle on-board decoded pad events for e.g. older VFD/iMON-Pad in imon_pad_to_keys()
1454 * 0x688301b7 and the right one 0x688481b7. All other keys generate in imon_pad_to_keys()
1479 if (ictx->rc_proto == RC_PROTO_BIT_IMON && pad_stabilize) { in imon_pad_to_keys()
1483 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_pad_to_keys()
1484 ictx->kc = KEY_UNKNOWN; in imon_pad_to_keys()
1485 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_pad_to_keys()
1494 * to use hard-coded scancodes here... in imon_pad_to_keys()
1515 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_pad_to_keys()
1516 ictx->kc = imon_remote_key_lookup(ictx, scancode); in imon_pad_to_keys()
1517 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_pad_to_keys()
1523 * care about repeats, as those will be auto-generated within the IR
1532 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_parse_press_type()
1535 if (ictx->kc == KEY_RESERVED && buf[0] == 0x02 && buf[3] == 0x00) in imon_parse_press_type()
1536 ictx->kc = ictx->last_keycode; in imon_parse_press_type()
1539 else if (ictx->kc == KEY_RESERVED && buf[0] == 0x68 && buf[1] == 0x82 && in imon_parse_press_type()
1541 ictx->kc = ictx->last_keycode; in imon_parse_press_type()
1544 else if (ictx->kc == KEY_RESERVED && buf[0] == 0x01 && buf[1] == 0x00 && in imon_parse_press_type()
1546 ictx->kc = ictx->last_keycode; in imon_parse_press_type()
1548 /* mce-specific button handling, no keyup events */ in imon_parse_press_type()
1550 ictx->rc_toggle = buf[2]; in imon_parse_press_type()
1554 } else if (ictx->kc == KEY_RESERVED) in imon_parse_press_type()
1555 press_type = -EINVAL; in imon_parse_press_type()
1558 else if (ictx->release_code) in imon_parse_press_type()
1565 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_parse_press_type()
1576 int len = urb->actual_length; in imon_incoming_packet()
1577 unsigned char *buf = urb->transfer_buffer; in imon_incoming_packet()
1578 struct device *dev = ictx->dev; in imon_incoming_packet()
1596 ictx->release_code = false; in imon_incoming_packet()
1599 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE) { in imon_incoming_packet()
1610 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_incoming_packet()
1612 if (kc == KEY_KEYBOARD && !ictx->release_code) { in imon_incoming_packet()
1613 ictx->last_keycode = kc; in imon_incoming_packet()
1615 ictx->pad_mouse = !ictx->pad_mouse; in imon_incoming_packet()
1617 ictx->pad_mouse ? "mouse" : "keyboard"); in imon_incoming_packet()
1618 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1621 ictx->pad_mouse = false; in imon_incoming_packet()
1626 ictx->kc = kc; in imon_incoming_packet()
1627 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1630 if (ictx->touch && len == 8 && buf[7] == 0x86) { in imon_incoming_packet()
1635 } else if (ictx->pad_mouse) { in imon_incoming_packet()
1640 /* Now for some special handling to convert pad input to arrow keys */ in imon_incoming_packet()
1659 rc_keyup(ictx->rdev); in imon_incoming_packet()
1663 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE) in imon_incoming_packet()
1665 else if (ictx->rc_proto == RC_PROTO_BIT_IMON) in imon_incoming_packet()
1670 rc_keydown(ictx->rdev, proto, ictx->rc_scancode, in imon_incoming_packet()
1671 ictx->rc_toggle); in imon_incoming_packet()
1673 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_incoming_packet()
1674 ictx->last_keycode = ictx->kc; in imon_incoming_packet()
1675 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1681 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_incoming_packet()
1685 if (ictx->kc == KEY_MUTE || in imon_incoming_packet()
1686 ictx->dev_descr->flags & IMON_SUPPRESS_REPEATED_KEYS) { in imon_incoming_packet()
1687 if (ictx->kc == ictx->last_keycode && in imon_incoming_packet()
1688 ktime_ms_delta(t, prev_time) < ictx->idev->rep[REP_DELAY]) { in imon_incoming_packet()
1689 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1695 kc = ictx->kc; in imon_incoming_packet()
1697 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1699 input_report_key(ictx->idev, kc, press_type); in imon_incoming_packet()
1700 input_sync(ictx->idev); in imon_incoming_packet()
1702 /* panel keys don't generate a release */ in imon_incoming_packet()
1703 input_report_key(ictx->idev, kc, 0); in imon_incoming_packet()
1704 input_sync(ictx->idev); in imon_incoming_packet()
1706 spin_lock_irqsave(&ictx->kc_lock, flags); in imon_incoming_packet()
1707 ictx->last_keycode = kc; in imon_incoming_packet()
1708 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_incoming_packet()
1729 ictx->rf_isassociating = false; in imon_incoming_packet()
1744 ictx = (struct imon_context *)urb->context; in usb_rx_callback_intf0()
1753 if (!ictx->dev_present_intf0) in usb_rx_callback_intf0()
1756 switch (urb->status) { in usb_rx_callback_intf0()
1757 case -ENOENT: /* usbcore unlink successful! */ in usb_rx_callback_intf0()
1760 case -ESHUTDOWN: /* transport endpoint was shut down */ in usb_rx_callback_intf0()
1768 dev_warn(ictx->dev, "imon %s: status(%d): ignored\n", in usb_rx_callback_intf0()
1769 __func__, urb->status); in usb_rx_callback_intf0()
1774 usb_submit_urb(ictx->rx_urb_intf0, GFP_ATOMIC); in usb_rx_callback_intf0()
1785 ictx = (struct imon_context *)urb->context; in usb_rx_callback_intf1()
1794 if (!ictx->dev_present_intf1) in usb_rx_callback_intf1()
1797 switch (urb->status) { in usb_rx_callback_intf1()
1798 case -ENOENT: /* usbcore unlink successful! */ in usb_rx_callback_intf1()
1801 case -ESHUTDOWN: /* transport endpoint was shut down */ in usb_rx_callback_intf1()
1809 dev_warn(ictx->dev, "imon %s: status(%d): ignored\n", in usb_rx_callback_intf1()
1810 __func__, urb->status); in usb_rx_callback_intf1()
1815 usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC); in usb_rx_callback_intf1()
1824 * actually supports. These devices have their IR protocol hard-coded into
1829 u8 ffdc_cfg_byte = ictx->usb_rx_buf[6]; in imon_get_ffdc_type()
1836 dev_info(ictx->dev, "0xffdc iMON Knob, iMON IR"); in imon_get_ffdc_type()
1837 ictx->display_supported = false; in imon_get_ffdc_type()
1841 dev_info(ictx->dev, "0xffdc iMON 2.4G LT, iMON RF"); in imon_get_ffdc_type()
1842 ictx->display_supported = false; in imon_get_ffdc_type()
1843 ictx->rf_device = true; in imon_get_ffdc_type()
1847 dev_info(ictx->dev, "0xffdc iMON VFD + knob, no IR"); in imon_get_ffdc_type()
1854 dev_info(ictx->dev, "0xffdc iMON VFD, iMON IR"); in imon_get_ffdc_type()
1860 dev_info(ictx->dev, "0xffdc iMON VFD, MCE IR"); in imon_get_ffdc_type()
1866 dev_info(ictx->dev, "0xffdc iMON VFD, iMON or MCE IR"); in imon_get_ffdc_type()
1872 dev_info(ictx->dev, "0xffdc iMON LCD, MCE IR"); in imon_get_ffdc_type()
1878 dev_info(ictx->dev, "0xffdc iMON Inside, iMON IR"); in imon_get_ffdc_type()
1879 ictx->display_supported = false; in imon_get_ffdc_type()
1883 dev_info(ictx->dev, "0xffdc iMON UltraBay, LCD + IR"); in imon_get_ffdc_type()
1886 ictx->dev_descr = &ultrabay_table; in imon_get_ffdc_type()
1890 dev_info(ictx->dev, "Unknown 0xffdc device, defaulting to VFD and iMON IR"); in imon_get_ffdc_type()
1902 ictx->display_type = detected_display_type; in imon_get_ffdc_type()
1903 ictx->rc_proto = allowed_protos; in imon_get_ffdc_type()
1911 * Try to auto-detect the type of display if the user hasn't set in imon_set_display_type()
1916 switch (ictx->product) { in imon_set_display_type()
1919 configured_display_type = ictx->display_type; in imon_set_display_type()
1935 ictx->display_supported = false; in imon_set_display_type()
1946 ictx->display_supported = false; in imon_set_display_type()
1948 ictx->display_supported = true; in imon_set_display_type()
1949 dev_info(ictx->dev, "%s: overriding display type to %d via modparam\n", in imon_set_display_type()
1953 ictx->display_type = configured_display_type; in imon_set_display_type()
1965 dev_err(ictx->dev, "remote control dev allocation failed\n"); in imon_init_rdev()
1969 snprintf(ictx->name_rdev, sizeof(ictx->name_rdev), in imon_init_rdev()
1970 "iMON Remote (%04x:%04x)", ictx->vendor, ictx->product); in imon_init_rdev()
1971 usb_make_path(ictx->usbdev_intf0, ictx->phys_rdev, in imon_init_rdev()
1972 sizeof(ictx->phys_rdev)); in imon_init_rdev()
1973 strlcat(ictx->phys_rdev, "/input0", sizeof(ictx->phys_rdev)); in imon_init_rdev()
1975 rdev->device_name = ictx->name_rdev; in imon_init_rdev()
1976 rdev->input_phys = ictx->phys_rdev; in imon_init_rdev()
1977 usb_to_input_id(ictx->usbdev_intf0, &rdev->input_id); in imon_init_rdev()
1978 rdev->dev.parent = ictx->dev; in imon_init_rdev()
1980 rdev->priv = ictx; in imon_init_rdev()
1982 rdev->allowed_protocols = RC_PROTO_BIT_IMON | RC_PROTO_BIT_RC6_MCE; in imon_init_rdev()
1983 rdev->change_protocol = imon_ir_change_protocol; in imon_init_rdev()
1984 rdev->driver_name = MOD_NAME; in imon_init_rdev()
1986 /* Enable front-panel buttons and/or knobs */ in imon_init_rdev()
1987 memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet)); in imon_init_rdev()
1991 dev_info(ictx->dev, "panel buttons/knobs setup failed\n"); in imon_init_rdev()
1993 if (ictx->product == 0xffdc) { in imon_init_rdev()
1995 rdev->allowed_protocols = ictx->rc_proto; in imon_init_rdev()
2000 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE) in imon_init_rdev()
2001 rdev->map_name = RC_MAP_IMON_MCE; in imon_init_rdev()
2003 rdev->map_name = RC_MAP_IMON_PAD; in imon_init_rdev()
2007 dev_err(ictx->dev, "remote input dev register failed\n"); in imon_init_rdev()
2024 key_table = ictx->dev_descr->key_table; in imon_init_idev()
2030 snprintf(ictx->name_idev, sizeof(ictx->name_idev), in imon_init_idev()
2032 ictx->vendor, ictx->product); in imon_init_idev()
2033 idev->name = ictx->name_idev; in imon_init_idev()
2035 usb_make_path(ictx->usbdev_intf0, ictx->phys_idev, in imon_init_idev()
2036 sizeof(ictx->phys_idev)); in imon_init_idev()
2037 strlcat(ictx->phys_idev, "/input1", sizeof(ictx->phys_idev)); in imon_init_idev()
2038 idev->phys = ictx->phys_idev; in imon_init_idev()
2040 idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_REL); in imon_init_idev()
2042 idev->keybit[BIT_WORD(BTN_MOUSE)] = in imon_init_idev()
2044 idev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y) | in imon_init_idev()
2050 __set_bit(kc, idev->keybit); in imon_init_idev()
2053 usb_to_input_id(ictx->usbdev_intf0, &idev->id); in imon_init_idev()
2054 idev->dev.parent = ictx->dev; in imon_init_idev()
2059 dev_err(ictx->dev, "input dev register failed\n"); in imon_init_idev()
2072 struct input_dev *touch; in imon_init_touch() local
2075 touch = input_allocate_device(); in imon_init_touch()
2076 if (!touch) in imon_init_touch()
2079 snprintf(ictx->name_touch, sizeof(ictx->name_touch), in imon_init_touch()
2081 ictx->vendor, ictx->product); in imon_init_touch()
2082 touch->name = ictx->name_touch; in imon_init_touch()
2084 usb_make_path(ictx->usbdev_intf1, ictx->phys_touch, in imon_init_touch()
2085 sizeof(ictx->phys_touch)); in imon_init_touch()
2086 strlcat(ictx->phys_touch, "/input2", sizeof(ictx->phys_touch)); in imon_init_touch()
2087 touch->phys = ictx->phys_touch; in imon_init_touch()
2089 touch->evbit[0] = in imon_init_touch()
2091 touch->keybit[BIT_WORD(BTN_TOUCH)] = in imon_init_touch()
2093 input_set_abs_params(touch, ABS_X, in imon_init_touch()
2095 input_set_abs_params(touch, ABS_Y, in imon_init_touch()
2098 input_set_drvdata(touch, ictx); in imon_init_touch()
2100 usb_to_input_id(ictx->usbdev_intf1, &touch->id); in imon_init_touch()
2101 touch->dev.parent = ictx->dev; in imon_init_touch()
2102 ret = input_register_device(touch); in imon_init_touch()
2104 dev_info(ictx->dev, "touchscreen input dev register failed\n"); in imon_init_touch()
2108 return touch; in imon_init_touch()
2111 input_free_device(touch); in imon_init_touch()
2123 int ifnum = iface_desc->desc.bInterfaceNumber; in imon_find_endpoints()
2124 int num_endpts = iface_desc->desc.bNumEndpoints; in imon_find_endpoints()
2136 ep = &iface_desc->endpoint[i].desc; in imon_find_endpoints()
2137 ep_dir = ep->bEndpointAddress & USB_ENDPOINT_DIR_MASK; in imon_find_endpoints()
2145 dev_dbg(ictx->dev, "%s: found IR endpoint\n", __func__); in imon_find_endpoints()
2151 dev_dbg(ictx->dev, "%s: found display endpoint\n", __func__); in imon_find_endpoints()
2156 ictx->rx_endpoint_intf0 = rx_endpoint; in imon_find_endpoints()
2161 ictx->tx_endpoint = tx_endpoint; in imon_find_endpoints()
2163 ictx->rx_endpoint_intf1 = rx_endpoint; in imon_find_endpoints()
2173 dev_dbg(ictx->dev, "%s: device uses control endpoint, not interface OUT endpoint\n", in imon_find_endpoints()
2182 if (ictx->display_type == IMON_DISPLAY_TYPE_NONE) { in imon_find_endpoints()
2184 dev_dbg(ictx->dev, "%s: device has no display\n", __func__); in imon_find_endpoints()
2188 * iMON Touch devices have a VGA touchscreen, but no "display", as in imon_find_endpoints()
2191 if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { in imon_find_endpoints()
2193 dev_dbg(ictx->dev, "%s: iMON Touch device found\n", __func__); in imon_find_endpoints()
2200 ictx->tx_control = tx_control; in imon_find_endpoints()
2203 ictx->display_supported = true; in imon_find_endpoints()
2215 struct device *dev = &intf->dev; in imon_init_intf0()
2217 int ret = -ENOMEM; in imon_init_intf0()
2230 mutex_init(&ictx->lock); in imon_init_intf0()
2231 spin_lock_init(&ictx->kc_lock); in imon_init_intf0()
2233 mutex_lock(&ictx->lock); in imon_init_intf0()
2235 ictx->dev = dev; in imon_init_intf0()
2236 ictx->usbdev_intf0 = usb_get_dev(interface_to_usbdev(intf)); in imon_init_intf0()
2237 ictx->rx_urb_intf0 = rx_urb; in imon_init_intf0()
2238 ictx->tx_urb = tx_urb; in imon_init_intf0()
2239 ictx->rf_device = false; in imon_init_intf0()
2241 init_completion(&ictx->tx.finished); in imon_init_intf0()
2243 ictx->vendor = le16_to_cpu(ictx->usbdev_intf0->descriptor.idVendor); in imon_init_intf0()
2244 ictx->product = le16_to_cpu(ictx->usbdev_intf0->descriptor.idProduct); in imon_init_intf0()
2247 ictx->dev_descr = (struct imon_usb_dev_descr *)id->driver_info; in imon_init_intf0()
2249 ictx->send_packet_delay = ictx->dev_descr->flags & in imon_init_intf0()
2252 ret = -ENODEV; in imon_init_intf0()
2253 iface_desc = intf->cur_altsetting; in imon_init_intf0()
2258 usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, in imon_init_intf0()
2259 usb_rcvintpipe(ictx->usbdev_intf0, in imon_init_intf0()
2260 ictx->rx_endpoint_intf0->bEndpointAddress), in imon_init_intf0()
2261 ictx->usb_rx_buf, sizeof(ictx->usb_rx_buf), in imon_init_intf0()
2263 ictx->rx_endpoint_intf0->bInterval); in imon_init_intf0()
2265 ret = usb_submit_urb(ictx->rx_urb_intf0, GFP_KERNEL); in imon_init_intf0()
2271 ictx->idev = imon_init_idev(ictx); in imon_init_intf0()
2272 if (!ictx->idev) { in imon_init_intf0()
2277 ictx->rdev = imon_init_rdev(ictx); in imon_init_intf0()
2278 if (!ictx->rdev) { in imon_init_intf0()
2283 ictx->dev_present_intf0 = true; in imon_init_intf0()
2285 mutex_unlock(&ictx->lock); in imon_init_intf0()
2289 input_unregister_device(ictx->idev); in imon_init_intf0()
2291 usb_kill_urb(ictx->rx_urb_intf0); in imon_init_intf0()
2294 usb_put_dev(ictx->usbdev_intf0); in imon_init_intf0()
2295 mutex_unlock(&ictx->lock); in imon_init_intf0()
2312 int ret = -ENOMEM; in imon_init_intf1()
2318 mutex_lock(&ictx->lock); in imon_init_intf1()
2320 if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { in imon_init_intf1()
2321 timer_setup(&ictx->ttimer, imon_touch_display_timeout, 0); in imon_init_intf1()
2324 ictx->usbdev_intf1 = usb_get_dev(interface_to_usbdev(intf)); in imon_init_intf1()
2325 ictx->rx_urb_intf1 = rx_urb; in imon_init_intf1()
2327 ret = -ENODEV; in imon_init_intf1()
2328 iface_desc = intf->cur_altsetting; in imon_init_intf1()
2332 if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { in imon_init_intf1()
2333 ictx->touch = imon_init_touch(ictx); in imon_init_intf1()
2334 if (!ictx->touch) in imon_init_intf1()
2337 ictx->touch = NULL; in imon_init_intf1()
2339 usb_fill_int_urb(ictx->rx_urb_intf1, ictx->usbdev_intf1, in imon_init_intf1()
2340 usb_rcvintpipe(ictx->usbdev_intf1, in imon_init_intf1()
2341 ictx->rx_endpoint_intf1->bEndpointAddress), in imon_init_intf1()
2342 ictx->usb_rx_buf, sizeof(ictx->usb_rx_buf), in imon_init_intf1()
2344 ictx->rx_endpoint_intf1->bInterval); in imon_init_intf1()
2346 ret = usb_submit_urb(ictx->rx_urb_intf1, GFP_KERNEL); in imon_init_intf1()
2353 ictx->dev_present_intf1 = true; in imon_init_intf1()
2355 mutex_unlock(&ictx->lock); in imon_init_intf1()
2359 if (ictx->touch) in imon_init_intf1()
2360 input_unregister_device(ictx->touch); in imon_init_intf1()
2363 usb_put_dev(ictx->usbdev_intf1); in imon_init_intf1()
2364 ictx->usbdev_intf1 = NULL; in imon_init_intf1()
2365 mutex_unlock(&ictx->lock); in imon_init_intf1()
2367 ictx->rx_urb_intf1 = NULL; in imon_init_intf1()
2369 dev_err(ictx->dev, "unable to initialize intf1, err %d\n", ret); in imon_init_intf1()
2379 dev_dbg(ictx->dev, "Registering iMON display with sysfs\n"); in imon_init_display()
2381 /* set up sysfs entry for built-in clock */ in imon_init_display()
2382 ret = sysfs_create_group(&intf->dev.kobj, &imon_display_attr_group); in imon_init_display()
2384 dev_err(ictx->dev, "Could not create display sysfs entries(%d)", in imon_init_display()
2387 if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) in imon_init_display()
2393 dev_info(ictx->dev, "could not get a minor number for display\n"); in imon_init_display()
2406 struct device *dev = &interface->dev; in imon_probe()
2413 iface_desc = interface->cur_altsetting; in imon_probe()
2414 ifnum = iface_desc->desc.bInterfaceNumber; in imon_probe()
2415 vendor = le16_to_cpu(usbdev->descriptor.idVendor); in imon_probe()
2416 product = le16_to_cpu(usbdev->descriptor.idProduct); in imon_probe()
2423 ret = -ENODEV; in imon_probe()
2427 if (first_if->dev.driver != interface->dev.driver) { in imon_probe()
2428 dev_err(&interface->dev, "inconsistent driver matching\n"); in imon_probe()
2429 ret = -EINVAL; in imon_probe()
2437 ret = -ENODEV; in imon_probe()
2440 refcount_set(&ictx->users, 1); in imon_probe()
2448 ret = -ENODEV; in imon_probe()
2455 ret = -ENODEV; in imon_probe()
2458 refcount_inc(&ictx->users); in imon_probe()
2465 if (product == 0xffdc && ictx->rf_device) { in imon_probe()
2466 sysfs_err = sysfs_create_group(&interface->dev.kobj, in imon_probe()
2473 if (ictx->display_supported) in imon_probe()
2479 usbdev->bus->busnum, usbdev->devnum); in imon_probe()
2502 ictx->disconnected = true; in imon_disconnect()
2503 dev = ictx->dev; in imon_disconnect()
2504 ifnum = interface->cur_altsetting->desc.bInterfaceNumber; in imon_disconnect()
2510 sysfs_remove_group(&interface->dev.kobj, &imon_display_attr_group); in imon_disconnect()
2511 sysfs_remove_group(&interface->dev.kobj, &imon_rf_attr_group); in imon_disconnect()
2516 if (ictx->tx.busy) { in imon_disconnect()
2517 usb_kill_urb(ictx->tx_urb); in imon_disconnect()
2518 complete(&ictx->tx.finished); in imon_disconnect()
2522 ictx->dev_present_intf0 = false; in imon_disconnect()
2523 usb_kill_urb(ictx->rx_urb_intf0); in imon_disconnect()
2524 input_unregister_device(ictx->idev); in imon_disconnect()
2525 rc_unregister_device(ictx->rdev); in imon_disconnect()
2526 if (ictx->display_supported) { in imon_disconnect()
2527 if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) in imon_disconnect()
2529 else if (ictx->display_type == IMON_DISPLAY_TYPE_VFD) in imon_disconnect()
2532 usb_put_dev(ictx->usbdev_intf0); in imon_disconnect()
2534 ictx->dev_present_intf1 = false; in imon_disconnect()
2535 usb_kill_urb(ictx->rx_urb_intf1); in imon_disconnect()
2536 if (ictx->display_type == IMON_DISPLAY_TYPE_VGA) { in imon_disconnect()
2537 del_timer_sync(&ictx->ttimer); in imon_disconnect()
2538 input_unregister_device(ictx->touch); in imon_disconnect()
2540 usb_put_dev(ictx->usbdev_intf1); in imon_disconnect()
2543 if (refcount_dec_and_test(&ictx->users)) in imon_disconnect()
2553 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in imon_suspend()
2556 usb_kill_urb(ictx->rx_urb_intf0); in imon_suspend()
2558 usb_kill_urb(ictx->rx_urb_intf1); in imon_suspend()
2567 int ifnum = intf->cur_altsetting->desc.bInterfaceNumber; in imon_resume()
2570 usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, in imon_resume()
2571 usb_rcvintpipe(ictx->usbdev_intf0, in imon_resume()
2572 ictx->rx_endpoint_intf0->bEndpointAddress), in imon_resume()
2573 ictx->usb_rx_buf, sizeof(ictx->usb_rx_buf), in imon_resume()
2575 ictx->rx_endpoint_intf0->bInterval); in imon_resume()
2577 rc = usb_submit_urb(ictx->rx_urb_intf0, GFP_NOIO); in imon_resume()
2580 usb_fill_int_urb(ictx->rx_urb_intf1, ictx->usbdev_intf1, in imon_resume()
2581 usb_rcvintpipe(ictx->usbdev_intf1, in imon_resume()
2582 ictx->rx_endpoint_intf1->bEndpointAddress), in imon_resume()
2583 ictx->usb_rx_buf, sizeof(ictx->usb_rx_buf), in imon_resume()
2585 ictx->rx_endpoint_intf1->bInterval); in imon_resume()
2587 rc = usb_submit_urb(ictx->rx_urb_intf1, GFP_NOIO); in imon_resume()