aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@rpsys.net>2005-09-06 18:19:06 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-09-07 19:57:54 -0400
commit3158106685acac8f8d4e74a17b974f160fe77c0b (patch)
tree7712eb16eb543b5247f90b41647d08ff0a05e663 /drivers
parent41b1bce80b43f7c6a6c64006b2abe3a8d52ab120 (diff)
[PATCH] Input: Add a new switch event type
The corgi keyboard has need of a switch event type with slightly type to the input system as recommended by the input maintainer. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Cc: Vojtech Pavlik <vojtech@suse.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/input/evdev.c8
-rw-r--r--drivers/input/input.c11
-rw-r--r--drivers/input/keyboard/corgikbd.c9
3 files changed, 24 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);