diff options
author | Anssi Hannula <anssi.hannula@gmail.com> | 2006-07-19 01:40:22 -0400 |
---|---|---|
committer | Dmitry Torokhov <dtor@insightbb.com> | 2006-07-19 01:40:22 -0400 |
commit | 509ca1a9383601fdc5612d3d3ba5b981f6eb6c8b (patch) | |
tree | 4d7b63c2b108510c11a89dc0ea45efe788fed779 /include | |
parent | 806d41b756fecc1b13584e2b806b76d8934b1679 (diff) |
Input: implement new force feedback interface
Implement a new force feedback interface, in which all non-driver-specific
operations are separated to a common module. This includes handling effect
type validations, locking, etc.
The effects are now file descriptor specific instead of the previous strange
half-process half-fd specific behaviour. The effect memory of devices is not
emptied if the root user opens and closes the device while another user is
using effects. This is a minor change and most likely no force feedback
aware programs are affected by this negatively.
Otherwise the userspace interface is left unaltered.
Signed-off-by: Anssi Hannula <anssi.hannula@gmail.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/input.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/include/linux/input.h b/include/linux/input.h index b3253ab72ff7..81c6ea5afedb 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -784,6 +784,9 @@ struct ff_effect { | |||
784 | #define FF_INERTIA 0x56 | 784 | #define FF_INERTIA 0x56 |
785 | #define FF_RAMP 0x57 | 785 | #define FF_RAMP 0x57 |
786 | 786 | ||
787 | #define FF_EFFECT_MIN FF_RUMBLE | ||
788 | #define FF_EFFECT_MAX FF_RAMP | ||
789 | |||
787 | /* | 790 | /* |
788 | * Force feedback periodic effect types | 791 | * Force feedback periodic effect types |
789 | */ | 792 | */ |
@@ -795,6 +798,9 @@ struct ff_effect { | |||
795 | #define FF_SAW_DOWN 0x5c | 798 | #define FF_SAW_DOWN 0x5c |
796 | #define FF_CUSTOM 0x5d | 799 | #define FF_CUSTOM 0x5d |
797 | 800 | ||
801 | #define FF_WAVEFORM_MIN FF_SQUARE | ||
802 | #define FF_WAVEFORM_MAX FF_CUSTOM | ||
803 | |||
798 | /* | 804 | /* |
799 | * Set ff device properties | 805 | * Set ff device properties |
800 | */ | 806 | */ |
@@ -870,6 +876,8 @@ struct input_dev { | |||
870 | unsigned int keycodesize; | 876 | unsigned int keycodesize; |
871 | void *keycode; | 877 | void *keycode; |
872 | 878 | ||
879 | struct ff_device *ff; | ||
880 | |||
873 | unsigned int repeat_key; | 881 | unsigned int repeat_key; |
874 | struct timer_list timer; | 882 | struct timer_list timer; |
875 | 883 | ||
@@ -1108,5 +1116,58 @@ static inline void input_set_abs_params(struct input_dev *dev, int axis, int min | |||
1108 | 1116 | ||
1109 | extern struct class input_class; | 1117 | extern struct class input_class; |
1110 | 1118 | ||
1119 | /** | ||
1120 | * struct ff_device - force-feedback part of an input device | ||
1121 | * @upload: Called to upload an new effect into device | ||
1122 | * @erase: Called to erase an effect from device | ||
1123 | * @playback: Called to request device to start playing specified effect | ||
1124 | * @set_gain: Called to set specified gain | ||
1125 | * @set_autocenter: Called to auto-center device | ||
1126 | * @destroy: called by input core when parent input device is being | ||
1127 | * destroyed | ||
1128 | * @private: driver-specific data, will be freed automatically | ||
1129 | * @ffbit: bitmap of force feedback capabilities truly supported by | ||
1130 | * device (not emulated like ones in input_dev->ffbit) | ||
1131 | * @mutex: mutex for serializing access to the device | ||
1132 | * @max_effects: maximum number of effects supported by device | ||
1133 | * @effects: pointer to an array of effects currently loaded into device | ||
1134 | * @effect_owners: array of effect owners; when file handle owning | ||
1135 | * an effect gets closed the effcet is automatically erased | ||
1136 | * | ||
1137 | * Every force-feedback device must implement upload() and playback() | ||
1138 | * methods; erase() is optional. set_gain() and set_autocenter() need | ||
1139 | * only be implemented if driver sets up FF_GAIN and FF_AUTOCENTER | ||
1140 | * bits. | ||
1141 | */ | ||
1142 | struct ff_device { | ||
1143 | int (*upload)(struct input_dev *dev, struct ff_effect *effect, | ||
1144 | struct ff_effect *old); | ||
1145 | int (*erase)(struct input_dev *dev, int effect_id); | ||
1146 | |||
1147 | int (*playback)(struct input_dev *dev, int effect_id, int value); | ||
1148 | void (*set_gain)(struct input_dev *dev, u16 gain); | ||
1149 | void (*set_autocenter)(struct input_dev *dev, u16 magnitude); | ||
1150 | |||
1151 | void (*destroy)(struct ff_device *); | ||
1152 | |||
1153 | void *private; | ||
1154 | |||
1155 | unsigned long ffbit[NBITS(FF_MAX)]; | ||
1156 | |||
1157 | struct mutex mutex; | ||
1158 | |||
1159 | int max_effects; | ||
1160 | struct ff_effect *effects; | ||
1161 | struct file *effect_owners[]; | ||
1162 | }; | ||
1163 | |||
1164 | int input_ff_create(struct input_dev *dev, int max_effects); | ||
1165 | void input_ff_destroy(struct input_dev *dev); | ||
1166 | |||
1167 | int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value); | ||
1168 | |||
1169 | int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file); | ||
1170 | int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file); | ||
1171 | |||
1111 | #endif | 1172 | #endif |
1112 | #endif | 1173 | #endif |