Initial code release
authorZhang Qiang <qiang.z.zhang@intel.com>
Fri, 18 May 2012 11:55:31 +0000 (19:55 +0800)
committerZhang Qiang <qiang.z.zhang@intel.com>
Sat, 19 May 2012 06:06:44 +0000 (14:06 +0800)
23 files changed:
COPYING [new file with mode: 0644]
Makefile [new file with mode: 0644]
README [new file with mode: 0644]
conf/xorg.conf.section [new file with mode: 0644]
debian/README.Debian [new file with mode: 0644]
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/copyright [new file with mode: 0644]
debian/files [new file with mode: 0644]
debian/rules [new file with mode: 0755]
packaging/update-api-change.patch [new file with mode: 0644]
packaging/xorg-drv-mtev.spec [new file with mode: 0644]
src/caps.c [new file with mode: 0644]
src/caps.h [new file with mode: 0644]
src/common.h [new file with mode: 0644]
src/hw.c [new file with mode: 0644]
src/hw.h [new file with mode: 0644]
src/mtouch.c [new file with mode: 0644]
src/mtouch.h [new file with mode: 0644]
src/multitouch.c [new file with mode: 0644]
xf86-input-mtev.spec [new file with mode: 0644]
xf86-input-mtev.yaml [new file with mode: 0644]

