]>
Commit | Line | Data |
---|---|---|
2d56f3a3 PL |
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 */ |