[Patch-V2,1/6] INPUT: xpad: Add minimal support for Logitech G920 Wheel
diff mbox

Message ID 1447345535-2912-2-git-send-email-simon@mungewell.org
State Superseded
Headers show

Commit Message

simon@mungewell.org Nov. 12, 2015, 4:25 p.m. UTC
When plugged in the Logitech G920 wheel starts with USBID 046d:c261
and behaviors as a vendor specific class. If a 'magic' byte sequence
is sent the wheel will detach and reconnect as a HID device with the
USBID 046d:c262.

Signed-off-by: Simon Wood <simon@mungewell.org>
---
 drivers/input/joystick/xpad.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Jiri Kosina Nov. 19, 2015, 1:50 p.m. UTC | #1
On Thu, 12 Nov 2015, Simon Wood wrote:

> When plugged in the Logitech G920 wheel starts with USBID 046d:c261
> and behaviors as a vendor specific class. If a 'magic' byte sequence
> is sent the wheel will detach and reconnect as a HID device with the
> USBID 046d:c262.
> 
> Signed-off-by: Simon Wood <simon@mungewell.org>

Adding Dmitry to CC.

Dmitry, I am planning to take this through my tree together with the rest 
of the actual HID support for that device if you Ack this.

Thanks,
Dmitry Torokhov Nov. 19, 2015, 6:31 p.m. UTC | #2
On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:
> On Thu, 12 Nov 2015, Simon Wood wrote:
> 
> > When plugged in the Logitech G920 wheel starts with USBID 046d:c261
> > and behaviors as a vendor specific class. If a 'magic' byte sequence
> > is sent the wheel will detach and reconnect as a HID device with the
> > USBID 046d:c262.
> > 
> > Signed-off-by: Simon Wood <simon@mungewell.org>
> 
> Adding Dmitry to CC.
> 
> Dmitry, I am planning to take this through my tree together with the rest 
> of the actual HID support for that device if you Ack this.

Hmm, I have an incoming series for xbox that night clash with this... If
you'll put it in a clean branch off 4.3 I'd pull it and then get more
changes on top.

Can we also change the subject as it is not about adding a minimal
support. Something like "Input: xpad - switch Logitech G920 Wheel into
HID mode"

Otherwise:

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Thanks.
simon@mungewell.org Nov. 19, 2015, 6:35 p.m. UTC | #3
On Thu, November 19, 2015 11:31 am, Dmitry Torokhov wrote:
> On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:
>
>> On Thu, 12 Nov 2015, Simon Wood wrote:
>>
>>
>>> When plugged in the Logitech G920 wheel starts with USBID 046d:c261
>>> and behaviors as a vendor specific class. If a 'magic' byte sequence is
>>> sent the wheel will detach and reconnect as a HID device with the
>>> USBID 046d:c262.
>>>
>>>
>>> Signed-off-by: Simon Wood <simon@mungewell.org>
>>>
>>
>> Adding Dmitry to CC.
>>
>>
>> Dmitry, I am planning to take this through my tree together with the
>> rest of the actual HID support for that device if you Ack this.
>
> Hmm, I have an incoming series for xbox that night clash with this... If
> you'll put it in a clean branch off 4.3 I'd pull it and then get more
> changes on top.
>
> Can we also change the subject as it is not about adding a minimal
> support. Something like "Input: xpad - switch Logitech G920 Wheel into HID
> mode"

Will spin a 'v3' with this and Benjamin's suggestion.

Cheers,
Simon.

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Edwin Nov. 19, 2015, 11:19 p.m. UTC | #4
On 19-11-15 19:35, Simon Wood wrote:
> On Thu, November 19, 2015 11:31 am, Dmitry Torokhov wrote:
> > On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:
> >
> >> On Thu, 12 Nov 2015, Simon Wood wrote:
> >>
> >>
> >>> When plugged in the Logitech G920 wheel starts with USBID 046d:c261
> >>> and behaviors as a vendor specific class. If a 'magic' byte sequence is
> >>> sent the wheel will detach and reconnect as a HID device with the
> >>> USBID 046d:c262.
> >>>
> >>>
> >>> Signed-off-by: Simon Wood <simon@mungewell.org>
> >>>
> >>
> >> Adding Dmitry to CC.
> >>
> >>
> >> Dmitry, I am planning to take this through my tree together with the
> >> rest of the actual HID support for that device if you Ack this.
> >
> > Hmm, I have an incoming series for xbox that night clash with this... If
> > you'll put it in a clean branch off 4.3 I'd pull it and then get more
> > changes on top.
> >
> > Can we also change the subject as it is not about adding a minimal
> > support. Something like "Input: xpad - switch Logitech G920 Wheel into HID
> > mode"
>
> Will spin a 'v3' with this and Benjamin's suggestion.
>
> Cheers,
> Simon.
>

I'll put out the force feedback patch right (or as close as I can) after v3.

