aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 11:20:33 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-02 11:20:33 -0400
commita12f66fccf2e266ad197df142b5ebafc6a169a8c (patch)
tree9d0bc76f8aa9c42fb44ce5f5bf6b4b09f4efafed /include/linux
parent12dce6263d43daeb4e16fa4eb964c1c99fa4fa2e (diff)
parentbb0885900de49b5822d7e8c91c1adf9a0fcc228b (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (35 commits) Input: wistron - add support for Acer TravelMate 2424NWXCi Input: wistron - fix setting up special buttons Input: add KEY_BLUETOOTH and KEY_WLAN definitions Input: add new BUS_VIRTUAL bus type Input: add driver for stowaway serial keyboards Input: make input_register_handler() return error codes Input: remove cruft that was needed for transition to sysfs Input: fix input module refcounting Input: constify input core Input: libps2 - rearrange exports Input: atkbd - support Microsoft Natural Elite Pro keyboards Input: i8042 - disable MUX mode on Toshiba Equium A110 Input: i8042 - get rid of polling timer Input: send key up events at disconnect Input: constify psmouse driver Input: i8042 - add Amoi to the MUX blacklist Input: logips2pp - add sugnature 56 (Cordless MouseMan Wheel), cleanup Input: add driver for Touchwin serial touchscreens Input: add driver for Touchright serial touchscreens Input: add driver for Penmount serial touchscreens ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/input.h272
-rw-r--r--include/linux/libps2.h1
-rw-r--r--include/linux/serio.h3
-rw-r--r--include/linux/uinput.h35
4 files changed, 223 insertions, 88 deletions
diff --git a/include/linux/input.h b/include/linux/input.h
index b3253ab72ff7..5770105471dd 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -349,6 +349,9 @@ struct input_absinfo {
349 349
350#define KEY_BATTERY 236 350#define KEY_BATTERY 236
351 351
352#define KEY_BLUETOOTH 237
353#define KEY_WLAN 238
354
352#define KEY_UNKNOWN 240 355#define KEY_UNKNOWN 240
353 356
354#define BTN_MISC 0x100 357#define BTN_MISC 0x100
@@ -645,6 +648,7 @@ struct input_absinfo {
645#define BUS_USB 0x03 648#define BUS_USB 0x03
646#define BUS_HIL 0x04 649#define BUS_HIL 0x04
647#define BUS_BLUETOOTH 0x05 650#define BUS_BLUETOOTH 0x05
651#define BUS_VIRTUAL 0x06
648 652
649#define BUS_ISA 0x10 653#define BUS_ISA 0x10
650#define BUS_I8042 0x11 654#define BUS_I8042 0x11
@@ -667,98 +671,167 @@ struct input_absinfo {
667 671
668/* 672/*
669 * Structures used in ioctls to upload effects to a device 673 * Structures used in ioctls to upload effects to a device
670 * The first structures are not passed directly by using ioctls. 674 * They are pieces of a bigger structure (called ff_effect)
671 * They are sub-structures of the actually sent structure (called ff_effect) 675 */
676
677/*
678 * All duration values are expressed in ms. Values above 32767 ms (0x7fff)
679 * should not be used and have unspecified results.
672 */ 680 */
673 681
682/**
683 * struct ff_replay - defines scheduling of the effect
684 * @length: duration of the effect
685 * @delay: delay before effect should start playing
686 */
674struct ff_replay { 687struct ff_replay {
675 __u16 length; /* Duration of an effect in ms. All other times are also expressed in ms */ 688 __u16 length;
676 __u16 delay; /* Time to wait before to start playing an effect */ 689 __u16 delay;
677}; 690};
678 691
692/**
693 * struct ff_trigger - defines what triggers the effect
694 * @button: number of the button triggering the effect
695 * @interval: controls how soon the effect can be re-triggered
696 */
679struct ff_trigger { 697struct ff_trigger {
680 __u16 button; /* Number of button triggering an effect */ 698 __u16 button;
681 __u16 interval; /* Time to wait before an effect can be re-triggered (ms) */ 699 __u16 interval;
682}; 700};
683 701
702/**
703 * struct ff_envelope - generic effect envelope
704 * @attack_length: duration of the attack (ms)
705 * @attack_level: level at the beginning of the attack
706 * @fade_length: duration of fade (ms)
707 * @fade_level: level at the end of fade
708 *
709 * The @attack_level and @fade_level are absolute values; when applying
710 * envelope force-feedback core will convert to positive/negative
711 * value based on polarity of the default level of the effect.
712 * Valid range for the attack and fade levels is 0x0000 - 0x7fff
713 */
684struct ff_envelope { 714struct ff_envelope {
685 __u16 attack_length; /* Duration of attack (ms) */ 715 __u16 attack_length;
686 __u16 attack_level; /* Level at beginning of attack */ 716 __u16 attack_level;
687 __u16 fade_length; /* Duration of fade (ms) */ 717 __u16 fade_length;
688 __u16 fade_level; /* Level at end of fade */ 718 __u16 fade_level;
689}; 719};
690 720
691/* FF_CONSTANT */ 721/**
722 * struct ff_constant_effect - defines parameters of a constant effect
723 * @level: strength of the effect; may be negative
724 * @envelope: envelope data
725 */
692struct ff_constant_effect { 726struct ff_constant_effect {
693 __s16 level; /* Strength of effect. Negative values are OK */ 727 __s16 level;
694 struct ff_envelope envelope; 728 struct ff_envelope envelope;
695}; 729};
696 730
697/* FF_RAMP */ 731/**
732 * struct ff_ramp_effect - defines parameters of a ramp effect
733 * @start_level: beginning strength of the effect; may be negative
734 * @end_level: final strength of the effect; may be negative
735 * @envelope: envelope data
736 */
698struct ff_ramp_effect { 737struct ff_ramp_effect {
699 __s16 start_level; 738 __s16 start_level;
700 __s16 end_level; 739 __s16 end_level;
701 struct ff_envelope envelope; 740 struct ff_envelope envelope;
702}; 741};
703 742
704/* FF_SPRING of FF_FRICTION */ 743/**
744 * struct ff_condition_effect - defines a spring or friction effect
745 * @right_saturation: maximum level when joystick moved all way to the right
746 * @left_saturation: same for the left side
747 * @right_coeff: controls how fast the force grows when the joystick moves
748 * to the right
749 * @left_coeff: same for the left side
750 * @deadband: size of the dead zone, where no force is produced
751 * @center: position of the dead zone
752 */
705struct ff_condition_effect { 753struct ff_condition_effect {
706 __u16 right_saturation; /* Max level when joystick is on the right */ 754 __u16 right_saturation;
707 __u16 left_saturation; /* Max level when joystick in on the left */ 755 __u16 left_saturation;
708
709 __s16 right_coeff; /* Indicates how fast the force grows when the
710 joystick moves to the right */
711 __s16 left_coeff; /* Same for left side */
712 756
713 __u16 deadband; /* Size of area where no force is produced */ 757 __s16 right_coeff;
714 __s16 center; /* Position of dead zone */ 758 __s16 left_coeff;
715 759
760 __u16 deadband;
761 __s16 center;
716}; 762};
717 763
718/* FF_PERIODIC */ 764/**
765 * struct ff_periodic_effect - defines parameters of a periodic effect
766 * @waveform: kind of the effect (wave)
767 * @period: period of the wave (ms)
768 * @magnitude: peak value
769 * @offset: mean value of the wave (roughly)
770 * @phase: 'horizontal' shift
771 * @envelope: envelope data
772 * @custom_len: number of samples (FF_CUSTOM only)
773 * @custom_data: buffer of samples (FF_CUSTOM only)
774 *
775 * Known waveforms - FF_SQUARE, FF_TRIANGLE, FF_SINE, FF_SAW_UP,
776 * FF_SAW_DOWN, FF_CUSTOM. The exact syntax FF_CUSTOM is undefined
777 * for the time being as no driver supports it yet.
778 *
779 * Note: the data pointed by custom_data is copied by the driver.
780 * You can therefore dispose of the memory after the upload/update.
781 */
719struct ff_periodic_effect { 782struct ff_periodic_effect {
720 __u16 waveform; /* Kind of wave (sine, square...) */ 783 __u16 waveform;
721 __u16 period; /* in ms */ 784 __u16 period;
722 __s16 magnitude; /* Peak value */ 785 __s16 magnitude;
723 __s16 offset; /* Mean value of wave (roughly) */ 786 __s16 offset;
724 __u16 phase; /* 'Horizontal' shift */ 787 __u16 phase;
725 788
726 struct ff_envelope envelope; 789 struct ff_envelope envelope;
727 790
728/* Only used if waveform == FF_CUSTOM */ 791 __u32 custom_len;
729 __u32 custom_len; /* Number of samples */ 792 __s16 *custom_data;
730 __s16 *custom_data; /* Buffer of samples */
731/* Note: the data pointed by custom_data is copied by the driver. You can
732 * therefore dispose of the memory after the upload/update */
733}; 793};
734 794
735/* FF_RUMBLE */ 795/**
736/* Some rumble pads have two motors of different weight. 796 * struct ff_rumble_effect - defines parameters of a periodic effect
737 strong_magnitude represents the magnitude of the vibration generated 797 * @strong_magnitude: magnitude of the heavy motor
738 by the heavy motor. 798 * @weak_magnitude: magnitude of the light one
739*/ 799 *
800 * Some rumble pads have two motors of different weight. Strong_magnitude
801 * represents the magnitude of the vibration generated by the heavy one.
802 */
740struct ff_rumble_effect { 803struct ff_rumble_effect {
741 __u16 strong_magnitude; /* Magnitude of the heavy motor */ 804 __u16 strong_magnitude;
742 __u16 weak_magnitude; /* Magnitude of the light one */ 805 __u16 weak_magnitude;
743}; 806};
744 807
745/* 808/**
746 * Structure sent through ioctl from the application to the driver 809 * struct ff_effect - defines force feedback effect
810 * @type: type of the effect (FF_CONSTANT, FF_PERIODIC, FF_RAMP, FF_SPRING,
811 * FF_FRICTION, FF_DAMPER, FF_RUMBLE, FF_INERTIA, or FF_CUSTOM)
812 * @id: an unique id assigned to an effect
813 * @direction: direction of the effect
814 * @trigger: trigger conditions (struct ff_trigger)
815 * @replay: scheduling of the effect (struct ff_replay)
816 * @u: effect-specific structure (one of ff_constant_effect, ff_ramp_effect,
817 * ff_periodic_effect, ff_condition_effect, ff_rumble_effect) further
818 * defining effect parameters
819 *
820 * This structure is sent through ioctl from the application to the driver.
821 * To create a new effect aplication should set its @id to -1; the kernel
822 * will return assigned @id which can later be used to update or delete
823 * this effect.
824 *
825 * Direction of the effect is encoded as follows:
826 * 0 deg -> 0x0000 (down)
827 * 90 deg -> 0x4000 (left)
828 * 180 deg -> 0x8000 (up)
829 * 270 deg -> 0xC000 (right)
747 */ 830 */
748struct ff_effect { 831struct ff_effect {
749 __u16 type; 832 __u16 type;
750/* Following field denotes the unique id assigned to an effect.
751 * If user sets if to -1, a new effect is created, and its id is returned in the same field
752 * Else, the user sets it to the effect id it wants to update.
753 */
754 __s16 id; 833 __s16 id;
755 834 __u16 direction;
756 __u16 direction; /* Direction. 0 deg -> 0x0000 (down)
757 90 deg -> 0x4000 (left)
758 180 deg -> 0x8000 (up)
759 270 deg -> 0xC000 (right)
760 */
761
762 struct ff_trigger trigger; 835 struct ff_trigger trigger;
763 struct ff_replay replay; 836 struct ff_replay replay;
764 837
@@ -784,6 +857,9 @@ struct ff_effect {
784#define FF_INERTIA 0x56 857#define FF_INERTIA 0x56
785#define FF_RAMP 0x57 858#define FF_RAMP 0x57
786 859
860#define FF_EFFECT_MIN FF_RUMBLE
861#define FF_EFFECT_MAX FF_RAMP
862
787/* 863/*
788 * Force feedback periodic effect types 864 * Force feedback periodic effect types
789 */ 865 */
@@ -795,6 +871,9 @@ struct ff_effect {
795#define FF_SAW_DOWN 0x5c 871#define FF_SAW_DOWN 0x5c
796#define FF_CUSTOM 0x5d 872#define FF_CUSTOM 0x5d
797 873
874#define FF_WAVEFORM_MIN FF_SQUARE
875#define FF_WAVEFORM_MAX FF_CUSTOM
876
798/* 877/*
799 * Set ff device properties 878 * Set ff device properties
800 */ 879 */
@@ -864,12 +943,13 @@ struct input_dev {
864 unsigned long sndbit[NBITS(SND_MAX)]; 943 unsigned long sndbit[NBITS(SND_MAX)];
865 unsigned long ffbit[NBITS(FF_MAX)]; 944 unsigned long ffbit[NBITS(FF_MAX)];
866 unsigned long swbit[NBITS(SW_MAX)]; 945 unsigned long swbit[NBITS(SW_MAX)];
867 int ff_effects_max;
868 946
869 unsigned int keycodemax; 947 unsigned int keycodemax;
870 unsigned int keycodesize; 948 unsigned int keycodesize;
871 void *keycode; 949 void *keycode;
872 950
951 struct ff_device *ff;
952
873 unsigned int repeat_key; 953 unsigned int repeat_key;
874 struct timer_list timer; 954 struct timer_list timer;
875 955
@@ -895,8 +975,6 @@ struct input_dev {
895 void (*close)(struct input_dev *dev); 975 void (*close)(struct input_dev *dev);
896 int (*flush)(struct input_dev *dev, struct file *file); 976 int (*flush)(struct input_dev *dev, struct file *file);
897 int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value); 977 int (*event)(struct input_dev *dev, unsigned int type, unsigned int code, int value);
898 int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect);
899 int (*erase_effect)(struct input_dev *dev, int effect_id);
900 978
901 struct input_handle *grab; 979 struct input_handle *grab;
902 980
@@ -904,9 +982,6 @@ struct input_dev {
904 unsigned int users; 982 unsigned int users;
905 983
906 struct class_device cdev; 984 struct class_device cdev;
907 struct device *dev; /* will be removed soon */
908
909 int dynalloc; /* temporarily */
910 985
911 struct list_head h_list; 986 struct list_head h_list;
912 struct list_head node; 987 struct list_head node;
@@ -985,16 +1060,16 @@ struct input_handler {
985 void *private; 1060 void *private;
986 1061
987 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value); 1062 void (*event)(struct input_handle *handle, unsigned int type, unsigned int code, int value);
988 struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, struct input_device_id *id); 1063 struct input_handle* (*connect)(struct input_handler *handler, struct input_dev *dev, const struct input_device_id *id);
989 void (*disconnect)(struct input_handle *handle); 1064 void (*disconnect)(struct input_handle *handle);
990 void (*start)(struct input_handle *handle); 1065 void (*start)(struct input_handle *handle);
991 1066
992 const struct file_operations *fops; 1067 const struct file_operations *fops;
993 int minor; 1068 int minor;
994 char *name; 1069 const char *name;
995 1070
996 struct input_device_id *id_table; 1071 const struct input_device_id *id_table;
997 struct input_device_id *blacklist; 1072 const struct input_device_id *blacklist;
998 1073
999 struct list_head h_list; 1074 struct list_head h_list;
1000 struct list_head node; 1075 struct list_head node;
@@ -1005,7 +1080,7 @@ struct input_handle {
1005 void *private; 1080 void *private;
1006 1081
1007 int open; 1082 int open;
1008 char *name; 1083 const char *name;
1009 1084
1010 struct input_dev *dev; 1085 struct input_dev *dev;
1011 struct input_handler *handler; 1086 struct input_handler *handler;
@@ -1019,12 +1094,6 @@ struct input_handle {
1019#define to_handle(n) container_of(n,struct input_handle,d_node) 1094#define to_handle(n) container_of(n,struct input_handle,d_node)
1020#define to_handle_h(n) container_of(n,struct input_handle,h_node) 1095#define to_handle_h(n) container_of(n,struct input_handle,h_node)
1021 1096
1022static inline void init_input_dev(struct input_dev *dev)
1023{
1024 INIT_LIST_HEAD(&dev->h_list);
1025 INIT_LIST_HEAD(&dev->node);
1026}
1027
1028struct input_dev *input_allocate_device(void); 1097struct input_dev *input_allocate_device(void);
1029void input_free_device(struct input_dev *dev); 1098void input_free_device(struct input_dev *dev);
1030 1099
@@ -1041,7 +1110,7 @@ static inline void input_put_device(struct input_dev *dev)
1041int input_register_device(struct input_dev *); 1110int input_register_device(struct input_dev *);
1042void input_unregister_device(struct input_dev *); 1111void input_unregister_device(struct input_dev *);
1043 1112
1044void input_register_handler(struct input_handler *); 1113int input_register_handler(struct input_handler *);
1045void input_unregister_handler(struct input_handler *); 1114void input_unregister_handler(struct input_handler *);
1046 1115
1047int input_grab_device(struct input_handle *); 1116int input_grab_device(struct input_handle *);
@@ -1070,11 +1139,6 @@ static inline void input_report_abs(struct input_dev *dev, unsigned int code, in
1070 input_event(dev, EV_ABS, code, value); 1139 input_event(dev, EV_ABS, code, value);
1071} 1140}
1072 1141
1073static inline void input_report_ff(struct input_dev *dev, unsigned int code, int value)
1074{
1075 input_event(dev, EV_FF, code, value);
1076}
1077
1078static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value) 1142static inline void input_report_ff_status(struct input_dev *dev, unsigned int code, int value)
1079{ 1143{
1080 input_event(dev, EV_FF_STATUS, code, value); 1144 input_event(dev, EV_FF_STATUS, code, value);
@@ -1108,5 +1172,61 @@ static inline void input_set_abs_params(struct input_dev *dev, int axis, int min
1108 1172
1109extern struct class input_class; 1173extern struct class input_class;
1110 1174
1175/**
1176 * struct ff_device - force-feedback part of an input device
1177 * @upload: Called to upload an new effect into device
1178 * @erase: Called to erase an effect from device
1179 * @playback: Called to request device to start playing specified effect
1180 * @set_gain: Called to set specified gain
1181 * @set_autocenter: Called to auto-center device
1182 * @destroy: called by input core when parent input device is being
1183 * destroyed
1184 * @private: driver-specific data, will be freed automatically
1185 * @ffbit: bitmap of force feedback capabilities truly supported by
1186 * device (not emulated like ones in input_dev->ffbit)
1187 * @mutex: mutex for serializing access to the device
1188 * @max_effects: maximum number of effects supported by device
1189 * @effects: pointer to an array of effects currently loaded into device
1190 * @effect_owners: array of effect owners; when file handle owning
1191 * an effect gets closed the effcet is automatically erased
1192 *
1193 * Every force-feedback device must implement upload() and playback()
1194 * methods; erase() is optional. set_gain() and set_autocenter() need
1195 * only be implemented if driver sets up FF_GAIN and FF_AUTOCENTER
1196 * bits.
1197 */
1198struct ff_device {
1199 int (*upload)(struct input_dev *dev, struct ff_effect *effect,
1200 struct ff_effect *old);
1201 int (*erase)(struct input_dev *dev, int effect_id);
1202
1203 int (*playback)(struct input_dev *dev, int effect_id, int value);
1204 void (*set_gain)(struct input_dev *dev, u16 gain);
1205 void (*set_autocenter)(struct input_dev *dev, u16 magnitude);
1206
1207 void (*destroy)(struct ff_device *);
1208
1209 void *private;
1210
1211 unsigned long ffbit[NBITS(FF_MAX)];
1212
1213 struct mutex mutex;
1214
1215 int max_effects;
1216 struct ff_effect *effects;
1217 struct file *effect_owners[];
1218};
1219
1220int input_ff_create(struct input_dev *dev, int max_effects);
1221void input_ff_destroy(struct input_dev *dev);
1222
1223int input_ff_event(struct input_dev *dev, unsigned int type, unsigned int code, int value);
1224
1225int input_ff_upload(struct input_dev *dev, struct ff_effect *effect, struct file *file);
1226int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file);
1227
1228int input_ff_create_memless(struct input_dev *dev, void *data,
1229 int (*play_effect)(struct input_dev *, void *, struct ff_effect *));
1230
1111#endif 1231#endif
1112#endif 1232#endif
diff --git a/include/linux/libps2.h b/include/linux/libps2.h
index 08a450a9dbf7..f6f301e2b0f5 100644
--- a/include/linux/libps2.h
+++ b/include/linux/libps2.h
@@ -47,5 +47,6 @@ int ps2_schedule_command(struct ps2dev *ps2dev, unsigned char *param, int comman
47int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data); 47int ps2_handle_ack(struct ps2dev *ps2dev, unsigned char data);
48int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data); 48int ps2_handle_response(struct ps2dev *ps2dev, unsigned char data);
49void ps2_cmd_aborted(struct ps2dev *ps2dev); 49void ps2_cmd_aborted(struct ps2dev *ps2dev);
50int ps2_is_keyboard_id(char id);
50 51
51#endif /* _LIBPS2_H */ 52#endif /* _LIBPS2_H */
diff --git a/include/linux/serio.h b/include/linux/serio.h
index 6348e8330897..c9069310b6ac 100644
--- a/include/linux/serio.h
+++ b/include/linux/serio.h
@@ -217,5 +217,8 @@ static inline void serio_unpin_driver(struct serio *serio)
217#define SERIO_LKKBD 0x28 217#define SERIO_LKKBD 0x28
218#define SERIO_ELO 0x29 218#define SERIO_ELO 0x29
219#define SERIO_MICROTOUCH 0x30 219#define SERIO_MICROTOUCH 0x30
220#define SERIO_PENMOUNT 0x31
221#define SERIO_TOUCHRIGHT 0x32
222#define SERIO_TOUCHWIN 0x33
220 223
221#endif 224#endif
diff --git a/include/linux/uinput.h b/include/linux/uinput.h
index 7168302f9844..1fd61eeed664 100644
--- a/include/linux/uinput.h
+++ b/include/linux/uinput.h
@@ -22,12 +22,18 @@
22 * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org> 22 * Author: Aristeu Sergio Rozanski Filho <aris@cathedrallabs.org>
23 * 23 *
24 * Changes/Revisions: 24 * Changes/Revisions:
25 * 0.3 24/05/2006 (Anssi Hannula <anssi.hannulagmail.com>)
26 * - update ff support for the changes in kernel interface
27 * - add UINPUT_VERSION
25 * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>) 28 * 0.2 16/10/2004 (Micah Dowty <micah@navi.cx>)
26 * - added force feedback support 29 * - added force feedback support
27 * - added UI_SET_PHYS 30 * - added UI_SET_PHYS
28 * 0.1 20/06/2002 31 * 0.1 20/06/2002
29 * - first public version 32 * - first public version
30 */ 33 */
34
35#define UINPUT_VERSION 3
36
31#ifdef __KERNEL__ 37#ifdef __KERNEL__
32#define UINPUT_MINOR 223 38#define UINPUT_MINOR 223
33#define UINPUT_NAME "uinput" 39#define UINPUT_NAME "uinput"
@@ -45,7 +51,10 @@ struct uinput_request {
45 51
46 union { 52 union {
47 int effect_id; 53 int effect_id;
48 struct ff_effect* effect; 54 struct {
55 struct ff_effect *effect;
56 struct ff_effect *old;
57 } upload;
49 } u; 58 } u;
50}; 59};
51 60
@@ -58,6 +67,7 @@ struct uinput_device {
58 unsigned char head; 67 unsigned char head;
59 unsigned char tail; 68 unsigned char tail;
60 struct input_event buff[UINPUT_BUFFER_SIZE]; 69 struct input_event buff[UINPUT_BUFFER_SIZE];
70 int ff_effects_max;
61 71
62 struct uinput_request *requests[UINPUT_NUM_REQUESTS]; 72 struct uinput_request *requests[UINPUT_NUM_REQUESTS];
63 wait_queue_head_t requests_waitq; 73 wait_queue_head_t requests_waitq;
@@ -69,6 +79,7 @@ struct uinput_ff_upload {
69 int request_id; 79 int request_id;
70 int retval; 80 int retval;
71 struct ff_effect effect; 81 struct ff_effect effect;
82 struct ff_effect old;
72}; 83};
73 84
74struct uinput_ff_erase { 85struct uinput_ff_erase {
@@ -98,33 +109,33 @@ struct uinput_ff_erase {
98#define UI_BEGIN_FF_ERASE _IOWR(UINPUT_IOCTL_BASE, 202, struct uinput_ff_erase) 109#define UI_BEGIN_FF_ERASE _IOWR(UINPUT_IOCTL_BASE, 202, struct uinput_ff_erase)
99#define UI_END_FF_ERASE _IOW(UINPUT_IOCTL_BASE, 203, struct uinput_ff_erase) 110#define UI_END_FF_ERASE _IOW(UINPUT_IOCTL_BASE, 203, struct uinput_ff_erase)
100 111
101/* To write a force-feedback-capable driver, the upload_effect 112/*
113 * To write a force-feedback-capable driver, the upload_effect
102 * and erase_effect callbacks in input_dev must be implemented. 114 * and erase_effect callbacks in input_dev must be implemented.
103 * The uinput driver will generate a fake input event when one of 115 * The uinput driver will generate a fake input event when one of
104 * these callbacks are invoked. The userspace code then uses 116 * these callbacks are invoked. The userspace code then uses
105 * ioctls to retrieve additional parameters and send the return code. 117 * ioctls to retrieve additional parameters and send the return code.
106 * The callback blocks until this return code is sent. 118 * The callback blocks until this return code is sent.
107 * 119 *
108 * The described callback mechanism is only used if EV_FF is set. 120 * The described callback mechanism is only used if ff_effects_max
109 * Otherwise, default implementations of upload_effect and erase_effect 121 * is set.
110 * are used.
111 * 122 *
112 * To implement upload_effect(): 123 * To implement upload_effect():
113 * 1. Wait for an event with type==EV_UINPUT and code==UI_FF_UPLOAD. 124 * 1. Wait for an event with type == EV_UINPUT and code == UI_FF_UPLOAD.
114 * A request ID will be given in 'value'. 125 * A request ID will be given in 'value'.
115 * 2. Allocate a uinput_ff_upload struct, fill in request_id with 126 * 2. Allocate a uinput_ff_upload struct, fill in request_id with
116 * the 'value' from the EV_UINPUT event. 127 * the 'value' from the EV_UINPUT event.
117 * 3. Issue a UI_BEGIN_FF_UPLOAD ioctl, giving it the 128 * 3. Issue a UI_BEGIN_FF_UPLOAD ioctl, giving it the
118 * uinput_ff_upload struct. It will be filled in with the 129 * uinput_ff_upload struct. It will be filled in with the
119 * ff_effect passed to upload_effect(). 130 * ff_effects passed to upload_effect().
120 * 4. Perform the effect upload, and place the modified ff_effect 131 * 4. Perform the effect upload, and place a return code back into
121 * and a return code back into the uinput_ff_upload struct. 132 the uinput_ff_upload struct.
122 * 5. Issue a UI_END_FF_UPLOAD ioctl, also giving it the 133 * 5. Issue a UI_END_FF_UPLOAD ioctl, also giving it the
123 * uinput_ff_upload_effect struct. This will complete execution 134 * uinput_ff_upload_effect struct. This will complete execution
124 * of our upload_effect() handler. 135 * of our upload_effect() handler.
125 * 136 *
126 * To implement erase_effect(): 137 * To implement erase_effect():
127 * 1. Wait for an event with type==EV_UINPUT and code==UI_FF_ERASE. 138 * 1. Wait for an event with type == EV_UINPUT and code == UI_FF_ERASE.
128 * A request ID will be given in 'value'. 139 * A request ID will be given in 'value'.
129 * 2. Allocate a uinput_ff_erase struct, fill in request_id with 140 * 2. Allocate a uinput_ff_erase struct, fill in request_id with
130 * the 'value' from the EV_UINPUT event. 141 * the 'value' from the EV_UINPUT event.
@@ -133,13 +144,13 @@ struct uinput_ff_erase {
133 * effect ID passed to erase_effect(). 144 * effect ID passed to erase_effect().
134 * 4. Perform the effect erasure, and place a return code back 145 * 4. Perform the effect erasure, and place a return code back
135 * into the uinput_ff_erase struct. 146 * into the uinput_ff_erase struct.
136 * and a return code back into the uinput_ff_erase struct.
137 * 5. Issue a UI_END_FF_ERASE ioctl, also giving it the 147 * 5. Issue a UI_END_FF_ERASE ioctl, also giving it the
138 * uinput_ff_erase_effect struct. This will complete execution 148 * uinput_ff_erase_effect struct. This will complete execution
139 * of our erase_effect() handler. 149 * of our erase_effect() handler.
140 */ 150 */
141 151
142/* This is the new event type, used only by uinput. 152/*
153 * This is the new event type, used only by uinput.
143 * 'code' is UI_FF_UPLOAD or UI_FF_ERASE, and 'value' 154 * 'code' is UI_FF_UPLOAD or UI_FF_ERASE, and 'value'
144 * is the unique request ID. This number was picked 155 * is the unique request ID. This number was picked
145 * arbitrarily, above EV_MAX (since the input system 156 * arbitrarily, above EV_MAX (since the input system