diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-06-17 16:27:59 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-06-17 16:27:59 +0000 |
commit | a2aeb9f207e15e74bc8f59dfc7c1ac40dcaafb56 (patch) | |
tree | 57bf5feb15feb4abe50ef9017110c9dc5ba576b8 /sys | |
parent | d182f8bedd433d1d257136760201058f477d599e (diff) |
Recent Powerbook systems have their on-board keyboard and mouse devices
also showing up as usb devices, but both devices are tied.
To make things less confusing, do not attach the usb phantoms at all.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/macppc/macppc/ofw_machdep.c | 27 | ||||
-rw-r--r-- | sys/dev/usb/ugen.c | 18 | ||||
-rw-r--r-- | sys/dev/usb/uhidev.c | 15 |
3 files changed, 51 insertions, 9 deletions
diff --git a/sys/arch/macppc/macppc/ofw_machdep.c b/sys/arch/macppc/macppc/ofw_machdep.c index 08849e59c26..35500d8a185 100644 --- a/sys/arch/macppc/macppc/ofw_machdep.c +++ b/sys/arch/macppc/macppc/ofw_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ofw_machdep.c,v 1.30 2006/02/12 16:50:13 miod Exp $ */ +/* $OpenBSD: ofw_machdep.c,v 1.31 2006/06/17 16:27:55 miod Exp $ */ /* $NetBSD: ofw_machdep.c,v 1.1 1996/09/30 16:34:50 ws Exp $ */ /* @@ -57,6 +57,7 @@ #include "zstty.h" #include <dev/usb/ukbdvar.h> #include <dev/adb/akbdvar.h> +#include <dev/usb/usbdevs.h> /* XXX, called from asm */ int save_ofw_mapping(void); @@ -243,7 +244,6 @@ ofwconprobe() #define DEVTREE_UNKNOWN 0 #define DEVTREE_USB 1 #define DEVTREE_ADB 2 -#define DEVTREE_HID 3 int ofw_devtree = DEVTREE_UNKNOWN; #define OFW_HAVE_USBKBD 1 @@ -260,6 +260,7 @@ ofw_recurse_keyboard(int pnode) int old_devtree; int len; int node; + int vendor, product; for (node = OF_child(pnode); node != 0; node = OF_peer(node)) { @@ -270,7 +271,23 @@ ofw_recurse_keyboard(int pnode) if (strcmp(name, "keyboard") == 0) { /* found a keyboard node, where is it? */ if (ofw_devtree == DEVTREE_USB) { - ofw_have_kbd |= OFW_HAVE_USBKBD; + /* + * On some machines, such as PowerBook6,8, + * the built-in ADB keyboard and mouse also + * appears as an USB device, which we will + * ignore. + * We need to tell these shadow devices apart + * from regular external USB keyboards. + */ + if (OF_getprop(pnode, "vendor-id", &vendor, + sizeof vendor) != sizeof vendor) + vendor = 0; + if (OF_getprop(pnode, "product-id", &product, + sizeof product) != sizeof product) + product = 0; + if (vendor != USB_VENDOR_APPLE || + product != USB_PRODUCT_APPLE_ADB) + ofw_have_kbd |= OFW_HAVE_USBKBD; } else if (ofw_devtree == DEVTREE_ADB) { ofw_have_kbd |= OFW_HAVE_ADBKBD; } else { @@ -319,12 +336,12 @@ ofw_find_keyboard() #endif } - if (ofw_have_kbd == (OFW_HAVE_USBKBD|OFW_HAVE_ADBKBD)) { + if (ofw_have_kbd == (OFW_HAVE_USBKBD | OFW_HAVE_ADBKBD)) { #if NUKBD > 0 printf("USB and ADB found, using USB\n"); ukbd_cnattach(); #else - ofw_have_kbd = OFW_HAVE_ADBKBD; /* ??? */ + ofw_have_kbd = OFW_HAVE_ADBKBD; #endif } if (ofw_have_kbd == OFW_HAVE_USBKBD) { diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c index 9bcc875d770..d0a0df2db9a 100644 --- a/sys/dev/usb/ugen.c +++ b/sys/dev/usb/ugen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ugen.c,v 1.33 2005/11/21 18:16:43 millert Exp $ */ +/* $OpenBSD: ugen.c,v 1.34 2006/06/17 16:27:58 miod Exp $ */ /* $NetBSD: ugen.c,v 1.63 2002/11/26 18:49:48 christos Exp $ */ /* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */ @@ -66,6 +66,7 @@ #include <dev/usb/usb.h> #include <dev/usb/usbdi.h> #include <dev/usb/usbdi_util.h> +#include <dev/usb/usbdevs.h> #ifdef UGEN_DEBUG #define DPRINTF(x) do { if (ugendebug) logprintf x; } while (0) @@ -189,9 +190,20 @@ USB_MATCH(ugen) if (uaa->matchlvl) return (uaa->matchlvl); #endif - if (uaa->usegeneric) + if (uaa->usegeneric) { +#ifdef __macppc__ + /* + * Some Apple laptops have USB phantom devices which match + * the ADB devices. We want to ignore them to avoid + * confusing users, as the real hardware underneath is adb + * and has already attached. + */ + if (uaa->vendor == USB_VENDOR_APPLE && + uaa->product == USB_PRODUCT_APPLE_ADB) + return (UMATCH_NONE); +#endif return (UMATCH_GENERIC); - else + } else return (UMATCH_NONE); } diff --git a/sys/dev/usb/uhidev.c b/sys/dev/usb/uhidev.c index ef45c247404..d6ff3465b56 100644 --- a/sys/dev/usb/uhidev.c +++ b/sys/dev/usb/uhidev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uhidev.c,v 1.14 2006/05/14 12:00:04 matthieu Exp $ */ +/* $OpenBSD: uhidev.c,v 1.15 2006/06/17 16:27:58 miod Exp $ */ /* $NetBSD: uhidev.c,v 1.14 2003/03/11 16:44:00 augustss Exp $ */ /* @@ -100,6 +100,19 @@ USB_MATCH(uhidev) return (UMATCH_NONE); if (uaa->matchlvl) return (uaa->matchlvl); + +#ifdef __macppc__ + /* + * Some Apple laptops have USB phantom devices which match + * the ADB devices. We want to ignore them to avoid + * confusing users, as the real hardware underneath is adb + * and has already attached. + */ + if (uaa->vendor == USB_VENDOR_APPLE && + uaa->product == USB_PRODUCT_APPLE_ADB) + return (UMATCH_NONE); +#endif + return (UMATCH_IFACECLASS_GENERIC); } |