From owner-p4-projects@FreeBSD.ORG Tue May 8 21:46:48 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 9C66E16A403; Tue, 8 May 2007 21:46:48 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 57AC516A400 for ; Tue, 8 May 2007 21:46:48 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 4A15B13C447 for ; Tue, 8 May 2007 21:46:48 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l48Lkmvb060991 for ; Tue, 8 May 2007 21:46:48 GMT (envelope-from rpaulo@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l48LklLM060988 for perforce@freebsd.org; Tue, 8 May 2007 21:46:47 GMT (envelope-from rpaulo@FreeBSD.org) Date: Tue, 8 May 2007 21:46:47 GMT Message-Id: <200705082146.l48LklLM060988@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to rpaulo@FreeBSD.org using -f From: Rui Paulo To: Perforce Change Reviews Cc: Subject: PERFORCE change 119515 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 May 2007 21:46:48 -0000 http://perforce.freebsd.org/chv.cgi?CH=119515 Change 119515 by rpaulo@rpaulo_epsilon on 2007/05/08 21:46:22 On internal Apple keyboards (found on MacBooks and PowerBooks) the Fn key is software controlled. For now, locate the HID. Handling of the key will be done in subsequent edits. Affected files ... .. //depot/projects/soc2007/rpaulo-macbook/dev/usb/ukbd.c#2 edit .. //depot/projects/soc2007/rpaulo-macbook/dev/usb/usb_quirks.c#2 edit .. //depot/projects/soc2007/rpaulo-macbook/dev/usb/usb_quirks.h#2 edit .. //depot/projects/soc2007/rpaulo-macbook/dev/usb/usbhid.h#2 edit Differences ... ==== //depot/projects/soc2007/rpaulo-macbook/dev/usb/ukbd.c#2 (text+ko) ==== @@ -120,6 +120,9 @@ typedef struct ukbd_softc { device_t sc_dev; /* base device */ +#define UKBD_FN 0x01 + int sc_flags; + struct hid_location sc_loc_fn; /* location of the Fn key */ } ukbd_softc_t; #define UKBD_CHUNK 128 /* chunk size for read */ @@ -163,6 +166,10 @@ usbd_interface_handle iface = uaa->iface; usb_interface_descriptor_t *id; char devinfo[1024]; + void *desc; + int size; + usbd_status err; + uint32_t flags; keyboard_switch_t *sw; keyboard_t *kbd; @@ -177,6 +184,28 @@ usbd_devinfo(uaa->device, USBD_SHOW_INTERFACE_CLASS, devinfo); USB_ATTACH_SETUP; + /* + * Locate the Fn key on Apple keyboards. + */ + if (usbd_get_quirks(uaa->device)->uq_flags & UQ_KBD_FNKEY) { + err = usbd_read_report_desc(uaa->iface, &desc, &size, M_TEMP); + if (err) { + printf("%s: could not read report descriptor\n", + device_get_nameunit(sc->sc_dev)); + USB_ATTACH_ERROR_RETURN; + } + + if (hid_locate(desc, size, HID_USAGE2(HUP_CUSTOM, HUC_FNKEY), + hid_input, &sc->sc_loc_fn, &flags)) { + printf("%s: Fn key.\n", + device_get_nameunit(sc->sc_dev)); + sc->sc_flags |= UKBD_FN; + } else + printf("%s: Fn key not found.\n", + device_get_nameunit(sc->sc_dev)); + free(desc, M_TEMP); + } + arg[0] = (void *)uaa; arg[1] = (void *)ukbd_intr; kbd = NULL; ==== //depot/projects/soc2007/rpaulo-macbook/dev/usb/usb_quirks.c#2 (text+ko) ==== @@ -133,6 +133,9 @@ /* Devices which should be ignored by both ukbd and uhid */ { USB_VENDOR_CYPRESS, USB_PRODUCT_CYPRESS_WISPY, ANY, { UQ_KBD_IGNORE }}, + /* Devices that need special handling of the Fn key */ + { USB_VENDOR_APPLE, USB_PRODUCT_APPLE_INTKBTP, + ANY, { UQ_KBD_FNKEY } }, { 0, 0, 0, { 0 } } }; ==== //depot/projects/soc2007/rpaulo-macbook/dev/usb/usb_quirks.h#2 (text+ko) ==== @@ -57,6 +57,7 @@ #define UQ_OPEN_CLEARSTALL 0x4000 /* device needs clear endpoint stall */ #define UQ_HID_IGNORE 0x8000 /* device should be ignored by hid class */ #define UQ_KBD_IGNORE 0x18000 /* device should be ignored by both kbd and hid class */ +#define UQ_KBD_FNKEY 0x40000 /* device needs special handling for the Fn key */ }; ==== //depot/projects/soc2007/rpaulo-macbook/dev/usb/usbhid.h#2 (text+ko) ==== @@ -94,6 +94,7 @@ #define HUP_SCALE 0x008c #define HUP_CAMERA_CONTROL 0x0090 #define HUP_ARCADE 0x0091 +#define HUP_CUSTOM 0xffff #define HUP_MICROSOFT 0xff00 /* Usages, generic desktop */ @@ -165,6 +166,9 @@ #define HUD_ERASER 0x0045 #define HUD_TABLET_PICK 0x0046 +/* Usages Custom */ +#define HUC_FNKEY 0x0003 + #define HID_USAGE2(p,u) (((p) << 16) | u) #define UHID_INPUT_REPORT 0x01