├── .ci └── check-abi ├── .git-blame-ignore-revs ├── .github └── workflows │ └── main.yml ├── .gitignore ├── .gitlab-ci.yml ├── .gitlab-ci ├── libfprint-image-variables.yaml ├── libfprint-templates.yaml └── scan-build ├── AUTHORS ├── COPYING ├── HACKING.md ├── INSTALL ├── MAINTAINERS ├── NEWS ├── README.md ├── THANKS ├── code-of-conduct.md ├── data ├── autosuspend.hwdb └── meson.build ├── demo ├── gtk-libfprint-test.c ├── gtk-libfprint-test.gresource.xml ├── gtk-libfprint-test.ui ├── meson.build ├── org.freedesktop.libfprint.Demo.appdata.xml ├── org.freedesktop.libfprint.Demo.desktop ├── org.freedesktop.libfprint.Demo.json └── org.freedesktop.libfprint.Demo.png ├── doc ├── advanced-topics.xml ├── getting-started.xml ├── intro.xml ├── libfprint-2-sections.txt ├── libfprint-2.types ├── libfprint-docs.xml ├── libfprint-sections.txt-new-manual ├── meson.build └── xml │ ├── gtkdocentities.ent.in │ └── meson.build ├── examples ├── cpp-test.cpp ├── enroll.c ├── identify.c ├── img-capture.c ├── manage-prints.c ├── meson.build ├── prints │ ├── README │ ├── arch.jpg │ ├── arch.png │ ├── loop-right.jpg │ ├── loop-right.png │ ├── tented_arch.jpg │ ├── tented_arch.png │ ├── whorl.jpg │ └── whorl.png ├── sendvirtimg.py ├── storage.c ├── storage.h ├── utilities.c ├── utilities.h └── verify.c ├── libfprint ├── drivers │ ├── aes1610.c │ ├── aes1660.c │ ├── aes1660.h │ ├── aes2501.c │ ├── aes2501.h │ ├── aes2550.c │ ├── aes2550.h │ ├── aes2660.c │ ├── aes2660.h │ ├── aes3500.c │ ├── aes3k.c │ ├── aes3k.h │ ├── aes4000.c │ ├── aeslib.c │ ├── aeslib.h │ ├── aesx660.c │ ├── aesx660.h │ ├── egis0570.c │ ├── egis0570.h │ ├── elan.c │ ├── elan.h │ ├── elanmoc │ │ ├── elanmoc.c │ │ └── elanmoc.h │ ├── elanspi.c │ ├── elanspi.h │ ├── etes603.c │ ├── fpcmoc │ │ ├── fpc.c │ │ └── fpc.h │ ├── goodixmoc │ │ ├── goodix.c │ │ ├── goodix.h │ │ ├── goodix_proto.c │ │ └── goodix_proto.h │ ├── nb1010.c │ ├── synaptics │ │ ├── bmkt.h │ │ ├── bmkt_message.c │ │ ├── bmkt_message.h │ │ ├── bmkt_response.h │ │ ├── sensor.h │ │ ├── synaptics.c │ │ └── synaptics.h │ ├── upek_proto.c │ ├── upek_proto.h │ ├── upeksonly.c │ ├── upeksonly.h │ ├── upektc.c │ ├── upektc.h │ ├── upektc_img.c │ ├── upektc_img.h │ ├── upekts.c │ ├── uru4000.c │ ├── vcom5s.c │ ├── vfs0050.c │ ├── vfs0050.h │ ├── vfs101.c │ ├── vfs301.c │ ├── vfs301.h │ ├── vfs301_proto.c │ ├── vfs301_proto_fragments.h │ ├── vfs5011.c │ ├── vfs5011_proto.h │ ├── vfs7552.c │ ├── vfs7552_proto.h │ ├── virtual-device-listener.c │ ├── virtual-device-private.h │ ├── virtual-device-storage.c │ ├── virtual-device.c │ └── virtual-image.c ├── drivers_api.h ├── empty_file ├── fp-context.c ├── fp-context.h ├── fp-device-private.h ├── fp-device.c ├── fp-device.h ├── fp-image-device-private.h ├── fp-image-device.c ├── fp-image-device.h ├── fp-image.c ├── fp-image.h ├── fp-print-private.h ├── fp-print.c ├── fp-print.h ├── fpi-assembling.c ├── fpi-assembling.h ├── fpi-byte-reader.c ├── fpi-byte-reader.h ├── fpi-byte-utils.h ├── fpi-byte-writer.c ├── fpi-byte-writer.h ├── fpi-compat.h ├── fpi-context.h ├── fpi-device.c ├── fpi-device.h ├── fpi-image-device.c ├── fpi-image-device.h ├── fpi-image.c ├── fpi-image.h ├── fpi-log.h ├── fpi-minutiae.h ├── fpi-print.c ├── fpi-print.h ├── fpi-spi-transfer.c ├── fpi-spi-transfer.h ├── fpi-ssm.c ├── fpi-ssm.h ├── fpi-usb-transfer.c ├── fpi-usb-transfer.h ├── fprint-list-supported-devices.c ├── fprint-list-udev-hwdb.c ├── fprint-list-udev-rules.c ├── fprint.h ├── libfprint.ver ├── meson.build └── nbis │ ├── bozorth3 │ ├── bozorth3.c │ ├── bz_alloc.c │ ├── bz_drvrs.c │ ├── bz_gbls.c │ ├── bz_io.c │ └── bz_sort.c │ ├── fix-musl-build.patch │ ├── fix-scan-build-reports.patch │ ├── glib-mem-warning.patch │ ├── glib-memory.cocci │ ├── include │ ├── bozorth.h │ ├── bz_array.h │ ├── defs.h │ ├── lfs.h │ ├── log.h │ ├── meson.build │ ├── morph.h │ ├── mytime.h │ └── sunrast.h │ ├── lfs.h.patch │ ├── libfprint-include │ ├── meson.build │ ├── nbis-helpers.h │ └── nbis.h │ ├── mindtct │ ├── binar.c │ ├── block.c │ ├── chaincod.c │ ├── contour.c │ ├── detect.c │ ├── dft.c │ ├── free.c │ ├── getmin.c │ ├── globals.c │ ├── imgutil.c │ ├── init.c │ ├── line.c │ ├── link.c │ ├── log.c │ ├── loop.c │ ├── maps.c │ ├── matchpat.c │ ├── minutia.c │ ├── morph.c │ ├── quality.c │ ├── remove.c │ ├── ridges.c │ ├── shape.c │ ├── sort.c │ ├── util.c │ └── xytreps.c │ ├── remove-function.lua │ ├── remove-global-y.cocci │ ├── remove-perimeter-pts.patch │ └── update-from-nbis.sh ├── meson.build ├── meson_options.txt ├── nfpm_arch_sample.yaml ├── nfpm_deb_sample.yaml ├── nfpm_rpm_sample.yaml ├── scripts ├── uncrustify.cfg └── uncrustify.sh └── tests ├── README.md ├── aes2501 ├── capture.pcapng ├── capture.png └── device ├── aes3500 ├── capture.ioctl ├── capture.png └── device ├── capture.py ├── create-driver-test.py.in ├── egis0570 ├── capture.pcapng ├── capture.png └── device ├── elan-cobo ├── capture.pcapng ├── capture.png └── device ├── elan ├── capture.ioctl ├── capture.ioctl-recording ├── capture.png └── device ├── elanmoc ├── custom.pcapng ├── custom.py └── device ├── elanspi ├── capture.ioctl ├── capture.png ├── device-hidraw └── device-spi ├── fpcmoc ├── custom.pcapng ├── custom.py └── device ├── goodixmoc ├── custom.pcapng ├── custom.py └── device ├── hwdb-check-unsupported.py ├── libfprint.supp ├── meson.build ├── nb1010 ├── capture.ioctl ├── capture.png └── device ├── synaptics ├── custom.pcapng ├── custom.py └── device ├── test-device-fake.c ├── test-device-fake.h ├── test-fp-context.c ├── test-fp-device.c ├── test-fpi-assembling.c ├── test-fpi-device.c ├── test-fpi-ssm.c ├── test-generated-hwdb.sh ├── test-utils.c ├── test-utils.h ├── umockdev-test.py ├── unittest_inspector.py ├── upektc_img ├── capture.pcapng ├── capture.png └── device ├── uru4000-4500 ├── capture.pcapng ├── capture.png └── device ├── uru4000-msv2 ├── capture.pcapng ├── capture.png └── device ├── valgrind-python.supp ├── vfs0050 ├── capture-recorded.ioctl ├── capture.ioctl ├── capture.png └── device ├── vfs301 ├── capture-recorded.ioctl ├── capture.ioctl ├── capture.png └── device ├── vfs5011 ├── capture.ioctl ├── capture.png └── device ├── vfs7552 ├── capture.ioctl ├── capture.png └── device ├── virtual-device.py └── virtual-image.py /.ci/check-abi: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | 4 | import argparse 5 | import contextlib 6 | import os 7 | import shutil 8 | import subprocess 9 | import sys 10 | 11 | 12 | def format_title(title): 13 | box = { 14 | 'tl': '╔', 'tr': '╗', 'bl': '╚', 'br': '╝', 'h': '═', 'v': '║', 15 | } 16 | hline = box['h'] * (len(title) + 2) 17 | 18 | return '\n'.join([ 19 | f"{box['tl']}{hline}{box['tr']}", 20 | f"{box['v']} {title} {box['v']}", 21 | f"{box['bl']}{hline}{box['br']}", 22 | ]) 23 | 24 | 25 | def rm_rf(path): 26 | try: 27 | shutil.rmtree(path) 28 | except FileNotFoundError: 29 | pass 30 | 31 | 32 | def sanitize_path(name): 33 | return name.replace('/', '-') 34 | 35 | 36 | def get_current_revision(): 37 | revision = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], 38 | encoding='utf-8').strip() 39 | 40 | if revision == 'HEAD': 41 | # This is a detached HEAD, get the commit hash 42 | revision = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip().decode('utf-8') 43 | 44 | return revision 45 | 46 | 47 | @contextlib.contextmanager 48 | def checkout_git_revision(revision): 49 | current_revision = get_current_revision() 50 | subprocess.check_call(['git', 'checkout', '-q', revision]) 51 | 52 | try: 53 | yield 54 | finally: 55 | subprocess.check_call(['git', 'checkout', '-q', current_revision]) 56 | 57 | 58 | def build_install(revision): 59 | build_dir = '_build' 60 | dest_dir = os.path.abspath(sanitize_path(revision)) 61 | print(format_title(f'# Building and installing {revision} in {dest_dir}'), 62 | end='\n\n', flush=True) 63 | 64 | with checkout_git_revision(revision): 65 | rm_rf(build_dir) 66 | rm_rf(revision) 67 | 68 | subprocess.check_call(['meson', build_dir, 69 | '--prefix=/usr', '--libdir=lib', 70 | '-Dx11-examples=false', '-Ddoc=false', '-Dgtk-examples=false']) 71 | subprocess.check_call(['ninja', '-v', '-C', build_dir]) 72 | subprocess.check_call(['ninja', '-v', '-C', build_dir, 'install'], 73 | env={'DESTDIR': dest_dir}) 74 | 75 | return dest_dir 76 | 77 | 78 | def compare(old_tree, new_tree): 79 | print(format_title(f'# Comparing the two ABIs'), end='\n\n', flush=True) 80 | 81 | old_headers = os.path.join(old_tree, 'usr', 'include') 82 | old_lib = os.path.join(old_tree, 'usr', 'lib', 'libfprint.so') 83 | 84 | new_headers = os.path.join(new_tree, 'usr', 'include') 85 | new_lib = os.path.join(new_tree, 'usr', 'lib', 'libfprint.so') 86 | 87 | subprocess.check_call([ 88 | 'abidiff', '--headers-dir1', old_headers, '--headers-dir2', new_headers, 89 | '--drop-private-types', '--fail-no-debug-info', '--no-added-syms', old_lib, new_lib]) 90 | 91 | 92 | if __name__ == '__main__': 93 | parser = argparse.ArgumentParser() 94 | 95 | parser.add_argument('old', help='the previous revision, considered the reference') 96 | parser.add_argument('new', help='the new revision, to compare to the reference') 97 | 98 | args = parser.parse_args() 99 | 100 | if args.old == args.new: 101 | print("Let's not waste time comparing something to itself") 102 | sys.exit(0) 103 | 104 | old_tree = build_install(args.old) 105 | new_tree = build_install(args.new) 106 | 107 | try: 108 | compare(old_tree, new_tree) 109 | 110 | except Exception: 111 | sys.exit(1) 112 | 113 | print(f'Hurray! {args.old} and {args.new} are ABI-compatible!') 114 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # The commits that did automated reformatting. You can ignore them 2 | # during git-blame with `--ignore-rev` or `--ignore-revs-file`. 3 | # 4 | # $ git config --add 'blame.ignoreRevsFile' '.git-blame-ignore-revs' 5 | # 6 | 7 | d1fb1e26f3b79e54febc94496c1184763cf2af3d 8 | e4f9935706be4c0e3253afe251c182019ff7ccef 9 | 65e602d8c72baa7020efb62d10bf28e621feb05d 10 | 4115ae7ced77d392ee11ea55212206d9404356f0 11 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build Linux packages 2 | on: 3 | workflow_dispatch: 4 | push: 5 | branches: 6 | - master 7 | - goodixtls 8 | - sigfm 9 | 10 | jobs: 11 | build: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: nicksnell/action-reset-repo@master 15 | with: 16 | reset_branch: buildpackage 17 | base_branch: master 18 | github_token: ${{ github.token }} 19 | - name: Merge goodixtls -> buildpackage 20 | uses: devmasx/merge-branch@master 21 | with: 22 | type: now 23 | from_branch: goodixtls 24 | target_branch: buildpackage 25 | github_token: ${{ github.token }} 26 | - name: Merge sigfm -> buildpackage 27 | uses: devmasx/merge-branch@master 28 | with: 29 | type: now 30 | from_branch: sigfm 31 | target_branch: buildpackage 32 | github_token: ${{ github.token }} 33 | - name: Chown user 34 | run: | 35 | sudo chown -R $USER:$USER $GITHUB_WORKSPACE 36 | - uses: actions/checkout@v3 37 | with: 38 | ref: buildpackage 39 | - uses: actions/setup-python@v1 40 | - name: Install dependencies 41 | run: sudo apt-get install -y libgusb-dev libgirepository1.0-dev libnss3-dev libgudev-1.0-dev gtk-doc-tools libopencv-dev doctest-dev 42 | - uses: BSFishy/meson-build@v1.0.3 43 | with: 44 | action: build 45 | setup-options: --prefix /usr/ --buildtype=release 46 | options: --verbose 47 | meson-version: 0.63.3 48 | ninja-version: 1.10.2 49 | - name: Install nFPM 50 | run: echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list && sudo apt update && sudo apt install nfpm 51 | - name: Prepare nFPM DEB config 52 | run: cd /home/runner/work/libfprint/libfprint && cp nfpm_deb_sample.yaml nfpm_deb.yaml && sed -i "s/COMMITID/$(git rev-parse --short HEAD)/g" nfpm_deb.yaml && mkdir ./output && cd /home/runner/work/libfprint/libfprint/build && sed -i "s/LIBVERSION/$(meson introspect --projectinfo | jq -r '.version')/g" /home/runner/work/libfprint/libfprint/nfpm_deb.yaml 53 | - name: Prepare nFPM RPM config 54 | run: cd /home/runner/work/libfprint/libfprint && cp nfpm_rpm_sample.yaml nfpm_rpm.yaml && sed -i "s/COMMITID/$(git rev-parse --short HEAD)/g" nfpm_rpm.yaml && cd /home/runner/work/libfprint/libfprint/build && sed -i "s/LIBVERSION/$(meson introspect --projectinfo | jq -r '.version')/g" /home/runner/work/libfprint/libfprint/nfpm_rpm.yaml 55 | - name: Prepare nFPM Arch config 56 | run: cd /home/runner/work/libfprint/libfprint && cp nfpm_arch_sample.yaml nfpm_arch.yaml && sed -i "s/COMMITID/$(git rev-parse --short HEAD)/g" nfpm_arch.yaml && cd /home/runner/work/libfprint/libfprint/build && sed -i "s/LIBVERSION/$(meson introspect --projectinfo | jq -r '.version')/g" /home/runner/work/libfprint/libfprint/nfpm_arch.yaml 57 | - name: Generating DEB package 58 | run: nfpm pkg --packager deb --config ./nfpm_deb.yaml --target ./output/ 59 | - name: Generating RPM package 60 | run: nfpm pkg --packager rpm --config ./nfpm_rpm.yaml --target ./output/ 61 | - name: Generating ArchLinux package 62 | run: nfpm pkg --packager archlinux --config ./nfpm_arch.yaml --target ./output/ 63 | - uses: actions/upload-artifact@v3 64 | with: 65 | name: meson-build-artifacts 66 | path: /home/runner/work/libfprint/libfprint/build 67 | - uses: actions/upload-artifact@v3 68 | with: 69 | name: deb-rpm-arch-packages 70 | path: /home/runner/work/libfprint/libfprint/output 71 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.swp 3 | _build 4 | -------------------------------------------------------------------------------- /.gitlab-ci/libfprint-image-variables.yaml: -------------------------------------------------------------------------------- 1 | variables: 2 | LIBFPRINT_IMAGE_TAG: v2 3 | -------------------------------------------------------------------------------- /.gitlab-ci/libfprint-templates.yaml: -------------------------------------------------------------------------------- 1 | # Bump image version on .gitlab-ci/libfprint-image-variables.yaml to trigger 2 | # a rebuild on changes to this file 3 | 4 | .libfprint_common_variables: 5 | LIBFPRINT_DEPENDENCIES: 6 | doxygen 7 | dnf-plugins-core 8 | flatpak-builder 9 | gcc 10 | gcc-c++ 11 | gcovr 12 | git 13 | glib2-devel 14 | glibc-devel 15 | gobject-introspection-devel 16 | gtk-doc 17 | gtk3-devel 18 | libabigail 19 | libgusb-devel 20 | libgudev-devel 21 | libX11-devel 22 | libXv-devel 23 | meson 24 | nss-devel 25 | pixman-devel 26 | python3-cairo 27 | python3-gobject 28 | systemd 29 | umockdev 30 | uncrustify 31 | valgrind 32 | clang-analyzer 33 | diffutils 34 | 35 | LIBFPRINT_EXEC: | 36 | dnf debuginfo-install -y \ 37 | glib2 \ 38 | glibc \ 39 | libgusb \ 40 | libusb \ 41 | nss \ 42 | pixman 43 | 44 | git clone https://github.com/martinpitt/umockdev.git && \ 45 | cd umockdev && \ 46 | meson _build --prefix=/usr && \ 47 | ninja -C _build && ninja -C _build install 48 | -------------------------------------------------------------------------------- /.gitlab-ci/scan-build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # This wrapper just disables the malloc checker 4 | exec /usr/bin/scan-build --status-bugs -disable-checker unix.Malloc "$@" -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Copyright (C) 2007 Daniel Drake 2 | Copyright (C) 2006-2007 Timo Hoenig 3 | Copyright (C) 2006 Pavel Machek 4 | Copyright (C) 1999 Erik Walthinsen 5 | Copyright (C) 2004,2006 Thomas Vander Stichele 6 | Copyright (C) 2007 Cyrille Bagard 7 | Copyright (C) 2007-2008,2012 Vasily Khoruzhick 8 | Copyright (C) 2007 Jan-Michael Brummer 9 | Copyright (C) 2007 Anthony Bretaudeau 10 | Copyright (C) 2010 Hugo Grostabussiat 11 | Copyright (C) 2012 Timo Teräs 12 | -------------------------------------------------------------------------------- /HACKING.md: -------------------------------------------------------------------------------- 1 | # Contributing to libfprint 2 | 3 | ## GLib 4 | 5 | Although the library uses GLib internally, libfprint is designed to provide 6 | a completely neutral interface to its application users. So, the public 7 | APIs should never return GLib data types. 8 | 9 | ## License clarification 10 | 11 | Although this library's license could allow for shims that hook up into 12 | proprietary blobs to add driver support for some unsupported devices, the 13 | intent of the original authors, and of current maintainers of the library, 14 | was for this license to allow _integration into_ proprietary stacks, not 15 | _integration of_ proprietary code in the library. 16 | 17 | As such, no code to integrate proprietary drivers will be accepted in libfprint 18 | upstream. Proprietary drivers would make it impossible to debug problems in 19 | libfprint, as we wouldn't know what the proprietary driver does behind the 20 | library's back. The closed source nature of drivers is usually used to hide 21 | parts of the hardware setup, such as encryption keys, or protocols, in order 22 | to protect the hardware's integrity. Unfortunately, this is only [security through 23 | obscurity](https://en.wikipedia.org/wiki/Security_through_obscurity). 24 | 25 | We however encourage potential contributors to take advantage of libfprint's 26 | source availability to create such shims to make it easier to reverse-engineer 27 | proprietary drivers in order to create new free software drivers, to the extent 28 | permitted by local laws. 29 | 30 | ## Two-faced-ness 31 | 32 | Like any decent library, this one is designed to provide a stable and 33 | documented API to its users: applications. Clear distinction is made between 34 | data available internally in the library, and data/functions available to 35 | the applications. 36 | 37 | This library is confused a little by the fact that there is another 'interface' 38 | at hand: the internal interface provided to drivers. So, we effectively end 39 | up with 2 APIs: 40 | 41 | 1. The [external-facing API for applications](libfprint/fprint.h) 42 | 2. The [internal API for fingerprint drivers](libfprint/drivers_api.h) 43 | 44 | Non-static functions which are intended for internal use only are prepended 45 | with the "fpi_" prefix. 46 | 47 | ## Documentation 48 | 49 | All additions of public API functions must be accompanied with gtk-doc 50 | comments. 51 | 52 | All changes which potentially change the behaviour of the public API must 53 | be reflected by updating the appropriate gtk-doc comments. 54 | 55 | 56 | ## Contributing 57 | 58 | Patches should be sent as merge requests to the gitlab page: 59 | https://gitlab.freedesktop.org/libfprint/libfprint/merge_requests 60 | 61 | Drivers are not usually written by libfprint developers, but when they 62 | are, we require: 63 | - 3 stand-alone devices. Not in a laptop or another embedded device, as 64 | space is scarce, unless the device has special integration with that 65 | hardware. 66 | - specifications of the protocol. 67 | 68 | If you are an end-user, you can file a feature request with the "Driver Request" 69 | tag on [libfprint's issue page](https://gitlab.freedesktop.org/libfprint/libfprint/issues?scope=all&utf8=%E2%9C%93&state=opened&label_name[]=Driver%20Request), 70 | or subscribe to an existing feature request there. 71 | 72 | If you are an enterprising hacker, please file a new merge request with 73 | the driver patches integrated. 74 | -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | libfprint uses the Meson build system. See 2 | http://mesonbuild.com/Quick-guide.html for details on how to 3 | compile libfprint. 4 | 5 | The "meson configure" command will give you a list of available 6 | command-line options. 7 | -------------------------------------------------------------------------------- /MAINTAINERS: -------------------------------------------------------------------------------- 1 | Current maintainers of libfprint are: 2 | 3 | * Benjamin Berg 4 | * Marco Trevisan (Treviño) 5 | 6 | Many drivers are not actively maintained and may not be fully functional. 7 | We are happy to receive contributions, but the support we can give is 8 | limitted unfortunately. For many drivers we may not even have test devices. 9 | 10 | Maintained drivers are: 11 | * synaptics: 12 | Contributed and maintained by Synaptics Inc. 13 | Contact: Vincent Huang 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | # LibFPrint 6 | 7 | This is an experimental libfprint driver implementation for Goodix drivers. 8 | 9 | Currently in the works: 10 | - 27c6x5110 (80x64 resolution) 11 | 12 | *LibFPrint is part of the **[FPrint][Website]** project.* 13 | 14 |
15 | 16 | [![Button Website]][Website] 17 | [![Button Documentation]][Documentation] 18 | 19 | [![Button Supported]][Supported] 20 | [![Button Unsupported]][Unsupported] 21 | 22 | [![Button Contribute]][Contribute] 23 | [![Button Contributors]][Contributors] 24 | 25 |
26 | 27 | ## History 28 | 29 | **LibFPrint** was originally developed as part of an 30 | academic project at the **[University Of Manchester]**. 31 | 32 | It aimed to hide the differences between consumer 33 | fingerprint scanners and provide a single uniform 34 | API to application developers. 35 | 36 | ## Goal 37 | 38 | The ultimate goal of the **FPrint** project is to make 39 | fingerprint scanners widely and easily usable under 40 | common Linux environments. 41 | 42 | ## License 43 | 44 | `Section 6` of the license states that for compiled works that use 45 | this library, such works must include **LibFPrint** copyright notices 46 | alongside the copyright notices for the other parts of the work. 47 | 48 | **LibFPrint** includes code from **NIST's** **[NBIS]** software distribution. 49 | 50 | We include **Bozorth3** from the **[US Export Controlled]** 51 | distribution, which we have determined to be fine 52 | being shipped in an open source project. 53 | 54 |
55 | 56 |
57 | 58 | [![Badge License]][License] 59 | 60 |
61 | 62 | 63 | 64 | 65 | [Documentation]: https://fprint.freedesktop.org/libfprint-dev/ 66 | [Contributors]: https://gitlab.freedesktop.org/libfprint/libfprint/-/graphs/master 67 | [Unsupported]: https://gitlab.freedesktop.org/libfprint/wiki/-/wikis/Unsupported-Devices 68 | [Supported]: https://fprint.freedesktop.org/supported-devices.html 69 | [Website]: https://fprint.freedesktop.org/ 70 | 71 | [Contribute]: ./HACKING.md 72 | [License]: ./COPYING 73 | 74 | [University Of Manchester]: https://www.manchester.ac.uk/ 75 | [US Export Controlled]: https://fprint.freedesktop.org/us-export-control.html 76 | [NBIS]: http://fingerprint.nist.gov/NBIS/index.html 77 | 78 | 79 | 80 | 81 | [Badge License]: https://img.shields.io/badge/License-LGPL2.1-015d93.svg?style=for-the-badge&labelColor=blue 82 | 83 | 84 | 85 | 86 | [Button Documentation]: https://img.shields.io/badge/Documentation-04ACE6?style=for-the-badge&logoColor=white&logo=BookStack 87 | [Button Contributors]: https://img.shields.io/badge/Contributors-FF4F8B?style=for-the-badge&logoColor=white&logo=ActiGraph 88 | [Button Unsupported]: https://img.shields.io/badge/Unsupported_Devices-EF2D5E?style=for-the-badge&logoColor=white&logo=AdBlock 89 | [Button Contribute]: https://img.shields.io/badge/Contribute-66459B?style=for-the-badge&logoColor=white&logo=Git 90 | [Button Supported]: https://img.shields.io/badge/Supported_Devices-428813?style=for-the-badge&logoColor=white&logo=AdGuard 91 | [Button Website]: https://img.shields.io/badge/Homepage-3B80AE?style=for-the-badge&logoColor=white&logo=freedesktopDotOrg 92 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Tony Vroon - hardware donations 2 | Gerrie Mansur from Security Database BV (http://www.securitydatabase.net/) - hardware donations 3 | Joaquin Custodio - hardware donations 4 | TimeTrex (http://www.timetrex.com/) - hardware donations 5 | Craig Watson (NIST) 6 | James Vasile (SFLC) 7 | Toby Howard (University of Manchester) 8 | Seemant Kulleen 9 | Pavel Herrman 10 | Bastien Nocera 11 | Greg Kerr and Martin Konecny from AuthenTec Inc - hardware donations (AES2550 device), datasheets for AES2550 and AES2810 12 | -------------------------------------------------------------------------------- /code-of-conduct.md: -------------------------------------------------------------------------------- 1 | This project and its community follow the [Freedesktop.org code of conduct] 2 | 3 | [Freedesktop.org code of conduct]: https://www.freedesktop.org/wiki/CodeOfConduct/ 4 | -------------------------------------------------------------------------------- /data/meson.build: -------------------------------------------------------------------------------- 1 | if udev_hwdb_dir != '' 2 | # This file has to be updated using 3 | # ninja -C libfprint/sync-udev-hwdb 4 | # Note that the unsupported device list needs to be manually synced from 5 | # the wiki. See comment in libfprint/fprint-list-uev-hwdb.c 6 | 7 | install_data('autosuspend.hwdb', 8 | rename: '60-autosuspend-@0@.hwdb'.format(versioned_libname), 9 | install_dir: udev_hwdb_dir, 10 | ) 11 | endif 12 | -------------------------------------------------------------------------------- /demo/gtk-libfprint-test.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | gtk-libfprint-test.ui 5 | 6 | 7 | -------------------------------------------------------------------------------- /demo/meson.build: -------------------------------------------------------------------------------- 1 | gtk_test_resources = gnome.compile_resources('gtk-test-resources', 2 | 'gtk-libfprint-test.gresource.xml', 3 | source_dir : '.', 4 | c_name : 'gtk_test') 5 | 6 | prefix = get_option('prefix') 7 | bindir = join_paths(prefix, get_option('bindir')) 8 | datadir = join_paths(prefix, get_option('datadir')) 9 | 10 | executable('gtk-libfprint-test', 11 | [ 'gtk-libfprint-test.c', gtk_test_resources ], 12 | dependencies: [ 13 | gtk_dep, 14 | libfprint_dep, 15 | ], 16 | c_args: '-DPACKAGE_VERSION="' + meson.project_version() + '"', 17 | install: true, 18 | install_dir: bindir) 19 | 20 | appdata = 'org.freedesktop.libfprint.Demo.appdata.xml' 21 | install_data(appdata, 22 | install_dir: join_paths(datadir, 'metainfo')) 23 | 24 | desktop = 'org.freedesktop.libfprint.Demo.desktop' 25 | install_data(desktop, 26 | install_dir: join_paths(datadir, 'applications')) 27 | 28 | icon = 'org.freedesktop.libfprint.Demo.png' 29 | install_data(icon, 30 | install_dir: join_paths(datadir, 'icons')) 31 | -------------------------------------------------------------------------------- /demo/org.freedesktop.libfprint.Demo.appdata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.freedesktop.libfprint.Demo.desktop 4 | Fingerprint Reader Demo 5 | Test fingerprint readers 6 | CC0-1.0 7 | LGPL-2.1+ 8 | 9 |

