* [PATCH] uinput: allow events per packet to be specified
@ 2011-03-01 15:47 Alan Cox
2011-03-01 16:35 ` Aristeu Rozanski
2011-03-02 14:13 ` Henrik Rydberg
0 siblings, 2 replies; 6+ messages in thread
From: Alan Cox @ 2011-03-01 15:47 UTC (permalink / raw)
To: aris, linux-input
From: Alan Cox <alan@linux.intel.com>
Implement an events per packet interface configuration. We do this by
adding a new ioctl that must be called before creation and follows the
pattern of the existing API.
The behaviour is:
Not set: input default or value computed by the uinput driver
Set: value used in preference if larger than computed
value
Signed-off-by: Alan Cox <alan@linux.intel.com>
---
drivers/input/misc/uinput.c | 25 +++++++++++++++++++++++--
include/linux/uinput.h | 3 +++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
index b941078..2d36ad8 100644
--- a/drivers/input/misc/uinput.c
+++ b/drivers/input/misc/uinput.c
@@ -349,6 +349,7 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
char *name;
int i, size;
int retval;
+ int epp = 0;
if (count != sizeof(struct uinput_user_dev))
return -EINVAL;
@@ -407,11 +408,19 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
if (test_bit(ABS_MT_SLOT, dev->absbit)) {
int nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1;
input_mt_create_slots(dev, nslot);
- input_set_events_per_packet(dev, 6 * nslot);
+ epp = 6 * nslot;
} else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) {
- input_set_events_per_packet(dev, 60);
+ epp = 60;
}
}
+ /* if the user forced the event information then honour their
+ * request providing it is bigger than the value we have ascertained
+ * is required */
+ if (udev->events_per_packet > epp)
+ epp = udev->events_per_packet;
+
+ if (epp)
+ input_set_events_per_packet(dev, epp);
udev->state = UIST_SETUP_COMPLETE;
retval = count;
@@ -705,6 +714,18 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
phys[length - 1] = '\0';
break;
+ case UI_SET_EPP:
+ if (udev->state == UIST_CREATED) {
+ retval = -EINVAL;
+ goto out;
+ }
+ if (arg < 1) {
+ retval = -EINVAL;
+ goto out;
+ }
+ udev->events_per_packet = arg;
+ break;
+
case UI_BEGIN_FF_UPLOAD:
retval = uinput_ff_upload_from_user(p, &ff_up);
if (retval)
diff --git a/include/linux/uinput.h b/include/linux/uinput.h
index 05f7fed2..85c8b17 100644
--- a/include/linux/uinput.h
+++ b/include/linux/uinput.h
@@ -73,6 +73,8 @@ struct uinput_device {
struct uinput_request *requests[UINPUT_NUM_REQUESTS];
wait_queue_head_t requests_waitq;
spinlock_t requests_lock;
+
+ int events_per_packet;
};
#endif /* __KERNEL__ */
@@ -104,6 +106,7 @@ struct uinput_ff_erase {
#define UI_SET_FFBIT _IOW(UINPUT_IOCTL_BASE, 107, int)
#define UI_SET_PHYS _IOW(UINPUT_IOCTL_BASE, 108, char*)
#define UI_SET_SWBIT _IOW(UINPUT_IOCTL_BASE, 109, int)
+#define UI_SET_EPP _IOW(UINPUT_IOCTL_BASE, 110, int)
#define UI_BEGIN_FF_UPLOAD _IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload)
#define UI_END_FF_UPLOAD _IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload)
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] uinput: allow events per packet to be specified
2011-03-01 15:47 [PATCH] uinput: allow events per packet to be specified Alan Cox
@ 2011-03-01 16:35 ` Aristeu Rozanski
2011-03-02 14:13 ` Henrik Rydberg
1 sibling, 0 replies; 6+ messages in thread
From: Aristeu Rozanski @ 2011-03-01 16:35 UTC (permalink / raw)
To: Alan Cox; +Cc: linux-input
On Tue, Mar 01, 2011 at 03:47:23PM +0000, Alan Cox wrote:
> From: Alan Cox <alan@linux.intel.com>
>
> Implement an events per packet interface configuration. We do this by
> adding a new ioctl that must be called before creation and follows the
> pattern of the existing API.
>
> The behaviour is:
> Not set: input default or value computed by the uinput driver
> Set: value used in preference if larger than computed
> value
>
> Signed-off-by: Alan Cox <alan@linux.intel.com>
> ---
>
> drivers/input/misc/uinput.c | 25 +++++++++++++++++++++++--
> include/linux/uinput.h | 3 +++
> 2 files changed, 26 insertions(+), 2 deletions(-)
>
>
> diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
> index b941078..2d36ad8 100644
> --- a/drivers/input/misc/uinput.c
> +++ b/drivers/input/misc/uinput.c
> @@ -349,6 +349,7 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
> char *name;
> int i, size;
> int retval;
> + int epp = 0;
>
> if (count != sizeof(struct uinput_user_dev))
> return -EINVAL;
> @@ -407,11 +408,19 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
> if (test_bit(ABS_MT_SLOT, dev->absbit)) {
> int nslot = input_abs_get_max(dev, ABS_MT_SLOT) + 1;
> input_mt_create_slots(dev, nslot);
> - input_set_events_per_packet(dev, 6 * nslot);
> + epp = 6 * nslot;
> } else if (test_bit(ABS_MT_POSITION_X, dev->absbit)) {
> - input_set_events_per_packet(dev, 60);
> + epp = 60;
> }
> }
> + /* if the user forced the event information then honour their
> + * request providing it is bigger than the value we have ascertained
> + * is required */
> + if (udev->events_per_packet > epp)
> + epp = udev->events_per_packet;
> +
> + if (epp)
> + input_set_events_per_packet(dev, epp);
>
> udev->state = UIST_SETUP_COMPLETE;
> retval = count;
> @@ -705,6 +714,18 @@ static long uinput_ioctl_handler(struct file *file, unsigned int cmd,
> phys[length - 1] = '\0';
> break;
>
> + case UI_SET_EPP:
> + if (udev->state == UIST_CREATED) {
> + retval = -EINVAL;
> + goto out;
> + }
> + if (arg < 1) {
> + retval = -EINVAL;
> + goto out;
> + }
> + udev->events_per_packet = arg;
> + break;
> +
> case UI_BEGIN_FF_UPLOAD:
> retval = uinput_ff_upload_from_user(p, &ff_up);
> if (retval)
> diff --git a/include/linux/uinput.h b/include/linux/uinput.h
> index 05f7fed2..85c8b17 100644
> --- a/include/linux/uinput.h
> +++ b/include/linux/uinput.h
> @@ -73,6 +73,8 @@ struct uinput_device {
> struct uinput_request *requests[UINPUT_NUM_REQUESTS];
> wait_queue_head_t requests_waitq;
> spinlock_t requests_lock;
> +
> + int events_per_packet;
> };
> #endif /* __KERNEL__ */
>
> @@ -104,6 +106,7 @@ struct uinput_ff_erase {
> #define UI_SET_FFBIT _IOW(UINPUT_IOCTL_BASE, 107, int)
> #define UI_SET_PHYS _IOW(UINPUT_IOCTL_BASE, 108, char*)
> #define UI_SET_SWBIT _IOW(UINPUT_IOCTL_BASE, 109, int)
> +#define UI_SET_EPP _IOW(UINPUT_IOCTL_BASE, 110, int)
>
> #define UI_BEGIN_FF_UPLOAD _IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload)
> #define UI_END_FF_UPLOAD _IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload)
Acked-by: Aristeu Rozanski <aris@ruivo.org>
--
Aristeu
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] uinput: allow events per packet to be specified
2011-03-01 15:47 [PATCH] uinput: allow events per packet to be specified Alan Cox
2011-03-01 16:35 ` Aristeu Rozanski
@ 2011-03-02 14:13 ` Henrik Rydberg
2011-03-02 16:06 ` Alan Cox
1 sibling, 1 reply; 6+ messages in thread
From: Henrik Rydberg @ 2011-03-02 14:13 UTC (permalink / raw)
To: Alan Cox; +Cc: aris, linux-input
Hi Alan,
> Implement an events per packet interface configuration. We do this by
> adding a new ioctl that must be called before creation and follows the
> pattern of the existing API.
>
> The behaviour is:
> Not set: input default or value computed by the uinput driver
> Set: value used in preference if larger than computed
> value
>
> Signed-off-by: Alan Cox <alan@linux.intel.com>
> ---
I agree that adding this ioctl is symmetrical from the a device
emulation standpoint, but I was imagining eventually replacing the eep
with an automatic scheme, or at least with a more realtime-oriented
parameter. Fixating the interface as you propose will make such a
transition much harder.
Thanks,
Henrik
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] uinput: allow events per packet to be specified
2011-03-02 14:13 ` Henrik Rydberg
@ 2011-03-02 16:06 ` Alan Cox
2011-03-02 17:13 ` Henrik Rydberg
0 siblings, 1 reply; 6+ messages in thread
From: Alan Cox @ 2011-03-02 16:06 UTC (permalink / raw)
To: Henrik Rydberg; +Cc: aris, linux-input
On Wed, 2 Mar 2011 15:13:05 +0100
"Henrik Rydberg" <rydberg@euromail.se> wrote:
> Hi Alan,
>
> > Implement an events per packet interface configuration. We do this by
> > adding a new ioctl that must be called before creation and follows the
> > pattern of the existing API.
> >
> > The behaviour is:
> > Not set: input default or value computed by the uinput driver
> > Set: value used in preference if larger than computed
> > value
> >
> > Signed-off-by: Alan Cox <alan@linux.intel.com>
> > ---
>
> I agree that adding this ioctl is symmetrical from the a device
> emulation standpoint, but I was imagining eventually replacing the eep
> with an automatic scheme, or at least with a more realtime-oriented
> parameter. Fixating the interface as you propose will make such a
> transition much harder.
This is something we actually need rather than are having future
visions about, so imaginings for the future don't really help here
unfortunately. I'd obviously rather have a standard API than get into the
situation where more and more devices and distros simply won't run an
upstream kernel.
If the long term theoretical transition is a concern then we could simply
make the "set" behaviour
Set: value is used as a hint to the uinput driver and input layer
that a given amount of buffering may be required. It may be
ignored by the input layer.
and if the long term imagining ever happens the interface cannot be an
implediment. It won't cause any problems because if the automatic
interfaces work then the hint isn't needed, and if they never get
implemented or it turns out they never to work for all cases (most
likely I suspect) then you'll still need the hint.
Does that work ?
Alan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] uinput: allow events per packet to be specified
2011-03-02 16:06 ` Alan Cox
@ 2011-03-02 17:13 ` Henrik Rydberg
2011-03-03 8:06 ` Dmitry Torokhov
0 siblings, 1 reply; 6+ messages in thread
From: Henrik Rydberg @ 2011-03-02 17:13 UTC (permalink / raw)
To: Alan Cox; +Cc: aris, linux-input
> > I agree that adding this ioctl is symmetrical from the a device
> > emulation standpoint, but I was imagining eventually replacing the eep
> > with an automatic scheme, or at least with a more realtime-oriented
> > parameter. Fixating the interface as you propose will make such a
> > transition much harder.
>
> This is something we actually need rather than are having future
> visions about, so imaginings for the future don't really help here
> unfortunately. I'd obviously rather have a standard API than get into the
> situation where more and more devices and distros simply won't run an
> upstream kernel.
>
> If the long term theoretical transition is a concern then we could simply
> make the "set" behaviour
>
> Set: value is used as a hint to the uinput driver and input layer
> that a given amount of buffering may be required. It may be
> ignored by the input layer.
>
> and if the long term imagining ever happens the interface cannot be an
> implediment. It won't cause any problems because if the automatic
> interfaces work then the hint isn't needed, and if they never get
> implemented or it turns out they never to work for all cases (most
> likely I suspect) then you'll still need the hint.
Sure, we may need a hint, but if the better hint turns out to be
events_per_millisecond rather than events_per_packet, we are still in
a bad situation. Let's see what Dmitry thinks about this. I don't mind
making the accompanying changes right away, if that helps you.
Thanks,
Henrik
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] uinput: allow events per packet to be specified
2011-03-02 17:13 ` Henrik Rydberg
@ 2011-03-03 8:06 ` Dmitry Torokhov
0 siblings, 0 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2011-03-03 8:06 UTC (permalink / raw)
To: Henrik Rydberg; +Cc: Alan Cox, aris, linux-input
On Wed, Mar 02, 2011 at 06:13:57PM +0100, Henrik Rydberg wrote:
> > > I agree that adding this ioctl is symmetrical from the a device
> > > emulation standpoint, but I was imagining eventually replacing the eep
> > > with an automatic scheme, or at least with a more realtime-oriented
> > > parameter. Fixating the interface as you propose will make such a
> > > transition much harder.
> >
> > This is something we actually need rather than are having future
> > visions about, so imaginings for the future don't really help here
> > unfortunately. I'd obviously rather have a standard API than get into the
> > situation where more and more devices and distros simply won't run an
> > upstream kernel.
> >
> > If the long term theoretical transition is a concern then we could simply
> > make the "set" behaviour
> >
> > Set: value is used as a hint to the uinput driver and input layer
> > that a given amount of buffering may be required. It may be
> > ignored by the input layer.
> >
> > and if the long term imagining ever happens the interface cannot be an
> > implediment. It won't cause any problems because if the automatic
> > interfaces work then the hint isn't needed, and if they never get
> > implemented or it turns out they never to work for all cases (most
> > likely I suspect) then you'll still need the hint.
>
> Sure, we may need a hint, but if the better hint turns out to be
> events_per_millisecond rather than events_per_packet, we are still in
> a bad situation. Let's see what Dmitry thinks about this. I don't mind
> making the accompanying changes right away, if that helps you.
>
Umm, before we do that could we get an idea what kind of device is that
that our current hints are not sufficient? Is the rate is so high
because the device is too noisy?
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-03-03 8:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-01 15:47 [PATCH] uinput: allow events per packet to be specified Alan Cox
2011-03-01 16:35 ` Aristeu Rozanski
2011-03-02 14:13 ` Henrik Rydberg
2011-03-02 16:06 ` Alan Cox
2011-03-02 17:13 ` Henrik Rydberg
2011-03-03 8:06 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).