From eb8e529c4657c2e57e491ed8f38215708eed7fb5 Mon Sep 17 00:00:00 2001 From: Henrik Rydberg Date: Fri, 24 Oct 2008 23:53:30 +0200 Subject: Reorganize into a usable debian dkms package Signed-off-by: Henrik Rydberg --- CHANGES | 180 ----- INSTALL | 19 - LICENSE | 280 -------- Makefile | 33 +- README | 14 - bcm5974-dkms-mkdeb/Makefile | 10 - bcm5974-dkms-mkdeb/debian/README.Debian | 23 - bcm5974-dkms-mkdeb/debian/changelog | 5 - bcm5974-dkms-mkdeb/debian/compat | 1 - bcm5974-dkms-mkdeb/debian/control | 16 - bcm5974-dkms-mkdeb/debian/copyright | 41 -- bcm5974-dkms-mkdeb/debian/dirs | 1 - bcm5974-dkms-mkdeb/debian/postinst | 71 -- bcm5974-dkms-mkdeb/debian/postrm | 27 - bcm5974-dkms-mkdeb/debian/prerm | 28 - bcm5974-dkms-mkdeb/debian/rules | 53 -- bcm5974.c | 778 --------------------- debian/README.Debian | 23 + debian/changelog | 187 +++++ debian/compat | 1 + debian/control | 16 + debian/copyright | 41 ++ debian/dirs | 2 + debian/postinst | 71 ++ debian/postrm | 27 + debian/prerm | 28 + debian/rules | 53 ++ dkms.conf | 9 - scripts/bcm5974-diagnostics | 232 ------ scripts/bcm5974-post-install | 63 -- scripts/bcm5974-post-remove | 29 - scripts/bcm5974-pre-install | 42 -- scripts/patch-name-version.sh | 9 + usr/src/dkms_main_tree/dkms_dbversion | 1 + usr/src/dkms_source_tree/Makefile | 5 + usr/src/dkms_source_tree/bcm5974.c | 778 +++++++++++++++++++++ usr/src/dkms_source_tree/dkms.conf | 11 + .../dkms_source_tree/scripts/bcm5974-diagnostics | 232 ++++++ .../dkms_source_tree/scripts/bcm5974-post-install | 63 ++ .../dkms_source_tree/scripts/bcm5974-post-remove | 29 + .../dkms_source_tree/scripts/bcm5974-pre-install | 42 ++ 41 files changed, 1648 insertions(+), 1926 deletions(-) delete mode 100644 CHANGES delete mode 100644 INSTALL delete mode 100644 LICENSE delete mode 100644 README delete mode 100644 bcm5974-dkms-mkdeb/Makefile delete mode 100644 bcm5974-dkms-mkdeb/debian/README.Debian delete mode 100644 bcm5974-dkms-mkdeb/debian/changelog delete mode 100644 bcm5974-dkms-mkdeb/debian/compat delete mode 100644 bcm5974-dkms-mkdeb/debian/control delete mode 100644 bcm5974-dkms-mkdeb/debian/copyright delete mode 100644 bcm5974-dkms-mkdeb/debian/dirs delete mode 100644 bcm5974-dkms-mkdeb/debian/postinst delete mode 100644 bcm5974-dkms-mkdeb/debian/postrm delete mode 100644 bcm5974-dkms-mkdeb/debian/prerm delete mode 100644 bcm5974-dkms-mkdeb/debian/rules delete mode 100644 bcm5974.c create mode 100644 debian/README.Debian create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/postinst create mode 100644 debian/postrm create mode 100644 debian/prerm create mode 100755 debian/rules delete mode 100644 dkms.conf delete mode 100755 scripts/bcm5974-diagnostics delete mode 100755 scripts/bcm5974-post-install delete mode 100755 scripts/bcm5974-post-remove delete mode 100755 scripts/bcm5974-pre-install create mode 100755 scripts/patch-name-version.sh create mode 100644 usr/src/dkms_main_tree/dkms_dbversion create mode 100644 usr/src/dkms_source_tree/Makefile create mode 100644 usr/src/dkms_source_tree/bcm5974.c create mode 100644 usr/src/dkms_source_tree/dkms.conf create mode 100755 usr/src/dkms_source_tree/scripts/bcm5974-diagnostics create mode 100755 usr/src/dkms_source_tree/scripts/bcm5974-post-install create mode 100755 usr/src/dkms_source_tree/scripts/bcm5974-post-remove create mode 100755 usr/src/dkms_source_tree/scripts/bcm5974-pre-install diff --git a/CHANGES b/CHANGES deleted file mode 100644 index e1df040..0000000 --- a/CHANGES +++ /dev/null @@ -1,180 +0,0 @@ -bcm5974 (0.66) unstable; urgency=low - - * Add support for MacBook 5,1 (unibody) - - -- Henrik Rydberg Sun, 19 Oct 2008 17:23:26 +0200 - -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 - - -- 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 - * 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 - - -- Henrik Rydberg Mon, 01 Sep 2008 21:01:24 +0200 - -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 - * 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 - * 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 Sat, 19 Jul 2008 01:42:52 +0200 - -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. - * Reverting GFP_ATOMIC for irq handlers. - - -- Henrik Rydberg Wed, 09 Jul 2008 20:59:39 +0200 - -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 - -bcm5974 (0.53) unstable; urgency=low - - * Another typo in the post-install script. - - -- Henrik Rydberg Mon, 07 Jul 2008 20:59:39 +0200 - -bcm5974 (0.52) unstable; urgency=low - - * Typo in the post-install script. - - -- Henrik Rydberg Mon, 07 Jul 2008 20:09:39 +0200 - -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 - -bcm5974 (0.5) unstable; urgency=low - - * Working palm detection - * Changes for kernel.org - * DKMS introduced. - - -- Henrik Rydberg Sun, 06 Jul 2008 20:59:39 +0200 - -bcm5974 (0.42) unstable; urgency=low - - * First button click registered. - * Hooks pre/post-reset added. - - -- Henrik Rydberg Tue, 01 Jul 2008 20:59:39 +0200 - -bcm5974 (0.41) unstable; urgency=low - - * The reset_resume kernel function added. - - -- Henrik Rydberg Sun, 29 Jun 2008 20:59:39 +0200 - -bcm5974 (0.4) unstable; urgency=low - - * Both finger pressure and width reported. - - -- Henrik Rydberg Sun, 29 Jun 2008 18:59:39 +0200 - -bcm5974 (0.31) unstable; urgency=low - - * Administrative changes for kernel.org. - - -- Henrik Rydberg Fri, 27 Jun 2008 20:59:39 +0200 - -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 deleted file mode 100644 index 195fd05..0000000 --- a/INSTALL +++ /dev/null @@ -1,19 +0,0 @@ -Installation instructions bcm5974 ----------------------------------- - -Standing in the source directory, do: - -1. make -C /lib/modules/`uname -r`/build M=$PWD modules - -2. sudo cp bcm5974.ko /lib/modules/`uname -r`/kernel/drivers/input/mouse/ - -3. sudo ./scripts/bcm5974-post-install - -4. sudo depmod -a - -5. reboot (or reload the bcm5974 module if already installed) - -For trouble-shooting, try running - - ./scripts/bcm5974-diagnostics - diff --git a/LICENSE b/LICENSE deleted file mode 100644 index c7aea18..0000000 --- a/LICENSE +++ /dev/null @@ -1,280 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/Makefile b/Makefile index 6a04556..b750188 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,30 @@ -# -# Makefile for input/mouse drivers -# +NAME = bcm5974 +VERSION = 0.99 +SRC = usr/src -obj-m := bcm5974.o +TARBALL = $(NAME)-$(VERSION).dkms.tar.gz +PATCH = ./scripts/patch-name-version.sh $(NAME) $(VERSION) + +all: $(SRC)/$(TARBALL) + +$(SRC)/$(TARBALL): $(SRC)/dkms_source_tree/$(NAME).c + (cd $(SRC); tar cvfz $(TARBALL) dkms*) + +clean: + rm -f $(SRC)/$(TARBALL) + +distclean: clean + rm -rf *-stamp debian/$(NAME)-dkms debian/*.log debian/files + +install: $(SRC)/$(TARBALL) + install -d "$(DESTDIR)/$(SRC)" + (cd $(SRC); install -m 644 $(NAME)-$(VERSION).dkms.tar.gz "$(DESTDIR)/$(SRC)") + +bump: + $(PATCH) debian/postinst + $(PATCH) debian/postrm + $(PATCH) debian/prerm + $(PATCH) debian/rules + $(PATCH) debian/postinst + $(PATCH) usr/src/dkms_source_tree/dkms.conf + chmod 0755 debian/rules diff --git a/README b/README deleted file mode 100644 index 898826a..0000000 --- a/README +++ /dev/null @@ -1,14 +0,0 @@ -Apple USB BCM5974 Multitouch trackpad support ---------------------------------------------- - -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. - -Authors -------- - -Written by Henrik Rydberg (rydberg@euromail.se); see bcm5974.c for the -complete list of credits. - diff --git a/bcm5974-dkms-mkdeb/Makefile b/bcm5974-dkms-mkdeb/Makefile deleted file mode 100644 index b8d246c..0000000 --- a/bcm5974-dkms-mkdeb/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -SRC = $(DESTDIR)/usr/src - -all: - -clean: - -install: - install -d "$(SRC)" - install -m 644 $(NAME)-$(VERSION).dkms.tar.gz "$(SRC)" - diff --git a/bcm5974-dkms-mkdeb/debian/README.Debian b/bcm5974-dkms-mkdeb/debian/README.Debian deleted file mode 100644 index 1f170f1..0000000 --- a/bcm5974-dkms-mkdeb/debian/README.Debian +++ /dev/null @@ -1,23 +0,0 @@ -MODULE_NAME DKMS module for Debian - -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. - -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 deleted file mode 100644 index 2f74f29..0000000 --- a/bcm5974-dkms-mkdeb/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -MODULE_NAME-dkms (MODULE_VERSION) unstable; urgency=low - - * Add support for MacBook 5,1 (unibody) - - -- Henrik Rydberg DATE_STAMP diff --git a/bcm5974-dkms-mkdeb/debian/compat b/bcm5974-dkms-mkdeb/debian/compat deleted file mode 100644 index 7ed6ff8..0000000 --- a/bcm5974-dkms-mkdeb/debian/compat +++ /dev/null @@ -1 +0,0 @@ -5 diff --git a/bcm5974-dkms-mkdeb/debian/control b/bcm5974-dkms-mkdeb/debian/control deleted file mode 100644 index c5497bf..0000000 --- a/bcm5974-dkms-mkdeb/debian/control +++ /dev/null @@ -1,16 +0,0 @@ -Source: MODULE_NAME-dkms -Section: linux-input -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 deleted file mode 100644 index e00b447..0000000 --- a/bcm5974-dkms-mkdeb/debian/copyright +++ /dev/null @@ -1,41 +0,0 @@ -The bcm5974-dkms package was created using DKMS - -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 deleted file mode 100644 index b601f22..0000000 --- a/bcm5974-dkms-mkdeb/debian/dirs +++ /dev/null @@ -1 +0,0 @@ -usr/src diff --git a/bcm5974-dkms-mkdeb/debian/postinst b/bcm5974-dkms-mkdeb/debian/postinst deleted file mode 100644 index 65b16ae..0000000 --- a/bcm5974-dkms-mkdeb/debian/postinst +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh - -set -e - -NAME=MODULE_NAME -VERSION=MODULE_VERSION - -case "$1" in - configure) - # Determine current arch / kernel - c_arch=`uname -m` - c_kern=`uname -r` - - if [ -e "/var/lib/dkms/$NAME/$VERSION" ]; then - echo "Removing old $NAME-$VERSION DKMS files..." - dkms remove -m $NAME -v $VERSION --all - fi - - echo "Loading new $NAME-$VERSION DKMS files..." - #dkms add -m $NAME -v $VERSION - dkms ldtarball --archive "/usr/src/$NAME-$VERSION.dkms.tar.gz" - rm -f "/usr/src/$NAME-$VERSION.dkms.tar.gz" - - echo "Installing prebuilt kernel module binaries (if any)" - set +e - IFS=' -' - for kern in `dkms status -m $NAME -v $VERSION -a $c_arch | grep ": built" | awk {'print $3'} | sed 's/,$//'`; do - echo "Trying kernel: $kern" - dkms install --force -m $NAME -v $VERSION -k $kern -a $c_arch - done - unset IFS - set -e - - # If none installed, install. - ##if [ `dkms status -m $NAME -v $VERSION -k $c_kern -a $c_arch | grep -c ": installed"` -eq 0 ]; then - dkms_status=`dkms status -m $NAME -v $VERSION -k $c_kern -a $c_arch` - if [ `echo $dkms_status | grep -c ": installed"` -eq 0 ]; then - if [ `echo $c_kern | grep -c "BOOT"` -eq 0 ] && [ -e "/lib/modules/$c_kern/build/include" ]; then - # Only build if we need to. - if [ `echo $dkms_status | grep -c ": built"` -eq 0 ]; then - echo "Building module..." - dkms build -m $NAME -v $VERSION - fi - echo "Installing module..." - dkms install -m $NAME -v $VERSION - elif [ `echo $c_kern | grep -c "BOOT"` -gt 0 ]; then - echo -e "" - echo -e "Module build for the currently running kernel was skipped since you" - echo -e "are running a BOOT variant of the kernel." - else - echo -e "" - echo -e "Module build for the currently running kernel was skipped since the" - echo -e "kernel source for this kernel does not seem to be installed." - fi - fi - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -#DEBHELPER# - -exit 0 - diff --git a/bcm5974-dkms-mkdeb/debian/postrm b/bcm5974-dkms-mkdeb/debian/postrm deleted file mode 100644 index 78221c8..0000000 --- a/bcm5974-dkms-mkdeb/debian/postrm +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -NAME=MODULE_NAME -VERSION=MODULE_VERSION - -set -e - -case "$1" in - purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - moddir="/lib/modules/`uname -r`/kernel/" - depmod - if [ -d "/usr/src/$NAME-$VERSION" ]; then - echo "Removing old module source..." - rm -rf "/usr/src/$NAME-$VERSION" - fi - ;; - - *) - echo "postrm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -#DEBHELPER# - -exit 0 - diff --git a/bcm5974-dkms-mkdeb/debian/prerm b/bcm5974-dkms-mkdeb/debian/prerm deleted file mode 100644 index f42d293..0000000 --- a/bcm5974-dkms-mkdeb/debian/prerm +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -NAME=MODULE_NAME -VERSION=MODULE_VERSION - -set -e - -case "$1" in - remove|upgrade|deconfigure) - if [ "`dkms status -m $NAME`" ]; then - dkms remove -m $NAME -v $VERSION --all - fi - ;; - - failed-upgrade) - ;; - - *) - echo "prerm called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -#DEBHELPER# - -exit 0 - - diff --git a/bcm5974-dkms-mkdeb/debian/rules b/bcm5974-dkms-mkdeb/debian/rules deleted file mode 100644 index 385aa1c..0000000 --- a/bcm5974-dkms-mkdeb/debian/rules +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -NAME=MODULE_NAME -VERSION=MODULE_VERSION - -configure: configure-stamp -configure-stamp: - dh_testdir - touch configure-stamp - - -build: build-stamp - -build-stamp: configure-stamp - dh_testdir - $(MAKE) - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - -$(MAKE) clean - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - $(MAKE) DESTDIR=$(CURDIR)/debian/$(NAME)-dkms NAME=$(NAME) VERSION=$(VERSION) install - -binary-arch: build install - -binary-indep: build install - dh_testdir - dh_testroot - dh_link - dh_strip - dh_compress - dh_fixperms - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/bcm5974.c b/bcm5974.c deleted file mode 100644 index e858f0b..0000000 --- a/bcm5974.c +++ /dev/null @@ -1,778 +0,0 @@ -/* - * Apple USB BCM5974 (Macbook Air and Penryn Macbook Pro) multitouch driver - * - * 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) - * - * 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. - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define USB_VENDOR_ID_APPLE 0x05ac -#define BTN_TOOL_PRESS 0x148 -#define BTN_TOOL_QUADTAP 0x14f - -/* MacbookAir, aka wellspring */ -#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 USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 -#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 -#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 -/* Macbook5,1 (unibody), aka wellspring3 */ -#define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 -#define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 -#define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 - -#define BCM5974_DEVICE(prod) { \ - .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ - USB_DEVICE_ID_MATCH_INT_CLASS | \ - USB_DEVICE_ID_MATCH_INT_PROTOCOL), \ - .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 bcm5974_table[] = { - /* MacbookAir1.1 */ - 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 */ - BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI), - BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ISO), - BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), - /* Macbook5,1 */ - BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), - BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), - BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), - /* Terminating entry */ - {} -}; -MODULE_DEVICE_TABLE(usb, bcm5974_table); - -MODULE_AUTHOR("Henrik Rydberg"); -MODULE_DESCRIPTION("Apple USB BCM5974 multitouch driver"); -MODULE_LICENSE("GPL"); - -#define dprintk(level, format, a...)\ - { if (debug >= level) printk(KERN_DEBUG format, ##a); } - -static int debug = 1; -module_param(debug, int, 0644); -MODULE_PARM_DESC(debug, "Activate debugging output"); - -/* button data structure */ -struct bt_data { - u8 unknown1; /* constant */ - u8 button; /* left button */ - u8 rel_x; /* relative x coordinate */ - u8 rel_y; /* relative y coordinate */ -}; - -/* trackpad header types */ -enum tp_type { - TYPE1, /* plain trackpad */ - TYPE2 /* button integrated in trackpad */ -}; - -/* trackpad finger data offsets */ -#define FINGER_TYPE1 26 -#define FINGER_TYPE2 30 - -/* trackpad button data offsets */ -#define BUTTON_TYPE2 15 - -/* integrated button capability by configuration */ -#define HAS_INTEGRATED_BUTTON(c) (c->tp_type == TYPE2) - -/* trackpad finger structure */ -struct tp_finger { - __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 */ - __le16 rel_y; /* relative y coodinate */ - __le16 size_major; /* finger size, major axis? */ - __le16 size_minor; /* finger size, minor axis? */ - __le16 orientation; /* 16384 when point, else 15 bit angle */ - __le16 force_major; /* trackpad force, major axis? */ - __le16 force_minor; /* trackpad force, minor axis? */ - __le16 unused[3]; /* zeros */ - __le16 multi; /* one finger: varies, more fingers: constant */ -}; - -/* trackpad finger data size, empirically at least ten fingers */ -#define SIZEOF_FINGER sizeof(struct tp_finger) -#define SIZEOF_ALL_FINGERS (16 * SIZEOF_FINGER) - -/* device-specific parameters */ -struct bcm5974_param { - int dim; /* logical dimension */ - int fuzz; /* logical noise value */ - int devmin; /* device minimum reading */ - int devmax; /* device maximum reading */ -}; - -/* device-specific configuration */ -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 */ - enum tp_type tp_type; /* type of trackpad interface */ - int tp_offset; /* offset to trackpad finger data */ - int tp_datalen; /* data length of the trackpad interface */ - 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 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 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 */ - u8 *tp_data; /* trackpad transferred data */ - int fingers; /* number of fingers on trackpad */ -}; - -/* logical dimensions */ -#define DIM_PRESSURE 256 /* maximum finger pressure */ -#define DIM_WIDTH 16 /* maximum finger width */ -#define DIM_X 1280 /* maximum trackpad x value */ -#define DIM_Y 800 /* maximum trackpad y value */ - -/* logical signal quality */ -#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 */ - -/* 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[] = { - { - USB_DEVICE_ID_APPLE_WELLSPRING_ANSI, - USB_DEVICE_ID_APPLE_WELLSPRING_ISO, - USB_DEVICE_ID_APPLE_WELLSPRING_JIS, - 0x84, sizeof(struct bt_data), - 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS, - { 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 } - }, - { - USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI, - USB_DEVICE_ID_APPLE_WELLSPRING2_ISO, - USB_DEVICE_ID_APPLE_WELLSPRING2_JIS, - 0x84, sizeof(struct bt_data), - 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS, - { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, - { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, - { DIM_X, DIM_X / SN_COORD, -4824, 4824 }, - { DIM_Y, DIM_Y / SN_COORD, -172, 4290 } - }, - { - USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI, - USB_DEVICE_ID_APPLE_WELLSPRING3_ISO, - USB_DEVICE_ID_APPLE_WELLSPRING3_JIS, - 0x84, sizeof(struct bt_data), - 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS, - { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 }, - { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, - { DIM_X, DIM_X / SN_COORD, -4460, 5166 }, - { DIM_Y, DIM_Y / SN_COORD, -75, 6700 } - }, - {} -}; - -/* return the device-specific configuration by device */ -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; -} - -/* convert 16-bit little endian to signed integer */ -static inline int raw2int(__le16 x) -{ - return (signed short)le16_to_cpu(x); -} - -/* scale device data to logical dimensions (asserts devmin < devmax) */ -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 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) -{ - __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_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_TOOL_QUADTAP, input_dev->keybit); - if (HAS_INTEGRATED_BUTTON(cfg)) - __set_bit(BTN_TOOL_PRESS, input_dev->keybit); - __set_bit(BTN_LEFT, input_dev->keybit); -} - -/* 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; - - dprintk(7, - "bcm5974: button data: %x %x %x %x\n", - dev->bt_data->unknown1, dev->bt_data->button, - dev->bt_data->rel_x, dev->bt_data->rel_y); - - 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 bcm5974 *dev, int size) -{ - const struct bcm5974_config *c = &dev->cfg; - const struct tp_finger *f; - struct input_dev *input = dev->input; - int raw_p, raw_w, raw_x, raw_y, raw_n; - int ptest = 0, origin = 0, ibt = 0, nmin = 0, nmax = 0; - int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0; - - if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0) - return -EIO; - - f = (const struct tp_finger *)(dev->tp_data + c->tp_offset); - raw_n = (size - c->tp_offset) / SIZEOF_FINGER; - - /* always track the first finger; when detached, start over */ - if (raw_n) { - 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: raw: p: %+05d w: %+05d x: %+05d y: %+05d " - "n: %d\n", raw_p, raw_w, raw_x, raw_y, raw_n); - - ptest = int2bound(&c->p, raw_p); - origin = raw2int(f->origin); - - /* set the integrated button if applicable */ - if (c->tp_type == TYPE2) - ibt = raw2int(dev->tp_data[BUTTON_TYPE2]); - } - - /* 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); - while (raw_n--) { - ptest = int2bound(&c->p, raw2int(f->force_major)); - if (ptest > PRESSURE_LOW) - nmax++; - if (ptest > PRESSURE_HIGH) - nmin++; - f++; - } - } - - 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 == 3); - input_report_key(input, BTN_TOOL_QUADTAP, dev->fingers > 3); - - 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 ibt: %d\n", abs_p, abs_w, - abs_x, abs_y, nmin, nmax, dev->fingers, ibt); - - } - - if (HAS_INTEGRATED_BUTTON(c)) { - input_report_key(input, BTN_TOOL_PRESS, ibt); - input_report_key(input, BTN_LEFT, ibt); - } - - input_sync(input); - - return 0; -} - -/* Wellspring initialization constants */ -#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 -#define BCM5974_WELLSPRING_MODE_NORMAL_VALUE 0x08 - -static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on) -{ - char *data = kmalloc(8, GFP_KERNEL); - int retval = 0, size; - - if (!data) { - err("bcm5974: out of memory"); - 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); - - if (size != 8) { - err("bcm5974: could not read from device"); - retval = -EIO; - goto out; - } - - /* apply the mode switch */ - 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), - 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"); - retval = -EIO; - goto out; - } - - dprintk(2, "bcm5974: switched to %s mode.\n", - on ? "wellspring" : "normal"); - - out: - kfree(data); - return retval; -} - -static void bcm5974_irq_button(struct urb *urb) -{ - struct bcm5974 *dev = urb->context; - int error; - - switch (urb->status) { - case 0: - break; - case -EOVERFLOW: - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - dbg("bcm5974: button urb shutting down: %d", urb->status); - return; - default: - dbg("bcm5974: button urb status: %d", urb->status); - goto exit; - } - - if (report_bt_state(dev, dev->bt_urb->actual_length)) - dprintk(1, "bcm5974: bad button package, length: %d\n", - dev->bt_urb->actual_length); - -exit: - error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC); - if (error) - err("bcm5974: button urb failed: %d", error); -} - -static void bcm5974_irq_trackpad(struct urb *urb) -{ - struct bcm5974 *dev = urb->context; - int error; - - switch (urb->status) { - case 0: - break; - case -EOVERFLOW: - case -ECONNRESET: - case -ENOENT: - case -ESHUTDOWN: - dbg("bcm5974: trackpad urb shutting down: %d", urb->status); - return; - default: - dbg("bcm5974: trackpad urb status: %d", urb->status); - goto exit; - } - - /* 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", - dev->tp_urb->actual_length); - -exit: - error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC); - if (error) - 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 start_traffic, it seems easier to always do the switch when - * starting traffic on the device. - */ -static int bcm5974_start_traffic(struct bcm5974 *dev) -{ - if (bcm5974_wellspring_mode(dev, true)) { - 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 bcm5974_pause_traffic(struct bcm5974 *dev) -{ - usb_kill_urb(dev->tp_urb); - usb_kill_urb(dev->bt_urb); - bcm5974_wellspring_mode(dev, false); -} - -/* - * 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; - - error = usb_autopm_get_interface(dev->intf); - if (error) - return error; - - mutex_lock(&dev->pm_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; -} - -static void bcm5974_close(struct input_dev *input) -{ - struct bcm5974 *dev = input_get_drvdata(input); - - mutex_lock(&dev->pm_mutex); - - bcm5974_pause_traffic(dev); - dev->opened = 0; - - 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); - - mutex_lock(&dev->pm_mutex); - - if (dev->opened) - bcm5974_pause_traffic(dev); - - mutex_unlock(&dev->pm_mutex); - - return 0; -} - -static int bcm5974_resume(struct usb_interface *iface) -{ - struct bcm5974 *dev = usb_get_intfdata(iface); - int error = 0; - - 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) -{ - struct usb_device *udev = interface_to_usbdev(iface); - const struct bcm5974_config *cfg; - struct bcm5974 *dev; - struct input_dev *input_dev; - int error = -ENOMEM; - - /* find the product index */ - cfg = bcm5974_get_config(udev); - - /* allocate memory for our device state and initialize it */ - dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL); - input_dev = input_allocate_device(); - if (!dev || !input_dev) { - err("bcm5974: out of memory"); - goto err_free_devs; - } - - dev->udev = udev; - dev->intf = iface; - dev->input = input_dev; - dev->cfg = *cfg; - mutex_init(&dev->pm_mutex); - - /* setup urbs */ - dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!dev->bt_urb) - goto err_free_devs; - - dev->tp_urb = usb_alloc_urb(0, GFP_KERNEL); - 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) - 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) - 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, - 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, - bcm5974_irq_trackpad, dev, 1); - - /* create bcm5974 device */ - usb_make_path(udev, dev->phys, sizeof(dev->phys)); - strlcat(dev->phys, "/input0", sizeof(dev->phys)); - - input_dev->name = "bcm5974"; - input_dev->phys = dev->phys; - usb_to_input_id(dev->udev, &input_dev->id); - input_dev->dev.parent = &iface->dev; - - input_set_drvdata(input_dev, dev); - - input_dev->open = bcm5974_open; - input_dev->close = bcm5974_close; - - setup_events_to_report(input_dev, cfg); - - error = input_register_device(dev->input); - if (error) - goto err_free_buffer; - - /* save our data pointer in this interface device */ - usb_set_intfdata(iface, dev); - - return 0; - -err_free_buffer: - usb_buffer_free(dev->udev, dev->cfg.tp_datalen, - dev->tp_data, dev->tp_urb->transfer_dma); -err_free_bt_buffer: - usb_buffer_free(dev->udev, dev->cfg.bt_datalen, - dev->bt_data, dev->bt_urb->transfer_dma); -err_free_urb: - usb_free_urb(dev->tp_urb); -err_free_bt_urb: - usb_free_urb(dev->bt_urb); -err_free_devs: - usb_set_intfdata(iface, NULL); - input_free_device(input_dev); - kfree(dev); - return error; -} - -static void bcm5974_disconnect(struct usb_interface *iface) -{ - struct bcm5974 *dev = usb_get_intfdata(iface); - - usb_set_intfdata(iface, NULL); - - 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); -} - -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, - .supports_autosuspend = 1, -}; - -static int __init bcm5974_init(void) -{ - return usb_register(&bcm5974_driver); -} - -static void __exit bcm5974_exit(void) -{ - usb_deregister(&bcm5974_driver); -} - -module_init(bcm5974_init); -module_exit(bcm5974_exit); - diff --git a/debian/README.Debian b/debian/README.Debian new file mode 100644 index 0000000..1fd7380 --- /dev/null +++ b/debian/README.Debian @@ -0,0 +1,23 @@ +bcm5974 DKMS module for Debian + +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. + +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/debian/changelog b/debian/changelog new file mode 100644 index 0000000..fed1652 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,187 @@ +bcm5974-dkms (1.0) unstable; urgency=low + + * Add support for MacBookPro 5,1 (unibody) + * Distribute package at launchpad as version 1.0 + + -- Henrik Rydberg Fri, 24 Oct 2008 23:36:22 +0200 + +bcm5974-dkms (0.66) unstable; urgency=low + + * Add support for MacBook 5,1 (unibody) + + -- Henrik Rydberg Sun, 19 Oct 2008 17:23:26 +0200 + +bcm5974-dkms (0.65) unstable; urgency=low + + * Switch back to normal mode when closing + + -- Henrik Rydberg Sun, 14 Sep 2008 16:06:42 +0200 + +bcm5974-dkms (0.64) unstable; urgency=low + + * Finger counting improved further + + -- Henrik Rydberg Wed, 03 Sep 2008 21:58:38 +0200 + +bcm5974-dkms (0.63) unstable; urgency=low + + * Finger pressure hysteresis added + + -- Henrik Rydberg Wed, 03 Sep 2008 13:26:29 +0200 + +bcm5974-dkms (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-dkms (0.61) unstable; urgency=low + + * Smoother motion in mouse interface + + -- Henrik Rydberg Mon, 01 Sep 2008 21:01:24 +0200 + +bcm5974-dkms (0.60) unstable; urgency=low + + * New default mouse driver mode + * Mouse configuration parameters + + -- Henrik Rydberg Mon, 01 Sep 2008 18:38:21 +0200 + +bcm5974-dkms (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-dkms (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-dkms (0.57) unstable; urgency=low + + * Keep reset_resume around + * Submitted to kernel.org + + -- Henrik Rydberg Sat, 19 Jul 2008 01:42:52 +0200 + +bcm5974-dkms (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-dkms (0.55) unstable; urgency=low + + * Package updates. + * Reverting GFP_ATOMIC for irq handlers. + + -- Henrik Rydberg Wed, 09 Jul 2008 20:59:39 +0200 + +bcm5974-dkms (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 + +bcm5974-dkms (0.53) unstable; urgency=low + + * Another typo in the post-install script. + + -- Henrik Rydberg Mon, 07 Jul 2008 20:59:39 +0200 + +bcm5974-dkms (0.52) unstable; urgency=low + + * Typo in the post-install script. + + -- Henrik Rydberg Mon, 07 Jul 2008 20:09:39 +0200 + +bcm5974-dkms (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 + +bcm5974-dkms (0.5) unstable; urgency=low + + * Working palm detection + * Changes for kernel.org + * DKMS introduced. + + -- Henrik Rydberg Sun, 06 Jul 2008 20:59:39 +0200 + +bcm5974-dkms (0.42) unstable; urgency=low + + * First button click registered. + * Hooks pre/post-reset added. + + -- Henrik Rydberg Tue, 01 Jul 2008 20:59:39 +0200 + +bcm5974-dkms (0.41) unstable; urgency=low + + * The reset_resume kernel function added. + + -- Henrik Rydberg Sun, 29 Jun 2008 20:59:39 +0200 + +bcm5974-dkms (0.4) unstable; urgency=low + + * Both finger pressure and width reported. + + -- Henrik Rydberg Sun, 29 Jun 2008 18:59:39 +0200 + +bcm5974-dkms (0.31) unstable; urgency=low + + * Administrative changes for kernel.org. + + -- Henrik Rydberg Fri, 27 Jun 2008 20:59:39 +0200 + +bcm5974-dkms (0.3) unstable; urgency=low + + * Explicit device structure, use all packages. + + -- Henrik Rydberg Fri, 27 Jun 2008 18:59:39 +0200 + +bcm5974-dkms (0.23) unstable; urgency=low + + * Finger release not reported properly. + + -- Henrik Rydberg Fri, 27 Jun 2008 17:59:39 +0200 + +bcm5974-dkms (0.22) unstable; urgency=low + + * ABS coordinates more stable with synaptics. + + -- Henrik Rydberg Thu, 26 Jun 2008 20:59:39 +0200 + +bcm5974-dkms (0.21) unstable; urgency=low + + * Fixed the relative coordinate scaling. + + -- Henrik Rydberg Wed, 25 Jun 2008 20:59:39 +0200 + +bcm5974-dkms (0.2) unstable; urgency=low + + * Misinterpreted pressure input, noise reduction. + + -- Henrik Rydberg Wed, 25 Jun 2008 20:59:39 +0200 + +bcm5974-dkms (0.1) unstable; urgency=low + + * First version. + + -- Henrik Rydberg Tue, 24 Jun 2008 20:59:39 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..07c8bcb --- /dev/null +++ b/debian/control @@ -0,0 +1,16 @@ +Source: bcm5974-dkms +Section: misc +Priority: optional +Maintainer: Henrik Rydberg +Build-Depends: debhelper (>= 5) +Standards-Version: 3.7.2 +Homepage: http://web.comhem.se/rydberg/Bits/ + +Package: bcm5974-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/debian/copyright b/debian/copyright new file mode 100644 index 0000000..e00b447 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,41 @@ +The bcm5974-dkms package was created using DKMS + +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/debian/dirs b/debian/dirs new file mode 100644 index 0000000..fee20a1 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +etc/modprobe.d +usr/src diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..3bc6c41 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,71 @@ +#!/bin/sh + +set -e + +NAME=bcm5974 +VERSION=0.99 + +case "$1" in + configure) + # Determine current arch / kernel + c_arch=`uname -m` + c_kern=`uname -r` + + if [ -e "/var/lib/dkms/$NAME/$VERSION" ]; then + echo "Removing old $NAME-$VERSION DKMS files..." + dkms remove -m $NAME -v $VERSION --all + fi + + echo "Loading new $NAME-$VERSION DKMS files..." + #dkms add -m $NAME -v $VERSION + dkms ldtarball --archive "/usr/src/$NAME-$VERSION.dkms.tar.gz" + rm -f "/usr/src/$NAME-$VERSION.dkms.tar.gz" + + echo "Installing prebuilt kernel module binaries (if any)" + set +e + IFS=' +' + for kern in `dkms status -m $NAME -v $VERSION -a $c_arch | grep ": built" | awk {'print $3'} | sed 's/,$//'`; do + echo "Trying kernel: $kern" + dkms install --force -m $NAME -v $VERSION -k $kern -a $c_arch + done + unset IFS + set -e + + # If none installed, install. + ##if [ `dkms status -m $NAME -v $VERSION -k $c_kern -a $c_arch | grep -c ": installed"` -eq 0 ]; then + dkms_status=`dkms status -m $NAME -v $VERSION -k $c_kern -a $c_arch` + if [ `echo $dkms_status | grep -c ": installed"` -eq 0 ]; then + if [ `echo $c_kern | grep -c "BOOT"` -eq 0 ] && [ -e "/lib/modules/$c_kern/build/include" ]; then + # Only build if we need to. + if [ `echo $dkms_status | grep -c ": built"` -eq 0 ]; then + echo "Building module..." + dkms build -m $NAME -v $VERSION + fi + echo "Installing module..." + dkms install -m $NAME -v $VERSION + elif [ `echo $c_kern | grep -c "BOOT"` -gt 0 ]; then + echo -e "" + echo -e "Module build for the currently running kernel was skipped since you" + echo -e "are running a BOOT variant of the kernel." + else + echo -e "" + echo -e "Module build for the currently running kernel was skipped since the" + echo -e "kernel source for this kernel does not seem to be installed." + fi + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 + diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..9a4ef29 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,27 @@ +#!/bin/sh + +NAME=bcm5974 +VERSION=0.99 + +set -e + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + moddir="/lib/modules/`uname -r`/kernel/" + depmod + if [ -d "/usr/src/$NAME-$VERSION" ]; then + echo "Removing old module source..." + rm -rf "/usr/src/$NAME-$VERSION" + fi + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 + diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..7c34eaa --- /dev/null +++ b/debian/prerm @@ -0,0 +1,28 @@ +#!/bin/sh + +NAME=bcm5974 +VERSION=0.99 + +set -e + +case "$1" in + remove|upgrade|deconfigure) + if [ "`dkms status -m $NAME`" ]; then + dkms remove -m $NAME -v $VERSION --all + fi + ;; + + failed-upgrade) + ;; + + *) + echo "prerm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 + + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..649ebba --- /dev/null +++ b/debian/rules @@ -0,0 +1,53 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +NAME=bcm5974 +VERSION=0.99 + +configure: configure-stamp +configure-stamp: + dh_testdir + touch configure-stamp + + +build: build-stamp + +build-stamp: configure-stamp + dh_testdir + $(MAKE) + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + -$(MAKE) clean + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + $(MAKE) DESTDIR=$(CURDIR)/debian/$(NAME)-dkms NAME=$(NAME) VERSION=$(VERSION) install + +binary-arch: build install + +binary-indep: build install + dh_testdir + dh_testroot + dh_link + dh_strip + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/dkms.conf b/dkms.conf deleted file mode 100644 index 4be76c4..0000000 --- a/dkms.conf +++ /dev/null @@ -1,9 +0,0 @@ -PACKAGE_NAME="bcm5974" -PACKAGE_VERSION="0.66" -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-diagnostics b/scripts/bcm5974-diagnostics deleted file mode 100755 index acd0bf4..0000000 --- a/scripts/bcm5974-diagnostics +++ /dev/null @@ -1,232 +0,0 @@ -#!/bin/bash -# -# bcm5943-diagnostics - troubleshooting the BCM5974 setup -# -# 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 - -echo ----------------------------------------------------------------------- - -# What kernel version am I running? -KERNEL=`uname -r` -echo \* Kernel version: $KERNEL - -# What synaptics version is installed (debian)? -if [ -x /usr/bin/dpkg-query ]; then - SYNAPTICS=`/usr/bin/dpkg-query -W -f='${Version}\n' xserver-xorg-input-synaptics` - echo \* Synaptics version: $SYNAPTICS -else - echo \* Synaptics version: UNKNOWN - dpkg not found -fi - -# What USB devices of interest can we find? -if [ -x /usr/sbin/lsusb ]; then - LSUSB=`lsusb|grep 05ac:02` - echo \* USB device: $LSUSB -else - echo \* USB device: UNKNOWN - lsusb not found -fi - -# Do we have the module intalled? -MODLIB=/lib/modules/$KERNEL/kernel/drivers/input/mouse/$DRIVER.ko -MODLIB2=/lib/modules/$KERNEL/updates/dkms/$DRIVER.ko -if [ -f $MODLIB ]; then - echo \* $MODLIB: exists -elif [ -f $MODLIB2 ]; then - echo \* $MODLIB2: exists -else - echo \* $DRIVER does NOT exist - echo dkms: install package - echo manual: copy the file $DRIVER.ko to $MODLIB - exit 1 -fi - -# Do we have the module configured? -MODULES=/etc/modules -if [ -f $MODULES ]; then - if (grep -q $DRIVER $MODULES); then - echo \* $MODULES: has $DRIVER config, please remove - exit 1 - else - echo \* $MODULES: $DRIVER no longer explicitly listed, good - fi -fi - -# Do we have old quirks? -MODPROBE=/etc/modprobe.d/options -if [ -f $MODPROBE ]; then - MODPROBEOPTS=`grep quirks= $MODPROBE|grep -v ^#|grep 0x05ac:0x02` - if [ "$MODPROBEOPTS" != "" ]; then - echo \* $MODPROBE: has obsolete quirks - please remove - exit 1 - else - echo \* $MODPROBE: no obsolete quirks, good - fi -else - echo \* $MODPROBE: file not found -fi - -# Do we have the right quirks? -DRIVMOD=/etc/modprobe.d/$DRIVER -if [ -f $DRIVMOD ]; then - DRIVMODOPTS=`grep quirks= $DRIVMOD|grep -v ^#|grep 0x05ac:0x02` - if [ "$DRIVMODOPTS" != "" ]; then - echo \* $DRIVMOD: has quirks, good - else - echo \* $DRIVMOD: does NOT have quirks - echo Uncomment the right quirk line in $DRIVMOD - exit 1 - fi -else - echo \* $DRIVMOD: file not found - echo Copy the etc/modprobe.d/bcm5974 file to /etc/modprobe.d/ - exit 1 -fi - -# Did the depmod bite? -USBMAP=/lib/modules/$KERNEL/modules.usbmap -if [ -f $USBMAP ]; then - typeset -i nusb=`grep $DRIVER $USBMAP|grep 0x05ac|grep 0x02|wc -l` - if [ $nusb -gt 0 ]; then - echo \* $USBMAP: maps to $DRIVER, good - else - echo \* $USBMAP: does NOT map to $DRIVER - echo Run depmod -a as root - exit 1 - fi -fi - -# Was the $DRIVER module loaded? -DMESG=`lsmod|grep $DRIVER` -if [ "$DMESG" != "" ]; then - echo \* $DRIVER: module is loaded -else - echo \* $DRIVER: module is NOT loaded - echo Add this line to /etc/modules: - echo "$DRIVER" - exit 1 -fi - -# Was the $DRIVER module registered? -DEVPATH=/proc/bus/input/devices -if [ -f $DEVPATH ]; then - DEVICES=`grep $DRIVER /proc/bus/input/devices` - if [ "$DEVICES" != "" ]; then - echo \* $DEVPATH: module is registered - else - echo \* $DEVPATH: module is NOT registered - echo "Please double-check the quirks settings in $DRIVMOD" - exit 1 - fi -else - echo \* $DEVPATH: does not exist, ignore -fi - -# Do we have synaptics working properly? -typeset -i SYNLINES=`synclient -l|wc -l` -if [ $SYNLINES -gt 10 ]; then - echo \* synaptics: configuration readable -else - echo \* synaptics: configuration NOT readable - exit 1 -fi - -# Do we have a working synaptics configuration? -DIFF=/tmp/synclient-output.diff.$$ -TMP=/tmp/synclient-output.txt.$$ -synclient -l | grep -v Parameter | sort > $TMP -diff -u - $TMP > $DIFF < $ETCPATH - exit 0 -else - echo No suitable device found - exit 1 -fi diff --git a/scripts/bcm5974-post-remove b/scripts/bcm5974-post-remove deleted file mode 100755 index 21977de..0000000 --- a/scripts/bcm5974-post-remove +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# -# bcm5943-post-remove - post-removing 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 -ETCPATH=/etc/modprobe.d/$DRIVER - -echo ----------------------------------------------------------------------- - -rm -f $ETCPATH - -exit 0 diff --git a/scripts/bcm5974-pre-install b/scripts/bcm5974-pre-install deleted file mode 100755 index 1e2b864..0000000 --- a/scripts/bcm5974-pre-install +++ /dev/null @@ -1,42 +0,0 @@ -#!/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 [ "`$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 diff --git a/scripts/patch-name-version.sh b/scripts/patch-name-version.sh new file mode 100755 index 0000000..d1a7796 --- /dev/null +++ b/scripts/patch-name-version.sh @@ -0,0 +1,9 @@ +#!/bin/sh +#1: name +#2: version +#3: file +cat $3 \ +| sed "s/^NAME=.*/NAME=$1/" \ +| sed "s/^VERSION=.*/VERSION=$2/" \ +> /tmp/$1.$$ +mv /tmp/$1.$$ $3 diff --git a/usr/src/dkms_main_tree/dkms_dbversion b/usr/src/dkms_main_tree/dkms_dbversion new file mode 100644 index 0000000..227cea2 --- /dev/null +++ b/usr/src/dkms_main_tree/dkms_dbversion @@ -0,0 +1 @@ +2.0.0 diff --git a/usr/src/dkms_source_tree/Makefile b/usr/src/dkms_source_tree/Makefile new file mode 100644 index 0000000..6a04556 --- /dev/null +++ b/usr/src/dkms_source_tree/Makefile @@ -0,0 +1,5 @@ +# +# Makefile for input/mouse drivers +# + +obj-m := bcm5974.o diff --git a/usr/src/dkms_source_tree/bcm5974.c b/usr/src/dkms_source_tree/bcm5974.c new file mode 100644 index 0000000..e858f0b --- /dev/null +++ b/usr/src/dkms_source_tree/bcm5974.c @@ -0,0 +1,778 @@ +/* + * Apple USB BCM5974 (Macbook Air and Penryn Macbook Pro) multitouch driver + * + * 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) + * + * 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. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#define USB_VENDOR_ID_APPLE 0x05ac +#define BTN_TOOL_PRESS 0x148 +#define BTN_TOOL_QUADTAP 0x14f + +/* MacbookAir, aka wellspring */ +#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 USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI 0x0230 +#define USB_DEVICE_ID_APPLE_WELLSPRING2_ISO 0x0231 +#define USB_DEVICE_ID_APPLE_WELLSPRING2_JIS 0x0232 +/* Macbook5,1 (unibody), aka wellspring3 */ +#define USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI 0x0236 +#define USB_DEVICE_ID_APPLE_WELLSPRING3_ISO 0x0237 +#define USB_DEVICE_ID_APPLE_WELLSPRING3_JIS 0x0238 + +#define BCM5974_DEVICE(prod) { \ + .match_flags = (USB_DEVICE_ID_MATCH_DEVICE | \ + USB_DEVICE_ID_MATCH_INT_CLASS | \ + USB_DEVICE_ID_MATCH_INT_PROTOCOL), \ + .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 bcm5974_table[] = { + /* MacbookAir1.1 */ + 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 */ + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_ISO), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING2_JIS), + /* Macbook5,1 */ + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_ISO), + BCM5974_DEVICE(USB_DEVICE_ID_APPLE_WELLSPRING3_JIS), + /* Terminating entry */ + {} +}; +MODULE_DEVICE_TABLE(usb, bcm5974_table); + +MODULE_AUTHOR("Henrik Rydberg"); +MODULE_DESCRIPTION("Apple USB BCM5974 multitouch driver"); +MODULE_LICENSE("GPL"); + +#define dprintk(level, format, a...)\ + { if (debug >= level) printk(KERN_DEBUG format, ##a); } + +static int debug = 1; +module_param(debug, int, 0644); +MODULE_PARM_DESC(debug, "Activate debugging output"); + +/* button data structure */ +struct bt_data { + u8 unknown1; /* constant */ + u8 button; /* left button */ + u8 rel_x; /* relative x coordinate */ + u8 rel_y; /* relative y coordinate */ +}; + +/* trackpad header types */ +enum tp_type { + TYPE1, /* plain trackpad */ + TYPE2 /* button integrated in trackpad */ +}; + +/* trackpad finger data offsets */ +#define FINGER_TYPE1 26 +#define FINGER_TYPE2 30 + +/* trackpad button data offsets */ +#define BUTTON_TYPE2 15 + +/* integrated button capability by configuration */ +#define HAS_INTEGRATED_BUTTON(c) (c->tp_type == TYPE2) + +/* trackpad finger structure */ +struct tp_finger { + __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 */ + __le16 rel_y; /* relative y coodinate */ + __le16 size_major; /* finger size, major axis? */ + __le16 size_minor; /* finger size, minor axis? */ + __le16 orientation; /* 16384 when point, else 15 bit angle */ + __le16 force_major; /* trackpad force, major axis? */ + __le16 force_minor; /* trackpad force, minor axis? */ + __le16 unused[3]; /* zeros */ + __le16 multi; /* one finger: varies, more fingers: constant */ +}; + +/* trackpad finger data size, empirically at least ten fingers */ +#define SIZEOF_FINGER sizeof(struct tp_finger) +#define SIZEOF_ALL_FINGERS (16 * SIZEOF_FINGER) + +/* device-specific parameters */ +struct bcm5974_param { + int dim; /* logical dimension */ + int fuzz; /* logical noise value */ + int devmin; /* device minimum reading */ + int devmax; /* device maximum reading */ +}; + +/* device-specific configuration */ +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 */ + enum tp_type tp_type; /* type of trackpad interface */ + int tp_offset; /* offset to trackpad finger data */ + int tp_datalen; /* data length of the trackpad interface */ + 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 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 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 */ + u8 *tp_data; /* trackpad transferred data */ + int fingers; /* number of fingers on trackpad */ +}; + +/* logical dimensions */ +#define DIM_PRESSURE 256 /* maximum finger pressure */ +#define DIM_WIDTH 16 /* maximum finger width */ +#define DIM_X 1280 /* maximum trackpad x value */ +#define DIM_Y 800 /* maximum trackpad y value */ + +/* logical signal quality */ +#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 */ + +/* 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[] = { + { + USB_DEVICE_ID_APPLE_WELLSPRING_ANSI, + USB_DEVICE_ID_APPLE_WELLSPRING_ISO, + USB_DEVICE_ID_APPLE_WELLSPRING_JIS, + 0x84, sizeof(struct bt_data), + 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS, + { 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 } + }, + { + USB_DEVICE_ID_APPLE_WELLSPRING2_ANSI, + USB_DEVICE_ID_APPLE_WELLSPRING2_ISO, + USB_DEVICE_ID_APPLE_WELLSPRING2_JIS, + 0x84, sizeof(struct bt_data), + 0x81, TYPE1, FINGER_TYPE1, FINGER_TYPE1 + SIZEOF_ALL_FINGERS, + { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 256 }, + { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, + { DIM_X, DIM_X / SN_COORD, -4824, 4824 }, + { DIM_Y, DIM_Y / SN_COORD, -172, 4290 } + }, + { + USB_DEVICE_ID_APPLE_WELLSPRING3_ANSI, + USB_DEVICE_ID_APPLE_WELLSPRING3_ISO, + USB_DEVICE_ID_APPLE_WELLSPRING3_JIS, + 0x84, sizeof(struct bt_data), + 0x81, TYPE2, FINGER_TYPE2, FINGER_TYPE2 + SIZEOF_ALL_FINGERS, + { DIM_PRESSURE, DIM_PRESSURE / SN_PRESSURE, 0, 300 }, + { DIM_WIDTH, DIM_WIDTH / SN_WIDTH, 0, 2048 }, + { DIM_X, DIM_X / SN_COORD, -4460, 5166 }, + { DIM_Y, DIM_Y / SN_COORD, -75, 6700 } + }, + {} +}; + +/* return the device-specific configuration by device */ +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; +} + +/* convert 16-bit little endian to signed integer */ +static inline int raw2int(__le16 x) +{ + return (signed short)le16_to_cpu(x); +} + +/* scale device data to logical dimensions (asserts devmin < devmax) */ +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 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) +{ + __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_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_TOOL_QUADTAP, input_dev->keybit); + if (HAS_INTEGRATED_BUTTON(cfg)) + __set_bit(BTN_TOOL_PRESS, input_dev->keybit); + __set_bit(BTN_LEFT, input_dev->keybit); +} + +/* 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; + + dprintk(7, + "bcm5974: button data: %x %x %x %x\n", + dev->bt_data->unknown1, dev->bt_data->button, + dev->bt_data->rel_x, dev->bt_data->rel_y); + + 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 bcm5974 *dev, int size) +{ + const struct bcm5974_config *c = &dev->cfg; + const struct tp_finger *f; + struct input_dev *input = dev->input; + int raw_p, raw_w, raw_x, raw_y, raw_n; + int ptest = 0, origin = 0, ibt = 0, nmin = 0, nmax = 0; + int abs_p = 0, abs_w = 0, abs_x = 0, abs_y = 0; + + if (size < c->tp_offset || (size - c->tp_offset) % SIZEOF_FINGER != 0) + return -EIO; + + f = (const struct tp_finger *)(dev->tp_data + c->tp_offset); + raw_n = (size - c->tp_offset) / SIZEOF_FINGER; + + /* always track the first finger; when detached, start over */ + if (raw_n) { + 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: raw: p: %+05d w: %+05d x: %+05d y: %+05d " + "n: %d\n", raw_p, raw_w, raw_x, raw_y, raw_n); + + ptest = int2bound(&c->p, raw_p); + origin = raw2int(f->origin); + + /* set the integrated button if applicable */ + if (c->tp_type == TYPE2) + ibt = raw2int(dev->tp_data[BUTTON_TYPE2]); + } + + /* 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); + while (raw_n--) { + ptest = int2bound(&c->p, raw2int(f->force_major)); + if (ptest > PRESSURE_LOW) + nmax++; + if (ptest > PRESSURE_HIGH) + nmin++; + f++; + } + } + + 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 == 3); + input_report_key(input, BTN_TOOL_QUADTAP, dev->fingers > 3); + + 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 ibt: %d\n", abs_p, abs_w, + abs_x, abs_y, nmin, nmax, dev->fingers, ibt); + + } + + if (HAS_INTEGRATED_BUTTON(c)) { + input_report_key(input, BTN_TOOL_PRESS, ibt); + input_report_key(input, BTN_LEFT, ibt); + } + + input_sync(input); + + return 0; +} + +/* Wellspring initialization constants */ +#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 +#define BCM5974_WELLSPRING_MODE_NORMAL_VALUE 0x08 + +static int bcm5974_wellspring_mode(struct bcm5974 *dev, bool on) +{ + char *data = kmalloc(8, GFP_KERNEL); + int retval = 0, size; + + if (!data) { + err("bcm5974: out of memory"); + 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); + + if (size != 8) { + err("bcm5974: could not read from device"); + retval = -EIO; + goto out; + } + + /* apply the mode switch */ + 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), + 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"); + retval = -EIO; + goto out; + } + + dprintk(2, "bcm5974: switched to %s mode.\n", + on ? "wellspring" : "normal"); + + out: + kfree(data); + return retval; +} + +static void bcm5974_irq_button(struct urb *urb) +{ + struct bcm5974 *dev = urb->context; + int error; + + switch (urb->status) { + case 0: + break; + case -EOVERFLOW: + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + dbg("bcm5974: button urb shutting down: %d", urb->status); + return; + default: + dbg("bcm5974: button urb status: %d", urb->status); + goto exit; + } + + if (report_bt_state(dev, dev->bt_urb->actual_length)) + dprintk(1, "bcm5974: bad button package, length: %d\n", + dev->bt_urb->actual_length); + +exit: + error = usb_submit_urb(dev->bt_urb, GFP_ATOMIC); + if (error) + err("bcm5974: button urb failed: %d", error); +} + +static void bcm5974_irq_trackpad(struct urb *urb) +{ + struct bcm5974 *dev = urb->context; + int error; + + switch (urb->status) { + case 0: + break; + case -EOVERFLOW: + case -ECONNRESET: + case -ENOENT: + case -ESHUTDOWN: + dbg("bcm5974: trackpad urb shutting down: %d", urb->status); + return; + default: + dbg("bcm5974: trackpad urb status: %d", urb->status); + goto exit; + } + + /* 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", + dev->tp_urb->actual_length); + +exit: + error = usb_submit_urb(dev->tp_urb, GFP_ATOMIC); + if (error) + 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 start_traffic, it seems easier to always do the switch when + * starting traffic on the device. + */ +static int bcm5974_start_traffic(struct bcm5974 *dev) +{ + if (bcm5974_wellspring_mode(dev, true)) { + 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 bcm5974_pause_traffic(struct bcm5974 *dev) +{ + usb_kill_urb(dev->tp_urb); + usb_kill_urb(dev->bt_urb); + bcm5974_wellspring_mode(dev, false); +} + +/* + * 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; + + error = usb_autopm_get_interface(dev->intf); + if (error) + return error; + + mutex_lock(&dev->pm_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; +} + +static void bcm5974_close(struct input_dev *input) +{ + struct bcm5974 *dev = input_get_drvdata(input); + + mutex_lock(&dev->pm_mutex); + + bcm5974_pause_traffic(dev); + dev->opened = 0; + + 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); + + mutex_lock(&dev->pm_mutex); + + if (dev->opened) + bcm5974_pause_traffic(dev); + + mutex_unlock(&dev->pm_mutex); + + return 0; +} + +static int bcm5974_resume(struct usb_interface *iface) +{ + struct bcm5974 *dev = usb_get_intfdata(iface); + int error = 0; + + 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) +{ + struct usb_device *udev = interface_to_usbdev(iface); + const struct bcm5974_config *cfg; + struct bcm5974 *dev; + struct input_dev *input_dev; + int error = -ENOMEM; + + /* find the product index */ + cfg = bcm5974_get_config(udev); + + /* allocate memory for our device state and initialize it */ + dev = kzalloc(sizeof(struct bcm5974), GFP_KERNEL); + input_dev = input_allocate_device(); + if (!dev || !input_dev) { + err("bcm5974: out of memory"); + goto err_free_devs; + } + + dev->udev = udev; + dev->intf = iface; + dev->input = input_dev; + dev->cfg = *cfg; + mutex_init(&dev->pm_mutex); + + /* setup urbs */ + dev->bt_urb = usb_alloc_urb(0, GFP_KERNEL); + if (!dev->bt_urb) + goto err_free_devs; + + dev->tp_urb = usb_alloc_urb(0, GFP_KERNEL); + 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) + 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) + 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, + 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, + bcm5974_irq_trackpad, dev, 1); + + /* create bcm5974 device */ + usb_make_path(udev, dev->phys, sizeof(dev->phys)); + strlcat(dev->phys, "/input0", sizeof(dev->phys)); + + input_dev->name = "bcm5974"; + input_dev->phys = dev->phys; + usb_to_input_id(dev->udev, &input_dev->id); + input_dev->dev.parent = &iface->dev; + + input_set_drvdata(input_dev, dev); + + input_dev->open = bcm5974_open; + input_dev->close = bcm5974_close; + + setup_events_to_report(input_dev, cfg); + + error = input_register_device(dev->input); + if (error) + goto err_free_buffer; + + /* save our data pointer in this interface device */ + usb_set_intfdata(iface, dev); + + return 0; + +err_free_buffer: + usb_buffer_free(dev->udev, dev->cfg.tp_datalen, + dev->tp_data, dev->tp_urb->transfer_dma); +err_free_bt_buffer: + usb_buffer_free(dev->udev, dev->cfg.bt_datalen, + dev->bt_data, dev->bt_urb->transfer_dma); +err_free_urb: + usb_free_urb(dev->tp_urb); +err_free_bt_urb: + usb_free_urb(dev->bt_urb); +err_free_devs: + usb_set_intfdata(iface, NULL); + input_free_device(input_dev); + kfree(dev); + return error; +} + +static void bcm5974_disconnect(struct usb_interface *iface) +{ + struct bcm5974 *dev = usb_get_intfdata(iface); + + usb_set_intfdata(iface, NULL); + + 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); +} + +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, + .supports_autosuspend = 1, +}; + +static int __init bcm5974_init(void) +{ + return usb_register(&bcm5974_driver); +} + +static void __exit bcm5974_exit(void) +{ + usb_deregister(&bcm5974_driver); +} + +module_init(bcm5974_init); +module_exit(bcm5974_exit); + diff --git a/usr/src/dkms_source_tree/dkms.conf b/usr/src/dkms_source_tree/dkms.conf new file mode 100644 index 0000000..df7925c --- /dev/null +++ b/usr/src/dkms_source_tree/dkms.conf @@ -0,0 +1,11 @@ +NAME=bcm5974 +VERSION=0.99 +PACKAGE_NAME="$NAME" +PACKAGE_VERSION="$VERSION" +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/usr/src/dkms_source_tree/scripts/bcm5974-diagnostics b/usr/src/dkms_source_tree/scripts/bcm5974-diagnostics new file mode 100755 index 0000000..acd0bf4 --- /dev/null +++ b/usr/src/dkms_source_tree/scripts/bcm5974-diagnostics @@ -0,0 +1,232 @@ +#!/bin/bash +# +# bcm5943-diagnostics - troubleshooting the BCM5974 setup +# +# 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 + +echo ----------------------------------------------------------------------- + +# What kernel version am I running? +KERNEL=`uname -r` +echo \* Kernel version: $KERNEL + +# What synaptics version is installed (debian)? +if [ -x /usr/bin/dpkg-query ]; then + SYNAPTICS=`/usr/bin/dpkg-query -W -f='${Version}\n' xserver-xorg-input-synaptics` + echo \* Synaptics version: $SYNAPTICS +else + echo \* Synaptics version: UNKNOWN - dpkg not found +fi + +# What USB devices of interest can we find? +if [ -x /usr/sbin/lsusb ]; then + LSUSB=`lsusb|grep 05ac:02` + echo \* USB device: $LSUSB +else + echo \* USB device: UNKNOWN - lsusb not found +fi + +# Do we have the module intalled? +MODLIB=/lib/modules/$KERNEL/kernel/drivers/input/mouse/$DRIVER.ko +MODLIB2=/lib/modules/$KERNEL/updates/dkms/$DRIVER.ko +if [ -f $MODLIB ]; then + echo \* $MODLIB: exists +elif [ -f $MODLIB2 ]; then + echo \* $MODLIB2: exists +else + echo \* $DRIVER does NOT exist + echo dkms: install package + echo manual: copy the file $DRIVER.ko to $MODLIB + exit 1 +fi + +# Do we have the module configured? +MODULES=/etc/modules +if [ -f $MODULES ]; then + if (grep -q $DRIVER $MODULES); then + echo \* $MODULES: has $DRIVER config, please remove + exit 1 + else + echo \* $MODULES: $DRIVER no longer explicitly listed, good + fi +fi + +# Do we have old quirks? +MODPROBE=/etc/modprobe.d/options +if [ -f $MODPROBE ]; then + MODPROBEOPTS=`grep quirks= $MODPROBE|grep -v ^#|grep 0x05ac:0x02` + if [ "$MODPROBEOPTS" != "" ]; then + echo \* $MODPROBE: has obsolete quirks - please remove + exit 1 + else + echo \* $MODPROBE: no obsolete quirks, good + fi +else + echo \* $MODPROBE: file not found +fi + +# Do we have the right quirks? +DRIVMOD=/etc/modprobe.d/$DRIVER +if [ -f $DRIVMOD ]; then + DRIVMODOPTS=`grep quirks= $DRIVMOD|grep -v ^#|grep 0x05ac:0x02` + if [ "$DRIVMODOPTS" != "" ]; then + echo \* $DRIVMOD: has quirks, good + else + echo \* $DRIVMOD: does NOT have quirks + echo Uncomment the right quirk line in $DRIVMOD + exit 1 + fi +else + echo \* $DRIVMOD: file not found + echo Copy the etc/modprobe.d/bcm5974 file to /etc/modprobe.d/ + exit 1 +fi + +# Did the depmod bite? +USBMAP=/lib/modules/$KERNEL/modules.usbmap +if [ -f $USBMAP ]; then + typeset -i nusb=`grep $DRIVER $USBMAP|grep 0x05ac|grep 0x02|wc -l` + if [ $nusb -gt 0 ]; then + echo \* $USBMAP: maps to $DRIVER, good + else + echo \* $USBMAP: does NOT map to $DRIVER + echo Run depmod -a as root + exit 1 + fi +fi + +# Was the $DRIVER module loaded? +DMESG=`lsmod|grep $DRIVER` +if [ "$DMESG" != "" ]; then + echo \* $DRIVER: module is loaded +else + echo \* $DRIVER: module is NOT loaded + echo Add this line to /etc/modules: + echo "$DRIVER" + exit 1 +fi + +# Was the $DRIVER module registered? +DEVPATH=/proc/bus/input/devices +if [ -f $DEVPATH ]; then + DEVICES=`grep $DRIVER /proc/bus/input/devices` + if [ "$DEVICES" != "" ]; then + echo \* $DEVPATH: module is registered + else + echo \* $DEVPATH: module is NOT registered + echo "Please double-check the quirks settings in $DRIVMOD" + exit 1 + fi +else + echo \* $DEVPATH: does not exist, ignore +fi + +# Do we have synaptics working properly? +typeset -i SYNLINES=`synclient -l|wc -l` +if [ $SYNLINES -gt 10 ]; then + echo \* synaptics: configuration readable +else + echo \* synaptics: configuration NOT readable + exit 1 +fi + +# Do we have a working synaptics configuration? +DIFF=/tmp/synclient-output.diff.$$ +TMP=/tmp/synclient-output.txt.$$ +synclient -l | grep -v Parameter | sort > $TMP +diff -u - $TMP > $DIFF < $ETCPATH + exit 0 +else + echo No suitable device found + exit 1 +fi diff --git a/usr/src/dkms_source_tree/scripts/bcm5974-post-remove b/usr/src/dkms_source_tree/scripts/bcm5974-post-remove new file mode 100755 index 0000000..21977de --- /dev/null +++ b/usr/src/dkms_source_tree/scripts/bcm5974-post-remove @@ -0,0 +1,29 @@ +#!/bin/bash +# +# bcm5943-post-remove - post-removing 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 +ETCPATH=/etc/modprobe.d/$DRIVER + +echo ----------------------------------------------------------------------- + +rm -f $ETCPATH + +exit 0 diff --git a/usr/src/dkms_source_tree/scripts/bcm5974-pre-install b/usr/src/dkms_source_tree/scripts/bcm5974-pre-install new file mode 100755 index 0000000..1e2b864 --- /dev/null +++ b/usr/src/dkms_source_tree/scripts/bcm5974-pre-install @@ -0,0 +1,42 @@ +#!/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 [ "`$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