diff options
-rw-r--r-- | drivers/input/evdev.c | 8 | ||||
-rw-r--r-- | drivers/input/input.c | 11 | ||||
-rw-r--r-- | drivers/input/keyboard/corgikbd.c | 9 | ||||
-rw-r--r-- | include/linux/input.h | 25 |
4 files changed, 49 insertions, 4 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index f8b278d3559b..19c14c4beb44 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c | |||
@@ -393,6 +393,7 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
393 | case EV_LED: bits = dev->ledbit; len = LED_MAX; break; | 393 | case EV_LED: bits = dev->ledbit; len = LED_MAX; break; |
394 | case EV_SND: bits = dev->sndbit; len = SND_MAX; break; | 394 | case EV_SND: bits = dev->sndbit; len = SND_MAX; break; |
395 | case EV_FF: bits = dev->ffbit; len = FF_MAX; break; | 395 | case EV_FF: bits = dev->ffbit; len = FF_MAX; break; |
396 | case EV_SW: bits = dev->swbit; len = SW_MAX; break; | ||
396 | default: return -EINVAL; | 397 | default: return -EINVAL; |
397 | } | 398 | } |
398 | len = NBITS(len) * sizeof(long); | 399 | len = NBITS(len) * sizeof(long); |
@@ -421,6 +422,13 @@ static long evdev_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
421 | return copy_to_user(p, dev->snd, len) ? -EFAULT : len; | 422 | return copy_to_user(p, dev->snd, len) ? -EFAULT : len; |
422 | } | 423 | } |
423 | 424 | ||
425 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGSW(0))) { | ||
426 | int len; | ||
427 | len = NBITS(SW_MAX) * sizeof(long); | ||
428 | if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd); | ||
429 | return copy_to_user(p, dev->sw, len) ? -EFAULT : len; | ||
430 | } | ||
431 | |||
424 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { | 432 | if (_IOC_NR(cmd) == _IOC_NR(EVIOCGNAME(0))) { |
425 | int len; | 433 | int len; |
426 | if (!dev->name) return -ENOENT; | 434 | if (!dev->name) return -ENOENT; |
diff --git a/drivers/input/input.c b/drivers/input/input.c index a275211c8e1e..88636a204525 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
@@ -89,6 +89,15 @@ void input_event(struct input_dev *dev, unsigned int type, unsigned int code, in | |||
89 | 89 | ||
90 | break; | 90 | break; |
91 | 91 | ||
92 | case EV_SW: | ||
93 | |||
94 | if (code > SW_MAX || !test_bit(code, dev->swbit) || !!test_bit(code, dev->sw) == value) | ||
95 | return; | ||
96 | |||
97 | change_bit(code, dev->sw); | ||
98 | |||
99 | break; | ||
100 | |||
92 | case EV_ABS: | 101 | case EV_ABS: |
93 | 102 | ||
94 | if (code > ABS_MAX || !test_bit(code, dev->absbit)) | 103 | if (code > ABS_MAX || !test_bit(code, dev->absbit)) |
@@ -402,6 +411,7 @@ static void input_call_hotplug(char *verb, struct input_dev *dev) | |||
402 | SPRINTF_BIT_A2(ledbit, "LED=", LED_MAX, EV_LED); | 411 | SPRINTF_BIT_A2(ledbit, "LED=", LED_MAX, EV_LED); |
403 | SPRINTF_BIT_A2(sndbit, "SND=", SND_MAX, EV_SND); | 412 | SPRINTF_BIT_A2(sndbit, "SND=", SND_MAX, EV_SND); |
404 | SPRINTF_BIT_A2(ffbit, "FF=", FF_MAX, EV_FF); | 413 | SPRINTF_BIT_A2(ffbit, "FF=", FF_MAX, EV_FF); |
414 | SPRINTF_BIT_A2(swbit, "SW=", SW_MAX, EV_SW); | ||
405 | 415 | ||
406 | envp[i++] = NULL; | 416 | envp[i++] = NULL; |
407 | 417 | ||
@@ -490,6 +500,7 @@ static int input_devices_read(char *buf, char **start, off_t pos, int count, int | |||
490 | SPRINTF_BIT_B2(ledbit, "LED=", LED_MAX, EV_LED); | 500 | SPRINTF_BIT_B2(ledbit, "LED=", LED_MAX, EV_LED); |
491 | SPRINTF_BIT_B2(sndbit, "SND=", SND_MAX, EV_SND); | 501 | SPRINTF_BIT_B2(sndbit, "SND=", SND_MAX, EV_SND); |
492 | SPRINTF_BIT_B2(ffbit, "FF=", FF_MAX, EV_FF); | 502 | SPRINTF_BIT_B2(ffbit, "FF=", FF_MAX, EV_FF); |
503 | SPRINTF_BIT_B2(swbit, "SW=", SW_MAX, EV_SW); | ||
493 | 504 | ||
494 | len += sprintf(buf + len, "\n"); | 505 | len += sprintf(buf + len, "\n"); |
495 | 506 | ||
diff --git a/drivers/input/keyboard/corgikbd.c b/drivers/input/keyboard/corgikbd.c index 767e853dd766..cd4b6e795013 100644 --- a/drivers/input/keyboard/corgikbd.c +++ b/drivers/input/keyboard/corgikbd.c | |||
@@ -249,9 +249,8 @@ static void corgikbd_hinge_timer(unsigned long data) | |||
249 | if (hinge_count >= HINGE_STABLE_COUNT) { | 249 | if (hinge_count >= HINGE_STABLE_COUNT) { |
250 | spin_lock_irqsave(&corgikbd_data->lock, flags); | 250 | spin_lock_irqsave(&corgikbd_data->lock, flags); |
251 | 251 | ||
252 | input_report_key(&corgikbd_data->input, corgikbd_data->keycode[125], (sharpsl_hinge_state == 0x00)); | 252 | input_report_switch(&corgikbd_data->input, SW_0, ((sharpsl_hinge_state & CORGI_SCP_SWA) != 0)); |
253 | input_report_key(&corgikbd_data->input, corgikbd_data->keycode[126], (sharpsl_hinge_state == 0x08)); | 253 | input_report_switch(&corgikbd_data->input, SW_1, ((sharpsl_hinge_state & CORGI_SCP_SWB) != 0)); |
254 | input_report_key(&corgikbd_data->input, corgikbd_data->keycode[127], (sharpsl_hinge_state == 0x0c)); | ||
255 | input_sync(&corgikbd_data->input); | 254 | input_sync(&corgikbd_data->input); |
256 | 255 | ||
257 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); | 256 | spin_unlock_irqrestore(&corgikbd_data->lock, flags); |
@@ -321,7 +320,7 @@ static int __init corgikbd_probe(struct device *dev) | |||
321 | corgikbd->input.id.vendor = 0x0001; | 320 | corgikbd->input.id.vendor = 0x0001; |
322 | corgikbd->input.id.product = 0x0001; | 321 | corgikbd->input.id.product = 0x0001; |
323 | corgikbd->input.id.version = 0x0100; | 322 | corgikbd->input.id.version = 0x0100; |
324 | corgikbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR); | 323 | corgikbd->input.evbit[0] = BIT(EV_KEY) | BIT(EV_REP) | BIT(EV_PWR) | BIT(EV_SW); |
325 | corgikbd->input.keycode = corgikbd->keycode; | 324 | corgikbd->input.keycode = corgikbd->keycode; |
326 | corgikbd->input.keycodesize = sizeof(unsigned char); | 325 | corgikbd->input.keycodesize = sizeof(unsigned char); |
327 | corgikbd->input.keycodemax = ARRAY_SIZE(corgikbd_keycode); | 326 | corgikbd->input.keycodemax = ARRAY_SIZE(corgikbd_keycode); |
@@ -330,6 +329,8 @@ static int __init corgikbd_probe(struct device *dev) | |||
330 | for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) | 329 | for (i = 0; i < ARRAY_SIZE(corgikbd_keycode); i++) |
331 | set_bit(corgikbd->keycode[i], corgikbd->input.keybit); | 330 | set_bit(corgikbd->keycode[i], corgikbd->input.keybit); |
332 | clear_bit(0, corgikbd->input.keybit); | 331 | clear_bit(0, corgikbd->input.keybit); |
332 | set_bit(SW_0, corgikbd->input.swbit); | ||
333 | set_bit(SW_1, corgikbd->input.swbit); | ||
333 | 334 | ||
334 | input_register_device(&corgikbd->input); | 335 | input_register_device(&corgikbd->input); |
335 | mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL); | 336 | mod_timer(&corgikbd->htimer, jiffies + HINGE_SCAN_INTERVAL); |
diff --git a/include/linux/input.h b/include/linux/input.h index bdc53c6cc962..4767e5429534 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -66,6 +66,7 @@ struct input_absinfo { | |||
66 | #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */ | 66 | #define EVIOCGKEY(len) _IOC(_IOC_READ, 'E', 0x18, len) /* get global keystate */ |
67 | #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ | 67 | #define EVIOCGLED(len) _IOC(_IOC_READ, 'E', 0x19, len) /* get all LEDs */ |
68 | #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ | 68 | #define EVIOCGSND(len) _IOC(_IOC_READ, 'E', 0x1a, len) /* get all sounds status */ |
69 | #define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ | ||
69 | 70 | ||
70 | #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */ | 71 | #define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */ |
71 | #define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */ | 72 | #define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */ |
@@ -86,6 +87,7 @@ struct input_absinfo { | |||
86 | #define EV_REL 0x02 | 87 | #define EV_REL 0x02 |
87 | #define EV_ABS 0x03 | 88 | #define EV_ABS 0x03 |
88 | #define EV_MSC 0x04 | 89 | #define EV_MSC 0x04 |
90 | #define EV_SW 0x05 | ||
89 | #define EV_LED 0x11 | 91 | #define EV_LED 0x11 |
90 | #define EV_SND 0x12 | 92 | #define EV_SND 0x12 |
91 | #define EV_REP 0x14 | 93 | #define EV_REP 0x14 |
@@ -551,6 +553,20 @@ struct input_absinfo { | |||
551 | #define ABS_MAX 0x3f | 553 | #define ABS_MAX 0x3f |
552 | 554 | ||
553 | /* | 555 | /* |
556 | * Switch events | ||
557 | */ | ||
558 | |||
559 | #define SW_0 0x00 | ||
560 | #define SW_1 0x01 | ||
561 | #define SW_2 0x02 | ||
562 | #define SW_3 0x03 | ||
563 | #define SW_4 0x04 | ||
564 | #define SW_5 0x05 | ||
565 | #define SW_6 0x06 | ||
566 | #define SW_7 0x07 | ||
567 | #define SW_MAX 0x0f | ||
568 | |||
569 | /* | ||
554 | * Misc events | 570 | * Misc events |
555 | */ | 571 | */ |
556 | 572 | ||
@@ -824,6 +840,7 @@ struct input_dev { | |||
824 | unsigned long ledbit[NBITS(LED_MAX)]; | 840 | unsigned long ledbit[NBITS(LED_MAX)]; |
825 | unsigned long sndbit[NBITS(SND_MAX)]; | 841 | unsigned long sndbit[NBITS(SND_MAX)]; |
826 | unsigned long ffbit[NBITS(FF_MAX)]; | 842 | unsigned long ffbit[NBITS(FF_MAX)]; |
843 | unsigned long swbit[NBITS(SW_MAX)]; | ||
827 | int ff_effects_max; | 844 | int ff_effects_max; |
828 | 845 | ||
829 | unsigned int keycodemax; | 846 | unsigned int keycodemax; |
@@ -844,6 +861,7 @@ struct input_dev { | |||
844 | unsigned long key[NBITS(KEY_MAX)]; | 861 | unsigned long key[NBITS(KEY_MAX)]; |
845 | unsigned long led[NBITS(LED_MAX)]; | 862 | unsigned long led[NBITS(LED_MAX)]; |
846 | unsigned long snd[NBITS(SND_MAX)]; | 863 | unsigned long snd[NBITS(SND_MAX)]; |
864 | unsigned long sw[NBITS(SW_MAX)]; | ||
847 | 865 | ||
848 | int absmax[ABS_MAX + 1]; | 866 | int absmax[ABS_MAX + 1]; |
849 | int absmin[ABS_MAX + 1]; | 867 | int absmin[ABS_MAX + 1]; |
@@ -886,6 +904,7 @@ struct input_dev { | |||
886 | #define INPUT_DEVICE_ID_MATCH_LEDBIT 0x200 | 904 | #define INPUT_DEVICE_ID_MATCH_LEDBIT 0x200 |
887 | #define INPUT_DEVICE_ID_MATCH_SNDBIT 0x400 | 905 | #define INPUT_DEVICE_ID_MATCH_SNDBIT 0x400 |
888 | #define INPUT_DEVICE_ID_MATCH_FFBIT 0x800 | 906 | #define INPUT_DEVICE_ID_MATCH_FFBIT 0x800 |
907 | #define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000 | ||
889 | 908 | ||
890 | #define INPUT_DEVICE_ID_MATCH_DEVICE\ | 909 | #define INPUT_DEVICE_ID_MATCH_DEVICE\ |
891 | (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) | 910 | (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) |
@@ -906,6 +925,7 @@ struct input_device_id { | |||
906 | unsigned long ledbit[NBITS(LED_MAX)]; | 925 | unsigned long ledbit[NBITS(LED_MAX)]; |
907 | unsigned long sndbit[NBITS(SND_MAX)]; | 926 | unsigned long sndbit[NBITS(SND_MAX)]; |
908 | unsigned long ffbit[NBITS(FF_MAX)]; | 927 | unsigned long ffbit[NBITS(FF_MAX)]; |
928 | unsigned long swbit[NBITS(SW_MAX)]; | ||
909 | 929 | ||
910 | unsigned long driver_info; | 930 | unsigned long driver_info; |
911 | }; | 931 | }; |
@@ -998,6 +1018,11 @@ static inline void input_report_ff_status(struct input_dev *dev, unsigned int co | |||
998 | input_event(dev, EV_FF_STATUS, code, value); | 1018 | input_event(dev, EV_FF_STATUS, code, value); |
999 | } | 1019 | } |
1000 | 1020 | ||
1021 | static inline void input_report_switch(struct input_dev *dev, unsigned int code, int value) | ||
1022 | { | ||
1023 | input_event(dev, EV_SW, code, !!value); | ||
1024 | } | ||
1025 | |||
1001 | static inline void input_regs(struct input_dev *dev, struct pt_regs *regs) | 1026 | static inline void input_regs(struct input_dev *dev, struct pt_regs *regs) |
1002 | { | 1027 | { |
1003 | dev->regs = regs; | 1028 | dev->regs = regs; |