xref: /openbmc/linux/drivers/input/input-compat.h (revision 75bf465f0bc33e9b776a46d6a1b9b990f5fb7c37)
1*d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
22d56f3a3SPhilip Langdale #ifndef _INPUT_COMPAT_H
32d56f3a3SPhilip Langdale #define _INPUT_COMPAT_H
42d56f3a3SPhilip Langdale 
52d56f3a3SPhilip Langdale /*
62d56f3a3SPhilip Langdale  * 32bit compatibility wrappers for the input subsystem.
72d56f3a3SPhilip Langdale  *
82d56f3a3SPhilip Langdale  * Very heavily based on evdev.c - Copyright (c) 1999-2002 Vojtech Pavlik
92d56f3a3SPhilip Langdale  */
102d56f3a3SPhilip Langdale 
112d56f3a3SPhilip Langdale #include <linux/compiler.h>
122d56f3a3SPhilip Langdale #include <linux/compat.h>
132d56f3a3SPhilip Langdale #include <linux/input.h>
142d56f3a3SPhilip Langdale 
152d56f3a3SPhilip Langdale #ifdef CONFIG_COMPAT
162d56f3a3SPhilip Langdale 
172d56f3a3SPhilip Langdale struct input_event_compat {
18152194feSDeepa Dinamani 	compat_ulong_t sec;
19152194feSDeepa Dinamani 	compat_ulong_t usec;
202d56f3a3SPhilip Langdale 	__u16 type;
212d56f3a3SPhilip Langdale 	__u16 code;
222d56f3a3SPhilip Langdale 	__s32 value;
232d56f3a3SPhilip Langdale };
242d56f3a3SPhilip Langdale 
252d56f3a3SPhilip Langdale struct ff_periodic_effect_compat {
262d56f3a3SPhilip Langdale 	__u16 waveform;
272d56f3a3SPhilip Langdale 	__u16 period;
282d56f3a3SPhilip Langdale 	__s16 magnitude;
292d56f3a3SPhilip Langdale 	__s16 offset;
302d56f3a3SPhilip Langdale 	__u16 phase;
312d56f3a3SPhilip Langdale 
322d56f3a3SPhilip Langdale 	struct ff_envelope envelope;
332d56f3a3SPhilip Langdale 
342d56f3a3SPhilip Langdale 	__u32 custom_len;
352d56f3a3SPhilip Langdale 	compat_uptr_t custom_data;
362d56f3a3SPhilip Langdale };
372d56f3a3SPhilip Langdale 
382d56f3a3SPhilip Langdale struct ff_effect_compat {
392d56f3a3SPhilip Langdale 	__u16 type;
402d56f3a3SPhilip Langdale 	__s16 id;
412d56f3a3SPhilip Langdale 	__u16 direction;
422d56f3a3SPhilip Langdale 	struct ff_trigger trigger;
432d56f3a3SPhilip Langdale 	struct ff_replay replay;
442d56f3a3SPhilip Langdale 
452d56f3a3SPhilip Langdale 	union {
462d56f3a3SPhilip Langdale 		struct ff_constant_effect constant;
472d56f3a3SPhilip Langdale 		struct ff_ramp_effect ramp;
482d56f3a3SPhilip Langdale 		struct ff_periodic_effect_compat periodic;
492d56f3a3SPhilip Langdale 		struct ff_condition_effect condition[2]; /* One for each axis */
502d56f3a3SPhilip Langdale 		struct ff_rumble_effect rumble;
512d56f3a3SPhilip Langdale 	} u;
522d56f3a3SPhilip Langdale };
532d56f3a3SPhilip Langdale 
input_event_size(void)542d56f3a3SPhilip Langdale static inline size_t input_event_size(void)
552d56f3a3SPhilip Langdale {
56b8b4ead1SAndrew Morton 	return (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) ?
572d56f3a3SPhilip Langdale 		sizeof(struct input_event_compat) : sizeof(struct input_event);
582d56f3a3SPhilip Langdale }
592d56f3a3SPhilip Langdale 
602d56f3a3SPhilip Langdale #else
612d56f3a3SPhilip Langdale 
input_event_size(void)622d56f3a3SPhilip Langdale static inline size_t input_event_size(void)
632d56f3a3SPhilip Langdale {
642d56f3a3SPhilip Langdale 	return sizeof(struct input_event);
652d56f3a3SPhilip Langdale }
662d56f3a3SPhilip Langdale 
672d56f3a3SPhilip Langdale #endif /* CONFIG_COMPAT */
682d56f3a3SPhilip Langdale 
692d56f3a3SPhilip Langdale int input_event_from_user(const char __user *buffer,
702d56f3a3SPhilip Langdale 			 struct input_event *event);
712d56f3a3SPhilip Langdale 
722d56f3a3SPhilip Langdale int input_event_to_user(char __user *buffer,
732d56f3a3SPhilip Langdale 			const struct input_event *event);
742d56f3a3SPhilip Langdale 
752d56f3a3SPhilip Langdale int input_ff_effect_from_user(const char __user *buffer, size_t size,
762d56f3a3SPhilip Langdale 			      struct ff_effect *effect);
772d56f3a3SPhilip Langdale 
782d56f3a3SPhilip Langdale #endif /* _INPUT_COMPAT_H */
79