From 4e9ef6f50ac1df020d572924dd57304655fb535d Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:18:49 +0200 Subject: bcm5974 (0.51) unstable; urgency=low * Fine-tuned signal-to-noise ratio, smoother mouse motion. * Interrupt code got minor simplifications. * GFP_ATOMIC completetly removed. -- Henrik Rydberg Mon, 07 Jul 2008 18:09:39 +0200 --- CHANGES | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 CHANGES (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES new file mode 100644 index 0000000..cd46743 --- /dev/null +++ b/CHANGES @@ -0,0 +1,62 @@ +07JUL2008 version 0.51 +---------------------- + +Fine-tuned signal-to-noise ratio, smoother mouse motion. +Interrupt code got minor simplifications. +GFP_ATOMIC completetly removed. + +06JUL2008 version 0.5 +---------------------- + +Working palm detection, changes for kernel.org, dkms introduced. + +01JUL2008 version 0.42 +---------------------- + +First button click registered, pre/post-reset added. + +29JUN2008 version 0.41 +---------------------- + +The reset_resume kernel function added. + +29JUN2008 version 0.4 +---------------------- + +Both finger pressure and width reported. + +27JUN2008 version 0.31 +---------------------- + +Administrative changes for kernel.org. + +27JUN2008 version 0.3 +---------------------- + +Explicit device structure, use all packages. + +27JUN2008 version 0.23 +---------------------- + +Finger release not reported properly. + +26JUN2008 version 0.22 +---------------------- + +ABS coordinates more stable with synaptics. + +25JUN2008 version 0.21 +---------------------- + +Fixed the relative coordinate scaling. + +25JUN2008 version 0.2 +---------------------- + +Misinterpreted pressure input, noise reduction. + +24JUN2008 version 0.1 +---------------------- + +First version. + -- cgit v1.2.3 From d7e13b9eb682d7008b94d050ad35804d46f76750 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:19:56 +0200 Subject: bcm5974 (0.52) unstable; urgency=low * Typo in the post-install script. -- Henrik Rydberg Mon, 07 Jul 2008 20:09:39 +0200 --- CHANGES | 5 +++++ bcm5974.c | 4 ++-- dkms.conf | 2 +- scripts/bcm5974-diagnostics | 2 +- scripts/bcm5974-post-install | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index cd46743..1e4583f 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +07JUL2008 version 0.52 +---------------------- + +Typo in the post-install script. + 07JUL2008 version 0.51 ---------------------- diff --git a/bcm5974.c b/bcm5974.c index bc00a38..e1876c6 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -377,7 +377,7 @@ static void irq_button(struct urb *urb) } if (report_bt_state(dev, dev->bt_urb->actual_length)) { - dprintk(1, "bcm5974: bad button package, length: %d)\n", + dprintk(1, "bcm5974: bad button package, length: %d\n", dev->bt_urb->actual_length); goto exit; } @@ -416,7 +416,7 @@ static void irq_trackpad(struct urb *urb) } if (report_tp_state(dev, dev->tp_urb->actual_length)) { - dprintk(1, "bcm5974: bad trackpad package, length: %d)\n", + dprintk(1, "bcm5974: bad trackpad package, length: %d\n", dev->tp_urb->actual_length); goto exit; } diff --git a/dkms.conf b/dkms.conf index 615cc69..ff1cdf2 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.51" +PACKAGE_VERSION="0.52" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" diff --git a/scripts/bcm5974-diagnostics b/scripts/bcm5974-diagnostics index 0322158..bacc02e 100755 --- a/scripts/bcm5974-diagnostics +++ b/scripts/bcm5974-diagnostics @@ -131,7 +131,7 @@ if [ -f $DEVPATH ]; then echo \* $DEVPATH: module is registered else echo \* $DEVPATH: module is NOT registered - echo No help on this one... + echo "Please double-check the quirks settings in $DRIVMOD" exit 1 fi else diff --git a/scripts/bcm5974-post-install b/scripts/bcm5974-post-install index 21e989e..bf3f74f 100755 --- a/scripts/bcm5974-post-install +++ b/scripts/bcm5974-post-install @@ -29,7 +29,7 @@ PAT_HEAD="options usbhid quirks=" PAT_MBA="0x05ac:0x022" PAT_MBP="0x05ac:0x023" MATCH_MBA=$PAT_HEAD$PAT_MBA -MATCH_MBB=$PAT_HEAD$PAT_MBB +MATCH_MBP=$PAT_HEAD$PAT_MBP if [ -x /usr/sbin/lsusb ]; then if [ "lsusb|grep $PAT_MBA" != "" ]; then -- cgit v1.2.3 From 6aa1bd4e2935d2aa770e841b607850304092f5f8 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:21:01 +0200 Subject: bcm5974 (0.53) unstable; urgency=low * Another typo in the post-install script. -- Henrik Rydberg Mon, 07 Jul 2008 20:59:39 +0200 --- CHANGES | 5 +++++ dkms.conf | 2 +- scripts/bcm5974-post-install | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index 1e4583f..bcb0867 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +07JUL2008 version 0.53 +---------------------- + +Another typo in the post-install script. + 07JUL2008 version 0.52 ---------------------- diff --git a/dkms.conf b/dkms.conf index ff1cdf2..35e8af8 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.52" +PACKAGE_VERSION="0.53" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" diff --git a/scripts/bcm5974-post-install b/scripts/bcm5974-post-install index bf3f74f..8c71be0 100755 --- a/scripts/bcm5974-post-install +++ b/scripts/bcm5974-post-install @@ -34,7 +34,7 @@ MATCH_MBP=$PAT_HEAD$PAT_MBP if [ -x /usr/sbin/lsusb ]; then if [ "lsusb|grep $PAT_MBA" != "" ]; then SED="s/#$MATCH_MBA/$MATCH_MBA/" - elif [ $has_mbb -gt 0 ]; then + elif [ "lsusb|grep $PAT_MBP" != "" ]; then SED="s/#$MATCH_MBP/$MATCH_MBP/" else echo No suitable device found -- cgit v1.2.3 From f9a35c63d6114a9c922bf3b84233e74b61f99f10 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:21:44 +0200 Subject: bcm5974 (0.54) unstable; urgency=low * And another one... finally got the bright idea to test it by emulating the different product ids. -- Henrik Rydberg Tue, 08 Jul 2008 20:59:39 +0200 --- CHANGES | 6 ++++++ bcm5974.c | 4 ++-- dkms.conf | 2 +- scripts/bcm5974-post-install | 20 +++++++++++--------- 4 files changed, 20 insertions(+), 12 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index bcb0867..8512d87 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +08JUL2008 version 0.54 +---------------------- + +And another one... finally got the bright idea to test it by emulating +the different product ids. + 07JUL2008 version 0.53 ---------------------- diff --git a/bcm5974.c b/bcm5974.c index e1876c6..4d9dd45 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -192,8 +192,8 @@ static const struct atp_config atp_config_table[] = { 0x81, sizeof(struct tp_data), { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, - { DIM_X, DIM_X / SN_COORD, -4824, 5342 }, - { DIM_Y, DIM_Y / SN_COORD, -172, 5820 } + { DIM_X, DIM_X / SN_COORD, -4824, 4824 }, + { DIM_Y, DIM_Y / SN_COORD, -172, 4290 } }, {} }; diff --git a/dkms.conf b/dkms.conf index 35e8af8..cb169d6 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.53" +PACKAGE_VERSION="0.54" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" diff --git a/scripts/bcm5974-post-install b/scripts/bcm5974-post-install index 8c71be0..5674d40 100755 --- a/scripts/bcm5974-post-install +++ b/scripts/bcm5974-post-install @@ -25,17 +25,19 @@ ETCPATH=/etc/modprobe.d/$DRIVER echo ----------------------------------------------------------------------- DIR=`dirname $0` +LSUSB=/usr/sbin/lsusb + PAT_HEAD="options usbhid quirks=" -PAT_MBA="0x05ac:0x022" -PAT_MBP="0x05ac:0x023" -MATCH_MBA=$PAT_HEAD$PAT_MBA -MATCH_MBP=$PAT_HEAD$PAT_MBP +PAT[0]="05ac:022" +PAT[1]="05ac:023" +MATCH[0]=${PAT_HEAD}0x05ac:0x022 +MATCH[1]=${PAT_HEAD}0x05ac:0x023 -if [ -x /usr/sbin/lsusb ]; then - if [ "lsusb|grep $PAT_MBA" != "" ]; then - SED="s/#$MATCH_MBA/$MATCH_MBA/" - elif [ "lsusb|grep $PAT_MBP" != "" ]; then - SED="s/#$MATCH_MBP/$MATCH_MBP/" +if [ -x $LSUSB ]; then + if [ "`$LSUSB|grep ${PAT[0]}`" != "" ]; then + SED="s/#${MATCH[0]}/${MATCH[0]}/" + elif [ "`$LSUSB|grep ${PAT[1]}`" != "" ]; then + SED="s/#${MATCH[1]}/${MATCH[1]}/" else echo No suitable device found exit 1 -- cgit v1.2.3 From 7285547e67f8924aace7a78773fa57f9b8fd5bd7 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:25:53 +0200 Subject: bcm5974 (0.55) unstable; urgency=low * Package updates. * Reverting GFP_ATOMIC for irq handlers. -- Henrik Rydberg Wed, 09 Jul 2008 20:59:39 +0200 --- CHANGES | 120 +++++++++++++++++++------------- INSTALL | 2 +- bcm5974-dkms-mkdeb/debian/README.Debian | 23 ++++-- bcm5974-dkms-mkdeb/debian/changelog | 4 +- bcm5974-dkms-mkdeb/debian/control | 5 ++ bcm5974-dkms-mkdeb/debian/copyright | 41 ++++++++++- bcm5974-dkms-mkdeb/debian/dirs | 1 - bcm5974.c | 6 +- dkms.conf | 3 +- scripts/bcm5974-pre-install | 43 ++++++++++++ 10 files changed, 185 insertions(+), 63 deletions(-) create mode 100755 scripts/bcm5974-pre-install (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index 8512d87..6e51394 100644 --- a/CHANGES +++ b/CHANGES @@ -1,78 +1,102 @@ -08JUL2008 version 0.54 ----------------------- +bcm5974 (0.55) unstable; urgency=low -And another one... finally got the bright idea to test it by emulating -the different product ids. + * Package updates. + * Reverting GFP_ATOMIC for irq handlers. -07JUL2008 version 0.53 ----------------------- + -- Henrik Rydberg Wed, 09 Jul 2008 20:59:39 +0200 -Another typo in the post-install script. +bcm5974 (0.54) unstable; urgency=low -07JUL2008 version 0.52 ----------------------- + * And another one... finally got the bright idea to test it by + emulating the different product ids. -Typo in the post-install script. + -- Henrik Rydberg Tue, 08 Jul 2008 20:59:39 +0200 -07JUL2008 version 0.51 ----------------------- +bcm5974 (0.53) unstable; urgency=low -Fine-tuned signal-to-noise ratio, smoother mouse motion. -Interrupt code got minor simplifications. -GFP_ATOMIC completetly removed. + * Another typo in the post-install script. -06JUL2008 version 0.5 ----------------------- + -- Henrik Rydberg Mon, 07 Jul 2008 20:59:39 +0200 -Working palm detection, changes for kernel.org, dkms introduced. +bcm5974 (0.52) unstable; urgency=low -01JUL2008 version 0.42 ----------------------- + * Typo in the post-install script. -First button click registered, pre/post-reset added. + -- Henrik Rydberg Mon, 07 Jul 2008 20:09:39 +0200 -29JUN2008 version 0.41 ----------------------- +bcm5974 (0.51) unstable; urgency=low -The reset_resume kernel function added. + * Fine-tuned signal-to-noise ratio, smoother mouse motion. + * Interrupt code got minor simplifications. + * GFP_ATOMIC completetly removed. -29JUN2008 version 0.4 ----------------------- + -- Henrik Rydberg Mon, 07 Jul 2008 18:09:39 +0200 -Both finger pressure and width reported. +bcm5974 (0.5) unstable; urgency=low -27JUN2008 version 0.31 ----------------------- + * Working palm detection + * Changes for kernel.org + * DKMS introduced. -Administrative changes for kernel.org. + -- Henrik Rydberg Sun, 06 Jul 2008 20:59:39 +0200 -27JUN2008 version 0.3 ----------------------- +bcm5974 (0.42) unstable; urgency=low -Explicit device structure, use all packages. + * First button click registered. + * Hooks pre/post-reset added. -27JUN2008 version 0.23 ----------------------- + -- Henrik Rydberg Tue, 01 Jul 2008 20:59:39 +0200 -Finger release not reported properly. +bcm5974 (0.41) unstable; urgency=low -26JUN2008 version 0.22 ----------------------- + * The reset_resume kernel function added. -ABS coordinates more stable with synaptics. + -- Henrik Rydberg Sun, 29 Jun 2008 20:59:39 +0200 + +bcm5974 (0.4) unstable; urgency=low -25JUN2008 version 0.21 ----------------------- + * Both finger pressure and width reported. -Fixed the relative coordinate scaling. + -- Henrik Rydberg Sun, 29 Jun 2008 18:59:39 +0200 -25JUN2008 version 0.2 ----------------------- +bcm5974 (0.31) unstable; urgency=low -Misinterpreted pressure input, noise reduction. + * Administrative changes for kernel.org. -24JUN2008 version 0.1 ----------------------- + -- Henrik Rydberg Fri, 27 Jun 2008 20:59:39 +0200 -First version. +bcm5974 (0.3) unstable; urgency=low + * Explicit device structure, use all packages. + + -- Henrik Rydberg Fri, 27 Jun 2008 18:59:39 +0200 + +bcm5974 (0.23) unstable; urgency=low + + * Finger release not reported properly. + + -- Henrik Rydberg Fri, 27 Jun 2008 17:59:39 +0200 + +bcm5974 (0.22) unstable; urgency=low + + * ABS coordinates more stable with synaptics. + + -- Henrik Rydberg Thu, 26 Jun 2008 20:59:39 +0200 + +bcm5974 (0.21) unstable; urgency=low + + * Fixed the relative coordinate scaling. + + -- Henrik Rydberg Wed, 25 Jun 2008 20:59:39 +0200 + +bcm5974 (0.2) unstable; urgency=low + + * Misinterpreted pressure input, noise reduction. + + -- Henrik Rydberg Wed, 25 Jun 2008 20:59:39 +0200 + +bcm5974 (0.1) unstable; urgency=low + + * First version. + + -- Henrik Rydberg Tue, 24 Jun 2008 20:59:39 +0200 diff --git a/INSTALL b/INSTALL index 7c7e975..2a2c42f 100644 --- a/INSTALL +++ b/INSTALL @@ -9,7 +9,7 @@ Standing in the source directory, do: 3. sudo ./scripts/bcm5974-post-install -4. reboot (only if bcm5974 never was used before) +4. reboot (or reload the bcm5974 module if already installed) For trouble-shooting, try running diff --git a/bcm5974-dkms-mkdeb/debian/README.Debian b/bcm5974-dkms-mkdeb/debian/README.Debian index 7a1b108..1f170f1 100644 --- a/bcm5974-dkms-mkdeb/debian/README.Debian +++ b/bcm5974-dkms-mkdeb/debian/README.Debian @@ -1,10 +1,23 @@ MODULE_NAME DKMS module for Debian -This driver adds support for the multitouch trackpad on the new -Apple Macbook Air and Macbook Pro Penryn laptops. It replaces the +BCM5974: This driver adds support for the multitouch trackpad on the +new Apple Macbook Air and Macbook Pro Penryn laptops. It replaces the appletouch driver on those computers, and integrates well with the -synaptics driver of the Xorg system. +synaptics driver of the Xorg system. -This package was automatically generated by the DKMS system, -for distribution on Debian based operating systems. +Known to work on Macbook Air and Macbook Pro Penryn. +* Install the debian package (uses dkms) + +* Reboot + +Post installation + +* Make sure your /etc/X11/xorg.conf settings are sane. + +* If experiencing problems with your xorg settings, try the + bcm5974-diagnostics script (dkms installs the source under /usr/src/). + +Enjoy! + +Henrik Rydberg diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index 029a7bc..1d4e435 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,6 +1,6 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * Automatically packaged by DKMS. + * Package updates. + * Reverting GFP_ATOMIC for irq handlers. -- Henrik Rydberg DATE_STAMP - diff --git a/bcm5974-dkms-mkdeb/debian/control b/bcm5974-dkms-mkdeb/debian/control index ad717e6..c5497bf 100644 --- a/bcm5974-dkms-mkdeb/debian/control +++ b/bcm5974-dkms-mkdeb/debian/control @@ -4,8 +4,13 @@ Priority: optional Maintainer: Henrik Rydberg Build-Depends: debhelper (>= 5) Standards-Version: 3.7.2 +Homepage: http://web.comhem.se/rydberg/Bits/ Package: MODULE_NAME-dkms Architecture: all Depends: dkms (>= 1.95), bash (>> 1.99) Description: Apple USB BCM5974 Multitouch trackpad support (DKMS) + This driver adds support for the multitouch trackpad on the new + Apple Macbook Air and Macbook Pro Penryn laptops. It replaces the + appletouch driver on those computers, and integrates well with the + synaptics driver of the Xorg system. diff --git a/bcm5974-dkms-mkdeb/debian/copyright b/bcm5974-dkms-mkdeb/debian/copyright index d690e83..e00b447 100644 --- a/bcm5974-dkms-mkdeb/debian/copyright +++ b/bcm5974-dkms-mkdeb/debian/copyright @@ -1,4 +1,41 @@ -GNU GENERAL PUBLIC LICENSE Version 2 +The bcm5974-dkms package was created using DKMS -See the LICENSE file of this distribution for details. +Source URL: http://web.comhem.se/rydberg/Bits/ +Upstream Author: Henrik Rydberg + +Copyright: + Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se) + + The USB initialization and package decoding was made by + Scott Shawcroft as part of the touchd user-space driver project: + Copyright (C) 2008 Scott Shawcroft (scott.shawcroft@gmail.com) + + The BCM5974 driver is based on the appletouch driver: + Copyright (C) 2001-2004 Greg Kroah-Hartman (greg@kroah.com) + Copyright (C) 2005 Johannes Berg (johannes@sipsolutions.net) + Copyright (C) 2005 Stelian Pop (stelian@popies.net) + Copyright (C) 2005 Frank Arnold (frank@scirocco-5v-turbo.de) + Copyright (C) 2005 Peter Osterlund (petero2@telia.com) + Copyright (C) 2005 Michael Hanselmann (linux-kernel@hansmi.ch) + Copyright (C) 2006 Nicolas Boichat (nicolas@boichat.ch) + +License: + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Packaging: + Copyright (C) 2008 by Henrik Rydberg + released under GPL 2 diff --git a/bcm5974-dkms-mkdeb/debian/dirs b/bcm5974-dkms-mkdeb/debian/dirs index 2b01d9a..b601f22 100644 --- a/bcm5974-dkms-mkdeb/debian/dirs +++ b/bcm5974-dkms-mkdeb/debian/dirs @@ -1,2 +1 @@ usr/src -etc/modprobe.d diff --git a/bcm5974.c b/bcm5974.c index 4d9dd45..2b94835 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -167,7 +167,7 @@ struct atp { #define DIM_Y 800 /* maximum trackpad y value */ /* logical signal quality */ -#define SN_PRESSURE 40 /* pressure signal-to-noise ratio */ +#define SN_PRESSURE 45 /* pressure signal-to-noise ratio */ #define SN_WIDTH 100 /* width signal-to-noise ratio */ #define SN_COORD 250 /* coordinate signal-to-noise ratio */ @@ -385,7 +385,7 @@ static void irq_button(struct urb *urb) input_sync(dev->input); exit: - error = usb_submit_urb(dev->bt_urb, GFP_KERNEL); + error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC); if (error) err("bcm5974: button urb failed: %d", error); } @@ -424,7 +424,7 @@ static void irq_trackpad(struct urb *urb) input_sync(dev->input); exit: - error = usb_submit_urb(dev->tp_urb, GFP_KERNEL); + error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC); if (error) err("bcm5974: trackpad urb failed: %d", error); } diff --git a/dkms.conf b/dkms.conf index cb169d6..44076e7 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,8 +1,9 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.54" +PACKAGE_VERSION="0.55" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" DEST_MODULE_LOCATION[0]="/kernel/drivers/input/mouse" +PRE_INSTALL="scripts/bcm5974-pre-install" POST_INSTALL="scripts/bcm5974-post-install" POST_REMOVE="scripts/bcm5974-post-remove" diff --git a/scripts/bcm5974-pre-install b/scripts/bcm5974-pre-install new file mode 100755 index 0000000..3c4556e --- /dev/null +++ b/scripts/bcm5974-pre-install @@ -0,0 +1,43 @@ +#!/bin/bash +# +# bcm5943-pre-install - check system before installing the bcm5974 +# +# Copyright (C) 2008 Henrik Rydberg (rydberg@euromail.se) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +DRIVER=bcm5974 +LSUSB=/usr/sbin/lsusb + +PAT[0]="05ac:022" +PAT[1]="05ac:023" + +#if [ -x $LSUSB ]; then +if true; then + if [ "`$LSUSB|grep ${PAT[0]}`" != "" ]; then + exit 0 + elif [ "`$LSUSB|grep ${PAT[1]}`" != "" ]; then + exit 0 + else + echo bcm5974: no suitable device found + exit 1 + fi +else + echo bcm5974: cannot determine device type + exit 1 +fi + +exit 0 -- cgit v1.2.3 From 5bf3dece8af80656f0ab23421c720451e4157ad2 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:26:39 +0200 Subject: bcm5974 (0.56) unstable; urgency=low * Leave device initialization to hid; use mode-switch only * Mode switch moved to atp_open and simplified * Corrected cleanup action in atp_open * Simplified control package detection * Removed reset_resume, pre_reset, post_reset; not needed -- Henrik Rydberg Fri, 18 Jul 2008 02:42:52 +0200 --- CHANGES | 10 +++++ Makefile | 2 +- bcm5974-dkms-mkdeb/debian/changelog | 7 +++- bcm5974.c | 75 ++++++------------------------------- dkms.conf | 2 +- scripts/bcm5974-diagnostics | 9 ----- scripts/bcm5974-pre-install | 7 ++-- 7 files changed, 32 insertions(+), 80 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index 6e51394..d31ea79 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,13 @@ +bcm5974 (0.56) unstable; urgency=low + + * Leave device initialization to hid; use mode-switch only + * Mode switch moved to atp_open and simplified + * Corrected cleanup action in atp_open + * Simplified control package detection + * Removed reset_resume, pre_reset, post_reset; not needed + + -- Henrik Rydberg Fri, 18 Jul 2008 02:42:52 +0200 + bcm5974 (0.55) unstable; urgency=low * Package updates. diff --git a/Makefile b/Makefile index 74335c8..6a04556 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ # -# Makefile for USB Network drivers +# Makefile for input/mouse drivers # obj-m := bcm5974.o diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index 1d4e435..cd60af8 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,6 +1,9 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * Package updates. - * Reverting GFP_ATOMIC for irq handlers. + * Leave device initialization to hid; use mode-switch only + * Mode switch moved to atp_open and simplified + * Corrected cleanup action in atp_open + * Simplified control package detection + * Removed reset_resume, pre_reset, post_reset; not needed -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974.c b/bcm5974.c index 2b94835..67cbab3 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -157,7 +157,6 @@ struct atp { struct bt_data *bt_data; /* button transferred data */ struct urb *tp_urb; /* trackpad usb request block */ struct tp_data *tp_data; /* trackpad transferred data */ - unsigned tp_valid; /* trackpad sensors valid */ }; /* logical dimensions */ @@ -283,10 +282,9 @@ static int report_tp_state(struct atp *dev, int size) #define ATP_WELLSPRING_MODE_WRITE_REQUEST_ID 9 #define ATP_WELLSPRING_MODE_REQUEST_VALUE 0x300 #define ATP_WELLSPRING_MODE_REQUEST_INDEX 0 -#define ATP_WELLSPRING_MODE_VENDOR_VALUE_1 0x01 -#define ATP_WELLSPRING_MODE_VENDOR_VALUE_2 0x05 +#define ATP_WELLSPRING_MODE_VENDOR_VALUE 0x01 -static int atp_wellspring_init(struct atp *dev) +static int atp_wellspring_mode(struct atp *dev) { char *data = kmalloc(8, GFP_KERNEL); int error = 0, size; @@ -297,24 +295,6 @@ static int atp_wellspring_init(struct atp *dev) goto error; } - /* reset button endpoint */ - if (usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, - 0, dev->cfg.bt_ep, NULL, 0, 5000)) { - err("bcm5974: could not reset button endpoint"); - error = -EIO; - goto error; - } - - /* reset trackpad endpoint */ - if (usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), - USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, - 0, dev->cfg.tp_ep, NULL, 0, 5000)) { - err("bcm5974: could not reset trackpad endpoint"); - error = -EIO; - goto error; - } - /* read configuration */ size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), ATP_WELLSPRING_MODE_READ_REQUEST_ID, @@ -329,8 +309,7 @@ static int atp_wellspring_init(struct atp *dev) } /* apply the mode switch */ - data[0] = ATP_WELLSPRING_MODE_VENDOR_VALUE_1; - data[1] = ATP_WELLSPRING_MODE_VENDOR_VALUE_2; + data[0] = ATP_WELLSPRING_MODE_VENDOR_VALUE; /* write configuration */ size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), @@ -345,9 +324,7 @@ static int atp_wellspring_init(struct atp *dev) goto error; } - dev->tp_valid = 0; - - printk(KERN_INFO "bcm5974: Wellspring mode initialized.\n"); + dprintk(2, "bcm5974: switched to wellspring mode.\n"); kfree(data); return 0; @@ -409,11 +386,9 @@ static void irq_trackpad(struct urb *urb) goto exit; } - /* first sample data ignored */ - if (!dev->tp_valid) { - dev->tp_valid = 1; + /* control response ignored */ + if (dev->tp_urb->actual_length == 2) goto exit; - } if (report_tp_state(dev, dev->tp_urb->actual_length)) { dprintk(1, "bcm5974: bad trackpad package, length: %d\n", @@ -434,18 +409,21 @@ static int atp_open(struct input_dev *input) struct atp *dev = input_get_drvdata(input); if (!dev->open) { + if (atp_wellspring_mode(dev)) + printk(KERN_INFO "bcm5974: mode switch failed\n"); + if (usb_submit_urb(dev->bt_urb, GFP_KERNEL)) goto error; if (usb_submit_urb(dev->tp_urb, GFP_KERNEL)) - goto err_free_bt_urb; + goto err_kill_bt; } dev->open = 1; dev->suspended = 0; return 0; -err_free_bt_urb: - usb_free_urb(dev->bt_urb); +err_kill_bt: + usb_kill_urb(dev->bt_urb); error: return -EIO; } @@ -486,12 +464,6 @@ static int atp_probe(struct usb_interface *iface, dev->input = input_dev; dev->cfg = *cfg; - /* switch to raw sensor mode */ - if (atp_wellspring_init(dev)) { - error = -EIO; - goto err_free_devs; - } - dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL); if (!dev->bt_urb) { error = -ENOMEM; @@ -631,35 +603,12 @@ static int atp_resume(struct usb_interface *iface) return error; } -static int atp_reset_resume(struct usb_interface *iface) -{ - struct atp *dev = usb_get_intfdata(iface); - - if (dev && atp_wellspring_init(dev)) - printk(KERN_INFO "bcm5974: warning: reset failed\n"); - - return atp_resume(iface); -} - -static int atp_pre_reset(struct usb_interface *iface) -{ - return atp_suspend(iface, PMSG_ON); -} - -static int atp_post_reset(struct usb_interface *iface) -{ - return atp_reset_resume(iface); -} - static struct usb_driver atp_driver = { .name = "bcm5974", .probe = atp_probe, .disconnect = atp_disconnect, .suspend = atp_suspend, .resume = atp_resume, - .reset_resume = atp_reset_resume, - .pre_reset = atp_pre_reset, - .post_reset = atp_post_reset, .id_table = atp_table, }; diff --git a/dkms.conf b/dkms.conf index 44076e7..93e97f3 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.55" +PACKAGE_VERSION="0.56" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" diff --git a/scripts/bcm5974-diagnostics b/scripts/bcm5974-diagnostics index bacc02e..acd0bf4 100755 --- a/scripts/bcm5974-diagnostics +++ b/scripts/bcm5974-diagnostics @@ -138,15 +138,6 @@ else echo \* $DEVPATH: does not exist, ignore fi -# Was the $DRIVER properly initialized? -WELLSPRING=`dmesg|grep $DRIVER|grep Wellspring` -if [ "$WELLSPRING" != "" ]; then - echo \* $DRIVER: Wellspring was initialized -else - echo \* $DRIVER: Wellspring was NOT initialized - exit 1 -fi - # Do we have synaptics working properly? typeset -i SYNLINES=`synclient -l|wc -l` if [ $SYNLINES -gt 10 ]; then diff --git a/scripts/bcm5974-pre-install b/scripts/bcm5974-pre-install index 3c4556e..1e2b864 100755 --- a/scripts/bcm5974-pre-install +++ b/scripts/bcm5974-pre-install @@ -25,19 +25,18 @@ LSUSB=/usr/sbin/lsusb PAT[0]="05ac:022" PAT[1]="05ac:023" -#if [ -x $LSUSB ]; then -if true; then +if [ -x $LSUSB ]; then if [ "`$LSUSB|grep ${PAT[0]}`" != "" ]; then exit 0 elif [ "`$LSUSB|grep ${PAT[1]}`" != "" ]; then exit 0 else echo bcm5974: no suitable device found - exit 1 + exit -1 fi else echo bcm5974: cannot determine device type - exit 1 + exit -1 fi exit 0 -- cgit v1.2.3 From fdf8de5f419e66a793e64896c53f0ccff0a19efb Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:27:18 +0200 Subject: bcm5974 (0.57) unstable; urgency=low * Keep reset_resume around * Submitted to kernel.org -- Henrik Rydberg Sat, 19 Jul 2008 01:42:52 +0200 --- CHANGES | 7 +++++++ bcm5974-dkms-mkdeb/debian/changelog | 7 ++----- bcm5974.c | 26 +++++++++++++++++++++++--- dkms.conf | 2 +- 4 files changed, 33 insertions(+), 9 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index d31ea79..89f02c1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +bcm5974 (0.57) unstable; urgency=low + + * Keep reset_resume around + * Submitted to kernel.org + + -- Henrik Rydberg Fri, 18 Jul 2008 02:42:52 +0200 + bcm5974 (0.56) unstable; urgency=low * Leave device initialization to hid; use mode-switch only diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index cd60af8..76304fd 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,9 +1,6 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * Leave device initialization to hid; use mode-switch only - * Mode switch moved to atp_open and simplified - * Corrected cleanup action in atp_open - * Simplified control package detection - * Removed reset_resume, pre_reset, post_reset; not needed + * Keep reset_resume around + * Submitted to kernel.org -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974.c b/bcm5974.c index 67cbab3..1e1cf04 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -404,14 +404,33 @@ exit: err("bcm5974: trackpad urb failed: %d", error); } +/* + * The Wellspring trackpad, like many recent Apple trackpads, share + * the usb device with the keyboard. Since keyboards are usually + * handled by the HID system, the device ends up being handled by two + * modules. Setting up the device therefore becomes slightly + * complicated. To enable multitouch features, a mode switch is + * required, which is usually applied via the control interface of the + * device. It can be argued where this switch should take place. In + * some drivers, like appletouch, the switch is made during + * probe. However, the hid module may also alter the state of the + * device, resulting in trackpad malfunction under certain + * circumstances. To get around this problem, there is at least one + * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to + * recieve a reset_resume request rather than the normal resume. Since + * the implementation of reset_resume is equal to mode switch plus + * open, it seems easier to always do the switch while opening the + * device. + */ static int atp_open(struct input_dev *input) { struct atp *dev = input_get_drvdata(input); if (!dev->open) { - if (atp_wellspring_mode(dev)) - printk(KERN_INFO "bcm5974: mode switch failed\n"); - + if (atp_wellspring_mode(dev)) { + dprintk(1, "bcm5974: mode switch failed\n"); + goto error; + } if (usb_submit_urb(dev->bt_urb, GFP_KERNEL)) goto error; if (usb_submit_urb(dev->tp_urb, GFP_KERNEL)) @@ -609,6 +628,7 @@ static struct usb_driver atp_driver = { .disconnect = atp_disconnect, .suspend = atp_suspend, .resume = atp_resume, + .reset_resume = atp_resume, .id_table = atp_table, }; diff --git a/dkms.conf b/dkms.conf index 93e97f3..2d5c9f4 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.56" +PACKAGE_VERSION="0.57" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" -- cgit v1.2.3 From 5b36c0f3cbbf29ab25038b1af3b158262d527116 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:28:07 +0200 Subject: bcm5974 (0.58) unstable; urgency=low * Name changes; use usbhid definitions, rename atp to bcm5974 * Input syncing moved to report functions, event type setup broken out * Traffic functions added for open/close and suspend/resume logic * Open/close and suspend/resume transition logic corrected * Open/close serialized with respect to suspend/resume -- Henrik Rydberg Wed, 23 Jul 2008 02:20:10 +0200 --- CHANGES | 12 +- bcm5974-dkms-mkdeb/debian/changelog | 7 +- bcm5974.c | 392 +++++++++++++++++++----------------- dkms.conf | 2 +- 4 files changed, 226 insertions(+), 187 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index 89f02c1..42031d1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,19 @@ +bcm5974 (0.58) unstable; urgency=low + + * Name changes; use usbhid definitions, rename atp to bcm5974 + * Input syncing moved to report functions, event type setup broken out + * Traffic functions added for open/close and suspend/resume logic + * Open/close and suspend/resume transition logic corrected + * Open/close serialized with respect to suspend/resume + + -- Henrik Rydberg Wed, 23 Jul 2008 02:20:10 +0200 + bcm5974 (0.57) unstable; urgency=low * Keep reset_resume around * Submitted to kernel.org - -- Henrik Rydberg Fri, 18 Jul 2008 02:42:52 +0200 + -- Henrik Rydberg Sat, 19 Jul 2008 01:42:52 +0200 bcm5974 (0.56) unstable; urgency=low diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index 76304fd..b0211af 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,6 +1,9 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * Keep reset_resume around - * Submitted to kernel.org + * Name changes; use usbhid definitions, rename atp to bcm5974 + * Input syncing moved to report functions, event type setup broken out + * Traffic functions added for open/close and suspend/resume logic + * Open/close and suspend/resume transition logic corrected + * Open/close serialized with respect to suspend/resume -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974.c b/bcm5974.c index 1e1cf04..55c1f60 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -39,42 +39,43 @@ #include #include #include +#include -#define APPLE_VENDOR_ID 0x05AC +#define USB_VENDOR_ID_APPLE 0x05ac /* MacbookAir, aka wellspring */ -#define ATP_WELLSPRING_ANSI 0x0223 -#define ATP_WELLSPRING_ISO 0x0224 -#define ATP_WELLSPRING_JIS 0x0225 +#define USB_DEVICE_ID_APPLE_WELLSPRING_ANSI 0x0223 +#define USB_DEVICE_ID_APPLE_WELLSPRING_ISO 0x0224 +#define USB_DEVICE_ID_APPLE_WELLSPRING_JIS 0x0225 /* MacbookProPenryn, aka wellspring2 */ -#define ATP_WELLSPRING2_ANSI 0x0230 -#define ATP_WELLSPRING2_ISO 0x0231 -#define ATP_WELLSPRING2_JIS 0x0232 +#define USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 +#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 +#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 -#define ATP_DEVICE(prod) { \ +#define BCM5974_DEVICE(prod) { \ .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ USB_DEVICE_ID_MATCH_INT_CLASS | \ USB_DEVICE_ID_MATCH_INT_PROTOCOL), \ - .idVendor = APPLE_VENDOR_ID, \ + .idVendor = USB_VENDOR_ID_APPLE, \ .idProduct = (prod), \ .bInterfaceClass = USB_INTERFACE_CLASS_HID, \ .bInterfaceProtocol = USB_INTERFACE_PROTOCOL_MOUSE \ } /* table of devices that work with this driver */ -static const struct usb_device_id atp_table [] = { +static const struct usb_device_id bcm5974_table [] = { /* MacbookAir1.1 */ - ATP_DEVICE(ATP_WELLSPRING_ANSI), - ATP_DEVICE(ATP_WELLSPRING_ISO), - ATP_DEVICE(ATP_WELLSPRING_JIS), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_JIS), /* MacbookProPenryn */ - ATP_DEVICE(ATP_WELLSPRING2_ANSI), - ATP_DEVICE(ATP_WELLSPRING2_ISO), - ATP_DEVICE(ATP_WELLSPRING2_JIS), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ISO), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), /* Terminating entry */ {} }; -MODULE_DEVICE_TABLE(usb, atp_table); +MODULE_DEVICE_TABLE(usb, bcm5974_table); MODULE_AUTHOR("Henrik Rydberg"); MODULE_DESCRIPTION("Apple USB BCM5974 multitouch driver"); @@ -125,7 +126,7 @@ struct tp_data { }; /* device-specific parameters */ -struct atp_params { +struct bcm5974_param { int dim; /* logical dimension */ int fuzz; /* logical noise value */ int devmin; /* device minimum reading */ @@ -133,26 +134,27 @@ struct atp_params { }; /* device-specific configuration */ -struct atp_config { +struct bcm5974_config { int ansi, iso, jis; /* the product id of this device */ int bt_ep; /* the endpoint of the button interface */ int bt_datalen; /* data length of the button interface */ int tp_ep; /* the endpoint of the trackpad interface */ int tp_datalen; /* data length of the trackpad interface */ - struct atp_params p; /* finger pressure limits */ - struct atp_params w; /* finger width limits */ - struct atp_params x; /* horizontal limits */ - struct atp_params y; /* vertical limits */ + struct bcm5974_param p; /* finger pressure limits */ + struct bcm5974_param w; /* finger width limits */ + struct bcm5974_param x; /* horizontal limits */ + struct bcm5974_param y; /* vertical limits */ }; /* logical device structure */ -struct atp { +struct bcm5974 { char phys[64]; struct usb_device *udev; /* usb device */ struct input_dev *input; /* input dev */ - struct atp_config cfg; /* device configuration */ - int open; /* >0: open, else closed */ - int suspended; /* >0: suspended, else open */ + struct bcm5974_config cfg; /* device configuration */ + struct mutex mutex; /* serialize access to open/suspend */ + int opened; /* >0: opened, else closed */ + int manually_suspended; /* >0: manually suspended */ struct urb *bt_urb; /* button usb request block */ struct bt_data *bt_data; /* button transferred data */ struct urb *tp_urb; /* trackpad usb request block */ @@ -171,11 +173,11 @@ struct atp { #define SN_COORD 250 /* coordinate signal-to-noise ratio */ /* device constants */ -static const struct atp_config atp_config_table[] = { +static const struct bcm5974_config bcm5974_config_table[] = { { - ATP_WELLSPRING_ANSI, - ATP_WELLSPRING_ISO, - ATP_WELLSPRING_JIS, + USB_DEVICE_ID_APPLE_WELLSPRING_ANSI, + USB_DEVICE_ID_APPLE_WELLSPRING_ISO, + USB_DEVICE_ID_APPLE_WELLSPRING_JIS, 0x84, sizeof(struct bt_data), 0x81, sizeof(struct tp_data), { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, @@ -184,9 +186,9 @@ static const struct atp_config atp_config_table[] = { { DIM_Y, DIM_Y / SN_COORD, -172, 5820 } }, { - ATP_WELLSPRING2_ANSI, - ATP_WELLSPRING2_ISO, - ATP_WELLSPRING2_JIS, + USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI, + USB_DEVICE_ID_APPLE_WELLSPRING2_ISO, + USB_DEVICE_ID_APPLE_WELLSPRING2_JIS, 0x84, sizeof(struct bt_data), 0x81, sizeof(struct tp_data), { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, @@ -198,15 +200,14 @@ static const struct atp_config atp_config_table[] = { }; /* return the device-specific configuration by device */ -static const struct atp_config *atp_product_config(struct usb_device *udev) +static const struct bcm5974_config *bcm5974_get_config(struct usb_device *udev) { u16 id = le16_to_cpu(udev->descriptor.idProduct); - const struct atp_config *config; - for (config = atp_config_table; config->ansi; ++config) - if (config->ansi == id || config->iso == id || - config->jis == id) - return config; - return atp_config_table; + const struct bcm5974_config *cfg; + for (cfg = bcm5974_config_table; cfg->ansi; ++cfg) + if (cfg->ansi == id || cfg->iso == id || cfg->jis == id) + return cfg; + return bcm5974_config_table; } /* convert 16-bit little endian to signed integer */ @@ -216,33 +217,55 @@ static inline int raw2int(__le16 x) } /* scale device data to logical dimensions (asserts devmin < devmax) */ -static inline int int2scale(const struct atp_params *p, int x) +static inline int int2scale(const struct bcm5974_param *p, int x) { return x * p->dim / (p->devmax - p->devmin); } /* all logical value ranges are [0,dim). */ -static inline int int2bound(const struct atp_params *p, int x) +static inline int int2bound(const struct bcm5974_param *p, int x) { int s = int2scale(p, x); return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; } +/* setup which logical events to report */ +static void setup_events_to_report(struct input_dev *input_dev, + const struct bcm5974_config *cfg) +{ + set_bit(EV_ABS, input_dev->evbit); + input_set_abs_params(input_dev, ABS_PRESSURE, + 0, cfg->p.dim, cfg->p.fuzz, 0); + input_set_abs_params(input_dev, ABS_TOOL_WIDTH, + 0, cfg->w.dim, cfg->w.fuzz, 0); + input_set_abs_params(input_dev, ABS_X, + 0, cfg->x.dim, cfg->x.fuzz, 0); + input_set_abs_params(input_dev, ABS_Y, + 0, cfg->y.dim, cfg->y.fuzz, 0); + + set_bit(EV_KEY, input_dev->evbit); + set_bit(BTN_TOOL_FINGER, input_dev->keybit); + set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); + set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); + set_bit(BTN_LEFT, input_dev->keybit); +} + /* report button data as logical button state */ -static int report_bt_state(struct atp *dev, int size) +static int report_bt_state(struct bcm5974 *dev, int size) { if (size != sizeof(struct bt_data)) return -EIO; input_report_key(dev->input, BTN_LEFT, dev->bt_data->button); + input_sync(dev->input); return 0; } /* report trackpad data as logical trackpad state */ -static int report_tp_state(struct atp *dev, int size) +static int report_tp_state(struct bcm5974 *dev, int size) { - const struct atp_config *c = &dev->cfg; + const struct bcm5974_config *c = &dev->cfg; const struct tp_finger *f = dev->tp_data->finger; const int fingers = (size - 26) / 28; int p, w, x, y, n; @@ -255,6 +278,7 @@ static int report_tp_state(struct atp *dev, int size) input_report_key(dev->input, BTN_TOOL_FINGER, false); input_report_key(dev->input, BTN_TOOL_DOUBLETAP, false); input_report_key(dev->input, BTN_TOOL_TRIPLETAP, false); + input_sync(dev->input); return 0; } @@ -274,17 +298,18 @@ static int report_tp_state(struct atp *dev, int size) input_report_key(dev->input, BTN_TOOL_FINGER, n == 1); input_report_key(dev->input, BTN_TOOL_DOUBLETAP, n == 2); input_report_key(dev->input, BTN_TOOL_TRIPLETAP, n > 2); + input_sync(dev->input); return 0; } /* Wellspring initialization constants */ -#define ATP_WELLSPRING_MODE_READ_REQUEST_ID 1 -#define ATP_WELLSPRING_MODE_WRITE_REQUEST_ID 9 -#define ATP_WELLSPRING_MODE_REQUEST_VALUE 0x300 -#define ATP_WELLSPRING_MODE_REQUEST_INDEX 0 -#define ATP_WELLSPRING_MODE_VENDOR_VALUE 0x01 +#define BCM5974_WELLSPRING_MODE_READ_REQUEST_ID 1 +#define BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID 9 +#define BCM5974_WELLSPRING_MODE_REQUEST_VALUE 0x300 +#define BCM5974_WELLSPRING_MODE_REQUEST_INDEX 0 +#define BCM5974_WELLSPRING_MODE_VENDOR_VALUE 0x01 -static int atp_wellspring_mode(struct atp *dev) +static int bcm5974_wellspring_mode(struct bcm5974 *dev) { char *data = kmalloc(8, GFP_KERNEL); int error = 0, size; @@ -297,10 +322,10 @@ static int atp_wellspring_mode(struct atp *dev) /* read configuration */ size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), - ATP_WELLSPRING_MODE_READ_REQUEST_ID, + BCM5974_WELLSPRING_MODE_READ_REQUEST_ID, USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, - ATP_WELLSPRING_MODE_REQUEST_VALUE, - ATP_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); + BCM5974_WELLSPRING_MODE_REQUEST_VALUE, + BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); if (size != 8) { err("bcm5974: could not read from device"); @@ -309,14 +334,14 @@ static int atp_wellspring_mode(struct atp *dev) } /* apply the mode switch */ - data[0] = ATP_WELLSPRING_MODE_VENDOR_VALUE; + data[0] = BCM5974_WELLSPRING_MODE_VENDOR_VALUE; /* write configuration */ size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), - ATP_WELLSPRING_MODE_WRITE_REQUEST_ID, + BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID, USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, - ATP_WELLSPRING_MODE_REQUEST_VALUE, - ATP_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); + BCM5974_WELLSPRING_MODE_REQUEST_VALUE, + BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); if (size != 8) { err("bcm5974: could not write to device"); @@ -336,7 +361,7 @@ error: static void irq_button(struct urb *urb) { - struct atp *dev = urb->context; + struct bcm5974 *dev = urb->context; int error; switch (urb->status) { @@ -353,13 +378,9 @@ static void irq_button(struct urb *urb) goto exit; } - if (report_bt_state(dev, dev->bt_urb->actual_length)) { + if (report_bt_state(dev, dev->bt_urb->actual_length)) dprintk(1, "bcm5974: bad button package, length: %d\n", dev->bt_urb->actual_length); - goto exit; - } - - input_sync(dev->input); exit: error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC); @@ -369,7 +390,7 @@ exit: static void irq_trackpad(struct urb *urb) { - struct atp *dev = urb->context; + struct bcm5974 *dev = urb->context; int error; switch (urb->status) { @@ -390,13 +411,9 @@ static void irq_trackpad(struct urb *urb) if (dev->tp_urb->actual_length == 2) goto exit; - if (report_tp_state(dev, dev->tp_urb->actual_length)) { + if (report_tp_state(dev, dev->tp_urb->actual_length)) dprintk(1, "bcm5974: bad trackpad package, length: %d\n", dev->tp_urb->actual_length); - goto exit; - } - - input_sync(dev->input); exit: error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC); @@ -417,99 +434,149 @@ exit: * device, resulting in trackpad malfunction under certain * circumstances. To get around this problem, there is at least one * example that utilizes the USB_QUIRK_RESET_RESUME quirk in order to - * recieve a reset_resume request rather than the normal resume. Since - * the implementation of reset_resume is equal to mode switch plus - * open, it seems easier to always do the switch while opening the - * device. + * recieve a reset_resume request rather than the normal resume. + * Since the implementation of reset_resume is equal to mode switch + * plus start_traffic, it seems easier to always do the switch when + * starting traffic on the device. */ -static int atp_open(struct input_dev *input) +static int start_traffic(struct bcm5974 *dev) { - struct atp *dev = input_get_drvdata(input); - - if (!dev->open) { - if (atp_wellspring_mode(dev)) { - dprintk(1, "bcm5974: mode switch failed\n"); - goto error; - } - if (usb_submit_urb(dev->bt_urb, GFP_KERNEL)) - goto error; - if (usb_submit_urb(dev->tp_urb, GFP_KERNEL)) - goto err_kill_bt; + if (bcm5974_wellspring_mode(dev)) { + dprintk(1, "bcm5974: mode switch failed\n"); + goto error; } + if (usb_submit_urb(dev->bt_urb, GFP_KERNEL)) + goto error; + if (usb_submit_urb(dev->tp_urb, GFP_KERNEL)) + goto err_kill_bt; - dev->open = 1; - dev->suspended = 0; return 0; - err_kill_bt: usb_kill_urb(dev->bt_urb); error: return -EIO; } -static void atp_close(struct input_dev *input) +static void pause_traffic(struct bcm5974 *dev) { - struct atp *dev = input_get_drvdata(input); - usb_kill_urb(dev->tp_urb); usb_kill_urb(dev->bt_urb); +} - dev->open = 0; - dev->suspended = 0; +/* + * The code below implements open/close and manual suspend/resume. + * All functions may be called in random order. + * + * Opening a suspended device fails with EACCES - permission denied. + * + * Failing a resume leaves the device resumed but closed. + */ +static int bcm5974_open(struct input_dev *input) +{ + struct bcm5974 *dev = input_get_drvdata(input); + int error = 0; + + mutex_lock(&dev->mutex); + if (dev->manually_suspended) + error = -EACCES; + else if (!dev->opened) + error = start_traffic(dev); + dev->opened = !error; + mutex_unlock(&dev->mutex); + + return error; } -static int atp_probe(struct usb_interface *iface, +static void bcm5974_close(struct input_dev *input) +{ + struct bcm5974 *dev = input_get_drvdata(input); + + mutex_lock(&dev->mutex); + if (!dev->manually_suspended) + pause_traffic(dev); + dev->opened = 0; + mutex_unlock(&dev->mutex); +} + +static int bcm5974_suspend(struct usb_interface *iface, pm_message_t message) +{ + struct bcm5974 *dev = usb_get_intfdata(iface); + + if (dev) { + mutex_lock(&dev->mutex); + if (dev->opened && !dev->manually_suspended) + pause_traffic(dev); + dev->manually_suspended++; + mutex_unlock(&dev->mutex); + } + + return 0; +} + +static int bcm5974_resume(struct usb_interface *iface) +{ + struct bcm5974 *dev = usb_get_intfdata(iface); + int error = 0; + + if (dev) { + mutex_lock(&dev->mutex); + if (dev->manually_suspended) + dev->manually_suspended--; + if (dev->opened && !dev->manually_suspended) + error = start_traffic(dev); + if (error) + dev->opened = 0; + mutex_unlock(&dev->mutex); + } + + return error; +} + +static int bcm5974_probe(struct usb_interface *iface, const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev(iface); - const struct atp_config *cfg; - struct atp *dev; + const struct bcm5974_config *cfg; + struct bcm5974 *dev; struct input_dev *input_dev; - int error = 0; + int error = -ENOMEM; /* find the product index */ - cfg = atp_product_config(udev); + cfg = bcm5974_get_config(udev); /* allocate memory for our device state and initialize it */ - dev = kzalloc(sizeof(struct atp), GFP_KERNEL); + dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL); input_dev = input_allocate_device(); if (!dev || !input_dev) { err("bcm5974: out of memory"); - error = -ENOMEM; goto err_free_devs; } dev->udev = udev; dev->input = input_dev; dev->cfg = *cfg; + mutex_init(&dev->mutex); + /* setup urbs */ dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!dev->bt_urb) { - error = -ENOMEM; + if (!dev->bt_urb) goto err_free_devs; - } dev->tp_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!dev->tp_urb) { - error = -ENOMEM; + if (!dev->tp_urb) goto err_free_bt_urb; - } dev->bt_data = usb_buffer_alloc(dev->udev, dev->cfg.bt_datalen, GFP_KERNEL, &dev->bt_urb->transfer_dma); - if (!dev->bt_data) { - error = -ENOMEM; + if (!dev->bt_data) goto err_free_urb; - } dev->tp_data = usb_buffer_alloc(dev->udev, dev->cfg.tp_datalen, GFP_KERNEL, &dev->tp_urb->transfer_dma); - if (!dev->tp_data) { - error = -ENOMEM; + if (!dev->tp_data) goto err_free_bt_buffer; - } usb_fill_int_urb(dev->bt_urb, udev, usb_rcvintpipe(udev, cfg->bt_ep), @@ -521,6 +588,7 @@ static int atp_probe(struct usb_interface *iface, dev->tp_data, dev->cfg.tp_datalen, irq_trackpad, dev, 1); + /* create bcm5974 device */ usb_make_path(udev, dev->phys, sizeof(dev->phys)); strlcat(dev->phys, "/input0", sizeof(dev->phys)); @@ -531,24 +599,10 @@ static int atp_probe(struct usb_interface *iface, input_set_drvdata(input_dev, dev); - input_dev->open = atp_open; - input_dev->close = atp_close; + input_dev->open = bcm5974_open; + input_dev->close = bcm5974_close; - set_bit(EV_ABS, input_dev->evbit); - input_set_abs_params(input_dev, ABS_PRESSURE, - 0, cfg->p.dim, cfg->p.fuzz, 0); - input_set_abs_params(input_dev, ABS_TOOL_WIDTH, - 0, cfg->w.dim, cfg->w.fuzz, 0); - input_set_abs_params(input_dev, ABS_X, - 0, cfg->x.dim, cfg->x.fuzz, 0); - input_set_abs_params(input_dev, ABS_Y, - 0, cfg->y.dim, cfg->y.fuzz, 0); - - set_bit(EV_KEY, input_dev->evbit); - set_bit(BTN_TOOL_FINGER, input_dev->keybit); - set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); - set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); - set_bit(BTN_LEFT, input_dev->keybit); + setup_events_to_report(input_dev, cfg); error = input_register_device(dev->input); if (error) @@ -571,77 +625,49 @@ err_free_bt_urb: usb_free_urb(dev->bt_urb); err_free_devs: usb_set_intfdata(iface, NULL); - kfree(dev); input_free_device(input_dev); + kfree(dev); return error; } -static void atp_disconnect(struct usb_interface *iface) +static void bcm5974_disconnect(struct usb_interface *iface) { - struct atp *dev = usb_get_intfdata(iface); + struct bcm5974 *dev = usb_get_intfdata(iface); usb_set_intfdata(iface, NULL); - if (dev) { - input_unregister_device(dev->input); - usb_buffer_free(dev->udev, dev->cfg.tp_datalen, - dev->tp_data, dev->tp_urb->transfer_dma); - usb_buffer_free(dev->udev, dev->cfg.bt_datalen, - dev->bt_data, dev->bt_urb->transfer_dma); - usb_free_urb(dev->tp_urb); - usb_free_urb(dev->bt_urb); - kfree(dev); - } + input_unregister_device(dev->input); + usb_buffer_free(dev->udev, dev->cfg.tp_datalen, + dev->tp_data, dev->tp_urb->transfer_dma); + usb_buffer_free(dev->udev, dev->cfg.bt_datalen, + dev->bt_data, dev->bt_urb->transfer_dma); + usb_free_urb(dev->tp_urb); + usb_free_urb(dev->bt_urb); + kfree(dev); printk(KERN_INFO "bcm5974: disconnected\n"); } -static int atp_suspend(struct usb_interface *iface, pm_message_t message) -{ - struct atp *dev = usb_get_intfdata(iface); - - if (dev) { - if (!dev->suspended) - atp_close(dev->input); - dev->suspended++; - } - - return 0; -} - -static int atp_resume(struct usb_interface *iface) -{ - struct atp *dev = usb_get_intfdata(iface); - int error = 0; - - if (dev && dev->suspended) { - if (!--dev->suspended) - error = atp_open(dev->input); - } - - return error; -} - -static struct usb_driver atp_driver = { +static struct usb_driver bcm5974_driver = { .name = "bcm5974", - .probe = atp_probe, - .disconnect = atp_disconnect, - .suspend = atp_suspend, - .resume = atp_resume, - .reset_resume = atp_resume, - .id_table = atp_table, + .probe = bcm5974_probe, + .disconnect = bcm5974_disconnect, + .suspend = bcm5974_suspend, + .resume = bcm5974_resume, + .reset_resume = bcm5974_resume, + .id_table = bcm5974_table, }; -static int __init atp_init(void) +static int __init bcm5974_init(void) { - return usb_register(&atp_driver); + return usb_register(&bcm5974_driver); } -static void __exit atp_exit(void) +static void __exit bcm5974_exit(void) { - usb_deregister(&atp_driver); + usb_deregister(&bcm5974_driver); } -module_init(atp_init); -module_exit(atp_exit); +module_init(bcm5974_init); +module_exit(bcm5974_exit); diff --git a/dkms.conf b/dkms.conf index 2d5c9f4..251efb1 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.57" +PACKAGE_VERSION="0.58" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" -- cgit v1.2.3 From cff494e93004e71ee7c94ccbd7e019eee6deec89 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:28:41 +0200 Subject: bcm5974 (0.59) unstable; urgency=low * Cleanup patch from Dmitry Torokhov * Auto-suspend patch from Dmitry Torokhov -- Henrik Rydberg Fri, 25 Jul 2008 20:14:05 +0200 --- CHANGES | 7 ++ INSTALL | 4 +- bcm5974-dkms-mkdeb/debian/changelog | 7 +- bcm5974.c | 239 +++++++++++++++++++----------------- dkms.conf | 2 +- 5 files changed, 137 insertions(+), 122 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index 42031d1..0f80cb1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +bcm5974 (0.59) unstable; urgency=low + + * Cleanup patch from Dmitry Torokhov + * Auto-suspend patch from Dmitry Torokhov + + -- Henrik Rydberg Fri, 25 Jul 2008 20:14:05 +0200 + bcm5974 (0.58) unstable; urgency=low * Name changes; use usbhid definitions, rename atp to bcm5974 diff --git a/INSTALL b/INSTALL index 2a2c42f..195fd05 100644 --- a/INSTALL +++ b/INSTALL @@ -9,7 +9,9 @@ Standing in the source directory, do: 3. sudo ./scripts/bcm5974-post-install -4. reboot (or reload the bcm5974 module if already installed) +4. sudo depmod -a + +5. reboot (or reload the bcm5974 module if already installed) For trouble-shooting, try running diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index b0211af..9c8bd7b 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,9 +1,6 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * Name changes; use usbhid definitions, rename atp to bcm5974 - * Input syncing moved to report functions, event type setup broken out - * Traffic functions added for open/close and suspend/resume logic - * Open/close and suspend/resume transition logic corrected - * Open/close serialized with respect to suspend/resume + * Cleanup patch from Dmitry Torokhov + * Auto-suspend patch from Dmitry Torokhov -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974.c b/bcm5974.c index 55c1f60..710d0ac 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -150,11 +150,11 @@ struct bcm5974_config { struct bcm5974 { char phys[64]; struct usb_device *udev; /* usb device */ + struct usb_interface *intf; /* our interface */ struct input_dev *input; /* input dev */ struct bcm5974_config cfg; /* device configuration */ - struct mutex mutex; /* serialize access to open/suspend */ - int opened; /* >0: opened, else closed */ - int manually_suspended; /* >0: manually suspended */ + struct mutex pm_mutex; /* serialize access to open/suspend */ + int opened; /* 1: opened, 0: closed */ struct urb *bt_urb; /* button usb request block */ struct bt_data *bt_data; /* button transferred data */ struct urb *tp_urb; /* trackpad usb request block */ @@ -204,9 +204,11 @@ static const struct bcm5974_config *bcm5974_get_config(struct usb_device *udev) { u16 id = le16_to_cpu(udev->descriptor.idProduct); const struct bcm5974_config *cfg; + for (cfg = bcm5974_config_table; cfg->ansi; ++cfg) if (cfg->ansi == id || cfg->iso == id || cfg->jis == id) return cfg; + return bcm5974_config_table; } @@ -226,28 +228,31 @@ static inline int int2scale(const struct bcm5974_param *p, int x) static inline int int2bound(const struct bcm5974_param *p, int x) { int s = int2scale(p, x); + +// return clamp_val(s, 0, p->dim - 1); return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; } /* setup which logical events to report */ static void setup_events_to_report(struct input_dev *input_dev, - const struct bcm5974_config *cfg) + const struct bcm5974_config *cfg) { - set_bit(EV_ABS, input_dev->evbit); + __set_bit(EV_ABS, input_dev->evbit); + input_set_abs_params(input_dev, ABS_PRESSURE, - 0, cfg->p.dim, cfg->p.fuzz, 0); + 0, cfg->p.dim, cfg->p.fuzz, 0); input_set_abs_params(input_dev, ABS_TOOL_WIDTH, - 0, cfg->w.dim, cfg->w.fuzz, 0); + 0, cfg->w.dim, cfg->w.fuzz, 0); input_set_abs_params(input_dev, ABS_X, - 0, cfg->x.dim, cfg->x.fuzz, 0); + 0, cfg->x.dim, cfg->x.fuzz, 0); input_set_abs_params(input_dev, ABS_Y, - 0, cfg->y.dim, cfg->y.fuzz, 0); + 0, cfg->y.dim, cfg->y.fuzz, 0); - set_bit(EV_KEY, input_dev->evbit); - set_bit(BTN_TOOL_FINGER, input_dev->keybit); - set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); - set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); - set_bit(BTN_LEFT, input_dev->keybit); + __set_bit(EV_KEY, input_dev->evbit); + __set_bit(BTN_TOOL_FINGER, input_dev->keybit); + __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); + __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); + __set_bit(BTN_LEFT, input_dev->keybit); } /* report button data as logical button state */ @@ -267,38 +272,37 @@ static int report_tp_state(struct bcm5974 *dev, int size) { const struct bcm5974_config *c = &dev->cfg; const struct tp_finger *f = dev->tp_data->finger; + struct input_dev *input = dev->input; const int fingers = (size - 26) / 28; - int p, w, x, y, n; + int p = 0, w, x, y, n = 0; if (size < 26 || (size - 26) % 28 != 0) return -EIO; - if (!fingers) { - input_report_abs(dev->input, ABS_PRESSURE, 0); - input_report_key(dev->input, BTN_TOOL_FINGER, false); - input_report_key(dev->input, BTN_TOOL_DOUBLETAP, false); - input_report_key(dev->input, BTN_TOOL_TRIPLETAP, false); - input_sync(dev->input); - return 0; + if (fingers) { + p = raw2int(f->force_major); + w = raw2int(f->size_major); + x = raw2int(f->abs_x); + y = raw2int(f->abs_y); + n = p > 0 ? fingers : 0; + + dprintk(9, + "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", + p, w, x, y, n); + + input_report_abs(input, ABS_TOOL_WIDTH, int2bound(&c->w, w)); + input_report_abs(input, ABS_X, int2bound(&c->x, x - c->x.devmin)); + input_report_abs(input, ABS_Y, int2bound(&c->y, c->y.devmax - y)); } - p = raw2int(f->force_major); - w = raw2int(f->size_major); - x = raw2int(f->abs_x); - y = raw2int(f->abs_y); - n = p > 0 ? fingers : 0; - - dprintk(9, "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", - p, w, x, y, n); - - input_report_abs(dev->input, ABS_PRESSURE, int2bound(&c->p, p)); - input_report_abs(dev->input, ABS_TOOL_WIDTH, int2bound(&c->w, w)); - input_report_abs(dev->input, ABS_X, int2bound(&c->x, x - c->x.devmin)); - input_report_abs(dev->input, ABS_Y, int2bound(&c->y, c->y.devmax - y)); - input_report_key(dev->input, BTN_TOOL_FINGER, n == 1); - input_report_key(dev->input, BTN_TOOL_DOUBLETAP, n == 2); - input_report_key(dev->input, BTN_TOOL_TRIPLETAP, n > 2); - input_sync(dev->input); + input_report_abs(input, ABS_PRESSURE, int2bound(&c->p, p)); + + input_report_key(input, BTN_TOOL_FINGER, n == 1); + input_report_key(input, BTN_TOOL_DOUBLETAP, n == 2); + input_report_key(input, BTN_TOOL_TRIPLETAP, n > 2); + + input_sync(input); + return 0; } @@ -312,25 +316,25 @@ static int report_tp_state(struct bcm5974 *dev, int size) static int bcm5974_wellspring_mode(struct bcm5974 *dev) { char *data = kmalloc(8, GFP_KERNEL); - int error = 0, size; + int retval = 0, size; if (!data) { err("bcm5974: out of memory"); - error = -ENOMEM; - goto error; + retval = -ENOMEM; + goto out; } /* read configuration */ size = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), - BCM5974_WELLSPRING_MODE_READ_REQUEST_ID, - USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, - BCM5974_WELLSPRING_MODE_REQUEST_VALUE, - BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); + BCM5974_WELLSPRING_MODE_READ_REQUEST_ID, + USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + BCM5974_WELLSPRING_MODE_REQUEST_VALUE, + BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); if (size != 8) { err("bcm5974: could not read from device"); - error = -EIO; - goto error; + retval = -EIO; + goto out; } /* apply the mode switch */ @@ -338,28 +342,25 @@ static int bcm5974_wellspring_mode(struct bcm5974 *dev) /* write configuration */ size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), - BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID, - USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, - BCM5974_WELLSPRING_MODE_REQUEST_VALUE, - BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); + BCM5974_WELLSPRING_MODE_WRITE_REQUEST_ID, + USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, + BCM5974_WELLSPRING_MODE_REQUEST_VALUE, + BCM5974_WELLSPRING_MODE_REQUEST_INDEX, data, 8, 5000); if (size != 8) { err("bcm5974: could not write to device"); - error = -EIO; - goto error; + retval = -EIO; + goto out; } dprintk(2, "bcm5974: switched to wellspring mode.\n"); + out: kfree(data); - return 0; - -error: - kfree(data); - return error; + return retval; } -static void irq_button(struct urb *urb) +static void bcm5974_irq_button(struct urb *urb) { struct bcm5974 *dev = urb->context; int error; @@ -388,7 +389,7 @@ exit: err("bcm5974: button urb failed: %d", error); } -static void irq_trackpad(struct urb *urb) +static void bcm5974_irq_trackpad(struct urb *urb) { struct bcm5974 *dev = urb->context; int error; @@ -439,25 +440,28 @@ exit: * plus start_traffic, it seems easier to always do the switch when * starting traffic on the device. */ -static int start_traffic(struct bcm5974 *dev) +static int bcm5974_start_traffic(struct bcm5974 *dev) { if (bcm5974_wellspring_mode(dev)) { dprintk(1, "bcm5974: mode switch failed\n"); goto error; } + if (usb_submit_urb(dev->bt_urb, GFP_KERNEL)) goto error; + if (usb_submit_urb(dev->tp_urb, GFP_KERNEL)) goto err_kill_bt; return 0; + err_kill_bt: usb_kill_urb(dev->bt_urb); error: return -EIO; } -static void pause_traffic(struct bcm5974 *dev) +static void bcm5974_pause_traffic(struct bcm5974 *dev) { usb_kill_urb(dev->tp_urb); usb_kill_urb(dev->bt_urb); @@ -474,15 +478,22 @@ static void pause_traffic(struct bcm5974 *dev) static int bcm5974_open(struct input_dev *input) { struct bcm5974 *dev = input_get_drvdata(input); - int error = 0; + int error; + + error = usb_autopm_get_interface(dev->intf); + if (error) + return error; + + mutex_lock(&dev->pm_mutex); - mutex_lock(&dev->mutex); - if (dev->manually_suspended) - error = -EACCES; - else if (!dev->opened) - error = start_traffic(dev); - dev->opened = !error; - mutex_unlock(&dev->mutex); + error = bcm5974_start_traffic(dev); + if (!error) + dev->opened = 1; + + mutex_unlock(&dev->pm_mutex); + + if (error) + usb_autopm_put_interface(dev->intf); return error; } @@ -491,24 +502,26 @@ static void bcm5974_close(struct input_dev *input) { struct bcm5974 *dev = input_get_drvdata(input); - mutex_lock(&dev->mutex); - if (!dev->manually_suspended) - pause_traffic(dev); + mutex_lock(&dev->pm_mutex); + + bcm5974_pause_traffic(dev); dev->opened = 0; - mutex_unlock(&dev->mutex); + + mutex_unlock(&dev->pm_mutex); + + usb_autopm_put_interface(dev->intf); } static int bcm5974_suspend(struct usb_interface *iface, pm_message_t message) { struct bcm5974 *dev = usb_get_intfdata(iface); - if (dev) { - mutex_lock(&dev->mutex); - if (dev->opened && !dev->manually_suspended) - pause_traffic(dev); - dev->manually_suspended++; - mutex_unlock(&dev->mutex); - } + mutex_lock(&dev->pm_mutex); + + if (dev->opened) + bcm5974_pause_traffic(dev); + + mutex_unlock(&dev->pm_mutex); return 0; } @@ -518,22 +531,18 @@ static int bcm5974_resume(struct usb_interface *iface) struct bcm5974 *dev = usb_get_intfdata(iface); int error = 0; - if (dev) { - mutex_lock(&dev->mutex); - if (dev->manually_suspended) - dev->manually_suspended--; - if (dev->opened && !dev->manually_suspended) - error = start_traffic(dev); - if (error) - dev->opened = 0; - mutex_unlock(&dev->mutex); - } + mutex_lock(&dev->pm_mutex); + + if (dev->opened) + error = bcm5974_start_traffic(dev); + + mutex_unlock(&dev->pm_mutex); return error; } static int bcm5974_probe(struct usb_interface *iface, - const struct usb_device_id *id) + const struct usb_device_id *id) { struct usb_device *udev = interface_to_usbdev(iface); const struct bcm5974_config *cfg; @@ -553,9 +562,10 @@ static int bcm5974_probe(struct usb_interface *iface, } dev->udev = udev; + dev->intf = iface; dev->input = input_dev; dev->cfg = *cfg; - mutex_init(&dev->mutex); + mutex_init(&dev->pm_mutex); /* setup urbs */ dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL); @@ -567,26 +577,26 @@ static int bcm5974_probe(struct usb_interface *iface, goto err_free_bt_urb; dev->bt_data = usb_buffer_alloc(dev->udev, - dev->cfg.bt_datalen, GFP_KERNEL, - &dev->bt_urb->transfer_dma); + dev->cfg.bt_datalen, GFP_KERNEL, + &dev->bt_urb->transfer_dma); if (!dev->bt_data) goto err_free_urb; dev->tp_data = usb_buffer_alloc(dev->udev, - dev->cfg.tp_datalen, GFP_KERNEL, - &dev->tp_urb->transfer_dma); + dev->cfg.tp_datalen, GFP_KERNEL, + &dev->tp_urb->transfer_dma); if (!dev->tp_data) goto err_free_bt_buffer; usb_fill_int_urb(dev->bt_urb, udev, - usb_rcvintpipe(udev, cfg->bt_ep), - dev->bt_data, dev->cfg.bt_datalen, - irq_button, dev, 1); + usb_rcvintpipe(udev, cfg->bt_ep), + dev->bt_data, dev->cfg.bt_datalen, + bcm5974_irq_button, dev, 1); usb_fill_int_urb(dev->tp_urb, udev, - usb_rcvintpipe(udev, cfg->tp_ep), - dev->tp_data, dev->cfg.tp_datalen, - irq_trackpad, dev, 1); + usb_rcvintpipe(udev, cfg->tp_ep), + dev->tp_data, dev->cfg.tp_datalen, + bcm5974_irq_trackpad, dev, 1); /* create bcm5974 device */ usb_make_path(udev, dev->phys, sizeof(dev->phys)); @@ -638,24 +648,23 @@ static void bcm5974_disconnect(struct usb_interface *iface) input_unregister_device(dev->input); usb_buffer_free(dev->udev, dev->cfg.tp_datalen, - dev->tp_data, dev->tp_urb->transfer_dma); + dev->tp_data, dev->tp_urb->transfer_dma); usb_buffer_free(dev->udev, dev->cfg.bt_datalen, - dev->bt_data, dev->bt_urb->transfer_dma); + dev->bt_data, dev->bt_urb->transfer_dma); usb_free_urb(dev->tp_urb); usb_free_urb(dev->bt_urb); kfree(dev); - - printk(KERN_INFO "bcm5974: disconnected\n"); } static struct usb_driver bcm5974_driver = { - .name = "bcm5974", - .probe = bcm5974_probe, - .disconnect = bcm5974_disconnect, - .suspend = bcm5974_suspend, - .resume = bcm5974_resume, - .reset_resume = bcm5974_resume, - .id_table = bcm5974_table, + .name = "bcm5974", + .probe = bcm5974_probe, + .disconnect = bcm5974_disconnect, + .suspend = bcm5974_suspend, + .resume = bcm5974_resume, + .reset_resume = bcm5974_resume, + .id_table = bcm5974_table, + .supports_autosuspend = 1, }; static int __init bcm5974_init(void) diff --git a/dkms.conf b/dkms.conf index 251efb1..3709c2d 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.58" +PACKAGE_VERSION="0.59" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" -- cgit v1.2.3 From badbf2522bf71d23817f9266f5a3ad9d545f53a8 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:29:18 +0200 Subject: bcm5974 (0.60) unstable; urgency=low * New default mouse driver mode * Mouse configuration parameters -- Henrik Rydberg Mon, 01 Sep 2008 18:38:21 +0200 --- CHANGES | 7 ++ bcm5974-dkms-mkdeb/debian/changelog | 4 +- bcm5974.c | 234 ++++++++++++++++++++++++++++++------ dkms.conf | 2 +- etc/modprobe.d/bcm5974 | 15 +++ 5 files changed, 220 insertions(+), 42 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index 0f80cb1..8544468 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +bcm5974 (0.60) unstable; urgency=low + + * New default mouse driver mode + * Mouse configuration parameters + + -- Henrik Rydberg Mon, 01 Sep 2008 18:38:21 +0200 + bcm5974 (0.59) unstable; urgency=low * Cleanup patch from Dmitry Torokhov diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index 9c8bd7b..aff6ab4 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,6 +1,6 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * Cleanup patch from Dmitry Torokhov - * Auto-suspend patch from Dmitry Torokhov + * New default mouse driver mode + * Mouse configuration parameters -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974.c b/bcm5974.c index 710d0ac..9aca008 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -63,7 +63,7 @@ } /* table of devices that work with this driver */ -static const struct usb_device_id bcm5974_table [] = { +static const struct usb_device_id bcm5974_table[] = { /* MacbookAir1.1 */ BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ANSI), BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING_ISO), @@ -84,10 +84,33 @@ MODULE_LICENSE("GPL"); #define dprintk(level, format, a...)\ { if (debug >= level) printk(KERN_DEBUG format, ##a); } +#define MODE_MOUSE 1 +#define MODE_TOUCHPAD 2 + static int debug = 1; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Activate debugging output"); +static int driver_mode = MODE_MOUSE; +module_param(driver_mode, int, 0644); +MODULE_PARM_DESC(driver_mode, "Driver mode (1 - mouse; 2 - touchpad)"); + +static int mouse_motion_damping = 8; +module_param(mouse_motion_damping, int, 0644); +MODULE_PARM_DESC(mouse_motion_damping, "Mouse motion damping"); + +static int mouse_wheel_damping = 256; +module_param(mouse_wheel_damping, int, 0644); +MODULE_PARM_DESC(mouse_wheel_damping, "Vertical mouse wheel damping"); + +static int mouse_hwheel_damping = 256; +module_param(mouse_hwheel_damping, int, 0644); +MODULE_PARM_DESC(mouse_hwheel_damping, "Horizontal mouse wheel damping"); + +static int mouse_button_mode = 2; +module_param(mouse_button_mode, int, 0644); +MODULE_PARM_DESC(mouse_button_mode, "Mouse button mode (1 - unix; 2 - macos)"); + /* button data structure */ struct bt_data { u8 unknown1; /* constant */ @@ -146,6 +169,13 @@ struct bcm5974_config { struct bcm5974_param y; /* vertical limits */ }; +/* mouse driver state */ +struct bcm5974_mouse_state { + int fingers; /* number of fingers on trackpad */ + int wheel; /* vertical wheel counter */ + int hwheel; /* horizontal wheel counter */ +}; + /* logical device structure */ struct bcm5974 { char phys[64]; @@ -159,6 +189,7 @@ struct bcm5974 { struct bt_data *bt_data; /* button transferred data */ struct urb *tp_urb; /* trackpad usb request block */ struct tp_data *tp_data; /* trackpad transferred data */ + struct bcm5974_mouse_state ms; /* mouse state */ }; /* logical dimensions */ @@ -229,79 +260,204 @@ static inline int int2bound(const struct bcm5974_param *p, int x) { int s = int2scale(p, x); -// return clamp_val(s, 0, p->dim - 1); - return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; +// return clamp_val(s, 0, p->dim - 1); + return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; } /* setup which logical events to report */ static void setup_events_to_report(struct input_dev *input_dev, const struct bcm5974_config *cfg) { - __set_bit(EV_ABS, input_dev->evbit); - - input_set_abs_params(input_dev, ABS_PRESSURE, - 0, cfg->p.dim, cfg->p.fuzz, 0); - input_set_abs_params(input_dev, ABS_TOOL_WIDTH, - 0, cfg->w.dim, cfg->w.fuzz, 0); - input_set_abs_params(input_dev, ABS_X, - 0, cfg->x.dim, cfg->x.fuzz, 0); - input_set_abs_params(input_dev, ABS_Y, - 0, cfg->y.dim, cfg->y.fuzz, 0); - __set_bit(EV_KEY, input_dev->evbit); - __set_bit(BTN_TOOL_FINGER, input_dev->keybit); - __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); - __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); __set_bit(BTN_LEFT, input_dev->keybit); + + switch (driver_mode) { + case MODE_MOUSE: + __set_bit(EV_REL, input_dev->evbit); + __set_bit(REL_X, input_dev->relbit); + __set_bit(REL_Y, input_dev->relbit); + __set_bit(REL_WHEEL, input_dev->relbit); + __set_bit(REL_HWHEEL, input_dev->relbit); + __set_bit(BTN_MIDDLE, input_dev->keybit); + __set_bit(BTN_RIGHT, input_dev->keybit); + break; + case MODE_TOUCHPAD: + __set_bit(EV_ABS, input_dev->evbit); + __set_bit(BTN_TOOL_FINGER, input_dev->keybit); + __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); + __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); + + input_set_abs_params(input_dev, ABS_PRESSURE, + 0, cfg->p.dim, cfg->p.fuzz, 0); + input_set_abs_params(input_dev, ABS_TOOL_WIDTH, + 0, cfg->w.dim, cfg->w.fuzz, 0); + input_set_abs_params(input_dev, ABS_X, + 0, cfg->x.dim, cfg->x.fuzz, 0); + input_set_abs_params(input_dev, ABS_Y, + 0, cfg->y.dim, cfg->y.fuzz, 0); + break; + } } -/* report button data as logical button state */ +/* update logical mouse button state */ +static void update_bt_mouse_state(struct input_dev *dev, + const struct bcm5974_mouse_state *ms, + const struct bt_data *bt) +{ + const int n = ms->fingers; + + bool left, middle, right; + switch (mouse_button_mode) { + case 1: + left = n <= 1 && bt->button; + middle = n == 2 && bt->button; + right = n >= 3 && bt->button; + break; + case 2: + left = n <= 1 && bt->button; + middle = n >= 3 && bt->button; + right = n == 2 && bt->button; + break; + default: + left = bt->button; + middle = false; + right = false; + break; + }; + input_report_key(dev, BTN_LEFT, left); + input_report_key(dev, BTN_MIDDLE, middle); + input_report_key(dev, BTN_RIGHT, right); +} + +/* update logical touchpad button state */ +static void update_bt_touchpad_state(struct input_dev *dev, + const struct bt_data *bt) +{ + input_report_key(dev, BTN_LEFT, bt->button); +} + +/* report button data as logical mouse/touchpad button state */ static int report_bt_state(struct bcm5974 *dev, int size) { if (size != sizeof(struct bt_data)) return -EIO; - input_report_key(dev->input, BTN_LEFT, dev->bt_data->button); + switch (driver_mode) { + case MODE_MOUSE: + update_bt_mouse_state(dev->input, &dev->ms, dev->bt_data); + break; + case MODE_TOUCHPAD: + update_bt_touchpad_state(dev->input, dev->bt_data); + break; + } + input_sync(dev->input); return 0; } -/* report trackpad data as logical trackpad state */ -static int report_tp_state(struct bcm5974 *dev, int size) +/* update logical mouse motion state */ +static void update_tp_mouse_state(struct input_dev *dev, + struct bcm5974_mouse_state *ms, + const struct bcm5974_config *c, + const struct tp_finger *f, + int p, int n) { - const struct bcm5974_config *c = &dev->cfg; - const struct tp_finger *f = dev->tp_data->finger; - struct input_dev *input = dev->input; - const int fingers = (size - 26) / 28; - int p = 0, w, x, y, n = 0; + int dx = 0, dy = 0, sx = 0, sy = 0, sw = 0, shw = 0; - if (size < 26 || (size - 26) % 28 != 0) - return -EIO; + if (f) { + dx = raw2int(f->rel_x); + dy = raw2int(f->rel_y); - if (fingers) { - p = raw2int(f->force_major); + dprintk(9, + "bcm5974: p: %+05d dx: %+05d dy: %+05d n: %d\n", + p, dx, dy, n); + } + + if (n >= 3) { + /* swipe */ + ms->wheel = 0; + ms->hwheel += int2scale(&c->x, dx); + shw = ms->hwheel / mouse_hwheel_damping; + ms->hwheel -= shw * mouse_hwheel_damping; + } else if (n == 2) { + /* scroll */ + ms->wheel += int2scale(&c->y, dy); + ms->hwheel = 0; + sw = ms->wheel / mouse_wheel_damping; + ms->wheel -= sw * mouse_wheel_damping; + } else { + /* pointer */ + ms->wheel = 0; + ms->hwheel = 0; + sx = int2scale(&c->x, dx) / mouse_motion_damping; + sy = int2scale(&c->y, -dy) / mouse_motion_damping; + } + + ms->fingers = n; + + input_report_rel(dev, REL_X, sx); + input_report_rel(dev, REL_Y, sy); + input_report_rel(dev, REL_WHEEL, sw); + input_report_rel(dev, REL_HWHEEL, shw); +} + +/* update logical touchpad state */ +static void update_tp_touchpad_state(struct input_dev *dev, + const struct bcm5974_config *c, + const struct tp_finger *f, + int p, int n) +{ + int w, x, y; + + if (f) { w = raw2int(f->size_major); x = raw2int(f->abs_x); y = raw2int(f->abs_y); - n = p > 0 ? fingers : 0; dprintk(9, "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", p, w, x, y, n); - input_report_abs(input, ABS_TOOL_WIDTH, int2bound(&c->w, w)); - input_report_abs(input, ABS_X, int2bound(&c->x, x - c->x.devmin)); - input_report_abs(input, ABS_Y, int2bound(&c->y, c->y.devmax - y)); + input_report_abs(dev, ABS_TOOL_WIDTH, int2bound(&c->w, w)); + input_report_abs(dev, ABS_X, int2bound(&c->x, x - c->x.devmin)); + input_report_abs(dev, ABS_Y, int2bound(&c->y, c->y.devmax - y)); } - input_report_abs(input, ABS_PRESSURE, int2bound(&c->p, p)); + input_report_abs(dev, ABS_PRESSURE, int2bound(&c->p, p)); + + input_report_key(dev, BTN_TOOL_FINGER, n == 1); + input_report_key(dev, BTN_TOOL_DOUBLETAP, n == 2); + input_report_key(dev, BTN_TOOL_TRIPLETAP, n > 2); +} + +/* report trackpad data as logical mouse/touchpad state */ +static int report_tp_state(struct bcm5974 *dev, int size) +{ + const struct bcm5974_config *c = &dev->cfg; + const int fingers = (size - 26) / 28; + const struct tp_finger *f = 0; + int p = 0, n = 0; + + if (size < 26 || (size - 26) % 28 != 0) + return -EIO; + + if (fingers) { + f = dev->tp_data->finger; + p = raw2int(f->force_major); + n = p > 0 ? fingers : 0; + } - input_report_key(input, BTN_TOOL_FINGER, n == 1); - input_report_key(input, BTN_TOOL_DOUBLETAP, n == 2); - input_report_key(input, BTN_TOOL_TRIPLETAP, n > 2); + switch (driver_mode) { + case MODE_MOUSE: + update_tp_mouse_state(dev->input, &dev->ms, c, f, p, n); + break; + case MODE_TOUCHPAD: + update_tp_touchpad_state(dev->input, c, f, p, n); + break; + } - input_sync(input); + input_sync(dev->input); return 0; } diff --git a/dkms.conf b/dkms.conf index 3709c2d..fa3d9e5 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.59" +PACKAGE_VERSION="0.60" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" diff --git a/etc/modprobe.d/bcm5974 b/etc/modprobe.d/bcm5974 index 81cd5ce..8a0e017 100644 --- a/etc/modprobe.d/bcm5974 +++ b/etc/modprobe.d/bcm5974 @@ -8,3 +8,18 @@ ## Debug level - uncomment this to get raw packets in /var/log/debug #options bcm5974 debug=99 + +## Driver mode: 1 - mouse; 2 - touchpad +options bcm5974 driver_mode=2 + +## Mouse motion damping +#options bcm5974 mouse_motion_damping=8 + +## Vertical mouse wheel damping +#options bcm5974 mouse_wheel_damping=256 + +## Horizontal mouse wheel damping +#options bcm5974 mouse_hwheel_damping=256 + +## Mouse button mode: 0 - standard; 1 - unix three-button; 2 - mac three-button +#options bcm5974 mouse_button_mode=2 -- cgit v1.2.3 From a02d4536f5b8929d33409579246631dadaa171c0 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:29:44 +0200 Subject: bcm5974 (0.61) unstable; urgency=low * Smoother motion in mouse interface -- Henrik Rydberg Mon, 01 Sep 2008 21:01:24 +0200 --- CHANGES | 6 +++++ bcm5974-dkms-mkdeb/debian/changelog | 3 +-- bcm5974.c | 46 ++++++++++++++++++++++--------------- dkms.conf | 2 +- 4 files changed, 36 insertions(+), 21 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index 8544468..f56506d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +bcm5974 (0.61) unstable; urgency=low + + * Smoother motion in mouse interface + + -- Henrik Rydberg Mon, 01 Sep 2008 21:01:24 +0200 + bcm5974 (0.60) unstable; urgency=low * New default mouse driver mode diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index aff6ab4..1ab2521 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,6 +1,5 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * New default mouse driver mode - * Mouse configuration parameters + * Smoother motion in mouse interface -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974.c b/bcm5974.c index 9aca008..9b67b2a 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -172,8 +172,10 @@ struct bcm5974_config { /* mouse driver state */ struct bcm5974_mouse_state { int fingers; /* number of fingers on trackpad */ - int wheel; /* vertical wheel counter */ - int hwheel; /* horizontal wheel counter */ + int rel_x; /* horizontal relative counter */ + int rel_y; /* vertical relative counter */ + int wheel_x; /* horizontal wheel counter */ + int wheel_y; /* vertical wheel counter */ }; /* logical device structure */ @@ -276,8 +278,8 @@ static void setup_events_to_report(struct input_dev *input_dev, __set_bit(EV_REL, input_dev->evbit); __set_bit(REL_X, input_dev->relbit); __set_bit(REL_Y, input_dev->relbit); - __set_bit(REL_WHEEL, input_dev->relbit); __set_bit(REL_HWHEEL, input_dev->relbit); + __set_bit(REL_WHEEL, input_dev->relbit); __set_bit(BTN_MIDDLE, input_dev->keybit); __set_bit(BTN_RIGHT, input_dev->keybit); break; @@ -363,7 +365,7 @@ static void update_tp_mouse_state(struct input_dev *dev, const struct tp_finger *f, int p, int n) { - int dx = 0, dy = 0, sx = 0, sy = 0, sw = 0, shw = 0; + int dx = 0, dy = 0, sx = 0, sy = 0, swx = 0, swy = 0; if (f) { dx = raw2int(f->rel_x); @@ -376,30 +378,38 @@ static void update_tp_mouse_state(struct input_dev *dev, if (n >= 3) { /* swipe */ - ms->wheel = 0; - ms->hwheel += int2scale(&c->x, dx); - shw = ms->hwheel / mouse_hwheel_damping; - ms->hwheel -= shw * mouse_hwheel_damping; + ms->rel_x = 0; + ms->rel_y = 0; + ms->wheel_x += int2scale(&c->x, dx); + ms->wheel_y = 0; + swx = ms->wheel_x / mouse_hwheel_damping; + ms->wheel_x -= swx * mouse_hwheel_damping; } else if (n == 2) { /* scroll */ - ms->wheel += int2scale(&c->y, dy); - ms->hwheel = 0; - sw = ms->wheel / mouse_wheel_damping; - ms->wheel -= sw * mouse_wheel_damping; + ms->rel_x = 0; + ms->rel_y = 0; + ms->wheel_x = 0; + ms->wheel_y += int2scale(&c->y, dy); + swy = ms->wheel_y / mouse_wheel_damping; + ms->wheel_y -= swy * mouse_wheel_damping; } else { /* pointer */ - ms->wheel = 0; - ms->hwheel = 0; - sx = int2scale(&c->x, dx) / mouse_motion_damping; - sy = int2scale(&c->y, -dy) / mouse_motion_damping; + ms->rel_x += int2scale(&c->x, dx); + ms->rel_y += int2scale(&c->y, -dy); + ms->wheel_x = 0; + ms->wheel_y = 0; + sx = ms->rel_x / mouse_motion_damping; + sy = ms->rel_y / mouse_motion_damping; + ms->rel_x -= sx * mouse_motion_damping; + ms->rel_y -= sy * mouse_motion_damping; } ms->fingers = n; input_report_rel(dev, REL_X, sx); input_report_rel(dev, REL_Y, sy); - input_report_rel(dev, REL_WHEEL, sw); - input_report_rel(dev, REL_HWHEEL, shw); + input_report_rel(dev, REL_HWHEEL, swx); + input_report_rel(dev, REL_WHEEL, swy); } /* update logical touchpad state */ diff --git a/dkms.conf b/dkms.conf index fa3d9e5..07c7af3 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.60" +PACKAGE_VERSION="0.61" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" -- cgit v1.2.3 From bb6f9218ca4f9ee5188ddfbd80e177ddab6c6fd6 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:30:21 +0200 Subject: bcm5974 (0.62) unstable; urgency=low * Compatibility mode reverted * BTN_TOUCH event added for mousedev -- Henrik Rydberg Tue, 02 Sep 2008 20:46:51 +0200 --- CHANGES | 7 ++ bcm5974-dkms-mkdeb/debian/changelog | 3 +- bcm5974.c | 240 ++++++------------------------------ dkms.conf | 2 +- etc/modprobe.d/bcm5974 | 15 --- 5 files changed, 48 insertions(+), 219 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index f56506d..5bed2e7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,10 @@ +bcm5974 (0.62) unstable; urgency=low + + * Compatibility mode reverted + * BTN_TOUCH event added for mousedev + + -- Henrik Rydberg Tue, 02 Sep 2008 20:46:51 +0200 + bcm5974 (0.61) unstable; urgency=low * Smoother motion in mouse interface diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index 1ab2521..ccb4bc3 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,5 +1,6 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * Smoother motion in mouse interface + * Compatibility mode reverted + * BTN_TOUCH event added for mousedev -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974.c b/bcm5974.c index 9b67b2a..65281de 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -84,33 +84,10 @@ MODULE_LICENSE("GPL"); #define dprintk(level, format, a...)\ { if (debug >= level) printk(KERN_DEBUG format, ##a); } -#define MODE_MOUSE 1 -#define MODE_TOUCHPAD 2 - static int debug = 1; module_param(debug, int, 0644); MODULE_PARM_DESC(debug, "Activate debugging output"); -static int driver_mode = MODE_MOUSE; -module_param(driver_mode, int, 0644); -MODULE_PARM_DESC(driver_mode, "Driver mode (1 - mouse; 2 - touchpad)"); - -static int mouse_motion_damping = 8; -module_param(mouse_motion_damping, int, 0644); -MODULE_PARM_DESC(mouse_motion_damping, "Mouse motion damping"); - -static int mouse_wheel_damping = 256; -module_param(mouse_wheel_damping, int, 0644); -MODULE_PARM_DESC(mouse_wheel_damping, "Vertical mouse wheel damping"); - -static int mouse_hwheel_damping = 256; -module_param(mouse_hwheel_damping, int, 0644); -MODULE_PARM_DESC(mouse_hwheel_damping, "Horizontal mouse wheel damping"); - -static int mouse_button_mode = 2; -module_param(mouse_button_mode, int, 0644); -MODULE_PARM_DESC(mouse_button_mode, "Mouse button mode (1 - unix; 2 - macos)"); - /* button data structure */ struct bt_data { u8 unknown1; /* constant */ @@ -169,15 +146,6 @@ struct bcm5974_config { struct bcm5974_param y; /* vertical limits */ }; -/* mouse driver state */ -struct bcm5974_mouse_state { - int fingers; /* number of fingers on trackpad */ - int rel_x; /* horizontal relative counter */ - int rel_y; /* vertical relative counter */ - int wheel_x; /* horizontal wheel counter */ - int wheel_y; /* vertical wheel counter */ -}; - /* logical device structure */ struct bcm5974 { char phys[64]; @@ -191,7 +159,6 @@ struct bcm5974 { struct bt_data *bt_data; /* button transferred data */ struct urb *tp_urb; /* trackpad usb request block */ struct tp_data *tp_data; /* trackpad transferred data */ - struct bcm5974_mouse_state ms; /* mouse state */ }; /* logical dimensions */ @@ -270,204 +237,73 @@ static inline int int2bound(const struct bcm5974_param *p, int x) static void setup_events_to_report(struct input_dev *input_dev, const struct bcm5974_config *cfg) { - __set_bit(EV_KEY, input_dev->evbit); - __set_bit(BTN_LEFT, input_dev->keybit); + __set_bit(EV_ABS, input_dev->evbit); - switch (driver_mode) { - case MODE_MOUSE: - __set_bit(EV_REL, input_dev->evbit); - __set_bit(REL_X, input_dev->relbit); - __set_bit(REL_Y, input_dev->relbit); - __set_bit(REL_HWHEEL, input_dev->relbit); - __set_bit(REL_WHEEL, input_dev->relbit); - __set_bit(BTN_MIDDLE, input_dev->keybit); - __set_bit(BTN_RIGHT, input_dev->keybit); - break; - case MODE_TOUCHPAD: - __set_bit(EV_ABS, input_dev->evbit); - __set_bit(BTN_TOOL_FINGER, input_dev->keybit); - __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); - __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); - - input_set_abs_params(input_dev, ABS_PRESSURE, - 0, cfg->p.dim, cfg->p.fuzz, 0); - input_set_abs_params(input_dev, ABS_TOOL_WIDTH, - 0, cfg->w.dim, cfg->w.fuzz, 0); - input_set_abs_params(input_dev, ABS_X, - 0, cfg->x.dim, cfg->x.fuzz, 0); - input_set_abs_params(input_dev, ABS_Y, - 0, cfg->y.dim, cfg->y.fuzz, 0); - break; - } -} + input_set_abs_params(input_dev, ABS_PRESSURE, + 0, cfg->p.dim, cfg->p.fuzz, 0); + input_set_abs_params(input_dev, ABS_TOOL_WIDTH, + 0, cfg->w.dim, cfg->w.fuzz, 0); + input_set_abs_params(input_dev, ABS_X, + 0, cfg->x.dim, cfg->x.fuzz, 0); + input_set_abs_params(input_dev, ABS_Y, + 0, cfg->y.dim, cfg->y.fuzz, 0); -/* update logical mouse button state */ -static void update_bt_mouse_state(struct input_dev *dev, - const struct bcm5974_mouse_state *ms, - const struct bt_data *bt) -{ - const int n = ms->fingers; - - bool left, middle, right; - switch (mouse_button_mode) { - case 1: - left = n <= 1 && bt->button; - middle = n == 2 && bt->button; - right = n >= 3 && bt->button; - break; - case 2: - left = n <= 1 && bt->button; - middle = n >= 3 && bt->button; - right = n == 2 && bt->button; - break; - default: - left = bt->button; - middle = false; - right = false; - break; - }; - input_report_key(dev, BTN_LEFT, left); - input_report_key(dev, BTN_MIDDLE, middle); - input_report_key(dev, BTN_RIGHT, right); -} - -/* update logical touchpad button state */ -static void update_bt_touchpad_state(struct input_dev *dev, - const struct bt_data *bt) -{ - input_report_key(dev, BTN_LEFT, bt->button); + __set_bit(EV_KEY, input_dev->evbit); + __set_bit(BTN_TOUCH, input_dev->keybit); + __set_bit(BTN_TOOL_FINGER, input_dev->keybit); + __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); + __set_bit(BTN_TOOL_TRIPLETAP, input_dev->keybit); + __set_bit(BTN_LEFT, input_dev->keybit); } -/* report button data as logical mouse/touchpad button state */ +/* report button data as logical button state */ static int report_bt_state(struct bcm5974 *dev, int size) { if (size != sizeof(struct bt_data)) return -EIO; - switch (driver_mode) { - case MODE_MOUSE: - update_bt_mouse_state(dev->input, &dev->ms, dev->bt_data); - break; - case MODE_TOUCHPAD: - update_bt_touchpad_state(dev->input, dev->bt_data); - break; - } - + input_report_key(dev->input, BTN_LEFT, dev->bt_data->button); input_sync(dev->input); return 0; } -/* update logical mouse motion state */ -static void update_tp_mouse_state(struct input_dev *dev, - struct bcm5974_mouse_state *ms, - const struct bcm5974_config *c, - const struct tp_finger *f, - int p, int n) +/* report trackpad data as logical trackpad state */ +static int report_tp_state(struct bcm5974 *dev, int size) { - int dx = 0, dy = 0, sx = 0, sy = 0, swx = 0, swy = 0; - - if (f) { - dx = raw2int(f->rel_x); - dy = raw2int(f->rel_y); - - dprintk(9, - "bcm5974: p: %+05d dx: %+05d dy: %+05d n: %d\n", - p, dx, dy, n); - } - - if (n >= 3) { - /* swipe */ - ms->rel_x = 0; - ms->rel_y = 0; - ms->wheel_x += int2scale(&c->x, dx); - ms->wheel_y = 0; - swx = ms->wheel_x / mouse_hwheel_damping; - ms->wheel_x -= swx * mouse_hwheel_damping; - } else if (n == 2) { - /* scroll */ - ms->rel_x = 0; - ms->rel_y = 0; - ms->wheel_x = 0; - ms->wheel_y += int2scale(&c->y, dy); - swy = ms->wheel_y / mouse_wheel_damping; - ms->wheel_y -= swy * mouse_wheel_damping; - } else { - /* pointer */ - ms->rel_x += int2scale(&c->x, dx); - ms->rel_y += int2scale(&c->y, -dy); - ms->wheel_x = 0; - ms->wheel_y = 0; - sx = ms->rel_x / mouse_motion_damping; - sy = ms->rel_y / mouse_motion_damping; - ms->rel_x -= sx * mouse_motion_damping; - ms->rel_y -= sy * mouse_motion_damping; - } - - ms->fingers = n; - - input_report_rel(dev, REL_X, sx); - input_report_rel(dev, REL_Y, sy); - input_report_rel(dev, REL_HWHEEL, swx); - input_report_rel(dev, REL_WHEEL, swy); -} + const struct bcm5974_config *c = &dev->cfg; + const struct tp_finger *f = dev->tp_data->finger; + struct input_dev *input = dev->input; + const int fingers = (size - 26) / 28; + int p = 0, w, x, y, n = 0; -/* update logical touchpad state */ -static void update_tp_touchpad_state(struct input_dev *dev, - const struct bcm5974_config *c, - const struct tp_finger *f, - int p, int n) -{ - int w, x, y; + if (size < 26 || (size - 26) % 28 != 0) + return -EIO; - if (f) { + if (fingers) { + p = raw2int(f->force_major); w = raw2int(f->size_major); x = raw2int(f->abs_x); y = raw2int(f->abs_y); + n = p > 0 ? fingers : 0; dprintk(9, "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", p, w, x, y, n); - input_report_abs(dev, ABS_TOOL_WIDTH, int2bound(&c->w, w)); - input_report_abs(dev, ABS_X, int2bound(&c->x, x - c->x.devmin)); - input_report_abs(dev, ABS_Y, int2bound(&c->y, c->y.devmax - y)); + input_report_abs(input, ABS_TOOL_WIDTH, int2bound(&c->w, w)); + input_report_abs(input, ABS_X, int2bound(&c->x, x - c->x.devmin)); + input_report_abs(input, ABS_Y, int2bound(&c->y, c->y.devmax - y)); } - input_report_abs(dev, ABS_PRESSURE, int2bound(&c->p, p)); - - input_report_key(dev, BTN_TOOL_FINGER, n == 1); - input_report_key(dev, BTN_TOOL_DOUBLETAP, n == 2); - input_report_key(dev, BTN_TOOL_TRIPLETAP, n > 2); -} - -/* report trackpad data as logical mouse/touchpad state */ -static int report_tp_state(struct bcm5974 *dev, int size) -{ - const struct bcm5974_config *c = &dev->cfg; - const int fingers = (size - 26) / 28; - const struct tp_finger *f = 0; - int p = 0, n = 0; - - if (size < 26 || (size - 26) % 28 != 0) - return -EIO; - - if (fingers) { - f = dev->tp_data->finger; - p = raw2int(f->force_major); - n = p > 0 ? fingers : 0; - } + input_report_abs(input, ABS_PRESSURE, int2bound(&c->p, p)); - switch (driver_mode) { - case MODE_MOUSE: - update_tp_mouse_state(dev->input, &dev->ms, c, f, p, n); - break; - case MODE_TOUCHPAD: - update_tp_touchpad_state(dev->input, c, f, p, n); - break; - } + input_report_key(input, BTN_TOUCH, p > 0); + input_report_key(input, BTN_TOOL_FINGER, n == 1); + input_report_key(input, BTN_TOOL_DOUBLETAP, n == 2); + input_report_key(input, BTN_TOOL_TRIPLETAP, n > 2); - input_sync(dev->input); + input_sync(input); return 0; } diff --git a/dkms.conf b/dkms.conf index 07c7af3..0c75a98 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.61" +PACKAGE_VERSION="0.62" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" diff --git a/etc/modprobe.d/bcm5974 b/etc/modprobe.d/bcm5974 index 8a0e017..81cd5ce 100644 --- a/etc/modprobe.d/bcm5974 +++ b/etc/modprobe.d/bcm5974 @@ -8,18 +8,3 @@ ## Debug level - uncomment this to get raw packets in /var/log/debug #options bcm5974 debug=99 - -## Driver mode: 1 - mouse; 2 - touchpad -options bcm5974 driver_mode=2 - -## Mouse motion damping -#options bcm5974 mouse_motion_damping=8 - -## Vertical mouse wheel damping -#options bcm5974 mouse_wheel_damping=256 - -## Horizontal mouse wheel damping -#options bcm5974 mouse_hwheel_damping=256 - -## Mouse button mode: 0 - standard; 1 - unix three-button; 2 - mac three-button -#options bcm5974 mouse_button_mode=2 -- cgit v1.2.3 From 98625bc2be4a6009d4f90598c3ea111ef0f30d87 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:31:06 +0200 Subject: bcm5974 (0.64) unstable; urgency=low * Finger counting improved further -- Henrik Rydberg Wed, 03 Sep 2008 21:58:38 +0200 bcm5974 (0.63) unstable; urgency=low * Finger pressure hysteresis added -- Henrik Rydberg Wed, 03 Sep 2008 13:26:29 +0200 --- CHANGES | 12 ++++++ bcm5974-dkms-mkdeb/debian/changelog | 3 +- bcm5974.c | 76 +++++++++++++++++++++++++++---------- dkms.conf | 2 +- 4 files changed, 71 insertions(+), 22 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index 5bed2e7..01f0cd9 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,15 @@ +bcm5974 (0.64) unstable; urgency=low + + * Finger counting improved further + + -- Henrik Rydberg Wed, 03 Sep 2008 21:58:38 +0200 + +bcm5974 (0.63) unstable; urgency=low + + * Finger pressure hysteresis added + + -- Henrik Rydberg Wed, 03 Sep 2008 13:26:29 +0200 + bcm5974 (0.62) unstable; urgency=low * Compatibility mode reverted diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index ccb4bc3..f6d016a 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,6 +1,5 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * Compatibility mode reverted - * BTN_TOUCH event added for mousedev + * Finger counting improved further -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974.c b/bcm5974.c index 65281de..d3d08e3 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -105,7 +105,7 @@ struct tp_header { /* trackpad finger structure */ struct tp_finger { - __le16 origin; /* left/right origin? */ + __le16 origin; /* zero when switching track finger */ __le16 abs_x; /* absolute x coodinate */ __le16 abs_y; /* absolute y coodinate */ __le16 rel_x; /* relative x coodinate */ @@ -159,6 +159,7 @@ struct bcm5974 { struct bt_data *bt_data; /* button transferred data */ struct urb *tp_urb; /* trackpad usb request block */ struct tp_data *tp_data; /* trackpad transferred data */ + int fingers; /* number of fingers on trackpad */ }; /* logical dimensions */ @@ -172,6 +173,10 @@ struct bcm5974 { #define SN_WIDTH 100 /* width signal-to-noise ratio */ #define SN_COORD 250 /* coordinate signal-to-noise ratio */ +/* pressure thresholds */ +#define PRESSURE_LOW (2 * DIM_PRESSURE / SN_PRESSURE) +#define PRESSURE_HIGH (3 * PRESSURE_LOW) + /* device constants */ static const struct bcm5974_config bcm5974_config_table[] = { { @@ -229,8 +234,8 @@ static inline int int2bound(const struct bcm5974_param *p, int x) { int s = int2scale(p, x); -// return clamp_val(s, 0, p->dim - 1); - return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; +// return clamp_val(s, 0, p->dim - 1); + return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; } /* setup which logical events to report */ @@ -275,33 +280,66 @@ static int report_tp_state(struct bcm5974 *dev, int size) const struct tp_finger *f = dev->tp_data->finger; struct input_dev *input = dev->input; const int fingers = (size - 26) / 28; - int p = 0, w, x, y, n = 0; + int raw_p, raw_w, raw_x, raw_y; + int ptest = 0, origin = 0, nmin = 0, nmax = 0; + int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0; if (size < 26 || (size - 26) % 28 != 0) return -EIO; + /* always track the first finger; when detached, start over */ if (fingers) { - p = raw2int(f->force_major); - w = raw2int(f->size_major); - x = raw2int(f->abs_x); - y = raw2int(f->abs_y); - n = p > 0 ? fingers : 0; + raw_p = raw2int(f->force_major); + raw_w = raw2int(f->size_major); + raw_x = raw2int(f->abs_x); + raw_y = raw2int(f->abs_y); dprintk(9, - "bcm5974: p: %+05d w: %+05d x: %+05d y: %+05d n: %d\n", - p, w, x, y, n); + "bcm5974: raw: p: %+05d w: %+05d x: %+05d y: %+05d\n", + raw_p, raw_w, raw_x, raw_y); + + ptest = int2bound(&c->p, raw_p); + origin = raw2int(f->origin); + } - input_report_abs(input, ABS_TOOL_WIDTH, int2bound(&c->w, w)); - input_report_abs(input, ABS_X, int2bound(&c->x, x - c->x.devmin)); - input_report_abs(input, ABS_Y, int2bound(&c->y, c->y.devmax - y)); + /* while tracking finger still valid, count all fingers */ + if (ptest > PRESSURE_LOW && origin) { + abs_p = ptest; + abs_w = int2bound(&c->w, raw_w); + abs_x = int2bound(&c->x, raw_x - c->x.devmin); + abs_y = int2bound(&c->y, c->y.devmax - raw_y); + for (; f != dev->tp_data->finger + fingers; f++) { + ptest = int2bound(&c->p, raw2int(f->force_major)); + if (ptest > PRESSURE_LOW) + nmax++; + if (ptest > PRESSURE_HIGH) + nmin++; + } } - input_report_abs(input, ABS_PRESSURE, int2bound(&c->p, p)); + if (dev->fingers < nmin) + dev->fingers = nmin; + if (dev->fingers > nmax) + dev->fingers = nmax; + + input_report_key(input, BTN_TOUCH, dev->fingers > 0); + input_report_key(input, BTN_TOOL_FINGER, dev->fingers == 1); + input_report_key(input, BTN_TOOL_DOUBLETAP, dev->fingers == 2); + input_report_key(input, BTN_TOOL_TRIPLETAP, dev->fingers > 2); - input_report_key(input, BTN_TOUCH, p > 0); - input_report_key(input, BTN_TOOL_FINGER, n == 1); - input_report_key(input, BTN_TOOL_DOUBLETAP, n == 2); - input_report_key(input, BTN_TOOL_TRIPLETAP, n > 2); + input_report_abs(input, ABS_PRESSURE, abs_p); + input_report_abs(input, ABS_TOOL_WIDTH, abs_w); + + if (abs_p) { + input_report_abs(input, ABS_X, abs_x); + input_report_abs(input, ABS_Y, abs_y); + + dprintk(8, + "bcm5974: abs: p: %+05d w: %+05d x: %+05d y: %+05d " + "nmin: %d nmax: %d n: %d\n", + abs_p, abs_w, abs_x, abs_y, nmin, nmax, dev->fingers); + + } input_sync(input); diff --git a/dkms.conf b/dkms.conf index 0c75a98..9d8587d 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.62" +PACKAGE_VERSION="0.64" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" -- cgit v1.2.3 From aa2d0bf085f624ad24deb0357d4fe935225ccd18 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Wed, 8 Oct 2008 23:31:59 +0200 Subject: bcm5974 (0.65) unstable; urgency=low * Switch back to normal mode when closing -- Henrik Rydberg Sun, 14 Sep 2008 16:06:42 +0200 --- CHANGES | 6 ++++++ bcm5974-dkms-mkdeb/debian/changelog | 2 +- bcm5974.c | 17 +++++++++++------ dkms.conf | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) (limited to 'CHANGES') diff --git a/CHANGES b/CHANGES index 01f0cd9..2850cef 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,9 @@ +bcm5974 (0.65) unstable; urgency=low + + * Switch back to normal mode when closing + + -- Henrik Rydberg Sun, 14 Sep 2008 16:06:42 +0200 + bcm5974 (0.64) unstable; urgency=low * Finger counting improved further diff --git a/bcm5974-dkms-mkdeb/debian/changelog b/bcm5974-dkms-mkdeb/debian/changelog index f6d016a..3ea1523 100644 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ b/bcm5974-dkms-mkdeb/debian/changelog @@ -1,5 +1,5 @@ MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - * Finger counting improved further + * Switch back to normal mode when closing -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974.c b/bcm5974.c index d3d08e3..bf6c59f 100644 --- a/bcm5974.c +++ b/bcm5974.c @@ -234,8 +234,8 @@ static inline int int2bound(const struct bcm5974_param *p, int x) { int s = int2scale(p, x); -// return clamp_val(s, 0, p->dim - 1); - return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; + //return clamp_val(s, 0, p->dim - 1); + return s < 0 ? 0 : s >= p->dim ? p->dim - 1 : s; } /* setup which logical events to report */ @@ -352,8 +352,9 @@ static int report_tp_state(struct bcm5974 *dev, int size) #define BCM5974_WELLSPRING_MODE_REQUEST_VALUE 0x300 #define BCM5974_WELLSPRING_MODE_REQUEST_INDEX 0 #define BCM5974_WELLSPRING_MODE_VENDOR_VALUE 0x01 +#define BCM5974_WELLSPRING_MODE_NORMAL_VALUE 0x08 -static int bcm5974_wellspring_mode(struct bcm5974 *dev) +static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on) { char *data = kmalloc(8, GFP_KERNEL); int retval = 0, size; @@ -378,7 +379,9 @@ static int bcm5974_wellspring_mode(struct bcm5974 *dev) } /* apply the mode switch */ - data[0] = BCM5974_WELLSPRING_MODE_VENDOR_VALUE; + data[0] = on ? + BCM5974_WELLSPRING_MODE_VENDOR_VALUE : + BCM5974_WELLSPRING_MODE_NORMAL_VALUE; /* write configuration */ size = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), @@ -393,7 +396,8 @@ static int bcm5974_wellspring_mode(struct bcm5974 *dev) goto out; } - dprintk(2, "bcm5974: switched to wellspring mode.\n"); + dprintk(2, "bcm5974: switched to %s mode.\n", + on ? "wellspring" : "normal"); out: kfree(data); @@ -482,7 +486,7 @@ exit: */ static int bcm5974_start_traffic(struct bcm5974 *dev) { - if (bcm5974_wellspring_mode(dev)) { + if (bcm5974_wellspring_mode(dev, true)) { dprintk(1, "bcm5974: mode switch failed\n"); goto error; } @@ -505,6 +509,7 @@ static void bcm5974_pause_traffic(struct bcm5974 *dev) { usb_kill_urb(dev->tp_urb); usb_kill_urb(dev->bt_urb); + bcm5974_wellspring_mode(dev, false); } /* diff --git a/dkms.conf b/dkms.conf index 9d8587d..aec50fa 100644 --- a/dkms.conf +++ b/dkms.conf @@ -1,5 +1,5 @@ PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.64" +PACKAGE_VERSION="0.65" MAKE[0]="make -C ${kernel_source_dir} SUBDIRS=${dkms_tree}/${PACKAGE_NAME}/${PACKAGE_VERSION}/build modules" BUILT_MODULE_NAME[0]="bcm5974" -- cgit v1.2.3