diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-20 13:17:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-20 13:17:02 -0400 |
commit | 93db6294958f62643a917e44d1abc85440e600cf (patch) | |
tree | 33de2c41b0f70d209d64487d1a2bba6d673015ef /drivers/input/misc | |
parent | 43813f399c72aa22e01a680559c1cb5274bf2140 (diff) | |
parent | eef3e4cab72eaf5345e3c73b2975c194a714f6cd (diff) |
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (35 commits)
Input: add driver for Synaptics I2C touchpad
Input: synaptics - add support for reporting x/y resolution
Input: ALPS - handle touchpoints buttons correctly
Input: gpio-keys - change timer to workqueue
Input: ads7846 - pin change interrupt support
Input: add support for touchscreen on W90P910 ARM platform
Input: appletouch - improve finger detection
Input: wacom - clear Intuos4 wheel data when finger leaves proximity
Input: ucb1400 - move static function from header into core
Input: add driver for EETI touchpanels
Input: ads7846 - more detailed model name in sysfs
Input: ads7846 - support swapping x and y axes
Input: ati_remote2 - use non-atomic bitops
Input: introduce lm8323 keypad driver
Input: psmouse - ESD workaround fix for OLPC XO touchpad
Input: tsc2007 - make sure platform provides get_pendown_state()
Input: uinput - flush all pending ff effects before destroying device
Input: simplify name handling for certain input handles
Input: serio - do not use deprecated dev.power.power_state
Input: wacom - add support for Intuos4 tablets
...
Diffstat (limited to 'drivers/input/misc')
-rw-r--r-- | drivers/input/misc/Kconfig | 19 | ||||
-rw-r--r-- | drivers/input/misc/Makefile | 2 | ||||
-rw-r--r-- | drivers/input/misc/ati_remote2.c | 16 | ||||
-rw-r--r-- | drivers/input/misc/dm355evm_keys.c | 329 | ||||
-rw-r--r-- | drivers/input/misc/rotary_encoder.c | 61 | ||||
-rw-r--r-- | drivers/input/misc/twl4030-pwrbutton.c | 145 | ||||
-rw-r--r-- | drivers/input/misc/uinput.c | 94 |
7 files changed, 615 insertions, 51 deletions
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 06f46fcc077..1acfa3a05aa 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig | |||
@@ -193,6 +193,16 @@ config INPUT_CM109 | |||
193 | To compile this driver as a module, choose M here: the module will be | 193 | To compile this driver as a module, choose M here: the module will be |
194 | called cm109. | 194 | called cm109. |
195 | 195 | ||
196 | config INPUT_TWL4030_PWRBUTTON | ||
197 | tristate "TWL4030 Power button Driver" | ||
198 | depends on TWL4030_CORE | ||
199 | help | ||
200 | Say Y here if you want to enable power key reporting via the | ||
201 | TWL4030 family of chips. | ||
202 | |||
203 | To compile this driver as a module, choose M here. The module will | ||
204 | be called twl4030_pwrbutton. | ||
205 | |||
196 | config INPUT_UINPUT | 206 | config INPUT_UINPUT |
197 | tristate "User level driver support" | 207 | tristate "User level driver support" |
198 | help | 208 | help |
@@ -250,4 +260,13 @@ config INPUT_RB532_BUTTON | |||
250 | To compile this driver as a module, choose M here: the | 260 | To compile this driver as a module, choose M here: the |
251 | module will be called rb532_button. | 261 | module will be called rb532_button. |
252 | 262 | ||
263 | config INPUT_DM355EVM | ||
264 | tristate "TI DaVinci DM355 EVM Keypad and IR Remote" | ||
265 | depends on MFD_DM355EVM_MSP | ||
266 | help | ||
267 | Supports the pushbuttons and IR remote used with | ||
268 | the DM355 EVM board. | ||
269 | |||
270 | To compile this driver as a module, choose M here: the | ||
271 | module will be called dm355evm_keys. | ||
253 | endif | 272 | endif |
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile index eb3f407baed..0d979fd4cd5 100644 --- a/drivers/input/misc/Makefile +++ b/drivers/input/misc/Makefile | |||
@@ -10,6 +10,7 @@ obj-$(CONFIG_INPUT_ATI_REMOTE2) += ati_remote2.o | |||
10 | obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o | 10 | obj-$(CONFIG_INPUT_ATLAS_BTNS) += atlas_btns.o |
11 | obj-$(CONFIG_INPUT_CM109) += cm109.o | 11 | obj-$(CONFIG_INPUT_CM109) += cm109.o |
12 | obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o | 12 | obj-$(CONFIG_INPUT_COBALT_BTNS) += cobalt_btns.o |
13 | obj-$(CONFIG_INPUT_DM355EVM) += dm355evm_keys.o | ||
13 | obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o | 14 | obj-$(CONFIG_HP_SDC_RTC) += hp_sdc_rtc.o |
14 | obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o | 15 | obj-$(CONFIG_INPUT_IXP4XX_BEEPER) += ixp4xx-beeper.o |
15 | obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o | 16 | obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o |
@@ -21,6 +22,7 @@ obj-$(CONFIG_INPUT_RB532_BUTTON) += rb532_button.o | |||
21 | obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o | 22 | obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o |
22 | obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o | 23 | obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o |
23 | obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o | 24 | obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o |
25 | obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o | ||
24 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o | 26 | obj-$(CONFIG_INPUT_UINPUT) += uinput.o |
25 | obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o | 27 | obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o |
26 | obj-$(CONFIG_INPUT_YEALINK) += yealink.o | 28 | obj-$(CONFIG_INPUT_YEALINK) += yealink.o |
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c index 922c0514158..0501f0e6515 100644 --- a/drivers/input/misc/ati_remote2.c +++ b/drivers/input/misc/ati_remote2.c | |||
@@ -509,7 +509,7 @@ static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keyc | |||
509 | 509 | ||
510 | old_keycode = ar2->keycode[mode][index]; | 510 | old_keycode = ar2->keycode[mode][index]; |
511 | ar2->keycode[mode][index] = keycode; | 511 | ar2->keycode[mode][index] = keycode; |
512 | set_bit(keycode, idev->keybit); | 512 | __set_bit(keycode, idev->keybit); |
513 | 513 | ||
514 | for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) { | 514 | for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) { |
515 | for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) { | 515 | for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) { |
@@ -518,7 +518,7 @@ static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keyc | |||
518 | } | 518 | } |
519 | } | 519 | } |
520 | 520 | ||
521 | clear_bit(old_keycode, idev->keybit); | 521 | __clear_bit(old_keycode, idev->keybit); |
522 | 522 | ||
523 | return 0; | 523 | return 0; |
524 | } | 524 | } |
@@ -543,7 +543,7 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2) | |||
543 | for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) { | 543 | for (mode = 0; mode < ATI_REMOTE2_MODES; mode++) { |
544 | for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) { | 544 | for (index = 0; index < ARRAY_SIZE(ati_remote2_key_table); index++) { |
545 | ar2->keycode[mode][index] = ati_remote2_key_table[index].keycode; | 545 | ar2->keycode[mode][index] = ati_remote2_key_table[index].keycode; |
546 | set_bit(ar2->keycode[mode][index], idev->keybit); | 546 | __set_bit(ar2->keycode[mode][index], idev->keybit); |
547 | } | 547 | } |
548 | } | 548 | } |
549 | 549 | ||
@@ -554,11 +554,11 @@ static int ati_remote2_input_init(struct ati_remote2 *ar2) | |||
554 | ar2->keycode[ATI_REMOTE2_AUX3][index] = KEY_PROG3; | 554 | ar2->keycode[ATI_REMOTE2_AUX3][index] = KEY_PROG3; |
555 | ar2->keycode[ATI_REMOTE2_AUX4][index] = KEY_PROG4; | 555 | ar2->keycode[ATI_REMOTE2_AUX4][index] = KEY_PROG4; |
556 | ar2->keycode[ATI_REMOTE2_PC][index] = KEY_PC; | 556 | ar2->keycode[ATI_REMOTE2_PC][index] = KEY_PC; |
557 | set_bit(KEY_PROG1, idev->keybit); | 557 | __set_bit(KEY_PROG1, idev->keybit); |
558 | set_bit(KEY_PROG2, idev->keybit); | 558 | __set_bit(KEY_PROG2, idev->keybit); |
559 | set_bit(KEY_PROG3, idev->keybit); | 559 | __set_bit(KEY_PROG3, idev->keybit); |
560 | set_bit(KEY_PROG4, idev->keybit); | 560 | __set_bit(KEY_PROG4, idev->keybit); |
561 | set_bit(KEY_PC, idev->keybit); | 561 | __set_bit(KEY_PC, idev->keybit); |
562 | 562 | ||
563 | idev->rep[REP_DELAY] = 250; | 563 | idev->rep[REP_DELAY] = 250; |
564 | idev->rep[REP_PERIOD] = 33; | 564 | idev->rep[REP_PERIOD] = 33; |
diff --git a/drivers/input/misc/dm355evm_keys.c b/drivers/input/misc/dm355evm_keys.c new file mode 100644 index 00000000000..a63315ce4a6 --- /dev/null +++ b/drivers/input/misc/dm355evm_keys.c | |||
@@ -0,0 +1,329 @@ | |||
1 | /* | ||
2 | * dm355evm_keys.c - support buttons and IR remote on DM355 EVM board | ||
3 | * | ||
4 | * Copyright (c) 2008 by David Brownell | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * as published by the Free Software Foundation; either version | ||
9 | * 2 of the License, or (at your option) any later version. | ||
10 | */ | ||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/input.h> | ||
14 | #include <linux/platform_device.h> | ||
15 | #include <linux/interrupt.h> | ||
16 | |||
17 | #include <linux/i2c/dm355evm_msp.h> | ||
18 | |||
19 | |||
20 | /* | ||
21 | * The MSP430 firmware on the DM355 EVM monitors on-board pushbuttons | ||
22 | * and an IR receptor used for the remote control. When any key is | ||
23 | * pressed, or its autorepeat kicks in, an event is sent. This driver | ||
24 | * read those events from the small (32 event) queue and reports them. | ||
25 | * | ||
26 | * Because we communicate with the MSP430 using I2C, and all I2C calls | ||
27 | * in Linux sleep, we need to cons up a kind of threaded IRQ handler | ||
28 | * using a work_struct. The IRQ is active low, but we use it through | ||
29 | * the GPIO controller so we can trigger on falling edges. | ||
30 | * | ||
31 | * Note that physically there can only be one of these devices. | ||
32 | * | ||
33 | * This driver was tested with firmware revision A4. | ||
34 | */ | ||
35 | struct dm355evm_keys { | ||
36 | struct work_struct work; | ||
37 | struct input_dev *input; | ||
38 | struct device *dev; | ||
39 | int irq; | ||
40 | }; | ||
41 | |||
42 | static irqreturn_t dm355evm_keys_irq(int irq, void *_keys) | ||
43 | { | ||
44 | struct dm355evm_keys *keys = _keys; | ||
45 | |||
46 | schedule_work(&keys->work); | ||
47 | return IRQ_HANDLED; | ||
48 | } | ||
49 | |||
50 | /* These initial keycodes can be remapped by dm355evm_setkeycode(). */ | ||
51 | static struct { | ||
52 | u16 event; | ||
53 | u16 keycode; | ||
54 | } dm355evm_keys[] = { | ||
55 | |||
56 | /* | ||
57 | * Pushbuttons on the EVM board ... note that the labels for these | ||
58 | * are SW10/SW11/etc on the PC board. The left/right orientation | ||
59 | * comes only from the firmware's documentation, and presumes the | ||
60 | * power connector is immediately in front of you and the IR sensor | ||
61 | * is to the right. (That is, rotate the board counter-clockwise | ||
62 | * by 90 degrees from the SW10/etc and "DM355 EVM" labels.) | ||
63 | */ | ||
64 | { 0x00d8, KEY_OK, }, /* SW12 */ | ||
65 | { 0x00b8, KEY_UP, }, /* SW13 */ | ||
66 | { 0x00e8, KEY_DOWN, }, /* SW11 */ | ||
67 | { 0x0078, KEY_LEFT, }, /* SW14 */ | ||
68 | { 0x00f0, KEY_RIGHT, }, /* SW10 */ | ||
69 | |||
70 | /* | ||
71 | * IR buttons ... codes assigned to match the universal remote | ||
72 | * provided with the EVM (Philips PM4S) using DVD code 0020. | ||
73 | * | ||
74 | * These event codes match firmware documentation, but other | ||
75 | * remote controls could easily send more RC5-encoded events. | ||
76 | * The PM4S manual was used in several cases to help select | ||
77 | * a keycode reflecting the intended usage. | ||
78 | * | ||
79 | * RC5 codes are 14 bits, with two start bits (0x3 prefix) | ||
80 | * and a toggle bit (masked out below). | ||
81 | */ | ||
82 | { 0x300c, KEY_POWER, }, /* NOTE: docs omit this */ | ||
83 | { 0x3000, KEY_NUMERIC_0, }, | ||
84 | { 0x3001, KEY_NUMERIC_1, }, | ||
85 | { 0x3002, KEY_NUMERIC_2, }, | ||
86 | { 0x3003, KEY_NUMERIC_3, }, | ||
87 | { 0x3004, KEY_NUMERIC_4, }, | ||
88 | { 0x3005, KEY_NUMERIC_5, }, | ||
89 | { 0x3006, KEY_NUMERIC_6, }, | ||
90 | { 0x3007, KEY_NUMERIC_7, }, | ||
91 | { 0x3008, KEY_NUMERIC_8, }, | ||
92 | { 0x3009, KEY_NUMERIC_9, }, | ||
93 | { 0x3022, KEY_ENTER, }, | ||
94 | { 0x30ec, KEY_MODE, }, /* "tv/vcr/..." */ | ||
95 | { 0x300f, KEY_SELECT, }, /* "info" */ | ||
96 | { 0x3020, KEY_CHANNELUP, }, /* "up" */ | ||
97 | { 0x302e, KEY_MENU, }, /* "in/out" */ | ||
98 | { 0x3011, KEY_VOLUMEDOWN, }, /* "left" */ | ||
99 | { 0x300d, KEY_MUTE, }, /* "ok" */ | ||
100 | { 0x3010, KEY_VOLUMEUP, }, /* "right" */ | ||
101 | { 0x301e, KEY_SUBTITLE, }, /* "cc" */ | ||
102 | { 0x3021, KEY_CHANNELDOWN, }, /* "down" */ | ||
103 | { 0x3022, KEY_PREVIOUS, }, | ||
104 | { 0x3026, KEY_SLEEP, }, | ||
105 | { 0x3172, KEY_REWIND, }, /* NOTE: docs wrongly say 0x30ca */ | ||
106 | { 0x3175, KEY_PLAY, }, | ||
107 | { 0x3174, KEY_FASTFORWARD, }, | ||
108 | { 0x3177, KEY_RECORD, }, | ||
109 | { 0x3176, KEY_STOP, }, | ||
110 | { 0x3169, KEY_PAUSE, }, | ||
111 | }; | ||
112 | |||
113 | static void dm355evm_keys_work(struct work_struct *work) | ||
114 | { | ||
115 | struct dm355evm_keys *keys; | ||
116 | int status; | ||
117 | |||
118 | keys = container_of(work, struct dm355evm_keys, work); | ||
119 | |||
120 | /* For simplicity we ignore INPUT_COUNT and just read | ||
121 | * events until we get the "queue empty" indicator. | ||
122 | * Reading INPUT_LOW decrements the count. | ||
123 | */ | ||
124 | for (;;) { | ||
125 | static u16 last_event; | ||
126 | u16 event; | ||
127 | int keycode; | ||
128 | int i; | ||
129 | |||
130 | status = dm355evm_msp_read(DM355EVM_MSP_INPUT_HIGH); | ||
131 | if (status < 0) { | ||
132 | dev_dbg(keys->dev, "input high err %d\n", | ||
133 | status); | ||
134 | break; | ||
135 | } | ||
136 | event = status << 8; | ||
137 | |||
138 | status = dm355evm_msp_read(DM355EVM_MSP_INPUT_LOW); | ||
139 | if (status < 0) { | ||
140 | dev_dbg(keys->dev, "input low err %d\n", | ||
141 | status); | ||
142 | break; | ||
143 | } | ||
144 | event |= status; | ||
145 | if (event == 0xdead) | ||
146 | break; | ||
147 | |||
148 | /* Press and release a button: two events, same code. | ||
149 | * Press and hold (autorepeat), then release: N events | ||
150 | * (N > 2), same code. For RC5 buttons the toggle bits | ||
151 | * distinguish (for example) "1-autorepeat" from "1 1"; | ||
152 | * but PCB buttons don't support that bit. | ||
153 | * | ||
154 | * So we must synthesize release events. We do that by | ||
155 | * mapping events to a press/release event pair; then | ||
156 | * to avoid adding extra events, skip the second event | ||
157 | * of each pair. | ||
158 | */ | ||
159 | if (event == last_event) { | ||
160 | last_event = 0; | ||
161 | continue; | ||
162 | } | ||
163 | last_event = event; | ||
164 | |||
165 | /* ignore the RC5 toggle bit */ | ||
166 | event &= ~0x0800; | ||
167 | |||
168 | /* find the key, or leave it as unknown */ | ||
169 | keycode = KEY_UNKNOWN; | ||
170 | for (i = 0; i < ARRAY_SIZE(dm355evm_keys); i++) { | ||
171 | if (dm355evm_keys[i].event != event) | ||
172 | continue; | ||
173 | keycode = dm355evm_keys[i].keycode; | ||
174 | break; | ||
175 | } | ||
176 | dev_dbg(keys->dev, | ||
177 | "input event 0x%04x--> keycode %d\n", | ||
178 | event, keycode); | ||
179 | |||
180 | /* report press + release */ | ||
181 | input_report_key(keys->input, keycode, 1); | ||
182 | input_sync(keys->input); | ||
183 | input_report_key(keys->input, keycode, 0); | ||
184 | input_sync(keys->input); | ||
185 | } | ||
186 | } | ||
187 | |||
188 | static int dm355evm_setkeycode(struct input_dev *dev, int index, int keycode) | ||
189 | { | ||
190 | u16 old_keycode; | ||
191 | unsigned i; | ||
192 | |||
193 | if (((unsigned)index) >= ARRAY_SIZE(dm355evm_keys)) | ||
194 | return -EINVAL; | ||
195 | |||
196 | old_keycode = dm355evm_keys[index].keycode; | ||
197 | dm355evm_keys[index].keycode = keycode; | ||
198 | set_bit(keycode, dev->keybit); | ||
199 | |||
200 | for (i = 0; i < ARRAY_SIZE(dm355evm_keys); i++) { | ||
201 | if (dm355evm_keys[index].keycode == old_keycode) | ||
202 | goto done; | ||
203 | } | ||
204 | clear_bit(old_keycode, dev->keybit); | ||
205 | done: | ||
206 | return 0; | ||
207 | } | ||
208 | |||
209 | static int dm355evm_getkeycode(struct input_dev *dev, int index, int *keycode) | ||
210 | { | ||
211 | if (((unsigned)index) >= ARRAY_SIZE(dm355evm_keys)) | ||
212 | return -EINVAL; | ||
213 | |||
214 | return dm355evm_keys[index].keycode; | ||
215 | } | ||
216 | |||
217 | /*----------------------------------------------------------------------*/ | ||
218 | |||
219 | static int __devinit dm355evm_keys_probe(struct platform_device *pdev) | ||
220 | { | ||
221 | struct dm355evm_keys *keys; | ||
222 | struct input_dev *input; | ||
223 | int status; | ||
224 | int i; | ||
225 | |||
226 | /* allocate instance struct and input dev */ | ||
227 | keys = kzalloc(sizeof *keys, GFP_KERNEL); | ||
228 | input = input_allocate_device(); | ||
229 | if (!keys || !input) { | ||
230 | status = -ENOMEM; | ||
231 | goto fail1; | ||
232 | } | ||
233 | |||
234 | keys->dev = &pdev->dev; | ||
235 | keys->input = input; | ||
236 | INIT_WORK(&keys->work, dm355evm_keys_work); | ||
237 | |||
238 | /* set up "threaded IRQ handler" */ | ||
239 | status = platform_get_irq(pdev, 0); | ||
240 | if (status < 0) | ||
241 | goto fail1; | ||
242 | keys->irq = status; | ||
243 | |||
244 | input_set_drvdata(input, keys); | ||
245 | |||
246 | input->name = "DM355 EVM Controls"; | ||
247 | input->phys = "dm355evm/input0"; | ||
248 | input->dev.parent = &pdev->dev; | ||
249 | |||
250 | input->id.bustype = BUS_I2C; | ||
251 | input->id.product = 0x0355; | ||
252 | input->id.version = dm355evm_msp_read(DM355EVM_MSP_FIRMREV); | ||
253 | |||
254 | input->evbit[0] = BIT(EV_KEY); | ||
255 | for (i = 0; i < ARRAY_SIZE(dm355evm_keys); i++) | ||
256 | __set_bit(dm355evm_keys[i].keycode, input->keybit); | ||
257 | |||
258 | input->setkeycode = dm355evm_setkeycode; | ||
259 | input->getkeycode = dm355evm_getkeycode; | ||
260 | |||
261 | /* REVISIT: flush the event queue? */ | ||
262 | |||
263 | status = request_irq(keys->irq, dm355evm_keys_irq, | ||
264 | IRQF_TRIGGER_FALLING, | ||
265 | dev_name(&pdev->dev), keys); | ||
266 | if (status < 0) | ||
267 | goto fail1; | ||
268 | |||
269 | /* register */ | ||
270 | status = input_register_device(input); | ||
271 | if (status < 0) | ||
272 | goto fail2; | ||
273 | |||
274 | platform_set_drvdata(pdev, keys); | ||
275 | |||
276 | return 0; | ||
277 | |||
278 | fail2: | ||
279 | free_irq(keys->irq, keys); | ||
280 | fail1: | ||
281 | input_free_device(input); | ||
282 | kfree(keys); | ||
283 | dev_err(&pdev->dev, "can't register, err %d\n", status); | ||
284 | |||
285 | return status; | ||
286 | } | ||
287 | |||
288 | static int __devexit dm355evm_keys_remove(struct platform_device *pdev) | ||
289 | { | ||
290 | struct dm355evm_keys *keys = platform_get_drvdata(pdev); | ||
291 | |||
292 | free_irq(keys->irq, keys); | ||
293 | input_unregister_device(keys->input); | ||
294 | kfree(keys); | ||
295 | |||
296 | return 0; | ||
297 | } | ||
298 | |||
299 | /* REVISIT: add suspend/resume when DaVinci supports it. The IRQ should | ||
300 | * be able to wake up the system. When device_may_wakeup(&pdev->dev), call | ||
301 | * enable_irq_wake() on suspend, and disable_irq_wake() on resume. | ||
302 | */ | ||
303 | |||
304 | /* | ||
305 | * I2C is used to talk to the MSP430, but this platform device is | ||
306 | * exposed by an MFD driver that manages I2C communications. | ||
307 | */ | ||
308 | static struct platform_driver dm355evm_keys_driver = { | ||
309 | .probe = dm355evm_keys_probe, | ||
310 | .remove = __devexit_p(dm355evm_keys_remove), | ||
311 | .driver = { | ||
312 | .owner = THIS_MODULE, | ||
313 | .name = "dm355evm_keys", | ||
314 | }, | ||
315 | }; | ||
316 | |||
317 | static int __init dm355evm_keys_init(void) | ||
318 | { | ||
319 | return platform_driver_register(&dm355evm_keys_driver); | ||
320 | } | ||
321 | module_init(dm355evm_keys_init); | ||
322 | |||
323 | static void __exit dm355evm_keys_exit(void) | ||
324 | { | ||
325 | platform_driver_unregister(&dm355evm_keys_driver); | ||
326 | } | ||
327 | module_exit(dm355evm_keys_exit); | ||
328 | |||
329 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index 5bb3ab51b8c..c806fbf1e17 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c | |||
@@ -26,13 +26,17 @@ | |||
26 | #define DRV_NAME "rotary-encoder" | 26 | #define DRV_NAME "rotary-encoder" |
27 | 27 | ||
28 | struct rotary_encoder { | 28 | struct rotary_encoder { |
29 | unsigned int irq_a; | ||
30 | unsigned int irq_b; | ||
31 | unsigned int pos; | ||
32 | unsigned int armed; | ||
33 | unsigned int dir; | ||
34 | struct input_dev *input; | 29 | struct input_dev *input; |
35 | struct rotary_encoder_platform_data *pdata; | 30 | struct rotary_encoder_platform_data *pdata; |
31 | |||
32 | unsigned int axis; | ||
33 | unsigned int pos; | ||
34 | |||
35 | unsigned int irq_a; | ||
36 | unsigned int irq_b; | ||
37 | |||
38 | bool armed; | ||
39 | unsigned char dir; /* 0 - clockwise, 1 - CCW */ | ||
36 | }; | 40 | }; |
37 | 41 | ||
38 | static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) | 42 | static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) |
@@ -53,21 +57,32 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) | |||
53 | if (!encoder->armed) | 57 | if (!encoder->armed) |
54 | break; | 58 | break; |
55 | 59 | ||
56 | if (encoder->dir) { | 60 | if (pdata->relative_axis) { |
57 | /* turning counter-clockwise */ | 61 | input_report_rel(encoder->input, pdata->axis, |
58 | encoder->pos += pdata->steps; | 62 | encoder->dir ? -1 : 1); |
59 | encoder->pos--; | ||
60 | encoder->pos %= pdata->steps; | ||
61 | } else { | 63 | } else { |
62 | /* turning clockwise */ | 64 | unsigned int pos = encoder->pos; |
63 | encoder->pos++; | 65 | |
64 | encoder->pos %= pdata->steps; | 66 | if (encoder->dir) { |
67 | /* turning counter-clockwise */ | ||
68 | if (pdata->rollover) | ||
69 | pos += pdata->steps; | ||
70 | if (pos) | ||
71 | pos--; | ||
72 | } else { | ||
73 | /* turning clockwise */ | ||
74 | if (pdata->rollover || pos < pdata->steps) | ||
75 | pos++; | ||
76 | } | ||
77 | if (pdata->rollover) | ||
78 | pos %= pdata->steps; | ||
79 | encoder->pos = pos; | ||
80 | input_report_abs(encoder->input, pdata->axis, | ||
81 | encoder->pos); | ||
65 | } | 82 | } |
66 | |||
67 | input_report_abs(encoder->input, pdata->axis, encoder->pos); | ||
68 | input_sync(encoder->input); | 83 | input_sync(encoder->input); |
69 | 84 | ||
70 | encoder->armed = 0; | 85 | encoder->armed = false; |
71 | break; | 86 | break; |
72 | 87 | ||
73 | case 0x1: | 88 | case 0x1: |
@@ -77,7 +92,7 @@ static irqreturn_t rotary_encoder_irq(int irq, void *dev_id) | |||
77 | break; | 92 | break; |
78 | 93 | ||
79 | case 0x3: | 94 | case 0x3: |
80 | encoder->armed = 1; | 95 | encoder->armed = true; |
81 | break; | 96 | break; |
82 | } | 97 | } |
83 | 98 | ||
@@ -113,9 +128,15 @@ static int __devinit rotary_encoder_probe(struct platform_device *pdev) | |||
113 | input->name = pdev->name; | 128 | input->name = pdev->name; |
114 | input->id.bustype = BUS_HOST; | 129 | input->id.bustype = BUS_HOST; |
115 | input->dev.parent = &pdev->dev; | 130 | input->dev.parent = &pdev->dev; |
116 | input->evbit[0] = BIT_MASK(EV_ABS); | 131 | |
117 | input_set_abs_params(encoder->input, | 132 | if (pdata->relative_axis) { |
118 | pdata->axis, 0, pdata->steps, 0, 1); | 133 | input->evbit[0] = BIT_MASK(EV_REL); |
134 | input->relbit[0] = BIT_MASK(pdata->axis); | ||
135 | } else { | ||
136 | input->evbit[0] = BIT_MASK(EV_ABS); | ||
137 | input_set_abs_params(encoder->input, | ||
138 | pdata->axis, 0, pdata->steps, 0, 1); | ||
139 | } | ||
119 | 140 | ||
120 | err = input_register_device(input); | 141 | err = input_register_device(input); |
121 | if (err) { | 142 | if (err) { |
diff --git a/drivers/input/misc/twl4030-pwrbutton.c b/drivers/input/misc/twl4030-pwrbutton.c new file mode 100644 index 00000000000..f5fc9974a11 --- /dev/null +++ b/drivers/input/misc/twl4030-pwrbutton.c | |||
@@ -0,0 +1,145 @@ | |||
1 | /** | ||
2 | * twl4030-pwrbutton.c - TWL4030 Power Button Input Driver | ||
3 | * | ||
4 | * Copyright (C) 2008-2009 Nokia Corporation | ||
5 | * | ||
6 | * Written by Peter De Schrijver <peter.de-schrijver@nokia.com> | ||
7 | * Several fixes by Felipe Balbi <felipe.balbi@nokia.com> | ||
8 | * | ||
9 | * This file is subject to the terms and conditions of the GNU General | ||
10 | * Public License. See the file "COPYING" in the main directory of this | ||
11 | * archive for more details. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
21 | */ | ||
22 | |||
23 | #include <linux/module.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/errno.h> | ||
27 | #include <linux/input.h> | ||
28 | #include <linux/interrupt.h> | ||
29 | #include <linux/platform_device.h> | ||
30 | #include <linux/i2c/twl4030.h> | ||
31 | |||
32 | #define PWR_PWRON_IRQ (1 << 0) | ||
33 | |||
34 | #define STS_HW_CONDITIONS 0xf | ||
35 | |||
36 | static irqreturn_t powerbutton_irq(int irq, void *_pwr) | ||
37 | { | ||
38 | struct input_dev *pwr = _pwr; | ||
39 | int err; | ||
40 | u8 value; | ||
41 | |||
42 | #ifdef CONFIG_LOCKDEP | ||
43 | /* WORKAROUND for lockdep forcing IRQF_DISABLED on us, which | ||
44 | * we don't want and can't tolerate since this is a threaded | ||
45 | * IRQ and can sleep due to the i2c reads it has to issue. | ||
46 | * Although it might be friendlier not to borrow this thread | ||
47 | * context... | ||
48 | */ | ||
49 | local_irq_enable(); | ||
50 | #endif | ||
51 | |||
52 | err = twl4030_i2c_read_u8(TWL4030_MODULE_PM_MASTER, &value, | ||
53 | STS_HW_CONDITIONS); | ||
54 | if (!err) { | ||
55 | input_report_key(pwr, KEY_POWER, value & PWR_PWRON_IRQ); | ||
56 | input_sync(pwr); | ||
57 | } else { | ||
58 | dev_err(pwr->dev.parent, "twl4030: i2c error %d while reading" | ||
59 | " TWL4030 PM_MASTER STS_HW_CONDITIONS register\n", err); | ||
60 | } | ||
61 | |||
62 | return IRQ_HANDLED; | ||
63 | } | ||
64 | |||
65 | static int __devinit twl4030_pwrbutton_probe(struct platform_device *pdev) | ||
66 | { | ||
67 | struct input_dev *pwr; | ||
68 | int irq = platform_get_irq(pdev, 0); | ||
69 | int err; | ||
70 | |||
71 | pwr = input_allocate_device(); | ||
72 | if (!pwr) { | ||
73 | dev_dbg(&pdev->dev, "Can't allocate power button\n"); | ||
74 | return -ENOMEM; | ||
75 | } | ||
76 | |||
77 | pwr->evbit[0] = BIT_MASK(EV_KEY); | ||
78 | pwr->keybit[BIT_WORD(KEY_POWER)] = BIT_MASK(KEY_POWER); | ||
79 | pwr->name = "twl4030_pwrbutton"; | ||
80 | pwr->phys = "twl4030_pwrbutton/input0"; | ||
81 | pwr->dev.parent = &pdev->dev; | ||
82 | |||
83 | err = request_irq(irq, powerbutton_irq, | ||
84 | IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, | ||
85 | "twl4030_pwrbutton", pwr); | ||
86 | if (err < 0) { | ||
87 | dev_dbg(&pdev->dev, "Can't get IRQ for pwrbutton: %d\n", err); | ||
88 | goto free_input_dev; | ||
89 | } | ||
90 | |||
91 | err = input_register_device(pwr); | ||
92 | if (err) { | ||
93 | dev_dbg(&pdev->dev, "Can't register power button: %d\n", err); | ||
94 | goto free_irq; | ||
95 | } | ||
96 | |||
97 | platform_set_drvdata(pdev, pwr); | ||
98 | |||
99 | return 0; | ||
100 | |||
101 | free_irq: | ||
102 | free_irq(irq, NULL); | ||
103 | free_input_dev: | ||
104 | input_free_device(pwr); | ||
105 | return err; | ||
106 | } | ||
107 | |||
108 | static int __devexit twl4030_pwrbutton_remove(struct platform_device *pdev) | ||
109 | { | ||
110 | struct input_dev *pwr = platform_get_drvdata(pdev); | ||
111 | int irq = platform_get_irq(pdev, 0); | ||
112 | |||
113 | free_irq(irq, pwr); | ||
114 | input_unregister_device(pwr); | ||
115 | |||
116 | return 0; | ||
117 | } | ||
118 | |||
119 | struct platform_driver twl4030_pwrbutton_driver = { | ||
120 | .probe = twl4030_pwrbutton_probe, | ||
121 | .remove = __devexit_p(twl4030_pwrbutton_remove), | ||
122 | .driver = { | ||
123 | .name = "twl4030_pwrbutton", | ||
124 | .owner = THIS_MODULE, | ||
125 | }, | ||
126 | }; | ||
127 | |||
128 | static int __init twl4030_pwrbutton_init(void) | ||
129 | { | ||
130 | return platform_driver_register(&twl4030_pwrbutton_driver); | ||
131 | } | ||
132 | module_init(twl4030_pwrbutton_init); | ||
133 | |||
134 | static void __exit twl4030_pwrbutton_exit(void) | ||
135 | { | ||
136 | platform_driver_unregister(&twl4030_pwrbutton_driver); | ||
137 | } | ||
138 | module_exit(twl4030_pwrbutton_exit); | ||
139 | |||
140 | MODULE_ALIAS("platform:twl4030_pwrbutton"); | ||
141 | MODULE_DESCRIPTION("Triton2 Power Button"); | ||
142 | MODULE_LICENSE("GPL"); | ||
143 | MODULE_AUTHOR("Peter De Schrijver <peter.de-schrijver@nokia.com>"); | ||
144 | MODULE_AUTHOR("Felipe Balbi <felipe.balbi@nokia.com>"); | ||
145 | |||
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c index 46b7caeb281..c5a49aba418 100644 --- a/drivers/input/misc/uinput.c +++ b/drivers/input/misc/uinput.c | |||
@@ -54,27 +54,28 @@ static int uinput_dev_event(struct input_dev *dev, unsigned int type, unsigned i | |||
54 | return 0; | 54 | return 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | /* Atomically allocate an ID for the given request. Returns 0 on success. */ | ||
57 | static int uinput_request_alloc_id(struct uinput_device *udev, struct uinput_request *request) | 58 | static int uinput_request_alloc_id(struct uinput_device *udev, struct uinput_request *request) |
58 | { | 59 | { |
59 | /* Atomically allocate an ID for the given request. Returns 0 on success. */ | ||
60 | int id; | 60 | int id; |
61 | int err = -1; | 61 | int err = -1; |
62 | 62 | ||
63 | spin_lock(&udev->requests_lock); | 63 | spin_lock(&udev->requests_lock); |
64 | 64 | ||
65 | for (id = 0; id < UINPUT_NUM_REQUESTS; id++) | 65 | for (id = 0; id < UINPUT_NUM_REQUESTS; id++) { |
66 | if (!udev->requests[id]) { | 66 | if (!udev->requests[id]) { |
67 | request->id = id; | 67 | request->id = id; |
68 | udev->requests[id] = request; | 68 | udev->requests[id] = request; |
69 | err = 0; | 69 | err = 0; |
70 | break; | 70 | break; |
71 | } | 71 | } |
72 | } | ||
72 | 73 | ||
73 | spin_unlock(&udev->requests_lock); | 74 | spin_unlock(&udev->requests_lock); |
74 | return err; | 75 | return err; |
75 | } | 76 | } |
76 | 77 | ||
77 | static struct uinput_request* uinput_request_find(struct uinput_device *udev, int id) | 78 | static struct uinput_request *uinput_request_find(struct uinput_device *udev, int id) |
78 | { | 79 | { |
79 | /* Find an input request, by ID. Returns NULL if the ID isn't valid. */ | 80 | /* Find an input request, by ID. Returns NULL if the ID isn't valid. */ |
80 | if (id >= UINPUT_NUM_REQUESTS || id < 0) | 81 | if (id >= UINPUT_NUM_REQUESTS || id < 0) |
@@ -99,14 +100,51 @@ static void uinput_request_done(struct uinput_device *udev, struct uinput_reques | |||
99 | complete(&request->done); | 100 | complete(&request->done); |
100 | } | 101 | } |
101 | 102 | ||
102 | static int uinput_request_submit(struct input_dev *dev, struct uinput_request *request) | 103 | static int uinput_request_submit(struct uinput_device *udev, struct uinput_request *request) |
103 | { | 104 | { |
105 | int retval; | ||
106 | |||
107 | retval = uinput_request_reserve_slot(udev, request); | ||
108 | if (retval) | ||
109 | return retval; | ||
110 | |||
111 | retval = mutex_lock_interruptible(&udev->mutex); | ||
112 | if (retval) | ||
113 | return retval; | ||
114 | |||
115 | if (udev->state != UIST_CREATED) { | ||
116 | retval = -ENODEV; | ||
117 | goto out; | ||
118 | } | ||
119 | |||
104 | /* Tell our userspace app about this new request by queueing an input event */ | 120 | /* Tell our userspace app about this new request by queueing an input event */ |
105 | uinput_dev_event(dev, EV_UINPUT, request->code, request->id); | 121 | uinput_dev_event(udev->dev, EV_UINPUT, request->code, request->id); |
122 | |||
123 | out: | ||
124 | mutex_unlock(&udev->mutex); | ||
125 | return retval; | ||
126 | } | ||
127 | |||
128 | /* | ||
129 | * Fail all ouitstanding requests so handlers don't wait for the userspace | ||
130 | * to finish processing them. | ||
131 | */ | ||
132 | static void uinput_flush_requests(struct uinput_device *udev) | ||
133 | { | ||
134 | struct uinput_request *request; | ||
135 | int i; | ||
136 | |||
137 | spin_lock(&udev->requests_lock); | ||
138 | |||
139 | for (i = 0; i < UINPUT_NUM_REQUESTS; i++) { | ||
140 | request = udev->requests[i]; | ||
141 | if (request) { | ||
142 | request->retval = -ENODEV; | ||
143 | uinput_request_done(udev, request); | ||
144 | } | ||
145 | } | ||
106 | 146 | ||
107 | /* Wait for the request to complete */ | 147 | spin_unlock(&udev->requests_lock); |
108 | wait_for_completion(&request->done); | ||
109 | return request->retval; | ||
110 | } | 148 | } |
111 | 149 | ||
112 | static void uinput_dev_set_gain(struct input_dev *dev, u16 gain) | 150 | static void uinput_dev_set_gain(struct input_dev *dev, u16 gain) |
@@ -126,6 +164,7 @@ static int uinput_dev_playback(struct input_dev *dev, int effect_id, int value) | |||
126 | 164 | ||
127 | static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect, struct ff_effect *old) | 165 | static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *effect, struct ff_effect *old) |
128 | { | 166 | { |
167 | struct uinput_device *udev = input_get_drvdata(dev); | ||
129 | struct uinput_request request; | 168 | struct uinput_request request; |
130 | int retval; | 169 | int retval; |
131 | 170 | ||
@@ -146,15 +185,18 @@ static int uinput_dev_upload_effect(struct input_dev *dev, struct ff_effect *eff | |||
146 | request.u.upload.effect = effect; | 185 | request.u.upload.effect = effect; |
147 | request.u.upload.old = old; | 186 | request.u.upload.old = old; |
148 | 187 | ||
149 | retval = uinput_request_reserve_slot(input_get_drvdata(dev), &request); | 188 | retval = uinput_request_submit(udev, &request); |
150 | if (!retval) | 189 | if (!retval) { |
151 | retval = uinput_request_submit(dev, &request); | 190 | wait_for_completion(&request.done); |
191 | retval = request.retval; | ||
192 | } | ||
152 | 193 | ||
153 | return retval; | 194 | return retval; |
154 | } | 195 | } |
155 | 196 | ||
156 | static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id) | 197 | static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id) |
157 | { | 198 | { |
199 | struct uinput_device *udev = input_get_drvdata(dev); | ||
158 | struct uinput_request request; | 200 | struct uinput_request request; |
159 | int retval; | 201 | int retval; |
160 | 202 | ||
@@ -166,9 +208,11 @@ static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id) | |||
166 | request.code = UI_FF_ERASE; | 208 | request.code = UI_FF_ERASE; |
167 | request.u.effect_id = effect_id; | 209 | request.u.effect_id = effect_id; |
168 | 210 | ||
169 | retval = uinput_request_reserve_slot(input_get_drvdata(dev), &request); | 211 | retval = uinput_request_submit(udev, &request); |
170 | if (!retval) | 212 | if (!retval) { |
171 | retval = uinput_request_submit(dev, &request); | 213 | wait_for_completion(&request.done); |
214 | retval = request.retval; | ||
215 | } | ||
172 | 216 | ||
173 | return retval; | 217 | return retval; |
174 | } | 218 | } |
@@ -176,20 +220,24 @@ static int uinput_dev_erase_effect(struct input_dev *dev, int effect_id) | |||
176 | static void uinput_destroy_device(struct uinput_device *udev) | 220 | static void uinput_destroy_device(struct uinput_device *udev) |
177 | { | 221 | { |
178 | const char *name, *phys; | 222 | const char *name, *phys; |
223 | struct input_dev *dev = udev->dev; | ||
224 | enum uinput_state old_state = udev->state; | ||
179 | 225 | ||
180 | if (udev->dev) { | 226 | udev->state = UIST_NEW_DEVICE; |
181 | name = udev->dev->name; | 227 | |
182 | phys = udev->dev->phys; | 228 | if (dev) { |
183 | if (udev->state == UIST_CREATED) | 229 | name = dev->name; |
184 | input_unregister_device(udev->dev); | 230 | phys = dev->phys; |
185 | else | 231 | if (old_state == UIST_CREATED) { |
186 | input_free_device(udev->dev); | 232 | uinput_flush_requests(udev); |
233 | input_unregister_device(dev); | ||
234 | } else { | ||
235 | input_free_device(dev); | ||
236 | } | ||
187 | kfree(name); | 237 | kfree(name); |
188 | kfree(phys); | 238 | kfree(phys); |
189 | udev->dev = NULL; | 239 | udev->dev = NULL; |
190 | } | 240 | } |
191 | |||
192 | udev->state = UIST_NEW_DEVICE; | ||
193 | } | 241 | } |
194 | 242 | ||
195 | static int uinput_create_device(struct uinput_device *udev) | 243 | static int uinput_create_device(struct uinput_device *udev) |