diff --git a/COPYING b/COPYING
new file mode 100644 (file)
index 0000000..999ca85
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,340 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  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.
+\f
+                   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.)
+\f
+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.
+\f
+  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.
+\f
+  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
+\f
+           How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..8e5baa9
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,76 @@
+LIBRARY        = mtev.so
+MODULES = src
+
+o_src  = caps \
+       hw \
+       mtouch \
+       multitouch
+
+#TARGETS       = $(addsuffix /test,$(MODULES))
+
+OBJECTS        = $(addsuffix .o,\
+       $(foreach mod,$(MODULES),\
+       $(addprefix $(mod)/,$(o_$(mod)))))
+
+#TBIN  = $(addprefix bin/,$(TARGETS))
+TLIB   = $(addprefix obj/,$(LIBRARY))
+#TOBJ  = $(addprefix obj/,$(addsuffix .o,$(TARGETS)))
+#TFDI  = $(addprefix fdi/,$(FDIS))
+OBJS   = $(addprefix obj/,$(OBJECTS))
+#LIBS  = -lpixman-1
+LIBS   += $(shell pkg-config --libs mtdev)
+
+DLIB   = usr/lib/xorg/modules/input
+# DFDI = usr/share/hal/fdi/policy/20thirdparty
+
+INCLUDE = -I/usr/include/xorg -I/usr/include/pixman-1 $(shell pkg-config --cflags mtdev)
+OPTS   = -O2 -g -Wall -fpic
+
+.PHONY: all clean
+.PRECIOUS: obj/%.o
+
+VERSION=$(shell cat debian/changelog | head -n 1 | sed -e 's/.*(\(.*\)).*/\1/g')
+
+all:   $(OBJS) $(TLIB) $(TOBJ)
+# $(TBIN)
+
+bin/%: obj/%.o
+       @mkdir -p $(@D)
+       gcc $< -o $@
+
+$(TLIB): $(OBJS)
+       @rm -f $(TLIB)
+       gcc -shared $(OBJS) -Wl,-soname -Wl,$(LIBRARY) -o $@ $(LIBS)
+
+obj/%.o: %.c
+       @mkdir -p $(@D)
+       gcc $(INCLUDE) $(OPTS) -c $< -o $@
+
+obj/%.o: %.cc
+       @mkdir -p $(@D)
+       gcc $(INCLUDE) $(OPTS) -c $< -o $@
+
+clean:
+       rm -rf bin obj
+
+spec: xf86-input-mtev.yaml
+       specify xf86-input-mtev.yaml
+
+dist:
+       git archive --format=tar --prefix=xf86-input-mtev-$(VERSION)/ master | gzip >xf86-input-mtev-$(VERSION).tar.gz
+
+rpm: dist
+#      cp xf86-input-mtev-$(VERSION).tar.gz rpm/SOURCES/
+#      rpmbuild -v -bb --clean xf86-input-mtev.spec
+
+# doesnt work :(
+#      sudo build --repository http://repo.meego.com/MeeGo/releases/1.0.1/core/repos/ia32/packages --arch i686 xf86-input-mtev.spec
+
+#http://repo.meego.com/MeeGo/releases/1.0.1/core/repos/ia32/os/ --arch i686 xf86-input-mtev.spec
+
+distclean: clean
+       rm -rf debian/*.log debian/files
+
+install: $(TLIB) $(TFDI)
+       install -d "$(DESTDIR)/$(DLIB)"
+       install -m 755 $(TLIB) "$(DESTDIR)/$(DLIB)"
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..0da532c
--- /dev/null
+++ b/README
@@ -0,0 +1,18 @@
+This is a xserver-xorg input driver for devices supporting
+Linux Multi-Touch protocol.
+
+Author: Mika Kuoppala <mika.kuoppala at-here nokia.com>
+
+This driver is based on apple touchpad driver by Henrik Rydberg
+
+Installation howto:
+
+You need to add correct input class definitio to xorg.conf
+Look at conf/xorg.conf.section and cut paste it into your xorg.conf
+
+The kernel device driver needs to pass correct MultiTouch protocol events to
+this driver. Also note that BTN_TOUCH needs to be provided by the kernel
+driver for udev to correctly set MatchIsTouchscreen capability in xserver.
+
+
+
diff --git a/conf/xorg.conf.section b/conf/xorg.conf.section
new file mode 100644 (file)
index 0000000..3e059da
--- /dev/null
@@ -0,0 +1,6 @@
+Section "InputClass"
+        Identifier              "internal-touchscreen"
+        MatchIsTouchScreen      "on"
+        Driver                  "mtev"
+        Option                  "Ignore"                "off"
+EndSection
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644 (file)
index 0000000..fefadee
--- /dev/null
@@ -0,0 +1,14 @@
+mtev Xorg driver
+
+This driver is based heavily on a work by Hendrik Rydberg (multitouch)
+
+Usage:
+
+* Install the debian package
+
+* Restart X
+
+Enjoy!
+
+Mika Kuoppala <mika.kuoppala@nokia.com>
+
diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..490ede5
--- /dev/null
@@ -0,0 +1,84 @@
+xserver-xorg-input-mtev (0.1.13) unstable; urgency=low
+   * Adapted to use libmtdev, supporting kernel protocol A and B
+
+ -- James Ketrenos <jketreno@linux.intel.com> Mon, 6 Dec 2010 14:56:03 -0800
+
+xserver-xorg-input-mtev (0.1.12) unstable; urgency=low
+
+  * Send motion events before button down
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Wed, 27 Oct 2010 13:40:02 +0300
+
+xserver-xorg-input-mtev (0.1.11) unstable; urgency=low
+
+  * Added orientation config options: SwapAxes, InvertX, InvertY.
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Tue, 26 Oct 2010 13:57:06 +0300
+
+xserver-xorg-input-mtev (0.1.10) unstable; urgency=low
+
+  * Dummy version bump to get messed up and released tags in sync :(
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Wed, 15 Sep 2010 14:22:53 +0300
+
+xserver-xorg-input-mtev (0.1.9) unstable; urgency=low
+
+  * Removed depracated xallocs
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Wed, 15 Sep 2010 14:17:58 +0300
+
+xserver-xorg-input-mtev (0.1.8) unstable; urgency=low
+
+  * Fixes: NB#167575 If kernel driver does't expose minor width,
+  assume it is the same as major width. As stated by Multi-Touch
+  protocol
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Wed, 19 May 2010 15:38:43 +0300
+
+xserver-xorg-input-mtev (0.1.7) unstable; urgency=low
+
+  * correct patchlevel for the module too
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Tue, 20 Apr 2010 14:37:04 +0300
+
+xserver-xorg-input-mtev (0.1.6) unstable; urgency=low
+
+  * fixed: buffer size was never grown due to redefinition
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Fri, 09 Apr 2010 13:23:18 +0300
+
+xserver-xorg-input-mtev (0.1.5) unstable; urgency=low
+
+  * bigger input buffer size
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Wed, 31 Mar 2010 15:47:03 +0300
+
+xserver-xorg-input-mtev (0.1.4) unstable; urgency=low
+
+  * Fix valuator overflow with >6 fingers
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Tue, 30 Mar 2010 11:58:08 +0300
+
+xserver-xorg-input-mtev (0.1.3) unstable; urgency=low
+
+  * Fix double free on uninit
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Fri, 26 Mar 2010 14:55:02 +0200
+
+xserver-xorg-input-mtev (0.1.2) unstable; urgency=low
+
+  * cleanup
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Thu, 04 Mar 2010 18:32:05 +0200
+
+xserver-xorg-input-mtev (0.1.1) unstable; urgency=low
+
+  * clamp fingers to six
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Tue, 16 Feb 2010 16:59:00 +0200
+
+xserver-xorg-input-mtev (0.1) unstable; urgency=low
+
+  * Initial version. Based heavily on a work by Hendrik Rydberg (multitouch)
+
+ -- Mika Kuoppala <mika.kuoppala@nokia.com>  Wed, 16 Dec 2009 17:21:33 +0200
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..7ed6ff8
--- /dev/null
@@ -0,0 +1 @@
+5
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..fd62ef8
--- /dev/null
@@ -0,0 +1,12 @@
+Source: xserver-xorg-input-mtev
+Section: x11
+Priority: optional
+Maintainer: Mika Kuoppala <mika.kuoppala@nokia.com>
+Build-Depends: debhelper (>= 5.0.0), pkg-config, xserver-xorg-dev (>= 1.7.993), libxi-dev (>= 2:1.2.99.4+0m6),x11proto-core-dev, x11proto-input-dev, dpkg-dev (>= 1.14.17), automake, libtool, xutils-dev (>= 1:7.5~1)
+Standards-Version: 3.7.3
+
+Package: xserver-xorg-input-mtev
+Architecture: any
+Description: Multitouch XI2 input driver
+ This package is a multitouch Xorg input driver supporting MultiTouch protocol
+
diff --git a/debian/copyright b/debian/copyright
new file mode 100644 (file)
index 0000000..498b99c
--- /dev/null
@@ -0,0 +1,24 @@
+Copyright:
+       Copyright (C) 2008      Henrik Rydberg (rydberg@euromail.se)
+       Copyright (C) 2009,2010 Nokia Corporation
+
+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 <rydberg@euromail.se>
+        released under GPL 2
+       Copyright (C) 2009,2010 Nokia Corporation
diff --git a/debian/files b/debian/files
new file mode 100644 (file)
index 0000000..27bf67c
--- /dev/null
@@ -0,0 +1 @@
+xserver-xorg-input-mtev_0.1.12_armel.deb x11 optional
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..7415c92
--- /dev/null
@@ -0,0 +1,45 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+build-arch:
+       dh_testdir
+       $(MAKE)
+
+build-indep:
+
+build: build-arch build-indep
+
+install:
+       dh_testdir
+       dh_testroot
+       dh_clean -k
+       dh_installdirs
+       $(MAKE) DESTDIR=$(CURDIR)/debian/xserver-xorg-input-mtev install
+
+binary-arch: build-arch install
+       dh_testdir
+       dh_testroot
+       dh_link
+       dh_strip
+       dh_compress
+       dh_fixperms
+       dh_installdeb
+       dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary-indep: build-indep
+
+binary: binary-arch binary-indep
+
+clean:
+       dh_testdir
+       dh_testroot
+       $(MAKE) clean
+       dh_clean
+
+.PHONY: build-arch build-indep build install binary-arch binary-indep binary clean
diff --git a/packaging/update-api-change.patch b/packaging/update-api-change.patch
new file mode 100644 (file)
index 0000000..1f1e806
--- /dev/null
@@ -0,0 +1,184 @@
+diff -Naurp xorg-x11-drv-mtev-0.1.13-orig//src/multitouch.c xorg-x11-drv-mtev-0.1.13/src/multitouch.c
+--- xorg-x11-drv-mtev-0.1.13-orig//src/multitouch.c    2012-01-04 13:05:27.603707979 +0800
++++ xorg-x11-drv-mtev-0.1.13/src/multitouch.c  2012-01-04 14:48:57.607869339 +0800
+@@ -33,6 +33,11 @@
+ #include "common.h"
+ #include "mtouch.h"
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 12
++/* removed from server, purge when dropping support for server 1.10 */
++#define XI86_SEND_DRAG_EVENTS   0x08
++#endif
++
+ static const char* const axis_labels_str[] = {
+       AXIS_LABEL_PROP_ABS_MT_POSITION_X,
+       AXIS_LABEL_PROP_ABS_MT_POSITION_Y,
+@@ -114,7 +119,11 @@ static int init_properties(DeviceIntPtr
+       return Success;
+ }
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+ static int device_init(DeviceIntPtr dev, LocalDevicePtr local)
++#else
++static int device_init(DeviceIntPtr dev, InputInfoPtr local)
++#endif
+ {
+       struct mtev_mtouch *mt = local->private;
+       Atom atom;
+@@ -208,7 +217,11 @@ static int device_init(DeviceIntPtr dev,
+                       xf86InitValuatorAxisStruct(dev, val, axes_labels[val],
+                                                  min,
+                                                  max,
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) > 12
++                                                 1, 0, 1, Absolute);
++#else
+                                                  1, 0, 1);
++#endif
+                       xf86InitValuatorDefaults(dev, val);
+               }
+       }
+@@ -218,7 +231,11 @@ static int device_init(DeviceIntPtr dev,
+       return Success;
+ }
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+ static int device_on(LocalDevicePtr local)
++#else
++static int device_on(InputInfoPtr local)
++#endif
+ {
+       struct mtev_mtouch *mt = local->private;
+       local->fd = xf86OpenSerial(local->options);
+@@ -234,7 +251,11 @@ static int device_on(LocalDevicePtr loca
+       return Success;
+ }
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+ static int device_off(LocalDevicePtr local)
++#else
++static int device_off(InputInfoPtr local)
++#endif
+ {
+       struct mtev_mtouch *mt = local->private;
+       xf86RemoveEnabledDevice(local);
+@@ -245,12 +266,20 @@ static int device_off(LocalDevicePtr loc
+       return Success;
+ }
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+ static int device_close(LocalDevicePtr local)
++#else
++static int device_close(InputInfoPtr local)
++#endif
+ {
+       return Success;
+ }
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+ static void process_state(LocalDevicePtr local,
++#else
++static void process_state(InputInfoPtr local,
++#endif
+                         const struct mtev_mtouch *mt)
+ {
+@@ -324,7 +353,11 @@ static void process_state(LocalDevicePtr
+ }
+ /* called for each full received packet from the touchpad */
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+ static void read_input(LocalDevicePtr local)
++#else
++static void read_input(InputInfoPtr local)
++#endif
+ {
+       struct mtev_mtouch *mt = local->private;
+       while (mtouch_read_synchronized_event(mt, local->fd)) {
+@@ -334,7 +367,12 @@ static void read_input(LocalDevicePtr lo
+ static Bool device_control(DeviceIntPtr dev, int mode)
+ {
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+       LocalDevicePtr local = dev->public.devicePrivate;
++#else
++      InputInfoPtr local = dev->public.devicePrivate;
++#endif
++
+       switch (mode) {
+       case DEVICE_INIT:
+               xf86Msg(X_INFO, "device control: init\n");
+@@ -354,27 +392,46 @@ static Bool device_control(DeviceIntPtr
+       }
+ }
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+ static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags)
++#else
++static int preinit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
++#endif
+ {
+       struct mtev_mtouch *mt;
++      int rc = BadAlloc;
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+       InputInfoPtr local = xf86AllocateInput(drv, 0);
+       if (!local)
+               goto error;
++#else
++      InputInfoPtr local = pInfo;
++#endif
+       mt = calloc(1, sizeof(struct mtev_mtouch));
+       if (!mt)
+               goto error;
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+       local->name = dev->identifier;
++#endif
+       local->type_name = XI_TOUCHSCREEN;
+       local->device_control = device_control;
+       local->read_input = read_input;
+       local->private = mt;
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+       local->flags = XI86_POINTER_CAPABLE |
+               XI86_SEND_DRAG_EVENTS;
+       local->conf_idev = dev;
++#else
++      local->flags = XI86_SEND_DRAG_EVENTS;
++#endif
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+       xf86CollectInputOptions(local, NULL, NULL);
++#else
++      xf86CollectInputOptions(local, NULL);
++#endif
+       //xf86OptionListReport(local->options);
+       xf86ProcessCommonOptions(local, local->options);
+@@ -383,10 +440,17 @@ static InputInfoPtr preinit(InputDriverP
+       mt->invert_x = xf86SetBoolOption(local->options, "InvertX", FALSE);
+       mt->invert_y = xf86SetBoolOption(local->options, "InvertY", FALSE);
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+       local->flags |= XI86_CONFIGURED;
++#endif
++      rc = Success;
+ error:
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+       return local;
++#else
++      return rc;
++#endif
+ }
+ static void uninit(InputDriverPtr drv, InputInfoPtr local, int flags)
+@@ -403,7 +467,9 @@ static InputDriverRec MTEV = {
+       .PreInit = preinit,
+       .UnInit = uninit,
+       .module = NULL,
++#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 12
+       .refCount = 0
++#endif
+ };
+ static XF86ModuleVersionInfo VERSION = {
diff --git a/packaging/xorg-drv-mtev.spec b/packaging/xorg-drv-mtev.spec
new file mode 100644 (file)
index 0000000..3728a4e
--- /dev/null
@@ -0,0 +1,41 @@
+Name:       xorg-drv-mtev
+Summary:    Multitouch input driver for Xserver
+Version:    0.1.13
+Release:    1
+Group:      System/X Hardware Support
+License:    GPLv2
+URL:        http://gitorious.org/xorg/xf86-input-mtev
+Source0:    xorg-x11-drv-mtev-%{version}.tar.gz
+# >> gbp-patch-tags         # auto-added by gbp
+Patch0:     update-api-change.patch
+# << gbp-patch-tags         # auto-added by gbp
+BuildRequires:  pkgconfig(xorg-server)
+BuildRequires:  pkgconfig(xkbfile)
+BuildRequires:  pkgconfig(xproto)
+BuildRequires:  pkgconfig(inputproto)
+BuildRequires:  pkgconfig(xrandr)
+BuildRequires:  pkgconfig(randrproto)
+BuildRequires:  pkgconfig(xextproto)
+BuildRequires:  pkgconfig(mtdev)
+
+
+%description
+This is a xserver-xorg input driver for devices supporting Linux Multi-Touch protocol
+
+
+%prep
+%setup -q -n xorg-x11-drv-mtev-%{version}
+# >> gbp-apply-patches    # auto-added by gbp
+%patch0 -p1
+# << gbp-apply-patches    # auto-added by gbp
+
+%build
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+%files
+%(pkg-config xorg-server --variable=moduledir )/input/mtev.so
+
+
diff --git a/src/caps.c b/src/caps.c
new file mode 100644 (file)
index 0000000..293e5b3
--- /dev/null
@@ -0,0 +1,143 @@
+/***************************************************************************
+ *
+ * Multitouch protocol X driver
+ * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
+ * Copyright (C) 2009,2010 Nokia Corporation
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#include "caps.h"
+#include <errno.h>
+#include <string.h>
+#include <xf86.h>
+#include <xf86Xinput.h>
+
+#define SETABS(c, x, map, key, fd)                                     \
+       c->has_##x = getbit(map, key) && getabs(&c->abs_##x, key, fd)
+
+#define ADDCAP(s, c, x) strcat(s, c->has_##x ? " " #x : "")
+
+static const int bits_per_long = 8 * sizeof(long);
+
+static inline int nlongs(int nbit)
+{
+       return (nbit + bits_per_long - 1) / bits_per_long;
+}
+
+static inline bool getbit(const unsigned long* map, int key)
+{
+       return (map[key / bits_per_long] >> (key % bits_per_long)) & 0x01;
+}
+
+static bool getabs(struct input_absinfo *abs, int key, int fd)
+{
+       int rc;
+       SYSCALL(rc = ioctl(fd, EVIOCGABS(key), abs));
+       return rc >= 0;
+}
+
+int caps_read(struct mtev_caps *caps, int fd)
+{
+       unsigned long evbits[nlongs(EV_MAX)];
+       unsigned long absbits[nlongs(ABS_MAX)];
+       unsigned long keybits[nlongs(KEY_MAX)];
+       int rc;
+
+       memset(caps, 0, sizeof(struct mtev_caps));
+
+       SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_SYN, sizeof(evbits)), evbits));
+       if (rc < 0) {
+               xf86Msg(X_ERROR, "mtev: EV_SYN needed but missing\n");
+               return rc;
+       }
+
+       SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybits)), keybits));
+       if (rc < 0) {
+               xf86Msg(X_ERROR, "mtev: EV_KEY needed but missing\n");
+               return rc;
+       }
+       SYSCALL(rc = ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbits)), absbits));
+       if (rc < 0) {
+               xf86Msg(X_ERROR, "mtev: EV_ABS needed but missing\n");
+               return rc;
+       }
+
+       caps->has_left = getbit(keybits, BTN_LEFT);
+       caps->has_middle = getbit(keybits, BTN_MIDDLE);
+       caps->has_right = getbit(keybits, BTN_RIGHT);
+
+       SETABS(caps, touch_major, absbits, ABS_MT_TOUCH_MAJOR, fd);
+       SETABS(caps, touch_minor, absbits, ABS_MT_TOUCH_MINOR, fd);
+       SETABS(caps, width_major, absbits, ABS_MT_WIDTH_MAJOR, fd);
+       SETABS(caps, width_minor, absbits, ABS_MT_WIDTH_MINOR, fd);
+       SETABS(caps, orientation, absbits, ABS_MT_ORIENTATION, fd);
+       SETABS(caps, position_x, absbits, ABS_MT_POSITION_X, fd);
+       SETABS(caps, position_y, absbits, ABS_MT_POSITION_Y, fd);
+       SETABS(caps, tracking_id, absbits, ABS_MT_TRACKING_ID, fd);
+
+       caps->has_mtdata = caps->has_position_x && caps->has_position_y;
+
+       return 0;
+}
+
+void caps_output(const struct mtev_caps *caps)
+{
+       char line[1024];
+       memset(line, 0, sizeof(line));
+       ADDCAP(line, caps, left);
+       ADDCAP(line, caps, middle);
+       ADDCAP(line, caps, right);
+       ADDCAP(line, caps, mtdata);
+       ADDCAP(line, caps, touch_major);
+       ADDCAP(line, caps, touch_minor);
+       ADDCAP(line, caps, width_major);
+       ADDCAP(line, caps, width_minor);
+       ADDCAP(line, caps, orientation);
+       ADDCAP(line, caps, tracking_id);
+       ADDCAP(line, caps, position_x);
+       ADDCAP(line, caps, position_y);
+
+       xf86Msg(X_INFO, "mtev: caps:%s\n", line);
+       if (caps->has_touch_major)
+               xf86Msg(X_INFO, "mtev: touch major: %d %d\n",
+                       caps->abs_touch_major.minimum,
+                       caps->abs_touch_major.maximum);
+       if (caps->has_touch_minor)
+               xf86Msg(X_INFO, "mtev: touch minor: %d %d\n",
+                       caps->abs_touch_minor.minimum,
+                       caps->abs_touch_minor.maximum);
+       if (caps->has_width_major)
+               xf86Msg(X_INFO, "mtev: width: %d %d\n",
+                       caps->abs_width_major.minimum,
+                       caps->abs_width_major.maximum);
+       if (caps->has_orientation)
+               xf86Msg(X_INFO, "mtev: orientation: %d %d\n",
+                       caps->abs_orientation.minimum,
+                       caps->abs_orientation.maximum);
+       if (caps->has_tracking_id)
+               xf86Msg(X_INFO, "mtev: tracking_id: %d %d\n",
+                       caps->abs_tracking_id.minimum,
+                       caps->abs_tracking_id.maximum);
+       if (caps->has_position_x)
+               xf86Msg(X_INFO, "mtev: position_x: %d %d\n",
+                       caps->abs_position_x.minimum,
+                       caps->abs_position_x.maximum);
+       if (caps->has_position_y)
+               xf86Msg(X_INFO, "mtev: position_y: %d %d\n",
+                       caps->abs_position_y.minimum,
+                       caps->abs_position_y.maximum);
+}
diff --git a/src/caps.h b/src/caps.h
new file mode 100644 (file)
index 0000000..bfc9c33
--- /dev/null
@@ -0,0 +1,49 @@
+/***************************************************************************
+ *
+ * Multitouch protocol X driver
+ * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
+ * Copyright (C) 2009,2010 Nokia Corporation
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef CAPABILITIES_H
+#define CAPABILITIES_H
+
+#include "common.h"
+#include <linux/input.h>
+
+struct mtev_caps {
+       bool has_left, has_middle;
+       bool has_right, has_mtdata;
+       bool has_touch_major, has_touch_minor;
+       bool has_width_major, has_width_minor;
+       bool has_orientation, has_tracking_id;
+       bool has_position_x, has_position_y;
+       struct input_absinfo abs_touch_major;
+       struct input_absinfo abs_touch_minor;
+       struct input_absinfo abs_width_major;
+       struct input_absinfo abs_width_minor;
+       struct input_absinfo abs_orientation;
+       struct input_absinfo abs_position_x;
+       struct input_absinfo abs_position_y;
+       struct input_absinfo abs_tracking_id;
+};
+
+int caps_read(struct mtev_caps *caps, int fd);
+void caps_output(const struct mtev_caps *caps);
+
+#endif
diff --git a/src/common.h b/src/common.h
new file mode 100644 (file)
index 0000000..7cc4998
--- /dev/null
@@ -0,0 +1,54 @@
+/***************************************************************************
+ *
+ * Multitouch protocol X driver
+ * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
+ * Copyright (C) 2009,2010 Nokia Corporation
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef COMMON_H
+#define COMMON_H
+
+typedef unsigned char bool;
+
+// includes available in 2.6.30-rc5
+
+#ifndef ABS_MT_PRESSURE
+#define BTN_TOOL_QUADTAP       0x14f   /* Four fingers on trackpad */
+#define ABS_MT_TOUCH_MAJOR     0x30    /* Major axis of touching ellipse */
+#define ABS_MT_TOUCH_MINOR     0x31    /* Minor axis (omit if circular) */
+#define ABS_MT_WIDTH_MAJOR     0x32    /* Major axis of approaching ellipse */
+#define ABS_MT_WIDTH_MINOR     0x33    /* Minor axis (omit if circular) */
+#define ABS_MT_ORIENTATION     0x34    /* Ellipse orientation */
+#define ABS_MT_POSITION_X      0x35    /* Center X ellipse position */
+#define ABS_MT_POSITION_Y      0x36    /* Center Y ellipse position */
+#define ABS_MT_TOOL_TYPE       0x37    /* Type of touching device */
+#define ABS_MT_BLOB_ID         0x38    /* Group a set of packets as a blob */
+#define ABS_MT_TRACKING_ID      0x39    /* Unique ID of initiated contact */
+#define ABS_MT_PRESSURE         0x3a    /* Pressure on contact area */
+#define SYN_MT_REPORT          2
+#define MT_TOOL_FINGER         0
+#define MT_TOOL_PEN            1
+#endif
+
+#define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
+
+#define GETBIT(m, x) ((m>>(x))&1U)
+#define SETBIT(m, x) (m|=(1U<<(x)))
+#define CLEARBIT(m, x) (m&=~(1U<<(x)))
+
+#endif
diff --git a/src/hw.c b/src/hw.c
new file mode 100644 (file)
index 0000000..1afec1a
--- /dev/null
+++ b/src/hw.c
@@ -0,0 +1,105 @@
+/***************************************************************************
+ *
+ * Multitouch protocol X driver
+ * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
+ * Copyright (C) 2009,2010 Nokia Corporation
+ *
+ * Adaptation to libmtdev and Linux multi-touch-protocol B (slotted)
+ * Copyright (C) 2010 Intel Corporation
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#include <string.h>
+#include <linux/input.h>
+#include <xf86.h>
+#include <mtdev.h>
+
+#include "hw.h"
+
+void hw_init(struct mtev_hw_state *hw)
+{
+       int i;
+       memset(hw, 0, sizeof(struct mtev_hw_state));
+       for (i = 0; i < HW_MAX_SLOTS; i++)
+           hw->slot[i].tracking_id = INVALID_TRACKING_ID;
+}
+
+bool hw_read(struct mtev_hw_state *hw, const struct input_event* ev)
+{
+       // xf86Msg(X_INFO, "event: %d %d %d\n", ev->type, ev->code, ev->value);
+
+       switch (ev->type) {
+       case EV_SYN:
+               switch (ev->code) {
+               case SYN_REPORT:
+                       return 1;
+
+               case SYN_MT_REPORT:
+                       xf86Msg(X_ERROR, "libmtdev sent SYN_MT_REPORT");
+                       break;
+               }
+               break;
+
+       case EV_ABS:
+               if (ev->code == ABS_MT_SLOT) {
+                       if (ev->value >= HW_MAX_SLOTS) {
+                               xf86Msg(X_ERROR, "Slot usage (%d) exceeds limit of %d", ev->value, HW_MAX_SLOTS);
+                               hw->current_slot = INVALID_SLOT;
+                       } else
+                               hw->current_slot = ev->value;
+                       break;
+               }
+
+               if (hw->current_slot == INVALID_SLOT)
+                       break;
+
+               switch (ev->code) {
+               case ABS_MT_POSITION_X:
+                       hw->slot[hw->current_slot].position_x = ev->value;
+                       break;
+               case ABS_MT_POSITION_Y:
+                       hw->slot[hw->current_slot].position_y = ev->value;
+                       break;
+               case ABS_MT_TOUCH_MAJOR:
+                       hw->slot[hw->current_slot].touch_major = ev->value;
+                       break;
+               case ABS_MT_TOUCH_MINOR:
+                       hw->slot[hw->current_slot].touch_minor = ev->value;
+                       break;
+               case ABS_MT_WIDTH_MAJOR:
+                       hw->slot[hw->current_slot].width_major = ev->value;
+                       break;
+               case ABS_MT_WIDTH_MINOR:
+                       hw->slot[hw->current_slot].width_minor = ev->value;
+                       break;
+               case ABS_MT_ORIENTATION:
+                       hw->slot[hw->current_slot].orientation = ev->value;
+                       break;
+               case ABS_MT_PRESSURE:
+                       hw->slot[hw->current_slot].pressure = ev->value;
+                       break;
+               case ABS_MT_TRACKING_ID:
+                       if (ev->value == -1) /* Slot contact has been released */
+                               hw->slot[hw->current_slot].tracking_id = INVALID_TRACKING_ID;
+                       else
+                               hw->slot[hw->current_slot].tracking_id = hw->current_slot;//ev->value;
+                       break;
+               }
+       }
+
+       return 0;
+}
diff --git a/src/hw.h b/src/hw.h
new file mode 100644 (file)
index 0000000..faba0f8
--- /dev/null
+++ b/src/hw.h
@@ -0,0 +1,52 @@
+/***************************************************************************
+ *
+ * Multitouch protocol X driver
+ * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
+ * Copyright (C) 2009,2010 Nokia Corporation
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef HWDATA_H
+#define HWDATA_H
+
+#include "common.h"
+
+struct input_event;
+
+// Max touch points we gonna get out from kernel layer
+#define HW_MAX_SLOTS 10
+#define INVALID_SLOT -1
+#define INVALID_TRACKING_ID -1
+
+struct mtev_touch_point {
+       int touch_major, touch_minor;
+       int width_major, width_minor;
+       int orientation;
+       int position_x, position_y;
+       int pressure;
+       int tracking_id;
+};
+
+struct mtev_hw_state {
+       struct mtev_touch_point slot[HW_MAX_SLOTS];
+       int current_slot;
+};
+
+void hw_init(struct mtev_hw_state *hw);
+bool hw_read(struct mtev_hw_state *hw, const struct input_event* ev);
+
+#endif
diff --git a/src/mtouch.c b/src/mtouch.c
new file mode 100644 (file)
index 0000000..cf3add8
--- /dev/null
@@ -0,0 +1,110 @@
+/***************************************************************************
+ *
+ * Multitouch protocol X driver
+ * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
+ * Copyright (C) 2009,2010 Nokia Corporation
+ *
+ * Adaptation to libmtdev and Linux multi-touch-protocol B (slotted)
+ * Copyright (C) 2010 Intel Corporation
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <xf86.h>
+
+#include "mtouch.h"
+
+int mtouch_configure(struct mtev_mtouch *mt, int fd)
+{
+       int rc = caps_read(&mt->caps, fd);
+       if (rc < 0)
+               return rc;
+       caps_output(&mt->caps);
+       return 0;
+}
+
+int mtouch_open(struct mtev_mtouch *mt, int fd)
+{
+       memset(&mt->ev, 0, sizeof(mt->ev));
+       memset(&mt->dev, 0, sizeof(mt->dev));
+       mt->num_events = 0;
+       hw_init(&mt->hw_state);
+       return mtdev_open(&mt->dev, fd);
+}
+
+int mtouch_close(struct mtev_mtouch *mt, int fd)
+{
+       mtdev_close(&mt->dev);
+       memset(&mt->dev, 0, sizeof(mt->dev));
+       memset(&mt->ev, 0, sizeof(mt->ev));
+       mt->num_events = 0;
+       hw_init(&mt->hw_state);
+       return 0;
+}
+
+const struct input_event* mtouch_read_event(struct mtev_mtouch *mt, int fd)
+{
+       struct input_event *ev;
+
+       /* Read in bursts from input subsystem, then feed to caller one
+        * at a time, only reading the next burst when the queue is empty */
+       if (mt->num_events_read >= mt->num_events) {
+               int n;
+
+               SYSCALL(n = mtdev_get(&mt->dev, fd, mt->ev, MAX_EVENTS));
+               if (n <= 0)
+                       return NULL;
+
+               mt->num_events = n;
+               mt->num_events_read = 0;
+       }
+
+       if (mt->num_events > mt->num_events_read) {
+               ev = &mt->ev[mt->num_events_read];
+               mt->num_events_read++;
+               return ev;
+       }
+
+       // This should not happen
+       xf86Msg(X_ERROR, "mtev: got read_event without event!\n");
+       return NULL;
+}
+
+bool mtouch_read_synchronized_event(struct mtev_mtouch *mt, int fd)
+{
+       const struct input_event* ev;
+
+       while ((ev = mtouch_read_event(mt, fd))) {
+               if (hw_read(&mt->hw_state, ev))
+                       return 1;
+       }
+
+       return 0;
+}
+
+const struct mtev_touch_point* mtouch_get_contact(const struct mtev_mtouch *mt, int n)
+{
+       int i = 0;
+       do {
+               if (mt->hw_state.slot[i].tracking_id != INVALID_TRACKING_ID && (n--) == 0)
+                       return &mt->hw_state.slot[i];
+       } while (++i < HW_MAX_SLOTS);
+
+       return NULL;
+}
diff --git a/src/mtouch.h b/src/mtouch.h
new file mode 100644 (file)
index 0000000..9745776
--- /dev/null
@@ -0,0 +1,83 @@
+/***************************************************************************
+ *
+ * Multitouch protocol X driver
+ * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
+ * Copyright (C) 2009,2010 Nokia Corporation
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#ifndef MTOUCH_H
+#define MTOUCH_H
+
+#include <mtdev.h>
+#include <mtdev-mapping.h>
+
+#include "caps.h"
+#include "hw.h"
+
+#define MT_AXIS_PER_FINGER   5
+
+/*
+ * How many fingers we export to upwards
+ * The MAX_VALUATORS limits these.
+ * MT_NUM_VALUATORS needs to be less or equal than MAX_VALUATORS
+ */
+
+#define MT_NUM_FINGERS       6
+#define MT_NUM_VALUATORS     (MT_NUM_FINGERS * MT_AXIS_PER_FINGER)
+
+#define MT_NUM_BUTTONS       1
+
+/* Axis labels */
+
+#define AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR "Abs MT Touch Major"
+#define AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR "Abs MT Touch Minor"
+#define AXIS_LABEL_PROP_ABS_MT_WIDTH_MAJOR "Abs MT Width Major"
+#define AXIS_LABEL_PROP_ABS_MT_WIDTH_MINOR "Abs MT Width Minor"
+#define AXIS_LABEL_PROP_ABS_MT_ORIENTATION "Abs MT Orientation"
+#define AXIS_LABEL_PROP_ABS_MT_POSITION_X  "Abs MT Position X"
+#define AXIS_LABEL_PROP_ABS_MT_POSITION_Y  "Abs MT Position Y"
+#define AXIS_LABEL_PROP_ABS_MT_TOOL_TYPE   "Abs MT Tool Type"
+#define AXIS_LABEL_PROP_ABS_MT_BLOB_ID     "Abs MT Blob ID"
+#define AXIS_LABEL_PROP_ABS_MT_TRACKING_ID "Abs MT Tracking ID"
+#define AXIS_LABEL_PROP_ABS_MT_PRESSURE    "Abs MT Pressure"
+
+#define MAX_EVENTS 256
+
+struct mtev_mtouch {
+       struct input_event ev[MAX_EVENTS];
+       unsigned long num_events;
+       unsigned long num_events_read;
+
+       struct mtev_hw_state hw_state;
+       struct mtev_caps caps;
+
+       bool invert_x;
+       bool invert_y;
+       bool swap_xy;
+       struct mtdev dev;
+};
+
+int mtouch_configure(struct mtev_mtouch *mt, int fd);
+int mtouch_open(struct mtev_mtouch *mt, int fd);
+int mtouch_close(struct mtev_mtouch *mt, int fd);
+
+bool mtouch_read_synchronized_event(struct mtev_mtouch *mt, int fd);
+int mtouch_num_contacts(const struct mtev_mtouch *mt);
+const struct mtev_touch_point* mtouch_get_contact(const struct mtev_mtouch *mt, int n);
+
+#endif
diff --git a/src/multitouch.c b/src/multitouch.c
new file mode 100644 (file)
index 0000000..20fdf65
--- /dev/null
@@ -0,0 +1,434 @@
+/***************************************************************************
+ *
+ * Multitouch X driver
+ * Copyright (C) 2008 Henrik Rydberg <rydberg@euromail.se>
+ * Copyright (C) 2009,2010 Nokia Corporation
+ *
+ * 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ **************************************************************************/
+
+#define MODULEVENDORSTRING "Nokia"
+
+#include "xorg-server.h"
+#include <xorg/exevents.h>
+#include <xorg/xserver-properties.h>
+#include <X11/Xatom.h>
+#include <xf86.h>
+#include <xf86_OSproc.h>
+#include <xf86Xinput.h>
+
+#include "common.h"
+#include "mtouch.h"
+
+static const char* const axis_labels_str[] = {
+       AXIS_LABEL_PROP_ABS_MT_POSITION_X,
+       AXIS_LABEL_PROP_ABS_MT_POSITION_Y,
+       AXIS_LABEL_PROP_ABS_MT_TOUCH_MAJOR,
+       AXIS_LABEL_PROP_ABS_MT_TOUCH_MINOR,
+       AXIS_LABEL_PROP_ABS_MT_TRACKING_ID,
+};
+
+static void pointer_control(DeviceIntPtr dev, PtrCtrl *ctrl)
+{
+       xf86Msg(X_INFO, "pointer_control\n");
+}
+
+static int pointer_property(DeviceIntPtr dev,
+                           Atom property,
+                           XIPropertyValuePtr prop,
+                           BOOL checkonly)
+{
+       xf86Msg(X_INFO, "pointer_property\n");
+       return Success;
+}
+
+static void init_axes_labels(Atom* labels, int num_labels)
+{
+       int i;
+
+       for (i = 0 ; i < num_labels; i++) {
+               labels[i] = MakeAtom(axis_labels_str[i % MT_AXIS_PER_FINGER],
+                                    strlen(axis_labels_str[i % MT_AXIS_PER_FINGER]),
+                                    TRUE);
+       }
+}
+
+static int init_properties(DeviceIntPtr dev)
+{
+       static const char* const strMaxContacts = "Max Contacts";
+       static const char* const strAxesPerContact = "Axes Per Contact";
+       int rc;
+
+       Atom labelMaxContacts;
+       Atom labelAxesPerContact;
+
+       int max_contacts = MT_NUM_FINGERS;
+       int axes_per_contact = MT_AXIS_PER_FINGER;
+
+       labelMaxContacts = MakeAtom(strMaxContacts,
+                                   strlen(strMaxContacts), TRUE);
+       labelAxesPerContact = MakeAtom(strAxesPerContact,
+                                      strlen(strAxesPerContact), TRUE);
+
+       rc = XIChangeDeviceProperty(dev,
+                                   labelMaxContacts,
+                                   XA_INTEGER,
+                                   8,
+                                   PropModeReplace,
+                                   1,
+                                   &max_contacts,
+                                   TRUE);
+       if (rc != Success)
+               return rc;
+
+       XISetDevicePropertyDeletable(dev, labelMaxContacts, FALSE);
+
+
+       rc = XIChangeDeviceProperty(dev,
+                                   labelAxesPerContact,
+                                   XA_INTEGER,
+                                   8,
+                                   PropModeReplace,
+                                   1,
+                                   &axes_per_contact,
+                                   TRUE);
+
+       if (rc != Success)
+               return rc;
+
+       XISetDevicePropertyDeletable(dev, labelAxesPerContact, FALSE);
+
+       return Success;
+}
+
+static int device_init(DeviceIntPtr dev, LocalDevicePtr local)
+{
+       struct mtev_mtouch *mt = local->private;
+       Atom atom;
+       int i;
+       int j;
+       unsigned char map[MT_NUM_BUTTONS + 1];
+       Atom btn_labels[MT_NUM_BUTTONS] = { 0 };
+       Atom axes_labels[MT_NUM_VALUATORS] = { 0, };
+       int r;
+
+       if (MT_NUM_VALUATORS > MAX_VALUATORS) {
+               xf86Msg(X_ERROR, "MT_NUM_VALUATORS(%d) > MAX_VALUATORS(%d)\n",
+                       MT_NUM_VALUATORS, MAX_VALUATORS);
+               return BadValue;
+       }
+
+       for (i = 0; i < MT_NUM_BUTTONS; i++)
+               btn_labels[i] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_UNKNOWN);
+
+       atom = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+       btn_labels[0] = atom;
+
+       init_axes_labels(axes_labels, MT_NUM_VALUATORS);
+
+       r = init_properties(dev);
+       if (r != Success)
+               return r;
+
+       local->fd = xf86OpenSerial(local->options);
+       if (local->fd < 0) {
+               xf86Msg(X_ERROR, "mtev: cannot open device\n");
+               return !Success;
+       }
+       if (mtouch_configure(mt, local->fd)) {
+               xf86Msg(X_ERROR, "mtev: cannot configure device\n");
+               return !Success;
+       }
+       xf86CloseSerial(local->fd);
+
+       for (i = 0; i < MT_NUM_BUTTONS+1; i++)
+               map[i] = i;
+
+       InitPointerDeviceStruct((DevicePtr)dev,
+                               map,
+                               MT_NUM_BUTTONS,
+                               btn_labels,
+                               pointer_control,
+                               GetMotionHistorySize(),
+                               MT_NUM_VALUATORS,
+                               axes_labels);
+
+       for (i = 0; i < MT_NUM_FINGERS; i++) {
+               for (j = 0; j < MT_AXIS_PER_FINGER; j++) {
+                       const int val = (i * MT_AXIS_PER_FINGER) + j;
+                       int min;
+                       int max;
+
+                       switch (j) {
+                       case 0:
+                               min = mt->caps.abs_position_x.minimum;
+                               max = mt->caps.abs_position_x.maximum;
+                               break;
+                       case 1:
+                               min = mt->caps.abs_position_y.minimum;
+                               max = mt->caps.abs_position_y.maximum;
+                               break;
+                       case 2:
+                               min = mt->caps.abs_touch_major.minimum;
+                               max = mt->caps.abs_touch_major.maximum;
+                               break;
+                       case 3:
+                               if (mt->caps.has_touch_minor) {
+                                       min = mt->caps.abs_touch_minor.minimum;
+                                       max = mt->caps.abs_touch_minor.maximum;
+                               } else {
+                                       min = mt->caps.abs_touch_major.minimum;
+                                       max = mt->caps.abs_touch_major.maximum;
+                               }
+                               break;
+                       case 4: // Tracking id
+                               min = mt->caps.abs_tracking_id.minimum;
+                               max = mt->caps.abs_tracking_id.maximum >
+                                       (MT_NUM_FINGERS-1) ?
+                                       (MT_NUM_FINGERS-1) :
+                                       mt->caps.abs_tracking_id.maximum;
+                               break;
+                       default:
+                               return BadValue;
+                       }
+
+                       xf86InitValuatorAxisStruct(dev, val, axes_labels[val],
+                                                  min,
+                                                  max,
+                                                  1, 0, 1);
+                       xf86InitValuatorDefaults(dev, val);
+               }
+       }
+
+       XIRegisterPropertyHandler(dev, pointer_property, NULL, NULL);
+
+       return Success;
+}
+
+static int device_on(LocalDevicePtr local)
+{
+       struct mtev_mtouch *mt = local->private;
+       local->fd = xf86OpenSerial(local->options);
+       if (local->fd < 0) {
+               xf86Msg(X_ERROR, "mtev: cannot open device\n");
+               return !Success;
+       }
+       if (mtouch_open(mt, local->fd)) {
+               xf86Msg(X_ERROR, "mtev: cannot grab device\n");
+               return !Success;
+       }
+       xf86AddEnabledDevice(local);
+       return Success;
+}
+
+static int device_off(LocalDevicePtr local)
+{
+       struct mtev_mtouch *mt = local->private;
+       xf86RemoveEnabledDevice(local);
+       if(mtouch_close(mt, local->fd)) {
+               xf86Msg(X_WARNING, "mtev: cannot ungrab device\n");
+       }
+       xf86CloseSerial(local->fd);
+       return Success;
+}
+
+static int device_close(LocalDevicePtr local)
+{
+       return Success;
+}
+
+static void process_state(LocalDevicePtr local,
+                         const struct mtev_mtouch *mt)
+{
+
+       const struct mtev_touch_point *tp;
+       static int pdown = 0;
+       int valuators[MAX_VALUATORS];
+       int down;
+       int valix;
+       int contacts;
+
+       contacts = valix = down = 0;
+
+       while ((tp = mtouch_get_contact(mt, contacts)) != NULL) {
+               contacts++;
+
+               // We don't do remapping of tracking id's so
+               // make sure clients don't see too high tracking_id numbers
+               if (tp->tracking_id < MT_NUM_FINGERS) {
+                       int x;
+                       int y;
+
+                       x = tp->position_x;
+                       y = tp->position_y;
+
+                       if (mt->invert_x)
+                               x = mt->caps.abs_position_x.maximum - x +
+                                       mt->caps.abs_position_x.minimum;
+
+                       if (mt->invert_y)
+                               y = mt->caps.abs_position_y.maximum - y
+                                       + mt->caps.abs_position_y.minimum;
+
+                       if (mt->swap_xy) {
+                               const int tmp = y;
+                               y = x;
+                               x = tmp;
+                       }
+
+                       valuators[valix++] = x;
+                       valuators[valix++] = y;
+                       valuators[valix++] = tp->touch_major;
+
+                       if (mt->caps.has_touch_minor)
+                               valuators[valix++] = tp->touch_minor;
+                       else
+                               valuators[valix++] = tp->touch_major;
+
+                       valuators[valix++] = tp->tracking_id;
+
+                       down++;
+               }
+
+               // Don't deliver more than MaxContacts
+               if (down >= MT_NUM_FINGERS)
+                       break;
+       }
+
+       /* Some x-clients assume they get motion events before button down */
+       if (down)
+               xf86PostMotionEventP(local->dev, TRUE,
+                                    0, down * MT_AXIS_PER_FINGER, valuators);
+
+       if(down && pdown == 0)
+               xf86PostButtonEventP(local->dev, TRUE,
+                                    1, 1,
+                                    0, down * MT_AXIS_PER_FINGER, valuators);
+       else if (down == 0 && pdown)
+               xf86PostButtonEvent(local->dev, TRUE, 1, 0, 0, 0);
+
+       pdown = !!down;
+}
+
+/* called for each full received packet from the touchpad */
+static void read_input(LocalDevicePtr local)
+{
+       struct mtev_mtouch *mt = local->private;
+       while (mtouch_read_synchronized_event(mt, local->fd)) {
+               process_state(local, mt);
+       }
+}
+
+static Bool device_control(DeviceIntPtr dev, int mode)
+{
+       LocalDevicePtr local = dev->public.devicePrivate;
+       switch (mode) {
+       case DEVICE_INIT:
+               xf86Msg(X_INFO, "device control: init\n");
+               return device_init(dev, local);
+       case DEVICE_ON:
+               xf86Msg(X_INFO, "device control: on\n");
+               return device_on(local);
+       case DEVICE_OFF:
+               xf86Msg(X_INFO, "device control: off\n");
+               return device_off(local);
+       case DEVICE_CLOSE:
+               xf86Msg(X_INFO, "device control: close\n");
+               return device_close(local);
+       default:
+               xf86Msg(X_INFO, "device control: default\n");
+               return BadValue;
+       }
+}
+
+static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags)
+{
+       struct mtev_mtouch *mt;
+       InputInfoPtr local = xf86AllocateInput(drv, 0);
+       if (!local)
+               goto error;
+       mt = calloc(1, sizeof(struct mtev_mtouch));
+       if (!mt)
+               goto error;
+
+       local->name = dev->identifier;
+       local->type_name = XI_TOUCHSCREEN;
+       local->device_control = device_control;
+       local->read_input = read_input;
+       local->private = mt;
+       local->flags = XI86_POINTER_CAPABLE |
+               XI86_SEND_DRAG_EVENTS;
+
+       local->conf_idev = dev;
+
+       xf86CollectInputOptions(local, NULL, NULL);
+       //xf86OptionListReport(local->options);
+       xf86ProcessCommonOptions(local, local->options);
+
+
+       mt->swap_xy = xf86SetBoolOption(local->options, "SwapAxes", FALSE);
+       mt->invert_x = xf86SetBoolOption(local->options, "InvertX", FALSE);
+       mt->invert_y = xf86SetBoolOption(local->options, "InvertY", FALSE);
+
+       local->flags |= XI86_CONFIGURED;
+
+error:
+       return local;
+}
+
+static void uninit(InputDriverPtr drv, InputInfoPtr local, int flags)
+{
+       free(local->private);
+       local->private = NULL;
+       xf86DeleteInput(local, 0);
+}
+
+static InputDriverRec MTEV = {
+       .driverVersion = 1,
+       .driverName = "mtev",
+       .Identify = NULL,
+       .PreInit = preinit,
+       .UnInit = uninit,
+       .module = NULL,
+       .refCount = 0
+};
+
+static XF86ModuleVersionInfo VERSION = {
+       .modname = "mtev",
+       .vendor = "Nokia",
+       ._modinfo1_ = MODINFOSTRING1,
+       ._modinfo2_ = MODINFOSTRING2,
+       .xf86version = XORG_VERSION_CURRENT,
+       .majorversion = 0,
+       .minorversion = 1,
+       .patchlevel = 12,
+       .abiclass = ABI_CLASS_XINPUT,
+       .abiversion = ABI_XINPUT_VERSION,
+       .moduleclass = MOD_CLASS_XINPUT,
+       .checksum = {0, 0, 0, 0}
+};
+
+static pointer setup(pointer module, pointer options, int *errmaj, int *errmin)
+{
+       xf86AddInputDriver(&MTEV, module, 0);
+       return module;
+}
+
+XF86ModuleData mtevModuleData = {
+       .vers = &VERSION,
+       .setup = &setup,
+       .teardown = NULL
+};
diff --git a/xf86-input-mtev.spec b/xf86-input-mtev.spec
new file mode 100644 (file)
index 0000000..18828da
--- /dev/null
@@ -0,0 +1,77 @@
+# 
+# Do NOT Edit the Auto-generated Part!
+# Generated by: spectacle version 0.19
+# 
+# >> macros
+# << macros
+
+Name:       xf86-input-mtev
+Summary:    Multitouch input driver for Xserver
+Version:    0.1.13
+Release:    1
+Group:      System/X Hardware Support
+License:    GPLv2
+URL:        http://gitorious.org/xorg-next/xf86-input-mtev
+Source0:    %{name}-%{version}.tar.gz
+Source100:  xf86-input-mtev.yaml
+BuildRequires:  pkgconfig(xorg-server)
+BuildRequires:  pkgconfig(xkbfile)
+BuildRequires:  pkgconfig(xproto)
+BuildRequires:  pkgconfig(inputproto)
+BuildRequires:  pkgconfig(xrandr)
+BuildRequires:  pkgconfig(randrproto)
+BuildRequires:  pkgconfig(xextproto)
+BuildRequires:  pkgconfig(mtdev)
+
+
+%description
+- xf86-input-mtev - This package is a multitouch Xorg input driver
+supporting MultiTouch protocol
+
+
+
+
+%prep
+%setup -q -n %{name}-%{version}
+
+# >> setup
+# << setup
+
+%build
+# >> build pre
+# << build pre
+
+
+make %{?jobs:-j%jobs}
+
+# >> build post
+# << build post
+%install
+rm -rf %{buildroot}
+# >> install pre
+# << install pre
+%make_install 
+
+# >> install post
+# << install post
+
+
+
+
+
+
+%files
+%defattr(-,root,root,-)
+/usr/lib/xorg/modules/input/mtev.so
+# >> files
+# << files
+
+%changelog
+ * Mon Dec 6 2010 James Ketrenos <jketreno@linux.intel.com> 0.1.13
+ - Adapted to use libmtdev to support kernel protocol A and B
+ * Wed Oct 27 2010 Mika Kuoppala <mika.kuoppala@nokia.com> 0.1.12
+ -  Send motion events before button down
+ * Tue Oct 26 2010 Mika Kuoppala <mika.kuoppala@nokia.com> 0.1.11
+ - Added orientation config options: SwapAxes, InvertX, InvertY
+ * Thu Sep 16 2010 Mika Kuoppala <mika.kuoppala@nokia.com> 0.1.10
+ - First rpm release
diff --git a/xf86-input-mtev.yaml b/xf86-input-mtev.yaml
new file mode 100644 (file)
index 0000000..6797b36
--- /dev/null
@@ -0,0 +1,28 @@
+Name: xf86-input-mtev
+Summary: Multitouch input driver for Xserver
+Version: 0.1.13
+Release: 1
+Group: System/X Hardware Support
+License: GPLv2
+URL: http://gitorious.org/xorg-next/xf86-input-mtev
+Description: |
+    - xf86-input-mtev - This package is a multitouch Xorg input driver
+    supporting MultiTouch protocol
+
+Sources:
+    - "%{name}-%{version}.tar.gz"
+
+PkgConfigBR:
+    - xorg-server
+    - xkbfile
+    - xproto
+    - inputproto
+    - xrandr
+    - randrproto
+    - xextproto
+    - mtdev
+
+Configure: none
+
+Files:
+    - /usr/lib/xorg/modules/input/mtev.so