Edwin

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov Dec. 10, 2015, 1:23 a.m. UTC | #5
On Thu, Nov 19, 2015 at 10:31 AM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:
>> On Thu, 12 Nov 2015, Simon Wood wrote:
>>
>> > When plugged in the Logitech G920 wheel starts with USBID 046d:c261
>> > and behaviors as a vendor specific class. If a 'magic' byte sequence
>> > is sent the wheel will detach and reconnect as a HID device with the
>> > USBID 046d:c262.
>> >
>> > Signed-off-by: Simon Wood <simon@mungewell.org>
>>
>> Adding Dmitry to CC.
>>
>> Dmitry, I am planning to take this through my tree together with the rest
>> of the actual HID support for that device if you Ack this.
>
> Hmm, I have an incoming series for xbox that night clash with this... If
> you'll put it in a clean branch off 4.3 I'd pull it and then get more
> changes on top.
>
> Can we also change the subject as it is not about adding a minimal
> support. Something like "Input: xpad - switch Logitech G920 Wheel into
> HID mode"
>
> Otherwise:
>
> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Hmm, looking sat this some more why are we waiting to switch device
mode until after userspace opens input device instead of when we are
executing driver probe()?

Thanks.
Dmitry Torokhov Dec. 10, 2015, 1:39 a.m. UTC | #6
On Wed, Dec 9, 2015 at 5:23 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Thu, Nov 19, 2015 at 10:31 AM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
>> On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:
>>> On Thu, 12 Nov 2015, Simon Wood wrote:
>>>
>>> > When plugged in the Logitech G920 wheel starts with USBID 046d:c261
>>> > and behaviors as a vendor specific class. If a 'magic' byte sequence
>>> > is sent the wheel will detach and reconnect as a HID device with the
>>> > USBID 046d:c262.
>>> >
>>> > Signed-off-by: Simon Wood <simon@mungewell.org>
>>>
>>> Adding Dmitry to CC.
>>>
>>> Dmitry, I am planning to take this through my tree together with the rest
>>> of the actual HID support for that device if you Ack this.
>>
>> Hmm, I have an incoming series for xbox that night clash with this... If
>> you'll put it in a clean branch off 4.3 I'd pull it and then get more
>> changes on top.
>>
>> Can we also change the subject as it is not about adding a minimal
>> support. Something like "Input: xpad - switch Logitech G920 Wheel into
>> HID mode"
>>
>> Otherwise:
>>
>> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>
> Hmm, looking sat this some more why are we waiting to switch device
> mode until after userspace opens input device instead of when we are
> executing driver probe()?
>

Actually, thinking about it even more, why do we want to have this in
xpad.c? Have HID module handle both IDs and switch to HID mode if we
want HID to handle this device. I think we should revert/drop this
patch.

Thanks.
Benjamin Tissoires Dec. 10, 2015, 5:08 p.m. UTC | #7
On Dec 09 2015 or thereabouts, Dmitry Torokhov wrote:
> On Wed, Dec 9, 2015 at 5:23 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > On Thu, Nov 19, 2015 at 10:31 AM, Dmitry Torokhov
> > <dmitry.torokhov@gmail.com> wrote:
> >> On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:
> >>> On Thu, 12 Nov 2015, Simon Wood wrote:
> >>>
> >>> > When plugged in the Logitech G920 wheel starts with USBID 046d:c261
> >>> > and behaviors as a vendor specific class. If a 'magic' byte sequence
> >>> > is sent the wheel will detach and reconnect as a HID device with the
> >>> > USBID 046d:c262.
> >>> >
> >>> > Signed-off-by: Simon Wood <simon@mungewell.org>
> >>>
> >>> Adding Dmitry to CC.
> >>>
> >>> Dmitry, I am planning to take this through my tree together with the rest
> >>> of the actual HID support for that device if you Ack this.
> >>
> >> Hmm, I have an incoming series for xbox that night clash with this... If
> >> you'll put it in a clean branch off 4.3 I'd pull it and then get more
> >> changes on top.
> >>
> >> Can we also change the subject as it is not about adding a minimal
> >> support. Something like "Input: xpad - switch Logitech G920 Wheel into
> >> HID mode"
> >>
> >> Otherwise:
> >>
> >> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >
> > Hmm, looking sat this some more why are we waiting to switch device
> > mode until after userspace opens input device instead of when we are
> > executing driver probe()?
> >
> 
> Actually, thinking about it even more, why do we want to have this in
> xpad.c? Have HID module handle both IDs and switch to HID mode if we
> want HID to handle this device. I think we should revert/drop this
> patch.
> 

Hi Dmitry,

IIRC, last time I saw an XBox-like controller, it doesn't register as a
HID device at all. SO I think It will be hard to switch it into the HID
mode from HID directly.
Simon, can you confirm that the device does not contains any references
to HID while in the XBox mode (lsusb -v should give enough information).

Switching the device during probe in xpad.c makes a lot of sense
however.

