diff options
author | Johannes Berg <johannes@sipsolutions.net> | 2006-06-26 01:49:55 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor_core@ameritech.net> | 2006-06-26 01:49:55 -0400 |
commit | 9e8e30a0cc0ccb43773d14d8b8b84bcc585e9cc1 (patch) | |
tree | 0e5c5a6b28953b934d4533d330f51af740c0399e /drivers/macintosh | |
parent | ca56fe07f46e1c174b544e714be183f1476fecea (diff) |
Input: via-pmu - add input device support
Add an input device for the button and lid switch so that userspace gets
notified about the user pressing them via the standard input layer.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/macintosh')
-rw-r--r-- | drivers/macintosh/Makefile | 2 | ||||
-rw-r--r-- | drivers/macintosh/via-pmu-event.c | 80 | ||||
-rw-r--r-- | drivers/macintosh/via-pmu-event.h | 8 | ||||
-rw-r--r-- | drivers/macintosh/via-pmu.c | 8 |
4 files changed, 97 insertions, 1 deletions
diff --git a/drivers/macintosh/Makefile b/drivers/macintosh/Makefile index 8972e53d2dc..45a268f8047 100644 --- a/drivers/macintosh/Makefile +++ b/drivers/macintosh/Makefile | |||
@@ -11,7 +11,7 @@ obj-$(CONFIG_MAC_EMUMOUSEBTN) += mac_hid.o | |||
11 | obj-$(CONFIG_INPUT_ADBHID) += adbhid.o | 11 | obj-$(CONFIG_INPUT_ADBHID) += adbhid.o |
12 | obj-$(CONFIG_ANSLCD) += ans-lcd.o | 12 | obj-$(CONFIG_ANSLCD) += ans-lcd.o |
13 | 13 | ||
14 | obj-$(CONFIG_ADB_PMU) += via-pmu.o | 14 | obj-$(CONFIG_ADB_PMU) += via-pmu.o via-pmu-event.o |
15 | obj-$(CONFIG_PMAC_BACKLIGHT) += via-pmu-backlight.o | 15 | obj-$(CONFIG_PMAC_BACKLIGHT) += via-pmu-backlight.o |
16 | obj-$(CONFIG_ADB_CUDA) += via-cuda.o | 16 | obj-$(CONFIG_ADB_CUDA) += via-cuda.o |
17 | obj-$(CONFIG_PMAC_APM_EMU) += apm_emu.o | 17 | obj-$(CONFIG_PMAC_APM_EMU) += apm_emu.o |
diff --git a/drivers/macintosh/via-pmu-event.c b/drivers/macintosh/via-pmu-event.c new file mode 100644 index 00000000000..25cd5654232 --- /dev/null +++ b/drivers/macintosh/via-pmu-event.c | |||
@@ -0,0 +1,80 @@ | |||
1 | /* | ||
2 | * via-pmu event device for reporting some events that come through the PMU | ||
3 | * | ||
4 | * Copyright 2006 Johannes Berg <johannes@sipsolutions.net> | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but | ||
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or | ||
14 | * NON INFRINGEMENT. See the GNU General Public License for more | ||
15 | * details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | #include <linux/input.h> | ||
24 | #include <linux/adb.h> | ||
25 | #include <linux/pmu.h> | ||
26 | #include "via-pmu-event.h" | ||
27 | |||
28 | static struct input_dev *pmu_input_dev; | ||
29 | |||
30 | static int __init via_pmu_event_init(void) | ||
31 | { | ||
32 | int err; | ||
33 | |||
34 | /* do other models report button/lid status? */ | ||
35 | if (pmu_get_model() != PMU_KEYLARGO_BASED) | ||
36 | return -ENODEV; | ||
37 | |||
38 | pmu_input_dev = input_allocate_device(); | ||
39 | if (!pmu_input_dev) | ||
40 | return -ENOMEM; | ||
41 | |||
42 | pmu_input_dev->name = "PMU"; | ||
43 | pmu_input_dev->id.bustype = BUS_HOST; | ||
44 | pmu_input_dev->id.vendor = 0x0001; | ||
45 | pmu_input_dev->id.product = 0x0001; | ||
46 | pmu_input_dev->id.version = 0x0100; | ||
47 | |||
48 | set_bit(EV_KEY, pmu_input_dev->evbit); | ||
49 | set_bit(EV_SW, pmu_input_dev->evbit); | ||
50 | set_bit(KEY_POWER, pmu_input_dev->keybit); | ||
51 | set_bit(SW_LID, pmu_input_dev->swbit); | ||
52 | |||
53 | err = input_register_device(pmu_input_dev); | ||
54 | if (err) | ||
55 | input_free_device(pmu_input_dev); | ||
56 | return err; | ||
57 | } | ||
58 | |||
59 | void via_pmu_event(int key, int down) | ||
60 | { | ||
61 | |||
62 | if (unlikely(!pmu_input_dev)) | ||
63 | return; | ||
64 | |||
65 | switch (key) { | ||
66 | case PMU_EVT_POWER: | ||
67 | input_report_key(pmu_input_dev, KEY_POWER, down); | ||
68 | break; | ||
69 | case PMU_EVT_LID: | ||
70 | input_report_switch(pmu_input_dev, SW_LID, down); | ||
71 | break; | ||
72 | default: | ||
73 | /* no such key handled */ | ||
74 | return; | ||
75 | } | ||
76 | |||
77 | input_sync(pmu_input_dev); | ||
78 | } | ||
79 | |||
80 | late_initcall(via_pmu_event_init); | ||
diff --git a/drivers/macintosh/via-pmu-event.h b/drivers/macintosh/via-pmu-event.h new file mode 100644 index 00000000000..72c54de408e --- /dev/null +++ b/drivers/macintosh/via-pmu-event.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __VIA_PMU_EVENT_H | ||
2 | #define __VIA_PMU_EVENT_H | ||
3 | |||
4 | #define PMU_EVT_POWER 0 | ||
5 | #define PMU_EVT_LID 1 | ||
6 | extern void via_pmu_event(int key, int down); | ||
7 | |||
8 | #endif /* __VIA_PMU_EVENT_H */ | ||
diff --git a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c index 2a355ae5956..1ab4f16c08b 100644 --- a/drivers/macintosh/via-pmu.c +++ b/drivers/macintosh/via-pmu.c | |||
@@ -69,6 +69,8 @@ | |||
69 | #include <asm/open_pic.h> | 69 | #include <asm/open_pic.h> |
70 | #endif | 70 | #endif |
71 | 71 | ||
72 | #include "via-pmu-event.h" | ||
73 | |||
72 | /* Some compile options */ | 74 | /* Some compile options */ |
73 | #undef SUSPEND_USES_PMU | 75 | #undef SUSPEND_USES_PMU |
74 | #define DEBUG_SLEEP | 76 | #define DEBUG_SLEEP |
@@ -1427,6 +1429,12 @@ next: | |||
1427 | if (pmu_battery_count) | 1429 | if (pmu_battery_count) |
1428 | query_battery_state(); | 1430 | query_battery_state(); |
1429 | pmu_pass_intr(data, len); | 1431 | pmu_pass_intr(data, len); |
1432 | /* len == 6 is probably a bad check. But how do I | ||
1433 | * know what PMU versions send what events here? */ | ||
1434 | if (len == 6) { | ||
1435 | via_pmu_event(PMU_EVT_POWER, !!(data[1]&8)); | ||
1436 | via_pmu_event(PMU_EVT_LID, data[1]&1); | ||
1437 | } | ||
1430 | } else { | 1438 | } else { |
1431 | pmu_pass_intr(data, len); | 1439 | pmu_pass_intr(data, len); |
1432 | } | 1440 | } |