Lines Matching refs:ictx

494 static void free_imon_context(struct imon_context *ictx)  in free_imon_context()  argument
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()
503 kfree_rcu(ictx, rcu); in free_imon_context()
515 struct imon_context *ictx = NULL; in display_open() local
528 ictx = usb_get_intfdata(interface); in display_open()
529 if (!ictx || ictx->disconnected || !refcount_inc_not_zero(&ictx->users)) { in display_open()
537 mutex_lock(&ictx->lock); in display_open()
539 if (!ictx->display_supported) { in display_open()
542 } else if (ictx->display_isopen) { 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()
554 free_imon_context(ictx); in display_open()
566 struct imon_context *ictx = file->private_data; in display_close() local
569 mutex_lock(&ictx->lock); in display_close()
571 if (!ictx->display_supported) { in display_close()
574 } else if (!ictx->display_isopen) { 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()
584 free_imon_context(ictx); in display_close()
593 static int send_packet(struct imon_context *ictx) in send_packet() argument
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()
610 usb_tx_callback, ictx, interval); in send_packet()
612 ictx->tx_urb->actual_length = 0; 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()
634 usb_tx_callback, ictx); 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()
684 static int send_associate_24g(struct imon_context *ictx) in send_associate_24g() argument
689 if (!ictx) { in send_associate_24g()
694 if (!ictx->dev_present_intf0) { in send_associate_24g()
699 memcpy(ictx->usb_tx_buf, packet, sizeof(packet)); in send_associate_24g()
701 return send_packet(ictx); in send_associate_24g()
711 static int send_set_imon_clock(struct imon_context *ictx, in send_set_imon_clock() argument
721 if (!ictx) { in send_set_imon_clock()
726 switch (ictx->display_type) { in send_set_imon_clock()
744 if (ictx->product == 0xffdc) { in send_set_imon_clock()
780 memcpy(ictx->usb_tx_buf, clock_enable_pkt[i], 8); in send_set_imon_clock()
781 retval = send_packet(ictx); in send_set_imon_clock()
798 struct imon_context *ictx = dev_get_drvdata(d); in associate_remote_show() local
800 if (!ictx) in associate_remote_show()
803 mutex_lock(&ictx->lock); in associate_remote_show()
804 if (ictx->rf_isassociating) in associate_remote_show()
810 mutex_unlock(&ictx->lock); in associate_remote_show()
818 struct imon_context *ictx; in associate_remote_store() local
820 ictx = dev_get_drvdata(d); in associate_remote_store()
822 if (!ictx) in associate_remote_store()
825 mutex_lock(&ictx->lock); in associate_remote_store()
826 ictx->rf_isassociating = true; in associate_remote_store()
827 send_associate_24g(ictx); in associate_remote_store()
828 mutex_unlock(&ictx->lock); in associate_remote_store()
839 struct imon_context *ictx = dev_get_drvdata(d); in imon_clock_show() local
842 if (!ictx) 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()
866 struct imon_context *ictx = dev_get_drvdata(d); in imon_clock_store() local
870 if (!ictx) in imon_clock_store()
873 mutex_lock(&ictx->lock); in imon_clock_store()
875 if (!ictx->display_supported) { in imon_clock_store()
878 } else if (ictx->display_isopen) { in imon_clock_store()
896 retval = send_set_imon_clock(ictx, year, month, day, dow, in imon_clock_store()
903 mutex_unlock(&ictx->lock); in imon_clock_store()
948 struct imon_context *ictx = file->private_data; in vfd_write() local
952 if (ictx->disconnected) in vfd_write()
955 if (mutex_lock_interruptible(&ictx->lock)) in vfd_write()
958 if (!ictx->dev_present_intf0) { in vfd_write()
970 if (copy_from_user(ictx->tx.data_buf, buf, n_bytes)) { 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()
989 retval = send_packet(ictx); 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()
1003 retval = send_packet(ictx); in vfd_write()
1008 mutex_unlock(&ictx->lock); in vfd_write()
1030 struct imon_context *ictx = file->private_data; in lcd_write() local
1032 if (ictx->disconnected) in lcd_write()
1035 mutex_lock(&ictx->lock); in lcd_write()
1037 if (!ictx->display_supported) { in lcd_write()
1050 if (copy_from_user(ictx->usb_tx_buf, buf, 8)) { in lcd_write()
1055 retval = send_packet(ictx); 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()
1073 struct imon_context *ictx; in usb_tx_callback() local
1077 ictx = (struct imon_context *)urb->context; in usb_tx_callback()
1078 if (!ictx) 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()
1094 struct imon_context *ictx = from_timer(ictx, t, ttimer); in imon_touch_display_timeout() local
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()
1122 struct imon_context *ictx = rc->priv; in imon_ir_change_protocol() local
1123 struct device *dev = ictx->dev; 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()
1156 retval = send_packet(ictx); 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()
1245 static u32 imon_remote_key_lookup(struct imon_context *ictx, u32 scancode) in imon_remote_key_lookup() argument
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()
1269 static u32 imon_mce_key_lookup(struct imon_context *ictx, u32 scancode) in imon_mce_key_lookup() argument
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()
1296 static u32 imon_panel_key_lookup(struct imon_context *ictx, u64 code) in imon_panel_key_lookup() argument
1302 key_table = ictx->dev_descr->key_table; in imon_panel_key_lookup()
1310 ictx->release_code = false; in imon_panel_key_lookup()
1314 static bool imon_mouse_event(struct imon_context *ictx, in imon_mouse_event() argument
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()
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()
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()
1379 static void imon_touch_event(struct imon_context *ictx, unsigned char *buf) in imon_touch_event() argument
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()
1390 static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf) in imon_pad_to_keys() argument
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()
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()
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()
1529 static int imon_parse_press_type(struct imon_context *ictx, in imon_parse_press_type() argument
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()
1553 ictx->rc_toggle = buf[2]; in imon_parse_press_type()
1557 } else if (ictx->kc == KEY_RESERVED) in imon_parse_press_type()
1561 else if (ictx->release_code) in imon_parse_press_type()
1568 spin_unlock_irqrestore(&ictx->kc_lock, flags); in imon_parse_press_type()
1576 static void imon_incoming_packet(struct imon_context *ictx, in imon_incoming_packet() argument
1581 struct device *dev = ictx->dev; in imon_incoming_packet()
1598 kc = imon_panel_key_lookup(ictx, scancode); 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()
1606 kc = imon_mce_key_lookup(ictx, scancode); in imon_incoming_packet()
1609 kc = imon_remote_key_lookup(ictx, scancode); 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()
1634 imon_touch_event(ictx, buf); in imon_incoming_packet()
1638 } else if (ictx->pad_mouse) { in imon_incoming_packet()
1639 if (imon_mouse_event(ictx, buf, len)) in imon_incoming_packet()
1648 imon_pad_to_keys(ictx, buf); in imon_incoming_packet()
1656 press_type = imon_parse_press_type(ictx, buf, ktype); 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()
1741 struct imon_context *ictx; in usb_rx_callback_intf0() local
1747 ictx = (struct imon_context *)urb->context; in usb_rx_callback_intf0()
1748 if (!ictx) in usb_rx_callback_intf0()
1756 if (!ictx->dev_present_intf0) in usb_rx_callback_intf0()
1767 imon_incoming_packet(ictx, urb, intfnum); in usb_rx_callback_intf0()
1771 dev_warn(ictx->dev, "imon %s: status(%d): ignored\n", in usb_rx_callback_intf0()
1777 usb_submit_urb(ictx->rx_urb_intf0, GFP_ATOMIC); in usb_rx_callback_intf0()
1782 struct imon_context *ictx; in usb_rx_callback_intf1() local
1788 ictx = (struct imon_context *)urb->context; in usb_rx_callback_intf1()
1789 if (!ictx) in usb_rx_callback_intf1()
1797 if (!ictx->dev_present_intf1) in usb_rx_callback_intf1()
1808 imon_incoming_packet(ictx, urb, intfnum); in usb_rx_callback_intf1()
1812 dev_warn(ictx->dev, "imon %s: status(%d): ignored\n", in usb_rx_callback_intf1()
1818 usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC); in usb_rx_callback_intf1()
1830 static void imon_get_ffdc_type(struct imon_context *ictx) in imon_get_ffdc_type() argument
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()
1909 static void imon_set_display_type(struct imon_context *ictx) in imon_set_display_type() argument
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()
1959 static struct rc_dev *imon_init_rdev(struct imon_context *ictx) in imon_init_rdev() argument
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()
1990 memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet)); in imon_init_rdev()
1991 ret = send_packet(ictx); 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()
1997 imon_get_ffdc_type(ictx); in imon_init_rdev()
1998 rdev->allowed_protocols = ictx->rc_proto; in imon_init_rdev()
2001 imon_set_display_type(ictx); in imon_init_rdev()
2003 if (ictx->rc_proto == RC_PROTO_BIT_RC6_MCE) in imon_init_rdev()
2010 dev_err(ictx->dev, "remote input dev register failed\n"); in imon_init_rdev()
2021 static struct input_dev *imon_init_idev(struct imon_context *ictx) in imon_init_idev() argument
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()
2056 usb_to_input_id(ictx->usbdev_intf0, &idev->id); in imon_init_idev()
2057 idev->dev.parent = ictx->dev; in imon_init_idev()
2058 input_set_drvdata(idev, ictx); in imon_init_idev()
2062 dev_err(ictx->dev, "input dev register failed\n"); in imon_init_idev()
2073 static struct input_dev *imon_init_touch(struct imon_context *ictx) in imon_init_touch() argument
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()
2101 input_set_drvdata(touch, ictx); 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()
2120 static bool imon_find_endpoints(struct imon_context *ictx, in imon_find_endpoints() argument
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()
2215 struct imon_context *ictx; in imon_init_intf0() local
2222 ictx = kzalloc(sizeof(*ictx), GFP_KERNEL); in imon_init_intf0()
2223 if (!ictx) 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()
2252 ictx->send_packet_delay = ictx->dev_descr->flags & in imon_init_intf0()
2257 if (!imon_find_endpoints(ictx, iface_desc)) { 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()
2265 usb_rx_callback_intf0, ictx, 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()
2289 return ictx; 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()
2303 kfree(ictx); in imon_init_intf0()
2311 struct imon_context *ictx) in imon_init_intf1() argument
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()
2332 if (!imon_find_endpoints(ictx, iface_desc)) 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()
2346 usb_rx_callback_intf1, ictx, 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()
2359 return ictx; 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()
2377 static void imon_init_display(struct imon_context *ictx, in imon_init_display() argument
2382 dev_dbg(ictx->dev, "Registering iMON display with sysfs\n"); 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()
2412 struct imon_context *ictx = NULL; in imon_probe() local
2431 ictx = imon_init_intf0(interface, id); in imon_probe()
2432 if (!ictx) { in imon_probe()
2437 refcount_set(&ictx->users, 1); in imon_probe()
2449 ictx = imon_init_intf1(interface, first_if_ctx); in imon_probe()
2450 if (!ictx) { in imon_probe()
2455 refcount_inc(&ictx->users); in imon_probe()
2459 usb_set_intfdata(interface, ictx); in imon_probe()
2462 if (product == 0xffdc && ictx->rf_device) { in imon_probe()
2470 if (ictx->display_supported) in imon_probe()
2471 imon_init_display(ictx, interface); in imon_probe()
2494 struct imon_context *ictx; in imon_disconnect() local
2498 ictx = usb_get_intfdata(interface); in imon_disconnect()
2499 ictx->disconnected = true; in imon_disconnect()
2500 dev = ictx->dev; 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()
2541 free_imon_context(ictx); in imon_disconnect()
2549 struct imon_context *ictx = usb_get_intfdata(intf); in imon_suspend() local
2553 usb_kill_urb(ictx->rx_urb_intf0); in imon_suspend()
2555 usb_kill_urb(ictx->rx_urb_intf1); in imon_suspend()
2563 struct imon_context *ictx = usb_get_intfdata(intf); in imon_resume() local
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()
2571 usb_rx_callback_intf0, ictx, 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()
2581 usb_rx_callback_intf1, ictx, 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()