2
* touchpad.c -- enable/disable touchpad
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License as published by the
6
* Free Software Foundation; either version 2, or (at your option) any
9
* This program is distributed in the hope that it will be useful, but
10
* WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* General Public License for more details.
14
* Written by Soós Péter <sp@osb.hu>, 2002-2004
15
* Modified by Mathieu Bérard <mathieu.berard@crans.org>, 2006
21
static int omnibook_touchpad_set(struct omnibook_operation *io_op, int status)
25
if(mutex_lock_interruptible(&io_op->backend->mutex))
28
if ((retval = __omnibook_toggle(io_op, !!status))) {
29
printk(O_ERR "Failed touchpad %sable command.\n", status ? "en" : "dis");
33
io_op->backend->touchpad_state = !!status;
36
mutex_unlock(&io_op->backend->mutex);
41
* Power management handlers: redisable touchpad on resume (if necessary)
43
static int omnibook_touchpad_resume(struct omnibook_operation *io_op)
46
mutex_lock(&io_op->backend->mutex);
47
retval = __omnibook_toggle(io_op, !!io_op->backend->touchpad_state);
48
mutex_unlock(&io_op->backend->mutex);
53
* Hardware query is unsupported, so reading is unreliable.
55
static int omnibook_touchpad_read(char *buffer, struct omnibook_operation *io_op)
59
if(mutex_lock_interruptible(&io_op->backend->mutex))
63
sprintf(buffer + len, "Last touchpad action was an %s command.\n",
64
io_op->backend->touchpad_state ? "enable" : "disable");
66
mutex_unlock(&io_op->backend->mutex);
70
static int omnibook_touchpad_write(char *buffer, struct omnibook_operation *io_op)
74
if (*buffer == '0' || *buffer == '1') {
76
if (!omnibook_touchpad_set(io_op, cmd)) {
77
dprintk("%sabling touchpad.\n", cmd ? "En" : "Dis");
86
static int __init omnibook_touchpad_init(struct omnibook_operation *io_op)
88
mutex_lock(&io_op->backend->mutex);
89
/* Touchpad is assumed to be enabled by default */
90
io_op->backend->touchpad_state = 1;
91
mutex_unlock(&io_op->backend->mutex);
96
* Reenable touchpad upon exit
98
static void __exit omnibook_touchpad_cleanup(struct omnibook_operation *io_op)
100
omnibook_touchpad_set(io_op, 1);
101
printk(O_INFO "Enabling touchpad.\n");
104
static struct omnibook_tbl touchpad_table[] __initdata = {
105
{XE3GF | XE3GC | TSP10,
106
COMMAND(KBC, OMNIBOOK_KBC_CMD_TOUCHPAD_ENABLE, OMNIBOOK_KBC_CMD_TOUCHPAD_DISABLE)},
107
{TSM70, {CDI, 0, TSM70_FN_INDEX, 0, TSM70_TOUCHPAD_ON, TSM70_TOUCHPAD_OFF}},
111
static struct omnibook_feature __declared_feature touchpad_driver = {
114
.read = omnibook_touchpad_read,
115
.write = omnibook_touchpad_write,
116
.init = omnibook_touchpad_init,
117
.exit = omnibook_touchpad_cleanup,
118
.resume = omnibook_touchpad_resume,
119
.ectypes = XE3GF | XE3GC | TSP10 | TSM70,
120
.tbl = touchpad_table,
123
module_param_named(touchpad, touchpad_driver.enabled, int, S_IRUGO);
124
MODULE_PARM_DESC(touchpad, "Use 0 to disable, 1 to enable touchpad handling");