diff options
| author | Daniel Mack <daniel@caiaq.de> | 2010-08-02 23:18:21 -0400 |
|---|---|---|
| committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-08-02 23:30:04 -0400 |
| commit | d31b2865a4e8a9dd02f39e56c8fadb824c5e187b (patch) | |
| tree | cbe062757aa54c88c8e9ae2bf6ff87f791313c60 /include/linux/input.h | |
| parent | 987a6c0298260b7aa40702b349282554d6180e4b (diff) | |
Input: dynamically allocate ABS information
As all callers are now changed to only use the input_abs_*() access
helpers, switching over to dynamically allocated ABS information is
easy. This reduces size of struct input_dev from 3152 to 1640 on
64 bit architectures.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'include/linux/input.h')
| -rw-r--r-- | include/linux/input.h | 57 |
1 files changed, 18 insertions, 39 deletions
diff --git a/include/linux/input.h b/include/linux/input.h index 4a5531161de1..896a92227bc4 100644 --- a/include/linux/input.h +++ b/include/linux/input.h | |||
| @@ -776,6 +776,7 @@ struct input_absinfo { | |||
| 776 | #define REP_DELAY 0x00 | 776 | #define REP_DELAY 0x00 |
| 777 | #define REP_PERIOD 0x01 | 777 | #define REP_PERIOD 0x01 |
| 778 | #define REP_MAX 0x01 | 778 | #define REP_MAX 0x01 |
| 779 | #define REP_CNT (REP_MAX+1) | ||
| 779 | 780 | ||
| 780 | /* | 781 | /* |
| 781 | * Sounds | 782 | * Sounds |
| @@ -1099,21 +1100,18 @@ struct input_mt_slot { | |||
| 1099 | * @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 |
| 1100 | * software autorepeat | 1101 | * software autorepeat |
| 1101 | * @timer: timer for software autorepeat | 1102 | * @timer: timer for software autorepeat |
| 1102 | * @abs: current values for reports from absolute axes | ||
| 1103 | * @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 | 1104 | * @mt: pointer to array of struct input_mt_slot holding current values |
| 1105 | * of tracked contacts | 1105 | * of tracked contacts |
| 1106 | * @mtsize: number of MT slots the device uses | 1106 | * @mtsize: number of MT slots the device uses |
| 1107 | * @slot: MT slot currently being transmitted | 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) | ||
| 1108 | * @key: reflects current state of device's keys/buttons | 1111 | * @key: reflects current state of device's keys/buttons |
| 1109 | * @led: reflects current state of device's LEDs | 1112 | * @led: reflects current state of device's LEDs |
| 1110 | * @snd: reflects current state of sound effects | 1113 | * @snd: reflects current state of sound effects |
| 1111 | * @sw: reflects current state of device's switches | 1114 | * @sw: reflects current state of device's switches |
| 1112 | * @absmax: maximum values for events coming from absolute axes | ||
| 1113 | * @absmin: minimum values for events coming from absolute axes | ||
| 1114 | * @absfuzz: describes noisiness for axes | ||
| 1115 | * @absflat: size of the center flat position (used by joydev) | ||
| 1116 | * @absres: resolution used for events coming form absolute axes | ||
| 1117 | * @open: this method is called when the very first user calls | 1115 | * @open: this method is called when the very first user calls |
| 1118 | * input_open_device(). The driver must prepare the device | 1116 | * input_open_device(). The driver must prepare the device |
| 1119 | * to start generating events (start polling thread, | 1117 | * to start generating events (start polling thread, |
| @@ -1180,24 +1178,19 @@ struct input_dev { | |||
| 1180 | unsigned int repeat_key; | 1178 | unsigned int repeat_key; |
| 1181 | struct timer_list timer; | 1179 | struct timer_list timer; |
| 1182 | 1180 | ||
| 1183 | int abs[ABS_CNT]; | 1181 | int rep[REP_CNT]; |
| 1184 | int rep[REP_MAX + 1]; | ||
| 1185 | 1182 | ||
| 1186 | struct input_mt_slot *mt; | 1183 | struct input_mt_slot *mt; |
| 1187 | int mtsize; | 1184 | int mtsize; |
| 1188 | int slot; | 1185 | int slot; |
| 1189 | 1186 | ||
| 1187 | struct input_absinfo *absinfo; | ||
| 1188 | |||
| 1190 | unsigned long key[BITS_TO_LONGS(KEY_CNT)]; | 1189 | unsigned long key[BITS_TO_LONGS(KEY_CNT)]; |
| 1191 | unsigned long led[BITS_TO_LONGS(LED_CNT)]; | 1190 | unsigned long led[BITS_TO_LONGS(LED_CNT)]; |
| 1192 | unsigned long snd[BITS_TO_LONGS(SND_CNT)]; | 1191 | unsigned long snd[BITS_TO_LONGS(SND_CNT)]; |
| 1193 | unsigned long sw[BITS_TO_LONGS(SW_CNT)]; | 1192 | unsigned long sw[BITS_TO_LONGS(SW_CNT)]; |
| 1194 | 1193 | ||
| 1195 | int absmax[ABS_CNT]; | ||
| 1196 | int absmin[ABS_CNT]; | ||
| 1197 | int absfuzz[ABS_CNT]; | ||
| 1198 | int absflat[ABS_CNT]; | ||
| 1199 | int absres[ABS_CNT]; | ||
| 1200 | |||
| 1201 | int (*open)(struct input_dev *dev); | 1194 | int (*open)(struct input_dev *dev); |
| 1202 | void (*close)(struct input_dev *dev); | 1195 | void (*close)(struct input_dev *dev); |
| 1203 | int (*flush)(struct input_dev *dev, struct file *file); | 1196 | int (*flush)(struct input_dev *dev, struct file *file); |
| @@ -1459,45 +1452,31 @@ static inline void input_set_events_per_packet(struct input_dev *dev, int n_even | |||
| 1459 | dev->hint_events_per_packet = n_events; | 1452 | dev->hint_events_per_packet = n_events; |
| 1460 | } | 1453 | } |
| 1461 | 1454 | ||
| 1462 | static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat) | 1455 | void input_alloc_absinfo(struct input_dev *dev); |
| 1463 | { | 1456 | void input_set_abs_params(struct input_dev *dev, unsigned int axis, |
| 1464 | dev->absmin[axis] = min; | 1457 | int min, int max, int fuzz, int flat); |
| 1465 | dev->absmax[axis] = max; | ||
| 1466 | dev->absfuzz[axis] = fuzz; | ||
| 1467 | dev->absflat[axis] = flat; | ||
| 1468 | |||
| 1469 | dev->absbit[BIT_WORD(axis)] |= BIT_MASK(axis); | ||
| 1470 | } | ||
| 1471 | 1458 | ||
| 1472 | #define INPUT_GENERATE_ABS_ACCESSORS(_suffix, _item) \ | 1459 | #define INPUT_GENERATE_ABS_ACCESSORS(_suffix, _item) \ |
| 1473 | static inline int input_abs_get_##_suffix(struct input_dev *dev, \ | 1460 | static inline int input_abs_get_##_suffix(struct input_dev *dev, \ |
| 1474 | unsigned int axis) \ | 1461 | unsigned int axis) \ |
| 1475 | { \ | 1462 | { \ |
| 1476 | return dev->abs##_item[axis]; \ | 1463 | return dev->absinfo ? dev->absinfo[axis]._item : 0; \ |
| 1477 | } \ | 1464 | } \ |
| 1478 | \ | 1465 | \ |
| 1479 | static inline void input_abs_set_##_suffix(struct input_dev *dev, \ | 1466 | static inline void input_abs_set_##_suffix(struct input_dev *dev, \ |
| 1480 | unsigned int axis, int val) \ | 1467 | unsigned int axis, int val) \ |
| 1481 | { \ | 1468 | { \ |
| 1482 | dev->abs##_item[axis] = val; \ | 1469 | input_alloc_absinfo(dev); \ |
| 1470 | if (dev->absinfo) \ | ||
| 1471 | dev->absinfo[axis]._item = val; \ | ||
| 1483 | } | 1472 | } |
| 1484 | 1473 | ||
| 1485 | INPUT_GENERATE_ABS_ACCESSORS(min, min) | 1474 | INPUT_GENERATE_ABS_ACCESSORS(val, value) |
| 1486 | INPUT_GENERATE_ABS_ACCESSORS(max, max) | 1475 | INPUT_GENERATE_ABS_ACCESSORS(min, minimum) |
| 1476 | INPUT_GENERATE_ABS_ACCESSORS(max, maximum) | ||
| 1487 | INPUT_GENERATE_ABS_ACCESSORS(fuzz, fuzz) | 1477 | INPUT_GENERATE_ABS_ACCESSORS(fuzz, fuzz) |
| 1488 | INPUT_GENERATE_ABS_ACCESSORS(flat, flat) | 1478 | INPUT_GENERATE_ABS_ACCESSORS(flat, flat) |
| 1489 | INPUT_GENERATE_ABS_ACCESSORS(res, res) | 1479 | INPUT_GENERATE_ABS_ACCESSORS(res, resolution) |
| 1490 | |||
| 1491 | static inline int input_abs_get_val(struct input_dev *dev, unsigned int axis) | ||
| 1492 | { | ||
| 1493 | return dev->abs[axis]; | ||
| 1494 | } | ||
| 1495 | |||
| 1496 | static inline void input_abs_set_val(struct input_dev *dev, | ||
| 1497 | unsigned int axis, int val) | ||
| 1498 | { | ||
| 1499 | dev->abs[axis] = val; | ||
| 1500 | } | ||
| 1501 | 1480 | ||
| 1502 | int input_get_keycode(struct input_dev *dev, | 1481 | int input_get_keycode(struct input_dev *dev, |
| 1503 | unsigned int scancode, unsigned int *keycode); | 1482 | unsigned int scancode, unsigned int *keycode); |
