input-compat.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. #ifdef CONFIG_X86_64
  19. # define INPUT_COMPAT_TEST is_compat_task()
  20. #elif defined(CONFIG_IA64)
  21. # define INPUT_COMPAT_TEST IS_IA32_PROCESS(task_pt_regs(current))
  22. #elif defined(CONFIG_S390)
  23. # define INPUT_COMPAT_TEST test_thread_flag(TIF_31BIT)
  24. #elif defined(CONFIG_MIPS)
  25. # define INPUT_COMPAT_TEST test_thread_flag(TIF_32BIT_ADDR)
  26. #else
  27. # define INPUT_COMPAT_TEST test_thread_flag(TIF_32BIT)
  28. #endif
  29. struct input_event_compat {
  30. struct compat_timeval time;
  31. __u16 type;
  32. __u16 code;
  33. __s32 value;
  34. };
  35. struct ff_periodic_effect_compat {
  36. __u16 waveform;
  37. __u16 period;
  38. __s16 magnitude;
  39. __s16 offset;
  40. __u16 phase;
  41. struct ff_envelope envelope;
  42. __u32 custom_len;
  43. compat_uptr_t custom_data;
  44. };
  45. struct ff_effect_compat {
  46. __u16 type;
  47. __s16 id;
  48. __u16 direction;
  49. struct ff_trigger trigger;
  50. struct ff_replay replay;
  51. union {
  52. struct ff_constant_effect constant;
  53. struct ff_ramp_effect ramp;
  54. struct ff_periodic_effect_compat periodic;
  55. struct ff_condition_effect condition[2]; /* One for each axis */
  56. struct ff_rumble_effect rumble;
  57. } u;
  58. };
  59. static inline size_t input_event_size(void)
  60. {
  61. return INPUT_COMPAT_TEST ?
  62. sizeof(struct input_event_compat) : sizeof(struct input_event);
  63. }
  64. #else
  65. static inline size_t input_event_size(void)
  66. {
  67. return sizeof(struct input_event);
  68. }
  69. #endif /* CONFIG_COMPAT */
  70. int input_event_from_user(const char __user *buffer,
  71. struct input_event *event);
  72. int input_event_to_user(char __user *buffer,
  73. const struct input_event *event);
  74. int input_ff_effect_from_user(const char __user *buffer, size_t size,
  75. struct ff_effect *effect);
  76. #endif /* _INPUT_COMPAT_H */