10 | Fingerprint Reader Demo is a test application for the libfprint 11 | fingerprint reader library. Its purpose is to test drivers, new and old, 12 | in a sandbox, to make sure that the drivers and associated functions 13 | work correctly. 14 |

15 |

16 | Fingerprint Reader Demo does not modify the system, or replace integration 17 | in desktop environments. 18 |

19 |
20 | https://fprint.freedesktop.org 21 | 22 | https://git.gnome.org/browse/totem/plain/data/appdata/ss-main.png 23 | https://git.gnome.org/browse/totem/plain/data/appdata/ss-music-playlist.png 24 | 25 | hadess@hadess.net 26 | 27 | libfprint 28 |
29 | -------------------------------------------------------------------------------- /demo/org.freedesktop.libfprint.Demo.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=Fingerprint Reader Demo 3 | Comment=Test fingerprint readers 4 | Keywords=finger;print;fingerprint;fprint;demo;driver;reader; 5 | Exec=gtk-libfprint-test 6 | Icon=org.freedesktop.libfprint.Demo 7 | Terminal=false 8 | Type=Application 9 | Categories=GTK;GNOME;Development;System; 10 | StartupNotify=true 11 | -------------------------------------------------------------------------------- /demo/org.freedesktop.libfprint.Demo.json: -------------------------------------------------------------------------------- 1 | { 2 | "app-id": "org.freedesktop.libfprint.Demo", 3 | "runtime": "org.gnome.Platform", 4 | "runtime-version": "42", 5 | "sdk": "org.gnome.Sdk", 6 | "command": "gtk-libfprint-test", 7 | "finish-args": [ 8 | /* X11 + XShm access */ 9 | "--share=ipc", "--socket=fallback-x11", 10 | /* Wayland access */ 11 | "--socket=wayland", 12 | /* OpenGL access */ 13 | "--device=dri", 14 | /* USB access */ 15 | "--device=all" 16 | ], 17 | "cleanup": [ "/include", "/lib/pkgconfig/" ], 18 | "modules": [ 19 | { 20 | "name": "libusb", 21 | "config-opts": [ "--disable-static" ], 22 | "cleanup": [ 23 | "/lib/*.la", 24 | "/lib/pkgconfig", 25 | "/include" 26 | ], 27 | "sources": [ 28 | { 29 | "type": "archive", 30 | "url": "https://github.com/libusb/libusb/releases/download/v1.0.26/libusb-1.0.26.tar.bz2", 31 | "sha256": "12ce7a61fc9854d1d2a1ffe095f7b5fac19ddba095c259e6067a46500381b5a5" 32 | } 33 | ], 34 | "post-install": [ 35 | "install -Dm644 COPYING /app/share/licenses/libusb/COPYING" 36 | ] 37 | }, 38 | { 39 | "name": "libgusb", 40 | "buildsystem": "meson", 41 | "config-opts": [ "-Dtests=false", "-Dvapi=false", "-Ddocs=false", "-Dintrospection=false" ], 42 | "sources": [ 43 | { 44 | "type": "archive", 45 | "url": "https://github.com/hughsie/libgusb/archive/0.3.0.tar.gz", 46 | "sha256": "b36310f8405d5fd68f6caf4a829f7ab4c627b38fd3d02a139d411fce0f3a49f1" 47 | } 48 | ] 49 | }, 50 | { 51 | "name": "gudev", 52 | "buildsystem": "meson", 53 | "config-opts": [ "-Dtests=disabled", "-Dintrospection=disabled" ], 54 | "sources": [ 55 | { 56 | "type": "archive", 57 | "url": "https://download.gnome.org/sources/libgudev/236/libgudev-236.tar.xz", 58 | "sha256": "e50369d06d594bae615eb7aeb787de304ebaad07a26d1043cef8e9c7ab7c9524" 59 | } 60 | ] 61 | }, 62 | { 63 | "name": "libfprint", 64 | "buildsystem": "meson", 65 | "config-opts": [ "-Dudev_hwdb=disabled", "-Dudev_rules=disabled", "-Dgtk-examples=true", "-Ddrivers=all" ], 66 | "sources": [ 67 | { 68 | "type": "git", 69 | "url": "https://gitlab.freedesktop.org/libfprint/libfprint.git" 70 | } 71 | ] 72 | } 73 | ] 74 | } 75 | -------------------------------------------------------------------------------- /demo/org.freedesktop.libfprint.Demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/demo/org.freedesktop.libfprint.Demo.png -------------------------------------------------------------------------------- /doc/getting-started.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Getting Started 7 | 8 | 9 | libfprint includes several simple functional examples under the examples/ 10 | directory in the libfprint source distribution. Those are good starting 11 | points. 12 | 13 | 14 | 15 | Usually the first thing you want to do is determine which fingerprint 16 | devices are present. This is done using the FpContext object. 17 | 18 | 19 | 20 | Once you have found a device you would like to operate, you should open it. 21 | Refer to device operations. This section also details enrollment, 22 | image capture, and verification. 23 | 24 | 25 | 26 | That should be enough to get you started, but do remember there are 27 | documentation pages on other aspects of libfprint's API (see the modules 28 | page). 29 | 30 | 31 | -------------------------------------------------------------------------------- /doc/intro.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | Introduction 7 | 8 | 9 | libfprint is an open source library to provide access to fingerprint 10 | scanning devices. For more info, see the 11 | libfprint project homepage. 12 | 13 | 14 | 15 | This documentation is aimed at application developers who wish to integrate 16 | fingerprint-related functionality into their software. libfprint has been 17 | designed so that you only have to do this once – by integrating your 18 | software with libfprint, you'll be supporting all the fingerprint readers 19 | that we have got our hands on. As such, the API is rather general (and 20 | therefore hopefully easy to comprehend!), and does its best to hide the 21 | technical details that required to operate the hardware. 22 | 23 | 24 | 25 | This documentation is not aimed at developers wishing to develop and 26 | contribute fingerprint device drivers to libfprint. 27 | 28 | 29 | 30 | Feedback on this API and its associated documentation is appreciated. Was 31 | anything unclear? Does anything seem unreasonably complicated? Is anything 32 | missing? Let us know on the 33 | mailing list. 34 | 35 | 36 | 37 | Enrollment 38 | 39 | 40 | Before you dive into the API, it's worth introducing a couple of concepts. 41 | 42 | 43 | 44 | The process of enrolling a finger is where you effectively scan your 45 | finger for the purposes of teaching the system what your finger looks like. 46 | This means that you scan your fingerprint, then the system processes it and 47 | stores some data about your fingerprint to refer to later. 48 | 49 | 50 | 51 | 52 | Verification 53 | 54 | 55 | Verification is what most people think of when they think about fingerprint 56 | scanning. The process of verification is effectively performing a fresh 57 | fingerprint scan, and then comparing that scan to a finger that was 58 | previously enrolled. 59 | 60 | 61 | 62 | As an example scenario, verification can be used to implement what people 63 | would picture as fingerprint login (i.e. fingerprint replaces password). 64 | For example: 65 | 66 | 67 | 68 | I enroll my fingerprint through some software that trusts I am who I say 69 | I am. This is a prerequisite before I can perform fingerprint-based 70 | login for my account. 71 | 72 | 73 | Some time later, I want to login to my computer. I enter my username, 74 | but instead of prompting me for a password, it asks me to scan my finger. 75 | I scan my finger. 76 | 77 | 78 | The system compares the finger I just scanned to the one that was 79 | enrolled earlier. If the system decides that the fingerprints match, 80 | I am successfully logged in. Otherwise, the system informs me that I am 81 | not authorised to login as that user. 82 | 83 | 84 | 85 | 86 | 87 | Identification 88 | 89 | 90 | Identification is the process of comparing a freshly scanned fingerprint 91 | to a collection of previously enrolled fingerprints. For example, 92 | imagine there are 100 people in an organisation, and they all have enrolled 93 | their fingerprints. One user walks up to a fingerprint scanner and scans 94 | their finger. With no other knowledge of who that user might be, 95 | the system examines their fingerprint, looks in the database, and determines 96 | that the user is user number #61. 97 | 98 | 99 | 100 | In other words, verification might be seen as a one-to-one fingerprint 101 | comparison where you know the identity of the user that you wish to 102 | authenticate, whereas identification is a one-to-many comparison where you 103 | do not know the identity of the user that you wish to authenticate. 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /doc/libfprint-2.types: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | fp_context_get_type 5 | fp_device_get_type 6 | fp_image_device_get_type 7 | fp_image_get_type 8 | fp_print_get_type 9 | -------------------------------------------------------------------------------- /doc/libfprint-docs.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | ]> 7 | 8 | 9 | libfprint Reference Manual 10 | 11 | This document is the API reference for the libfprint library. 12 | 13 | The latest version of libfprint, as well as the latest version of 14 | this API reference, is available online. 15 | 16 | 17 | 18 | 19 | 20 | Library Overview 21 | 22 | 23 | 24 | 25 | 26 | 27 | Library API Documentation 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Writing Drivers 37 | 38 | Device methods for drivers 39 | 40 | 41 | 42 | 43 | 44 | USB, SPI and State Machine helpers 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Image manipulation 53 | 54 | 55 | 56 | 57 | 58 | Print handling 59 | 60 | 61 | 62 | 63 | Listing drivers 64 | 65 | 66 | 67 | 68 | 69 | API Index 70 | 71 | 72 | 73 | Index of deprecated API 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /doc/libfprint-sections.txt-new-manual: -------------------------------------------------------------------------------- 1 | 2 |
3 | fprint.h 4 | context 5 | Device discovery and hotplugging 6 | FP_TYPE_CONTEXT 7 | FpContext 8 | fp_context_new 9 | fp_context_enumerate 10 | fp_context_get_devices 11 |
12 | 13 | 14 |
15 | fprint.h 16 | device 17 | Device 18 | FP_TYPE_DEVICE 19 | FpDevice 20 | FpDeviceType 21 | FpScanType 22 | FpDeviceRetry 23 | FpDeviceError 24 | FP_DEVICE_ERROR 25 | FP_DEVICE_RETRY 26 | fp_device_get_driver 27 | fp_device_get_device_id 28 | fp_device_get_name 29 | fp_device_get_scan_type 30 | 31 | fp_device_open 32 | fp_device_open_finish 33 | fp_device_open_sync 34 | 35 | fp_device_close 36 | fp_device_close_finish 37 | fp_device_close_sync 38 | 39 | fp_device_enroll 40 | fp_device_enroll_finish 41 | fp_device_enroll_sync 42 | 43 | fp_device_identify 44 | fp_device_identify_finish 45 | fp_device_identify_sync 46 | 47 | fp_device_capture 48 | fp_device_capture_finish 49 | fp_device_capture_sync 50 | 51 | fp_device_verify 52 | fp_device_verify_finish 53 | fp_device_verify_sync 54 | 55 | _fp_device_get_cancellable 56 |
57 | 58 | 59 |
60 | fprint.h 61 | print 62 | Fingerprint handling 63 | FpPrint 64 | fp_print_new 65 |
66 | 67 | 68 |
69 | fprint.h 70 | image 71 | Image handling 72 | FP_TYPE_IMAGE 73 | FpImage 74 | fp_image_new 75 | fp_image_detect_minutiae 76 | fp_image_detect_minutiae_finish 77 | fp_image_device_new 78 | fp_image_get_binarized 79 | fp_image_get_data 80 | fp_image_get_height 81 | fp_image_get_minutiae 82 | fp_image_get_ppmm 83 | fp_image_get_width 84 |
85 | 86 | 87 |
88 | internal-image-device 89 | drivers_api.h 90 | Base class for image devices 91 | FpImageDevice 92 | FpImageDeviceClass 93 | FpiImageDeviceState 94 |
95 | 96 |
97 | internal-usb-transfers 98 | drivers_api.h 99 | USB Transfers 100 | FpUsbTransfer 101 | fp_usb_transfer_fill_bulk 102 | fp_usb_transfer_fill_bulk_full 103 | fp_usb_transfer_fill_control 104 | fp_usb_transfer_fill_interrupt 105 | fp_usb_transfer_fill_interrupt_full 106 | fp_usb_transfer_get_type 107 | fp_usb_transfer_new 108 | fp_usb_transfer_ref 109 | fp_usb_transfer_set_short_error 110 | fp_usb_transfer_submit 111 | fp_usb_transfer_submit_sync 112 | fp_usb_transfer_unref 113 | FpUsbTransferCallback 114 | FP_USB_ENDPOINT_IN 115 | FP_USB_ENDPOINT_OUT 116 |
117 | -------------------------------------------------------------------------------- /doc/meson.build: -------------------------------------------------------------------------------- 1 | subdir('xml') 2 | 3 | private_headers = [ 4 | 'config.h', 5 | 'nbis-helpers.h', 6 | 'fprint.h', 7 | 8 | # Subdirectories to ignore 9 | 'drivers', 10 | 'nbis', 11 | ] 12 | 13 | html_images = [ 14 | ] 15 | 16 | content_files = [ 17 | 'intro.xml' 18 | ] 19 | 20 | expand_content_files = content_files 21 | 22 | glib_prefix = dependency('glib-2.0').get_pkgconfig_variable('prefix') 23 | glib_docpath = join_paths(glib_prefix, 'share', 'gtk-doc', 'html') 24 | docpath = join_paths(get_option('datadir'), 'gtk-doc', 'html') 25 | 26 | gnome.gtkdoc(versioned_libname, 27 | main_xml: 'libfprint-docs.xml', 28 | src_dir: join_paths(meson.source_root(), 'libfprint'), 29 | include_directories: include_directories('../libfprint'), 30 | dependencies: libfprint_dep, 31 | content_files: content_files, 32 | expand_content_files: expand_content_files, 33 | ignore_headers: private_headers, 34 | gobject_typesfile: 'libfprint-2.types', 35 | fixxref_args: [ 36 | '--html-dir=@0@'.format(docpath), 37 | '--extra-dir=@0@'.format(join_paths(glib_docpath, 'glib')), 38 | '--extra-dir=@0@'.format(join_paths(glib_docpath, 'gobject')), 39 | ], 40 | html_assets: html_images, 41 | install: true) 42 | -------------------------------------------------------------------------------- /doc/xml/gtkdocentities.ent.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /doc/xml/meson.build: -------------------------------------------------------------------------------- 1 | ent_conf = configuration_data() 2 | ent_conf.set('PACKAGE', versioned_libname) 3 | ent_conf.set('PACKAGE_BUGREPORT', 'https://gitlab.freedesktop.org/libfprint/libfprint/issues') 4 | ent_conf.set('PACKAGE_NAME', versioned_libname) 5 | ent_conf.set('PACKAGE_STRING', versioned_libname) 6 | ent_conf.set('PACKAGE_TARNAME', 'libfprint-' + meson.project_version()) 7 | ent_conf.set('PACKAGE_URL', 'https://fprint.freedesktop.org/') 8 | ent_conf.set('PACKAGE_VERSION', meson.project_version()) 9 | ent_conf.set('PACKAGE_API_VERSION', '1.0') 10 | configure_file(input: 'gtkdocentities.ent.in', 11 | output: 'gtkdocentities.ent', 12 | configuration: ent_conf) 13 | -------------------------------------------------------------------------------- /examples/cpp-test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | int main (int argc, char **argv) 8 | { 9 | FpContext *ctx; 10 | 11 | ctx = fp_context_new (); 12 | g_object_unref (ctx); 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /examples/meson.build: -------------------------------------------------------------------------------- 1 | 2 | examples = [ 3 | 'enroll', 4 | 'identify', 5 | 'img-capture', 6 | 'manage-prints', 7 | 'verify', 8 | ] 9 | 10 | foreach example: examples 11 | executable(example, 12 | [ example + '.c', 'storage.c', 'utilities.c' ], 13 | dependencies: [ 14 | libfprint_dep, 15 | glib_dep, 16 | ], 17 | ) 18 | endforeach 19 | 20 | executable('cpp-test', 21 | 'cpp-test.cpp', 22 | dependencies: libfprint_dep, 23 | ) 24 | -------------------------------------------------------------------------------- /examples/prints/README: -------------------------------------------------------------------------------- 1 | These are example images from NIST and are in the public domain. 2 | 3 | The PNG files have been generated by using the greyscale data as a mask. 4 | -------------------------------------------------------------------------------- /examples/prints/arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/examples/prints/arch.jpg -------------------------------------------------------------------------------- /examples/prints/arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/examples/prints/arch.png -------------------------------------------------------------------------------- /examples/prints/loop-right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/examples/prints/loop-right.jpg -------------------------------------------------------------------------------- /examples/prints/loop-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/examples/prints/loop-right.png -------------------------------------------------------------------------------- /examples/prints/tented_arch.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/examples/prints/tented_arch.jpg -------------------------------------------------------------------------------- /examples/prints/tented_arch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/examples/prints/tented_arch.png -------------------------------------------------------------------------------- /examples/prints/whorl.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/examples/prints/whorl.jpg -------------------------------------------------------------------------------- /examples/prints/whorl.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/examples/prints/whorl.png -------------------------------------------------------------------------------- /examples/sendvirtimg.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | # This script can be used together with the virtual_imgdev to simulate an 4 | # image based fingerprint reader. 5 | # 6 | # To use, set the FP_VIRTUAL_IMAGE environment variable for both the 7 | # libfprint using program (e.g. fprintd) and this script. 8 | # 9 | # Usually this would work by adding it into the systemd unit file. The 10 | # best way of doing so is to create 11 | # /etc/systemd/system/fprintd.service.d/fprintd-test.conf 12 | # 13 | # [Service] 14 | # RuntimeDirectory=fprint 15 | # Environment=FP_VIRTUAL_IMAGE=/run/fprint/virtimg_sock 16 | # Environment=G_MESSAGES_DEBUG=all 17 | # ReadWritePaths=$RUNTIME_DIR 18 | # 19 | # After that run: 20 | # 21 | # systemctl daemon-reload 22 | # systemctl restart fprintd.service 23 | # 24 | # You may also need to disable selinux. 25 | # 26 | # Then run this script with e.g. 27 | # FP_VIRTUAL_IMAGE=/run/fprint/virtimg_sock ./sendvirtimg.py prints/whorl.png 28 | 29 | 30 | 31 | import cairo 32 | import sys 33 | import os 34 | import socket 35 | import struct 36 | 37 | if len(sys.argv) != 2: 38 | sys.stderr.write('You need to pass a PNG with an alpha channel!\n') 39 | sys.exit(1) 40 | 41 | # Just copied from the C file, we could also use the introspection data for 42 | # this. Also, most of them do *not* make any sense. 43 | commands = { 44 | 'retry' : struct.pack('ii', -1, 0), 45 | 'retry-too-short' : struct.pack('ii', -1, 1), 46 | 'retry-center-finger' : struct.pack('ii', -1, 2), 47 | 'retry-remove-finger' : struct.pack('ii', -1, 3), 48 | 49 | 'error' : struct.pack('ii', -2, 0), 50 | 'error-not-supported' : struct.pack('ii', -2, 1), 51 | 'error-not-open' : struct.pack('ii', -2, 2), 52 | 'error-already-open' : struct.pack('ii', -2, 3), 53 | 'error-busy' : struct.pack('ii', -2, 4), 54 | 'error-proto' : struct.pack('ii', -2, 5), 55 | 'error-data-invalid' : struct.pack('ii', -2, 6), 56 | 'error-data-not-found' : struct.pack('ii', -2, 7), 57 | 'error-data-full' : struct.pack('ii', -2, 8), 58 | } 59 | 60 | 61 | if sys.argv[1] in commands: 62 | command = commands[sys.argv[1]] 63 | else: 64 | png = cairo.ImageSurface.create_from_png(sys.argv[1]) 65 | 66 | # Cairo wants 4 byte aligned rows, so just add a few pixel if necessary 67 | w = png.get_width() 68 | h = png.get_height() 69 | w = (w + 3) // 4 * 4 70 | h = (h + 3) // 4 * 4 71 | img = cairo.ImageSurface(cairo.Format.A8, w, h) 72 | cr = cairo.Context(img) 73 | 74 | cr.set_source_rgba(1, 1, 1, 1) 75 | cr.paint() 76 | 77 | cr.set_source_rgba(0, 0, 0, 0) 78 | cr.set_operator(cairo.OPERATOR_SOURCE) 79 | 80 | cr.set_source_surface(png) 81 | cr.paint() 82 | 83 | mem = img.get_data() 84 | mem = mem.tobytes() 85 | assert len(mem) == img.get_width() * img.get_height() 86 | 87 | command = struct.pack('ii', img.get_width(), img.get_height()) 88 | command += mem 89 | 90 | 91 | 92 | def write_dbg_img(): 93 | dbg_img_rgb = cairo.ImageSurface(cairo.Format.RGB24, img.get_width(), img.get_height()) 94 | dbg_cr = cairo.Context(dbg_img_rgb) 95 | dbg_cr.set_source_rgb(0, 0, 0) 96 | dbg_cr.paint() 97 | dbg_cr.set_source_rgb(1, 1, 1) 98 | dbg_cr.mask_surface(img, 0, 0) 99 | 100 | dbg_img_rgb.write_to_png('/tmp/test.png') 101 | 102 | #write_dbg_img() 103 | 104 | # Send image through socket 105 | sockaddr = os.environ['FP_VIRTUAL_IMAGE'] 106 | 107 | sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) 108 | sock.connect(sockaddr) 109 | 110 | sock.sendall(command) 111 | 112 | -------------------------------------------------------------------------------- /examples/storage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Trivial storage driver for example programs 3 | * 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | int print_data_save (FpPrint *print, 24 | FpFinger finger, 25 | gboolean update_fingerprint); 26 | FpPrint * print_data_load (FpDevice *dev, 27 | FpFinger finger); 28 | GPtrArray * gallery_data_load (FpDevice *dev); 29 | FpPrint * print_create_template (FpDevice *dev, 30 | FpFinger finger, 31 | const gboolean load_existing); 32 | gboolean print_image_save (FpPrint *print, 33 | const char *path); 34 | gboolean save_image_to_pgm (FpImage *img, 35 | const char *path); 36 | -------------------------------------------------------------------------------- /examples/utilities.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Utilities for example programs 3 | * 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #define FP_COMPONENT "example-utilities" 22 | 23 | #include 24 | #include 25 | 26 | #include "utilities.h" 27 | 28 | FpDevice * 29 | discover_device (GPtrArray * devices) 30 | { 31 | FpDevice *dev; 32 | int i; 33 | 34 | if (!devices->len) 35 | return NULL; 36 | 37 | if (devices->len == 1) 38 | { 39 | i = 0; 40 | } 41 | else 42 | { 43 | g_print ("Multiple devices found, choose one\n"); 44 | 45 | for (i = 0; i < devices->len; ++i) 46 | { 47 | dev = g_ptr_array_index (devices, i); 48 | g_print ("[%d] %s (%s) - driver %s\n", i, 49 | fp_device_get_device_id (dev), fp_device_get_name (dev), 50 | fp_device_get_driver (dev)); 51 | } 52 | 53 | g_print ("> "); 54 | if (!scanf ("%d%*c", &i)) 55 | return NULL; 56 | 57 | if (i < 0 || i >= devices->len) 58 | return NULL; 59 | } 60 | 61 | dev = g_ptr_array_index (devices, i); 62 | g_print ("Selected device %s (%s) claimed by %s driver\n", 63 | fp_device_get_device_id (dev), fp_device_get_name (dev), 64 | fp_device_get_driver (dev)); 65 | 66 | return dev; 67 | } 68 | 69 | const char * 70 | finger_to_string (FpFinger finger) 71 | { 72 | switch (finger) 73 | { 74 | case FP_FINGER_LEFT_THUMB: 75 | return "left thumb"; 76 | 77 | case FP_FINGER_LEFT_INDEX: 78 | return "left index"; 79 | 80 | case FP_FINGER_LEFT_MIDDLE: 81 | return "left middle"; 82 | 83 | case FP_FINGER_LEFT_RING: 84 | return "left ring"; 85 | 86 | case FP_FINGER_LEFT_LITTLE: 87 | return "left little"; 88 | 89 | case FP_FINGER_RIGHT_THUMB: 90 | return "right thumb"; 91 | 92 | case FP_FINGER_RIGHT_INDEX: 93 | return "right index"; 94 | 95 | case FP_FINGER_RIGHT_MIDDLE: 96 | return "right middle"; 97 | 98 | case FP_FINGER_RIGHT_RING: 99 | return "right ring"; 100 | 101 | case FP_FINGER_RIGHT_LITTLE: 102 | return "right little"; 103 | 104 | case FP_FINGER_UNKNOWN: 105 | default: 106 | return "unknown"; 107 | } 108 | } 109 | 110 | FpFinger 111 | finger_chooser (void) 112 | { 113 | int i = FP_FINGER_UNKNOWN; 114 | 115 | for (i = FP_FINGER_FIRST; i <= FP_FINGER_LAST; ++i) 116 | g_print (" [%d] %s\n", (i - FP_FINGER_FIRST), finger_to_string (i)); 117 | 118 | g_print ("> "); 119 | if (!scanf ("%d%*c", &i)) 120 | return FP_FINGER_UNKNOWN; 121 | 122 | i += FP_FINGER_FIRST; 123 | 124 | if (i < FP_FINGER_FIRST || i > FP_FINGER_LAST) 125 | return FP_FINGER_UNKNOWN; 126 | 127 | return i; 128 | } 129 | -------------------------------------------------------------------------------- /examples/utilities.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Trivial storage driver for example programs 3 | * 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | FpDevice * discover_device (GPtrArray *devices); 24 | FpFinger finger_chooser (void); 25 | const char * finger_to_string (FpFinger finger); 26 | -------------------------------------------------------------------------------- /libfprint/drivers/aes1660.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES1660 driver for libfprint 3 | * Copyright (C) 2012 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #define FP_COMPONENT "aes1660" 21 | 22 | #include "drivers_api.h" 23 | #include "aeslib.h" 24 | #include "aesx660.h" 25 | #include "aes1660.h" 26 | 27 | #define FRAME_WIDTH 128 28 | #define IMAGE_WIDTH (FRAME_WIDTH + (FRAME_WIDTH / 2)) 29 | 30 | struct _FpiDeviceAes1660 31 | { 32 | FpiDeviceAesX660 parent; 33 | }; 34 | G_DECLARE_FINAL_TYPE (FpiDeviceAes1660, fpi_device_aes1660, FPI, 35 | DEVICE_AES1660, FpiDeviceAesX660); 36 | G_DEFINE_TYPE (FpiDeviceAes1660, fpi_device_aes1660, FPI_TYPE_DEVICE_AES_X660); 37 | 38 | static struct fpi_frame_asmbl_ctx assembling_ctx = { 39 | .frame_width = FRAME_WIDTH, 40 | .frame_height = AESX660_FRAME_HEIGHT, 41 | .image_width = IMAGE_WIDTH, 42 | .get_pixel = aes_get_pixel, 43 | }; 44 | 45 | static const FpIdEntry id_table[] = { 46 | { .vid = 0x08ff, .pid = 0x1660, }, 47 | { .vid = 0x08ff, .pid = 0x1680, }, 48 | { .vid = 0x08ff, .pid = 0x1681, }, 49 | { .vid = 0x08ff, .pid = 0x1682, }, 50 | { .vid = 0x08ff, .pid = 0x1683, }, 51 | { .vid = 0x08ff, .pid = 0x1684, }, 52 | { .vid = 0x08ff, .pid = 0x1685, }, 53 | { .vid = 0x08ff, .pid = 0x1686, }, 54 | { .vid = 0x08ff, .pid = 0x1687, }, 55 | { .vid = 0x08ff, .pid = 0x1688, }, 56 | { .vid = 0x08ff, .pid = 0x1689, }, 57 | { .vid = 0x08ff, .pid = 0x168a, }, 58 | { .vid = 0x08ff, .pid = 0x168b, }, 59 | { .vid = 0x08ff, .pid = 0x168c, }, 60 | { .vid = 0x08ff, .pid = 0x168d, }, 61 | { .vid = 0x08ff, .pid = 0x168e, }, 62 | { .vid = 0x08ff, .pid = 0x168f, }, 63 | { .vid = 0, .pid = 0, .driver_data = 0 }, 64 | }; 65 | 66 | static void 67 | fpi_device_aes1660_init (FpiDeviceAes1660 *self) 68 | { 69 | } 70 | static void 71 | fpi_device_aes1660_class_init (FpiDeviceAes1660Class *klass) 72 | { 73 | FpDeviceClass *dev_class = FP_DEVICE_CLASS (klass); 74 | FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_CLASS (klass); 75 | FpiDeviceAesX660Class *aes_class = FPI_DEVICE_AES_X660_CLASS (klass); 76 | 77 | dev_class->id = "aes1660"; 78 | dev_class->full_name = "AuthenTec AES1660"; 79 | dev_class->type = FP_DEVICE_TYPE_USB; 80 | dev_class->id_table = id_table; 81 | dev_class->scan_type = FP_SCAN_TYPE_SWIPE; 82 | 83 | img_class->bz3_threshold = 20; 84 | 85 | img_class->img_width = FRAME_WIDTH + FRAME_WIDTH / 2; 86 | img_class->img_height = -1; 87 | 88 | aes_class->init_seqs[0] = aes1660_init_1; 89 | aes_class->init_seqs_len[0] = G_N_ELEMENTS (aes1660_init_1); 90 | aes_class->init_seqs[1] = aes1660_init_2; 91 | aes_class->init_seqs_len[1] = G_N_ELEMENTS (aes1660_init_2); 92 | aes_class->start_imaging_cmd = (unsigned char *) aes1660_start_imaging_cmd; 93 | aes_class->start_imaging_cmd_len = sizeof (aes1660_start_imaging_cmd); 94 | aes_class->assembling_ctx = &assembling_ctx; 95 | } 96 | -------------------------------------------------------------------------------- /libfprint/drivers/aes2550.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES2550/AES2810 driver for libfprint 3 | * Copyright (C) 2012 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | /* Registers bits */ 23 | 24 | #define AES2550_REG80_MASTER_RESET (1 << 0) 25 | #define AES2550_REG80_FORCE_FINGER_PRESENT (1 << 1) 26 | #define AES2550_REG80_LPO_START (1 << 2) 27 | #define AES2550_REG80_HGC_ENABLE (1 << 3) 28 | #define AES2550_REG80_SENSOR_MODE_OFS (4) 29 | #define AES2550_REG80_AUTO_RESTART_FD (1 << 6) 30 | #define AES2550_REG80_EXT_REG_ENABLE (1 << 7) 31 | 32 | #define AES2550_REG81_CONT_SCAN (1 << 0) 33 | #define AES2550_REG81_READ_REG (1 << 1) 34 | #define AES2550_REG81_NSHOT (1 << 2) 35 | #define AES2550_REG81_RUN_FD (1 << 3) 36 | #define AES2550_REG81_READ_ID (1 << 4) 37 | #define AES2550_REG81_RUN_CAL (1 << 5) 38 | #define AES2550_REG81_RUN_TIMER (1 << 6) 39 | #define AES2550_REG81_RUN_BIST (1 << 7) 40 | 41 | #define AES2550_REG83_FINGER_PRESENT (1 << 7) 42 | 43 | #define AES2550_REG85_FLUSH_PER_FRAME (1 << 7) 44 | 45 | #define AES2550_REG8F_EDATA_DISABLE (1 << 1) 46 | #define AES2550_REG8F_AUTH_DISABLE (1 << 2) 47 | #define AES2550_REG8F_EHISTO_DISABLE (1 << 3) 48 | #define AES2550_REG8F_HISTO64 (1 << 4) 49 | #define AES2550_REG8F_SINGLE_REG_ENABLE (1 << 6) 50 | 51 | #define AES2550_REG95_COL_SCANNED_OFS (0) 52 | #define AES2550_REG95_EPIX_AVG_OFS (4) 53 | 54 | #define AES2550_REGA8_DIG_BIT_DATA_OFS (0) 55 | #define AES2550_REGA8_DIG_BIT_EN (1 << 4) 56 | #define AES2550_REGA8_FIXED_BIT_DATA (1 << 5) 57 | #define AES2550_REGA8_INVERT_BIT_DATA (1 << 6) 58 | 59 | #define AES2550_REGAD_LPFD_AVG_OFS (0) 60 | #define AES2550_REGAD_DETECT_FGROFF (1 << 4) 61 | #define AES2550_REGAD_ADVRANGE_2V (1 << 6) 62 | 63 | #define AES2550_REGB1_ATE_CONT_IMAGE (1 << 1) 64 | #define AES2550_REGB1_ANALOG_RESET (1 << 2) 65 | #define AES2550_REGB1_ANALOG_PD (1 << 3) 66 | #define AES2550_REGB1_TEST_EMBD_WORD (1 << 4) 67 | #define AES2550_REGB1_ORIG_EMBD_WORD (1 << 5) 68 | #define AES2550_REGB1_RESET_UHSM (1 << 6) 69 | #define AES2550_REGB1_RESET_SENSOR (1 << 7) 70 | 71 | #define AES2550_REGBD_LPO_IN_15_8_OFS (0) 72 | #define AES2550_REGBE_LPO_IN_7_0_OFS (0) 73 | 74 | #define AES2550_REGBF_RSR_LEVEL_DISABLED (0 << 0) 75 | #define AES2550_REGBF_RSR_LEVEL_LEADING_RSR (1 << 0) 76 | #define AES2550_REGBF_RSR_LEVEL_SIMPLE_RSR (2 << 0) 77 | #define AES2550_REGBF_RSR_LEVEL_SUPER_RSR (3 << 0) 78 | #define AES2550_REGBF_RSR_DIR_DOWN_MOTION (0 << 2) 79 | #define AES2550_REGBF_RSR_DIR_UP_MOTION (1 << 2) 80 | #define AES2550_REGBF_RSR_DIR_UPDOWN_MOTION (2 << 2) 81 | #define AES2550_REGBF_NOISE_FLOOR_MODE (1 << 4) 82 | #define AES2550_REGBF_QUADRATURE_MODE (1 << 5) 83 | 84 | #define AES2550_REGCF_INTERFERENCE_CHK_EN (1 << 0) 85 | #define AES2550_REGCF_INTERFERENCE_AVG_EN (1 << 1) 86 | #define AES2550_REGCF_INTERFERENCE_AVG_OFFS (4) 87 | 88 | #define AES2550_REGDC_BP_NUM_REF_SWEEP_OFS (0) 89 | #define AES2550_REGDC_DEBUG_CTRL2_OFS (3) 90 | 91 | #define AES2550_REGDD_DEBUG_CTRL1_OFS (0) 92 | 93 | /* Commands */ 94 | 95 | enum aes2550_cmds { 96 | AES2550_CMD_SET_IDLE_MODE = 0x00, 97 | AES2550_CMD_RUN_FD = 0x01, 98 | AES2550_CMD_GET_ENROLL_IMG = 0x02, 99 | AES2550_CMD_CALIBRATE = 0x06, 100 | AES2550_CMD_READ_CALIBRATION_DATA = 0x10, 101 | AES2550_CMD_HEARTBEAT = 0x70, 102 | }; 103 | 104 | /* Messages */ 105 | 106 | #define AES2550_STRIP_SIZE (0x31e + 3) 107 | #define AES2550_HEARTBEAT_SIZE (4 + 3) 108 | #define AES2550_EDATA_MAGIC 0xe0 109 | #define AES2550_HEARTBEAT_MAGIC 0xdb 110 | 111 | #define AES2550_EP_IN_BUF_SIZE 8192 112 | -------------------------------------------------------------------------------- /libfprint/drivers/aes2660.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES2660 driver for libfprint 3 | * Copyright (C) 2012 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #define FP_COMPONENT "aes2660" 21 | 22 | #include "drivers_api.h" 23 | #include "aeslib.h" 24 | #include "aesx660.h" 25 | #include "aes2660.h" 26 | 27 | #define FRAME_WIDTH 192 28 | #define IMAGE_WIDTH (FRAME_WIDTH + (FRAME_WIDTH / 2)) 29 | 30 | struct _FpiDeviceAes2660 31 | { 32 | FpiDeviceAesX660 parent; 33 | }; 34 | G_DECLARE_FINAL_TYPE (FpiDeviceAes2660, fpi_device_aes2660, FPI, 35 | DEVICE_AES2660, FpiDeviceAesX660); 36 | G_DEFINE_TYPE (FpiDeviceAes2660, fpi_device_aes2660, FPI_TYPE_DEVICE_AES_X660); 37 | 38 | static struct fpi_frame_asmbl_ctx assembling_ctx = { 39 | .frame_width = FRAME_WIDTH, 40 | .frame_height = AESX660_FRAME_HEIGHT, 41 | .image_width = IMAGE_WIDTH, 42 | .get_pixel = aes_get_pixel, 43 | }; 44 | 45 | static const FpIdEntry id_table[] = { 46 | { .vid = 0x08ff, .pid = 0x2660, }, 47 | { .vid = 0x08ff, .pid = 0x2680, }, 48 | { .vid = 0x08ff, .pid = 0x2681, }, 49 | { .vid = 0x08ff, .pid = 0x2682, }, 50 | { .vid = 0x08ff, .pid = 0x2683, }, 51 | { .vid = 0x08ff, .pid = 0x2684, }, 52 | { .vid = 0x08ff, .pid = 0x2685, }, 53 | { .vid = 0x08ff, .pid = 0x2686, }, 54 | { .vid = 0x08ff, .pid = 0x2687, }, 55 | { .vid = 0x08ff, .pid = 0x2688, }, 56 | { .vid = 0x08ff, .pid = 0x2689, }, 57 | { .vid = 0x08ff, .pid = 0x268a, }, 58 | { .vid = 0x08ff, .pid = 0x268b, }, 59 | { .vid = 0x08ff, .pid = 0x268c, }, 60 | { .vid = 0x08ff, .pid = 0x268d, }, 61 | { .vid = 0x08ff, .pid = 0x268e, }, 62 | { .vid = 0x08ff, .pid = 0x268f, }, 63 | { .vid = 0x08ff, .pid = 0x2691, }, 64 | { .vid = 0, .pid = 0, .driver_data = 0 }, 65 | }; 66 | 67 | static void 68 | fpi_device_aes2660_init (FpiDeviceAes2660 *self) 69 | { 70 | } 71 | 72 | static void 73 | fpi_device_aes2660_class_init (FpiDeviceAes2660Class *klass) 74 | { 75 | FpDeviceClass *dev_class = FP_DEVICE_CLASS (klass); 76 | FpImageDeviceClass *img_class = FP_IMAGE_DEVICE_CLASS (klass); 77 | FpiDeviceAesX660Class *aes_class = FPI_DEVICE_AES_X660_CLASS (klass); 78 | 79 | dev_class->id = "aes2660"; 80 | dev_class->full_name = "AuthenTec AES2660"; 81 | dev_class->type = FP_DEVICE_TYPE_USB; 82 | dev_class->id_table = id_table; 83 | dev_class->scan_type = FP_SCAN_TYPE_SWIPE; 84 | 85 | img_class->bz3_threshold = 20; 86 | 87 | img_class->img_width = FRAME_WIDTH + FRAME_WIDTH / 2; 88 | img_class->img_height = -1; 89 | 90 | aes_class->init_seqs[0] = aes2660_init_1; 91 | aes_class->init_seqs_len[0] = G_N_ELEMENTS (aes2660_init_1); 92 | aes_class->init_seqs[1] = aes2660_init_2; 93 | aes_class->init_seqs_len[1] = G_N_ELEMENTS (aes2660_init_2); 94 | aes_class->start_imaging_cmd = (unsigned char *) aes2660_start_imaging_cmd; 95 | aes_class->start_imaging_cmd_len = sizeof (aes2660_start_imaging_cmd); 96 | aes_class->assembling_ctx = &assembling_ctx; 97 | } 98 | -------------------------------------------------------------------------------- /libfprint/drivers/aes3k.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES3500/AES4000 common routines 3 | * 4 | * The AES3500 and AES4000 sensors are press-typed, and could capture 5 | * fingerprint images in 128x128 and 96x96 pixels respectively. They 6 | * share a same communication interface: a number of frames are 7 | * transferred and captured, from which a final image could be 8 | * assembled. Each frame has fixed height of 16 pixels. 9 | * 10 | * As the imaging area is a bit small, only a part of finger could be 11 | * captured, the detected minutiae are not so many that the NBIS 12 | * matching works not so good. The verification rate is very low at the 13 | * moment. 14 | * 15 | * This work is derived from Daniel Drake's AES4000 driver. 16 | * 17 | * Copyright (C) 2013 Juvenn Woo 18 | * Copyright (C) 2007-2008 Daniel Drake 19 | * 20 | * This library is free software; you can redistribute it and/or modify 21 | * it under the terms of the GNU Lesser General Public License as 22 | * published by the Free Software Foundation; either version 2.1 of the 23 | * License, or (at your option) any later version. 24 | * 25 | * This library is distributed in the hope that it will be useful, but 26 | * WITHOUT ANY WARRANTY; without even the implied warranty of 27 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 28 | * Lesser General Public License for more details. 29 | * 30 | * You should have received a copy of the GNU Lesser General Public 31 | * License along with this library; if not, write to the Free Software 32 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 33 | * 02110-1301 USA 34 | * 35 | */ 36 | 37 | #pragma once 38 | #include "fpi-image-device.h" 39 | #include "aeslib.h" 40 | 41 | #define AES3K_FRAME_HEIGHT 16 42 | 43 | G_DECLARE_DERIVABLE_TYPE (FpiDeviceAes3k, fpi_device_aes3k, FPI, 44 | DEVICE_AES3K, FpImageDevice) 45 | 46 | #define FPI_TYPE_DEVICE_AES3K (fpi_device_aes3k_get_type ()) 47 | 48 | struct _FpiDeviceAes3kClass 49 | { 50 | FpImageDeviceClass parent; 51 | 52 | gsize frame_width; /* image size = frame_width x frame_width */ 53 | gsize frame_size; /* 4 bits/pixel: frame_width x AES3K_FRAME_HEIGHT / 2 */ 54 | gsize frame_number; /* number of frames */ 55 | gsize enlarge_factor; 56 | 57 | gsize data_buflen; /* buffer length of usb bulk transfer */ 58 | struct aes_regwrite *init_reqs; /* initial values sent to device */ 59 | gsize init_reqs_len; 60 | struct aes_regwrite *capture_reqs; /* capture values sent to device */ 61 | gsize capture_reqs_len; 62 | }; 63 | -------------------------------------------------------------------------------- /libfprint/drivers/aeslib.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Shared functions between libfprint Authentec drivers 3 | * Copyright (C) 2007 Daniel Drake 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | struct aes_regwrite 25 | { 26 | unsigned char reg; 27 | unsigned char value; 28 | }; 29 | 30 | struct fpi_frame; 31 | struct fpi_frame_asmbl_ctx; 32 | 33 | typedef void (*aes_write_regv_cb)(FpImageDevice *dev, 34 | GError *error, 35 | void *user_data); 36 | 37 | void aes_write_regv (FpImageDevice *dev, 38 | const struct aes_regwrite *regs, 39 | unsigned int num_regs, 40 | aes_write_regv_cb callback, 41 | void *user_data); 42 | 43 | unsigned char aes_get_pixel (struct fpi_frame_asmbl_ctx *ctx, 44 | struct fpi_frame *frame, 45 | unsigned int x, 46 | unsigned int y); 47 | -------------------------------------------------------------------------------- /libfprint/drivers/aesx660.h: -------------------------------------------------------------------------------- 1 | /* 2 | * AuthenTec AES1660/AES2660 common definitions 3 | * Copyright (c) 2012 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #define AESX660_HEADER_SIZE 3 23 | #define AESX660_RESPONSE_TYPE_OFFSET 0x00 24 | #define AESX660_RESPONSE_SIZE_LSB_OFFSET 0x01 25 | #define AESX660_RESPONSE_SIZE_MSB_OFFSET 0x02 26 | 27 | #define AESX660_CALIBRATE_RESPONSE 0x06 28 | #define AESX660_FINGER_DET_RESPONSE 0x40 29 | #define AESX660_FINGER_PRESENT_OFFSET 0x03 30 | #define AESX660_FINGER_PRESENT 0x01 31 | 32 | #define AESX660_IMAGE_OK_OFFSET 0x03 33 | #define AESX660_IMAGE_OK 0x0d 34 | #define AESX660_LAST_FRAME_OFFSET 0x04 35 | #define AESX660_LAST_FRAME_BIT 0x01 36 | 37 | #define AESX660_FRAME_DELTA_X_OFFSET 16 38 | #define AESX660_FRAME_DELTA_Y_OFFSET 17 39 | 40 | #define AESX660_IMAGE_OFFSET 43 41 | #define AESX660_BULK_TRANSFER_SIZE 4096 42 | 43 | #define AESX660_FRAME_HEIGHT 8 44 | 45 | G_DECLARE_DERIVABLE_TYPE (FpiDeviceAesX660, fpi_device_aes_x660, FPI, 46 | DEVICE_AES_X660, FpImageDevice) 47 | 48 | #define FPI_TYPE_DEVICE_AES_X660 (fpi_device_aes_x660_get_type ()) 49 | 50 | struct _FpiDeviceAesX660Class 51 | { 52 | FpImageDeviceClass parent; 53 | 54 | struct aesX660_cmd *init_seqs[2]; 55 | gsize init_seqs_len[2]; 56 | guint8 *start_imaging_cmd; 57 | gsize start_imaging_cmd_len; 58 | struct fpi_frame_asmbl_ctx *assembling_ctx; 59 | }; 60 | 61 | struct aesX660_cmd 62 | { 63 | const guint8 *cmd; 64 | gsize len; 65 | }; 66 | 67 | /* 0x77 cmd seems to control LED, this sequence 68 | * makes LED blink 69 | */ 70 | static const guint8 led_blink_cmd[] = { 71 | 0x77, 0x18, 0x00, 72 | 0x00, 0x3f, 0x00, 0xff, 0x00, 73 | 0x01, 0x01, 0x00, 0x00, 0x00, 0xf3, 0x01, 0x00, 74 | 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0xf3, 75 | 0x01, 0x00, 0x7f 76 | }; 77 | 78 | /* This sequence makes LED light solid 79 | */ 80 | static const guint8 led_solid_cmd[] = { 81 | 0x77, 0x18, 0x00, 0x00, 0x3f, 0x00, 0xff, 0x00, 82 | 0x01, 0x01, 0x00, 0x00, 0x00, 0xe7, 0x03, 0x00, 83 | 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 84 | 0x00, 0x00, 0x7f 85 | }; 86 | 87 | static const guint8 wait_for_finger_cmd[] = { 88 | 0x20, 89 | 0x40, 0x04, 0x00, 0x02, 0x1e, 0x00, 0x32 90 | }; 91 | 92 | /* 0x40 cmd response 93 | * 94 | static const guint8 pkt1371[] = { 95 | 0x40, 0x01, 0x00, 0x01 96 | }; 97 | */ 98 | 99 | static const guint8 set_idle_cmd[] = { 100 | 0x0d, /* Reset or "set idle"? */ 101 | }; 102 | 103 | static const guint8 read_id_cmd[] = { 104 | 0x44, 0x02, 0x00, 0x08, 0x00, /* Max transfer size is 8 */ 105 | 0x07, /* Read ID? */ 106 | }; 107 | 108 | static const guint8 calibrate_cmd[] = { 109 | 0x44, 0x02, 0x00, 0x04, 0x00, 110 | 0x06, 111 | }; 112 | -------------------------------------------------------------------------------- /libfprint/drivers/goodixmoc/goodix.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Goodix Moc driver for libfprint 3 | * Copyright (C) 2019 Shenzhen Goodix Technology Co., Ltd. 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "fpi-device.h" 23 | #include "fpi-ssm.h" 24 | 25 | G_DECLARE_FINAL_TYPE (FpiDeviceGoodixMoc, fpi_device_goodixmoc, FPI, DEVICE_GOODIXMOC, FpDevice) 26 | 27 | typedef enum { 28 | FP_CMD_SEND = 0, 29 | FP_CMD_GET_ACK, 30 | FP_CMD_GET_DATA, 31 | FP_CMD_NUM_STATES, 32 | } FpCmdState; 33 | 34 | 35 | typedef enum { 36 | FP_INIT_VERSION = 0, 37 | FP_INIT_CONFIG, 38 | FP_INIT_TEMPLATE_LIST, 39 | FP_INIT_RESET_DEVICE, 40 | FP_INIT_NUM_STATES, 41 | } FpInitState; 42 | 43 | 44 | typedef enum { 45 | FP_ENROLL_PWR_BTN_SHIELD_ON = 0, 46 | FP_ENROLL_ENUM, 47 | FP_ENROLL_IDENTIFY, 48 | FP_ENROLL_CREATE, 49 | FP_ENROLL_CAPTURE, 50 | FP_ENROLL_UPDATE, 51 | FP_ENROLL_WAIT_FINGER_UP, 52 | FP_ENROLL_CHECK_DUPLICATE, 53 | FP_ENROLL_COMMIT, 54 | FP_ENROLL_PWR_BTN_SHIELD_OFF, 55 | FP_ENROLL_NUM_STATES, 56 | } FpEnrollState; 57 | 58 | typedef enum { 59 | FP_VERIFY_PWR_BTN_SHIELD_ON = 0, 60 | FP_VERIFY_CAPTURE, 61 | FP_VERIFY_IDENTIFY, 62 | FP_VERIFY_PWR_BTN_SHIELD_OFF, 63 | FP_VERIFY_NUM_STATES, 64 | } FpVerifyState; 65 | -------------------------------------------------------------------------------- /libfprint/drivers/synaptics/bmkt_message.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Synaptics Inc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #pragma once 20 | 21 | #define BMKT_MESSAGE_HEADER_ID 0xFE 22 | #define BMKT_MESSAGE_HEADER_LEN (4) 23 | #define BMKT_MESSAGE_CRC32_LEN (4) 24 | #define BMKT_MESSAGE_HEADER_ID_FIELD 0 25 | #define BMKT_MESSAGE_SEQ_NUM_FIELD 1 26 | #define BMKT_MESSAGE_ID_FIELD 2 27 | #define BMKT_MESSAGE_PAYLOAD_LEN_FIELD 3 28 | #define BMKT_MESSAGE_PAYLOAD_FIELD 4 29 | 30 | // Command messages 31 | #define BMKT_CMD_CONTINUOUS_IMAGE_CAPTURE 0x01 32 | #define BMKT_CMD_CONTINUOUS_IMAGE_CAPTURE_STOP 0x04 33 | #define BMKT_CMD_SENSOR_MODULE_TEST 0x06 34 | #define BMKT_CMD_SENSOR_MODULE_TEST_START 0x08 35 | #define BMKT_CMD_NEXT_TEST_REPORT_CHUNK 0x0B 36 | #define BMKT_CMD_FPS_INIT 0x11 37 | #define BMKT_CMD_GET_FPS_MODE 0x21 38 | #define BMKT_CMD_SET_SECURITY_LEVEL 0x31 39 | #define BMKT_CMD_GET_SECURITY_LEVEL 0x34 40 | #define BMKT_CMD_CANCEL_OP 0x41 41 | #define BMKT_CMD_ENROLL_USER 0x51 42 | #define BMKT_CMD_ENROLL_PAUSE 0x52 43 | #define BMKT_CMD_ENROLL_RESUME 0x53 44 | #define BMKT_CMD_ID_USER 0x61 45 | #define BMKT_CMD_VERIFY_USER 0x65 46 | #define BMKT_CMD_GET_TEMPLATE_RECORDS 0x71 47 | #define BMKT_CMD_GET_NEXT_QUERY_RESPONSE 0x72 48 | #define BMKT_CMD_GET_ENROLLED_FINGERS 0x73 49 | #define BMKT_CMD_GET_DATABASE_CAPACITY 0x74 50 | #define BMKT_CMD_DEL_USER_FP 0x81 51 | #define BMKT_CMD_DEL_FULL_DB 0x84 52 | #define BMKT_CMD_REPEAT_LAST_RSP 0x92 53 | #define BMKT_CMD_POWER_DOWN_NOTIFY 0xA1 54 | #define BMKT_CMD_GET_VERSION 0xB1 55 | #define BMKT_CMD_DISABLE_PAIRING 0xC2 56 | #define BMKT_CMD_QUERY_PAIRING 0xC5 57 | #define BMKT_CMD_SENSOR_STATUS 0xD1 58 | #define BMKT_CMD_ID_USER_IN_ORDER 0xE1 59 | #define BMKT_CMD_ID_NEXT_USER 0xE3 60 | #define BMKT_CMD_VERIFY_USER_IN_ORDER 0xF1 61 | #define BMKT_CMD_VERIFY_FINGERS_IN_ORDER 0xF2 62 | #define BMKT_CMD_GET_FINAL_RESULT 0xE4 63 | 64 | #define BMKT_EVT_FINGER_REPORT 0x91 65 | 66 | #define BMKT_EVT_FINGER_STATE_NOT_ON_SENSOR 0x00 67 | #define BMKT_EVT_FINGER_STATE_ON_SENSOR 0x01 68 | 69 | typedef struct bmkt_msg_resp 70 | { 71 | uint8_t msg_id; 72 | uint8_t seq_num; 73 | uint8_t payload_len; 74 | uint8_t *payload; 75 | int result; 76 | } bmkt_msg_resp_t; 77 | 78 | int bmkt_compose_message (uint8_t *cmd, 79 | int *cmd_len, 80 | uint8_t msg_id, 81 | uint8_t seq_num, 82 | uint8_t payload_size, 83 | const uint8_t *payload); 84 | 85 | int bmkt_parse_message_header (uint8_t *resp_buf, 86 | int resp_len, 87 | bmkt_msg_resp_t *msg_resp); 88 | int bmkt_parse_message_payload (bmkt_msg_resp_t *msg_resp, 89 | bmkt_response_t *resp); 90 | -------------------------------------------------------------------------------- /libfprint/drivers/synaptics/sensor.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Synaptics Inc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "usb_transport.h" 22 | #define BMKT_MAX_PENDING_SESSIONS 2 23 | 24 | typedef enum bmkt_sensor_state { 25 | BMKT_SENSOR_STATE_UNINIT = 0, 26 | BMKT_SENSOR_STATE_IDLE, 27 | BMKT_SENSOR_STATE_INIT, 28 | BMKT_SENSOR_STATE_EXIT, 29 | } bmkt_sensor_state_t; 30 | 31 | typedef struct bmkt_sensor_drv bmkt_sensor_drv_t; 32 | 33 | typedef struct bmkt_sensor_version 34 | { 35 | uint32_t build_time; 36 | uint32_t build_num; 37 | uint8_t version_major; 38 | uint8_t version_minor; 39 | uint8_t target; 40 | uint8_t product; 41 | uint8_t silicon_rev; 42 | uint8_t formal_release; 43 | uint8_t platform; 44 | uint8_t patch; 45 | uint8_t serial_number[6]; 46 | uint16_t security; 47 | uint8_t iface; 48 | uint8_t device_type; 49 | } bmkt_sensor_version_t; 50 | 51 | typedef struct bmkt_sensor 52 | { 53 | bmkt_usb_transport_t usb_xport; 54 | bmkt_sensor_version_t version; 55 | bmkt_session_ctx_t pending_sessions[BMKT_MAX_PENDING_SESSIONS]; 56 | int empty_session_idx; 57 | int flags; 58 | int seq_num; 59 | bmkt_sensor_state_t sensor_state; 60 | bmkt_event_cb_t finger_event_cb; 61 | void *finger_cb_ctx; 62 | bmkt_general_error_cb_t gen_err_cb; 63 | void *gen_err_cb_ctx; 64 | bmkt_op_state_t op_state; 65 | } bmkt_sensor_t; 66 | 67 | int bmkt_sensor_open (bmkt_sensor_t *sensor, 68 | bmkt_general_error_cb_t err_cb, 69 | void *err_cb_ctx); 70 | int bmkt_sensor_close (bmkt_sensor_t *sensor); 71 | 72 | int bmkt_sensor_init_fps (bmkt_sensor_t *sensor); 73 | 74 | int bmkt_sensor_send_message (bmkt_sensor_t *sensor, 75 | uint8_t msg_id, 76 | uint8_t payload_size, 77 | uint8_t *payload, 78 | bmkt_resp_cb_t resp_cb, 79 | void *resp_data); 80 | int bmkt_sensor_handle_response (bmkt_sensor_t *sensor, 81 | uint8_t *resp_buf, 82 | int resp_len, 83 | bmkt_msg_resp_t *msg_resp); 84 | 85 | int bmkt_sensor_send_async_read_command (bmkt_sensor_t *sensor); 86 | -------------------------------------------------------------------------------- /libfprint/drivers/synaptics/synaptics.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 Synaptics Inc 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "fpi-device.h" 22 | #include "fpi-ssm.h" 23 | 24 | #define SYNAPTICS_VENDOR_ID 0x06cb 25 | 26 | G_DECLARE_FINAL_TYPE (FpiDeviceSynaptics, fpi_device_synaptics, FPI, DEVICE_SYNAPTICS, FpDevice) 27 | 28 | 29 | #define MAX_TRANSFER_LEN 263 + 1 /* SPI Header */ + 2 /* VCSFW header */ 30 | 31 | #define USB_EP_REQUEST 0x01 32 | #define USB_EP_REPLY 0x81 33 | #define USB_EP_FINGERPRINT 0x82 34 | #define USB_EP_INTERRUPT 0x83 35 | 36 | #define USB_ASYNC_MESSAGE_PENDING 0x4 37 | #define USB_INTERRUPT_DATA_SIZE 7 38 | 39 | #define SENSOR_CMD_GET_VERSION 1 40 | #define SENSOR_CMD_ACE_COMMAND 167 41 | #define SENSOR_CMD_ASYNCMSG_READ 168 42 | 43 | #define SENSOR_FW_CMD_HEADER_LEN 1 44 | #define SENSOR_FW_REPLY_HEADER_LEN 2 45 | 46 | 47 | /* Number of enroll stages */ 48 | #define ENROLL_SAMPLES 8 49 | 50 | 51 | #define SYNAPTICS_DRIVER_FULLNAME "Synaptics Sensors" 52 | #include "bmkt.h" 53 | #include "bmkt_response.h" 54 | 55 | 56 | typedef struct bmkt_sensor_version 57 | { 58 | uint32_t build_time; 59 | uint32_t build_num; 60 | uint8_t version_major; 61 | uint8_t version_minor; 62 | uint8_t target; 63 | uint8_t product; 64 | uint8_t silicon_rev; 65 | uint8_t formal_release; 66 | uint8_t platform; 67 | uint8_t patch; 68 | uint8_t serial_number[6]; 69 | uint16_t security; 70 | uint8_t iface; 71 | uint8_t device_type; 72 | } bmkt_sensor_version_t; 73 | 74 | 75 | struct syna_enroll_resp_data 76 | { 77 | int progress; 78 | }; 79 | typedef enum syna_state { 80 | SYNA_STATE_UNINIT = 0, 81 | SYNA_STATE_IDLE, 82 | SYNA_STATE_ENROLL, 83 | SYNA_STATE_IDENTIFY, 84 | SYNA_STATE_IDENTIFY_DELAY_RESULT, 85 | SYNA_STATE_VERIFY, 86 | SYNA_STATE_VERIFY_DELAY_RESULT, 87 | SYNA_STATE_DELETE, 88 | } syna_state_t; 89 | 90 | typedef enum { 91 | SYNAPTICS_CMD_SEND_PENDING = 0, 92 | SYNAPTICS_CMD_GET_RESP, 93 | SYNAPTICS_CMD_WAIT_INTERRUPT, 94 | SYNAPTICS_CMD_SEND_ASYNC, 95 | SYNAPTICS_CMD_RESTART, 96 | SYNAPTICS_CMD_SUSPENDED, 97 | SYNAPTICS_CMD_RESUME, 98 | SYNAPTICS_CMD_NUM_STATES, 99 | } SynapticsCmdState; 100 | 101 | 102 | typedef void (*SynCmdMsgCallback) (FpiDeviceSynaptics *self, 103 | bmkt_response_t *resp, 104 | GError *error); 105 | 106 | struct _FpiDeviceSynaptics 107 | { 108 | FpDevice parent; 109 | 110 | guint8 cmd_seq_num; 111 | guint8 last_seq_num; 112 | FpiSsm *cmd_ssm; 113 | FpiUsbTransfer *cmd_pending_transfer; 114 | gboolean cmd_complete_on_removal; 115 | gboolean cmd_suspended; 116 | guint8 id_idx; 117 | 118 | bmkt_sensor_version_t mis_version; 119 | 120 | gboolean action_starting; 121 | GCancellable *interrupt_cancellable; 122 | 123 | gint enroll_stage; 124 | gboolean finger_on_sensor; 125 | GPtrArray *list_result; 126 | 127 | 128 | struct syna_enroll_resp_data enroll_resp_data; 129 | syna_state_t state; 130 | }; 131 | -------------------------------------------------------------------------------- /libfprint/drivers/upek_proto.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Code copied from gstreamer-plugins-bad gst/gdp/dataprotocol.c 3 | * 4 | * Copyright (C) <1999> Erik Walthinsen 5 | * Copyright (C) 2004,2006 Thomas Vander Stichele 6 | * Copyright (C) 2014 Tim-Philipp Müller 7 | * 8 | * This library is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as 10 | * published by the Free Software Foundation; either version 2.1 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | * 02110-1301 USA 22 | */ 23 | 24 | #include "upek_proto.h" 25 | 26 | static const uint16_t crc_table[256] = { 27 | 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, 28 | 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, 29 | 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, 30 | 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, 31 | 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, 32 | 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, 33 | 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, 34 | 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, 35 | 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, 36 | 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, 37 | 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, 38 | 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, 39 | 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, 40 | 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, 41 | 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, 42 | 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, 43 | 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, 44 | 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, 45 | 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, 46 | 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, 47 | 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, 48 | 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 49 | 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, 50 | 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, 51 | 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, 52 | 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, 53 | 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, 54 | 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, 55 | 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, 56 | 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, 57 | 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, 58 | 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0 59 | }; 60 | 61 | uint16_t 62 | udf_crc (unsigned char *buffer, size_t size) 63 | { 64 | uint16_t crc = 0; 65 | 66 | while (size--) 67 | crc = (uint16_t) ((crc << 8) ^ 68 | crc_table[((crc >> 8) & 0x00ff) ^ *buffer++]); 69 | return crc; 70 | } 71 | -------------------------------------------------------------------------------- /libfprint/drivers/upek_proto.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Code copied from gstreamer-plugins-bad gst/gdp/dataprotocol.c 3 | * 4 | * Copyright (C) <1999> Erik Walthinsen 5 | * Copyright (C) 2004,2006 Thomas Vander Stichele 6 | * Copyright (C) 2014 Tim-Philipp Müller 7 | * 8 | * This library is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU Lesser General Public License as 10 | * published by the Free Software Foundation; either version 2.1 of the 11 | * License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, but 14 | * WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Lesser General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Lesser General Public 19 | * License along with this library; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 21 | * 02110-1301 USA 22 | */ 23 | 24 | #include 25 | #include 26 | 27 | uint16_t udf_crc (unsigned char *buffer, 28 | size_t size); 29 | -------------------------------------------------------------------------------- /libfprint/drivers/upektc_img.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Upek TouchChip Fingerprint Coprocessor definitions 3 | * Copyright (c) 2013 Vasily Khoruzhick 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | static const unsigned char upek2020_init_1[] = { 23 | 'C', 'i', 'a', 'o', 24 | 0x04, 25 | 0x00, 0x0d, 26 | 0x01, 0x00, 0x46, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 27 | 0x01, 0x00, 0x00, 0x00, 28 | 0xda, 0xc1 29 | }; 30 | 31 | static const unsigned char upek2020_init_2[] = { 32 | 0x43, 0x69, 0x61, 0x6f, 33 | 0x07, 34 | 0x00, 0x01, 35 | 0x01, 36 | 0x3d, 0x72 37 | }; 38 | 39 | static const unsigned char upek2020_init_3[] = { 40 | 'C', 'i', 'a', 'o', 41 | 0x04, 42 | 0x00, 0x0d, 43 | 0x01, 0x00, 0xbc, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 44 | 0x01, 0x00, 0x00, 0x00, 45 | 0x55, 0x2f 46 | }; 47 | 48 | static const unsigned char upek2020_init_4[] = { 49 | 'C', 'i', 'a', 'o', 50 | 0x00, 51 | 0x00, 0x07, 52 | 0x28, 0x04, 0x00, 0x00, 0x00, 0x06, 0x04, 53 | 0xc0, 0xd6 54 | }; 55 | 56 | static const unsigned char upek2020_deinit[] = { 57 | 'C', 'i', 'a', 'o', 58 | 0x07, 59 | 0x00, 0x01, 60 | 0x01, 61 | 0x3d, 62 | 0x72 63 | }; 64 | 65 | static const unsigned char upek2020_init_capture[] = { 66 | 'C', 'i', 'a', 'o', 67 | 0x00, 68 | 0x00, 0x0e, /* Seq = 7, len = 0x00e */ 69 | 0x28, /* CMD = 0x28 */ 70 | 0x0b, 0x00, /* Inner len = 0x000b */ 71 | 0x00, 0x00, 72 | 0x0e, /* SUBCMD = 0x0e */ 73 | 0x02, 74 | 0xfe, 0xff, 0xff, 0xff, /* timeout = -2 = 0xfffffffe = infinite time */ 75 | 0x02, 76 | 0x00, /* Wait for acceptable finger */ 77 | 0x02, 78 | 0x14, 0x9a /* CRC */ 79 | }; 80 | 81 | #if 0 82 | static const unsigned char finger_status[] = { 83 | 'C', 'i', 'a', 'o', 84 | 0x00, 85 | 0x70, 0x14, /* Seq = 7, len = 0x014 */ 86 | 0x28, /* CMD = 0x28 */ 87 | 0x11, 0x00, /* Inner len = 0x0011 */ 88 | 0x00, 0x00, 0x00, 0x20, 0x01, 0x00, 0x00, 0x00, 89 | 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 90 | 0x00, 91 | 0x26, 0x03, /* CRC */ 92 | 0x00, 0x00, 0x00, /* Rest is garbage */ 93 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 94 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 95 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 96 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 97 | }; 98 | #endif 99 | 100 | static const unsigned char upek2020_ack_00_28[] = { 101 | 'C', 'i', 'a', 'o', 102 | 0x00, 103 | 0x80, 0x08, /* Seq = 8, len = 0x008 */ 104 | 0x28, /* CMD = 0x28 */ 105 | 0x05, 0x00, /* Inner len = 0x0005 */ 106 | 0x00, 0x00, 0x00, 0x30, 0x01, 107 | 0x6a, 0xc4 /* CRC */ 108 | }; 109 | 110 | #if 0 111 | /* No seq should be tracked here */ 112 | static const unsigned char got_finger[] = { 113 | 'C', 'i', 'a', 'o', 114 | 0x08, 115 | 0x00, 0x00, /* Seq = 0, len = 0x000 */ 116 | 0xa1, 0xa9, /* CRC */ 117 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* Rest is garbage */ 118 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 119 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 120 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 121 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 122 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 123 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 124 | }; 125 | #endif 126 | 127 | /* No seq should be put in there */ 128 | static const unsigned char upek2020_ack_08[] = { 129 | 'C', 'i', 'a', 'o', 130 | 0x09, 131 | 0x00, 0x00, /* Seq = 0, len = 0x0 */ 132 | 0x91, 0x9e /* CRC */ 133 | }; 134 | 135 | static const unsigned char upek2020_ack_frame[] = { 136 | 'C', 'i', 'a', 'o', 137 | 0x00, 138 | 0x50, 0x01, /* Seq = 5, len = 0x001 */ 139 | 0x30, 140 | 0xac, 0x5b /* CRC */ 141 | }; 142 | -------------------------------------------------------------------------------- /libfprint/drivers/vfs301.h: -------------------------------------------------------------------------------- 1 | /* 2 | * vfs301/vfs300 fingerprint reader driver 3 | * https://github.com/andree182/vfs301 4 | * 5 | * Copyright (c) 2011-2012 Andrej Krutak 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "fpi-usb-transfer.h" 25 | #include "fpi-image-device.h" 26 | 27 | enum { 28 | VFS301_DEFAULT_WAIT_TIMEOUT = 300, 29 | 30 | VFS301_SEND_ENDPOINT = 0x01, 31 | VFS301_RECEIVE_ENDPOINT_CTRL = 0x81, 32 | VFS301_RECEIVE_ENDPOINT_DATA = 0x82 33 | }; 34 | 35 | #define VFS301_FP_RECV_LEN_1 (84032) 36 | #define VFS301_FP_RECV_LEN_2 (84096) 37 | 38 | struct _FpDeviceVfs301 39 | { 40 | FpImageDevice parent; 41 | 42 | /* buffer to hold raw scanlines */ 43 | unsigned char *scanline_buf; 44 | int scanline_count; 45 | 46 | enum { 47 | VFS301_ONGOING = 0, 48 | VFS301_ENDED = 1, 49 | VFS301_FAILURE = -1 50 | } recv_progress; 51 | int recv_exp_amt; 52 | }; 53 | 54 | G_DECLARE_FINAL_TYPE (FpDeviceVfs301, fpi_device_vfs301, FPI, DEVICE_VFS301, FpImageDevice) 55 | 56 | enum { 57 | /* Width of the scanned data in px */ 58 | VFS301_FP_WIDTH = 200, 59 | 60 | /* sizeof(fp_line_t) */ 61 | VFS301_FP_FRAME_SIZE = 288, 62 | /* Width of output line */ 63 | #ifndef OUTPUT_RAW 64 | VFS301_FP_OUTPUT_WIDTH = VFS301_FP_WIDTH, 65 | #else 66 | VFS301_FP_OUTPUT_WIDTH = VFS301_FP_FRAME_SIZE, 67 | #endif 68 | 69 | VFS301_FP_SUM_LINES = 3, 70 | 71 | #ifdef SCAN_FINISH_DETECTION 72 | /* TODO: The following changes (seen ~60 and ~80) In that 73 | * case we'll need to calibrate this from empty data somehow... */ 74 | VFS301_FP_SUM_MEDIAN = 60, 75 | VFS301_FP_SUM_EMPTY_RANGE = 5, 76 | #endif 77 | 78 | /* Minimum average difference between returned lines */ 79 | VFS301_FP_LINE_DIFF_THRESHOLD = 15, 80 | 81 | /* Maximum waiting time for a single fingerprint frame */ 82 | VFS301_FP_RECV_TIMEOUT = 2000 83 | }; 84 | 85 | /* Arrays of this structure is returned during the initialization as a response 86 | * to the 0x02D0 messages. 87 | * It seems to be always the same - what is it for? Some kind of confirmation? 88 | */ 89 | typedef struct 90 | { 91 | unsigned char sync_0x01; 92 | unsigned char sync_0xfe; 93 | 94 | unsigned char counter_lo; 95 | unsigned char counter_hi; /* FIXME ? */ 96 | 97 | unsigned char flags[3]; 98 | 99 | unsigned char sync_0x00; 100 | 101 | unsigned char scan[VFS301_FP_WIDTH]; 102 | } vfs301_init_line_t; 103 | 104 | typedef struct 105 | { 106 | unsigned char sync_0x01; 107 | unsigned char sync_0xfe; 108 | 109 | unsigned char counter_lo; 110 | unsigned char counter_hi; 111 | 112 | unsigned char sync_0x08[2]; /* XXX: always? 0x08 0x08 */ 113 | /* 0x08 | 0x18 - Looks like 0x08 marks good quality lines */ 114 | unsigned char flag_1; 115 | unsigned char sync_0x00; 116 | 117 | unsigned char scan[VFS301_FP_WIDTH]; 118 | 119 | /* A offsetted, stretched, inverted copy of scan... probably could 120 | * serve finger motion speed detection? 121 | * Seems to be subdivided to some 10B + 53B + 1B blocks */ 122 | unsigned char mirror[64]; 123 | 124 | /* Some kind of sum of the scan, very low contrast */ 125 | unsigned char sum1[2]; 126 | unsigned char sum2[11]; 127 | unsigned char sum3[3]; 128 | } vfs301_line_t; 129 | 130 | void vfs301_proto_init (FpDeviceVfs301 *dev); 131 | void vfs301_proto_deinit (FpDeviceVfs301 *dev); 132 | 133 | void vfs301_proto_request_fingerprint (FpDeviceVfs301 *dev); 134 | 135 | /** returns 0 if no event is ready, or 1 if there is one... */ 136 | int vfs301_proto_peek_event (FpDeviceVfs301 *dev); 137 | void vfs301_proto_process_event_start (FpDeviceVfs301 *dev); 138 | int vfs301_proto_process_event_poll (FpDeviceVfs301 *dev); 139 | 140 | void vfs301_extract_image (FpDeviceVfs301 *vfs, 141 | unsigned char *output, 142 | int *output_height); 143 | -------------------------------------------------------------------------------- /libfprint/drivers_api.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Driver API definitions 3 | * Copyright (C) 2007-2008 Daniel Drake 4 | * Copyright (C) 2018 Bastien Nocera 5 | * Copyright (C) 2019 Marco Trevisan 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #pragma once 23 | 24 | #include "fpi-compat.h" 25 | #include "fpi-assembling.h" 26 | #include "fpi-device.h" 27 | #include "fpi-image-device.h" 28 | #include "fpi-image.h" 29 | #include "fpi-log.h" 30 | #include "fpi-print.h" 31 | #include "fpi-usb-transfer.h" 32 | #include "fpi-spi-transfer.h" 33 | #include "fpi-ssm.h" 34 | -------------------------------------------------------------------------------- /libfprint/empty_file: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /libfprint/fp-context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpContext - A FPrint context 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "fp-device.h" 23 | 24 | G_BEGIN_DECLS 25 | 26 | #define FP_TYPE_CONTEXT (fp_context_get_type ()) 27 | G_DECLARE_DERIVABLE_TYPE (FpContext, fp_context, FP, CONTEXT, GObject) 28 | 29 | /** 30 | * FpContextClass: 31 | * @device_added: Called when a new device is added 32 | * @device_removed: Called when a device is removed 33 | * 34 | * Class structure for #FpContext instances. 35 | */ 36 | struct _FpContextClass 37 | { 38 | GObjectClass parent_class; 39 | 40 | void (*device_added) (FpContext *context, 41 | FpDevice *device); 42 | void (*device_removed) (FpContext *context, 43 | FpDevice *device); 44 | }; 45 | 46 | FpContext *fp_context_new (void); 47 | 48 | void fp_context_enumerate (FpContext *context); 49 | 50 | GPtrArray *fp_context_get_devices (FpContext *context); 51 | 52 | G_END_DECLS 53 | -------------------------------------------------------------------------------- /libfprint/fp-device-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpDevice - A fingerprint reader device 3 | * Copyright (C) 2019 Benjamin Berg 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "fpi-device.h" 24 | 25 | /* Chosen so that if we turn on after WARM -> COLD, it takes exactly one time 26 | * constant to go from COLD -> HOT. 27 | * TEMP_COLD_THRESH = 1 / (e + 1) 28 | */ 29 | #define TEMP_COLD_THRESH (0.26894142136999512075) 30 | #define TEMP_WARM_HOT_THRESH (1.0 - TEMP_COLD_THRESH) 31 | #define TEMP_HOT_WARM_THRESH (0.5) 32 | 33 | /* Delay updates by 100ms to avoid hitting the border exactly */ 34 | #define TEMP_DELAY_SECONDS 0.1 35 | 36 | /* Hopefully 3min is long enough to not get in the way, while also not 37 | * properly overheating any devices. 38 | */ 39 | #define DEFAULT_TEMP_HOT_SECONDS (3 * 60) 40 | #define DEFAULT_TEMP_COLD_SECONDS (9 * 60) 41 | 42 | typedef struct 43 | { 44 | FpDeviceType type; 45 | 46 | GUsbDevice *usb_device; 47 | const gchar *virtual_env; 48 | struct 49 | { 50 | gchar *spidev_path; 51 | gchar *hidraw_path; 52 | } udev_data; 53 | 54 | gboolean is_removed; 55 | gboolean is_open; 56 | gboolean is_suspended; 57 | 58 | gchar *device_id; 59 | gchar *device_name; 60 | FpScanType scan_type; 61 | FpDeviceFeature features; 62 | 63 | guint64 driver_data; 64 | 65 | gint nr_enroll_stages; 66 | GSList *sources; 67 | 68 | /* We always make sure that only one task is run at a time. */ 69 | FpiDeviceAction current_action; 70 | GTask *current_task; 71 | GError *current_cancellation_reason; 72 | GAsyncReadyCallback current_user_cb; 73 | GCancellable *current_cancellable; 74 | gulong current_cancellable_id; 75 | gulong current_task_cancellable_id; 76 | GSource *current_idle_cancel_source; 77 | GSource *current_task_idle_return_source; 78 | 79 | /* State for tasks */ 80 | gboolean wait_for_finger; 81 | FpFingerStatusFlags finger_status; 82 | 83 | /* Driver critical sections */ 84 | guint critical_section; 85 | GSource *critical_section_flush_source; 86 | gboolean cancel_queued; 87 | gboolean suspend_queued; 88 | gboolean resume_queued; 89 | 90 | /* Suspend/resume tasks */ 91 | GTask *suspend_resume_task; 92 | GError *suspend_error; 93 | 94 | /* Device temperature model information and state */ 95 | GSource *temp_timeout; 96 | FpTemperature temp_current; 97 | gint32 temp_hot_seconds; 98 | gint32 temp_cold_seconds; 99 | gint64 temp_last_update; 100 | gboolean temp_last_active; 101 | gdouble temp_current_ratio; 102 | } FpDevicePrivate; 103 | 104 | 105 | typedef struct 106 | { 107 | FpPrint *print; 108 | 109 | FpEnrollProgress enroll_progress_cb; 110 | gpointer enroll_progress_data; 111 | GDestroyNotify enroll_progress_destroy; 112 | } FpEnrollData; 113 | 114 | typedef struct 115 | { 116 | FpPrint *enrolled_print; /* verify */ 117 | GPtrArray *gallery; /* identify */ 118 | 119 | gboolean result_reported; 120 | FpPrint *match; 121 | FpPrint *print; 122 | GError *error; 123 | 124 | FpMatchCb match_cb; 125 | gpointer match_data; 126 | GDestroyNotify match_destroy; 127 | } FpMatchData; 128 | 129 | 130 | void fpi_device_suspend (FpDevice *device); 131 | void fpi_device_resume (FpDevice *device); 132 | 133 | void fpi_device_configure_wakeup (FpDevice *device, 134 | gboolean enabled); 135 | void fpi_device_update_temp (FpDevice *device, 136 | gboolean is_active); 137 | -------------------------------------------------------------------------------- /libfprint/fp-image-device-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpImageDevice - An image based fingerprint reader device 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "fpi-image-device.h" 23 | 24 | #define IMG_ENROLL_STAGES 5 25 | 26 | typedef struct 27 | { 28 | FpiImageDeviceState state; 29 | gboolean active; 30 | 31 | gboolean finger_present; 32 | 33 | gint enroll_stage; 34 | 35 | gboolean minutiae_scan_active; 36 | GError *action_error; 37 | FpImage *capture_image; 38 | 39 | gint bz3_threshold; 40 | } FpImageDevicePrivate; 41 | 42 | 43 | void fpi_image_device_activate (FpImageDevice *image_device); 44 | void fpi_image_device_deactivate (FpImageDevice *image_device, 45 | gboolean cancelling); 46 | -------------------------------------------------------------------------------- /libfprint/fp-image-device.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpImageDevice - An image based fingerprint reader device 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "fp-device.h" 23 | 24 | G_BEGIN_DECLS 25 | 26 | #define FP_TYPE_IMAGE_DEVICE (fp_image_device_get_type ()) 27 | G_DECLARE_DERIVABLE_TYPE (FpImageDevice, fp_image_device, FP, IMAGE_DEVICE, FpDevice) 28 | 29 | G_END_DECLS 30 | -------------------------------------------------------------------------------- /libfprint/fp-image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint Image 3 | * Copyright (C) 2007 Daniel Drake 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include 24 | 25 | G_BEGIN_DECLS 26 | 27 | #define FP_TYPE_IMAGE (fp_image_get_type ()) 28 | 29 | typedef struct fp_minutia FpMinutia; 30 | 31 | G_DECLARE_FINAL_TYPE (FpImage, fp_image, FP, IMAGE, GObject) 32 | 33 | FpImage *fp_image_new (gint width, 34 | gint height); 35 | 36 | guint fp_image_get_width (FpImage *self); 37 | guint fp_image_get_height (FpImage *self); 38 | gdouble fp_image_get_ppmm (FpImage *self); 39 | 40 | GPtrArray * fp_image_get_minutiae (FpImage *self); 41 | 42 | void fp_image_detect_minutiae (FpImage *self, 43 | GCancellable *cancellable, 44 | GAsyncReadyCallback callback, 45 | gpointer user_data); 46 | gboolean fp_image_detect_minutiae_finish (FpImage *self, 47 | GAsyncResult *result, 48 | GError **error); 49 | 50 | const guchar * fp_image_get_data (FpImage *self, 51 | gsize *len); 52 | const guchar * fp_image_get_binarized (FpImage *self, 53 | gsize *len); 54 | 55 | void fp_minutia_get_coords (FpMinutia *min, 56 | gint *x, 57 | gint *y); 58 | 59 | G_END_DECLS 60 | -------------------------------------------------------------------------------- /libfprint/fp-print-private.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint Print handling 3 | * Copyright (C) 2007 Daniel Drake 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #include "fpi-print.h" 22 | #include "fpi-image.h" 23 | 24 | #include 25 | 26 | struct _FpPrint 27 | { 28 | GInitiallyUnowned parent_instance; 29 | 30 | FpiPrintType type; 31 | 32 | gchar *driver; 33 | gchar *device_id; 34 | gboolean device_stored; 35 | 36 | FpImage *image; 37 | 38 | /* Metadata */ 39 | FpFinger finger; 40 | gchar *username; 41 | gchar *description; 42 | GDate *enroll_date; 43 | 44 | GVariant *data; 45 | GPtrArray *prints; 46 | }; 47 | -------------------------------------------------------------------------------- /libfprint/fp-print.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint Print handling 3 | * Copyright (C) 2007 Daniel Drake 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "fp-image.h" 24 | #include "fp-enums.h" 25 | 26 | G_BEGIN_DECLS 27 | 28 | #define FP_TYPE_PRINT (fp_print_get_type ()) 29 | G_DECLARE_FINAL_TYPE (FpPrint, fp_print, FP, PRINT, GInitiallyUnowned) 30 | 31 | #define FP_FINGER_IS_VALID(finger) \ 32 | ((finger) >= FP_FINGER_FIRST && (finger) <= FP_FINGER_LAST) 33 | 34 | #include "fp-device.h" 35 | 36 | /** 37 | * FpFinger: 38 | * @FP_FINGER_UNKNOWN: The finger is unknown 39 | * @FP_FINGER_LEFT_THUMB: Left thumb 40 | * @FP_FINGER_LEFT_INDEX: Left index finger 41 | * @FP_FINGER_LEFT_MIDDLE: Left middle finger 42 | * @FP_FINGER_LEFT_RING: Left ring finger 43 | * @FP_FINGER_LEFT_LITTLE: Left little finger 44 | * @FP_FINGER_RIGHT_THUMB: Right thumb 45 | * @FP_FINGER_RIGHT_INDEX: Right index finger 46 | * @FP_FINGER_RIGHT_MIDDLE: Right middle finger 47 | * @FP_FINGER_RIGHT_RING: Right ring finger 48 | * @FP_FINGER_RIGHT_LITTLE: Right little finger 49 | * @FP_FINGER_FIRST: The first finger in the fp-print order 50 | * @FP_FINGER_LAST: The last finger in the fp-print order 51 | */ 52 | typedef enum { 53 | FP_FINGER_UNKNOWN = 0, 54 | FP_FINGER_LEFT_THUMB, 55 | FP_FINGER_LEFT_INDEX, 56 | FP_FINGER_LEFT_MIDDLE, 57 | FP_FINGER_LEFT_RING, 58 | FP_FINGER_LEFT_LITTLE, 59 | FP_FINGER_RIGHT_THUMB, 60 | FP_FINGER_RIGHT_INDEX, 61 | FP_FINGER_RIGHT_MIDDLE, 62 | FP_FINGER_RIGHT_RING, 63 | FP_FINGER_RIGHT_LITTLE, 64 | 65 | FP_FINGER_FIRST = FP_FINGER_LEFT_THUMB, 66 | FP_FINGER_LAST = FP_FINGER_RIGHT_LITTLE, 67 | } FpFinger; 68 | 69 | /** 70 | * FpFingerStatusFlags: 71 | * @FP_FINGER_STATUS_NONE: Sensor has not the finger on it, nor requires it 72 | * @FP_FINGER_STATUS_NEEDED: Sensor waits for the finger 73 | * @FP_FINGER_STATUS_PRESENT: Sensor has the finger on it 74 | */ 75 | typedef enum { 76 | FP_FINGER_STATUS_NONE = 0, 77 | FP_FINGER_STATUS_NEEDED = 1 << 0, 78 | FP_FINGER_STATUS_PRESENT = 1 << 1, 79 | } FpFingerStatusFlags; 80 | 81 | FpPrint *fp_print_new (FpDevice *device); 82 | 83 | const gchar *fp_print_get_driver (FpPrint *print); 84 | const gchar *fp_print_get_device_id (FpPrint *print); 85 | FpImage *fp_print_get_image (FpPrint *print); 86 | 87 | FpFinger fp_print_get_finger (FpPrint *print); 88 | const gchar *fp_print_get_username (FpPrint *print); 89 | const gchar *fp_print_get_description (FpPrint *print); 90 | const GDate *fp_print_get_enroll_date (FpPrint *print); 91 | gboolean fp_print_get_device_stored (FpPrint *print); 92 | 93 | void fp_print_set_finger (FpPrint *print, 94 | FpFinger finger); 95 | void fp_print_set_username (FpPrint *print, 96 | const gchar *username); 97 | void fp_print_set_description (FpPrint *print, 98 | const gchar *description); 99 | void fp_print_set_enroll_date (FpPrint *print, 100 | const GDate *enroll_date); 101 | 102 | gboolean fp_print_compatible (FpPrint *self, 103 | FpDevice *device); 104 | gboolean fp_print_equal (FpPrint *self, 105 | FpPrint *other); 106 | 107 | gboolean fp_print_serialize (FpPrint *print, 108 | guchar **data, 109 | gsize *length, 110 | GError **error); 111 | 112 | FpPrint *fp_print_deserialize (const guchar *data, 113 | gsize length, 114 | GError **error); 115 | 116 | G_END_DECLS 117 | -------------------------------------------------------------------------------- /libfprint/fpi-compat.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 Benjamin Berg 3 | * 4 | * This library is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU Lesser General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2.1 of the License, or (at your option) any later version. 8 | * 9 | * This library is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * Lesser General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU Lesser General Public 15 | * License along with this library; if not, write to the Free Software 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #if !GLIB_CHECK_VERSION (2, 57, 0) 24 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GTypeClass, g_type_class_unref); 25 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GEnumClass, g_type_class_unref); 26 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GFlagsClass, g_type_class_unref); 27 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GParamSpec, g_param_spec_unref); 28 | #else 29 | /* Re-define G_SOURCE_FUNC as we are technically not allowed to use it with 30 | * the version we depend on currently. */ 31 | #undef G_SOURCE_FUNC 32 | #endif 33 | 34 | #define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void))(f)) 35 | 36 | #if !GLIB_CHECK_VERSION (2, 63, 3) 37 | typedef struct _FpDeviceClass FpDeviceClass; 38 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpDeviceClass, g_type_class_unref); 39 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (GDate, g_date_free); 40 | #endif 41 | 42 | #if !GLIB_CHECK_VERSION (2, 68, 0) 43 | #define g_memdup2(data, size) g_memdup ((data), (size)) 44 | #else 45 | #define g_memdup2(data, size) \ 46 | (G_GNUC_EXTENSION ({ \ 47 | G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ 48 | g_memdup2 ((data), (size)); \ 49 | G_GNUC_END_IGNORE_DEPRECATIONS \ 50 | })) 51 | #endif 52 | 53 | #if __GNUC__ > 10 || (__GNUC__ == 10 && __GNUC_MINOR__ >= 1) 54 | #define FP_GNUC_ACCESS(m, p, s) __attribute__((access (m, p, s))) 55 | #else 56 | #define FP_GNUC_ACCESS(m, p, s) 57 | #endif 58 | -------------------------------------------------------------------------------- /libfprint/fpi-context.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FpContext - A FPrint context 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | #pragma once 20 | 21 | #include 22 | #include "fp-context.h" 23 | #include "fpi-compat.h" 24 | 25 | /** 26 | * fpi_get_driver_types: 27 | * 28 | * This function is purely for private used. It is solely part of the public 29 | * API as it is useful during build time. 30 | * 31 | * Stability: private 32 | * Returns: (element-type GType) (transfer container): a #GArray filled with 33 | * all driver types 34 | */ 35 | GArray *fpi_get_driver_types (void); 36 | -------------------------------------------------------------------------------- /libfprint/fpi-image.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint Image 3 | * Copyright (C) 2007 Daniel Drake 4 | * Copyright (C) 2019 Benjamin Berg 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "fp-image.h" 24 | 25 | /** 26 | * FpiImageFlags: 27 | * @FPI_IMAGE_V_FLIPPED: the image is vertically flipped 28 | * @FPI_IMAGE_H_FLIPPED: the image is horizontally flipped 29 | * @FPI_IMAGE_COLORS_INVERTED: the colours are inverted 30 | * 31 | * Flags used in an #FpImage structure to describe the contained image. 32 | * This is useful for image drivers as they can simply set these flags and 33 | * rely on the image to be normalized by libfprint before further processing. 34 | */ 35 | typedef enum { 36 | FPI_IMAGE_V_FLIPPED = 1 << 0, 37 | FPI_IMAGE_H_FLIPPED = 1 << 1, 38 | FPI_IMAGE_COLORS_INVERTED = 1 << 2, 39 | FPI_IMAGE_PARTIAL = 1 << 3, 40 | } FpiImageFlags; 41 | 42 | /** 43 | * FpImage: 44 | * @width: Width of the image 45 | * @height: Height of the image 46 | * @ppmm: Pixels per millimeter 47 | * @flags: #FpiImageFlags for required normalization 48 | * 49 | * Structure holding an image. The public fields are only public for internal 50 | * use by the drivers. 51 | */ 52 | struct _FpImage 53 | { 54 | /*< private >*/ 55 | GObject parent; 56 | 57 | /*< public >*/ 58 | guint width; 59 | guint height; 60 | 61 | gdouble ppmm; 62 | 63 | FpiImageFlags flags; 64 | 65 | /*< private >*/ 66 | guint8 *data; 67 | guint8 *binarized; 68 | 69 | GPtrArray *minutiae; 70 | guint ref_count; 71 | }; 72 | 73 | gint fpi_std_sq_dev (const guint8 *buf, 74 | gint size); 75 | gint fpi_mean_sq_diff_norm (const guint8 *buf1, 76 | const guint8 *buf2, 77 | gint size); 78 | 79 | FpImage *fpi_image_resize (FpImage *orig, 80 | guint w_factor, 81 | guint h_factor); 82 | -------------------------------------------------------------------------------- /libfprint/fpi-log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2007-2008 Daniel Drake 3 | * Copyright (C) 2018 Bastien Nocera 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | /** 23 | * SECTION:fpi-log 24 | * @title: Logging 25 | * @short_description: Logging functions 26 | * 27 | * Logging in libfprint is handled through GLib's logging system, and behave the same 28 | * way as in the GLib [Message Output and Debugging Functions](https://developer.gnome.org/glib/stable/glib-Message-Logging.html) 29 | * documentation. 30 | * 31 | * You should include `fpi-log.h` as early as possible in your sources, just after 32 | * setting the `FP_COMPONENT` define to a string unique to your sources. This will 33 | * set the suffix of the `G_LOG_DOMAIN` used for printing. 34 | */ 35 | 36 | #ifdef FP_COMPONENT 37 | #undef G_LOG_DOMAIN 38 | #ifndef __GTK_DOC_IGNORE__ 39 | #define G_LOG_DOMAIN "libfprint-"FP_COMPONENT 40 | #endif 41 | #endif 42 | 43 | #include 44 | 45 | /** 46 | * fp_dbg: 47 | * 48 | * Same as g_debug(). 49 | * 50 | */ 51 | #define fp_dbg g_debug 52 | 53 | /** 54 | * fp_info: 55 | * 56 | * Same as g_debug(). 57 | */ 58 | #define fp_info g_debug 59 | 60 | /** 61 | * fp_warn: 62 | * 63 | * Same as g_warning(). 64 | */ 65 | #define fp_warn g_warning 66 | 67 | /** 68 | * fp_err: 69 | * 70 | * Same as g_critical(). In the future, this might be changed to a 71 | * g_assert() instead, so bear this in mind when adding those calls 72 | * to your driver. 73 | */ 74 | #define fp_err g_critical 75 | 76 | /** 77 | * BUG_ON: 78 | * @condition: the condition to check 79 | * 80 | * Uses fp_err() to print an error if the @condition is true. 81 | */ 82 | #define BUG_ON(condition) G_STMT_START \ 83 | if (condition) { \ 84 | char *s; \ 85 | s = g_strconcat ("BUG: (", #condition, ")", NULL); \ 86 | fp_err ("%s: %s() %s:%d", s, G_STRFUNC, __FILE__, __LINE__); \ 87 | g_free (s); \ 88 | } G_STMT_END 89 | 90 | /** 91 | * BUG: 92 | * 93 | * Same as BUG_ON() but is always true. 94 | */ 95 | #define BUG() BUG_ON (1) 96 | -------------------------------------------------------------------------------- /libfprint/fpi-minutiae.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Internal/private definitions for libfprint 3 | * Copyright (C) 2007-2008 Daniel Drake 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | /* fp_minutia structure definition */ 23 | struct fp_minutia 24 | { 25 | int x; 26 | int y; 27 | int ex; 28 | int ey; 29 | int direction; 30 | double reliability; 31 | int type; 32 | int appearing; 33 | int feature_id; 34 | int *nbrs; 35 | int *ridge_counts; 36 | int num_nbrs; 37 | }; 38 | 39 | /* fp_minutiae structure definition */ 40 | struct fp_minutiae 41 | { 42 | int alloc; 43 | int num; 44 | struct fp_minutia **list; 45 | }; 46 | -------------------------------------------------------------------------------- /libfprint/fpi-print.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "fpi-enums.h" 4 | #include "fp-device.h" 5 | #include "fp-print.h" 6 | 7 | G_BEGIN_DECLS 8 | 9 | /** 10 | * FpiPrintType: 11 | * @FPI_PRINT_UNDEFINED: Undefined type, this happens prior to enrollment 12 | * @FPI_PRINT_RAW: A raw print where the data is directly compared 13 | * @FPI_PRINT_NBIS: NBIS minutiae comparison 14 | */ 15 | typedef enum { 16 | FPI_PRINT_UNDEFINED = 0, 17 | FPI_PRINT_RAW, 18 | FPI_PRINT_NBIS, 19 | } FpiPrintType; 20 | 21 | /** 22 | * FpiMatchResult: 23 | * @FPI_MATCH_ERROR: An error occurred during matching 24 | * @FPI_MATCH_FAIL: The prints did not match 25 | * @FPI_MATCH_SUCCESS: The prints matched 26 | */ 27 | typedef enum { 28 | FPI_MATCH_ERROR = -1, /* -1 for g_task_propagate_int */ 29 | FPI_MATCH_FAIL, 30 | FPI_MATCH_SUCCESS, 31 | } FpiMatchResult; 32 | 33 | void fpi_print_add_print (FpPrint *print, 34 | FpPrint *add); 35 | 36 | void fpi_print_set_type (FpPrint *print, 37 | FpiPrintType type); 38 | void fpi_print_set_device_stored (FpPrint *print, 39 | gboolean device_stored); 40 | 41 | gboolean fpi_print_add_from_image (FpPrint *print, 42 | FpImage *image, 43 | GError **error); 44 | 45 | FpiMatchResult fpi_print_bz3_match (FpPrint *temp, 46 | FpPrint *print, 47 | gint bz3_threshold, 48 | GError **error); 49 | 50 | /* Helpers to encode metadata into user ID strings. */ 51 | gchar * fpi_print_generate_user_id (FpPrint *print); 52 | gboolean fpi_print_fill_from_user_id (FpPrint *print, 53 | const char *user_id); 54 | 55 | G_END_DECLS 56 | -------------------------------------------------------------------------------- /libfprint/fpi-spi-transfer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * FPrint spidev transfer handling 3 | * Copyright (C) 2019-2020 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "fpi-compat.h" 23 | #include "fpi-device.h" 24 | 25 | G_BEGIN_DECLS 26 | 27 | #define FPI_TYPE_SPI_TRANSFER (fpi_spi_transfer_get_type ()) 28 | 29 | typedef struct _FpiSpiTransfer FpiSpiTransfer; 30 | typedef struct _FpiSsm FpiSsm; 31 | 32 | typedef void (*FpiSpiTransferCallback)(FpiSpiTransfer *transfer, 33 | FpDevice *dev, 34 | gpointer user_data, 35 | GError *error); 36 | 37 | /** 38 | * FpiSpiTransfer: 39 | * @device: The #FpDevice that the transfer belongs to. 40 | * @ssm: Storage slot to associate the transfer with a state machine. 41 | * Used by fpi_ssm_spi_transfer_cb() to modify the given state machine. 42 | * @length_wr: The length of the write buffer 43 | * @length_rd: The length of the read buffer 44 | * @buffer_wr: The write buffer. 45 | * @buffer_rd: The read buffer. 46 | * 47 | * Helper for handling SPI transfers. Currently transfers can either be pure 48 | * write/read transfers or a write followed by a read (full duplex support 49 | * can easily be added if desired). 50 | */ 51 | struct _FpiSpiTransfer 52 | { 53 | /*< public >*/ 54 | FpDevice *device; 55 | 56 | FpiSsm *ssm; 57 | 58 | gssize length_wr; 59 | gssize length_rd; 60 | 61 | guchar *buffer_wr; 62 | guchar *buffer_rd; 63 | 64 | /*< private >*/ 65 | guint ref_count; 66 | 67 | int spidev_fd; 68 | 69 | /* Callbacks */ 70 | gpointer user_data; 71 | FpiSpiTransferCallback callback; 72 | 73 | /* Data free function */ 74 | GDestroyNotify free_buffer_wr; 75 | GDestroyNotify free_buffer_rd; 76 | }; 77 | 78 | GType fpi_spi_transfer_get_type (void) G_GNUC_CONST; 79 | FpiSpiTransfer *fpi_spi_transfer_new (FpDevice *device, 80 | int spidev_fd); 81 | FpiSpiTransfer *fpi_spi_transfer_ref (FpiSpiTransfer *self); 82 | void fpi_spi_transfer_unref (FpiSpiTransfer *self); 83 | 84 | void fpi_spi_transfer_write (FpiSpiTransfer *transfer, 85 | gsize length); 86 | 87 | FP_GNUC_ACCESS (read_only, 2, 3) 88 | void fpi_spi_transfer_write_full (FpiSpiTransfer *transfer, 89 | guint8 *buffer, 90 | gsize length, 91 | GDestroyNotify free_func); 92 | 93 | void fpi_spi_transfer_read (FpiSpiTransfer *transfer, 94 | gsize length); 95 | 96 | FP_GNUC_ACCESS (write_only, 2, 3) 97 | void fpi_spi_transfer_read_full (FpiSpiTransfer *transfer, 98 | guint8 *buffer, 99 | gsize length, 100 | GDestroyNotify free_func); 101 | 102 | void fpi_spi_transfer_submit (FpiSpiTransfer *transfer, 103 | GCancellable *cancellable, 104 | FpiSpiTransferCallback callback, 105 | gpointer user_data); 106 | 107 | gboolean fpi_spi_transfer_submit_sync (FpiSpiTransfer *transfer, 108 | GError **error); 109 | 110 | 111 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (FpiSpiTransfer, fpi_spi_transfer_unref) 112 | 113 | G_END_DECLS 114 | -------------------------------------------------------------------------------- /libfprint/fprint-list-udev-rules.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 Red Hat 3 | * Copyright (C) 2008 Bastien Nocera 4 | * Copyright (C) 2008 Timo Hoenig , 5 | * Coypright (C) 2019 Benjamin Berg 6 | * 7 | * This library is free software; you can redistribute it and/or 8 | * modify it under the terms of the GNU Lesser General Public 9 | * License as published by the Free Software Foundation; either 10 | * version 2.1 of the License, or (at your option) any later version. 11 | * 12 | * This library is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 | * Lesser General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU Lesser General Public 18 | * License along with this library; if not, write to the Free Software 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 | */ 21 | 22 | #include 23 | 24 | #include "fpi-context.h" 25 | #include "fpi-device.h" 26 | 27 | GHashTable *printed = NULL; 28 | 29 | static void 30 | print_driver (const FpDeviceClass *cls) 31 | { 32 | const FpIdEntry *entry; 33 | gint num_printed = 0; 34 | 35 | if (cls->type != FP_DEVICE_TYPE_UDEV) 36 | return; 37 | 38 | for (entry = cls->id_table; entry->udev_types != 0; entry++) 39 | { 40 | /* We only add rules for spidev right now. */ 41 | if ((entry->udev_types & FPI_DEVICE_UDEV_SUBTYPE_SPIDEV) == 0) 42 | continue; 43 | 44 | if (g_hash_table_lookup (printed, entry->spi_acpi_id) != NULL) 45 | continue; 46 | 47 | g_hash_table_insert (printed, g_strdup (entry->spi_acpi_id), GINT_TO_POINTER (1)); 48 | 49 | if (num_printed == 0) 50 | g_print ("# %s\n", cls->full_name); 51 | 52 | g_print ("ACTION==\"add|change\", SUBSYSTEM==\"spi\", ENV{MODALIAS}==\"acpi:%s:\", RUN{builtin}+=\"kmod load spi:spidev\", RUN+=\"/bin/sh -c 'echo spidev > %%S%%p/driver_override && echo %%k > %%S%%p/subsystem/drivers/spidev/bind'\"\n", 53 | entry->spi_acpi_id); 54 | num_printed++; 55 | } 56 | 57 | if (num_printed > 0) 58 | g_print ("\n"); 59 | } 60 | 61 | int 62 | main (int argc, char **argv) 63 | { 64 | g_autoptr(GArray) drivers = fpi_get_driver_types (); 65 | guint i; 66 | 67 | printed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); 68 | 69 | g_print ("# This file is part of libfprint\n"); 70 | g_print ("# Do not modify this file, it will get overwritten on updates.\n"); 71 | g_print ("# To override or extend the rules place a file in /etc/udev/rules.d\n"); 72 | g_print ("\n"); 73 | 74 | for (i = 0; i < drivers->len; i++) 75 | { 76 | GType driver = g_array_index (drivers, GType, i); 77 | FpDeviceClass *cls = FP_DEVICE_CLASS (g_type_class_ref (driver)); 78 | 79 | if (cls->type != FP_DEVICE_TYPE_UDEV) 80 | { 81 | g_type_class_unref (cls); 82 | continue; 83 | } 84 | 85 | print_driver (cls); 86 | 87 | g_type_class_unref (cls); 88 | } 89 | 90 | g_hash_table_destroy (printed); 91 | 92 | return 0; 93 | } 94 | -------------------------------------------------------------------------------- /libfprint/fprint.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Main definitions for libfprint 3 | * Copyright (C) 2019 Benjamin Berg 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #pragma once 21 | 22 | #include "fp-context.h" 23 | #include "fp-device.h" 24 | #include "fp-image.h" 25 | -------------------------------------------------------------------------------- /libfprint/libfprint.ver: -------------------------------------------------------------------------------- 1 | LIBFPRINT_2.0.0 { 2 | global: 3 | fp_*; 4 | local: 5 | *; 6 | }; 7 | -------------------------------------------------------------------------------- /libfprint/nbis/bozorth3/bz_alloc.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | /*********************************************************************** 45 | LIBRARY: FING - NIST Fingerprint Systems Utilities 46 | 47 | FILE: BZ_ALLOC.C 48 | ALGORITHM: Allan S. Bozorth (FBI) 49 | MODIFICATIONS: Michael D. Garris (NIST) 50 | Stan Janet (NIST) 51 | DATE: 09/21/2004 52 | 53 | Contains routines responsible for supporting the 54 | Bozorth3 fingerprint matching algorithm. 55 | 56 | *********************************************************************** 57 | 58 | ROUTINES: 59 | #cat: malloc_or_exit - allocates a buffer of bytes from the heap of 60 | #cat: specified length exiting directly upon system error 61 | #cat: malloc_or_return_error - allocates a buffer of bytes from the heap 62 | #cat: of specified length returning an error code upon system error 63 | 64 | ***********************************************************************/ 65 | 66 | #include 67 | #include 68 | #include 69 | 70 | 71 | /***********************************************************************/ 72 | 73 | /***********************************************************************/ 74 | /* returns CNULL on error */ 75 | -------------------------------------------------------------------------------- /libfprint/nbis/fix-musl-build.patch: -------------------------------------------------------------------------------- 1 | From 2584d440afc87d463cb8dc809d48c660e091c2c4 Mon Sep 17 00:00:00 2001 2 | From: Sam James 3 | Date: Thu, 23 Jun 2022 05:57:46 +0100 4 | Subject: [PATCH] nbis: fix build on musl 5 | 6 | Drop re-definition of stderr. There's no need for this anywhere 7 | (including glibc). This breaks in particular on musl because 8 | stderr (and stdin) are both const, and macros unlike in glibc. 9 | 10 | Bug: https://bugs.gentoo.org/853811 11 | --- 12 | nbis/include/bozorth.h | 2 -- 13 | 1 file changed, 2 deletions(-) 14 | 15 | diff --git a/nbis/include/bozorth.h b/nbis/include/bozorth.h 16 | index a705da98..fd8975bf 100644 17 | --- a/nbis/include/bozorth.h 18 | +++ b/nbis/include/bozorth.h 19 | @@ -217,8 +217,6 @@ struct xytq_struct { 20 | /**************************************************************************/ 21 | /* Globals supporting command line options */ 22 | extern int verbose_threshold; 23 | -/* Global supporting error reporting */ 24 | -extern FILE *stderr; 25 | 26 | /**************************************************************************/ 27 | /* In: BZ_GBLS.C */ 28 | -- 29 | GitLab 30 | 31 | 32 | -------------------------------------------------------------------------------- /libfprint/nbis/fix-scan-build-reports.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libfprint/nbis/mindtct/contour.c b/libfprint/nbis/mindtct/contour.c 2 | index 3e9416c..31f32d0 100644 3 | --- mindtct/contour.c 4 | +++ mindtct/contour.c 5 | @@ -440,6 +440,8 @@ int get_centered_contour(int **ocontour_x, int **ocontour_y, 6 | int *contour_x, *contour_y, *contour_ex, *contour_ey, ncontour; 7 | int i, j, ret; 8 | 9 | + g_assert (half_contour > 0); 10 | + 11 | /* Compute maximum length of complete contour */ 12 | /* (2 half contours + feature point). */ 13 | max_contour = (half_contour<<1) + 1; 14 | diff --git a/libfprint/nbis/mindtct/minutia.c b/libfprint/nbis/mindtct/minutia.c 15 | index 0b29aa0..77cf09d 100644 16 | --- mindtct/minutia.c 17 | +++ mindtct/minutia.c 18 | @@ -1625,7 +1625,7 @@ int process_horizontal_scan_minutia_V2(MINUTIAE *minutiae, 19 | dmapval, bdata, iw, ih, lfsparms); 20 | 21 | /* If minuitia IGNORED and not added to the minutia list ... */ 22 | - if(ret == IGNORE) 23 | + if(ret != 0) 24 | /* Deallocate the minutia. */ 25 | free_minutia(minutia); 26 | 27 | @@ -1776,7 +1776,7 @@ int process_vertical_scan_minutia_V2(MINUTIAE *minutiae, 28 | dmapval, bdata, iw, ih, lfsparms); 29 | 30 | /* If minuitia IGNORED and not added to the minutia list ... */ 31 | - if(ret == IGNORE) 32 | + if(ret != 0) 33 | /* Deallocate the minutia. */ 34 | free_minutia(minutia); 35 | 36 | diff --git a/libfprint/nbis/mindtct/ridges.c b/libfprint/nbis/mindtct/ridges.c 37 | index f0d9cd3..9902585 100644 38 | --- mindtct/ridges.c 39 | +++ mindtct/ridges.c 40 | @@ -147,6 +147,8 @@ int count_minutia_ridges(const int first, MINUTIAE *minutiae, 41 | { 42 | int i, ret, *nbr_list, *nbr_nridges, nnbrs; 43 | 44 | + g_assert (lfsparms->max_nbrs > 0); 45 | + 46 | /* Find up to the maximum number of qualifying neighbors. */ 47 | nbr_list = NULL; 48 | if((ret = find_neighbors(&nbr_list, &nnbrs, lfsparms->max_nbrs, 49 | @@ -407,6 +409,8 @@ int insert_neighbor(const int pos, const int nbr_index, const double nbr_dist2, 50 | { 51 | int i; 52 | 53 | + g_assert (pos >= 0); 54 | + 55 | /* If the desired insertion position is beyond one passed the last */ 56 | /* neighbor in the lists OR greater than equal to the maximum ... */ 57 | /* NOTE: pos is zero-oriented while nnbrs and max_nbrs are 1-oriented. */ 58 | -------------------------------------------------------------------------------- /libfprint/nbis/glib-mem-warning.patch: -------------------------------------------------------------------------------- 1 | diff --git a/libfprint/nbis/mindtct/shape.c b/libfprint/nbis/mindtct/shape.c 2 | index 28bc66c..c399f36 100644 3 | --- mindtct/shape.c 4 | +++ mindtct/shape.c 5 | @@ -86,7 +86,7 @@ int alloc_shape(SHAPE **oshape, const int xmin, const int ymin, 6 | { 7 | SHAPE *shape; 8 | int alloc_rows, alloc_pts; 9 | - int i, j, y; 10 | + int i, y; 11 | 12 | /* Compute allocation parameters. */ 13 | /* First, compute the number of scanlines spanned by the shape. */ 14 | -------------------------------------------------------------------------------- /libfprint/nbis/glib-memory.cocci: -------------------------------------------------------------------------------- 1 | @ free @ 2 | expression ptr; 3 | @@ 4 | - free(ptr); 5 | + g_free(ptr); 6 | @ malloc @ 7 | type ptr_type; 8 | expression ptr; 9 | expression size; 10 | @@ 11 | - ptr = (ptr_type) malloc(size); 12 | + ptr = (ptr_type) g_malloc(size); 13 | ... 14 | ( 15 | - if (ptr == (ptr_type) NULL) { ... } 16 | | 17 | ) 18 | @ realloc @ 19 | type ptr_type; 20 | expression ptr; 21 | expression size; 22 | @@ 23 | - ptr = (ptr_type) realloc(ptr, size); 24 | + ptr = (ptr_type) g_realloc(ptr, size); 25 | ... 26 | ( 27 | - if (ptr == (ptr_type) NULL) { ... } 28 | | 29 | ) 30 | -------------------------------------------------------------------------------- /libfprint/nbis/include/bz_array.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | #ifndef _BZ_ARRAY_H 45 | #define _BZ_ARRAY_H 46 | 47 | #define STATIC static 48 | /* #define BAD_BOUNDS 1 */ 49 | 50 | #define COLP_SIZE_1 20000 51 | #define COLP_SIZE_2 5 52 | 53 | #define COLS_SIZE_2 6 54 | #define SCOLS_SIZE_1 20000 55 | #define FCOLS_SIZE_1 20000 56 | 57 | #define SCOLPT_SIZE 20000 58 | #define FCOLPT_SIZE 20000 59 | 60 | #define SC_SIZE 20000 61 | 62 | 63 | #define RQ_SIZE 20000 64 | #define TQ_SIZE 20000 65 | #define ZZ_SIZE 20000 66 | 67 | 68 | 69 | #define RX_SIZE 100 70 | #define MM_SIZE 100 71 | #define NN_SIZE 20 72 | 73 | 74 | 75 | #define RK_SIZE 20000 76 | 77 | 78 | 79 | #define RR_SIZE 100 80 | #define AVN_SIZE 5 81 | #define AVV_SIZE_1 2000 82 | #define AVV_SIZE_2 5 83 | #define CT_SIZE 2000 84 | #define GCT_SIZE 2000 85 | #define CTT_SIZE 2000 86 | 87 | 88 | #ifdef BAD_BOUNDS 89 | #define CTP_SIZE_1 2000 90 | #define CTP_SIZE_2 1000 91 | #else 92 | #define CTP_SIZE_1 2000 93 | #define CTP_SIZE_2 2500 94 | #endif 95 | 96 | 97 | 98 | /* 99 | rp[x] == ctp[][x] :: sct[x][] 100 | */ 101 | 102 | 103 | 104 | 105 | #define RF_SIZE_1 100 106 | #define RF_SIZE_2 10 107 | 108 | #define CF_SIZE_1 100 109 | #define CF_SIZE_2 10 110 | 111 | #define Y_SIZE 20000 112 | 113 | 114 | 115 | 116 | 117 | 118 | #define YL_SIZE_1 2 119 | #define YL_SIZE_2 2000 120 | 121 | 122 | 123 | 124 | #define YY_SIZE_1 1000 125 | #define YY_SIZE_2 2 126 | #define YY_SIZE_3 2000 127 | 128 | 129 | 130 | #ifdef BAD_BOUNDS 131 | #define SCT_SIZE_1 1000 132 | #define SCT_SIZE_2 1000 133 | #else 134 | #define SCT_SIZE_1 2500 135 | #define SCT_SIZE_2 1000 136 | #endif 137 | 138 | #define CP_SIZE 20000 139 | #define RP_SIZE 20000 140 | 141 | #endif /* !_BZ_ARRAY_H */ 142 | -------------------------------------------------------------------------------- /libfprint/nbis/include/defs.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | #ifndef _DEFS_H 45 | #define _DEFS_H 46 | 47 | /*********************************************************************/ 48 | /* General Purpose Defines */ 49 | /*********************************************************************/ 50 | #ifndef True 51 | #define True 1 52 | #define False 0 53 | #endif 54 | #ifndef TRUE 55 | #define TRUE True 56 | #define FALSE False 57 | #endif 58 | #define Yes True 59 | #define No False 60 | #define Empty NULL 61 | #ifndef None 62 | #define None -1 63 | #endif 64 | #ifndef FOUND 65 | #define FOUND 1 66 | #endif 67 | #define NOT_FOUND_NEG -1 68 | #define EOL EOF 69 | #ifndef DEG2RAD 70 | #define DEG2RAD (double)(57.29578) 71 | #endif 72 | #define max(a, b) ((a) > (b) ? (a) : (b)) 73 | #define min(a, b) ((a) < (b) ? (a) : (b)) 74 | #define sround(x) ((int) (((x)<0) ? (x)-0.5 : (x)+0.5)) 75 | #define sround_uint(x) ((unsigned int) (((x)<0) ? (x)-0.5 : (x)+0.5)) 76 | #define align_to_16(_v_) ((((_v_)+15)>>4)<<4) 77 | #define align_to_32(_v_) ((((_v_)+31)>>5)<<5) 78 | #ifndef CHUNKS 79 | #define CHUNKS 100 80 | #endif 81 | 82 | #endif /* !_DEFS_H */ 83 | -------------------------------------------------------------------------------- /libfprint/nbis/include/log.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | 45 | #ifndef _LOG_H 46 | #define _LOG_H 47 | 48 | /* Definitions and references to support log report files. */ 49 | /* UPDATED: 03/16/2005 by MDG */ 50 | 51 | #include 52 | #include 53 | #include 54 | 55 | #ifdef LOG_REPORT 56 | /* Uncomment the following line to enable logging. */ 57 | #define LOG_FILE "log.txt" 58 | #endif 59 | 60 | 61 | extern int open_logfile(void); 62 | extern int close_logfile(void); 63 | extern void print2log(char *, ...); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /libfprint/nbis/include/meson.build: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/libfprint/nbis/include/meson.build -------------------------------------------------------------------------------- /libfprint/nbis/include/morph.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | 45 | #ifndef __MORPH_H__ 46 | #define __MORPH_H__ 47 | 48 | /* Modified 10/26/1999 by MDG to avoid indisciminate erosion of pixels */ 49 | /* along the edge of the binary image. */ 50 | 51 | extern void erode_charimage_2(unsigned char *, unsigned char *, 52 | const int, const int); 53 | extern void dilate_charimage_2(unsigned char *, unsigned char *, 54 | const int, const int); 55 | extern char get_south8_2(char *, const int, const int, const int, const int); 56 | extern char get_north8_2(char *, const int, const int, const int); 57 | extern char get_east8_2(char *, const int, const int, const int); 58 | extern char get_west8_2(char *, const int, const int); 59 | 60 | #endif /* !__MORPH_H__ */ 61 | -------------------------------------------------------------------------------- /libfprint/nbis/include/mytime.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | 45 | #ifndef _MYTIME_H 46 | #define _MYTIME_H 47 | 48 | /* this file needed to support timer and ticks */ 49 | /* UPDATED: 03/16/2005 by MDG */ 50 | 51 | #ifdef TIMER 52 | #include 53 | #endif 54 | 55 | #ifdef __MSYS__ 56 | #include 57 | #else 58 | #include 59 | #endif 60 | 61 | #ifdef TIMER 62 | #define set_timer(_timer_); \ 63 | { \ 64 | _timer_ = ticks(); 65 | #else 66 | #define set_timer(_timer_); 67 | #endif 68 | 69 | #ifdef TIMER 70 | #define time_accum(_timer_, _var_); \ 71 | _var_ += (ticks() - _timer_)/(float)ticksPerSec(); \ 72 | } 73 | #else 74 | #define time_accum(_timer_, _var_); 75 | #endif 76 | 77 | #ifdef TIMER 78 | #define print_time(_fp_, _fmt_, _var_); \ 79 | fprintf(_fp_, _fmt_, _var_); 80 | #else 81 | #define print_time(_fp_, _fmt_, _var_); 82 | #endif 83 | 84 | extern clock_t ticks(void); 85 | extern int ticksPerSec(void); 86 | 87 | extern clock_t total_timer; 88 | extern float total_time; 89 | 90 | extern clock_t imap_timer; 91 | extern float imap_time; 92 | 93 | extern clock_t bin_timer; 94 | extern float bin_time; 95 | 96 | extern clock_t minutia_timer; 97 | extern float minutia_time; 98 | 99 | extern clock_t rm_minutia_timer; 100 | extern float rm_minutia_time; 101 | 102 | extern clock_t ridge_count_timer; 103 | extern float ridge_count_time; 104 | 105 | #endif 106 | 107 | -------------------------------------------------------------------------------- /libfprint/nbis/lfs.h.patch: -------------------------------------------------------------------------------- 1 | --- include/lfs.h 2 | +++ include/lfs.h 3 | @@ -66,7 +66,8 @@ of the software. 4 | 5 | #include 6 | #include 7 | -#include /* Needed by to_type9.c */ 8 | +#include 9 | +#include 10 | 11 | /*************************************************************************/ 12 | /* OUTPUT FILE EXTENSIONS */ 13 | @@ -154,26 +155,8 @@ typedef struct rotgrids{ 14 | #define DISAPPEARING 0 15 | #define APPEARING 1 16 | 17 | -typedef struct minutia{ 18 | - int x; 19 | - int y; 20 | - int ex; 21 | - int ey; 22 | - int direction; 23 | - double reliability; 24 | - int type; 25 | - int appearing; 26 | - int feature_id; 27 | - int *nbrs; 28 | - int *ridge_counts; 29 | - int num_nbrs; 30 | -} MINUTIA; 31 | - 32 | -typedef struct minutiae{ 33 | - int alloc; 34 | - int num; 35 | - MINUTIA **list; 36 | -} MINUTIAE; 37 | +typedef struct fp_minutia MINUTIA; 38 | +typedef struct fp_minutiae MINUTIAE; 39 | 40 | typedef struct feature_pattern{ 41 | int type; 42 | @@ -1203,17 +1186,6 @@ extern void bubble_sort_double_inc_2(double *, int *, const int); 43 | extern void bubble_sort_double_dec_2(double *, int *, const int); 44 | extern void bubble_sort_int_inc(int *, const int); 45 | 46 | -/* to_type9.c */ 47 | -extern int minutiae2type_9(RECORD **, const int, MINUTIAE *, const int, 48 | - const int, const double); 49 | -extern int mintiae2field_12(FIELD **, MINUTIAE *, const int, const int, 50 | - const double); 51 | - 52 | -/* update.c */ 53 | -extern int update_ANSI_NIST_lfs_results(ANSI_NIST *, MINUTIAE *, 54 | - unsigned char *, const int, const int, 55 | - const int, const double, const int, const int); 56 | - 57 | /* util.c */ 58 | extern int maxv(const int *, const int); 59 | extern int minv(const int *, const int); 60 | -------------------------------------------------------------------------------- /libfprint/nbis/libfprint-include/meson.build: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/libfprint/nbis/libfprint-include/meson.build -------------------------------------------------------------------------------- /libfprint/nbis/libfprint-include/nbis-helpers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Helpers to use within the NBIS copy/paste library 3 | * Copyright (C) 2018 Bastien Nocera 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | #define ASSERT_SIZE_MUL(a,b) \ 23 | { \ 24 | gsize dest; \ 25 | g_assert(g_size_checked_mul(&dest, a, b)); \ 26 | } 27 | 28 | #define ASSERT_INT_MUL(a, b) \ 29 | { \ 30 | gsize dest; \ 31 | g_assert(g_size_checked_mul(&dest, a, b)); \ 32 | g_assert(dest < G_MAXINT); \ 33 | } 34 | -------------------------------------------------------------------------------- /libfprint/nbis/libfprint-include/nbis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Example fingerprint device prints listing and deletion 3 | * Enrolls your right index finger and saves the print to disk 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #pragma GCC diagnostic push 24 | #pragma GCC diagnostic ignored "-Wredundant-decls" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | #pragma GCC diagnostic pop 36 | -------------------------------------------------------------------------------- /libfprint/nbis/mindtct/log.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | 3 | License: 4 | This software and/or related materials was developed at the National Institute 5 | of Standards and Technology (NIST) by employees of the Federal Government 6 | in the course of their official duties. Pursuant to title 17 Section 105 7 | of the United States Code, this software is not subject to copyright 8 | protection and is in the public domain. 9 | 10 | This software and/or related materials have been determined to be not subject 11 | to the EAR (see Part 734.3 of the EAR for exact details) because it is 12 | a publicly available technology and software, and is freely distributed 13 | to any interested party with no licensing requirements. Therefore, it is 14 | permissible to distribute this software as a free download from the internet. 15 | 16 | Disclaimer: 17 | This software and/or related materials was developed to promote biometric 18 | standards and biometric technology testing for the Federal Government 19 | in accordance with the USA PATRIOT Act and the Enhanced Border Security 20 | and Visa Entry Reform Act. Specific hardware and software products identified 21 | in this software were used in order to perform the software development. 22 | In no case does such identification imply recommendation or endorsement 23 | by the National Institute of Standards and Technology, nor does it imply that 24 | the products and equipment identified are necessarily the best available 25 | for the purpose. 26 | 27 | This software and/or related materials are provided "AS-IS" without warranty 28 | of any kind including NO WARRANTY OF PERFORMANCE, MERCHANTABILITY, 29 | NO WARRANTY OF NON-INFRINGEMENT OF ANY 3RD PARTY INTELLECTUAL PROPERTY 30 | or FITNESS FOR A PARTICULAR PURPOSE or for any purpose whatsoever, for the 31 | licensed product, however used. In no event shall NIST be liable for any 32 | damages and/or costs, including but not limited to incidental or consequential 33 | damages of any kind, including economic damage or injury to property and lost 34 | profits, regardless of whether NIST shall be advised, have reason to know, 35 | or in fact shall know of the possibility. 36 | 37 | By using this software, you agree to bear all risk relating to quality, 38 | use and performance of the software and/or related materials. You agree 39 | to hold the Government harmless from any claim arising from your use 40 | of the software. 41 | 42 | *******************************************************************************/ 43 | 44 | 45 | /*********************************************************************** 46 | LIBRARY: LFS - NIST Latent Fingerprint System 47 | 48 | FILE: LOG.C 49 | AUTHOR: Michael D. Garris 50 | DATE: 08/02/1999 51 | 52 | Contains routines responsible for dynamically updating a log file 53 | during the execution of the NIST Latent Fingerprint System (LFS). 54 | 55 | *********************************************************************** 56 | ROUTINES: 57 | open_logfile() 58 | print2log() 59 | close_logfile() 60 | ***********************************************************************/ 61 | 62 | #include 63 | 64 | /* If logging is on, declare global file pointer and supporting */ 65 | /* global variable for logging intermediate results. */ 66 | 67 | /***************************************************************************/ 68 | /***************************************************************************/ 69 | int open_logfile(void) 70 | { 71 | #ifdef LOG_REPORT 72 | fprintf(stderr, "ERROR : open_logfile : fopen : %s\n", LOG_FILE); 73 | return(-1); 74 | } 75 | #endif 76 | 77 | return(0); 78 | } 79 | 80 | /***************************************************************************/ 81 | /***************************************************************************/ 82 | void print2log(char *fmt, ...) 83 | { 84 | #ifdef LOG_REPORT 85 | va_list ap; 86 | 87 | va_start(ap, fmt); 88 | va_end(ap); 89 | #endif 90 | } 91 | 92 | /***************************************************************************/ 93 | /***************************************************************************/ 94 | int close_logfile(void) 95 | { 96 | #ifdef LOG_REPORT 97 | fprintf(stderr, "ERROR : close_logfile : fclose : %s\n", LOG_FILE); 98 | return(-1); 99 | } 100 | #endif 101 | 102 | return(0); 103 | } 104 | 105 | -------------------------------------------------------------------------------- /libfprint/nbis/remove-function.lua: -------------------------------------------------------------------------------- 1 | #!/bin/lua 2 | 3 | function read_all(file) 4 | local f = io.open(file, "r") 5 | if not f then return nil end 6 | local t = f:read("*all") 7 | f:close() 8 | return t 9 | end 10 | 11 | function write_all(file, content) 12 | local f = io.open(file, "w") 13 | f:write(content) 14 | f:close() 15 | end 16 | 17 | -- From http://lua-users.org/wiki/SplitJoin 18 | function split_lines(str) 19 | local t = {} 20 | local function helper(line) 21 | table.insert(t, line) 22 | return "" 23 | end 24 | helper((str:gsub("(.-)\r?\n", helper))) 25 | return t 26 | end 27 | 28 | function remove_func_content(func, content) 29 | local lines = split_lines(content) 30 | local res = {} 31 | local in_func = false 32 | local num_braces = 0 33 | local found_func = false 34 | for k, v in ipairs(lines) do 35 | if in_func == true then 36 | local orig_braces = num_braces 37 | local _, count = string.gsub(v, "{", "") 38 | num_braces = num_braces + count 39 | _, count = string.gsub(v, "}", "") 40 | num_braces = num_braces - count 41 | if orig_braces ~= 0 and num_braces == 0 then 42 | print (func .. ' finished line '.. k) 43 | in_func = false 44 | end 45 | elseif (v:match(' '..func..'%(%a+') or 46 | v:match(' '..func..' %(%a+') or 47 | v:match(' '..func..'%( %a+') or 48 | v:match(' '..func..'%($')) and 49 | not v:match('= '..func..'%(%a+') then 50 | print (func .. ' started line ' .. k) 51 | found_func = true 52 | in_func = true 53 | else 54 | table.insert(res, v) 55 | end 56 | end 57 | 58 | if not found_func then 59 | return nil 60 | end 61 | return table.concat(res, '\n') 62 | end 63 | 64 | function remove_func_file(func, file) 65 | content = read_all(file) 66 | content = remove_func_content(func, content) 67 | if not content then 68 | error('Could not find function '..func..'() in '..file) 69 | else 70 | write_all(file, content) 71 | end 72 | end 73 | 74 | local func 75 | for k, v in ipairs(arg) do 76 | if k == 1 then 77 | func = v 78 | else 79 | remove_func_file(func, v) 80 | end 81 | end 82 | 83 | -------------------------------------------------------------------------------- /libfprint/nbis/remove-global-y.cocci: -------------------------------------------------------------------------------- 1 | @ global_y @ 2 | identifier y; 3 | @@ 4 | int 5 | - y 6 | + bz_y 7 | [20000]; 8 | 9 | @@ 10 | identifier global_y.y; 11 | @@ 12 | - y 13 | + bz_y 14 | [...] 15 | 16 | @@ 17 | @@ 18 | int 19 | - y 20 | + bz_y 21 | [20000] = {}; 22 | -------------------------------------------------------------------------------- /meson_options.txt: -------------------------------------------------------------------------------- 1 | option('drivers', 2 | description: 'Drivers to integrate, "default" selects the default set, "all" selects all drivers', 3 | type: 'string', 4 | value: 'default') 5 | option('introspection', 6 | description: 'Build GObject Introspection repository', 7 | type: 'boolean', 8 | value: true) 9 | option('udev_rules', 10 | description: 'Whether to create and install udev rules (auto: turn on when needed by a driver)', 11 | type: 'feature', 12 | value: 'auto') 13 | option('udev_rules_dir', 14 | description: 'Installation path for udev rules', 15 | type: 'string', 16 | value: 'auto') 17 | option('udev_hwdb', 18 | description: 'Whether to create a udev hwdb for autosuspend (included in systemd v248 and later)', 19 | type: 'feature', 20 | value: 'auto') 21 | option('udev_hwdb_dir', 22 | description: 'Installation path for udev hwdb', 23 | type: 'string', 24 | value: 'auto') 25 | option('gtk-examples', 26 | description: 'Whether to build GTK+ example applications', 27 | type: 'boolean', 28 | value: false) 29 | option('doc', 30 | description: 'Whether to build the API documentation', 31 | type: 'boolean', 32 | value: true) 33 | -------------------------------------------------------------------------------- /nfpm_arch_sample.yaml: -------------------------------------------------------------------------------- 1 | # check https://nfpm.goreleaser.com/configuration for detailed usage 2 | # 3 | name: "libfprint" 4 | arch: "amd64" 5 | platform: "linux" 6 | version: "LIBVERSION" 7 | prerelease: goodixtls-COMMITID 8 | epoch: 99999999 9 | section: "default" 10 | priority: "extra" 11 | replaces: 12 | - libfprint 13 | provides: 14 | - libfprint 15 | - libfprint-2.so 16 | 17 | depends: 18 | - libgudev 19 | - libgusb 20 | - nss 21 | - openssl 22 | - pixman 23 | maintainer: "Alexander Meiler , Matthieu CHARETTE " 24 | description: | 25 | This is a community implemented driver for Goodix TLS devices on Linux. 26 | vendor: "Goodix Fingerprint Linux Development" 27 | homepage: "https://github.com/goodix-fp-linux-dev" 28 | license: "GNU LGPL 2.1" 29 | contents: 30 | - src: ./build/libfprint/fp-enums.h 31 | dst: /usr/include/libfprint-2/fp-enums.h 32 | 33 | - src: ./build/libfprint/libfprint-2.so.2.0.0 34 | dst: /usr/lib64/libfprint-2.so.2.0.0 35 | 36 | - src: ./build/libfprint/70-libfprint-2.rules 37 | dst: /usr/lib/udev/rules.d/70-libfprint-2.rules 38 | 39 | - src: ./build/libfprint/FPrint-2.0.gir 40 | dst: /usr/share/gir-1.0/FPrint-2.0.gir 41 | 42 | - src: ./build/libfprint/FPrint-2.0.typelib 43 | dst: /usr/lib64/girepository-1.0/FPrint-2.0.typelib 44 | 45 | - src: ./libfprint/fprint.h 46 | dst: /usr/include/libfprint-2/fprint.h 47 | 48 | - src: ./libfprint/fp-context.h 49 | dst: /usr/include/libfprint-2/fp-context.h 50 | 51 | - src: ./libfprint/fp-device.h 52 | dst: /usr/include/libfprint-2/fp-device.h 53 | 54 | - src: ./libfprint/fp-image-device.h 55 | dst: /usr/include/libfprint-2/fp-image-device.h 56 | 57 | - src: ./libfprint/fp-image.h 58 | dst: /usr/include/libfprint-2/fp-image.h 59 | 60 | - src: ./libfprint/fp-print.h 61 | dst: /usr/include/libfprint-2/fp-print.h 62 | 63 | - src: ./build/meson-private/libfprint-2.pc 64 | dst: /usr/lib64/pkgconfig/libfprint-2.pc 65 | 66 | - src: /usr/lib64/libfprint-2.so.2.0.0 67 | dst: /usr/lib64/libfprint-2.so.2 68 | type: symlink 69 | 70 | - src: /usr/lib64/libfprint-2.so.2.0.0 71 | dst: /usr/lib64/libfprint-2.so 72 | type: symlink 73 | -------------------------------------------------------------------------------- /nfpm_deb_sample.yaml: -------------------------------------------------------------------------------- 1 | # check https://nfpm.goreleaser.com/configuration for detailed usage 2 | # 3 | name: "libfprint-2-2" 4 | arch: "amd64" 5 | platform: "linux" 6 | version: "LIBVERSION" 7 | prerelease: goodixtls-COMMITID 8 | epoch: 99999999 9 | section: "default" 10 | priority: "extra" 11 | replaces: 12 | - libfprint-2-2 13 | - libfprint 14 | provides: 15 | - libfprint 16 | - libfprint-2.so 17 | - libfprint-2-2 18 | depends: 19 | - libc6 20 | - libglib2.0-0 21 | - libgudev-1.0-0 22 | - libgusb2 23 | - libnss3 24 | - openssl 25 | - libpixman-1-0 26 | maintainer: "Alexander Meiler , Matthieu CHARETTE " 27 | description: | 28 | This is a community implemented driver for Goodix TLS devices on Linux. 29 | vendor: "Goodix Fingerprint Linux Development" 30 | homepage: "https://github.com/goodix-fp-linux-dev" 31 | license: "GNU LGPL 2.1" 32 | contents: 33 | - src: ./build/libfprint/fp-enums.h 34 | dst: /usr/include/libfprint-2/fp-enums.h 35 | 36 | - src: ./build/libfprint/libfprint-2.so.2.0.0 37 | dst: /usr/lib/x86_64-linux-gnu/libfprint-2.so.2.0.0 38 | 39 | - src: ./build/libfprint/70-libfprint-2.rules 40 | dst: /usr/lib/udev/rules.d/70-libfprint-2.rules 41 | 42 | - src: ./build/libfprint/FPrint-2.0.gir 43 | dst: /usr/share/gir-1.0/FPrint-2.0.gir 44 | 45 | - src: ./build/libfprint/FPrint-2.0.typelib 46 | dst: /usr/lib/x86_64-linux-gnu/girepository-1.0/FPrint-2.0.typelib 47 | 48 | - src: ./libfprint/fprint.h 49 | dst: /usr/include/libfprint-2/fprint.h 50 | 51 | - src: ./libfprint/fp-context.h 52 | dst: /usr/include/libfprint-2/fp-context.h 53 | 54 | - src: ./libfprint/fp-device.h 55 | dst: /usr/include/libfprint-2/fp-device.h 56 | 57 | - src: ./libfprint/fp-image-device.h 58 | dst: /usr/include/libfprint-2/fp-image-device.h 59 | 60 | - src: ./libfprint/fp-image.h 61 | dst: /usr/include/libfprint-2/fp-image.h 62 | 63 | - src: ./libfprint/fp-print.h 64 | dst: /usr/include/libfprint-2/fp-print.h 65 | 66 | - src: ./build/meson-private/libfprint-2.pc 67 | dst: /usr/lib/x86_64-linux-gnu/pkgconfig/libfprint-2.pc 68 | 69 | - src: /usr/lib/x86_64-linux-gnu/libfprint-2.so.2.0.0 70 | dst: /usr/lib/x86_64-linux-gnu/libfprint-2.so.2 71 | type: symlink 72 | 73 | - src: /usr/lib/x86_64-linux-gnu/libfprint-2.so.2.0.0 74 | dst: /usr/lib/x86_64-linux-gnu/libfprint-2.so 75 | type: symlink 76 | -------------------------------------------------------------------------------- /nfpm_rpm_sample.yaml: -------------------------------------------------------------------------------- 1 | # check https://nfpm.goreleaser.com/configuration for detailed usage 2 | # 3 | name: "libfprint" 4 | arch: "amd64" 5 | platform: "linux" 6 | version: "LIBVERSION" 7 | prerelease: goodixtls-COMMITID 8 | epoch: 99999999 9 | section: "default" 10 | priority: "extra" 11 | replaces: 12 | - libfprint 13 | provides: 14 | - libfprint 15 | - libfprint(aarch-64) 16 | - libfprint-2.so.2()(64bit) 17 | - libfprint-2.so.2(LIBFPRINT_2.0.0)(64bit) 18 | 19 | depends: 20 | - libgudev 21 | - libgusb 22 | - nss 23 | - openssl 24 | - pixman 25 | maintainer: "Alexander Meiler , Matthieu CHARETTE " 26 | description: | 27 | This is a community implemented driver for Goodix TLS devices on Linux. 28 | vendor: "Goodix Fingerprint Linux Development" 29 | homepage: "https://github.com/goodix-fp-linux-dev" 30 | license: "GNU LGPL 2.1" 31 | contents: 32 | - src: ./build/libfprint/fp-enums.h 33 | dst: /usr/include/libfprint-2/fp-enums.h 34 | 35 | - src: ./build/libfprint/libfprint-2.so.2.0.0 36 | dst: /usr/lib64/libfprint-2.so.2.0.0 37 | 38 | - src: ./build/libfprint/70-libfprint-2.rules 39 | dst: /usr/lib/udev/rules.d/70-libfprint-2.rules 40 | 41 | - src: ./build/libfprint/FPrint-2.0.gir 42 | dst: /usr/share/gir-1.0/FPrint-2.0.gir 43 | 44 | - src: ./build/libfprint/FPrint-2.0.typelib 45 | dst: /usr/lib64/girepository-1.0/FPrint-2.0.typelib 46 | 47 | - src: ./libfprint/fprint.h 48 | dst: /usr/include/libfprint-2/fprint.h 49 | 50 | - src: ./libfprint/fp-context.h 51 | dst: /usr/include/libfprint-2/fp-context.h 52 | 53 | - src: ./libfprint/fp-device.h 54 | dst: /usr/include/libfprint-2/fp-device.h 55 | 56 | - src: ./libfprint/fp-image-device.h 57 | dst: /usr/include/libfprint-2/fp-image-device.h 58 | 59 | - src: ./libfprint/fp-image.h 60 | dst: /usr/include/libfprint-2/fp-image.h 61 | 62 | - src: ./libfprint/fp-print.h 63 | dst: /usr/include/libfprint-2/fp-print.h 64 | 65 | - src: ./build/meson-private/libfprint-2.pc 66 | dst: /usr/lib64/pkgconfig/libfprint-2.pc 67 | 68 | - src: /usr/lib64/libfprint-2.so.2.0.0 69 | dst: /usr/lib64/libfprint-2.so.2 70 | type: symlink 71 | 72 | - src: /usr/lib64/libfprint-2.so.2.0.0 73 | dst: /usr/lib64/libfprint-2.so 74 | type: symlink 75 | -------------------------------------------------------------------------------- /scripts/uncrustify.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | SRCROOT=`git rev-parse --show-toplevel` 3 | CFG="$SRCROOT/scripts/uncrustify.cfg" 4 | echo "srcroot: $SRCROOT" 5 | 6 | case "$1" in 7 | -c|--check) 8 | OPTS="--check" 9 | ;; 10 | *) 11 | OPTS="--replace --no-backup" 12 | ;; 13 | esac 14 | 15 | ARGS=4 16 | JOBS=4 17 | 18 | pushd "$SRCROOT" 19 | git ls-tree --name-only -r HEAD | grep -E '.*\.[ch]$' | grep -v nbis | grep -v fpi-byte | grep -v build/ | xargs -n$ARGS -P $JOBS uncrustify -c "$CFG" $OPTS 20 | RES=$? 21 | popd 22 | exit $RES 23 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | `umockdev` Tests 2 | ================ 3 | `umockdev` tests use fingerprint devices mocked by [`umockdev` 4 | toolchain][umockdev]. 5 | 6 | This document describes how to create test cases (for USB devices). Many of 7 | these tests are tests for image devices, where a single image is captured 8 | and stored. 9 | 10 | Other kinds of `umockdev` tests can be created in a similar manner. For 11 | match-on-chip devices you would instead create a test specific `custom.py` 12 | script, capture it and store the capture to `custom.pcapng`. 13 | 14 | 'capture' and 'custom' Test Creation 15 | ------------------------------------ 16 | 17 | For image devices the `capture.py` script will be used to capture one reference 18 | image. If the driver is a non-image driver, then a `custom.py` script should be 19 | created in advance, which will be run instead. 20 | 21 | 1. Make sure that libfprint is built with support for the device driver 22 | that you want to create a test case for. 23 | 24 | 2. From the build directory, run tests/create-driver-test.py as root. Note 25 | that if you're capturing data for a driver which already has a test case 26 | but the hardware is slightly different, you might want to pass a variant 27 | name as a command-line options, for example: 28 | ```sh 29 | $ sudo tests/create-driver-test.py driver [variant] 30 | ``` 31 | 32 | 3. If the capture is not successful, run the tool again to start another capture. 33 | 34 | 4. Add driver test name to `drivers_tests` in the `meson.build`, as instructed, 35 | and change the ownership of the just-created test directory in the source. 36 | 37 | 5. Check whether `meson test` passes with this new test. 38 | 39 | **Note.** To avoid submitting a real fingerprint when creating a 'capture' test, 40 | the side of finger, arm, or anything else producing an image with the device 41 | can be used. 42 | 43 | 44 | Possible Issues 45 | --------------- 46 | 47 | Other changes may be needed to get everything working. For example the 48 | `elan` driver relies on a timeout that is not reported correctly. In 49 | this case the driver works around it by interpreting the protocol 50 | error differently in the virtual environment (by means of 51 | `FP_DEVICE_EMULATION` environment variable). 52 | 53 | 54 | [umockdev]: https://github.com/martinpitt/umockdev 55 | -------------------------------------------------------------------------------- /tests/aes2501/capture.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/aes2501/capture.pcapng -------------------------------------------------------------------------------- /tests/aes2501/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/aes2501/capture.png -------------------------------------------------------------------------------- /tests/aes3500/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/aes3500/capture.png -------------------------------------------------------------------------------- /tests/capture.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import cairo 4 | import sys 5 | import traceback 6 | import gi 7 | 8 | gi.require_version('FPrint', '2.0') 9 | from gi.repository import FPrint, GLib 10 | 11 | # Exit with error on any exception, included those happening in async callbacks 12 | sys.excepthook = lambda *args: (traceback.print_exception(*args), sys.exit(1)) 13 | 14 | if len(sys.argv) != 2: 15 | print("Please specify exactly one argument, the output location for the capture image") 16 | sys.exit(1) 17 | 18 | ctx = GLib.main_context_default() 19 | 20 | c = FPrint.Context() 21 | c.enumerate() 22 | devices = c.get_devices() 23 | 24 | d = devices[0] 25 | assert d.has_feature(FPrint.DeviceFeature.CAPTURE) 26 | assert d.has_feature(FPrint.DeviceFeature.IDENTIFY) 27 | assert d.has_feature(FPrint.DeviceFeature.VERIFY) 28 | assert not d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK) 29 | assert not d.has_feature(FPrint.DeviceFeature.STORAGE) 30 | assert not d.has_feature(FPrint.DeviceFeature.STORAGE_LIST) 31 | assert not d.has_feature(FPrint.DeviceFeature.STORAGE_DELETE) 32 | assert not d.has_feature(FPrint.DeviceFeature.STORAGE_CLEAR) 33 | del devices 34 | 35 | d.open_sync() 36 | 37 | img = d.capture_sync(True) 38 | 39 | d.close_sync() 40 | 41 | del d 42 | del c 43 | 44 | width = img.get_width() 45 | height = img.get_height() 46 | 47 | c_img = cairo.ImageSurface(cairo.FORMAT_RGB24, width, height) 48 | 49 | c_rowstride = c_img.get_stride() 50 | 51 | buf = img.get_data() 52 | c_buf = c_img.get_data() 53 | 54 | for x in range(width): 55 | for y in range(height): 56 | # The upper byte is don't care, but the location depends on endianness, 57 | # so just set all of them. 58 | c_buf[y * c_rowstride + x * 4 + 0] = buf[y * width + x] 59 | c_buf[y * c_rowstride + x * 4 + 1] = buf[y * width + x] 60 | c_buf[y * c_rowstride + x * 4 + 2] = buf[y * width + x] 61 | c_buf[y * c_rowstride + x * 4 + 3] = buf[y * width + x] 62 | 63 | c_img.mark_dirty() 64 | c_img.write_to_png(sys.argv[1]) 65 | 66 | -------------------------------------------------------------------------------- /tests/egis0570/capture.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/egis0570/capture.pcapng -------------------------------------------------------------------------------- /tests/egis0570/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/egis0570/capture.png -------------------------------------------------------------------------------- /tests/elan-cobo/capture.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/elan-cobo/capture.pcapng -------------------------------------------------------------------------------- /tests/elan-cobo/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/elan-cobo/capture.png -------------------------------------------------------------------------------- /tests/elan/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/elan/capture.png -------------------------------------------------------------------------------- /tests/elanmoc/custom.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/elanmoc/custom.pcapng -------------------------------------------------------------------------------- /tests/elanmoc/custom.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import traceback 4 | import sys 5 | import gi 6 | 7 | gi.require_version('FPrint', '2.0') 8 | from gi.repository import FPrint, GLib 9 | 10 | # Exit with error on any exception, included those happening in async callbacks 11 | sys.excepthook = lambda *args: (traceback.print_exception(*args), sys.exit(1)) 12 | 13 | ctx = GLib.main_context_default() 14 | 15 | c = FPrint.Context() 16 | c.enumerate() 17 | devices = c.get_devices() 18 | 19 | d = devices[0] 20 | del devices 21 | 22 | assert d.get_driver() == "elanmoc" 23 | assert not d.has_feature(FPrint.DeviceFeature.CAPTURE) 24 | assert d.has_feature(FPrint.DeviceFeature.IDENTIFY) 25 | assert d.has_feature(FPrint.DeviceFeature.VERIFY) 26 | assert not d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK) 27 | assert d.has_feature(FPrint.DeviceFeature.STORAGE) 28 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_LIST) 29 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_DELETE) 30 | assert not d.has_feature(FPrint.DeviceFeature.STORAGE_CLEAR) 31 | 32 | d.open_sync() 33 | 34 | template = FPrint.Print.new(d) 35 | 36 | def enroll_progress(*args): 37 | #assert d.get_finger_status() == FPrint.FingerStatusFlags.NEEDED 38 | print("finger status: ", d.get_finger_status()) 39 | print('enroll progress: ' + str(args)) 40 | 41 | def identify_done(dev, res): 42 | global identified 43 | identified = True 44 | identify_match, identify_print = dev.identify_finish(res) 45 | print('indentification_done: ', identify_match, identify_print) 46 | assert identify_match.equal(identify_print) 47 | 48 | # List, enroll, list, verify, identify, delete 49 | print("enrolling") 50 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 51 | p = d.enroll_sync(template, None, enroll_progress, None) 52 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 53 | print("enroll done") 54 | 55 | print("listing") 56 | stored = d.list_prints_sync() 57 | print("listing done") 58 | assert len(stored) == 1 59 | assert stored[0].equal(p) 60 | print("verifying") 61 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 62 | verify_res, verify_print = d.verify_sync(p) 63 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 64 | print("verify done") 65 | del p 66 | assert verify_res == True 67 | 68 | identified = False 69 | deserialized_prints = [] 70 | for p in stored: 71 | deserialized_prints.append(FPrint.Print.deserialize(p.serialize())) 72 | assert deserialized_prints[-1].equal(p) 73 | del stored 74 | 75 | print('async identifying') 76 | d.identify(deserialized_prints, callback=identify_done) 77 | del deserialized_prints 78 | 79 | while not identified: 80 | ctx.iteration(True) 81 | 82 | print("deleting") 83 | d.delete_print_sync(p) 84 | print("delete done") 85 | 86 | d.close_sync() 87 | 88 | del d 89 | del c 90 | -------------------------------------------------------------------------------- /tests/elanspi/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/elanspi/capture.png -------------------------------------------------------------------------------- /tests/fpcmoc/custom.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/fpcmoc/custom.pcapng -------------------------------------------------------------------------------- /tests/fpcmoc/custom.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import traceback 4 | import sys 5 | import gi 6 | 7 | gi.require_version('FPrint', '2.0') 8 | from gi.repository import FPrint, GLib 9 | 10 | # Exit with error on any exception, included those happening in async callbacks 11 | sys.excepthook = lambda *args: (traceback.print_exception(*args), sys.exit(1)) 12 | 13 | ctx = GLib.main_context_default() 14 | 15 | c = FPrint.Context() 16 | c.enumerate() 17 | devices = c.get_devices() 18 | 19 | d = devices[0] 20 | del devices 21 | 22 | assert d.get_driver() == "fpcmoc" 23 | assert not d.has_feature(FPrint.DeviceFeature.CAPTURE) 24 | assert d.has_feature(FPrint.DeviceFeature.IDENTIFY) 25 | assert d.has_feature(FPrint.DeviceFeature.VERIFY) 26 | assert d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK) 27 | assert d.has_feature(FPrint.DeviceFeature.STORAGE) 28 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_LIST) 29 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_DELETE) 30 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_CLEAR) 31 | 32 | d.open_sync() 33 | 34 | print("Clear") 35 | d.clear_storage_sync() 36 | print("Clear done") 37 | 38 | template = FPrint.Print.new(d) 39 | 40 | def enroll_progress(*args): 41 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NEEDED 42 | print('enroll progress: ' + str(args)) 43 | 44 | def identify_done(dev, res): 45 | global identified 46 | identified = True 47 | identify_match, identify_print = dev.identify_finish(res) 48 | print('indentification_done: ', identify_match, identify_print) 49 | assert identify_match.equal(identify_print) 50 | 51 | # List, enroll, list, verify, identify, delete 52 | print("enrolling") 53 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 54 | p = d.enroll_sync(template, None, enroll_progress, None) 55 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 56 | print("enroll done") 57 | 58 | print("listing") 59 | stored = d.list_prints_sync() 60 | print("listing done") 61 | assert len(stored) == 1 62 | assert stored[0].equal(p) 63 | print("verifying") 64 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 65 | verify_res, verify_print = d.verify_sync(p) 66 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 67 | print("verify done") 68 | del p 69 | assert verify_res == True 70 | 71 | identified = False 72 | deserialized_prints = [] 73 | for p in stored: 74 | deserialized_prints.append(FPrint.Print.deserialize(p.serialize())) 75 | assert deserialized_prints[-1].equal(p) 76 | del stored 77 | 78 | print('async identifying') 79 | d.identify(deserialized_prints, callback=identify_done) 80 | del deserialized_prints 81 | 82 | while not identified: 83 | ctx.iteration(True) 84 | 85 | print("deleting") 86 | d.delete_print_sync(p) 87 | print("delete done") 88 | 89 | d.close_sync() 90 | 91 | del d 92 | del c 93 | -------------------------------------------------------------------------------- /tests/goodixmoc/custom.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/goodixmoc/custom.pcapng -------------------------------------------------------------------------------- /tests/goodixmoc/custom.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import traceback 4 | import sys 5 | import gi 6 | 7 | gi.require_version('FPrint', '2.0') 8 | from gi.repository import FPrint, GLib 9 | 10 | # Exit with error on any exception, included those happening in async callbacks 11 | sys.excepthook = lambda *args: (traceback.print_exception(*args), sys.exit(1)) 12 | 13 | ctx = GLib.main_context_default() 14 | 15 | c = FPrint.Context() 16 | c.enumerate() 17 | devices = c.get_devices() 18 | 19 | d = devices[0] 20 | del devices 21 | 22 | assert d.get_driver() == "goodixmoc" 23 | assert not d.has_feature(FPrint.DeviceFeature.CAPTURE) 24 | assert d.has_feature(FPrint.DeviceFeature.IDENTIFY) 25 | assert d.has_feature(FPrint.DeviceFeature.VERIFY) 26 | assert d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK) 27 | assert d.has_feature(FPrint.DeviceFeature.STORAGE) 28 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_LIST) 29 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_DELETE) 30 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_CLEAR) 31 | 32 | d.open_sync() 33 | 34 | # 1. verify clear storage command, 2. make sure later asserts are good 35 | d.clear_storage_sync() 36 | 37 | template = FPrint.Print.new(d) 38 | 39 | def enroll_progress(*args): 40 | assert d.get_finger_status() & FPrint.FingerStatusFlags.NEEDED 41 | print('enroll progress: ' + str(args)) 42 | 43 | def identify_done(dev, res): 44 | global identified 45 | identified = True 46 | identify_match, identify_print = dev.identify_finish(res) 47 | print('indentification_done: ', identify_match, identify_print) 48 | assert identify_match.equal(identify_print) 49 | 50 | # List, enroll, list, verify, identify, delete 51 | print("enrolling") 52 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 53 | p = d.enroll_sync(template, None, enroll_progress, None) 54 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 55 | print("enroll done") 56 | 57 | print("listing") 58 | stored = d.list_prints_sync() 59 | print("listing done") 60 | assert len(stored) == 1 61 | assert stored[0].equal(p) 62 | print("verifying") 63 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 64 | verify_res, verify_print = d.verify_sync(p) 65 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 66 | print("verify done") 67 | del p 68 | assert verify_res == True 69 | 70 | identified = False 71 | deserialized_prints = [] 72 | for p in stored: 73 | deserialized_prints.append(FPrint.Print.deserialize(p.serialize())) 74 | assert deserialized_prints[-1].equal(p) 75 | del stored 76 | 77 | print('async identifying') 78 | d.identify(deserialized_prints, callback=identify_done) 79 | del deserialized_prints 80 | 81 | while not identified: 82 | ctx.iteration(True) 83 | 84 | print("deleting") 85 | d.delete_print_sync(p) 86 | print("delete done") 87 | 88 | d.close_sync() 89 | 90 | del d 91 | del c 92 | -------------------------------------------------------------------------------- /tests/hwdb-check-unsupported.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | 3 | import os 4 | import sys 5 | import urllib 6 | import urllib.request 7 | import re 8 | 9 | error = False 10 | 11 | try: 12 | response = urllib.request.urlopen('https://gitlab.freedesktop.org/libfprint/wiki/-/wikis/Unsupported-Devices.md') 13 | except: 14 | print("Could not download current list of unsupported devices, skipping test.") 15 | sys.exit(77) 16 | data = response.read().decode('utf-8') 17 | 18 | devices = [] 19 | devices_re = re.compile(r'^.*([0-9a-fA-F]{4}):([0-9a-fA-F]{4}).*$', re.MULTILINE) 20 | for m in devices_re.finditer(data): 21 | vid = m.group(1) 22 | pid = m.group(2) 23 | devices.append((vid, pid)) 24 | 25 | generator = open(os.path.join(os.path.dirname(__file__), '..', 'libfprint', 'fprint-list-udev-hwdb.c')).read() 26 | 27 | id_re = re.compile(' { .vid = 0x([a-fA-F0-9]*), .pid = 0x([a-fA-F0-9]*) }') 28 | # Check everything is the same 29 | started = False 30 | for l in generator.split('\n'): 31 | m = id_re.match(l) 32 | if m is None: 33 | # Stop on the first line that does not match anymore 34 | if started: 35 | break 36 | continue 37 | else: 38 | started = True 39 | 40 | vid_pid = (m.group(1), m.group(2)) 41 | try: 42 | devices.remove(vid_pid) 43 | except ValueError: 44 | print("Generator has entry that is not on wiki: {}:{}".format(*vid_pid)) 45 | error = True 46 | 47 | for vid_pid in devices: 48 | print("New entry from wiki is missing: {}:{}".format(*vid_pid)) 49 | error = True 50 | 51 | if error: 52 | sys.exit(1) 53 | else: 54 | sys.exit(0) 55 | -------------------------------------------------------------------------------- /tests/libfprint.supp: -------------------------------------------------------------------------------- 1 | { 2 | 3 | Memcheck:Leak 4 | fun:malloc 5 | ... 6 | fun:dlopen* 7 | } 8 | 9 | { 10 | 11 | Memcheck:Param 12 | socketcall.sendto(msg) 13 | ... 14 | fun:send 15 | ... 16 | fun:g_usb_device_get_string_descriptor 17 | ... 18 | } 19 | 20 | -------------------------------------------------------------------------------- /tests/nb1010/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/nb1010/capture.png -------------------------------------------------------------------------------- /tests/synaptics/custom.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/synaptics/custom.pcapng -------------------------------------------------------------------------------- /tests/synaptics/custom.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import os 4 | import gi 5 | gi.require_version('FPrint', '2.0') 6 | from gi.repository import FPrint, GLib 7 | 8 | import sys 9 | import traceback 10 | sys.excepthook = lambda *args : (traceback.print_exception(*args), sys.exit(1)) 11 | 12 | 13 | c = FPrint.Context() 14 | c.enumerate() 15 | devices = c.get_devices() 16 | 17 | d = devices[0] 18 | del devices 19 | 20 | usb_device = d.get_property('fpi-usb-device') 21 | bus_num = usb_device.get_bus() 22 | port = [] 23 | while True: 24 | parent = usb_device.get_parent() 25 | if parent is None: 26 | break 27 | port.append(str(usb_device.get_port_number())) 28 | usb_device = parent 29 | port = '.'.join(port) 30 | 31 | persist = f'/sys/bus/usb/devices/{bus_num}-{port}/power/persist' 32 | wakeup = f'/sys/bus/usb/devices/{bus_num}-{port}/power/wakeup' 33 | 34 | # may not have written anything 35 | assert open(persist).read().strip() == "0" 36 | assert open(wakeup).read().strip() == "disabled" 37 | 38 | assert d.get_driver() == "synaptics" 39 | assert not d.has_feature(FPrint.DeviceFeature.CAPTURE) 40 | assert d.has_feature(FPrint.DeviceFeature.IDENTIFY) 41 | assert d.has_feature(FPrint.DeviceFeature.VERIFY) 42 | assert not d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK) 43 | assert d.has_feature(FPrint.DeviceFeature.STORAGE) 44 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_DELETE) 45 | assert d.has_feature(FPrint.DeviceFeature.STORAGE_CLEAR) 46 | 47 | d.open_sync() 48 | 49 | d.clear_storage_sync() 50 | 51 | template = FPrint.Print.new(d) 52 | 53 | def enroll_progress(*args): 54 | assert d.get_finger_status() & FPrint.FingerStatusFlags.NEEDED 55 | print('enroll progress: ' + str(args)) 56 | 57 | # List, enroll, list, verify, delete, list 58 | print("enrolling") 59 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 60 | p = d.enroll_sync(template, None, enroll_progress, None) 61 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 62 | print("enroll done") 63 | 64 | print("verifying") 65 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 66 | 67 | # Inject a suspend/resume cycle into the verify 68 | def suspend_resume(): 69 | d.suspend_sync() 70 | assert open(persist).read().strip() == "0" 71 | assert open(wakeup).read().strip() == "enabled" 72 | 73 | assert open(persist, 'w').write('0\n') 74 | d.resume_sync() 75 | # This tests that libfprint doesn't write if the value is correct 76 | # (i.e. the trailing \ would be lost inside umockdev if written) 77 | assert open(persist).read() == "0\n" 78 | assert open(wakeup).read().strip() == "disabled" 79 | 80 | GLib.idle_add(suspend_resume, priority=GLib.PRIORITY_HIGH) 81 | verify_res, verify_print = d.verify_sync(p) 82 | assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE 83 | print("verify done") 84 | assert verify_res == True 85 | 86 | print("deleting") 87 | d.delete_print_sync(p) 88 | print("delete done") 89 | d.close_sync() 90 | 91 | del d 92 | del c 93 | -------------------------------------------------------------------------------- /tests/test-device-fake.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Virtual driver for device debugging 3 | * 4 | * Copyright (C) 2019 Marco Trevisan 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Lesser General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2.1 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public 17 | * License along with this library; if not, write to the Free Software 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 | */ 20 | 21 | #pragma once 22 | 23 | #include "fpi-device.h" 24 | 25 | #define FPI_TYPE_DEVICE_FAKE (fpi_device_fake_get_type ()) 26 | G_DECLARE_FINAL_TYPE (FpiDeviceFake, fpi_device_fake, FPI, DEVICE_FAKE, FpDevice) 27 | 28 | struct _FpiDeviceFake 29 | { 30 | FpDevice parent; 31 | 32 | gpointer last_called_function; 33 | gboolean return_action_error; 34 | 35 | GCancellable *ext_cancellable; 36 | 37 | GError *ret_error; 38 | FpPrint *ret_print; 39 | FpPrint *ret_match; 40 | FpiMatchResult ret_result; 41 | FpImage *ret_image; 42 | GPtrArray *ret_list; 43 | 44 | GError *ret_suspend; 45 | GError *ret_resume; 46 | 47 | gpointer action_data; 48 | gpointer user_data; 49 | 50 | FpDeviceFeature probe_features_update; 51 | FpDeviceFeature probe_features_value; 52 | }; 53 | -------------------------------------------------------------------------------- /tests/test-generated-hwdb.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | if [ ! -x "$UDEV_HWDB" ]; then 5 | echo "E: UDEV_HWDB (${UDEV_HWDB}) unset or not executable." 6 | exit 1 7 | fi 8 | 9 | if [ "$UDEV_HWDB_CHECK_CONTENTS" == 1 ]; then 10 | generated_rules=$(mktemp "${TMPDIR:-/tmp}/libfprint-XXXXXX.hwdb") 11 | else 12 | generated_rules=/dev/null 13 | fi 14 | 15 | $UDEV_HWDB > "$generated_rules" 16 | if [ $? != 0 ]; then 17 | echo "E: UDEV_HWDB (${UDEV_HWDB}) failed to run without error." 18 | exit 1 19 | fi 20 | 21 | if [ "$UDEV_HWDB_CHECK_CONTENTS" != 1 ]; then 22 | exit 77 23 | fi 24 | 25 | if ! diff -u "$MESON_SOURCE_ROOT/data/autosuspend.hwdb" "$generated_rules"; then 26 | echo "E: Autosuspend file needs to be re-generated!" 27 | echo " ninja -C $MESON_BUILD_ROOT sync-udev-hwdb" 28 | exit 1 29 | fi 30 | 31 | rm "$generated_rules" 32 | -------------------------------------------------------------------------------- /tests/test-utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Unit tests for libfprint 3 | * Copyright (C) 2019 Marco Trevisan 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Lesser General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2.1 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Lesser General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Lesser General Public 16 | * License along with this library; if not, write to the Free Software 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 | */ 19 | 20 | #include 21 | 22 | typedef enum { 23 | FPT_VIRTUAL_DEVICE_IMAGE = 0, 24 | FPT_VIRTUAL_DEVICE_NONIMAGE, 25 | FPT_VIRTUAL_DEVICE_NONIMAGE_STORAGE, 26 | FPT_NUM_VIRTUAL_DEVICE_TYPES 27 | } FptVirtualDeviceType; 28 | 29 | void fpt_setup_virtual_device_environment (FptVirtualDeviceType devtype); 30 | void fpt_teardown_virtual_device_environment (void); 31 | 32 | typedef struct _FptContext 33 | { 34 | FpContext *fp_context; 35 | FpDevice *device; 36 | gpointer user_data; 37 | } FptContext; 38 | 39 | FptContext * fpt_context_new (void); 40 | FptContext * fpt_context_new_with_virtual_device (FptVirtualDeviceType devtype); 41 | 42 | void fpt_context_free (FptContext *test_context); 43 | 44 | G_DEFINE_AUTOPTR_CLEANUP_FUNC (FptContext, fpt_context_free) 45 | -------------------------------------------------------------------------------- /tests/unittest_inspector.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python3 2 | # Copyright © 2020, Canonical Ltd 3 | # 4 | # This program is free software; you can redistribute it and/or 5 | # modify it under the terms of the GNU Lesser General Public 6 | # License as published by the Free Software Foundation; either 7 | # version 2.1 of the License, or (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | # Lesser General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Lesser General Public 15 | # License along with this library. If not, see . 16 | # Authors: 17 | # Marco Trevisan 18 | 19 | import argparse 20 | import importlib.util 21 | import inspect 22 | import os 23 | import unittest 24 | 25 | def list_tests(module): 26 | tests = [] 27 | for name, obj in inspect.getmembers(module): 28 | if inspect.isclass(obj) and issubclass(obj, unittest.TestCase): 29 | cases = unittest.defaultTestLoader.getTestCaseNames(obj) 30 | tests += [ (obj, '{}.{}'.format(name, t)) for t in cases ] 31 | return tests 32 | 33 | 34 | if __name__ == '__main__': 35 | parser = argparse.ArgumentParser() 36 | parser.add_argument('unittest_source', type=argparse.FileType('r')) 37 | 38 | args = parser.parse_args() 39 | source_path = args.unittest_source.name 40 | spec = importlib.util.spec_from_file_location( 41 | os.path.basename(source_path), source_path) 42 | module = importlib.util.module_from_spec(spec) 43 | spec.loader.exec_module(module) 44 | 45 | for machine, human in list_tests(module): 46 | print(human) 47 | -------------------------------------------------------------------------------- /tests/upektc_img/capture.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/upektc_img/capture.pcapng -------------------------------------------------------------------------------- /tests/upektc_img/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/upektc_img/capture.png -------------------------------------------------------------------------------- /tests/uru4000-4500/capture.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/uru4000-4500/capture.pcapng -------------------------------------------------------------------------------- /tests/uru4000-4500/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/uru4000-4500/capture.png -------------------------------------------------------------------------------- /tests/uru4000-msv2/capture.pcapng: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/uru4000-msv2/capture.pcapng -------------------------------------------------------------------------------- /tests/uru4000-msv2/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/uru4000-msv2/capture.png -------------------------------------------------------------------------------- /tests/valgrind-python.supp: -------------------------------------------------------------------------------- 1 | { 2 | ignore_py_cond 3 | Memcheck:Cond 4 | ... 5 | fun:Py* 6 | } 7 | 8 | { 9 | ignore__py_cond 10 | Memcheck:Cond 11 | ... 12 | fun:_Py* 13 | } 14 | 15 | { 16 | ignore_py_value8 17 | Memcheck:Value8 18 | ... 19 | fun:Py* 20 | } 21 | 22 | { 23 | ignore__py_value8 24 | Memcheck:Value8 25 | ... 26 | fun:_Py* 27 | } 28 | 29 | { 30 | ignore_py_addr4 31 | Memcheck:Addr4 32 | ... 33 | fun:Py* 34 | } 35 | 36 | { 37 | ignore__py_addr4 38 | Memcheck:Addr4 39 | ... 40 | fun:_Py* 41 | } 42 | 43 | { 44 | ignore_py_leaks 45 | Memcheck:Leak 46 | ... 47 | fun:Py* 48 | } 49 | 50 | { 51 | ignore__py_leaks 52 | Memcheck:Leak 53 | ... 54 | fun:_Py* 55 | } 56 | -------------------------------------------------------------------------------- /tests/vfs0050/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/vfs0050/capture.png -------------------------------------------------------------------------------- /tests/vfs301/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/vfs301/capture.png -------------------------------------------------------------------------------- /tests/vfs5011/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/vfs5011/capture.png -------------------------------------------------------------------------------- /tests/vfs7552/capture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/goodix-fp-linux-dev/libfprint/eebdacff358c90e3f909ae4f5526fff194fe3f7c/tests/vfs7552/capture.png --------------------------------------------------------------------------------