Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 May 2007 21:46:47 GMT
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 119515 for review
Message-ID:  <200705082146.l48LklLM060988@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200705082146.l48LklLM060988>