2006-10-26 09:54:09

by Soeren Sonnenburg

[permalink] [raw]
Subject: usb initialization order (usbhid vs. appletouch)

Dear all,

I've noticed that the appletouch driver needs to be loaded *before* the
usbhid driver to function. This is currently impossible when built into
the kernel (and not modules). So I wonder how one can change the
ordering of when the usb drivers are loaded.

Suggestions ?

Soeren
--
For the one fact about the future of which we can be certain is that it
will be utterly fantastic. -- Arthur C. Clarke, 1962


2006-10-26 10:19:57

by Oliver Neukum

[permalink] [raw]
Subject: Re: usb initialization order (usbhid vs. appletouch)

Am Donnerstag, 26. Oktober 2006 11:53 schrieb Soeren Sonnenburg:
> Dear all,
>
> I've noticed that the appletouch driver needs to be loaded *before* the
> usbhid driver to function. This is currently impossible when built into
> the kernel (and not modules). So I wonder how one can change the
> ordering of when the usb drivers are loaded.
>
> Suggestions ?

Add a quirk to HID. Messing around with probing orders is not
a sure thing.

Regards
Oliver

2006-10-26 11:49:55

by Soeren Sonnenburg

[permalink] [raw]
Subject: Re: usb initialization order (usbhid vs. appletouch)

On Thu, 2006-10-26 at 12:20 +0200, Oliver Neukum wrote:
> Am Donnerstag, 26. Oktober 2006 11:53 schrieb Soeren Sonnenburg:
> > Dear all,
> >
> > I've noticed that the appletouch driver needs to be loaded *before* the
> > usbhid driver to function. This is currently impossible when built into
> > the kernel (and not modules). So I wonder how one can change the
> > ordering of when the usb drivers are loaded.
> >
> > Suggestions ?
>
> Add a quirk to HID. Messing around with probing orders is not
> a sure thing.

what do you have in mind ? if appletouch is turned on ignore IDs that
appear in appletouch ?

Soeren
--
Sometimes, there's a moment as you're waking, when you become aware of
the real world around you, but you're still dreaming.

2006-10-26 12:36:37

by Oliver Neukum

[permalink] [raw]
Subject: Re: usb initialization order (usbhid vs. appletouch)

Am Donnerstag, 26. Oktober 2006 13:49 schrieb Soeren Sonnenburg:
> On Thu, 2006-10-26 at 12:20 +0200, Oliver Neukum wrote:
> > Am Donnerstag, 26. Oktober 2006 11:53 schrieb Soeren Sonnenburg:
> > > Dear all,
> > >
> > > I've noticed that the appletouch driver needs to be loaded *before* the
> > > usbhid driver to function. This is currently impossible when built into
> > > the kernel (and not modules). So I wonder how one can change the
> > > ordering of when the usb drivers are loaded.
> > >
> > > Suggestions ?
> >
> > Add a quirk to HID. Messing around with probing orders is not
> > a sure thing.
>
> what do you have in mind ? if appletouch is turned on ignore IDs that
> appear in appletouch ?

Yes, or even make it unconditional. There is a specific driver for a device.
It exists for a reason.

Regards
Oliver

2006-10-28 16:56:27

by Soeren Sonnenburg

[permalink] [raw]
Subject: Re: usb initialization order (usbhid vs. appletouch)

On Thu, 2006-10-26 at 14:36 +0200, Oliver Neukum wrote:
> Am Donnerstag, 26. Oktober 2006 13:49 schrieb Soeren Sonnenburg:
> > On Thu, 2006-10-26 at 12:20 +0200, Oliver Neukum wrote:
> > > Am Donnerstag, 26. Oktober 2006 11:53 schrieb Soeren Sonnenburg:
> > > > Dear all,
> > > >
> > > > I've noticed that the appletouch driver needs to be loaded *before* the
> > > > usbhid driver to function. This is currently impossible when built into
> > > > the kernel (and not modules). So I wonder how one can change the
> > > > ordering of when the usb drivers are loaded.
> > > >
> > > > Suggestions ?
> > >
> > > Add a quirk to HID. Messing around with probing orders is not
> > > a sure thing.
> >
> > what do you have in mind ? if appletouch is turned on ignore IDs that
> > appear in appletouch ?
>
> Yes, or even make it unconditional. There is a specific driver for a device.
> It exists for a reason.

OK, so I tried adding all of them to the HID_QUIRK_IGNORE LIST, i.e.


#define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
#define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215
#define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216
#define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217
#define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218
#define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219


{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_IGNORE },
{ USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_IGNORE },


however this did (and cannot) work, as the product id stands for both
keyboard AND mouse.

It will however work for the internal infrared receiver (which is also
affected).

#define USB_DEVICE_ID_APPLE_IR 0x8240

{ USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_IR, HID_QUIRK_IGNORE },

Could someone please add this to the quirk list in hid-core.c in git ?
Please note that one can even do this from userspace via

libhid-detach-device 05ac:8240
modprobe appleir


