input-compat.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef _INPUT_COMPAT_H
  3. #define _INPUT_COMPAT_H
  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. #include <linux/compiler.h>
  10. #include <linux/compat.h>
  11. #include <linux/input.h>
  12. #ifdef CONFIG_COMPAT
  13. struct input_event_compat {
  14. compat_ulong_t sec;
  15. compat_ulong_t usec;
  16. __u16 type;
  17. __u16 code;
  18. __s32 value;
  19. };
  20. struct ff_periodic_effect_compat {
  21. __u16 waveform;
  22. __u16 period;
  23. __s16 magnitude;
  24. __s16 offset;
  25. __u16 phase;
  26. struct ff_envelope envelope;
  27. __u32 custom_len;
  28. compat_uptr_t custom_data;
  29. };
  30. struct ff_effect_compat {
  31. __u16 type;
  32. __s16 id;
  33. __u16 direction;
  34. struct ff_trigger trigger;
  35. struct ff_replay replay;
  36. union {
  37. struct ff_constant_effect constant;
  38. struct ff_ramp_effect ramp;
  39. struct ff_periodic_effect_compat periodic;
  40. struct ff_condition_effect condition[2]; /* One for each axis */
  41. struct ff_rumble_effect rumble;
  42. } u;
  43. };
  44. static inline size_t input_event_size(void)
  45. {
  46. return (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) ?
  47. sizeof(struct input_event_compat) : sizeof(struct input_event);
  48. }
  49. #else
  50. static inline size_t input_event_size(void)
  51. {
  52. return sizeof(struct input_event);
  53. }
  54. #endif /* CONFIG_COMPAT */
  55. int input_event_from_user(const char __user *buffer,
  56. struct input_event *event);
  57. int input_event_to_user(char __user *buffer,
  58. const struct input_event *event);
  59. int input_ff_effect_from_user(const char __user *buffer, size_t size,
  60. struct ff_effect *effect);
  61. #endif /* _INPUT_COMPAT_H */