^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0-only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _INPUT_COMPAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _INPUT_COMPAT_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * 32bit compatibility wrappers for the input subsystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Very heavily based on evdev.c - Copyright (c) 1999-2002 Vojtech Pavlik
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/compiler.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/compat.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/input.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #ifdef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct input_event_compat {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) compat_ulong_t sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) compat_ulong_t usec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) __u16 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) __u16 code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) __s32 value;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) struct ff_periodic_effect_compat {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) __u16 waveform;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) __u16 period;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) __s16 magnitude;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) __s16 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) __u16 phase;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct ff_envelope envelope;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __u32 custom_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) compat_uptr_t custom_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) struct ff_effect_compat {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) __u16 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) __s16 id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) __u16 direction;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct ff_trigger trigger;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct ff_replay replay;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct ff_constant_effect constant;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct ff_ramp_effect ramp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct ff_periodic_effect_compat periodic;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct ff_condition_effect condition[2]; /* One for each axis */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) struct ff_rumble_effect rumble;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) } u;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static inline size_t input_event_size(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) sizeof(struct input_event_compat) : sizeof(struct input_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) static inline size_t input_event_size(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) return sizeof(struct input_event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #endif /* CONFIG_COMPAT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) int input_event_from_user(const char __user *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) struct input_event *event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) int input_event_to_user(char __user *buffer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) const struct input_event *event);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int input_ff_effect_from_user(const char __user *buffer, size_t size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) struct ff_effect *effect);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #endif /* _INPUT_COMPAT_H */