Cheers,
Benjamin
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov Dec. 10, 2015, 6:40 p.m. UTC | #8
On Thu, Dec 10, 2015 at 9:08 AM, Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
> On Dec 09 2015 or thereabouts, Dmitry Torokhov wrote:
>> On Wed, Dec 9, 2015 at 5:23 PM, Dmitry Torokhov
>> <dmitry.torokhov@gmail.com> wrote:
>> > On Thu, Nov 19, 2015 at 10:31 AM, Dmitry Torokhov
>> > <dmitry.torokhov@gmail.com> wrote:
>> >> On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:
>> >>> On Thu, 12 Nov 2015, Simon Wood wrote:
>> >>>
>> >>> > When plugged in the Logitech G920 wheel starts with USBID 046d:c261
>> >>> > and behaviors as a vendor specific class. If a 'magic' byte sequence
>> >>> > is sent the wheel will detach and reconnect as a HID device with the
>> >>> > USBID 046d:c262.
>> >>> >
>> >>> > Signed-off-by: Simon Wood <simon@mungewell.org>
>> >>>
>> >>> Adding Dmitry to CC.
>> >>>
>> >>> Dmitry, I am planning to take this through my tree together with the rest
>> >>> of the actual HID support for that device if you Ack this.
>> >>
>> >> Hmm, I have an incoming series for xbox that night clash with this... If
>> >> you'll put it in a clean branch off 4.3 I'd pull it and then get more
>> >> changes on top.
>> >>
>> >> Can we also change the subject as it is not about adding a minimal
>> >> support. Something like "Input: xpad - switch Logitech G920 Wheel into
>> >> HID mode"
>> >>
>> >> Otherwise:
>> >>
>> >> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> >
>> > Hmm, looking sat this some more why are we waiting to switch device
>> > mode until after userspace opens input device instead of when we are
>> > executing driver probe()?
>> >
>>
>> Actually, thinking about it even more, why do we want to have this in
>> xpad.c? Have HID module handle both IDs and switch to HID mode if we
>> want HID to handle this device. I think we should revert/drop this
>> patch.
>>
>
> Hi Dmitry,

Hi Benjamin,

>
> IIRC, last time I saw an XBox-like controller, it doesn't register as a
> HID device at all. SO I think It will be hard to switch it into the HID
> mode from HID directly.
> Simon, can you confirm that the device does not contains any references
> to HID while in the XBox mode (lsusb -v should give enough information).
>
> Switching the device during probe in xpad.c makes a lot of sense
> however.

It makes as much sense doing it in xpad as doing it from a random USB
network driver. I mean the only reason we are doing it from xpad is
because of name and the fat that it has usb_driver structure. Nobody
stops you from creating a tiny USB stub driver in hid portion that
would probe the "non-hid" device and switch it over to hid.

Thanks.
Elias Vanderstuyft Dec. 13, 2015, 12:50 p.m. UTC | #9
On Thu, Dec 10, 2015 at 6:08 PM, Benjamin Tissoires
<benjamin.tissoires@redhat.com> wrote:
> On Dec 09 2015 or thereabouts, Dmitry Torokhov wrote:
>> On Wed, Dec 9, 2015 at 5:23 PM, Dmitry Torokhov
>> <dmitry.torokhov@gmail.com> wrote:
>> > On Thu, Nov 19, 2015 at 10:31 AM, Dmitry Torokhov
>> > <dmitry.torokhov@gmail.com> wrote:
>> >> On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:
>> >>> On Thu, 12 Nov 2015, Simon Wood wrote:
>> >>>
>> >>> > When plugged in the Logitech G920 wheel starts with USBID 046d:c261
>> >>> > and behaviors as a vendor specific class. If a 'magic' byte sequence
>> >>> > is sent the wheel will detach and reconnect as a HID device with the
>> >>> > USBID 046d:c262.
>> >>> >
>> >>> > Signed-off-by: Simon Wood <simon@mungewell.org>
>> >>>
>> >>> Adding Dmitry to CC.
>> >>>
>> >>> Dmitry, I am planning to take this through my tree together with the rest
>> >>> of the actual HID support for that device if you Ack this.
>> >>
>> >> Hmm, I have an incoming series for xbox that night clash with this... If
>> >> you'll put it in a clean branch off 4.3 I'd pull it and then get more
>> >> changes on top.
>> >>
>> >> Can we also change the subject as it is not about adding a minimal
>> >> support. Something like "Input: xpad - switch Logitech G920 Wheel into
>> >> HID mode"
>> >>
>> >> Otherwise:
>> >>
>> >> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> >
>> > Hmm, looking sat this some more why are we waiting to switch device
>> > mode until after userspace opens input device instead of when we are
>> > executing driver probe()?
>> >
>>
>> Actually, thinking about it even more, why do we want to have this in
>> xpad.c? Have HID module handle both IDs and switch to HID mode if we
>> want HID to handle this device. I think we should revert/drop this
>> patch.
>>
>
> Hi Dmitry,
>
> IIRC, last time I saw an XBox-like controller, it doesn't register as a
> HID device at all. SO I think It will be hard to switch it into the HID
> mode from HID directly.
> Simon, can you confirm that the device does not contains any references
> to HID while in the XBox mode (lsusb -v should give enough information).

