1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
/*
* touchpad.c -- enable/disable touchpad
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* Written by Soós Péter <sp@osb.hu>, 2002-2004
* Modified by Mathieu Bérard <mathieu.berard@crans.org>, 2006
*/
#include "omnibook.h"
#include "hardware.h"
static int omnibook_touchpad_set(struct omnibook_operation *io_op, int status)
{
int retval = 0;
if(mutex_lock_interruptible(&io_op->backend->mutex))
return -ERESTARTSYS;
if ((retval = __omnibook_toggle(io_op, !!status))) {
printk(O_ERR "Failed touchpad %sable command.\n", status ? "en" : "dis");
goto out;
}
io_op->backend->touchpad_state = !!status;
out:
mutex_unlock(&io_op->backend->mutex);
return retval;
}
/*
* Power management handlers: redisable touchpad on resume (if necessary)
*/
static int omnibook_touchpad_resume(struct omnibook_operation *io_op)
{
int retval;
mutex_lock(&io_op->backend->mutex);
retval = __omnibook_toggle(io_op, !!io_op->backend->touchpad_state);
mutex_unlock(&io_op->backend->mutex);
return retval;
}
/*
* Hardware query is unsupported, so reading is unreliable.
*/
static int omnibook_touchpad_read(char *buffer, struct omnibook_operation *io_op)
{
int len = 0;
if(mutex_lock_interruptible(&io_op->backend->mutex))
return -ERESTARTSYS;
len +=
sprintf(buffer + len, "Last touchpad action was an %s command.\n",
io_op->backend->touchpad_state ? "enable" : "disable");
mutex_unlock(&io_op->backend->mutex);
return len;
}
static int omnibook_touchpad_write(char *buffer, struct omnibook_operation *io_op)
{
int cmd;
if (*buffer == '0' || *buffer == '1') {
cmd = *buffer - '0';
if (!omnibook_touchpad_set(io_op, cmd)) {
dprintk("%sabling touchpad.\n", cmd ? "En" : "Dis");
}
} else {
return -EINVAL;
}
return 0;
}
static int __init omnibook_touchpad_init(struct omnibook_operation *io_op)
{
mutex_lock(&io_op->backend->mutex);
/* Touchpad is assumed to be enabled by default */
io_op->backend->touchpad_state = 1;
mutex_unlock(&io_op->backend->mutex);
return 0;
}
/*
* Reenable touchpad upon exit
*/
static void __exit omnibook_touchpad_cleanup(struct omnibook_operation *io_op)
{
omnibook_touchpad_set(io_op, 1);
printk(O_INFO "Enabling touchpad.\n");
}
static struct omnibook_tbl touchpad_table[] __initdata = {
{XE3GF | XE3GC | TSP10,
COMMAND(KBC, OMNIBOOK_KBC_CMD_TOUCHPAD_ENABLE, OMNIBOOK_KBC_CMD_TOUCHPAD_DISABLE)},
{TSM70, {CDI, 0, TSM70_FN_INDEX, 0, TSM70_TOUCHPAD_ON, TSM70_TOUCHPAD_OFF}},
{0,}
};
static struct omnibook_feature __declared_feature touchpad_driver = {
.name = "touchpad",
.enabled = 1,
.read = omnibook_touchpad_read,
.write = omnibook_touchpad_write,
.init = omnibook_touchpad_init,
.exit = omnibook_touchpad_cleanup,
.resume = omnibook_touchpad_resume,
.ectypes = XE3GF | XE3GC | TSP10 | TSM70,
.tbl = touchpad_table,
};
module_param_named(touchpad, touchpad_driver.enabled, int, S_IRUGO);
MODULE_PARM_DESC(touchpad, "Use 0 to disable, 1 to enable touchpad handling");
/* End of file */
|