diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2007-08-30 00:22:11 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2007-08-30 00:22:11 -0400 |
commit | 8006479c9b75fb6594a7b746af3d7f1fbb68f18f (patch) | |
tree | 1c1cd28f3fec192fa3e15f3042b4f087b43806d4 /include/linux/input.h | |
parent | 501cc54c4d2b0c2bbae1a6490b0e547be46fc09f (diff) |
Input: implement proper locking in input core
Also add some kerneldoc documentation to input.h
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'include/linux/input.h')
-rw-r--r-- | include/linux/input.h | 112 |
1 files changed, 104 insertions, 8 deletions
diff --git a/include/linux/input.h b/include/linux/input.h index adfbe4fcc1b2..d09e5e8be325 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
@@ -845,7 +845,7 @@ struct ff_rumble_effect { | |||
845 | * defining effect parameters | 845 | * defining effect parameters |
846 | * | 846 | * |
847 | * This structure is sent through ioctl from the application to the driver. | 847 | * This structure is sent through ioctl from the application to the driver. |
848 | * To create a new effect aplication should set its @id to -1; the kernel | 848 | * To create a new effect application should set its @id to -1; the kernel |
849 | * will return assigned @id which can later be used to update or delete | 849 | * will return assigned @id which can later be used to update or delete |
850 | * this effect. | 850 | * this effect. |
851 | * | 851 | * |
@@ -925,9 +925,82 @@ struct ff_effect { | |||
925 | #define BIT(x) (1UL<<((x)%BITS_PER_LONG)) | 925 | #define BIT(x) (1UL<<((x)%BITS_PER_LONG)) |
926 | #define LONG(x) ((x)/BITS_PER_LONG) | 926 | #define LONG(x) ((x)/BITS_PER_LONG) |
927 | 927 | ||
928 | /** | ||
929 | * struct input_dev - represents an input device | ||
930 | * @name: name of the device | ||
931 | * @phys: physical path to the device in the system hierarchy | ||
932 | * @uniq: unique identification code for the device (if device has it) | ||
933 | * @id: id of the device (struct input_id) | ||
934 | * @evbit: bitmap of types of events supported by the device (EV_KEY, | ||
935 | * EV_REL, etc.) | ||
936 | * @keybit: bitmap of keys/buttons this device has | ||
937 | * @relbit: bitmap of relative axes for the device | ||
938 | * @absbit: bitmap of absolute axes for the device | ||
939 | * @mscbit: bitmap of miscellaneous events supported by the device | ||
940 | * @ledbit: bitmap of leds present on the device | ||
941 | * @sndbit: bitmap of sound effects supported by the device | ||
942 | * @ffbit: bitmap of force feedback effects supported by the device | ||
943 | * @swbit: bitmap of switches present on the device | ||
944 | * @keycodemax: size of keycode table | ||
945 | * @keycodesize: size of elements in keycode table | ||
946 | * @keycode: map of scancodes to keycodes for this device | ||
947 | * @setkeycode: optional method to alter current keymap, used to implement | ||
948 | * sparse keymaps. If not supplied default mechanism will be used | ||
949 | * @getkeycode: optional method to retrieve current keymap. If not supplied | ||
950 | * default mechanism will be used | ||
951 | * @ff: force feedback structure associated with the device if device | ||
952 | * supports force feedback effects | ||
953 | * @repeat_key: stores key code of the last key pressed; used to implement | ||
954 | * software autorepeat | ||
955 | * @timer: timer for software autorepeat | ||
956 | * @sync: set to 1 when there were no new events since last EV_SYNC | ||
957 | * @abs: current values for reports from absolute axes | ||
958 | * @rep: current values for autorepeat parameters (delay, rate) | ||
959 | * @key: reflects current state of device's keys/buttons | ||
960 | * @led: reflects current state of device's LEDs | ||
961 | * @snd: reflects current state of sound effects | ||
962 | * @sw: reflects current state of device's switches | ||
963 | * @absmax: maximum values for events coming from absolute axes | ||
964 | * @absmin: minimum values for events coming from absolute axes | ||
965 | * @absfuzz: describes noisiness for axes | ||
966 | * @absflat: size of the center flat position (used by joydev) | ||
967 | * @open: this method is called when the very first user calls | ||
968 | * input_open_device(). The driver must prepare the device | ||
969 | * to start generating events (start polling thread, | ||
970 | * request an IRQ, submit URB, etc.) | ||
971 | * @close: this method is called when the very last user calls | ||
972 | * input_close_device(). | ||
973 | * @flush: purges the device. Most commonly used to get rid of force | ||
974 | * feedback effects loaded into the device when disconnecting | ||
975 | * from it | ||
976 | * @event: event handler for events sent _to_ the device, like EV_LED | ||
977 | * or EV_SND. The device is expected to carry out the requested | ||
978 | * action (turn on a LED, play sound, etc.) The call is protected | ||
979 | * by @event_lock and must not sleep | ||
980 | * @grab: input handle that currently has the device grabbed (via | ||
981 | * EVIOCGRAB ioctl). When a handle grabs a device it becomes sole | ||
982 | * recipient for all input events coming from the device | ||
983 | * @event_lock: this spinlock is is taken when input core receives | ||
984 | * and processes a new event for the device (in input_event()). | ||
985 | * Code that accesses and/or modifies parameters of a device | ||
986 | * (such as keymap or absmin, absmax, absfuzz, etc.) after device | ||
987 | * has been registered with input core must take this lock. | ||
988 | * @mutex: serializes calls to open(), close() and flush() methods | ||
989 | * @users: stores number of users (input handlers) that opened this | ||
990 | * device. It is used by input_open_device() and input_close_device() | ||
991 | * to make sure that dev->open() is only called when the first | ||
992 | * user opens device and dev->close() is called when the very | ||
993 | * last user closes the device | ||
994 | * @going_away: marks devices that are in a middle of unregistering and | ||
995 | * causes input_open_device*() fail with -ENODEV. | ||
996 | * @dev: driver model's view of this device | ||
997 | * @h_list: list of input handles associated with the device. When | ||
998 | * accessing the list dev->mutex must be held | ||
999 | * @node: used to place the device onto input_dev_list | ||
1000 | */ | ||
928 | struct input_dev { | 1001 | struct input_dev { |
929 | 1002 | ||
930 | void *private; | 1003 | void *private; /* do not use */ |
931 | 1004 | ||
932 | const char *name; | 1005 | const char *name; |
933 | const char *phys; | 1006 | const char *phys; |
@@ -955,8 +1028,6 @@ struct input_dev { | |||
955 | unsigned int repeat_key; | 1028 | unsigned int repeat_key; |
956 | struct timer_list timer; | 1029 | struct timer_list timer; |
957 | 1030 | ||
958 | int state; | ||
959 | |||
960 | int sync; | 1031 | int sync; |
961 | 1032 | ||
962 | int abs[ABS_MAX + 1]; | 1033 | int abs[ABS_MAX + 1]; |
@@ -979,8 +1050,11 @@ struct input_dev { | |||
979 | 1050 | ||
980 | struct input_handle *grab; | 1051 | struct input_handle *grab; |
981 | 1052 | ||
982 | struct mutex mutex; /* serializes open and close operations */ | 1053 | spinlock_t event_lock; |
1054 | struct mutex mutex; | ||
1055 | |||
983 | unsigned int users; | 1056 | unsigned int users; |
1057 | int going_away; | ||
984 | 1058 | ||
985 | struct device dev; | 1059 | struct device dev; |
986 | union { /* temporarily so while we switching to struct device */ | 1060 | union { /* temporarily so while we switching to struct device */ |
@@ -1046,7 +1120,9 @@ struct input_handle; | |||
1046 | /** | 1120 | /** |
1047 | * struct input_handler - implements one of interfaces for input devices | 1121 | * struct input_handler - implements one of interfaces for input devices |
1048 | * @private: driver-specific data | 1122 | * @private: driver-specific data |
1049 | * @event: event handler | 1123 | * @event: event handler. This method is being called by input core with |
1124 | * interrupts disabled and dev->event_lock spinlock held and so | ||
1125 | * it may not sleep | ||
1050 | * @connect: called when attaching a handler to an input device | 1126 | * @connect: called when attaching a handler to an input device |
1051 | * @disconnect: disconnects a handler from input device | 1127 | * @disconnect: disconnects a handler from input device |
1052 | * @start: starts handler for given handle. This function is called by | 1128 | * @start: starts handler for given handle. This function is called by |
@@ -1058,10 +1134,18 @@ struct input_handle; | |||
1058 | * @name: name of the handler, to be shown in /proc/bus/input/handlers | 1134 | * @name: name of the handler, to be shown in /proc/bus/input/handlers |
1059 | * @id_table: pointer to a table of input_device_ids this driver can | 1135 | * @id_table: pointer to a table of input_device_ids this driver can |
1060 | * handle | 1136 | * handle |
1061 | * @blacklist: prointer to a table of input_device_ids this driver should | 1137 | * @blacklist: pointer to a table of input_device_ids this driver should |
1062 | * ignore even if they match @id_table | 1138 | * ignore even if they match @id_table |
1063 | * @h_list: list of input handles associated with the handler | 1139 | * @h_list: list of input handles associated with the handler |
1064 | * @node: for placing the driver onto input_handler_list | 1140 | * @node: for placing the driver onto input_handler_list |
1141 | * | ||
1142 | * Input handlers attach to input devices and create input handles. There | ||
1143 | * are likely several handlers attached to any given input device at the | ||
1144 | * same time. All of them will get their copy of input event generated by | ||
1145 | * the device. | ||
1146 | * | ||
1147 | * Note that input core serializes calls to connect() and disconnect() | ||
1148 | * methods. | ||
1065 | */ | 1149 | */ |
1066 | struct input_handler { | 1150 | struct input_handler { |
1067 | 1151 | ||
@@ -1083,6 +1167,18 @@ struct input_handler { | |||
1083 | struct list_head node; | 1167 | struct list_head node; |
1084 | }; | 1168 | }; |
1085 | 1169 | ||
1170 | /** | ||
1171 | * struct input_handle - links input device with an input handler | ||
1172 | * @private: handler-specific data | ||
1173 | * @open: counter showing whether the handle is 'open', i.e. should deliver | ||
1174 | * events from its device | ||
1175 | * @name: name given to the handle by handler that created it | ||
1176 | * @dev: input device the handle is attached to | ||
1177 | * @handler: handler that works with the device through this handle | ||
1178 | * @d_node: used to put the handle on device's list of attached handles | ||
1179 | * @h_node: used to put the handle on handler's list of handles from which | ||
1180 | * it gets events | ||
1181 | */ | ||
1086 | struct input_handle { | 1182 | struct input_handle { |
1087 | 1183 | ||
1088 | void *private; | 1184 | void *private; |
@@ -1205,7 +1301,7 @@ extern struct class input_class; | |||
1205 | * @max_effects: maximum number of effects supported by device | 1301 | * @max_effects: maximum number of effects supported by device |
1206 | * @effects: pointer to an array of effects currently loaded into device | 1302 | * @effects: pointer to an array of effects currently loaded into device |
1207 | * @effect_owners: array of effect owners; when file handle owning | 1303 | * @effect_owners: array of effect owners; when file handle owning |
1208 | * an effect gets closed the effcet is automatically erased | 1304 | * an effect gets closed the effect is automatically erased |
1209 | * | 1305 | * |
1210 | * Every force-feedback device must implement upload() and playback() | 1306 | * Every force-feedback device must implement upload() and playback() |
1211 | * methods; erase() is optional. set_gain() and set_autocenter() need | 1307 | * methods; erase() is optional. set_gain() and set_autocenter() need |