This is probably not relevant anymore, but here is the "sudo lsusb -v"
output of my G920 in XBox mode:

Bus 001 Device 121: ID 046d:c261 Logitech, Inc.
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          255 Vendor Specific Class
  bDeviceSubClass       255 Vendor Specific Subclass
  bDeviceProtocol       255 Vendor Specific Protocol
  bMaxPacketSize0        64
  idVendor           0x046d Logitech, Inc.
  idProduct          0xc261
  bcdDevice           96.01
  iManufacturer           1 Logitech
  iProduct                2 G920 Driving Force Racing Wheel for Xbox One
  iSerial                 3 000072fb6b3b9f58
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass     71
      bInterfaceProtocol    208
      iInterface              0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               4
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               4
Device Status:     0x0002
  (Bus Powered)
  Remote Wakeup Enabled
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Benjamin Tissoires Jan. 4, 2016, 9:55 a.m. UTC | #10
On Dec 10 2015 or thereabouts, Dmitry Torokhov wrote:
> On Thu, Dec 10, 2015 at 9:08 AM, Benjamin Tissoires
> <benjamin.tissoires@redhat.com> wrote:
> > On Dec 09 2015 or thereabouts, Dmitry Torokhov wrote:
> >> On Wed, Dec 9, 2015 at 5:23 PM, Dmitry Torokhov
> >> <dmitry.torokhov@gmail.com> wrote:
> >> > On Thu, Nov 19, 2015 at 10:31 AM, Dmitry Torokhov
> >> > <dmitry.torokhov@gmail.com> wrote:
> >> >> On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:
> >> >>> On Thu, 12 Nov 2015, Simon Wood wrote:
> >> >>>
> >> >>> > When plugged in the Logitech G920 wheel starts with USBID 046d:c261
> >> >>> > and behaviors as a vendor specific class. If a 'magic' byte sequence
> >> >>> > is sent the wheel will detach and reconnect as a HID device with the
> >> >>> > USBID 046d:c262.
> >> >>> >
> >> >>> > Signed-off-by: Simon Wood <simon@mungewell.org>
> >> >>>
> >> >>> Adding Dmitry to CC.
> >> >>>
> >> >>> Dmitry, I am planning to take this through my tree together with the rest
> >> >>> of the actual HID support for that device if you Ack this.
> >> >>
> >> >> Hmm, I have an incoming series for xbox that night clash with this... If
> >> >> you'll put it in a clean branch off 4.3 I'd pull it and then get more
> >> >> changes on top.
> >> >>
> >> >> Can we also change the subject as it is not about adding a minimal
> >> >> support. Something like "Input: xpad - switch Logitech G920 Wheel into
> >> >> HID mode"
> >> >>
> >> >> Otherwise:
> >> >>
> >> >> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> >> >
> >> > Hmm, looking sat this some more why are we waiting to switch device
> >> > mode until after userspace opens input device instead of when we are
> >> > executing driver probe()?
> >> >
> >>
> >> Actually, thinking about it even more, why do we want to have this in
> >> xpad.c? Have HID module handle both IDs and switch to HID mode if we
> >> want HID to handle this device. I think we should revert/drop this
> >> patch.
> >>
> >
> > Hi Dmitry,
> 
> Hi Benjamin,
> 
> >
> > IIRC, last time I saw an XBox-like controller, it doesn't register as a
> > HID device at all. SO I think It will be hard to switch it into the HID
> > mode from HID directly.
> > Simon, can you confirm that the device does not contains any references
> > to HID while in the XBox mode (lsusb -v should give enough information).
> >
> > Switching the device during probe in xpad.c makes a lot of sense
> > however.
> 
> It makes as much sense doing it in xpad as doing it from a random USB
> network driver. I mean the only reason we are doing it from xpad is
> because of name and the fat that it has usb_driver structure. Nobody
> stops you from creating a tiny USB stub driver in hid portion that
> would probe the "non-hid" device and switch it over to hid.
> 

Jiri, I *think* this commit still is in your next pull request for
Linus. We might want to drop it before it hits Linus' tree.

We can still keep the HID work in place even if the device is not
switched into the HID protocol at plug.

Simon, do you mind looking into Dmitry's suggestion of having a clean,
small usb device which loads itself when the G920 is plugged in and
switches it immediately into the HID mode?

Cheers,
Benjamin



--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Malý Jan. 4, 2016, 12:43 p.m. UTC | #11
On Mon Jan 4 10:55:24 2016 GMT+0100, Benjamin Tissoires wrote:
> On Dec 10 2015 or thereabouts, Dmitry Torokhov wrote:

> > On Thu, Dec 10, 2015 at 9:08 AM, Benjamin Tissoires

> > <benjamin.tissoires@redhat.com> wrote:

> > > On Dec 09 2015 or thereabouts, Dmitry Torokhov wrote:

