aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/misc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-03-14 14:13:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-03-14 14:13:54 -0400
commita818d8e43147f40864363456b37a00b819439307 (patch)
treec0a5139116747c2240f94c024e247a4efd1791c6 /drivers/input/misc
parentf901e753923192a7793e5d7591e2c03dcb252d68 (diff)
parent31968ecf584330b51a25b7bf881c2b632a02a3fb (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: Input: i8042 - add ALDI/MEDION netbook E1222 to qurik reset table Input: ALPS - fix stuck buttons on some touchpads Input: wm831x-on - convert to use genirq Input: ads7846 - add wakeup support Input: appletouch - fix integer overflow issue Input: ad7877 - increase pen up imeout Input: ads7846 - add support for AD7843 parts Input: bf54x-keys - fix system hang when pressing a key Input: alps - add support for the touchpad on Toshiba Tecra A11-11L Input: remove BKL, fix input_open_file() locking Input: serio_raw - remove BKL Input: mousedev - remove BKL Input: add driver for TWL4030 vibrator device Input: enable remote wakeup for PNP i8042 keyboard ports Input: scancode in get/set_keycodes should be unsigned Input: i8042 - use platfrom_create_bundle() helper Input: wacom - merge out and in prox events Input: gamecon - fix off by one range check Input: wacom - replace WACOM_PKGLEN_PENABLED
Diffstat (limited to 'drivers/input/misc')
-rw-r--r--drivers/input/misc/Kconfig11
-rw-r--r--drivers/input/misc/Makefile1
-rw-r--r--drivers/input/misc/ati_remote2.c14
-rw-r--r--drivers/input/misc/twl4030-vibra.c297
-rw-r--r--drivers/input/misc/winbond-cir.c12
-rw-r--r--drivers/input/misc/wm831x-on.c9
6 files changed, 326 insertions, 18 deletions
diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig
index 7097bfe581d7..23140a3bb8e0 100644
--- a/drivers/input/misc/Kconfig
+++ b/drivers/input/misc/Kconfig
@@ -214,6 +214,17 @@ config INPUT_TWL4030_PWRBUTTON
214 To compile this driver as a module, choose M here. The module will 214 To compile this driver as a module, choose M here. The module will
215 be called twl4030_pwrbutton. 215 be called twl4030_pwrbutton.
216 216
217config INPUT_TWL4030_VIBRA
218 tristate "Support for TWL4030 Vibrator"
219 depends on TWL4030_CORE
220 select TWL4030_CODEC
221 select INPUT_FF_MEMLESS
222 help
223 This option enables support for TWL4030 Vibrator Driver.
224
225 To compile this driver as a module, choose M here. The module will
226 be called twl4030_vibra.
227
217config INPUT_UINPUT 228config INPUT_UINPUT
218 tristate "User level driver support" 229 tristate "User level driver support"
219 help 230 help
diff --git a/drivers/input/misc/Makefile b/drivers/input/misc/Makefile
index b611615e24ad..7e95a5d474dc 100644
--- a/drivers/input/misc/Makefile
+++ b/drivers/input/misc/Makefile
@@ -26,6 +26,7 @@ obj-$(CONFIG_INPUT_GPIO_ROTARY_ENCODER) += rotary_encoder.o
26obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o 26obj-$(CONFIG_INPUT_SGI_BTNS) += sgi_btns.o
27obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o 27obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o
28obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o 28obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o
29obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o
29obj-$(CONFIG_INPUT_UINPUT) += uinput.o 30obj-$(CONFIG_INPUT_UINPUT) += uinput.o
30obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o 31obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o
31obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o 32obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o
diff --git a/drivers/input/misc/ati_remote2.c b/drivers/input/misc/ati_remote2.c
index 0501f0e65157..15be5430bc6d 100644
--- a/drivers/input/misc/ati_remote2.c
+++ b/drivers/input/misc/ati_remote2.c
@@ -474,10 +474,11 @@ static void ati_remote2_complete_key(struct urb *urb)
474} 474}
475 475
476static int ati_remote2_getkeycode(struct input_dev *idev, 476static int ati_remote2_getkeycode(struct input_dev *idev,
477 int scancode, int *keycode) 477 unsigned int scancode, unsigned int *keycode)
478{ 478{
479 struct ati_remote2 *ar2 = input_get_drvdata(idev); 479 struct ati_remote2 *ar2 = input_get_drvdata(idev);
480 int index, mode; 480 unsigned int mode;
481 int index;
481 482
482 mode = scancode >> 8; 483 mode = scancode >> 8;
483 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask)) 484 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
@@ -491,10 +492,12 @@ static int ati_remote2_getkeycode(struct input_dev *idev,
491 return 0; 492 return 0;
492} 493}
493 494
494static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keycode) 495static int ati_remote2_setkeycode(struct input_dev *idev,
496 unsigned int scancode, unsigned int keycode)
495{ 497{
496 struct ati_remote2 *ar2 = input_get_drvdata(idev); 498 struct ati_remote2 *ar2 = input_get_drvdata(idev);
497 int index, mode, old_keycode; 499 unsigned int mode, old_keycode;
500 int index;
498 501
499 mode = scancode >> 8; 502 mode = scancode >> 8;
500 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask)) 503 if (mode > ATI_REMOTE2_PC || !((1 << mode) & ar2->mode_mask))
@@ -504,9 +507,6 @@ static int ati_remote2_setkeycode(struct input_dev *idev, int scancode, int keyc
504 if (index < 0) 507 if (index < 0)
505 return -EINVAL; 508 return -EINVAL;
506 509
507 if (keycode < KEY_RESERVED || keycode > KEY_MAX)
508 return -EINVAL;
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);
diff --git a/drivers/input/misc/twl4030-vibra.c b/drivers/input/misc/twl4030-vibra.c
new file mode 100644
index 000000000000..2fb79e064da3
--- /dev/null
+++ b/drivers/input/misc/twl4030-vibra.c
@@ -0,0 +1,297 @@
1/*
2 * twl4030-vibra.c - TWL4030 Vibrator driver
3 *
4 * Copyright (C) 2008-2010 Nokia Corporation
5 *
6 * Written by Henrik Saari <henrik.saari@nokia.com>
7 * Updates by Felipe Balbi <felipe.balbi@nokia.com>
8 * Input by Jari Vanhala <ext-jari.vanhala@nokia.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301 USA
23 *
24 */
25
26#include <linux/module.h>
27#include <linux/jiffies.h>
28#include <linux/platform_device.h>
29#include <linux/workqueue.h>
30#include <linux/i2c/twl.h>
31#include <linux/mfd/twl4030-codec.h>
32#include <linux/input.h>
33
34/* MODULE ID2 */
35#define LEDEN 0x00
36
37/* ForceFeedback */
38#define EFFECT_DIR_180_DEG 0x8000 /* range is 0 - 0xFFFF */
39
40struct vibra_info {
41 struct device *dev;
42 struct input_dev *input_dev;
43
44 struct workqueue_struct *workqueue;
45 struct work_struct play_work;
46
47 bool enabled;
48 int speed;
49 int direction;
50
51 bool coexist;
52};
53
54static void vibra_disable_leds(void)
55{
56 u8 reg;
57
58 /* Disable LEDA & LEDB, cannot be used with vibra (PWM) */
59 twl_i2c_read_u8(TWL4030_MODULE_LED, &reg, LEDEN);
60 reg &= ~0x03;
61 twl_i2c_write_u8(TWL4030_MODULE_LED, LEDEN, reg);
62}
63
64/* Powers H-Bridge and enables audio clk */
65static void vibra_enable(struct vibra_info *info)
66{
67 u8 reg;
68
69 twl4030_codec_enable_resource(TWL4030_CODEC_RES_POWER);
70
71 /* turn H-Bridge on */
72 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE,
73 &reg, TWL4030_REG_VIBRA_CTL);
74 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
75 (reg | TWL4030_VIBRA_EN), TWL4030_REG_VIBRA_CTL);
76
77 twl4030_codec_enable_resource(TWL4030_CODEC_RES_APLL);
78
79 info->enabled = true;
80}
81
82static void vibra_disable(struct vibra_info *info)
83{
84 u8 reg;
85
86 /* Power down H-Bridge */
87 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE,
88 &reg, TWL4030_REG_VIBRA_CTL);
89 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
90 (reg & ~TWL4030_VIBRA_EN), TWL4030_REG_VIBRA_CTL);
91
92 twl4030_codec_disable_resource(TWL4030_CODEC_RES_POWER);
93 twl4030_codec_disable_resource(TWL4030_CODEC_RES_APLL);
94
95 info->enabled = false;
96}
97
98static void vibra_play_work(struct work_struct *work)
99{
100 struct vibra_info *info = container_of(work,
101 struct vibra_info, play_work);
102 int dir;
103 int pwm;
104 u8 reg;
105
106 dir = info->direction;
107 pwm = info->speed;
108
109 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE,
110 &reg, TWL4030_REG_VIBRA_CTL);
111 if (pwm && (!info->coexist || !(reg & TWL4030_VIBRA_SEL))) {
112
113 if (!info->enabled)
114 vibra_enable(info);
115
116 /* set vibra rotation direction */
117 twl_i2c_read_u8(TWL4030_MODULE_AUDIO_VOICE,
118 &reg, TWL4030_REG_VIBRA_CTL);
119 reg = (dir) ? (reg | TWL4030_VIBRA_DIR) :
120 (reg & ~TWL4030_VIBRA_DIR);
121 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
122 reg, TWL4030_REG_VIBRA_CTL);
123
124 /* set PWM, 1 = max, 255 = min */
125 twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE,
126 256 - pwm, TWL4030_REG_VIBRA_SET);
127 } else {
128 if (info->enabled)
129 vibra_disable(info);
130 }
131}
132
133/*** Input/ForceFeedback ***/
134
135static int vibra_play(struct input_dev *input, void *data,
136 struct ff_effect *effect)
137{
138 struct vibra_info *info = input_get_drvdata(input);
139
140 info->speed = effect->u.rumble.strong_magnitude >> 8;
141 if (!info->speed)
142 info->speed = effect->u.rumble.weak_magnitude >> 9;
143 info->direction = effect->direction < EFFECT_DIR_180_DEG ? 0 : 1;
144 queue_work(info->workqueue, &info->play_work);
145 return 0;
146}
147
148static int twl4030_vibra_open(struct input_dev *input)
149{
150 struct vibra_info *info = input_get_drvdata(input);
151
152 info->workqueue = create_singlethread_workqueue("vibra");
153 if (info->workqueue == NULL) {
154 dev_err(&input->dev, "couldn't create workqueue\n");
155 return -ENOMEM;
156 }
157 return 0;
158}
159
160static void twl4030_vibra_close(struct input_dev *input)
161{
162 struct vibra_info *info = input_get_drvdata(input);
163
164 cancel_work_sync(&info->play_work);
165 INIT_WORK(&info->play_work, vibra_play_work); /* cleanup */
166 destroy_workqueue(info->workqueue);
167 info->workqueue = NULL;
168
169 if (info->enabled)
170 vibra_disable(info);
171}
172
173/*** Module ***/
174#if CONFIG_PM
175static int twl4030_vibra_suspend(struct device *dev)
176{
177 struct platform_device *pdev = to_platform_device(dev);
178 struct vibra_info *info = platform_get_drvdata(pdev);
179
180 if (info->enabled)
181 vibra_disable(info);
182
183 return 0;
184}
185
186static int twl4030_vibra_resume(struct device *dev)
187{
188 vibra_disable_leds();
189 return 0;
190}
191
192static SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops,
193 twl4030_vibra_suspend, twl4030_vibra_resume);
194#endif
195
196static int __devinit twl4030_vibra_probe(struct platform_device *pdev)
197{
198 struct twl4030_codec_vibra_data *pdata = pdev->dev.platform_data;
199 struct vibra_info *info;
200 int ret;
201
202 if (!pdata) {
203 dev_dbg(&pdev->dev, "platform_data not available\n");
204 return -EINVAL;
205 }
206
207 info = kzalloc(sizeof(*info), GFP_KERNEL);
208 if (!info)
209 return -ENOMEM;
210
211 info->dev = &pdev->dev;
212 info->coexist = pdata->coexist;
213 INIT_WORK(&info->play_work, vibra_play_work);
214
215 info->input_dev = input_allocate_device();
216 if (info->input_dev == NULL) {
217 dev_err(&pdev->dev, "couldn't allocate input device\n");
218 ret = -ENOMEM;
219 goto err_kzalloc;
220 }
221
222 input_set_drvdata(info->input_dev, info);
223
224 info->input_dev->name = "twl4030:vibrator";
225 info->input_dev->id.version = 1;
226 info->input_dev->dev.parent = pdev->dev.parent;
227 info->input_dev->open = twl4030_vibra_open;
228 info->input_dev->close = twl4030_vibra_close;
229 __set_bit(FF_RUMBLE, info->input_dev->ffbit);
230
231 ret = input_ff_create_memless(info->input_dev, NULL, vibra_play);
232 if (ret < 0) {
233 dev_dbg(&pdev->dev, "couldn't register vibrator to FF\n");
234 goto err_ialloc;
235 }
236
237 ret = input_register_device(info->input_dev);
238 if (ret < 0) {
239 dev_dbg(&pdev->dev, "couldn't register input device\n");
240 goto err_iff;
241 }
242
243 vibra_disable_leds();
244
245 platform_set_drvdata(pdev, info);
246 return 0;
247
248err_iff:
249 input_ff_destroy(info->input_dev);
250err_ialloc:
251 input_free_device(info->input_dev);
252err_kzalloc:
253 kfree(info);
254 return ret;
255}
256
257static int __devexit twl4030_vibra_remove(struct platform_device *pdev)
258{
259 struct vibra_info *info = platform_get_drvdata(pdev);
260
261 /* this also free ff-memless and calls close if needed */
262 input_unregister_device(info->input_dev);
263 kfree(info);
264 platform_set_drvdata(pdev, NULL);
265
266 return 0;
267}
268
269static struct platform_driver twl4030_vibra_driver = {
270 .probe = twl4030_vibra_probe,
271 .remove = __devexit_p(twl4030_vibra_remove),
272 .driver = {
273 .name = "twl4030_codec_vibra",
274 .owner = THIS_MODULE,
275#ifdef CONFIG_PM
276 .pm = &twl4030_vibra_pm_ops,
277#endif
278 },
279};
280
281static int __init twl4030_vibra_init(void)
282{
283 return platform_driver_register(&twl4030_vibra_driver);
284}
285module_init(twl4030_vibra_init);
286
287static void __exit twl4030_vibra_exit(void)
288{
289 platform_driver_unregister(&twl4030_vibra_driver);
290}
291module_exit(twl4030_vibra_exit);
292
293MODULE_ALIAS("platform:twl4030_codec_vibra");
294
295MODULE_DESCRIPTION("TWL4030 Vibra driver");
296MODULE_LICENSE("GPL");
297MODULE_AUTHOR("Nokia Corporation");
diff --git a/drivers/input/misc/winbond-cir.c b/drivers/input/misc/winbond-cir.c
index cbec3dfdd42b..9c155a43abc2 100644
--- a/drivers/input/misc/winbond-cir.c
+++ b/drivers/input/misc/winbond-cir.c
@@ -385,26 +385,24 @@ wbcir_do_getkeycode(struct wbcir_data *data, u32 scancode)
385} 385}
386 386
387static int 387static int
388wbcir_getkeycode(struct input_dev *dev, int scancode, int *keycode) 388wbcir_getkeycode(struct input_dev *dev,
389 unsigned int scancode, unsigned int *keycode)
389{ 390{
390 struct wbcir_data *data = input_get_drvdata(dev); 391 struct wbcir_data *data = input_get_drvdata(dev);
391 392
392 *keycode = (int)wbcir_do_getkeycode(data, (u32)scancode); 393 *keycode = wbcir_do_getkeycode(data, scancode);
393 return 0; 394 return 0;
394} 395}
395 396
396static int 397static int
397wbcir_setkeycode(struct input_dev *dev, int sscancode, int keycode) 398wbcir_setkeycode(struct input_dev *dev,
399 unsigned int scancode, unsigned int keycode)
398{ 400{
399 struct wbcir_data *data = input_get_drvdata(dev); 401 struct wbcir_data *data = input_get_drvdata(dev);
400 struct wbcir_keyentry *keyentry; 402 struct wbcir_keyentry *keyentry;
401 struct wbcir_keyentry *new_keyentry; 403 struct wbcir_keyentry *new_keyentry;
402 unsigned long flags; 404 unsigned long flags;
403 unsigned int old_keycode = KEY_RESERVED; 405 unsigned int old_keycode = KEY_RESERVED;
404 u32 scancode = (u32)sscancode;
405
406 if (keycode < 0 || keycode > KEY_MAX)
407 return -EINVAL;
408 406
409 new_keyentry = kmalloc(sizeof(*new_keyentry), GFP_KERNEL); 407 new_keyentry = kmalloc(sizeof(*new_keyentry), GFP_KERNEL);
410 if (!new_keyentry) 408 if (!new_keyentry)
diff --git a/drivers/input/misc/wm831x-on.c b/drivers/input/misc/wm831x-on.c
index ba4f5dd7c60e..1e54bce72db5 100644
--- a/drivers/input/misc/wm831x-on.c
+++ b/drivers/input/misc/wm831x-on.c
@@ -97,8 +97,9 @@ static int __devinit wm831x_on_probe(struct platform_device *pdev)
97 wm831x_on->dev->phys = "wm831x_on/input0"; 97 wm831x_on->dev->phys = "wm831x_on/input0";
98 wm831x_on->dev->dev.parent = &pdev->dev; 98 wm831x_on->dev->dev.parent = &pdev->dev;
99 99
100 ret = wm831x_request_irq(wm831x, irq, wm831x_on_irq, 100 ret = request_threaded_irq(irq, NULL, wm831x_on_irq,
101 IRQF_TRIGGER_RISING, "wm831x_on", wm831x_on); 101 IRQF_TRIGGER_RISING, "wm831x_on",
102 wm831x_on);
102 if (ret < 0) { 103 if (ret < 0) {
103 dev_err(&pdev->dev, "Unable to request IRQ: %d\n", ret); 104 dev_err(&pdev->dev, "Unable to request IRQ: %d\n", ret);
104 goto err_input_dev; 105 goto err_input_dev;
@@ -114,7 +115,7 @@ static int __devinit wm831x_on_probe(struct platform_device *pdev)
114 return 0; 115 return 0;
115 116
116err_irq: 117err_irq:
117 wm831x_free_irq(wm831x, irq, NULL); 118 free_irq(irq, wm831x_on);
118err_input_dev: 119err_input_dev:
119 input_free_device(wm831x_on->dev); 120 input_free_device(wm831x_on->dev);
120err: 121err:
@@ -127,7 +128,7 @@ static int __devexit wm831x_on_remove(struct platform_device *pdev)
127 struct wm831x_on *wm831x_on = platform_get_drvdata(pdev); 128 struct wm831x_on *wm831x_on = platform_get_drvdata(pdev);
128 int irq = platform_get_irq(pdev, 0); 129 int irq = platform_get_irq(pdev, 0);
129 130
130 wm831x_free_irq(wm831x_on->wm831x, irq, wm831x_on); 131 free_irq(irq, wm831x_on);
131 cancel_delayed_work_sync(&wm831x_on->work); 132 cancel_delayed_work_sync(&wm831x_on->work);
132 input_unregister_device(wm831x_on->dev); 133 input_unregister_device(wm831x_on->dev);
133 kfree(wm831x_on); 134 kfree(wm831x_on);