aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/input.h
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2010-09-10 00:54:22 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-09-10 01:00:50 -0400
commit8613e4c2872a87cc309a42de2c7091744dc54d0e (patch)
tree75b6513268aca8b614f3b2a55421c7a07b4a9899 /include/linux/input.h
parenta4e6aad64735702256e4feaa4724eb776ca4e637 (diff)
Input: add support for large scancodes
Several devices use a high number of bits for scancodes. One important group is the Remote Controllers. Some new protocols like RC-6 define a scancode space of 64 bits. The current EVIO[CS]GKEYCODE ioctls allow replace the scancode/keycode translation tables, but it is limited to up to 32 bits for scancode. Also, if userspace wants to clean the existing table, replacing it by a new one, it needs to run a loop calling the ioctls over the entire sparse scancode space. To solve those problems, this patch extends the ioctls to allow drivers handle scancodes up to 32 bytes long (the length could be extended in the future should such need arise) and allow userspace to query and set scancode to keycode mappings not only by scancode but also by index. Compatibility code were also added to handle the old format of EVIO[CS]GKEYCODE ioctls. Folded fixes by: - Dan Carpenter: locking fixes for the original implementation - Jarod Wilson: fix crash when setting keycode and wiring up get/set handlers in original implementation. - Dmitry Torokhov: rework to consolidate old and new scancode handling, provide options to act either by index or scancode. Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com> Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'include/linux/input.h')
-rw-r--r--include/linux/input.h55
1 files changed, 44 insertions, 11 deletions
diff --git a/include/linux/input.h b/include/linux/input.h
index 789265123531..0057698fd975 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -34,7 +34,7 @@ struct input_event {
34 * Protocol version. 34 * Protocol version.
35 */ 35 */
36 36
37#define EV_VERSION 0x010000 37#define EV_VERSION 0x010001
38 38
39/* 39/*
40 * IOCTLs (0x00 - 0x7f) 40 * IOCTLs (0x00 - 0x7f)
@@ -56,12 +56,37 @@ struct input_absinfo {
56 __s32 resolution; 56 __s32 resolution;
57}; 57};
58 58
59/**
60 * struct input_keymap_entry - used by EVIOCGKEYCODE/EVIOCSKEYCODE ioctls
61 * @scancode: scancode represented in machine-endian form.
62 * @len: length of the scancode that resides in @scancode buffer.
63 * @index: index in the keymap, may be used instead of scancode
64 * @flags: allows to specify how kernel should handle the request. For
65 * example, setting INPUT_KEYMAP_BY_INDEX flag indicates that kernel
66 * should perform lookup in keymap by @index instead of @scancode
67 * @keycode: key code assigned to this scancode
68 *
69 * The structure is used to retrieve and modify keymap data. Users have
70 * option of performing lookup either by @scancode itself or by @index
71 * in keymap entry. EVIOCGKEYCODE will also return scancode or index
72 * (depending on which element was used to perform lookup).
73 */
74struct input_keymap_entry {
75#define INPUT_KEYMAP_BY_INDEX (1 << 0)
76 __u8 flags;
77 __u8 len;
78 __u16 index;
79 __u32 keycode;
80 __u8 scancode[32];
81};
82
59#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */ 83#define EVIOCGVERSION _IOR('E', 0x01, int) /* get driver version */
60#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */ 84#define EVIOCGID _IOR('E', 0x02, struct input_id) /* get device ID */
61#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */ 85#define EVIOCGREP _IOR('E', 0x03, unsigned int[2]) /* get repeat settings */
62#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */ 86#define EVIOCSREP _IOW('E', 0x03, unsigned int[2]) /* set repeat settings */
63#define EVIOCGKEYCODE _IOR('E', 0x04, unsigned int[2]) /* get keycode */ 87
64#define EVIOCSKEYCODE _IOW('E', 0x04, unsigned int[2]) /* set keycode */ 88#define EVIOCGKEYCODE _IOR('E', 0x04, struct input_keymap_entry) /* get keycode */
89#define EVIOCSKEYCODE _IOW('E', 0x04, struct input_keymap_entry) /* set keycode */
65 90
66#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */ 91#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len) /* get device name */
67#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */ 92#define EVIOCGPHYS(len) _IOC(_IOC_READ, 'E', 0x07, len) /* get physical location */
@@ -73,8 +98,8 @@ struct input_absinfo {
73#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */ 98#define EVIOCGSW(len) _IOC(_IOC_READ, 'E', 0x1b, len) /* get all switch states */
74 99
75#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */ 100#define EVIOCGBIT(ev,len) _IOC(_IOC_READ, 'E', 0x20 + ev, len) /* get event bits */
76#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */ 101#define EVIOCGABS(abs) _IOR('E', 0x40 + abs, struct input_absinfo) /* get abs value/limits */
77#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */ 102#define EVIOCSABS(abs) _IOW('E', 0xc0 + abs, struct input_absinfo) /* set abs value/limits */
78 103
79#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */ 104#define EVIOCSFF _IOC(_IOC_WRITE, 'E', 0x80, sizeof(struct ff_effect)) /* send a force effect to a force feedback device */
80#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */ 105#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
@@ -1088,13 +1113,13 @@ struct input_mt_slot {
1088 * @keycodemax: size of keycode table 1113 * @keycodemax: size of keycode table
1089 * @keycodesize: size of elements in keycode table 1114 * @keycodesize: size of elements in keycode table
1090 * @keycode: map of scancodes to keycodes for this device 1115 * @keycode: map of scancodes to keycodes for this device
1116 * @getkeycode: optional legacy method to retrieve current keymap.
1091 * @setkeycode: optional method to alter current keymap, used to implement 1117 * @setkeycode: optional method to alter current keymap, used to implement
1092 * sparse keymaps. If not supplied default mechanism will be used. 1118 * sparse keymaps. If not supplied default mechanism will be used.
1093 * The method is being called while holding event_lock and thus must 1119 * The method is being called while holding event_lock and thus must
1094 * not sleep 1120 * not sleep
1095 * @getkeycode: optional method to retrieve current keymap. If not supplied 1121 * @getkeycode_new: transition method
1096 * default mechanism will be used. The method is being called while 1122 * @setkeycode_new: transition method
1097 * holding event_lock and thus must not sleep
1098 * @ff: force feedback structure associated with the device if device 1123 * @ff: force feedback structure associated with the device if device
1099 * supports force feedback effects 1124 * supports force feedback effects
1100 * @repeat_key: stores key code of the last key pressed; used to implement 1125 * @repeat_key: stores key code of the last key pressed; used to implement
@@ -1168,10 +1193,16 @@ struct input_dev {
1168 unsigned int keycodemax; 1193 unsigned int keycodemax;
1169 unsigned int keycodesize; 1194 unsigned int keycodesize;
1170 void *keycode; 1195 void *keycode;
1196
1171 int (*setkeycode)(struct input_dev *dev, 1197 int (*setkeycode)(struct input_dev *dev,
1172 unsigned int scancode, unsigned int keycode); 1198 unsigned int scancode, unsigned int keycode);
1173 int (*getkeycode)(struct input_dev *dev, 1199 int (*getkeycode)(struct input_dev *dev,
1174 unsigned int scancode, unsigned int *keycode); 1200 unsigned int scancode, unsigned int *keycode);
1201 int (*setkeycode_new)(struct input_dev *dev,
1202 const struct input_keymap_entry *ke,
1203 unsigned int *old_keycode);
1204 int (*getkeycode_new)(struct input_dev *dev,
1205 struct input_keymap_entry *ke);
1175 1206
1176 struct ff_device *ff; 1207 struct ff_device *ff;
1177 1208
@@ -1478,10 +1509,12 @@ INPUT_GENERATE_ABS_ACCESSORS(fuzz, fuzz)
1478INPUT_GENERATE_ABS_ACCESSORS(flat, flat) 1509INPUT_GENERATE_ABS_ACCESSORS(flat, flat)
1479INPUT_GENERATE_ABS_ACCESSORS(res, resolution) 1510INPUT_GENERATE_ABS_ACCESSORS(res, resolution)
1480 1511
1481int input_get_keycode(struct input_dev *dev, 1512int input_scancode_to_scalar(const struct input_keymap_entry *ke,
1482 unsigned int scancode, unsigned int *keycode); 1513 unsigned int *scancode);
1514
1515int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke);
1483int input_set_keycode(struct input_dev *dev, 1516int input_set_keycode(struct input_dev *dev,
1484 unsigned int scancode, unsigned int keycode); 1517 const struct input_keymap_entry *ke);
1485 1518
1486extern struct class input_class; 1519extern struct class input_class;
1487 1520