> > >> On Wed, Dec 9, 2015 at 5:23 PM, Dmitry Torokhov

> > >> <dmitry.torokhov@gmail.com> wrote:

> > >> > On Thu, Nov 19, 2015 at 10:31 AM, Dmitry Torokhov

> > >> > <dmitry.torokhov@gmail.com> wrote:

> > >> >> On Thu, Nov 19, 2015 at 02:50:51PM +0100, Jiri Kosina wrote:

> > >> >>> On Thu, 12 Nov 2015, Simon Wood wrote:

> > >> >>>

> > >> >>> > When plugged in the Logitech G920 wheel starts with USBID 046d:c261

> > >> >>> > and behaviors as a vendor specific class. If a 'magic' byte sequence

> > >> >>> > is sent the wheel will detach and reconnect as a HID device with the

> > >> >>> > USBID 046d:c262.

> > >> >>> >

> > >> >>> > Signed-off-by: Simon Wood <simon@mungewell.org>

> > >> >>>

> > >> >>> Adding Dmitry to CC.

> > >> >>>

> > >> >>> Dmitry, I am planning to take this through my tree together with the rest

> > >> >>> of the actual HID support for that device if you Ack this.

> > >> >>

> > >> >> Hmm, I have an incoming series for xbox that night clash with this... If

> > >> >> you'll put it in a clean branch off 4.3 I'd pull it and then get more

> > >> >> changes on top.

> > >> >>

> > >> >> Can we also change the subject as it is not about adding a minimal

> > >> >> support. Something like "Input: xpad - switch Logitech G920 Wheel into

> > >> >> HID mode"

> > >> >>

> > >> >> Otherwise:

> > >> >>

> > >> >> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> > >> >

> > >> > Hmm, looking sat this some more why are we waiting to switch device

> > >> > mode until after userspace opens input device instead of when we are

> > >> > executing driver probe()?

> > >> >

> > >>

> > >> Actually, thinking about it even more, why do we want to have this in

> > >> xpad.c? Have HID module handle both IDs and switch to HID mode if we

> > >> want HID to handle this device. I think we should revert/drop this

> > >> patch.

> > >>

> > >

> > > Hi Dmitry,

> > 

> > Hi Benjamin,

> > 

> > >

> > > IIRC, last time I saw an XBox-like controller, it doesn't register as a

> > > HID device at all. SO I think It will be hard to switch it into the HID

> > > mode from HID directly.

> > > Simon, can you confirm that the device does not contains any references

> > > to HID while in the XBox mode (lsusb -v should give enough information).

> > >

> > > Switching the device during probe in xpad.c makes a lot of sense

> > > however.

> > 

> > It makes as much sense doing it in xpad as doing it from a random USB

> > network driver. I mean the only reason we are doing it from xpad is

> > because of name and the fat that it has usb_driver structure. Nobody

> > stops you from creating a tiny USB stub driver in hid portion that

> > would probe the "non-hid" device and switch it over to hid.

> > 

> 

> Jiri, I *think* this commit still is in your next pull request for

> Linus. We might want to drop it before it hits Linus' tree.

> 

> We can still keep the HID work in place even if the device is not

> switched into the HID protocol at plug.

> 

> Simon, do you mind looking into Dmitry's suggestion of having a clean,

> small usb device which loads itself when the G920 is plugged in and

> switches it immediately into the HID mode?

> 

> Cheers,

> Benjamin

> 


Hi guys,

since I feel pretty bad for not contributing to the project (too much PhD stuff) I'd gladly look into the USB stub driver is Simon is too buys or otherwise unable to do it himself. If I understand the issue the idea is to have a simple module that would pick up a device that at first appears as a generic USB device, do the necessary initialization and let the device-specific driver take over from there?

Michal
Dmitry Torokhov Jan. 5, 2016, 1:01 a.m. UTC | #12
Hi Simon,

On Mon, Jan 04, 2016 at 01:05:35PM -0700, Simon Wood wrote:
> 
> On Mon, 4 Jan 2016 02:55:24 -0700, Benjamin Tissoires wrote:
> your next pull request for
> > Linus. We might want to drop it before it hits Linus' tree.
> > 
> > We can still keep the HID work in place even if the device is not
> > switched into the HID protocol at plug.
> > 
> > Simon, do you mind looking into Dmitry's suggestion of having a clean,
> > small usb device which loads itself when the G920 is plugged in and
> > switches it immediately into the HID mode?
> 

> Hi,
>
> As noted 'xpad.c' sends the magic bytes to switch the G920 wheel into
> HID mode, the wheel then detaches and reconnects as a HID+ device
> handled by 'logitech-hidpp.c'.
> 
> I'd like to point that up to this point the wheel _is_ a Xbox One
> control device, that speaks some undocumented protocol from Microsoft.
> To my mind xpad is the correct place to send the magic bytes.

OTOH one can argue if it does not speak protocol that xpad understands
then it does not belong in xpad.

