aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/input.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/input.h')
-rw-r--r--include/linux/input.h118
1 files changed, 108 insertions, 10 deletions
diff --git a/include/linux/input.h b/include/linux/input.h
index 6eb3aead7f1d..f30da6fc08e3 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -523,6 +523,8 @@ struct input_absinfo {
523#define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */ 523#define KEY_ADDRESSBOOK 0x1ad /* AL Contacts/Address Book */
524#define KEY_MESSENGER 0x1ae /* AL Instant Messaging */ 524#define KEY_MESSENGER 0x1ae /* AL Instant Messaging */
525#define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */ 525#define KEY_DISPLAYTOGGLE 0x1af /* Turn display (LCD) on and off */
526#define KEY_SPELLCHECK 0x1b0 /* AL Spell Check */
527#define KEY_LOGOFF 0x1b1 /* AL Logoff */
526 528
527#define KEY_DEL_EOL 0x1c0 529#define KEY_DEL_EOL 0x1c0
528#define KEY_DEL_EOS 0x1c1 530#define KEY_DEL_EOS 0x1c1
@@ -854,7 +856,7 @@ struct ff_rumble_effect {
854 * defining effect parameters 856 * defining effect parameters
855 * 857 *
856 * This structure is sent through ioctl from the application to the driver. 858 * This structure is sent through ioctl from the application to the driver.
857 * To create a new effect aplication should set its @id to -1; the kernel 859 * To create a new effect application should set its @id to -1; the kernel
858 * will return assigned @id which can later be used to update or delete 860 * will return assigned @id which can later be used to update or delete
859 * this effect. 861 * this effect.
860 * 862 *
@@ -934,9 +936,82 @@ struct ff_effect {
934#define BIT(x) (1UL<<((x)%BITS_PER_LONG)) 936#define BIT(x) (1UL<<((x)%BITS_PER_LONG))
935#define LONG(x) ((x)/BITS_PER_LONG) 937#define LONG(x) ((x)/BITS_PER_LONG)
936 938
939/**
940 * struct input_dev - represents an input device
941 * @name: name of the device
942 * @phys: physical path to the device in the system hierarchy
943 * @uniq: unique identification code for the device (if device has it)
944 * @id: id of the device (struct input_id)
945 * @evbit: bitmap of types of events supported by the device (EV_KEY,
946 * EV_REL, etc.)
947 * @keybit: bitmap of keys/buttons this device has
948 * @relbit: bitmap of relative axes for the device
949 * @absbit: bitmap of absolute axes for the device
950 * @mscbit: bitmap of miscellaneous events supported by the device
951 * @ledbit: bitmap of leds present on the device
952 * @sndbit: bitmap of sound effects supported by the device
953 * @ffbit: bitmap of force feedback effects supported by the device
954 * @swbit: bitmap of switches present on the device
955 * @keycodemax: size of keycode table
956 * @keycodesize: size of elements in keycode table
957 * @keycode: map of scancodes to keycodes for this device
958 * @setkeycode: optional method to alter current keymap, used to implement
959 * sparse keymaps. If not supplied default mechanism will be used
960 * @getkeycode: optional method to retrieve current keymap. If not supplied
961 * default mechanism will be used
962 * @ff: force feedback structure associated with the device if device
963 * supports force feedback effects
964 * @repeat_key: stores key code of the last key pressed; used to implement
965 * software autorepeat
966 * @timer: timer for software autorepeat
967 * @sync: set to 1 when there were no new events since last EV_SYNC
968 * @abs: current values for reports from absolute axes
969 * @rep: current values for autorepeat parameters (delay, rate)
970 * @key: reflects current state of device's keys/buttons
971 * @led: reflects current state of device's LEDs
972 * @snd: reflects current state of sound effects
973 * @sw: reflects current state of device's switches
974 * @absmax: maximum values for events coming from absolute axes
975 * @absmin: minimum values for events coming from absolute axes
976 * @absfuzz: describes noisiness for axes
977 * @absflat: size of the center flat position (used by joydev)
978 * @open: this method is called when the very first user calls
979 * input_open_device(). The driver must prepare the device
980 * to start generating events (start polling thread,
981 * request an IRQ, submit URB, etc.)
982 * @close: this method is called when the very last user calls
983 * input_close_device().
984 * @flush: purges the device. Most commonly used to get rid of force
985 * feedback effects loaded into the device when disconnecting
986 * from it
987 * @event: event handler for events sent _to_ the device, like EV_LED
988 * or EV_SND. The device is expected to carry out the requested
989 * action (turn on a LED, play sound, etc.) The call is protected
990 * by @event_lock and must not sleep
991 * @grab: input handle that currently has the device grabbed (via
992 * EVIOCGRAB ioctl). When a handle grabs a device it becomes sole
993 * recipient for all input events coming from the device
994 * @event_lock: this spinlock is is taken when input core receives
995 * and processes a new event for the device (in input_event()).
996 * Code that accesses and/or modifies parameters of a device
997 * (such as keymap or absmin, absmax, absfuzz, etc.) after device
998 * has been registered with input core must take this lock.
999 * @mutex: serializes calls to open(), close() and flush() methods
1000 * @users: stores number of users (input handlers) that opened this
1001 * device. It is used by input_open_device() and input_close_device()
1002 * to make sure that dev->open() is only called when the first
1003 * user opens device and dev->close() is called when the very
1004 * last user closes the device
1005 * @going_away: marks devices that are in a middle of unregistering and
1006 * causes input_open_device*() fail with -ENODEV.
1007 * @dev: driver model's view of this device
1008 * @h_list: list of input handles associated with the device. When
1009 * accessing the list dev->mutex must be held
1010 * @node: used to place the device onto input_dev_list
1011 */
937struct input_dev { 1012struct input_dev {
938 1013
939 void *private; 1014 void *private; /* do not use */
940 1015
941 const char *name; 1016 const char *name;
942 const char *phys; 1017 const char *phys;
@@ -964,8 +1039,6 @@ struct input_dev {
964 unsigned int repeat_key; 1039 unsigned int repeat_key;
965 struct timer_list timer; 1040 struct timer_list timer;
966 1041
967 int state;
968
969 int sync; 1042 int sync;
970 1043
971 int abs[ABS_MAX + 1]; 1044 int abs[ABS_MAX + 1];
@@ -988,8 +1061,11 @@ struct input_dev {
988 1061
989 struct input_handle *grab; 1062 struct input_handle *grab;
990 1063
991 struct mutex mutex; /* serializes open and close operations */ 1064 spinlock_t event_lock;
1065 struct mutex mutex;
1066
992 unsigned int users; 1067 unsigned int users;
1068 int going_away;
993 1069
994 struct device dev; 1070 struct device dev;
995 union { /* temporarily so while we switching to struct device */ 1071 union { /* temporarily so while we switching to struct device */
@@ -1055,7 +1131,9 @@ struct input_handle;
1055/** 1131/**
1056 * struct input_handler - implements one of interfaces for input devices 1132 * struct input_handler - implements one of interfaces for input devices
1057 * @private: driver-specific data 1133 * @private: driver-specific data
1058 * @event: event handler 1134 * @event: event handler. This method is being called by input core with
1135 * interrupts disabled and dev->event_lock spinlock held and so
1136 * it may not sleep
1059 * @connect: called when attaching a handler to an input device 1137 * @connect: called when attaching a handler to an input device
1060 * @disconnect: disconnects a handler from input device 1138 * @disconnect: disconnects a handler from input device
1061 * @start: starts handler for given handle. This function is called by 1139 * @start: starts handler for given handle. This function is called by
@@ -1067,10 +1145,18 @@ struct input_handle;
1067 * @name: name of the handler, to be shown in /proc/bus/input/handlers 1145 * @name: name of the handler, to be shown in /proc/bus/input/handlers
1068 * @id_table: pointer to a table of input_device_ids this driver can 1146 * @id_table: pointer to a table of input_device_ids this driver can
1069 * handle 1147 * handle
1070 * @blacklist: prointer to a table of input_device_ids this driver should 1148 * @blacklist: pointer to a table of input_device_ids this driver should
1071 * ignore even if they match @id_table 1149 * ignore even if they match @id_table
1072 * @h_list: list of input handles associated with the handler 1150 * @h_list: list of input handles associated with the handler
1073 * @node: for placing the driver onto input_handler_list 1151 * @node: for placing the driver onto input_handler_list
1152 *
1153 * Input handlers attach to input devices and create input handles. There
1154 * are likely several handlers attached to any given input device at the
1155 * same time. All of them will get their copy of input event generated by
1156 * the device.
1157 *
1158 * Note that input core serializes calls to connect() and disconnect()
1159 * methods.
1074 */ 1160 */
1075struct input_handler { 1161struct input_handler {
1076 1162
@@ -1092,6 +1178,18 @@ struct input_handler {
1092 struct list_head node; 1178 struct list_head node;
1093}; 1179};
1094 1180
1181/**
1182 * struct input_handle - links input device with an input handler
1183 * @private: handler-specific data
1184 * @open: counter showing whether the handle is 'open', i.e. should deliver
1185 * events from its device
1186 * @name: name given to the handle by handler that created it
1187 * @dev: input device the handle is attached to
1188 * @handler: handler that works with the device through this handle
1189 * @d_node: used to put the handle on device's list of attached handles
1190 * @h_node: used to put the handle on handler's list of handles from which
1191 * it gets events
1192 */
1095struct input_handle { 1193struct input_handle {
1096 1194
1097 void *private; 1195 void *private;
@@ -1134,10 +1232,10 @@ static inline void input_set_drvdata(struct input_dev *dev, void *data)
1134 dev->private = data; 1232 dev->private = data;
1135} 1233}
1136 1234
1137int input_register_device(struct input_dev *); 1235int __must_check input_register_device(struct input_dev *);
1138void input_unregister_device(struct input_dev *); 1236void input_unregister_device(struct input_dev *);
1139 1237
1140int input_register_handler(struct input_handler *); 1238int __must_check input_register_handler(struct input_handler *);
1141void input_unregister_handler(struct input_handler *); 1239void input_unregister_handler(struct input_handler *);
1142 1240
1143int input_register_handle(struct input_handle *); 1241int input_register_handle(struct input_handle *);
@@ -1214,7 +1312,7 @@ extern struct class input_class;
1214 * @max_effects: maximum number of effects supported by device 1312 * @max_effects: maximum number of effects supported by device
1215 * @effects: pointer to an array of effects currently loaded into device 1313 * @effects: pointer to an array of effects currently loaded into device
1216 * @effect_owners: array of effect owners; when file handle owning 1314 * @effect_owners: array of effect owners; when file handle owning
1217 * an effect gets closed the effcet is automatically erased 1315 * an effect gets closed the effect is automatically erased
1218 * 1316 *
1219 * Every force-feedback device must implement upload() and playback() 1317 * Every force-feedback device must implement upload() and playback()
1220 * methods; erase() is optional. set_gain() and set_autocenter() need 1318 * methods; erase() is optional. set_gain() and set_autocenter() need