Anyways, back to the above problem. Can one somehow tell the hid-core to
load the appletouch driver when it detects any of these devices and then
initialize on top of that ? The appletouch driver is completely ignored
(doesn't even enter the atp_prope function as usb_register registers
with device/product tuples that are already taken by hid....

Any ideas ?

Soeren
--
Sometimes, there's a moment as you're waking, when you become aware of
the real world around you, but you're still dreaming.

2006-10-28 17:03:16

by Oliver Neukum

[permalink] [raw]
Subject: Re: usb initialization order (usbhid vs. appletouch)

Am Samstag, 28. Oktober 2006 18:56 schrieb Soeren Sonnenburg:
> Anyways, back to the above problem. Can one somehow tell the hid-core to
> load the appletouch driver when it detects any of these devices and then
> initialize on top of that ? The appletouch driver is completely ignored
> (doesn't even enter the atp_prope function as usb_register registers
> with device/product tuples that are already taken by hid....
>
> Any ideas ?

Try udev to disconnect the hid driver, then load appletouch.

HTH
Oliver

2006-10-28 17:36:42

by Soeren Sonnenburg

[permalink] [raw]
Subject: Re: usb initialization order (usbhid vs. appletouch)

On Sat, 2006-10-28 at 19:03 +0200, Oliver Neukum wrote:
> Am Samstag, 28. Oktober 2006 18:56 schrieb Soeren Sonnenburg:
> > Anyways, back to the above problem. Can one somehow tell the hid-core to
> > load the appletouch driver when it detects any of these devices and then
> > initialize on top of that ? The appletouch driver is completely ignored
> > (doesn't even enter the atp_prope function as usb_register registers
> > with device/product tuples that are already taken by hid....
> >
> > Any ideas ?
>
> Try udev to disconnect the hid driver, then load appletouch.

I don't understand... I can disconnect the driver if I do on cmdline
libhid-detach-device 05ac:<id> ; modprobe appletouch .
However then my keyboard is gone.

Of course there is the workaround of building both the appletouch and
hid driver as modules and then loading them in this order ... but I was
hoping to have them fix in the kernel. If this is however not doable we
should mark it in Kconfig and I will have to live with it.

Soeren
--
Sometimes, there's a moment as you're waking, when you become aware of
the real world around you, but you're still dreaming.

2006-10-28 18:14:39

by Sergey Vlasov

[permalink] [raw]
Subject: Re: [linux-usb-devel] usb initialization order (usbhid vs. appletouch)

On Sat, Oct 28, 2006 at 06:56:16PM +0200, Soeren Sonnenburg wrote:
[...]
> OK, so I tried adding all of them to the HID_QUIRK_IGNORE LIST, i.e.
>
>
> #define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
> #define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215
> #define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216
> #define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217
> #define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218
> #define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219
>
>
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_IGNORE },
>
>
> however this did (and cannot) work, as the product id stands for both
> keyboard AND mouse.

You mean that the device has multiple HID interfaces, but only one of
them should be ignored by usbhid and passed to appletouch? Then you
probably need to add a new quirk flag to hiddev (patch completely
untested):

---

From: Sergey Vlasov <[email protected]>
Subject: usbhid: Add HID_QUIRK_IGNORE_MOUSE flag

Some HID devices by Apple have both keyboard and mouse interfaces; the
keyboard interface is handled by usbhid, but the mouse (really
touchpad) interface must be handled by the separate 'appletouch'
driver. Using HID_QUIRK_IGNORE will make hiddev ignore both
interfaces, therefore a new quirk flag to ignore only the mouse
interface is required.

Signed-off-by: Sergey Vlasov <[email protected]>

diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 45f44fe..feb41e7 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1872,6 +1872,9 @@ static struct hid_device *usb_hid_config

if (quirks & HID_QUIRK_IGNORE)
return NULL;
+ if ((quirks & HID_QUIRK_IGNORE_MOUSE) &&
+ (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE))
+ return NULL;

if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) &&
(!interface->desc.bNumEndpoints ||
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index 9b50eff..abd7b52 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -260,6 +260,7 @@ struct hid_item {
#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000
#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000
#define HID_QUIRK_INVERT_HWHEEL 0x00004000
+#define HID_QUIRK_IGNORE_MOUSE 0x00008000

/*
* This is the global environment of the parser. This information is


Attachments:
(No filename) (2.90 kB)
signature.asc (189.00 B)
Digital signature
Download all attachments

2006-10-28 18:19:15

by Pete Zaitcev

[permalink] [raw]
Subject: Re: usb initialization order (usbhid vs. appletouch)

On Sat, 28 Oct 2006 18:56:16 +0200, Soeren Sonnenburg <[email protected]> wrote:

> > > > > I've noticed that the appletouch driver needs to be loaded *before* the
> > > > > usbhid driver to function. This is currently impossible when built into
> > > > > the kernel (and not modules). So I wonder how one can change the
> > > > > ordering of when the usb drivers are loaded.
> > > > >
> > > > > Suggestions ?
> > > >
> > > > Add a quirk to HID. Messing around with probing orders is not
> > > > a sure thing.
> > >
> > > what do you have in mind ? if appletouch is turned on ignore IDs that
> > > appear in appletouch ?
> >
> > Yes, or even make it unconditional. There is a specific driver for a device.
> > It exists for a reason.
>
> OK, so I tried adding all of them to the HID_QUIRK_IGNORE LIST, i.e.

This, of course, cannot possibly work, as we discussed a month ago.
http://lkml.org/lkml/2006/10/1/18

So, you two are just beating a dead horse. It's time to write the code
which identifies Apple devices and not try to ride a quirk.

-- Pete

2006-10-28 18:30:34

by Oliver Neukum

[permalink] [raw]
Subject: Re: [linux-usb-devel] usb initialization order (usbhid vs. appletouch)

Am Samstag, 28. Oktober 2006 20:14 schrieb Pete Zaitcev:
> > OK, so I tried adding all of them to the HID_QUIRK_IGNORE LIST, i.e.
>
> This, of course, cannot possibly work, as we discussed a month ago.
> ?http://lkml.org/lkml/2006/10/1/18
>
> So, you two are just beating a dead horse. It's time to write the code
> which identifies Apple devices and not try to ride a quirk.

No, this will need a quirk, just one that is more specific. Globally
triggering on Apple won't do.

Regards
Oliver

2006-10-28 19:14:57

by Sergey Vlasov

[permalink] [raw]
Subject: Re: [linux-usb-devel] usb initialization order (usbhid vs. appletouch)

(sorry for the duplicate - the message was considered as spam by some
servers due to local misconfiguration on my end)

On Sat, Oct 28, 2006 at 06:56:16PM +0200, Soeren Sonnenburg wrote:
[...]
> OK, so I tried adding all of them to the HID_QUIRK_IGNORE LIST, i.e.
>
>
> #define USB_DEVICE_ID_APPLE_GEYSER_ANSI 0x0214
> #define USB_DEVICE_ID_APPLE_GEYSER_ISO 0x0215
> #define USB_DEVICE_ID_APPLE_GEYSER_JIS 0x0216
> #define USB_DEVICE_ID_APPLE_GEYSER3_ANSI 0x0217
> #define USB_DEVICE_ID_APPLE_GEYSER3_ISO 0x0218
> #define USB_DEVICE_ID_APPLE_GEYSER3_JIS 0x0219
>
>
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ANSI, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_ISO, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER_JIS, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ANSI, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_ISO, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, USB_DEVICE_ID_APPLE_GEYSER3_JIS, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, 0x020E, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, 0x020F, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, 0x030A, HID_QUIRK_IGNORE },
> { USB_VENDOR_ID_APPLE, 0x030B, HID_QUIRK_IGNORE },
>
>
> however this did (and cannot) work, as the product id stands for both
> keyboard AND mouse.

You mean that the device has multiple HID interfaces, but only one of
them should be ignored by usbhid and passed to appletouch? Then you
probably need to add a new quirk flag to hiddev (patch completely
untested):

---

From: Sergey Vlasov <[email protected]>
Subject: usbhid: Add HID_QUIRK_IGNORE_MOUSE flag

Some HID devices by Apple have both keyboard and mouse interfaces; the
keyboard interface is handled by usbhid, but the mouse (really
touchpad) interface must be handled by the separate 'appletouch'
driver. Using HID_QUIRK_IGNORE will make hiddev ignore both
interfaces, therefore a new quirk flag to ignore only the mouse
interface is required.

Signed-off-by: Sergey Vlasov <[email protected]>

diff --git a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
index 45f44fe..feb41e7 100644
--- a/drivers/usb/input/hid-core.c
+++ b/drivers/usb/input/hid-core.c
@@ -1872,6 +1872,9 @@ static struct hid_device *usb_hid_config

if (quirks & HID_QUIRK_IGNORE)
return NULL;
+ if ((quirks & HID_QUIRK_IGNORE_MOUSE) &&
+ (interface->desc.bInterfaceProtocol == USB_INTERFACE_PROTOCOL_MOUSE))
+ return NULL;

if (usb_get_extra_descriptor(interface, HID_DT_HID, &hdesc) &&
(!interface->desc.bNumEndpoints ||
diff --git a/drivers/usb/input/hid.h b/drivers/usb/input/hid.h
index 9b50eff..abd7b52 100644
--- a/drivers/usb/input/hid.h
+++ b/drivers/usb/input/hid.h
@@ -260,6 +260,7 @@ struct hid_item {
#define HID_QUIRK_POWERBOOK_HAS_FN 0x00001000
#define HID_QUIRK_POWERBOOK_FN_ON 0x00002000
#define HID_QUIRK_INVERT_HWHEEL 0x00004000
+#define HID_QUIRK_IGNORE_MOUSE 0x00008000

/*
* This is the global environment of the parser. This information is


Attachments:
(No filename) (3.02 kB)
signature.asc (189.00 B)
Digital signature
Download all attachments