Currently xpad.ko "weighs" at 44K (in my configuration), this is steep
price for sending 1 packet to the device. I am certain that adding a
skeleton usb driver into hid module will be much cheaper.

> 
> It is possible that at some future time that the Xpad devs will
> understand the protocol enough sufficiently to do useful stuff with
> the wheel. In an earlier version of the patch I had a param to disable
> the 'switch to HID', and that might be resurrected.

This is way down the road. We may even end up with a brand new driver
for it, not xpad. And if/when that happens we'll be able to drop hid
potion.

Thanks.
Jiri Kosina Jan. 6, 2016, 2:36 p.m. UTC | #13
On Mon, 4 Jan 2016, Benjamin Tissoires wrote:

> Jiri, I *think* this commit still is in your next pull request for
> Linus. We might want to drop it before it hits Linus' tree.

What exactly would be the reasoning for dropping it?

I am all for implementing the skeleton HID driver to take over the xpad.c 
heavylifting, but before that work gets done, this can stay, can't it?

Thanks,
Dmitry Torokhov Jan. 7, 2016, 1:47 a.m. UTC | #14
On Wed, Jan 06, 2016 at 03:36:57PM +0100, Jiri Kosina wrote:
> On Mon, 4 Jan 2016, Benjamin Tissoires wrote:
> 
> > Jiri, I *think* this commit still is in your next pull request for
> > Linus. We might want to drop it before it hits Linus' tree.
> 
> What exactly would be the reasoning for dropping it?

It is wrong. Aside form the fact that IMO xpad.c is the wrong place for
this code to be in, why are we waiting for the input device to be
opened by userspace before we do the switch instead of doing it
immediately?

Thanks.
simon@mungewell.org Jan. 7, 2016, 4:25 a.m. UTC | #15
On Wed, January 6, 2016 6:47 pm, Dmitry Torokhov wrote:

> It is wrong. Aside form the fact that IMO xpad.c is the wrong place for
> this code to be in, why are we waiting for the input device to be opened by
> userspace before we do the switch instead of doing it immediately?

The 'send magic' might be better in a probe() call, but I don't believe
that it requires userspace interaction as it stands. The wheel will
disconnect almost immediately without me doing anything other than plug it
in.
--
Jan  6 21:18:50 speedster kernel: [  439.604037] usb 5-1: new full-speed
USB device number 2 using uhci_hcd
Jan  6 21:18:50 speedster kernel: [  439.791153] usb 5-1: New USB device
found, idVendor=046d, idProduct=c261
Jan  6 21:18:50 speedster kernel: [  439.791160] usb 5-1: New USB device
strings: Mfr=1, Product=2, SerialNumber=3
Jan  6 21:18:50 speedster kernel: [  439.791164] usb 5-1: Product: G920
Driving Force Racing Wheel for Xbox One
Jan  6 21:18:50 speedster kernel: [  439.791167] usb 5-1: Manufacturer:
Logitech
Jan  6 21:18:50 speedster kernel: [  439.791170] usb 5-1: SerialNumber:
00005d1d5129cebe
Jan  6 21:18:50 speedster mtp-probe: checking bus 5, device 2:
"/sys/devices/pci0000:00/0000:00:1d.3/usb5/5-1"
Jan  6 21:18:50 speedster mtp-probe: bus: 5, device: 2 was not an MTP device
Jan  6 21:18:51 speedster kernel: [  440.815191] input: Logitech G920
Driving Force Racing Wheel as
/devices/pci0000:00/0000:00:1d.3/usb5/5-1/5-1:1.0/input/input4
Jan  6 21:18:51 speedster kernel: [  440.815310] usbcore: registered new
interface driver xpad
Jan  6 21:18:52 speedster kernel: [  441.340093] usb 5-1: USB disconnect,
device number 2
Jan  6 21:18:52 speedster kernel: [  442.052037] usb 5-1: new full-speed
USB device number 3 using uhci_hcd
Jan  6 21:18:52 speedster kernel: [  442.239129] usb 5-1: New USB device
found, idVendor=046d, idProduct=c262
Jan  6 21:18:52 speedster kernel: [  442.239136] usb 5-1: New USB device
strings: Mfr=1, Product=2, SerialNumber=3
Jan  6 21:18:52 speedster kernel: [  442.239139] usb 5-1: Product: G920
Driving Force Racing Wheel for Xbox One
Jan  6 21:18:52 speedster kernel: [  442.239142] usb 5-1: Manufacturer:
Logitech
Jan  6 21:18:52 speedster kernel: [  442.239145] usb 5-1: SerialNumber:
00005d1d5129cebe
Jan  6 21:18:52 speedster mtp-probe: checking bus 5, device 3:
"/sys/devices/pci0000:00/0000:00:1d.3/usb5/5-1"
Jan  6 21:18:52 speedster mtp-probe: bus: 5, device: 3 was not an MTP device
Jan  6 21:18:52 speedster kernel: [  442.267248] input: Logitech G920
Driving Force Racing Wheel for Xbox One as
/devices/pci0000:00/0000:00:1d.3/usb5/5-1/5-1:1.0/0003:046D:C262.0002/input/input5
Jan  6 21:18:52 speedster kernel: [  442.267510] logitech-hidpp-device
0003:046D:C262.0002: input,hiddev0,hidraw1: USB HID v1.11 Joystick
[Logitech G920 Driving Force Racing Wheel for Xbox One] on
usb-0000:00:1d.3-1/input0
Jan  6 21:18:53 speedster kernel: [  442.322160] logitech-hidpp-device
0003:046D:C262.0002: HID++ 4.2 device connected.
--

