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.h107
1 files changed, 85 insertions, 22 deletions
diff --git a/include/linux/input.h b/include/linux/input.h
index 6fcc9101beeb..896a92227bc4 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -691,9 +691,12 @@ struct input_absinfo {
691#define ABS_TILT_X 0x1a 691#define ABS_TILT_X 0x1a
692#define ABS_TILT_Y 0x1b 692#define ABS_TILT_Y 0x1b
693#define ABS_TOOL_WIDTH 0x1c 693#define ABS_TOOL_WIDTH 0x1c
694
694#define ABS_VOLUME 0x20 695#define ABS_VOLUME 0x20
696
695#define ABS_MISC 0x28 697#define ABS_MISC 0x28
696 698
699#define ABS_MT_SLOT 0x2f /* MT slot being modified */
697#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */ 700#define ABS_MT_TOUCH_MAJOR 0x30 /* Major axis of touching ellipse */
698#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */ 701#define ABS_MT_TOUCH_MINOR 0x31 /* Minor axis (omit if circular) */
699#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */ 702#define ABS_MT_WIDTH_MAJOR 0x32 /* Major axis of approaching ellipse */
@@ -706,6 +709,12 @@ struct input_absinfo {
706#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */ 709#define ABS_MT_TRACKING_ID 0x39 /* Unique ID of initiated contact */
707#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */ 710#define ABS_MT_PRESSURE 0x3a /* Pressure on contact area */
708 711
712#ifdef __KERNEL__
713/* Implementation details, userspace should not care about these */
714#define ABS_MT_FIRST ABS_MT_TOUCH_MAJOR
715#define ABS_MT_LAST ABS_MT_PRESSURE
716#endif
717
709#define ABS_MAX 0x3f 718#define ABS_MAX 0x3f
710#define ABS_CNT (ABS_MAX+1) 719#define ABS_CNT (ABS_MAX+1)
711 720
@@ -767,6 +776,7 @@ struct input_absinfo {
767#define REP_DELAY 0x00 776#define REP_DELAY 0x00
768#define REP_PERIOD 0x01 777#define REP_PERIOD 0x01
769#define REP_MAX 0x01 778#define REP_MAX 0x01
779#define REP_CNT (REP_MAX+1)
770 780
771/* 781/*
772 * Sounds 782 * Sounds
@@ -1048,6 +1058,14 @@ struct ff_effect {
1048#include <linux/mod_devicetable.h> 1058#include <linux/mod_devicetable.h>
1049 1059
1050/** 1060/**
1061 * struct input_mt_slot - represents the state of an input MT slot
1062 * @abs: holds current values of ABS_MT axes for this slot
1063 */
1064struct input_mt_slot {
1065 int abs[ABS_MT_LAST - ABS_MT_FIRST + 1];
1066};
1067
1068/**
1051 * struct input_dev - represents an input device 1069 * struct input_dev - represents an input device
1052 * @name: name of the device 1070 * @name: name of the device
1053 * @phys: physical path to the device in the system hierarchy 1071 * @phys: physical path to the device in the system hierarchy
@@ -1063,6 +1081,10 @@ struct ff_effect {
1063 * @sndbit: bitmap of sound effects supported by the device 1081 * @sndbit: bitmap of sound effects supported by the device
1064 * @ffbit: bitmap of force feedback effects supported by the device 1082 * @ffbit: bitmap of force feedback effects supported by the device
1065 * @swbit: bitmap of switches present on the device 1083 * @swbit: bitmap of switches present on the device
1084 * @hint_events_per_packet: average number of events generated by the
1085 * device in a packet (between EV_SYN/SYN_REPORT events). Used by
1086 * event handlers to estimate size of the buffer needed to hold
1087 * events.
1066 * @keycodemax: size of keycode table 1088 * @keycodemax: size of keycode table
1067 * @keycodesize: size of elements in keycode table 1089 * @keycodesize: size of elements in keycode table
1068 * @keycode: map of scancodes to keycodes for this device 1090 * @keycode: map of scancodes to keycodes for this device
@@ -1078,18 +1100,18 @@ struct ff_effect {
1078 * @repeat_key: stores key code of the last key pressed; used to implement 1100 * @repeat_key: stores key code of the last key pressed; used to implement
1079 * software autorepeat 1101 * software autorepeat
1080 * @timer: timer for software autorepeat 1102 * @timer: timer for software autorepeat
1081 * @sync: set to 1 when there were no new events since last EV_SYNC
1082 * @abs: current values for reports from absolute axes
1083 * @rep: current values for autorepeat parameters (delay, rate) 1103 * @rep: current values for autorepeat parameters (delay, rate)
1104 * @mt: pointer to array of struct input_mt_slot holding current values
1105 * of tracked contacts
1106 * @mtsize: number of MT slots the device uses
1107 * @slot: MT slot currently being transmitted
1108 * @absinfo: array of &struct absinfo elements holding information
1109 * about absolute axes (current value, min, max, flat, fuzz,
1110 * resolution)
1084 * @key: reflects current state of device's keys/buttons 1111 * @key: reflects current state of device's keys/buttons
1085 * @led: reflects current state of device's LEDs 1112 * @led: reflects current state of device's LEDs
1086 * @snd: reflects current state of sound effects 1113 * @snd: reflects current state of sound effects
1087 * @sw: reflects current state of device's switches 1114 * @sw: reflects current state of device's switches
1088 * @absmax: maximum values for events coming from absolute axes
1089 * @absmin: minimum values for events coming from absolute axes
1090 * @absfuzz: describes noisiness for axes
1091 * @absflat: size of the center flat position (used by joydev)
1092 * @absres: resolution used for events coming form absolute axes
1093 * @open: this method is called when the very first user calls 1115 * @open: this method is called when the very first user calls
1094 * input_open_device(). The driver must prepare the device 1116 * input_open_device(). The driver must prepare the device
1095 * to start generating events (start polling thread, 1117 * to start generating events (start polling thread,
@@ -1119,6 +1141,7 @@ struct ff_effect {
1119 * last user closes the device 1141 * last user closes the device
1120 * @going_away: marks devices that are in a middle of unregistering and 1142 * @going_away: marks devices that are in a middle of unregistering and
1121 * causes input_open_device*() fail with -ENODEV. 1143 * causes input_open_device*() fail with -ENODEV.
1144 * @sync: set to %true when there were no new events since last EV_SYN
1122 * @dev: driver model's view of this device 1145 * @dev: driver model's view of this device
1123 * @h_list: list of input handles associated with the device. When 1146 * @h_list: list of input handles associated with the device. When
1124 * accessing the list dev->mutex must be held 1147 * accessing the list dev->mutex must be held
@@ -1140,6 +1163,8 @@ struct input_dev {
1140 unsigned long ffbit[BITS_TO_LONGS(FF_CNT)]; 1163 unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
1141 unsigned long swbit[BITS_TO_LONGS(SW_CNT)]; 1164 unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
1142 1165
1166 unsigned int hint_events_per_packet;
1167
1143 unsigned int keycodemax; 1168 unsigned int keycodemax;
1144 unsigned int keycodesize; 1169 unsigned int keycodesize;
1145 void *keycode; 1170 void *keycode;
@@ -1153,22 +1178,19 @@ struct input_dev {
1153 unsigned int repeat_key; 1178 unsigned int repeat_key;
1154 struct timer_list timer; 1179 struct timer_list timer;
1155 1180
1156 int sync; 1181 int rep[REP_CNT];
1182
1183 struct input_mt_slot *mt;
1184 int mtsize;
1185 int slot;
1157 1186
1158 int abs[ABS_CNT]; 1187 struct input_absinfo *absinfo;
1159 int rep[REP_MAX + 1];
1160 1188
1161 unsigned long key[BITS_TO_LONGS(KEY_CNT)]; 1189 unsigned long key[BITS_TO_LONGS(KEY_CNT)];
1162 unsigned long led[BITS_TO_LONGS(LED_CNT)]; 1190 unsigned long led[BITS_TO_LONGS(LED_CNT)];
1163 unsigned long snd[BITS_TO_LONGS(SND_CNT)]; 1191 unsigned long snd[BITS_TO_LONGS(SND_CNT)];
1164 unsigned long sw[BITS_TO_LONGS(SW_CNT)]; 1192 unsigned long sw[BITS_TO_LONGS(SW_CNT)];
1165 1193
1166 int absmax[ABS_CNT];
1167 int absmin[ABS_CNT];
1168 int absfuzz[ABS_CNT];
1169 int absflat[ABS_CNT];
1170 int absres[ABS_CNT];
1171
1172 int (*open)(struct input_dev *dev); 1194 int (*open)(struct input_dev *dev);
1173 void (*close)(struct input_dev *dev); 1195 void (*close)(struct input_dev *dev);
1174 int (*flush)(struct input_dev *dev, struct file *file); 1196 int (*flush)(struct input_dev *dev, struct file *file);
@@ -1182,6 +1204,8 @@ struct input_dev {
1182 unsigned int users; 1204 unsigned int users;
1183 bool going_away; 1205 bool going_away;
1184 1206
1207 bool sync;
1208
1185 struct device dev; 1209 struct device dev;
1186 1210
1187 struct list_head h_list; 1211 struct list_head h_list;
@@ -1406,18 +1430,54 @@ static inline void input_mt_sync(struct input_dev *dev)
1406 input_event(dev, EV_SYN, SYN_MT_REPORT, 0); 1430 input_event(dev, EV_SYN, SYN_MT_REPORT, 0);
1407} 1431}
1408 1432
1433static inline void input_mt_slot(struct input_dev *dev, int slot)
1434{
1435 input_event(dev, EV_ABS, ABS_MT_SLOT, slot);
1436}
1437
1409void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code); 1438void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
1410 1439
1411static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) 1440/**
1441 * input_set_events_per_packet - tell handlers about the driver event rate
1442 * @dev: the input device used by the driver
1443 * @n_events: the average number of events between calls to input_sync()
1444 *
1445 * If the event rate sent from a device is unusually large, use this
1446 * function to set the expected event rate. This will allow handlers
1447 * to set up an appropriate buffer size for the event stream, in order
1448 * to minimize information loss.
1449 */
1450static inline void input_set_events_per_packet(struct input_dev *dev, int n_events)
1412{ 1451{
1413 dev->absmin[axis] = min; 1452 dev->hint_events_per_packet = n_events;
1414 dev->absmax[axis] = max; 1453}
1415 dev->absfuzz[axis] = fuzz;
1416 dev->absflat[axis] = flat;
1417 1454
1418 dev->absbit[BIT_WORD(axis)] |= BIT_MASK(axis); 1455void input_alloc_absinfo(struct input_dev *dev);
1456void input_set_abs_params(struct input_dev *dev, unsigned int axis,
1457 int min, int max, int fuzz, int flat);
1458
1459#define INPUT_GENERATE_ABS_ACCESSORS(_suffix, _item) \
1460static inline int input_abs_get_##_suffix(struct input_dev *dev, \
1461 unsigned int axis) \
1462{ \
1463 return dev->absinfo ? dev->absinfo[axis]._item : 0; \
1464} \
1465 \
1466static inline void input_abs_set_##_suffix(struct input_dev *dev, \
1467 unsigned int axis, int val) \
1468{ \
1469 input_alloc_absinfo(dev); \
1470 if (dev->absinfo) \
1471 dev->absinfo[axis]._item = val; \
1419} 1472}
1420 1473
1474INPUT_GENERATE_ABS_ACCESSORS(val, value)
1475INPUT_GENERATE_ABS_ACCESSORS(min, minimum)
1476INPUT_GENERATE_ABS_ACCESSORS(max, maximum)
1477INPUT_GENERATE_ABS_ACCESSORS(fuzz, fuzz)
1478INPUT_GENERATE_ABS_ACCESSORS(flat, flat)
1479INPUT_GENERATE_ABS_ACCESSORS(res, resolution)
1480
1421int input_get_keycode(struct input_dev *dev, 1481int input_get_keycode(struct input_dev *dev,
1422 unsigned int scancode, unsigned int *keycode); 1482 unsigned int scancode, unsigned int *keycode);
1423int input_set_keycode(struct input_dev *dev, 1483int input_set_keycode(struct input_dev *dev,
@@ -1485,5 +1545,8 @@ int input_ff_erase(struct input_dev *dev, int effect_id, struct file *file);
1485int input_ff_create_memless(struct input_dev *dev, void *data, 1545int input_ff_create_memless(struct input_dev *dev, void *data,
1486 int (*play_effect)(struct input_dev *, void *, struct ff_effect *)); 1546 int (*play_effect)(struct input_dev *, void *, struct ff_effect *));
1487 1547
1548int input_mt_create_slots(struct input_dev *dev, unsigned int num_slots);
1549void input_mt_destroy_slots(struct input_dev *dev);
1550
1488#endif 1551#endif
1489#endif 1552#endif