From owner-freebsd-drivers@FreeBSD.ORG Fri Dec 26 21:25:20 2008 Return-Path: Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5C80C1065670 for ; Fri, 26 Dec 2008 21:25:20 +0000 (UTC) (envelope-from rgrover1@gmail.com) Received: from wa-out-1112.google.com (wa-out-1112.google.com [209.85.146.178]) by mx1.freebsd.org (Postfix) with ESMTP id 307828FC14 for ; Fri, 26 Dec 2008 21:25:20 +0000 (UTC) (envelope-from rgrover1@gmail.com) Received: by wa-out-1112.google.com with SMTP id m34so2251960wag.27 for ; Fri, 26 Dec 2008 13:25:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=T8jT+OZFoKdxFo3Pri8DGDlWR/KkYenq7dv/h33s+vs=; b=gSZ16Vv3Fq81bYmV+iZIdyEXnleoArKTy3SMLHzTjVuIeSAqdKj6h4FH6AmupV/bYT QLHVawRddH7HaBN6DJTrl3fJoWhgCcLkkRroAm0fcpg9Y6hv9bc6Lx9tPCPYSLW4WhBB 9HIYM0wyUnRdChcC5OmVnpU2AWaHWpGGuTOTQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=WMrPTNS4BJvWq/nnuB13IGyTvh/gN29YfDhQJUjEixG97tT5LQCWsoK+PfmR5g2Ttv weTdRI8BvoKZdEksOCUSE6OfB1BCFIcnJiP7zKV0H23AotFBUJg7SpH5Lbm9Pfqkj8Vc 5PrIaDHIQsWR2z6oYRot/fsoVL/KSDOqgA168= Received: by 10.114.155.1 with SMTP id c1mr7124909wae.174.1230324926380; Fri, 26 Dec 2008 12:55:26 -0800 (PST) Received: by 10.114.134.10 with HTTP; Fri, 26 Dec 2008 12:55:26 -0800 (PST) Message-ID: <426bed110812261255s45ad2f82vb874e21165617be7@mail.gmail.com> Date: Sat, 27 Dec 2008 09:55:26 +1300 From: "Rohit Grover" To: freebsd-drivers@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: Attempting to write a device driver for the macbook's USB trackpad X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Dec 2008 21:25:20 -0000 Hello People, I'm attempting to write a FreeBSD device driver for the USB trackpad on my macbook. The trackpad is an HID class device. Parsing the HID report descriptor (fetched from an invocation of usbd_read_report_desc()) for this device results in the following information: Legend: : input: page: 0x9; usage: 0x1; reportID: 2 size: 1, count: 1, loc: 0 input: page: 0x9; usage: 0x2; reportID: 2 size: 1, count: 1, loc: 1 input: page: 0x9; usage: 0x3; reportID: 2 size: 1, count: 1, loc: 2 input: page: 0x0; usage: 0x0; reportID: 2 size: 5, count: 1, loc: 3 input: page: 0x1; usage: 0x30; reportID: 2 size: 8, count: 1, loc: 8 input: page: 0x1; usage: 0x31; reportID: 2 size: 8, count: 1, loc: 16 input: page: 0xffff; usage: 0x2; reportID: 5 size: 8, count: 63, loc: 24 collection: page: 0x1; usage: 0x2; collection: 1; collevel: 1, reportID: 0 size: 0, count: 0, loc: 0 collection: page: 0x1; usage: 0x1; collection: 0; collevel: 2, reportID: 0 size: 0, count: 0, loc: 0 collection: page: 0xffff; usage: 0x1; collection: 0; collevel: 1, reportID: 2 size: 8, count: 2, loc: 0 feature: page: 0xffff; usage: 0x4, reportID: 5 size: 8, count: 1, loc: 0 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 8 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 16 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 24 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 32 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 40 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 48 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 56 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 64 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 72 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 80 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 88 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 96 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 104 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 112 feature: page: 0x0; usage: 0x0, reportID: 5 size: 8, count: 1, loc: 120 end_collection: page: 0x1; usage: 0x31, reportID: 2 size: 8, count: 2, loc: 0 end_collection: page: 0x0; usage: 0x0, reportID: 2 size: 8, count: 2, loc: 0 end_collection: page: 0xffff; usage: 0x4, reportID: 5 size: 8, count: 16, loc: 0 As can be seen, there are two distinct report IDs being used. Report ID 2 describes the mouse-buttons and XY deltas; and since the generic UMS driver in Freebsd is able to parse these values, the macbook's trackpad is usable. I would like to enhance the ums driver to report information from the pressure sensors--with the hope that this will allow the detection of tap events. I suspect that the reports with ID == 5 will contain this information. Of particular interest to me is the following (from the previous table): input: page: 0xffff; usage: 0x2; reportID: 5 size: 8, count: 63, loc: 24 Unfortunately, this report uses a vendor specific page (0xffff), and therefore will require some reverse engineering before it can be deciphered. I need help with receiving HID reports for both ID == 2 and ID == 5. Currently, the interrupt handler (ums_intr) only parses reports with ID==2. Based on my reading of the code, ums_attach() needs to setup sc->sc_iid and sc->sc_isize based on the report-descriptors fetched from the device; but in the case where there are multiple reportIDs supported by the device, the current setup code uses values from only the first reportID. In order to parse reportID 2, sc->sc_isize is set to a value of 4 bytes: 1 byte for the reportID header, together with 3 bytes for the button/XY-delta values. To accommodate an additional 63 bytes for the input in reportID 5, I am guessing that I should set sc->sc_isize to 68: for the 63 bytes starting at bit offset 24; with allowance for one additional byte which may be necessary to accommodate a reportID header. I still don't know how to initialize sc->sc_iid to handle both report IDs. Can someone please help me with setting up the device to receive reports with both IDs so that I can begin reverse-engineering the vendor-specific content of reportID 5? regards, Rohit.