I also did a quick check with the 'send magic' disabled. Xpad creates the
js0 and populates buttons, but pressing buttons/turning wheel does not
result in any change in js0.

I don't disagree to it being a seperate module, but don't have the time to
implement/test at the moment. If some else does that would be good, can we
make sure that the kconfig/makefile stuff uses same/sensible HID_CONFIGs?
Simon


--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Michal Malý Jan. 7, 2016, 10:50 p.m. UTC | #16
On Wed, 2016-01-06 at 17:47 -0800, Dmitry Torokhov wrote:
> On Wed, Jan 06, 2016 at 03:36:57PM +0100, Jiri Kosina wrote:
> > On Mon, 4 Jan 2016, Benjamin Tissoires wrote:
> > 
> > > Jiri, I *think* this commit still is in your next pull request
> > > for
> > > Linus. We might want to drop it before it hits Linus' tree.
> > 
> > What exactly would be the reasoning for dropping it?
> 
> It is wrong. Aside form the fact that IMO xpad.c is the wrong place
> for
> this code to be in, why are we waiting for the input device to be
> opened by userspace before we do the switch instead of doing it
> immediately?
> 

Hi all,

I have to disagree with the xpad driver being the wrong place to handle
this. The xpad driver matches devices it should handle by interface
class, subclass and protocol. When G920 first appears on the USB bus,
it for all intents and purposes looks like a Xbox One controller so the
xpad driver picks it up even if there is no G920-specific code in the
driver. Unless there is a way how to blacklist certain idProduct
values, the switch from XBone mode to HID mode will have to be done in
the xpad driver.

I'm pretty much done with the simple switching module but it will be of
no use if we cannot make the xpad module ignore G920 first.

Michal

--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Dmitry Torokhov Jan. 7, 2016, 10:53 p.m. UTC | #17
On Thu, Jan 7, 2016 at 2:50 PM, Michal Malý
<madcatxster@devoid-pointer.net> wrote:
> On Wed, 2016-01-06 at 17:47 -0800, Dmitry Torokhov wrote:
>> On Wed, Jan 06, 2016 at 03:36:57PM +0100, Jiri Kosina wrote:
>> > On Mon, 4 Jan 2016, Benjamin Tissoires wrote:
>> >
>> > > Jiri, I *think* this commit still is in your next pull request
>> > > for
>> > > Linus. We might want to drop it before it hits Linus' tree.
>> >
>> > What exactly would be the reasoning for dropping it?
>>
>> It is wrong. Aside form the fact that IMO xpad.c is the wrong place
>> for
>> this code to be in, why are we waiting for the input device to be
>> opened by userspace before we do the switch instead of doing it
>> immediately?
>>
>
> Hi all,
>
> I have to disagree with the xpad driver being the wrong place to handle
> this. The xpad driver matches devices it should handle by interface
> class, subclass and protocol. When G920 first appears on the USB bus,
> it for all intents and purposes looks like a Xbox One controller so the
> xpad driver picks it up even if there is no G920-specific code in the
> driver. Unless there is a way how to blacklist certain idProduct
> values, the switch from XBone mode to HID mode will have to be done in
> the xpad driver.
>
> I'm pretty much done with the simple switching module but it will be of
> no use if we cannot make the xpad module ignore G920 first.

I see that Simon's patch added:

XPAD_XBOXONE_VENDOR(0x046d),

to the xpad driver. Are you saying that we latch onto the controller
even without this addition?

