All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Colenbrander, Roelof" <Roderick.Colenbrander@sony.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "roderick@gaikai.com" <roderick@gaikai.com>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	Benjamin Tissoires <benjamin.tissoires@redhat.com>,
	Jiri Kosina <jikos@kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH 1/1] Input: joydev - blacklist ds3/ds4/udraw motion sensors
Date: Tue, 17 Oct 2017 00:48:57 +0000	[thread overview]
Message-ID: <1DD62093774CEE42AFC16E785A1088049E206CA3@USCULXMSG13.am.sony.com> (raw)
In-Reply-To: 20171013235044.thyp7bajww7j62pr@dtor-ws

Hi Dmitry,

I would like to confirm that the changes are working correctly. The code 
looked code before, but hadn't validated the changes yet. We did so 
today and things work accordingly, so I think it is ready to merge.

Thanks for the help!

Thanks,
Roderick


On 10/13/2017 04:50 PM, Dmitry Torokhov wrote:
> Hi Roderick,
> 
> On Wed, Oct 11, 2017 at 12:53:53AM +0000, Colenbrander, Roelof wrote:
>> Hi Dmitry,
>>
>> Thanks for your suggestions the feedback looks good. Just got back to office after a long weekend, then was surprised to see you already made a few changes to the series. The changes look. Thanks for the assistance!
>>
> 
> OK, if that works for you then I will queue it up.
> 
> Thanks.
> 
>> Thanks,
>> Roderick
>> ________________________________________
>> From: Dmitry Torokhov [dmitry.torokhov@gmail.com]
>> Sent: Saturday, October 07, 2017 11:44 AM
>> To: roderick@gaikai.com
>> Cc: linux-input@vger.kernel.org; Benjamin Tissoires; Jiri Kosina; Colenbrander, Roelof; stable@vger.kernel.org
>> Subject: Re: [PATCH 1/1] Input: joydev - blacklist ds3/ds4/udraw motion sensors
>>
>> Hi Roderick,
>>
>> On Thu, Oct 05, 2017 at 06:03:33PM -0700, Roderick Colenbrander wrote:
>>> From: Roderick Colenbrander <roderick.colenbrander@sony.com>
>>>
>>> Introduce a device table used for blacklisting devices. We currently
>>> blacklist the motion sensor subdevice of THQ Udraw and Sony ds3/ds4.
>>>
>>> Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
>>> Cc: stable@vger.kernel.org
>>> ---
>>>   drivers/input/joydev.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
>>>   1 file changed, 57 insertions(+)
>>>
>>> diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c
>>> index 29d677c714d2..e2a0f63d5656 100644
>>> --- a/drivers/input/joydev.c
>>> +++ b/drivers/input/joydev.c
>>> @@ -70,6 +70,40 @@ struct joydev_client {
>>>        struct list_head node;
>>>   };
>>>
>>> +/* These codes are copied from from hid-ids.h, unfortunately there is no common
>>> + * usb_ids/bt_ids.h header.
>>> + */
>>> +#define USB_VENDOR_ID_SONY 0x54c
>>> +#define USB_VENDOR_ID_THQ            0x20d6
>>> +#define USB_DEVICE_ID_SONY_PS3_CONTROLLER    0x0268
>>> +#define USB_DEVICE_ID_SONY_PS4_CONTROLLER    0x05c4
>>> +#define USB_DEVICE_ID_SONY_PS4_CONTROLLER_2  0x09cc
>>> +#define USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE     0x0ba0
>>> +#define USB_DEVICE_ID_THQ_PS3_UDRAW  0xcb17
>>> +
>>> +/* List of devices blacklisted from joydev. A reason for blacklisting a
>>> + * device is to support (legacy) software supporting joydev, but which will
>>> + * never get updated to support these devices or features. An example would
>>> + * be handling of motion sensors, which these applications could not handle
>>> + * resulting in undefined behavior.
>>> + */
>>> +static const struct joydev_blacklist {
>>> +     __u16 bustype;
>>> +     __u16 vendor;
>>> +     __u16 product;
>>> +     unsigned long propbit; /* Allow for filtering based on device properties. */
>>> +} joydev_blacklist[] = {
>>> +     { BUS_BLUETOOTH, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, BIT(INPUT_PROP_ACCELEROMETER) },
>>> +     { BUS_BLUETOOTH, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER, BIT(INPUT_PROP_ACCELEROMETER) },
>>> +     { BUS_BLUETOOTH, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2, BIT(INPUT_PROP_ACCELEROMETER) },
>>> +     { BUS_USB, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER, BIT(INPUT_PROP_ACCELEROMETER) },
>>> +     { BUS_USB, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER, BIT(INPUT_PROP_ACCELEROMETER) },
>>> +     { BUS_USB, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2, BIT(INPUT_PROP_ACCELEROMETER) },
>>> +     { BUS_USB, USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE, BIT(INPUT_PROP_ACCELEROMETER) },
>>> +     { BUS_USB, USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW, BIT(INPUT_PROP_ACCELEROMETER) },
>>> +     { 0, 0, 0, 0}
>>
>> I would assume that regardless of connection (USB, BT, SPI, I2C, the
>> accelerometer in PS4 controller should not be handled by joydev.  I
>> wonder if we should not factor out input device id matching from
>> input_match_device(), add propbit handling to input device id and use it
>> here? Then your blacklist would be:
>>
>> #define ACCEL_DEV(vendor, product)                              \
>>          {                                                               \
>>                  .flags          = INPUT_DEVICE_ID_MATCH_VENDOR |        \
>>                                          INPUT_DEVICE_ID_MATCH_PRODUCT | \
>>                                          INPUT_DEVICE_ID_MATCH_PROPBIT,  \
>>                  .vendor         = (vendor),                             \
>>                  .product        = (product),                            \
>>                  .propbit[0]     = BIT(INPUT_PROP_ACCELEROMETER),        \
>>          }
>>
>> static const struct input_device_id joydev_blacklist {
>>          ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER),
>>          ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER),
>>          ...
>>          { }
>> };
>>
>>> +};
>>> +
>>>   static int joydev_correct(int value, struct js_corr *corr)
>>>   {
>>>        switch (corr->type) {
>>> @@ -805,6 +839,25 @@ static bool joydev_dev_is_absolute_mouse(struct input_dev *dev)
>>>        return true;
>>>   }
>>>
>>> +
>>> +static bool joydev_dev_is_blacklisted(struct input_dev *dev)
>>> +{
>>> +     int i;
>>> +
>>> +     for (i = 0; joydev_blacklist[i].vendor; i++) {
>>> +             if (dev->id.bustype == joydev_blacklist[i].bustype &&
>>> +                 dev->id.vendor == joydev_blacklist[i].vendor &&
>>> +                 dev->id.product == joydev_blacklist[i].product &&
>>> +                 dev->propbit[0] == joydev_blacklist[i].propbit)
>>
>> You probably want "&" and not strict match?
>>
>>> +             {
>>> +                     dev_info(&dev->dev, "joydev: Blacklisting '%s'\n", dev->name);
>>> +                     return true;
>>> +             }
>>> +     }
>>> +
>>> +     return false;
>>> +}
>>> +
>>>   static bool joydev_match(struct input_handler *handler, struct input_dev *dev)
>>>   {
>>>        /* Avoid touchpads and touchscreens */
>>> @@ -819,6 +872,10 @@ static bool joydev_match(struct input_handler *handler, struct input_dev *dev)
>>>        if (joydev_dev_is_absolute_mouse(dev))
>>>                return false;
>>>
>>> +     /* Disable blacklisted devices */
>>> +     if (joydev_dev_is_blacklisted(dev))
>>> +             return false;
>>> +
>>>        return true;
>>>   }
>>>
>>> --
>>> 2.13.6
>>>
>>
>> Thanks.
>>
>> --
>> Dmitry
>>
> 


      reply	other threads:[~2017-10-17  0:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-06  1:03 [PATCH 0/1] Input: joydev blacklist feature Roderick Colenbrander
2017-10-06  1:03 ` [PATCH 1/1] Input: joydev - blacklist ds3/ds4/udraw motion sensors Roderick Colenbrander
2017-10-07 18:44   ` Dmitry Torokhov
2017-10-11  0:53     ` Colenbrander, Roelof
2017-10-13 23:50       ` Dmitry Torokhov
2017-10-17  0:48         ` Colenbrander, Roelof [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1DD62093774CEE42AFC16E785A1088049E206CA3@USCULXMSG13.am.sony.com \
    --to=roderick.colenbrander@sony.com \
    --cc=benjamin.tissoires@redhat.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=jikos@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=roderick@gaikai.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.