diff options
Diffstat (limited to 'drivers/media/IR/imon.c')
-rw-r--r-- | drivers/media/IR/imon.c | 690 |
1 files changed, 386 insertions, 304 deletions
diff --git a/drivers/media/IR/imon.c b/drivers/media/IR/imon.c index faed5a332c71..bc118066bc38 100644 --- a/drivers/media/IR/imon.c +++ b/drivers/media/IR/imon.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * imon.c: input and display driver for SoundGraph iMON IR/VFD/LCD | 2 | * imon.c: input and display driver for SoundGraph iMON IR/VFD/LCD |
3 | * | 3 | * |
4 | * Copyright(C) 2009 Jarod Wilson <jarod@wilsonet.com> | 4 | * Copyright(C) 2010 Jarod Wilson <jarod@wilsonet.com> |
5 | * Portions based on the original lirc_imon driver, | 5 | * Portions based on the original lirc_imon driver, |
6 | * Copyright(C) 2004 Venky Raju(dev@venky.ws) | 6 | * Copyright(C) 2004 Venky Raju(dev@venky.ws) |
7 | * | 7 | * |
@@ -26,6 +26,8 @@ | |||
26 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 26 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__ | ||
30 | |||
29 | #include <linux/errno.h> | 31 | #include <linux/errno.h> |
30 | #include <linux/init.h> | 32 | #include <linux/init.h> |
31 | #include <linux/kernel.h> | 33 | #include <linux/kernel.h> |
@@ -44,7 +46,7 @@ | |||
44 | #define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>" | 46 | #define MOD_AUTHOR "Jarod Wilson <jarod@wilsonet.com>" |
45 | #define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display" | 47 | #define MOD_DESC "Driver for SoundGraph iMON MultiMedia IR/Display" |
46 | #define MOD_NAME "imon" | 48 | #define MOD_NAME "imon" |
47 | #define MOD_VERSION "0.9.1" | 49 | #define MOD_VERSION "0.9.2" |
48 | 50 | ||
49 | #define DISPLAY_MINOR_BASE 144 | 51 | #define DISPLAY_MINOR_BASE 144 |
50 | #define DEVICE_NAME "lcd%d" | 52 | #define DEVICE_NAME "lcd%d" |
@@ -121,21 +123,26 @@ struct imon_context { | |||
121 | u16 vendor; /* usb vendor ID */ | 123 | u16 vendor; /* usb vendor ID */ |
122 | u16 product; /* usb product ID */ | 124 | u16 product; /* usb product ID */ |
123 | 125 | ||
124 | struct input_dev *idev; /* input device for remote */ | 126 | struct input_dev *rdev; /* input device for remote */ |
127 | struct input_dev *idev; /* input device for panel & IR mouse */ | ||
125 | struct input_dev *touch; /* input device for touchscreen */ | 128 | struct input_dev *touch; /* input device for touchscreen */ |
126 | 129 | ||
130 | spinlock_t kc_lock; /* make sure we get keycodes right */ | ||
127 | u32 kc; /* current input keycode */ | 131 | u32 kc; /* current input keycode */ |
128 | u32 last_keycode; /* last reported input keycode */ | 132 | u32 last_keycode; /* last reported input keycode */ |
133 | u32 rc_scancode; /* the computed remote scancode */ | ||
134 | u8 rc_toggle; /* the computed remote toggle bit */ | ||
129 | u64 ir_type; /* iMON or MCE (RC6) IR protocol? */ | 135 | u64 ir_type; /* iMON or MCE (RC6) IR protocol? */ |
130 | u8 mce_toggle_bit; /* last mce toggle bit */ | ||
131 | bool release_code; /* some keys send a release code */ | 136 | bool release_code; /* some keys send a release code */ |
132 | 137 | ||
133 | u8 display_type; /* store the display type */ | 138 | u8 display_type; /* store the display type */ |
134 | bool pad_mouse; /* toggle kbd(0)/mouse(1) mode */ | 139 | bool pad_mouse; /* toggle kbd(0)/mouse(1) mode */ |
135 | 140 | ||
141 | char name_rdev[128]; /* rc input device name */ | ||
142 | char phys_rdev[64]; /* rc input device phys path */ | ||
143 | |||
136 | char name_idev[128]; /* input device name */ | 144 | char name_idev[128]; /* input device name */ |
137 | char phys_idev[64]; /* input device phys path */ | 145 | char phys_idev[64]; /* input device phys path */ |
138 | struct timer_list itimer; /* input device timer, need for rc6 */ | ||
139 | 146 | ||
140 | char name_touch[128]; /* touch screen name */ | 147 | char name_touch[128]; /* touch screen name */ |
141 | char phys_touch[64]; /* touch screen phys path */ | 148 | char phys_touch[64]; /* touch screen phys path */ |
@@ -289,6 +296,9 @@ static const struct { | |||
289 | { 0x000100000000ffeell, KEY_VOLUMEUP }, | 296 | { 0x000100000000ffeell, KEY_VOLUMEUP }, |
290 | { 0x010000000000ffeell, KEY_VOLUMEDOWN }, | 297 | { 0x010000000000ffeell, KEY_VOLUMEDOWN }, |
291 | { 0x000000000100ffeell, KEY_MUTE }, | 298 | { 0x000000000100ffeell, KEY_MUTE }, |
299 | /* 0xffdc iMON MCE VFD */ | ||
300 | { 0x00010000ffffffeell, KEY_VOLUMEUP }, | ||
301 | { 0x01000000ffffffeell, KEY_VOLUMEDOWN }, | ||
292 | /* iMON Knob values */ | 302 | /* iMON Knob values */ |
293 | { 0x000100ffffffffeell, KEY_VOLUMEUP }, | 303 | { 0x000100ffffffffeell, KEY_VOLUMEUP }, |
294 | { 0x010000ffffffffeell, KEY_VOLUMEDOWN }, | 304 | { 0x010000ffffffffeell, KEY_VOLUMEDOWN }, |
@@ -307,7 +317,7 @@ MODULE_DEVICE_TABLE(usb, imon_usb_id_table); | |||
307 | 317 | ||
308 | static bool debug; | 318 | static bool debug; |
309 | module_param(debug, bool, S_IRUGO | S_IWUSR); | 319 | module_param(debug, bool, S_IRUGO | S_IWUSR); |
310 | MODULE_PARM_DESC(debug, "Debug messages: 0=no, 1=yes(default: no)"); | 320 | MODULE_PARM_DESC(debug, "Debug messages: 0=no, 1=yes (default: no)"); |
311 | 321 | ||
312 | /* lcd, vfd, vga or none? should be auto-detected, but can be overridden... */ | 322 | /* lcd, vfd, vga or none? should be auto-detected, but can be overridden... */ |
313 | static int display_type; | 323 | static int display_type; |
@@ -365,15 +375,14 @@ static int display_open(struct inode *inode, struct file *file) | |||
365 | subminor = iminor(inode); | 375 | subminor = iminor(inode); |
366 | interface = usb_find_interface(&imon_driver, subminor); | 376 | interface = usb_find_interface(&imon_driver, subminor); |
367 | if (!interface) { | 377 | if (!interface) { |
368 | err("%s: could not find interface for minor %d", | 378 | pr_err("could not find interface for minor %d\n", subminor); |
369 | __func__, subminor); | ||
370 | retval = -ENODEV; | 379 | retval = -ENODEV; |
371 | goto exit; | 380 | goto exit; |
372 | } | 381 | } |
373 | ictx = usb_get_intfdata(interface); | 382 | ictx = usb_get_intfdata(interface); |
374 | 383 | ||
375 | if (!ictx) { | 384 | if (!ictx) { |
376 | err("%s: no context found for minor %d", __func__, subminor); | 385 | pr_err("no context found for minor %d\n", subminor); |
377 | retval = -ENODEV; | 386 | retval = -ENODEV; |
378 | goto exit; | 387 | goto exit; |
379 | } | 388 | } |
@@ -381,10 +390,10 @@ static int display_open(struct inode *inode, struct file *file) | |||
381 | mutex_lock(&ictx->lock); | 390 | mutex_lock(&ictx->lock); |
382 | 391 | ||
383 | if (!ictx->display_supported) { | 392 | if (!ictx->display_supported) { |
384 | err("%s: display not supported by device", __func__); | 393 | pr_err("display not supported by device\n"); |
385 | retval = -ENODEV; | 394 | retval = -ENODEV; |
386 | } else if (ictx->display_isopen) { | 395 | } else if (ictx->display_isopen) { |
387 | err("%s: display port is already open", __func__); | 396 | pr_err("display port is already open\n"); |
388 | retval = -EBUSY; | 397 | retval = -EBUSY; |
389 | } else { | 398 | } else { |
390 | ictx->display_isopen = true; | 399 | ictx->display_isopen = true; |
@@ -411,17 +420,17 @@ static int display_close(struct inode *inode, struct file *file) | |||
411 | ictx = file->private_data; | 420 | ictx = file->private_data; |
412 | 421 | ||
413 | if (!ictx) { | 422 | if (!ictx) { |
414 | err("%s: no context for device", __func__); | 423 | pr_err("no context for device\n"); |
415 | return -ENODEV; | 424 | return -ENODEV; |
416 | } | 425 | } |
417 | 426 | ||
418 | mutex_lock(&ictx->lock); | 427 | mutex_lock(&ictx->lock); |
419 | 428 | ||
420 | if (!ictx->display_supported) { | 429 | if (!ictx->display_supported) { |
421 | err("%s: display not supported by device", __func__); | 430 | pr_err("display not supported by device\n"); |
422 | retval = -ENODEV; | 431 | retval = -ENODEV; |
423 | } else if (!ictx->display_isopen) { | 432 | } else if (!ictx->display_isopen) { |
424 | err("%s: display is not open", __func__); | 433 | pr_err("display is not open\n"); |
425 | retval = -EIO; | 434 | retval = -EIO; |
426 | } else { | 435 | } else { |
427 | ictx->display_isopen = false; | 436 | ictx->display_isopen = false; |
@@ -500,19 +509,19 @@ static int send_packet(struct imon_context *ictx) | |||
500 | if (retval) { | 509 | if (retval) { |
501 | ictx->tx.busy = false; | 510 | ictx->tx.busy = false; |
502 | smp_rmb(); /* ensure later readers know we're not busy */ | 511 | smp_rmb(); /* ensure later readers know we're not busy */ |
503 | err("%s: error submitting urb(%d)", __func__, retval); | 512 | pr_err("error submitting urb(%d)\n", retval); |
504 | } else { | 513 | } else { |
505 | /* Wait for transmission to complete (or abort) */ | 514 | /* Wait for transmission to complete (or abort) */ |
506 | mutex_unlock(&ictx->lock); | 515 | mutex_unlock(&ictx->lock); |
507 | retval = wait_for_completion_interruptible( | 516 | retval = wait_for_completion_interruptible( |
508 | &ictx->tx.finished); | 517 | &ictx->tx.finished); |
509 | if (retval) | 518 | if (retval) |
510 | err("%s: task interrupted", __func__); | 519 | pr_err("task interrupted\n"); |
511 | mutex_lock(&ictx->lock); | 520 | mutex_lock(&ictx->lock); |
512 | 521 | ||
513 | retval = ictx->tx.status; | 522 | retval = ictx->tx.status; |
514 | if (retval) | 523 | if (retval) |
515 | err("%s: packet tx failed (%d)", __func__, retval); | 524 | pr_err("packet tx failed (%d)\n", retval); |
516 | } | 525 | } |
517 | 526 | ||
518 | kfree(control_req); | 527 | kfree(control_req); |
@@ -544,12 +553,12 @@ static int send_associate_24g(struct imon_context *ictx) | |||
544 | 0x00, 0x00, 0x00, 0x20 }; | 553 | 0x00, 0x00, 0x00, 0x20 }; |
545 | 554 | ||
546 | if (!ictx) { | 555 | if (!ictx) { |
547 | err("%s: no context for device", __func__); | 556 | pr_err("no context for device\n"); |
548 | return -ENODEV; | 557 | return -ENODEV; |
549 | } | 558 | } |
550 | 559 | ||
551 | if (!ictx->dev_present_intf0) { | 560 | if (!ictx->dev_present_intf0) { |
552 | err("%s: no iMON device present", __func__); | 561 | pr_err("no iMON device present\n"); |
553 | return -ENODEV; | 562 | return -ENODEV; |
554 | } | 563 | } |
555 | 564 | ||
@@ -577,7 +586,7 @@ static int send_set_imon_clock(struct imon_context *ictx, | |||
577 | int i; | 586 | int i; |
578 | 587 | ||
579 | if (!ictx) { | 588 | if (!ictx) { |
580 | err("%s: no context for device", __func__); | 589 | pr_err("no context for device\n"); |
581 | return -ENODEV; | 590 | return -ENODEV; |
582 | } | 591 | } |
583 | 592 | ||
@@ -638,8 +647,7 @@ static int send_set_imon_clock(struct imon_context *ictx, | |||
638 | memcpy(ictx->usb_tx_buf, clock_enable_pkt[i], 8); | 647 | memcpy(ictx->usb_tx_buf, clock_enable_pkt[i], 8); |
639 | retval = send_packet(ictx); | 648 | retval = send_packet(ictx); |
640 | if (retval) { | 649 | if (retval) { |
641 | err("%s: send_packet failed for packet %d", | 650 | pr_err("send_packet failed for packet %d\n", i); |
642 | __func__, i); | ||
643 | break; | 651 | break; |
644 | } | 652 | } |
645 | } | 653 | } |
@@ -778,7 +786,7 @@ static struct attribute *imon_display_sysfs_entries[] = { | |||
778 | NULL | 786 | NULL |
779 | }; | 787 | }; |
780 | 788 | ||
781 | static struct attribute_group imon_display_attribute_group = { | 789 | static struct attribute_group imon_display_attr_group = { |
782 | .attrs = imon_display_sysfs_entries | 790 | .attrs = imon_display_sysfs_entries |
783 | }; | 791 | }; |
784 | 792 | ||
@@ -787,7 +795,7 @@ static struct attribute *imon_rf_sysfs_entries[] = { | |||
787 | NULL | 795 | NULL |
788 | }; | 796 | }; |
789 | 797 | ||
790 | static struct attribute_group imon_rf_attribute_group = { | 798 | static struct attribute_group imon_rf_attr_group = { |
791 | .attrs = imon_rf_sysfs_entries | 799 | .attrs = imon_rf_sysfs_entries |
792 | }; | 800 | }; |
793 | 801 | ||
@@ -815,20 +823,20 @@ static ssize_t vfd_write(struct file *file, const char *buf, | |||
815 | 823 | ||
816 | ictx = file->private_data; | 824 | ictx = file->private_data; |
817 | if (!ictx) { | 825 | if (!ictx) { |
818 | err("%s: no context for device", __func__); | 826 | pr_err("no context for device\n"); |
819 | return -ENODEV; | 827 | return -ENODEV; |
820 | } | 828 | } |
821 | 829 | ||
822 | mutex_lock(&ictx->lock); | 830 | mutex_lock(&ictx->lock); |
823 | 831 | ||
824 | if (!ictx->dev_present_intf0) { | 832 | if (!ictx->dev_present_intf0) { |
825 | err("%s: no iMON device present", __func__); | 833 | pr_err("no iMON device present\n"); |
826 | retval = -ENODEV; | 834 | retval = -ENODEV; |
827 | goto exit; | 835 | goto exit; |
828 | } | 836 | } |
829 | 837 | ||
830 | if (n_bytes <= 0 || n_bytes > 32) { | 838 | if (n_bytes <= 0 || n_bytes > 32) { |
831 | err("%s: invalid payload size", __func__); | 839 | pr_err("invalid payload size\n"); |
832 | retval = -EINVAL; | 840 | retval = -EINVAL; |
833 | goto exit; | 841 | goto exit; |
834 | } | 842 | } |
@@ -854,8 +862,7 @@ static ssize_t vfd_write(struct file *file, const char *buf, | |||
854 | 862 | ||
855 | retval = send_packet(ictx); | 863 | retval = send_packet(ictx); |
856 | if (retval) { | 864 | if (retval) { |
857 | err("%s: send packet failed for packet #%d", | 865 | pr_err("send packet failed for packet #%d\n", seq / 2); |
858 | __func__, seq/2); | ||
859 | goto exit; | 866 | goto exit; |
860 | } else { | 867 | } else { |
861 | seq += 2; | 868 | seq += 2; |
@@ -869,8 +876,7 @@ static ssize_t vfd_write(struct file *file, const char *buf, | |||
869 | ictx->usb_tx_buf[7] = (unsigned char) seq; | 876 | ictx->usb_tx_buf[7] = (unsigned char) seq; |
870 | retval = send_packet(ictx); | 877 | retval = send_packet(ictx); |
871 | if (retval) | 878 | if (retval) |
872 | err("%s: send packet failed for packet #%d", | 879 | pr_err("send packet failed for packet #%d\n", seq / 2); |
873 | __func__, seq / 2); | ||
874 | 880 | ||
875 | exit: | 881 | exit: |
876 | mutex_unlock(&ictx->lock); | 882 | mutex_unlock(&ictx->lock); |
@@ -899,21 +905,20 @@ static ssize_t lcd_write(struct file *file, const char *buf, | |||
899 | 905 | ||
900 | ictx = file->private_data; | 906 | ictx = file->private_data; |
901 | if (!ictx) { | 907 | if (!ictx) { |
902 | err("%s: no context for device", __func__); | 908 | pr_err("no context for device\n"); |
903 | return -ENODEV; | 909 | return -ENODEV; |
904 | } | 910 | } |
905 | 911 | ||
906 | mutex_lock(&ictx->lock); | 912 | mutex_lock(&ictx->lock); |
907 | 913 | ||
908 | if (!ictx->display_supported) { | 914 | if (!ictx->display_supported) { |
909 | err("%s: no iMON display present", __func__); | 915 | pr_err("no iMON display present\n"); |
910 | retval = -ENODEV; | 916 | retval = -ENODEV; |
911 | goto exit; | 917 | goto exit; |
912 | } | 918 | } |
913 | 919 | ||
914 | if (n_bytes != 8) { | 920 | if (n_bytes != 8) { |
915 | err("%s: invalid payload size: %d (expecting 8)", | 921 | pr_err("invalid payload size: %d (expected 8)\n", (int)n_bytes); |
916 | __func__, (int) n_bytes); | ||
917 | retval = -EINVAL; | 922 | retval = -EINVAL; |
918 | goto exit; | 923 | goto exit; |
919 | } | 924 | } |
@@ -925,7 +930,7 @@ static ssize_t lcd_write(struct file *file, const char *buf, | |||
925 | 930 | ||
926 | retval = send_packet(ictx); | 931 | retval = send_packet(ictx); |
927 | if (retval) { | 932 | if (retval) { |
928 | err("%s: send packet failed!", __func__); | 933 | pr_err("send packet failed!\n"); |
929 | goto exit; | 934 | goto exit; |
930 | } else { | 935 | } else { |
931 | dev_dbg(ictx->dev, "%s: write %d bytes to LCD\n", | 936 | dev_dbg(ictx->dev, "%s: write %d bytes to LCD\n", |
@@ -958,17 +963,6 @@ static void usb_tx_callback(struct urb *urb) | |||
958 | } | 963 | } |
959 | 964 | ||
960 | /** | 965 | /** |
961 | * mce/rc6 keypresses have no distinct release code, use timer | ||
962 | */ | ||
963 | static void imon_mce_timeout(unsigned long data) | ||
964 | { | ||
965 | struct imon_context *ictx = (struct imon_context *)data; | ||
966 | |||
967 | input_report_key(ictx->idev, ictx->last_keycode, 0); | ||
968 | input_sync(ictx->idev); | ||
969 | } | ||
970 | |||
971 | /** | ||
972 | * report touchscreen input | 966 | * report touchscreen input |
973 | */ | 967 | */ |
974 | static void imon_touch_display_timeout(unsigned long data) | 968 | static void imon_touch_display_timeout(unsigned long data) |
@@ -1008,14 +1002,11 @@ int imon_ir_change_protocol(void *priv, u64 ir_type) | |||
1008 | dev_dbg(dev, "Configuring IR receiver for MCE protocol\n"); | 1002 | dev_dbg(dev, "Configuring IR receiver for MCE protocol\n"); |
1009 | ir_proto_packet[0] = 0x01; | 1003 | ir_proto_packet[0] = 0x01; |
1010 | pad_mouse = false; | 1004 | pad_mouse = false; |
1011 | init_timer(&ictx->itimer); | ||
1012 | ictx->itimer.data = (unsigned long)ictx; | ||
1013 | ictx->itimer.function = imon_mce_timeout; | ||
1014 | break; | 1005 | break; |
1015 | case IR_TYPE_UNKNOWN: | 1006 | case IR_TYPE_UNKNOWN: |
1016 | case IR_TYPE_OTHER: | 1007 | case IR_TYPE_OTHER: |
1017 | dev_dbg(dev, "Configuring IR receiver for iMON protocol\n"); | 1008 | dev_dbg(dev, "Configuring IR receiver for iMON protocol\n"); |
1018 | if (pad_stabilize) | 1009 | if (pad_stabilize && !nomouse) |
1019 | pad_mouse = true; | 1010 | pad_mouse = true; |
1020 | else { | 1011 | else { |
1021 | dev_dbg(dev, "PAD stabilize functionality disabled\n"); | 1012 | dev_dbg(dev, "PAD stabilize functionality disabled\n"); |
@@ -1027,7 +1018,7 @@ int imon_ir_change_protocol(void *priv, u64 ir_type) | |||
1027 | default: | 1018 | default: |
1028 | dev_warn(dev, "Unsupported IR protocol specified, overriding " | 1019 | dev_warn(dev, "Unsupported IR protocol specified, overriding " |
1029 | "to iMON IR protocol\n"); | 1020 | "to iMON IR protocol\n"); |
1030 | if (pad_stabilize) | 1021 | if (pad_stabilize && !nomouse) |
1031 | pad_mouse = true; | 1022 | pad_mouse = true; |
1032 | else { | 1023 | else { |
1033 | dev_dbg(dev, "PAD stabilize functionality disabled\n"); | 1024 | dev_dbg(dev, "PAD stabilize functionality disabled\n"); |
@@ -1149,20 +1140,21 @@ static int stabilize(int a, int b, u16 timeout, u16 threshold) | |||
1149 | return result; | 1140 | return result; |
1150 | } | 1141 | } |
1151 | 1142 | ||
1152 | static u32 imon_remote_key_lookup(struct imon_context *ictx, u32 hw_code) | 1143 | static u32 imon_remote_key_lookup(struct imon_context *ictx, u32 scancode) |
1153 | { | 1144 | { |
1154 | u32 scancode = be32_to_cpu(hw_code); | ||
1155 | u32 keycode; | 1145 | u32 keycode; |
1156 | u32 release; | 1146 | u32 release; |
1157 | bool is_release_code = false; | 1147 | bool is_release_code = false; |
1158 | 1148 | ||
1159 | /* Look for the initial press of a button */ | 1149 | /* Look for the initial press of a button */ |
1160 | keycode = ir_g_keycode_from_table(ictx->idev, scancode); | 1150 | keycode = ir_g_keycode_from_table(ictx->rdev, scancode); |
1151 | ictx->rc_toggle = 0x0; | ||
1152 | ictx->rc_scancode = scancode; | ||
1161 | 1153 | ||
1162 | /* Look for the release of a button */ | 1154 | /* Look for the release of a button */ |
1163 | if (keycode == KEY_RESERVED) { | 1155 | if (keycode == KEY_RESERVED) { |
1164 | release = scancode & ~0x4000; | 1156 | release = scancode & ~0x4000; |
1165 | keycode = ir_g_keycode_from_table(ictx->idev, release); | 1157 | keycode = ir_g_keycode_from_table(ictx->rdev, release); |
1166 | if (keycode != KEY_RESERVED) | 1158 | if (keycode != KEY_RESERVED) |
1167 | is_release_code = true; | 1159 | is_release_code = true; |
1168 | } | 1160 | } |
@@ -1172,9 +1164,8 @@ static u32 imon_remote_key_lookup(struct imon_context *ictx, u32 hw_code) | |||
1172 | return keycode; | 1164 | return keycode; |
1173 | } | 1165 | } |
1174 | 1166 | ||
1175 | static u32 imon_mce_key_lookup(struct imon_context *ictx, u32 hw_code) | 1167 | static u32 imon_mce_key_lookup(struct imon_context *ictx, u32 scancode) |
1176 | { | 1168 | { |
1177 | u32 scancode = be32_to_cpu(hw_code); | ||
1178 | u32 keycode; | 1169 | u32 keycode; |
1179 | 1170 | ||
1180 | #define MCE_KEY_MASK 0x7000 | 1171 | #define MCE_KEY_MASK 0x7000 |
@@ -1188,18 +1179,21 @@ static u32 imon_mce_key_lookup(struct imon_context *ictx, u32 hw_code) | |||
1188 | * but we can't or them into all codes, as some keys are decoded in | 1179 | * but we can't or them into all codes, as some keys are decoded in |
1189 | * a different way w/o the same use of the toggle bit... | 1180 | * a different way w/o the same use of the toggle bit... |
1190 | */ | 1181 | */ |
1191 | if ((scancode >> 24) & 0x80) | 1182 | if (scancode & 0x80000000) |
1192 | scancode = scancode | MCE_KEY_MASK | MCE_TOGGLE_BIT; | 1183 | scancode = scancode | MCE_KEY_MASK | MCE_TOGGLE_BIT; |
1193 | 1184 | ||
1194 | keycode = ir_g_keycode_from_table(ictx->idev, scancode); | 1185 | ictx->rc_scancode = scancode; |
1186 | keycode = ir_g_keycode_from_table(ictx->rdev, scancode); | ||
1187 | |||
1188 | /* not used in mce mode, but make sure we know its false */ | ||
1189 | ictx->release_code = false; | ||
1195 | 1190 | ||
1196 | return keycode; | 1191 | return keycode; |
1197 | } | 1192 | } |
1198 | 1193 | ||
1199 | static u32 imon_panel_key_lookup(u64 hw_code) | 1194 | static u32 imon_panel_key_lookup(u64 code) |
1200 | { | 1195 | { |
1201 | int i; | 1196 | int i; |
1202 | u64 code = be64_to_cpu(hw_code); | ||
1203 | u32 keycode = KEY_RESERVED; | 1197 | u32 keycode = KEY_RESERVED; |
1204 | 1198 | ||
1205 | for (i = 0; i < ARRAY_SIZE(imon_panel_key_table); i++) { | 1199 | for (i = 0; i < ARRAY_SIZE(imon_panel_key_table); i++) { |
@@ -1219,6 +1213,9 @@ static bool imon_mouse_event(struct imon_context *ictx, | |||
1219 | u8 right_shift = 1; | 1213 | u8 right_shift = 1; |
1220 | bool mouse_input = true; | 1214 | bool mouse_input = true; |
1221 | int dir = 0; | 1215 | int dir = 0; |
1216 | unsigned long flags; | ||
1217 | |||
1218 | spin_lock_irqsave(&ictx->kc_lock, flags); | ||
1222 | 1219 | ||
1223 | /* newer iMON device PAD or mouse button */ | 1220 | /* newer iMON device PAD or mouse button */ |
1224 | if (ictx->product != 0xffdc && (buf[0] & 0x01) && len == 5) { | 1221 | if (ictx->product != 0xffdc && (buf[0] & 0x01) && len == 5) { |
@@ -1250,6 +1247,8 @@ static bool imon_mouse_event(struct imon_context *ictx, | |||
1250 | } else | 1247 | } else |
1251 | mouse_input = false; | 1248 | mouse_input = false; |
1252 | 1249 | ||
1250 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1251 | |||
1253 | if (mouse_input) { | 1252 | if (mouse_input) { |
1254 | dev_dbg(ictx->dev, "sending mouse data via input subsystem\n"); | 1253 | dev_dbg(ictx->dev, "sending mouse data via input subsystem\n"); |
1255 | 1254 | ||
@@ -1264,7 +1263,9 @@ static bool imon_mouse_event(struct imon_context *ictx, | |||
1264 | buf[1] >> right_shift & 0x1); | 1263 | buf[1] >> right_shift & 0x1); |
1265 | } | 1264 | } |
1266 | input_sync(ictx->idev); | 1265 | input_sync(ictx->idev); |
1266 | spin_lock_irqsave(&ictx->kc_lock, flags); | ||
1267 | ictx->last_keycode = ictx->kc; | 1267 | ictx->last_keycode = ictx->kc; |
1268 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1268 | } | 1269 | } |
1269 | 1270 | ||
1270 | return mouse_input; | 1271 | return mouse_input; |
@@ -1286,8 +1287,8 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf) | |||
1286 | int dir = 0; | 1287 | int dir = 0; |
1287 | char rel_x = 0x00, rel_y = 0x00; | 1288 | char rel_x = 0x00, rel_y = 0x00; |
1288 | u16 timeout, threshold; | 1289 | u16 timeout, threshold; |
1289 | u64 temp_key; | 1290 | u32 scancode = KEY_RESERVED; |
1290 | u32 remote_key; | 1291 | unsigned long flags; |
1291 | 1292 | ||
1292 | /* | 1293 | /* |
1293 | * The imon directional pad functions more like a touchpad. Bytes 3 & 4 | 1294 | * The imon directional pad functions more like a touchpad. Bytes 3 & 4 |
@@ -1311,26 +1312,36 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf) | |||
1311 | dir = stabilize((int)rel_x, (int)rel_y, | 1312 | dir = stabilize((int)rel_x, (int)rel_y, |
1312 | timeout, threshold); | 1313 | timeout, threshold); |
1313 | if (!dir) { | 1314 | if (!dir) { |
1315 | spin_lock_irqsave(&ictx->kc_lock, | ||
1316 | flags); | ||
1314 | ictx->kc = KEY_UNKNOWN; | 1317 | ictx->kc = KEY_UNKNOWN; |
1318 | spin_unlock_irqrestore(&ictx->kc_lock, | ||
1319 | flags); | ||
1315 | return; | 1320 | return; |
1316 | } | 1321 | } |
1317 | buf[2] = dir & 0xFF; | 1322 | buf[2] = dir & 0xFF; |
1318 | buf[3] = (dir >> 8) & 0xFF; | 1323 | buf[3] = (dir >> 8) & 0xFF; |
1319 | memcpy(&temp_key, buf, sizeof(temp_key)); | 1324 | scancode = be32_to_cpu(*((u32 *)buf)); |
1320 | remote_key = (u32) (le64_to_cpu(temp_key) | ||
1321 | & 0xffffffff); | ||
1322 | ictx->kc = imon_remote_key_lookup(ictx, | ||
1323 | remote_key); | ||
1324 | } | 1325 | } |
1325 | } else { | 1326 | } else { |
1327 | /* | ||
1328 | * Hack alert: instead of using keycodes, we have | ||
1329 | * to use hard-coded scancodes here... | ||
1330 | */ | ||
1326 | if (abs(rel_y) > abs(rel_x)) { | 1331 | if (abs(rel_y) > abs(rel_x)) { |
1327 | buf[2] = (rel_y > 0) ? 0x7F : 0x80; | 1332 | buf[2] = (rel_y > 0) ? 0x7F : 0x80; |
1328 | buf[3] = 0; | 1333 | buf[3] = 0; |
1329 | ictx->kc = (rel_y > 0) ? KEY_DOWN : KEY_UP; | 1334 | if (rel_y > 0) |
1335 | scancode = 0x01007f00; /* KEY_DOWN */ | ||
1336 | else | ||
1337 | scancode = 0x01008000; /* KEY_UP */ | ||
1330 | } else { | 1338 | } else { |
1331 | buf[2] = 0; | 1339 | buf[2] = 0; |
1332 | buf[3] = (rel_x > 0) ? 0x7F : 0x80; | 1340 | buf[3] = (rel_x > 0) ? 0x7F : 0x80; |
1333 | ictx->kc = (rel_x > 0) ? KEY_RIGHT : KEY_LEFT; | 1341 | if (rel_x > 0) |
1342 | scancode = 0x0100007f; /* KEY_RIGHT */ | ||
1343 | else | ||
1344 | scancode = 0x01000080; /* KEY_LEFT */ | ||
1334 | } | 1345 | } |
1335 | } | 1346 | } |
1336 | 1347 | ||
@@ -1367,34 +1378,56 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf) | |||
1367 | dir = stabilize((int)rel_x, (int)rel_y, | 1378 | dir = stabilize((int)rel_x, (int)rel_y, |
1368 | timeout, threshold); | 1379 | timeout, threshold); |
1369 | if (!dir) { | 1380 | if (!dir) { |
1381 | spin_lock_irqsave(&ictx->kc_lock, flags); | ||
1370 | ictx->kc = KEY_UNKNOWN; | 1382 | ictx->kc = KEY_UNKNOWN; |
1383 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1371 | return; | 1384 | return; |
1372 | } | 1385 | } |
1373 | buf[2] = dir & 0xFF; | 1386 | buf[2] = dir & 0xFF; |
1374 | buf[3] = (dir >> 8) & 0xFF; | 1387 | buf[3] = (dir >> 8) & 0xFF; |
1375 | memcpy(&temp_key, buf, sizeof(temp_key)); | 1388 | scancode = be32_to_cpu(*((u32 *)buf)); |
1376 | remote_key = (u32) (le64_to_cpu(temp_key) & 0xffffffff); | ||
1377 | ictx->kc = imon_remote_key_lookup(ictx, remote_key); | ||
1378 | } else { | 1389 | } else { |
1390 | /* | ||
1391 | * Hack alert: instead of using keycodes, we have | ||
1392 | * to use hard-coded scancodes here... | ||
1393 | */ | ||
1379 | if (abs(rel_y) > abs(rel_x)) { | 1394 | if (abs(rel_y) > abs(rel_x)) { |
1380 | buf[2] = (rel_y > 0) ? 0x7F : 0x80; | 1395 | buf[2] = (rel_y > 0) ? 0x7F : 0x80; |
1381 | buf[3] = 0; | 1396 | buf[3] = 0; |
1382 | ictx->kc = (rel_y > 0) ? KEY_DOWN : KEY_UP; | 1397 | if (rel_y > 0) |
1398 | scancode = 0x01007f00; /* KEY_DOWN */ | ||
1399 | else | ||
1400 | scancode = 0x01008000; /* KEY_UP */ | ||
1383 | } else { | 1401 | } else { |
1384 | buf[2] = 0; | 1402 | buf[2] = 0; |
1385 | buf[3] = (rel_x > 0) ? 0x7F : 0x80; | 1403 | buf[3] = (rel_x > 0) ? 0x7F : 0x80; |
1386 | ictx->kc = (rel_x > 0) ? KEY_RIGHT : KEY_LEFT; | 1404 | if (rel_x > 0) |
1405 | scancode = 0x0100007f; /* KEY_RIGHT */ | ||
1406 | else | ||
1407 | scancode = 0x01000080; /* KEY_LEFT */ | ||
1387 | } | 1408 | } |
1388 | } | 1409 | } |
1389 | } | 1410 | } |
1411 | |||
1412 | if (scancode) { | ||
1413 | spin_lock_irqsave(&ictx->kc_lock, flags); | ||
1414 | ictx->kc = imon_remote_key_lookup(ictx, scancode); | ||
1415 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1416 | } | ||
1390 | } | 1417 | } |
1391 | 1418 | ||
1419 | /** | ||
1420 | * figure out if these is a press or a release. We don't actually | ||
1421 | * care about repeats, as those will be auto-generated within the IR | ||
1422 | * subsystem for repeating scancodes. | ||
1423 | */ | ||
1392 | static int imon_parse_press_type(struct imon_context *ictx, | 1424 | static int imon_parse_press_type(struct imon_context *ictx, |
1393 | unsigned char *buf, u8 ktype) | 1425 | unsigned char *buf, u8 ktype) |
1394 | { | 1426 | { |
1395 | int press_type = 0; | 1427 | int press_type = 0; |
1396 | int rep_delay = ictx->idev->rep[REP_DELAY]; | 1428 | unsigned long flags; |
1397 | int rep_period = ictx->idev->rep[REP_PERIOD]; | 1429 | |
1430 | spin_lock_irqsave(&ictx->kc_lock, flags); | ||
1398 | 1431 | ||
1399 | /* key release of 0x02XXXXXX key */ | 1432 | /* key release of 0x02XXXXXX key */ |
1400 | if (ictx->kc == KEY_RESERVED && buf[0] == 0x02 && buf[3] == 0x00) | 1433 | if (ictx->kc == KEY_RESERVED && buf[0] == 0x02 && buf[3] == 0x00) |
@@ -1410,22 +1443,10 @@ static int imon_parse_press_type(struct imon_context *ictx, | |||
1410 | buf[2] == 0x81 && buf[3] == 0xb7) | 1443 | buf[2] == 0x81 && buf[3] == 0xb7) |
1411 | ictx->kc = ictx->last_keycode; | 1444 | ictx->kc = ictx->last_keycode; |
1412 | 1445 | ||
1413 | /* mce-specific button handling */ | 1446 | /* mce-specific button handling, no keyup events */ |
1414 | else if (ktype == IMON_KEY_MCE) { | 1447 | else if (ktype == IMON_KEY_MCE) { |
1415 | /* initial press */ | 1448 | ictx->rc_toggle = buf[2]; |
1416 | if (ictx->kc != ictx->last_keycode | 1449 | press_type = 1; |
1417 | || buf[2] != ictx->mce_toggle_bit) { | ||
1418 | ictx->last_keycode = ictx->kc; | ||
1419 | ictx->mce_toggle_bit = buf[2]; | ||
1420 | press_type = 1; | ||
1421 | mod_timer(&ictx->itimer, | ||
1422 | jiffies + msecs_to_jiffies(rep_delay)); | ||
1423 | /* repeat */ | ||
1424 | } else { | ||
1425 | press_type = 2; | ||
1426 | mod_timer(&ictx->itimer, | ||
1427 | jiffies + msecs_to_jiffies(rep_period)); | ||
1428 | } | ||
1429 | 1450 | ||
1430 | /* incoherent or irrelevant data */ | 1451 | /* incoherent or irrelevant data */ |
1431 | } else if (ictx->kc == KEY_RESERVED) | 1452 | } else if (ictx->kc == KEY_RESERVED) |
@@ -1439,6 +1460,8 @@ static int imon_parse_press_type(struct imon_context *ictx, | |||
1439 | else | 1460 | else |
1440 | press_type = 1; | 1461 | press_type = 1; |
1441 | 1462 | ||
1463 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1464 | |||
1442 | return press_type; | 1465 | return press_type; |
1443 | } | 1466 | } |
1444 | 1467 | ||
@@ -1451,41 +1474,45 @@ static void imon_incoming_packet(struct imon_context *ictx, | |||
1451 | int len = urb->actual_length; | 1474 | int len = urb->actual_length; |
1452 | unsigned char *buf = urb->transfer_buffer; | 1475 | unsigned char *buf = urb->transfer_buffer; |
1453 | struct device *dev = ictx->dev; | 1476 | struct device *dev = ictx->dev; |
1477 | unsigned long flags; | ||
1454 | u32 kc; | 1478 | u32 kc; |
1455 | bool norelease = false; | 1479 | bool norelease = false; |
1456 | int i; | 1480 | int i; |
1457 | u64 temp_key; | 1481 | u64 scancode; |
1458 | u64 panel_key = 0; | 1482 | struct input_dev *rdev = NULL; |
1459 | u32 remote_key = 0; | 1483 | struct ir_input_dev *irdev = NULL; |
1460 | struct input_dev *idev = NULL; | ||
1461 | int press_type = 0; | 1484 | int press_type = 0; |
1462 | int msec; | 1485 | int msec; |
1463 | struct timeval t; | 1486 | struct timeval t; |
1464 | static struct timeval prev_time = { 0, 0 }; | 1487 | static struct timeval prev_time = { 0, 0 }; |
1465 | u8 ktype = IMON_KEY_IMON; | 1488 | u8 ktype; |
1466 | 1489 | ||
1467 | idev = ictx->idev; | 1490 | rdev = ictx->rdev; |
1491 | irdev = input_get_drvdata(rdev); | ||
1468 | 1492 | ||
1469 | /* filter out junk data on the older 0xffdc imon devices */ | 1493 | /* filter out junk data on the older 0xffdc imon devices */ |
1470 | if ((buf[0] == 0xff) && (buf[1] == 0xff) && (buf[2] == 0xff)) | 1494 | if ((buf[0] == 0xff) && (buf[1] == 0xff) && (buf[2] == 0xff)) |
1471 | return; | 1495 | return; |
1472 | 1496 | ||
1473 | /* Figure out what key was pressed */ | 1497 | /* Figure out what key was pressed */ |
1474 | memcpy(&temp_key, buf, sizeof(temp_key)); | ||
1475 | if (len == 8 && buf[7] == 0xee) { | 1498 | if (len == 8 && buf[7] == 0xee) { |
1499 | scancode = be64_to_cpu(*((u64 *)buf)); | ||
1476 | ktype = IMON_KEY_PANEL; | 1500 | ktype = IMON_KEY_PANEL; |
1477 | panel_key = le64_to_cpu(temp_key); | 1501 | kc = imon_panel_key_lookup(scancode); |
1478 | kc = imon_panel_key_lookup(panel_key); | ||
1479 | } else { | 1502 | } else { |
1480 | remote_key = (u32) (le64_to_cpu(temp_key) & 0xffffffff); | 1503 | scancode = be32_to_cpu(*((u32 *)buf)); |
1481 | if (ictx->ir_type == IR_TYPE_RC6) { | 1504 | if (ictx->ir_type == IR_TYPE_RC6) { |
1505 | ktype = IMON_KEY_IMON; | ||
1482 | if (buf[0] == 0x80) | 1506 | if (buf[0] == 0x80) |
1483 | ktype = IMON_KEY_MCE; | 1507 | ktype = IMON_KEY_MCE; |
1484 | kc = imon_mce_key_lookup(ictx, remote_key); | 1508 | kc = imon_mce_key_lookup(ictx, scancode); |
1485 | } else | 1509 | } else { |
1486 | kc = imon_remote_key_lookup(ictx, remote_key); | 1510 | ktype = IMON_KEY_IMON; |
1511 | kc = imon_remote_key_lookup(ictx, scancode); | ||
1512 | } | ||
1487 | } | 1513 | } |
1488 | 1514 | ||
1515 | spin_lock_irqsave(&ictx->kc_lock, flags); | ||
1489 | /* keyboard/mouse mode toggle button */ | 1516 | /* keyboard/mouse mode toggle button */ |
1490 | if (kc == KEY_KEYBOARD && !ictx->release_code) { | 1517 | if (kc == KEY_KEYBOARD && !ictx->release_code) { |
1491 | ictx->last_keycode = kc; | 1518 | ictx->last_keycode = kc; |
@@ -1493,6 +1520,7 @@ static void imon_incoming_packet(struct imon_context *ictx, | |||
1493 | ictx->pad_mouse = ~(ictx->pad_mouse) & 0x1; | 1520 | ictx->pad_mouse = ~(ictx->pad_mouse) & 0x1; |
1494 | dev_dbg(dev, "toggling to %s mode\n", | 1521 | dev_dbg(dev, "toggling to %s mode\n", |
1495 | ictx->pad_mouse ? "mouse" : "keyboard"); | 1522 | ictx->pad_mouse ? "mouse" : "keyboard"); |
1523 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1496 | return; | 1524 | return; |
1497 | } else { | 1525 | } else { |
1498 | ictx->pad_mouse = 0; | 1526 | ictx->pad_mouse = 0; |
@@ -1501,11 +1529,13 @@ static void imon_incoming_packet(struct imon_context *ictx, | |||
1501 | } | 1529 | } |
1502 | 1530 | ||
1503 | ictx->kc = kc; | 1531 | ictx->kc = kc; |
1532 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1504 | 1533 | ||
1505 | /* send touchscreen events through input subsystem if touchpad data */ | 1534 | /* send touchscreen events through input subsystem if touchpad data */ |
1506 | if (ictx->display_type == IMON_DISPLAY_TYPE_VGA && len == 8 && | 1535 | if (ictx->display_type == IMON_DISPLAY_TYPE_VGA && len == 8 && |
1507 | buf[7] == 0x86) { | 1536 | buf[7] == 0x86) { |
1508 | imon_touch_event(ictx, buf); | 1537 | imon_touch_event(ictx, buf); |
1538 | return; | ||
1509 | 1539 | ||
1510 | /* look for mouse events with pad in mouse mode */ | 1540 | /* look for mouse events with pad in mouse mode */ |
1511 | } else if (ictx->pad_mouse) { | 1541 | } else if (ictx->pad_mouse) { |
@@ -1533,36 +1563,55 @@ static void imon_incoming_packet(struct imon_context *ictx, | |||
1533 | if (press_type < 0) | 1563 | if (press_type < 0) |
1534 | goto not_input_data; | 1564 | goto not_input_data; |
1535 | 1565 | ||
1566 | spin_lock_irqsave(&ictx->kc_lock, flags); | ||
1536 | if (ictx->kc == KEY_UNKNOWN) | 1567 | if (ictx->kc == KEY_UNKNOWN) |
1537 | goto unknown_key; | 1568 | goto unknown_key; |
1569 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1570 | |||
1571 | if (ktype != IMON_KEY_PANEL) { | ||
1572 | if (press_type == 0) | ||
1573 | ir_keyup(irdev); | ||
1574 | else { | ||
1575 | ir_keydown(rdev, ictx->rc_scancode, ictx->rc_toggle); | ||
1576 | spin_lock_irqsave(&ictx->kc_lock, flags); | ||
1577 | ictx->last_keycode = ictx->kc; | ||
1578 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1579 | } | ||
1580 | return; | ||
1581 | } | ||
1538 | 1582 | ||
1539 | /* KEY_MUTE repeats from MCE and knob need to be suppressed */ | 1583 | /* Only panel type events left to process now */ |
1540 | if ((ictx->kc == KEY_MUTE && ictx->kc == ictx->last_keycode) | 1584 | spin_lock_irqsave(&ictx->kc_lock, flags); |
1541 | && (buf[7] == 0xee || ktype == IMON_KEY_MCE)) { | 1585 | |
1586 | /* KEY_MUTE repeats from knob need to be suppressed */ | ||
1587 | if (ictx->kc == KEY_MUTE && ictx->kc == ictx->last_keycode) { | ||
1542 | do_gettimeofday(&t); | 1588 | do_gettimeofday(&t); |
1543 | msec = tv2int(&t, &prev_time); | 1589 | msec = tv2int(&t, &prev_time); |
1544 | prev_time = t; | 1590 | prev_time = t; |
1545 | if (msec < idev->rep[REP_DELAY]) | 1591 | if (msec < ictx->idev->rep[REP_DELAY]) { |
1592 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1546 | return; | 1593 | return; |
1594 | } | ||
1547 | } | 1595 | } |
1596 | kc = ictx->kc; | ||
1548 | 1597 | ||
1549 | input_report_key(idev, ictx->kc, press_type); | 1598 | spin_unlock_irqrestore(&ictx->kc_lock, flags); |
1550 | input_sync(idev); | ||
1551 | 1599 | ||
1552 | /* panel keys and some remote keys don't generate a release */ | 1600 | input_report_key(ictx->idev, kc, press_type); |
1553 | if (panel_key || norelease) { | 1601 | input_sync(ictx->idev); |
1554 | input_report_key(idev, ictx->kc, 0); | ||
1555 | input_sync(idev); | ||
1556 | } | ||
1557 | 1602 | ||
1558 | ictx->last_keycode = ictx->kc; | 1603 | /* panel keys don't generate a release */ |
1604 | input_report_key(ictx->idev, kc, 0); | ||
1605 | input_sync(ictx->idev); | ||
1606 | |||
1607 | ictx->last_keycode = kc; | ||
1559 | 1608 | ||
1560 | return; | 1609 | return; |
1561 | 1610 | ||
1562 | unknown_key: | 1611 | unknown_key: |
1612 | spin_unlock_irqrestore(&ictx->kc_lock, flags); | ||
1563 | dev_info(dev, "%s: unknown keypress, code 0x%llx\n", __func__, | 1613 | dev_info(dev, "%s: unknown keypress, code 0x%llx\n", __func__, |
1564 | (panel_key ? be64_to_cpu(panel_key) : | 1614 | (long long)scancode); |
1565 | be32_to_cpu(remote_key))); | ||
1566 | return; | 1615 | return; |
1567 | 1616 | ||
1568 | not_input_data: | 1617 | not_input_data: |
@@ -1653,31 +1702,205 @@ static void usb_rx_callback_intf1(struct urb *urb) | |||
1653 | usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC); | 1702 | usb_submit_urb(ictx->rx_urb_intf1, GFP_ATOMIC); |
1654 | } | 1703 | } |
1655 | 1704 | ||
1705 | /* | ||
1706 | * The 0x15c2:0xffdc device ID was used for umpteen different imon | ||
1707 | * devices, and all of them constantly spew interrupts, even when there | ||
1708 | * is no actual data to report. However, byte 6 of this buffer looks like | ||
1709 | * its unique across device variants, so we're trying to key off that to | ||
1710 | * figure out which display type (if any) and what IR protocol the device | ||
1711 | * actually supports. These devices have their IR protocol hard-coded into | ||
1712 | * their firmware, they can't be changed on the fly like the newer hardware. | ||
1713 | */ | ||
1714 | static void imon_get_ffdc_type(struct imon_context *ictx) | ||
1715 | { | ||
1716 | u8 ffdc_cfg_byte = ictx->usb_rx_buf[6]; | ||
1717 | u8 detected_display_type = IMON_DISPLAY_TYPE_NONE; | ||
1718 | u64 allowed_protos = IR_TYPE_OTHER; | ||
1719 | |||
1720 | switch (ffdc_cfg_byte) { | ||
1721 | /* iMON Knob, no display, iMON IR + vol knob */ | ||
1722 | case 0x21: | ||
1723 | dev_info(ictx->dev, "0xffdc iMON Knob, iMON IR"); | ||
1724 | ictx->display_supported = false; | ||
1725 | break; | ||
1726 | /* iMON 2.4G LT (usb stick), no display, iMON RF */ | ||
1727 | case 0x4e: | ||
1728 | dev_info(ictx->dev, "0xffdc iMON 2.4G LT, iMON RF"); | ||
1729 | ictx->display_supported = false; | ||
1730 | ictx->rf_device = true; | ||
1731 | break; | ||
1732 | /* iMON VFD, no IR (does have vol knob tho) */ | ||
1733 | case 0x35: | ||
1734 | dev_info(ictx->dev, "0xffdc iMON VFD + knob, no IR"); | ||
1735 | detected_display_type = IMON_DISPLAY_TYPE_VFD; | ||
1736 | break; | ||
1737 | /* iMON VFD, iMON IR */ | ||
1738 | case 0x24: | ||
1739 | case 0x85: | ||
1740 | dev_info(ictx->dev, "0xffdc iMON VFD, iMON IR"); | ||
1741 | detected_display_type = IMON_DISPLAY_TYPE_VFD; | ||
1742 | break; | ||
1743 | /* iMON VFD, MCE IR */ | ||
1744 | case 0x9e: | ||
1745 | dev_info(ictx->dev, "0xffdc iMON VFD, MCE IR"); | ||
1746 | detected_display_type = IMON_DISPLAY_TYPE_VFD; | ||
1747 | allowed_protos = IR_TYPE_RC6; | ||
1748 | break; | ||
1749 | /* iMON LCD, MCE IR */ | ||
1750 | case 0x9f: | ||
1751 | dev_info(ictx->dev, "0xffdc iMON LCD, MCE IR"); | ||
1752 | detected_display_type = IMON_DISPLAY_TYPE_LCD; | ||
1753 | allowed_protos = IR_TYPE_RC6; | ||
1754 | break; | ||
1755 | default: | ||
1756 | dev_info(ictx->dev, "Unknown 0xffdc device, " | ||
1757 | "defaulting to VFD and iMON IR"); | ||
1758 | detected_display_type = IMON_DISPLAY_TYPE_VFD; | ||
1759 | break; | ||
1760 | } | ||
1761 | |||
1762 | printk(KERN_CONT " (id 0x%02x)\n", ffdc_cfg_byte); | ||
1763 | |||
1764 | ictx->display_type = detected_display_type; | ||
1765 | ictx->props->allowed_protos = allowed_protos; | ||
1766 | ictx->ir_type = allowed_protos; | ||
1767 | } | ||
1768 | |||
1769 | static void imon_set_display_type(struct imon_context *ictx) | ||
1770 | { | ||
1771 | u8 configured_display_type = IMON_DISPLAY_TYPE_VFD; | ||
1772 | |||
1773 | /* | ||
1774 | * Try to auto-detect the type of display if the user hasn't set | ||
1775 | * it by hand via the display_type modparam. Default is VFD. | ||
1776 | */ | ||
1777 | |||
1778 | if (display_type == IMON_DISPLAY_TYPE_AUTO) { | ||
1779 | switch (ictx->product) { | ||
1780 | case 0xffdc: | ||
1781 | /* set in imon_get_ffdc_type() */ | ||
1782 | configured_display_type = ictx->display_type; | ||
1783 | break; | ||
1784 | case 0x0034: | ||
1785 | case 0x0035: | ||
1786 | configured_display_type = IMON_DISPLAY_TYPE_VGA; | ||
1787 | break; | ||
1788 | case 0x0038: | ||
1789 | case 0x0039: | ||
1790 | case 0x0045: | ||
1791 | configured_display_type = IMON_DISPLAY_TYPE_LCD; | ||
1792 | break; | ||
1793 | case 0x003c: | ||
1794 | case 0x0041: | ||
1795 | case 0x0042: | ||
1796 | case 0x0043: | ||
1797 | configured_display_type = IMON_DISPLAY_TYPE_NONE; | ||
1798 | ictx->display_supported = false; | ||
1799 | break; | ||
1800 | case 0x0036: | ||
1801 | case 0x0044: | ||
1802 | default: | ||
1803 | configured_display_type = IMON_DISPLAY_TYPE_VFD; | ||
1804 | break; | ||
1805 | } | ||
1806 | } else { | ||
1807 | configured_display_type = display_type; | ||
1808 | if (display_type == IMON_DISPLAY_TYPE_NONE) | ||
1809 | ictx->display_supported = false; | ||
1810 | else | ||
1811 | ictx->display_supported = true; | ||
1812 | dev_info(ictx->dev, "%s: overriding display type to %d via " | ||
1813 | "modparam\n", __func__, display_type); | ||
1814 | } | ||
1815 | |||
1816 | ictx->display_type = configured_display_type; | ||
1817 | } | ||
1818 | |||
1819 | static struct input_dev *imon_init_rdev(struct imon_context *ictx) | ||
1820 | { | ||
1821 | struct input_dev *rdev; | ||
1822 | struct ir_dev_props *props; | ||
1823 | int ret; | ||
1824 | char *ir_codes = NULL; | ||
1825 | const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00, | ||
1826 | 0x00, 0x00, 0x00, 0x88 }; | ||
1827 | |||
1828 | rdev = input_allocate_device(); | ||
1829 | props = kzalloc(sizeof(*props), GFP_KERNEL); | ||
1830 | if (!rdev || !props) { | ||
1831 | dev_err(ictx->dev, "remote control dev allocation failed\n"); | ||
1832 | goto out; | ||
1833 | } | ||
1834 | |||
1835 | snprintf(ictx->name_rdev, sizeof(ictx->name_rdev), | ||
1836 | "iMON Remote (%04x:%04x)", ictx->vendor, ictx->product); | ||
1837 | usb_make_path(ictx->usbdev_intf0, ictx->phys_rdev, | ||
1838 | sizeof(ictx->phys_rdev)); | ||
1839 | strlcat(ictx->phys_rdev, "/input0", sizeof(ictx->phys_rdev)); | ||
1840 | |||
1841 | rdev->name = ictx->name_rdev; | ||
1842 | rdev->phys = ictx->phys_rdev; | ||
1843 | usb_to_input_id(ictx->usbdev_intf0, &rdev->id); | ||
1844 | rdev->dev.parent = ictx->dev; | ||
1845 | rdev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP); | ||
1846 | input_set_drvdata(rdev, ictx); | ||
1847 | |||
1848 | props->priv = ictx; | ||
1849 | props->driver_type = RC_DRIVER_SCANCODE; | ||
1850 | props->allowed_protos = IR_TYPE_OTHER | IR_TYPE_RC6; /* iMON PAD or MCE */ | ||
1851 | props->change_protocol = imon_ir_change_protocol; | ||
1852 | ictx->props = props; | ||
1853 | |||
1854 | /* Enable front-panel buttons and/or knobs */ | ||
1855 | memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet)); | ||
1856 | ret = send_packet(ictx); | ||
1857 | /* Not fatal, but warn about it */ | ||
1858 | if (ret) | ||
1859 | dev_info(ictx->dev, "panel buttons/knobs setup failed\n"); | ||
1860 | |||
1861 | if (ictx->product == 0xffdc) | ||
1862 | imon_get_ffdc_type(ictx); | ||
1863 | |||
1864 | imon_set_display_type(ictx); | ||
1865 | |||
1866 | if (ictx->ir_type == IR_TYPE_RC6) | ||
1867 | ir_codes = RC_MAP_IMON_MCE; | ||
1868 | else | ||
1869 | ir_codes = RC_MAP_IMON_PAD; | ||
1870 | |||
1871 | ret = ir_input_register(rdev, ir_codes, props, MOD_NAME); | ||
1872 | if (ret < 0) { | ||
1873 | dev_err(ictx->dev, "remote input dev register failed\n"); | ||
1874 | goto out; | ||
1875 | } | ||
1876 | |||
1877 | return rdev; | ||
1878 | |||
1879 | out: | ||
1880 | kfree(props); | ||
1881 | input_free_device(rdev); | ||
1882 | return NULL; | ||
1883 | } | ||
1884 | |||
1656 | static struct input_dev *imon_init_idev(struct imon_context *ictx) | 1885 | static struct input_dev *imon_init_idev(struct imon_context *ictx) |
1657 | { | 1886 | { |
1658 | struct input_dev *idev; | 1887 | struct input_dev *idev; |
1659 | struct ir_dev_props *props; | ||
1660 | int ret, i; | 1888 | int ret, i; |
1661 | 1889 | ||
1662 | idev = input_allocate_device(); | 1890 | idev = input_allocate_device(); |
1663 | if (!idev) { | 1891 | if (!idev) { |
1664 | dev_err(ictx->dev, "remote input dev allocation failed\n"); | 1892 | dev_err(ictx->dev, "input dev allocation failed\n"); |
1665 | goto idev_alloc_failed; | 1893 | goto out; |
1666 | } | ||
1667 | |||
1668 | props = kzalloc(sizeof(struct ir_dev_props), GFP_KERNEL); | ||
1669 | if (!props) { | ||
1670 | dev_err(ictx->dev, "remote ir dev props allocation failed\n"); | ||
1671 | goto props_alloc_failed; | ||
1672 | } | 1894 | } |
1673 | 1895 | ||
1674 | snprintf(ictx->name_idev, sizeof(ictx->name_idev), | 1896 | snprintf(ictx->name_idev, sizeof(ictx->name_idev), |
1675 | "iMON Remote (%04x:%04x)", ictx->vendor, ictx->product); | 1897 | "iMON Panel, Knob and Mouse(%04x:%04x)", |
1898 | ictx->vendor, ictx->product); | ||
1676 | idev->name = ictx->name_idev; | 1899 | idev->name = ictx->name_idev; |
1677 | 1900 | ||
1678 | usb_make_path(ictx->usbdev_intf0, ictx->phys_idev, | 1901 | usb_make_path(ictx->usbdev_intf0, ictx->phys_idev, |
1679 | sizeof(ictx->phys_idev)); | 1902 | sizeof(ictx->phys_idev)); |
1680 | strlcat(ictx->phys_idev, "/input0", sizeof(ictx->phys_idev)); | 1903 | strlcat(ictx->phys_idev, "/input1", sizeof(ictx->phys_idev)); |
1681 | idev->phys = ictx->phys_idev; | 1904 | idev->phys = ictx->phys_idev; |
1682 | 1905 | ||
1683 | idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_REL); | 1906 | idev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP) | BIT_MASK(EV_REL); |
@@ -1693,30 +1916,20 @@ static struct input_dev *imon_init_idev(struct imon_context *ictx) | |||
1693 | __set_bit(kc, idev->keybit); | 1916 | __set_bit(kc, idev->keybit); |
1694 | } | 1917 | } |
1695 | 1918 | ||
1696 | props->priv = ictx; | ||
1697 | props->driver_type = RC_DRIVER_SCANCODE; | ||
1698 | /* IR_TYPE_OTHER maps to iMON PAD remote, IR_TYPE_RC6 to MCE remote */ | ||
1699 | props->allowed_protos = IR_TYPE_OTHER | IR_TYPE_RC6; | ||
1700 | props->change_protocol = imon_ir_change_protocol; | ||
1701 | ictx->props = props; | ||
1702 | |||
1703 | usb_to_input_id(ictx->usbdev_intf0, &idev->id); | 1919 | usb_to_input_id(ictx->usbdev_intf0, &idev->id); |
1704 | idev->dev.parent = ictx->dev; | 1920 | idev->dev.parent = ictx->dev; |
1921 | input_set_drvdata(idev, ictx); | ||
1705 | 1922 | ||
1706 | ret = ir_input_register(idev, RC_MAP_IMON_PAD, props, MOD_NAME); | 1923 | ret = input_register_device(idev); |
1707 | if (ret < 0) { | 1924 | if (ret < 0) { |
1708 | dev_err(ictx->dev, "remote input dev register failed\n"); | 1925 | dev_err(ictx->dev, "input dev register failed\n"); |
1709 | goto idev_register_failed; | 1926 | goto out; |
1710 | } | 1927 | } |
1711 | 1928 | ||
1712 | return idev; | 1929 | return idev; |
1713 | 1930 | ||
1714 | idev_register_failed: | 1931 | out: |
1715 | kfree(props); | ||
1716 | props_alloc_failed: | ||
1717 | input_free_device(idev); | 1932 | input_free_device(idev); |
1718 | idev_alloc_failed: | ||
1719 | |||
1720 | return NULL; | 1933 | return NULL; |
1721 | } | 1934 | } |
1722 | 1935 | ||
@@ -1738,7 +1951,7 @@ static struct input_dev *imon_init_touch(struct imon_context *ictx) | |||
1738 | 1951 | ||
1739 | usb_make_path(ictx->usbdev_intf1, ictx->phys_touch, | 1952 | usb_make_path(ictx->usbdev_intf1, ictx->phys_touch, |
1740 | sizeof(ictx->phys_touch)); | 1953 | sizeof(ictx->phys_touch)); |
1741 | strlcat(ictx->phys_touch, "/input1", sizeof(ictx->phys_touch)); | 1954 | strlcat(ictx->phys_touch, "/input2", sizeof(ictx->phys_touch)); |
1742 | touch->phys = ictx->phys_touch; | 1955 | touch->phys = ictx->phys_touch; |
1743 | 1956 | ||
1744 | touch->evbit[0] = | 1957 | touch->evbit[0] = |
@@ -1850,7 +2063,7 @@ static bool imon_find_endpoints(struct imon_context *ictx, | |||
1850 | 2063 | ||
1851 | /* Input endpoint is mandatory */ | 2064 | /* Input endpoint is mandatory */ |
1852 | if (!ir_ep_found) | 2065 | if (!ir_ep_found) |
1853 | err("%s: no valid input (IR) endpoint found.", __func__); | 2066 | pr_err("no valid input (IR) endpoint found\n"); |
1854 | 2067 | ||
1855 | ictx->tx_control = tx_control; | 2068 | ictx->tx_control = tx_control; |
1856 | 2069 | ||
@@ -1888,6 +2101,7 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf) | |||
1888 | } | 2101 | } |
1889 | 2102 | ||
1890 | mutex_init(&ictx->lock); | 2103 | mutex_init(&ictx->lock); |
2104 | spin_lock_init(&ictx->kc_lock); | ||
1891 | 2105 | ||
1892 | mutex_lock(&ictx->lock); | 2106 | mutex_lock(&ictx->lock); |
1893 | 2107 | ||
@@ -1913,6 +2127,12 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf) | |||
1913 | goto idev_setup_failed; | 2127 | goto idev_setup_failed; |
1914 | } | 2128 | } |
1915 | 2129 | ||
2130 | ictx->rdev = imon_init_rdev(ictx); | ||
2131 | if (!ictx->rdev) { | ||
2132 | dev_err(dev, "%s: rc device setup failed\n", __func__); | ||
2133 | goto rdev_setup_failed; | ||
2134 | } | ||
2135 | |||
1916 | usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, | 2136 | usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, |
1917 | usb_rcvintpipe(ictx->usbdev_intf0, | 2137 | usb_rcvintpipe(ictx->usbdev_intf0, |
1918 | ictx->rx_endpoint_intf0->bEndpointAddress), | 2138 | ictx->rx_endpoint_intf0->bEndpointAddress), |
@@ -1922,15 +2142,16 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf) | |||
1922 | 2142 | ||
1923 | ret = usb_submit_urb(ictx->rx_urb_intf0, GFP_KERNEL); | 2143 | ret = usb_submit_urb(ictx->rx_urb_intf0, GFP_KERNEL); |
1924 | if (ret) { | 2144 | if (ret) { |
1925 | err("%s: usb_submit_urb failed for intf0 (%d)", | 2145 | pr_err("usb_submit_urb failed for intf0 (%d)\n", ret); |
1926 | __func__, ret); | ||
1927 | goto urb_submit_failed; | 2146 | goto urb_submit_failed; |
1928 | } | 2147 | } |
1929 | 2148 | ||
1930 | return ictx; | 2149 | return ictx; |
1931 | 2150 | ||
1932 | urb_submit_failed: | 2151 | urb_submit_failed: |
1933 | ir_input_unregister(ictx->idev); | 2152 | ir_input_unregister(ictx->rdev); |
2153 | rdev_setup_failed: | ||
2154 | input_unregister_device(ictx->idev); | ||
1934 | idev_setup_failed: | 2155 | idev_setup_failed: |
1935 | find_endpoint_failed: | 2156 | find_endpoint_failed: |
1936 | mutex_unlock(&ictx->lock); | 2157 | mutex_unlock(&ictx->lock); |
@@ -1954,7 +2175,7 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf, | |||
1954 | 2175 | ||
1955 | rx_urb = usb_alloc_urb(0, GFP_KERNEL); | 2176 | rx_urb = usb_alloc_urb(0, GFP_KERNEL); |
1956 | if (!rx_urb) { | 2177 | if (!rx_urb) { |
1957 | err("%s: usb_alloc_urb failed for IR urb", __func__); | 2178 | pr_err("usb_alloc_urb failed for IR urb\n"); |
1958 | goto rx_urb_alloc_failed; | 2179 | goto rx_urb_alloc_failed; |
1959 | } | 2180 | } |
1960 | 2181 | ||
@@ -1992,8 +2213,7 @@ static struct imon_context *imon_init_intf1(struct usb_interface *intf, | |||
1992 | ret = usb_submit_urb(ictx->rx_urb_intf1, GFP_KERNEL); | 2213 | ret = usb_submit_urb(ictx->rx_urb_intf1, GFP_KERNEL); |
1993 | 2214 | ||
1994 | if (ret) { | 2215 | if (ret) { |
1995 | err("%s: usb_submit_urb failed for intf1 (%d)", | 2216 | pr_err("usb_submit_urb failed for intf1 (%d)\n", ret); |
1996 | __func__, ret); | ||
1997 | goto urb_submit_failed; | 2217 | goto urb_submit_failed; |
1998 | } | 2218 | } |
1999 | 2219 | ||
@@ -2012,116 +2232,6 @@ rx_urb_alloc_failed: | |||
2012 | return NULL; | 2232 | return NULL; |
2013 | } | 2233 | } |
2014 | 2234 | ||
2015 | /* | ||
2016 | * The 0x15c2:0xffdc device ID was used for umpteen different imon | ||
2017 | * devices, and all of them constantly spew interrupts, even when there | ||
2018 | * is no actual data to report. However, byte 6 of this buffer looks like | ||
2019 | * its unique across device variants, so we're trying to key off that to | ||
2020 | * figure out which display type (if any) and what IR protocol the device | ||
2021 | * actually supports. These devices have their IR protocol hard-coded into | ||
2022 | * their firmware, they can't be changed on the fly like the newer hardware. | ||
2023 | */ | ||
2024 | static void imon_get_ffdc_type(struct imon_context *ictx) | ||
2025 | { | ||
2026 | u8 ffdc_cfg_byte = ictx->usb_rx_buf[6]; | ||
2027 | u8 detected_display_type = IMON_DISPLAY_TYPE_NONE; | ||
2028 | u64 allowed_protos = IR_TYPE_OTHER; | ||
2029 | |||
2030 | switch (ffdc_cfg_byte) { | ||
2031 | /* iMON Knob, no display, iMON IR + vol knob */ | ||
2032 | case 0x21: | ||
2033 | dev_info(ictx->dev, "0xffdc iMON Knob, iMON IR"); | ||
2034 | ictx->display_supported = false; | ||
2035 | break; | ||
2036 | /* iMON 2.4G LT (usb stick), no display, iMON RF */ | ||
2037 | case 0x4e: | ||
2038 | dev_info(ictx->dev, "0xffdc iMON 2.4G LT, iMON RF"); | ||
2039 | ictx->display_supported = false; | ||
2040 | ictx->rf_device = true; | ||
2041 | break; | ||
2042 | /* iMON VFD, no IR (does have vol knob tho) */ | ||
2043 | case 0x35: | ||
2044 | dev_info(ictx->dev, "0xffdc iMON VFD + knob, no IR"); | ||
2045 | detected_display_type = IMON_DISPLAY_TYPE_VFD; | ||
2046 | break; | ||
2047 | /* iMON VFD, iMON IR */ | ||
2048 | case 0x24: | ||
2049 | case 0x85: | ||
2050 | dev_info(ictx->dev, "0xffdc iMON VFD, iMON IR"); | ||
2051 | detected_display_type = IMON_DISPLAY_TYPE_VFD; | ||
2052 | break; | ||
2053 | /* iMON LCD, MCE IR */ | ||
2054 | case 0x9e: | ||
2055 | case 0x9f: | ||
2056 | dev_info(ictx->dev, "0xffdc iMON LCD, MCE IR"); | ||
2057 | detected_display_type = IMON_DISPLAY_TYPE_LCD; | ||
2058 | allowed_protos = IR_TYPE_RC6; | ||
2059 | break; | ||
2060 | default: | ||
2061 | dev_info(ictx->dev, "Unknown 0xffdc device, " | ||
2062 | "defaulting to VFD and iMON IR"); | ||
2063 | detected_display_type = IMON_DISPLAY_TYPE_VFD; | ||
2064 | break; | ||
2065 | } | ||
2066 | |||
2067 | printk(KERN_CONT " (id 0x%02x)\n", ffdc_cfg_byte); | ||
2068 | |||
2069 | ictx->display_type = detected_display_type; | ||
2070 | ictx->props->allowed_protos = allowed_protos; | ||
2071 | ictx->ir_type = allowed_protos; | ||
2072 | } | ||
2073 | |||
2074 | static void imon_set_display_type(struct imon_context *ictx, | ||
2075 | struct usb_interface *intf) | ||
2076 | { | ||
2077 | u8 configured_display_type = IMON_DISPLAY_TYPE_VFD; | ||
2078 | |||
2079 | /* | ||
2080 | * Try to auto-detect the type of display if the user hasn't set | ||
2081 | * it by hand via the display_type modparam. Default is VFD. | ||
2082 | */ | ||
2083 | |||
2084 | if (display_type == IMON_DISPLAY_TYPE_AUTO) { | ||
2085 | switch (ictx->product) { | ||
2086 | case 0xffdc: | ||
2087 | /* set in imon_get_ffdc_type() */ | ||
2088 | configured_display_type = ictx->display_type; | ||
2089 | break; | ||
2090 | case 0x0034: | ||
2091 | case 0x0035: | ||
2092 | configured_display_type = IMON_DISPLAY_TYPE_VGA; | ||
2093 | break; | ||
2094 | case 0x0038: | ||
2095 | case 0x0039: | ||
2096 | case 0x0045: | ||
2097 | configured_display_type = IMON_DISPLAY_TYPE_LCD; | ||
2098 | break; | ||
2099 | case 0x003c: | ||
2100 | case 0x0041: | ||
2101 | case 0x0042: | ||
2102 | case 0x0043: | ||
2103 | configured_display_type = IMON_DISPLAY_TYPE_NONE; | ||
2104 | ictx->display_supported = false; | ||
2105 | break; | ||
2106 | case 0x0036: | ||
2107 | case 0x0044: | ||
2108 | default: | ||
2109 | configured_display_type = IMON_DISPLAY_TYPE_VFD; | ||
2110 | break; | ||
2111 | } | ||
2112 | } else { | ||
2113 | configured_display_type = display_type; | ||
2114 | if (display_type == IMON_DISPLAY_TYPE_NONE) | ||
2115 | ictx->display_supported = false; | ||
2116 | else | ||
2117 | ictx->display_supported = true; | ||
2118 | dev_info(ictx->dev, "%s: overriding display type to %d via " | ||
2119 | "modparam\n", __func__, display_type); | ||
2120 | } | ||
2121 | |||
2122 | ictx->display_type = configured_display_type; | ||
2123 | } | ||
2124 | |||
2125 | static void imon_init_display(struct imon_context *ictx, | 2235 | static void imon_init_display(struct imon_context *ictx, |
2126 | struct usb_interface *intf) | 2236 | struct usb_interface *intf) |
2127 | { | 2237 | { |
@@ -2130,8 +2240,7 @@ static void imon_init_display(struct imon_context *ictx, | |||
2130 | dev_dbg(ictx->dev, "Registering iMON display with sysfs\n"); | 2240 | dev_dbg(ictx->dev, "Registering iMON display with sysfs\n"); |
2131 | 2241 | ||
2132 | /* set up sysfs entry for built-in clock */ | 2242 | /* set up sysfs entry for built-in clock */ |
2133 | ret = sysfs_create_group(&intf->dev.kobj, | 2243 | ret = sysfs_create_group(&intf->dev.kobj, &imon_display_attr_group); |
2134 | &imon_display_attribute_group); | ||
2135 | if (ret) | 2244 | if (ret) |
2136 | dev_err(ictx->dev, "Could not create display sysfs " | 2245 | dev_err(ictx->dev, "Could not create display sysfs " |
2137 | "entries(%d)", ret); | 2246 | "entries(%d)", ret); |
@@ -2162,8 +2271,6 @@ static int __devinit imon_probe(struct usb_interface *interface, | |||
2162 | struct imon_context *ictx = NULL; | 2271 | struct imon_context *ictx = NULL; |
2163 | struct imon_context *first_if_ctx = NULL; | 2272 | struct imon_context *first_if_ctx = NULL; |
2164 | u16 vendor, product; | 2273 | u16 vendor, product; |
2165 | const unsigned char fp_packet[] = { 0x40, 0x00, 0x00, 0x00, | ||
2166 | 0x00, 0x00, 0x00, 0x88 }; | ||
2167 | 2274 | ||
2168 | code_length = BUF_CHUNK_SIZE * 8; | 2275 | code_length = BUF_CHUNK_SIZE * 8; |
2169 | 2276 | ||
@@ -2185,7 +2292,7 @@ static int __devinit imon_probe(struct usb_interface *interface, | |||
2185 | if (ifnum == 0) { | 2292 | if (ifnum == 0) { |
2186 | ictx = imon_init_intf0(interface); | 2293 | ictx = imon_init_intf0(interface); |
2187 | if (!ictx) { | 2294 | if (!ictx) { |
2188 | err("%s: failed to initialize context!\n", __func__); | 2295 | pr_err("failed to initialize context!\n"); |
2189 | ret = -ENODEV; | 2296 | ret = -ENODEV; |
2190 | goto fail; | 2297 | goto fail; |
2191 | } | 2298 | } |
@@ -2194,7 +2301,7 @@ static int __devinit imon_probe(struct usb_interface *interface, | |||
2194 | /* this is the secondary interface on the device */ | 2301 | /* this is the secondary interface on the device */ |
2195 | ictx = imon_init_intf1(interface, first_if_ctx); | 2302 | ictx = imon_init_intf1(interface, first_if_ctx); |
2196 | if (!ictx) { | 2303 | if (!ictx) { |
2197 | err("%s: failed to attach to context!\n", __func__); | 2304 | pr_err("failed to attach to context!\n"); |
2198 | ret = -ENODEV; | 2305 | ret = -ENODEV; |
2199 | goto fail; | 2306 | goto fail; |
2200 | } | 2307 | } |
@@ -2204,39 +2311,18 @@ static int __devinit imon_probe(struct usb_interface *interface, | |||
2204 | usb_set_intfdata(interface, ictx); | 2311 | usb_set_intfdata(interface, ictx); |
2205 | 2312 | ||
2206 | if (ifnum == 0) { | 2313 | if (ifnum == 0) { |
2207 | /* Enable front-panel buttons and/or knobs */ | ||
2208 | memcpy(ictx->usb_tx_buf, &fp_packet, sizeof(fp_packet)); | ||
2209 | ret = send_packet(ictx); | ||
2210 | /* Not fatal, but warn about it */ | ||
2211 | if (ret) | ||
2212 | dev_info(dev, "failed to enable panel buttons " | ||
2213 | "and/or knobs\n"); | ||
2214 | |||
2215 | if (product == 0xffdc) | ||
2216 | imon_get_ffdc_type(ictx); | ||
2217 | |||
2218 | imon_set_display_type(ictx, interface); | ||
2219 | |||
2220 | if (product == 0xffdc && ictx->rf_device) { | 2314 | if (product == 0xffdc && ictx->rf_device) { |
2221 | sysfs_err = sysfs_create_group(&interface->dev.kobj, | 2315 | sysfs_err = sysfs_create_group(&interface->dev.kobj, |
2222 | &imon_rf_attribute_group); | 2316 | &imon_rf_attr_group); |
2223 | if (sysfs_err) | 2317 | if (sysfs_err) |
2224 | err("%s: Could not create RF sysfs entries(%d)", | 2318 | pr_err("Could not create RF sysfs entries(%d)\n", |
2225 | __func__, sysfs_err); | 2319 | sysfs_err); |
2226 | } | 2320 | } |
2227 | 2321 | ||
2228 | if (ictx->display_supported) | 2322 | if (ictx->display_supported) |
2229 | imon_init_display(ictx, interface); | 2323 | imon_init_display(ictx, interface); |
2230 | } | 2324 | } |
2231 | 2325 | ||
2232 | /* set IR protocol/remote type */ | ||
2233 | ret = imon_ir_change_protocol(ictx, ictx->ir_type); | ||
2234 | if (ret) { | ||
2235 | dev_warn(dev, "%s: failed to set IR protocol, falling back " | ||
2236 | "to standard iMON protocol mode\n", __func__); | ||
2237 | ictx->ir_type = IR_TYPE_OTHER; | ||
2238 | } | ||
2239 | |||
2240 | dev_info(dev, "iMON device (%04x:%04x, intf%d) on " | 2326 | dev_info(dev, "iMON device (%04x:%04x, intf%d) on " |
2241 | "usb<%d:%d> initialized\n", vendor, product, ifnum, | 2327 | "usb<%d:%d> initialized\n", vendor, product, ifnum, |
2242 | usbdev->bus->busnum, usbdev->devnum); | 2328 | usbdev->bus->busnum, usbdev->devnum); |
@@ -2275,10 +2361,8 @@ static void __devexit imon_disconnect(struct usb_interface *interface) | |||
2275 | * sysfs_remove_group is safe to call even if sysfs_create_group | 2361 | * sysfs_remove_group is safe to call even if sysfs_create_group |
2276 | * hasn't been called | 2362 | * hasn't been called |
2277 | */ | 2363 | */ |
2278 | sysfs_remove_group(&interface->dev.kobj, | 2364 | sysfs_remove_group(&interface->dev.kobj, &imon_display_attr_group); |
2279 | &imon_display_attribute_group); | 2365 | sysfs_remove_group(&interface->dev.kobj, &imon_rf_attr_group); |
2280 | sysfs_remove_group(&interface->dev.kobj, | ||
2281 | &imon_rf_attribute_group); | ||
2282 | 2366 | ||
2283 | usb_set_intfdata(interface, NULL); | 2367 | usb_set_intfdata(interface, NULL); |
2284 | 2368 | ||
@@ -2291,7 +2375,8 @@ static void __devexit imon_disconnect(struct usb_interface *interface) | |||
2291 | if (ifnum == 0) { | 2375 | if (ifnum == 0) { |
2292 | ictx->dev_present_intf0 = false; | 2376 | ictx->dev_present_intf0 = false; |
2293 | usb_kill_urb(ictx->rx_urb_intf0); | 2377 | usb_kill_urb(ictx->rx_urb_intf0); |
2294 | ir_input_unregister(ictx->idev); | 2378 | input_unregister_device(ictx->idev); |
2379 | ir_input_unregister(ictx->rdev); | ||
2295 | if (ictx->display_supported) { | 2380 | if (ictx->display_supported) { |
2296 | if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) | 2381 | if (ictx->display_type == IMON_DISPLAY_TYPE_LCD) |
2297 | usb_deregister_dev(interface, &imon_lcd_class); | 2382 | usb_deregister_dev(interface, &imon_lcd_class); |
@@ -2311,11 +2396,8 @@ static void __devexit imon_disconnect(struct usb_interface *interface) | |||
2311 | mutex_unlock(&ictx->lock); | 2396 | mutex_unlock(&ictx->lock); |
2312 | if (!ictx->display_isopen) | 2397 | if (!ictx->display_isopen) |
2313 | free_imon_context(ictx); | 2398 | free_imon_context(ictx); |
2314 | } else { | 2399 | } else |
2315 | if (ictx->ir_type == IR_TYPE_RC6) | ||
2316 | del_timer_sync(&ictx->itimer); | ||
2317 | mutex_unlock(&ictx->lock); | 2400 | mutex_unlock(&ictx->lock); |
2318 | } | ||
2319 | 2401 | ||
2320 | mutex_unlock(&driver_lock); | 2402 | mutex_unlock(&driver_lock); |
2321 | 2403 | ||
@@ -2372,7 +2454,7 @@ static int __init imon_init(void) | |||
2372 | 2454 | ||
2373 | rc = usb_register(&imon_driver); | 2455 | rc = usb_register(&imon_driver); |
2374 | if (rc) { | 2456 | if (rc) { |
2375 | err("%s: usb register failed(%d)", __func__, rc); | 2457 | pr_err("usb register failed(%d)\n", rc); |
2376 | rc = -ENODEV; | 2458 | rc = -ENODEV; |
2377 | } | 2459 | } |
2378 | 2460 | ||