Thanks.
Michal Malý Jan. 7, 2016, 11:05 p.m. UTC | #18
On Thu, 2016-01-07 at 14:53 -0800, Dmitry Torokhov wrote:
> On Thu, Jan 7, 2016 at 2:50 PM, Michal Malý
> <madcatxster@devoid-pointer.net> wrote:
> > On Wed, 2016-01-06 at 17:47 -0800, Dmitry Torokhov wrote:
> > > On Wed, Jan 06, 2016 at 03:36:57PM +0100, Jiri Kosina wrote:
> > > > On Mon, 4 Jan 2016, Benjamin Tissoires wrote:
> > > > 
> > > > > Jiri, I *think* this commit still is in your next pull
> > > > > request
> > > > > for
> > > > > Linus. We might want to drop it before it hits Linus' tree.
> > > > 
> > > > What exactly would be the reasoning for dropping it?
> > > 
> > > It is wrong. Aside form the fact that IMO xpad.c is the wrong
> > > place
> > > for
> > > this code to be in, why are we waiting for the input device to be
> > > opened by userspace before we do the switch instead of doing it
> > > immediately?
> > > 
> > 
> > Hi all,
> > 
> > I have to disagree with the xpad driver being the wrong place to
> > handle
> > this. The xpad driver matches devices it should handle by interface
> > class, subclass and protocol. When G920 first appears on the USB
> > bus,
> > it for all intents and purposes looks like a Xbox One controller so
> > the
> > xpad driver picks it up even if there is no G920-specific code in
> > the
> > driver. Unless there is a way how to blacklist certain idProduct
> > values, the switch from XBone mode to HID mode will have to be done
> > in
> > the xpad driver.
> > 
> > I'm pretty much done with the simple switching module but it will
> > be of
> > no use if we cannot make the xpad module ignore G920 first.
> 
> I see that Simon's patch added:
> 
> XPAD_XBOXONE_VENDOR(0x046d),
> 
> to the xpad driver. Are you saying that we latch onto the controller
> even without this addition?
> 
> Thanks.

Sorry, my bad, I missed that change in the patch. Handling the switch
elsewhere should be no problem then.

Michal
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiri Kosina Jan. 8, 2016, 9:11 a.m. UTC | #19
Alright, so what I am planning to do is to drop 27b9d5a254d ("INPUT: xpad: 
switch Logitech G920 Wheel into HID mode") from the for-4.5/logitech 
branch, while keeping the rest of the G920 support in, so that it 
immediately starts working once proper HID-mode switching is implemented.

If anyone has objections to this aproach, please speak up.

Thanks,

Patch
diff mbox

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index fd4100d..338a3a4 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -93,6 +93,7 @@ 
 #define MAP_STICKS_TO_NULL		(1 << 2)
 #define DANCEPAD_MAP_CONFIG	(MAP_DPAD_TO_BUTTONS |			\
 				MAP_TRIGGERS_TO_BUTTONS | MAP_STICKS_TO_NULL)
+#define SWITCH_G920_TO_HID_MODE		(1 << 3)
 
 #define XTYPE_XBOX        0
 #define XTYPE_XBOX360     1
@@ -134,6 +135,7 @@  static const struct xpad_device {
 	{ 0x046d, 0xc21e, "Logitech Gamepad F510", 0, XTYPE_XBOX360 },
 	{ 0x046d, 0xc21f, "Logitech Gamepad F710", 0, XTYPE_XBOX360 },
 	{ 0x046d, 0xc242, "Logitech Chillstream Controller", 0, XTYPE_XBOX360 },
+	{ 0x046d, 0xc261, "Logitech G920 Driving Force Racing Wheel", SWITCH_G920_TO_HID_MODE, XTYPE_XBOXONE },
 	{ 0x046d, 0xca84, "Logitech Xbox Cordless Controller", 0, XTYPE_XBOX },
 	{ 0x046d, 0xca88, "Logitech Compact Controller for Xbox", 0, XTYPE_XBOX },
 	{ 0x05fd, 0x1007, "Mad Catz Controller (unverified)", 0, XTYPE_XBOX },
@@ -299,6 +301,7 @@  static struct usb_device_id xpad_table[] = {
 	XPAD_XBOX360_VENDOR(0x045e),		/* Microsoft X-Box 360 controllers */
 	XPAD_XBOXONE_VENDOR(0x045e),		/* Microsoft X-Box One controllers */
 	XPAD_XBOX360_VENDOR(0x046d),		/* Logitech X-Box 360 style controllers */
+	XPAD_XBOXONE_VENDOR(0x046d),		/* Logitech X-Box One style controllers */
 	XPAD_XBOX360_VENDOR(0x0738),		/* Mad Catz X-Box 360 controllers */
 	{ USB_DEVICE(0x0738, 0x4540) },		/* Mad Catz Beat Pad */
 	XPAD_XBOX360_VENDOR(0x0e6f),		/* 0x0e6f X-Box 360 controllers */
@@ -1048,6 +1051,19 @@  static int xpad_open(struct input_dev *dev)
 	if (usb_submit_urb(xpad->irq_in, GFP_KERNEL))
 		return -EIO;
 
+	/* Logitect G920 wheel starts in XBOX mode, but is reconfigured to be HID  */
+	/* device with USBID of 046D:C262. Wheel will detach when 'magic' is sent. */
+	if (xpad->mapping & SWITCH_G920_TO_HID_MODE) {
+		xpad->odata[0] = 0x0F;
+		xpad->odata[1] = 0x00;
+		xpad->odata[2] = 0x01;
+		xpad->odata[3] = 0x01;
+		xpad->odata[4] = 0x42;
+		xpad->irq_out->transfer_buffer_length = 5;
+
+		return usb_submit_urb(xpad->irq_out, GFP_KERNEL);
+	}
+
 	if (xpad->xtype == XTYPE_XBOXONE) {
 		/* Xbox one controller needs to be initialized. */
 		xpad->odata[0] = 0x05;