input-compat.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #ifndef _INPUT_COMPAT_H
  2. #define _INPUT_COMPAT_H
  3. /*
  4. * 32bit compatibility wrappers for the input subsystem.
  5. *
  6. * Very heavily based on evdev.c - Copyright (c) 1999-2002 Vojtech Pavlik
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License version 2 as published by
  10. * the Free Software Foundation.
  11. */
  12. #include <linux/compiler.h>
  13. #include <linux/compat.h>
  14. #include <linux/input.h>
  15. #ifdef CONFIG_COMPAT
  16. /* Note to the author of this code: did it ever occur to
  17. you why the ifdefs are needed? Think about it again. -AK */
  18. #if defined(CONFIG_X86_64) || defined(CONFIG_TILE)
  19. # define INPUT_COMPAT_TEST is_compat_task()
  20. #elif defined(CONFIG_S390)
  21. # define INPUT_COMPAT_TEST test_thread_flag(TIF_31BIT)
  22. #elif defined(CONFIG_MIPS)
  23. # define INPUT_COMPAT_TEST test_thread_flag(TIF_32BIT_ADDR)
  24. #else
  25. # define INPUT_COMPAT_TEST test_thread_flag(TIF_32BIT)
  26. #endif
  27. struct input_event_compat {
  28. struct compat_timeval time;
  29. __u16 type;
  30. __u16 code;
  31. __s32 value;
  32. };
  33. struct ff_periodic_effect_compat {
  34. __u16 waveform;
  35. __u16 period;
  36. __s16 magnitude;
  37. __s16 offset;
  38. __u16 phase;
  39. struct ff_envelope envelope;
  40. __u32 custom_len;
  41. compat_uptr_t custom_data;
  42. };
  43. struct ff_effect_compat {
  44. __u16 type;
  45. __s16 id;
  46. __u16 direction;
  47. struct ff_trigger trigger;
  48. struct ff_replay replay;
  49. union {
  50. struct ff_constant_effect constant;
  51. struct ff_ramp_effect ramp;
  52. struct ff_periodic_effect_compat periodic;
  53. struct ff_condition_effect condition[2]; /* One for each axis */
  54. struct ff_rumble_effect rumble;
  55. } u;
  56. };
  57. static inline size_t input_event_size(void)
  58. {
  59. return (INPUT_COMPAT_TEST && !COMPAT_USE_64BIT_TIME) ?
  60. sizeof(struct input_event_compat) : sizeof(struct input_event);
  61. }
  62. #else
  63. static inline size_t input_event_size(void)
  64. {
  65. return sizeof(struct input_event);
  66. }
  67. #endif /* CONFIG_COMPAT */
  68. int input_event_from_user(const char __user *buffer,
  69. struct input_event *event);
  70. int input_event_to_user(char __user *buffer,
  71. const struct input_event *event);
  72. int input_ff_effect_from_user(const char __user *buffer, size_t size,
  73. struct ff_effect *effect);
  74. #endif /* _INPUT_COMPAT_H */