Re: [RFC] Input: introduce ABS_MAX2/CNT2 and friends

From: David Herrmann
Date: Mon Oct 07 2013 - 06:58:24 EST


Hi

On Mon, Oct 7, 2013 at 3:30 AM, Peter Hutterer <peter.hutterer@xxxxxxxxx> wrote:
> On Sun, Oct 06, 2013 at 05:04:36PM -0700, Dmitry Torokhov wrote:
>> Peter Hutterer <peter.hutterer@xxxxxxxxx> wrote:
>> >On Sun, Oct 06, 2013 at 12:47:00AM -0700, Dmitry Torokhov wrote:
>> >> On Fri, Oct 04, 2013 at 09:32:23AM +1000, Peter Hutterer wrote:
>> >> > On Thu, Oct 03, 2013 at 12:10:36AM +0200, David Herrmann wrote:
>> >> > > As we painfully noticed during the 3.12 merge-window our
>> >> > > EVIOCGABS/EVIOCSABS API is limited to ABS_MAX<=0x3f. We tried
>> >several
>> >> > > hacks to work around it but if we ever decide to increase
>> >ABS_MAX, the
>> >> > > EVIOCSABS ioctl ABI might overflow into the next byte causing
>> >horrible
>> >> > > misinterpretations in the kernel that we cannot catch.
>> >> > >
>> >> > > Therefore, we decided to go with ABS_MAX2/CNT2 and introduce two
>> >new
>> >> > > ioctls to get/set abs-params. They no longer encode the ABS code
>> >in the
>> >> > > ioctl number and thus allow up to 4 billion ABS codes.
>> >> > >
>> >> > > Unfortunately, the uinput API also hard-coded the ABS_CNT value
>> >in its
>> >> > > ABI. To avoid any hacks in uinput, we simply introduce a new
>> >> > > uinput_user_dev2 to replace the old one. The new API allows
>> >growing
>> >> > > ABS_CNT2 values without any API changes.
>> >> > >
>> >> > > Signed-off-by: David Herrmann <dh.herrmann@xxxxxxxxx>
>> >> > > ---
>> >> > > Hi
>> >> > >
>> >> > > This is only compile-tested but I wanted to get a first revision
>> >out to let
>> >> > > people know what we're working on. Unfortunately, the ABS API has
>> >this horribly
>> >> > > low ABS_MAX limit and we couldn't figure out a way to increase it
>> >while keeping
>> >> > > ABI compatibility.
>> >> > >
>> >> > > Any feedback and review is welcome. And if anyone spots ABI
>> >breakage by this
>> >> > > patch, please let me know. If nothing comes up I will patch
>> >libevdev to use the
>> >> > > new API, write some extensive test-cases and push this forward.
>> >> > >
>> >> > > As a sidenote: I didn't modify joydev to use the new values.
>> >Fortunately, the
>> >> > > joydev API would allow switching to ABS_CNT2 without breaking
>> >API, but it would
>> >> > > limit the new ABS_CNT2 to 16k. This is quite high but nothing
>> >compared to the
>> >> > > 2^32 that we can theoretically support now. If you think 16k
>> >ought to be enough
>> >> > > (probably?) I can adjust the joydev API, too.
>> >> > > All other kernel users were converted to the new values. Nothing
>> >left behind..
>> >> >
>> >> >
>> >> > just a comment from skimming the patch:
>> >> > if you need a new uinput abi anyway, can we add the resolution
>> >here? it's
>> >> > sorely needed for some tests. see also the patch Benjamin sent a
>> >while ago
>> >> > ("input/uinput: support abs resolution", July 15 2013)
>> >>
>> >> Indeed. Also, while we are at it, would it make sense to allow
>> >> requesting a range of ABS infos at once?
>> >
>> >yes, but what API did you have in mind?
>> >
>>
>> I was thinking about specifying the start ABS but and the count and array of absinfo structures to be filled.
>
> yeah, that works for me (I suspect 90% of users will use ABS_MAX anyway :)

And how exactly should this look like? Like this:

#define EVIOCGABS2(cnt) _IOR('E', 0x92, struct
input_absinfo2 * (cnt))

Or like this:

struct input_absinfo3 {
size_t cnt;
struct input_absinfo2[];
};

#define EVIOCGABS2 _IOR('E', 0x92, struct input_absinfo3)

btw., resolution added and uinput changes split off into separate patch.

Thanks
David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/