Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202177
b: refs/heads/master
c: 63a6404
h: refs/heads/master
i:
  202175: 5deb974
v: v3
  • Loading branch information
Henrik Rydberg authored and Dmitry Torokhov committed Jun 23, 2010
1 parent d7581b8 commit 4e88eb0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b58f7086d52c0ac6c879ee5aaf7c276e17768e5b
refs/heads/master: 63a6404d8ae693e71ab27c4f9c4032aa29113e92
9 changes: 7 additions & 2 deletions trunk/drivers/input/evdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

#define EVDEV_MINOR_BASE 64
#define EVDEV_MINORS 32
#define EVDEV_MIN_BUFFER_SIZE 64
#define EVDEV_MIN_BUFFER_SIZE 64U
#define EVDEV_BUF_PACKETS 8

#include <linux/poll.h>
#include <linux/sched.h>
Expand Down Expand Up @@ -245,7 +246,11 @@ static int evdev_release(struct inode *inode, struct file *file)

static unsigned int evdev_compute_buffer_size(struct input_dev *dev)
{
return EVDEV_MIN_BUFFER_SIZE;
unsigned int n_events =
max(dev->hint_events_per_packet * EVDEV_BUF_PACKETS,
EVDEV_MIN_BUFFER_SIZE);

return roundup_pow_of_two(n_events);
}

static int evdev_open(struct inode *inode, struct file *file)
Expand Down
21 changes: 21 additions & 0 deletions trunk/include/linux/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4e88eb0

Please sign in to comment.