diff options
author | Philip Langdale <philipl@overt.org> | 2008-10-16 22:31:42 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2008-10-27 22:03:42 -0400 |
commit | 2d56f3a32c0e62f99c043d2579840f9731fe5855 (patch) | |
tree | 3bf1539bbed43e5309dcfd634f202bb9ad0f11b2 /drivers/input/input-compat.h | |
parent | 49fdf6785fd660e18a1eb4588928f47e9fa29a9a (diff) |
Input: refactor evdev 32bit compat to be shareable with uinput
Currently, evdev has working 32bit compatibility and uinput does not. uinput
needs the input_event code that evdev uses, so let's refactor it so it can
be shared.
[dtor@mail.ru: add fix for force feedback compat issues]
Signed-off-by: Philip Langdale <philipl@overt.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/input-compat.h')
-rw-r--r-- | drivers/input/input-compat.h | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/drivers/input/input-compat.h b/drivers/input/input-compat.h new file mode 100644 index 000000000000..47cd9eaee66a --- /dev/null +++ b/drivers/input/input-compat.h | |||
@@ -0,0 +1,94 @@ | |||
1 | #ifndef _INPUT_COMPAT_H | ||
2 | #define _INPUT_COMPAT_H | ||
3 | |||
4 | /* | ||
5 | * 32bit compatibility wrappers for the input subsystem. | ||
6 | * | ||
7 | * Very heavily based on evdev.c - Copyright (c) 1999-2002 Vojtech Pavlik | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or modify it | ||
10 | * under the terms of the GNU General Public License version 2 as published by | ||
11 | * the Free Software Foundation. | ||
12 | */ | ||
13 | |||
14 | #include <linux/compiler.h> | ||
15 | #include <linux/compat.h> | ||
16 | #include <linux/input.h> | ||
17 | |||
18 | #ifdef CONFIG_COMPAT | ||
19 | |||
20 | /* Note to the author of this code: did it ever occur to | ||
21 | you why the ifdefs are needed? Think about it again. -AK */ | ||
22 | #ifdef CONFIG_X86_64 | ||
23 | # define INPUT_COMPAT_TEST is_compat_task() | ||
24 | #elif defined(CONFIG_IA64) | ||
25 | # define INPUT_COMPAT_TEST IS_IA32_PROCESS(task_pt_regs(current)) | ||
26 | #elif defined(CONFIG_S390) | ||
27 | # define INPUT_COMPAT_TEST test_thread_flag(TIF_31BIT) | ||
28 | #elif defined(CONFIG_MIPS) | ||
29 | # define INPUT_COMPAT_TEST test_thread_flag(TIF_32BIT_ADDR) | ||
30 | #else | ||
31 | # define INPUT_COMPAT_TEST test_thread_flag(TIF_32BIT) | ||
32 | #endif | ||
33 | |||
34 | struct input_event_compat { | ||
35 | struct compat_timeval time; | ||
36 | __u16 type; | ||
37 | __u16 code; | ||
38 | __s32 value; | ||
39 | }; | ||
40 | |||
41 | struct ff_periodic_effect_compat { | ||
42 | __u16 waveform; | ||
43 | __u16 period; | ||
44 | __s16 magnitude; | ||
45 | __s16 offset; | ||
46 | __u16 phase; | ||
47 | |||
48 | struct ff_envelope envelope; | ||
49 | |||
50 | __u32 custom_len; | ||
51 | compat_uptr_t custom_data; | ||
52 | }; | ||
53 | |||
54 | struct ff_effect_compat { | ||
55 | __u16 type; | ||
56 | __s16 id; | ||
57 | __u16 direction; | ||
58 | struct ff_trigger trigger; | ||
59 | struct ff_replay replay; | ||
60 | |||
61 | union { | ||
62 | struct ff_constant_effect constant; | ||
63 | struct ff_ramp_effect ramp; | ||
64 | struct ff_periodic_effect_compat periodic; | ||
65 | struct ff_condition_effect condition[2]; /* One for each axis */ | ||
66 | struct ff_rumble_effect rumble; | ||
67 | } u; | ||
68 | }; | ||
69 | |||
70 | static inline size_t input_event_size(void) | ||
71 | { | ||
72 | return INPUT_COMPAT_TEST ? | ||
73 | sizeof(struct input_event_compat) : sizeof(struct input_event); | ||
74 | } | ||
75 | |||
76 | #else | ||
77 | |||
78 | static inline size_t input_event_size(void) | ||
79 | { | ||
80 | return sizeof(struct input_event); | ||
81 | } | ||
82 | |||
83 | #endif /* CONFIG_COMPAT */ | ||
84 | |||
85 | int input_event_from_user(const char __user *buffer, | ||
86 | struct input_event *event); | ||
87 | |||
88 | int input_event_to_user(char __user *buffer, | ||
89 | const struct input_event *event); | ||
90 | |||
91 | int input_ff_effect_from_user(const char __user *buffer, size_t size, | ||
92 | struct ff_effect *effect); | ||
93 | |||
94 | #endif /* _INPUT_COMPAT_H */ | ||