[PATCH] Input: add flags bitfield - Kernel

This is a discussion on [PATCH] Input: add flags bitfield - Kernel ; Add a flags bitfield to the input_dev structure, which can be used for internal coordination among kernel input devices and input handlers without the need to use ever-expanding blacklists on the input handlers. Add initial flag bits which allows an ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: [PATCH] Input: add flags bitfield

  1. [PATCH] Input: add flags bitfield

    Add a flags bitfield to the input_dev structure, which can be used for
    internal coordination among kernel input devices and input handlers without
    the need to use ever-expanding blacklists on the input handlers.

    Add initial flag bits which allows an input driver to request that joystick
    emulation (joydev) or mouse emulation (mousedev) not be attached to an
    input device.

    This will be used by accelerometer drivers exporting a raw interface which
    is not to be used as a joystick device (not to confuse this with the usual
    fuzzed joystick interface these drivers export for enhanced Neverball
    productivity), for example.

    Signed-off-by: Henrique de Moraes Holschuh
    Cc: Dmitry Torokhov
    Cc: Richard Purdie
    ---
    drivers/input/joydev.c | 3 +++
    drivers/input/mousedev.c | 3 +++
    include/linux/input.h | 10 ++++++++++
    3 files changed, 16 insertions(+), 0 deletions(-)

    diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
    index 22b2789..3837389 100644
    --- a/drivers/input/joydev.c
    +++ b/drivers/input/joydev.c
    @@ -727,6 +727,9 @@ static int joydev_connect(struct input_handler *handler, struct input_dev *dev,
    int i, j, t, minor;
    int error;

    + if (dev->flags & EV_F_NOJOYSTICK)
    + return -ENODEV;
    +
    for (minor = 0; minor < JOYDEV_MINORS; minor++)
    if (!joydev_table[minor])
    break;
    diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
    index bbbe5e8..716975f 100644
    --- a/drivers/input/mousedev.c
    +++ b/drivers/input/mousedev.c
    @@ -962,6 +962,9 @@ static int mousedev_connect(struct input_handler *handler,
    int minor;
    int error;

    + if (dev->flags & EV_F_NOMOUSE)
    + return -ENODEV;
    +
    for (minor = 0; minor < MOUSEDEV_MINORS; minor++)
    if (!mousedev_table[minor])
    break;
    diff --git a/include/linux/input.h b/include/linux/input.h
    index 1bdc39a..a5654fe 100644
    --- a/include/linux/input.h
    +++ b/include/linux/input.h
    @@ -951,12 +951,20 @@ struct ff_effect {
    #include
    #include

    +/*
    + * input device special flags
    + */
    +
    +#define EV_F_NOMOUSE 0x0001 /* Do not attach mousedev */
    +#define EV_F_NOJOYSTICK 0x0002 /* Do not attach joydev */
    +
    /**
    * struct input_dev - represents an input device
    * @name: name of the device
    * @phys: physical path to the device in the system hierarchy
    * @uniq: unique identification code for the device (if device has it)
    * @id: id of the device (struct input_id)
    + * @flags: bitmap of special flags (EV_F_*)
    * @evbit: bitmap of types of events supported by the device (EV_KEY,
    * EV_REL, etc.)
    * @keybit: bitmap of keys/buttons this device has
    @@ -1034,6 +1042,8 @@ struct input_dev {
    const char *uniq;
    struct input_id id;

    + unsigned long flags;
    +
    unsigned long evbit[BITS_TO_LONGS(EV_CNT)];
    unsigned long keybit[BITS_TO_LONGS(KEY_CNT)];
    unsigned long relbit[BITS_TO_LONGS(REL_CNT)];
    --
    1.5.4.4

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

  2. Re: [PATCH] Input: add flags bitfield

    Hi Henrique,

    On Sun, Mar 16, 2008 at 05:14:11PM -0300, Henrique de Moraes Holschuh wrote:
    > Add a flags bitfield to the input_dev structure, which can be used for
    > internal coordination among kernel input devices and input handlers without
    > the need to use ever-expanding blacklists on the input handlers.
    >
    > Add initial flag bits which allows an input driver to request that joystick
    > emulation (joydev) or mouse emulation (mousedev) not be attached to an
    > input device.
    >
    > This will be used by accelerometer drivers exporting a raw interface which
    > is not to be used as a joystick device (not to confuse this with the usual
    > fuzzed joystick interface these drivers export for enhanced Neverball
    > productivity), for example.
    >


    I'd rather not apply this patch because it pushes kowledge of existing
    input interfaces into device drivers. What we could do instead is add
    a 'type' field to the input device structure and then input interfaces
    (evdev/mousedev, etc) could have an option of matching either by device
    type or by device capabilities or both. Your raw devices could have type
    of accelerometer and joydev would bind to devices with type "joystick"
    or "unknown" + certain capabilities. Will this work?

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

  3. Re: [PATCH] Input: add flags bitfield

    On Fri, 21 Mar 2008 16:07:01 -0400, "Dmitry Torokhov"
    said:
    > On Sun, Mar 16, 2008 at 05:14:11PM -0300, Henrique de Moraes Holschuh wrote:
    > > Add a flags bitfield to the input_dev structure, which can be used for
    > > internal coordination among kernel input devices and input handlers without
    > > the need to use ever-expanding blacklists on the input handlers.
    > >
    > > Add initial flag bits which allows an input driver to request that joystick
    > > emulation (joydev) or mouse emulation (mousedev) not be attached to an
    > > input device.
    > >
    > > This will be used by accelerometer drivers exporting a raw interface which
    > > is not to be used as a joystick device (not to confuse this with the usual
    > > fuzzed joystick interface these drivers export for enhanced Neverball
    > > productivity), for example.

    >
    > I'd rather not apply this patch because it pushes kowledge of existing
    > input interfaces into device drivers. What we could do instead is add
    > a 'type' field to the input device structure and then input interfaces
    > (evdev/mousedev, etc) could have an option of matching either by device
    > type or by device capabilities or both. Your raw devices could have type
    > of accelerometer and joydev would bind to devices with type "joystick"
    > or "unknown" + certain capabilities. Will this work?


    It would solve my problem, yes.

    But I'd prefer if joydev and mousedev did not bind to
    unknown+capabilities,
    just in case. Looks like bad form to me, and might bite us back later
    on.
    We can properly fix all drivers in-tree to have suitable types for
    joydev
    and/or mousedev binds, rfkill binds, and so on after all.

    What did I miss? Are there drivers for some sort of generic device that
    would be unable to set their type bitfields at runtime?

    BTW: as far as I can see, type should be a bitfield or a list, to allow
    a
    device to have more than one type. Is that fine with you?

    --
    "One disk to rule them all, One disk to find them. One disk to bring
    them all and in the darkness grind them. In the Land of Redmond
    where the shadows lie." -- The Silicon Valley Tarot
    Henrique Holschuh

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

  4. Re: [PATCH] Input: add flags bitfield

    On Fri, 21 Mar 2008, Henrique de Moraes Holschuh wrote:
    > On Fri, 21 Mar 2008 16:07:01 -0400, "Dmitry Torokhov"
    > said:
    > > On Sun, Mar 16, 2008 at 05:14:11PM -0300, Henrique de Moraes Holschuh wrote:
    > > > Add a flags bitfield to the input_dev structure, which can be used for
    > > > internal coordination among kernel input devices and input handlers without
    > > > the need to use ever-expanding blacklists on the input handlers.
    > > >
    > > > Add initial flag bits which allows an input driver to request that joystick
    > > > emulation (joydev) or mouse emulation (mousedev) not be attached to an
    > > > input device.
    > > >
    > > > This will be used by accelerometer drivers exporting a raw interface which
    > > > is not to be used as a joystick device (not to confuse this with the usual
    > > > fuzzed joystick interface these drivers export for enhanced Neverball
    > > > productivity), for example.

    > >
    > > I'd rather not apply this patch because it pushes kowledge of existing
    > > input interfaces into device drivers. What we could do instead is add
    > > a 'type' field to the input device structure and then input interfaces
    > > (evdev/mousedev, etc) could have an option of matching either by device
    > > type or by device capabilities or both. Your raw devices could have type
    > > of accelerometer and joydev would bind to devices with type "joystick"
    > > or "unknown" + certain capabilities. Will this work?

    >
    > It would solve my problem, yes.
    >
    > But I'd prefer if joydev and mousedev did not bind to
    > unknown+capabilities, just in case. Looks like bad form to me, and
    > might bite us back later on. We can properly fix all drivers in-tree
    > to have suitable types for joydev and/or mousedev binds, rfkill binds,
    > and so on after all.


    Drat, removing unknown+capabilities means I'd have to hunt down every
    frigging input device in the tree to annotate its type... otherwise, it
    would cause regressions re. the handlers. It is a work that needs to be
    done anyway, only adding type metadata to new devices and leaving the
    rest to report "unknown" is just icky.

    Come to think of it, what about uinput? It would need to be able to set
    the device type as well, otherwise mousedev and joydev, for example,
    would not attach to uinput-created input devices.

    --
    "One disk to rule them all, One disk to find them. One disk to bring
    them all and in the darkness grind them. In the Land of Redmond
    where the shadows lie." -- The Silicon Valley Tarot
    Henrique Holschuh
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. Re: [PATCH] Input: add flags bitfield

    On Saturday 22 March 2008, Henrique de Moraes Holschuh wrote:
    > On Fri, 21 Mar 2008, Henrique de Moraes Holschuh wrote:
    > > On Fri, 21 Mar 2008 16:07:01 -0400, "Dmitry Torokhov"
    > > said:
    > > > On Sun, Mar 16, 2008 at 05:14:11PM -0300, Henrique de Moraes Holschuh wrote:
    > > > > Add a flags bitfield to the input_dev structure, which can be used for
    > > > > internal coordination among kernel input devices and input handlers without
    > > > > the need to use ever-expanding blacklists on the input handlers.
    > > > >
    > > > > Add initial flag bits which allows an input driver to request that joystick
    > > > > emulation (joydev) or mouse emulation (mousedev) not be attached to an
    > > > > input device.
    > > > >
    > > > > This will be used by accelerometer drivers exporting a raw interface which
    > > > > is not to be used as a joystick device (not to confuse this with the usual
    > > > > fuzzed joystick interface these drivers export for enhanced Neverball
    > > > > productivity), for example.
    > > >
    > > > I'd rather not apply this patch because it pushes kowledge of existing
    > > > input interfaces into device drivers. What we could do instead is add
    > > > a 'type' field to the input device structure and then input interfaces
    > > > (evdev/mousedev, etc) could have an option of matching either by device
    > > > type or by device capabilities or both. Your raw devices could have type
    > > > of accelerometer and joydev would bind to devices with type "joystick"
    > > > or "unknown" + certain capabilities. Will this work?

    > >
    > > It would solve my problem, yes.
    > >
    > > But I'd prefer if joydev and mousedev did not bind to
    > > unknown+capabilities, just in case. Looks like bad form to me, and
    > > might bite us back later on. We can properly fix all drivers in-tree
    > > to have suitable types for joydev and/or mousedev binds, rfkill binds,
    > > and so on after all.


    Ohne word - HID.

    >
    > Drat, removing unknown+capabilities means I'd have to hunt down every
    > frigging input device in the tree to annotate its type... otherwise, it
    > would cause regressions re. the handlers. It is a work that needs to be
    > done anyway, only adding type metadata to new devices and leaving the
    > rest to report "unknown" is just icky.
    >
    > Come to think of it, what about uinput? It would need to be able to set
    > the device type as well, otherwise mousedev and joydev, for example,
    > would not attach to uinput-created input devices.
    >


    That's why I thinkg unmarked should really be default and only few selected
    devices should set their type.

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

  6. Re: [PATCH] Input: add flags bitfield

    On Sun, 23 Mar 2008, Dmitry Torokhov wrote:
    > On Saturday 22 March 2008, Henrique de Moraes Holschuh wrote:
    > > On Fri, 21 Mar 2008, Henrique de Moraes Holschuh wrote:
    > > > But I'd prefer if joydev and mousedev did not bind to
    > > > unknown+capabilities, just in case. Looks like bad form to me, and
    > > > might bite us back later on. We can properly fix all drivers in-tree
    > > > to have suitable types for joydev and/or mousedev binds, rfkill binds,
    > > > and so on after all.

    >
    > Ohne word - HID.


    Bleh. In that case, it will be too ugly to have it called a type, most
    of the input devices will have a type of "generic", which is at the very
    least damn ugly.

    > That's why I thinkg unmarked should really be default and only few selected
    > devices should set their type.


    I do think unmarked should be the default, and if it is so hard to have
    the emulation (and other handlers) ignore unmarked, we can leave that
    active by default as well. No problems here.

    What I don't like is to call it a "input device type", and have bits on
    it for joystick and mouse, which almost every mouse and joystick will
    NOT set.

    At that point, the difference between the bitfield with a handler
    whitelist (with blacklist all others implied, "Cisco ACL-style"), and a
    type bitfield is just in the name. The difference from what I already
    sent you would be the name, and inverted logic (I sent you a blacklist
    patch, not a whitelist patch).

    IMO, it doesn't make sense to leave people wondering why their HID
    devices (and most other input devices) have a type of "generic", when
    they indeed are mouses, joysticks, or whatever.

    Another approach would be to call the flags bitfield "emulation type",
    set it to "any" as default (all bits zeroed), add one bit for every
    emulation-style handler we add (e.g. mousedev and joydev, but not
    rfkill), and never bind a handler to a device which has that bitfield
    nonzero, unless it has the emulation bit for that handler set.

    Do you *really* want a device type bitfield?

    --
    "One disk to rule them all, One disk to find them. One disk to bring
    them all and in the darkness grind them. In the Land of Redmond
    where the shadows lie." -- The Silicon Valley Tarot
    Henrique Holschuh
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread