Input: evdev - use driver hint to compute size of event buffer
[deliverable/linux.git] / include / linux / input.h
index 6fcc9101beeb3e907b9b4c030fef7db9b7f9e334..cc524c8b6703967e657bcc4faae554e9f88df6bd 100644 (file)
@@ -1063,6 +1063,10 @@ struct ff_effect {
  * @sndbit: bitmap of sound effects supported by the device
  * @ffbit: bitmap of force feedback effects supported by the device
  * @swbit: bitmap of switches present on the device
+ * @hint_events_per_packet: average number of events generated by the
+ *     device in a packet (between EV_SYN/SYN_REPORT events). Used by
+ *     event handlers to estimate size of the buffer needed to hold
+ *     events.
  * @keycodemax: size of keycode table
  * @keycodesize: size of elements in keycode table
  * @keycode: map of scancodes to keycodes for this device
@@ -1140,6 +1144,8 @@ struct input_dev {
        unsigned long ffbit[BITS_TO_LONGS(FF_CNT)];
        unsigned long swbit[BITS_TO_LONGS(SW_CNT)];
 
+       unsigned int hint_events_per_packet;
+
        unsigned int keycodemax;
        unsigned int keycodesize;
        void *keycode;
@@ -1408,6 +1414,21 @@ static inline void input_mt_sync(struct input_dev *dev)
 
 void input_set_capability(struct input_dev *dev, unsigned int type, unsigned int code);
 
+/**
+ * input_set_events_per_packet - tell handlers about the driver event rate
+ * @dev: the input device used by the driver
+ * @n_events: the average number of events between calls to input_sync()
+ *
+ * If the event rate sent from a device is unusually large, use this
+ * function to set the expected event rate. This will allow handlers
+ * to set up an appropriate buffer size for the event stream, in order
+ * to minimize information loss.
+ */
+static inline void input_set_events_per_packet(struct input_dev *dev, int n_events)
+{
+       dev->hint_events_per_packet = n_events;
+}
+
 static inline void input_set_abs_params(struct input_dev *dev, int axis, int min, int max, int fuzz, int flat)
 {
        dev->absmin[axis] = min;
This page took 0.024093 seconds and 5 git commands to generate.