Compare commits

..

44 Commits

Author SHA1 Message Date
Bastien Nocera
9b3e9d9e8c elan: Fix frames being leaked
==24440== 14,416 bytes in 2 blocks are possibly lost in loss record 9,233 of 9,261
==24440==    at 0x483980B: malloc (vg_replace_malloc.c:309)
==24440==    by 0x7846BB8: g_malloc (gmem.c:102)
==24440==    by 0x48A2ABC: elan_process_frame_thirds (elan.c:277)
==24440==    by 0x785FB37: g_slist_foreach (gslist.c:864)
==24440==    by 0x48A57EE: elan_submit_image (elan.c:320)
==24440==    by 0x48A57EE: capture_complete (elan.c:591)
==24440==    by 0x4880C9C: fpi_ssm_mark_completed (fpi-ssm.c:369)
==24440==    by 0x4881003: fpi_ssm_mark_failed (fpi-ssm.c:437)
==24440==    by 0x48A5424: elan_cmd_cb (elan.c:347)
==24440==    by 0x4882296: transfer_finish_cb (fpi-usb-transfer.c:351)
==24440==    by 0x79BFC68: g_task_return_now (gtask.c:1214)
==24440==    by 0x79BFCA8: complete_in_idle_cb (gtask.c:1228)
==24440==    by 0x78410BD: g_main_dispatch (gmain.c:3272)
==24440==    by 0x78410BD: g_main_context_dispatch (gmain.c:3937)
2019-12-06 16:22:26 +01:00
Marco Trevisan (Treviño)
bb0ef04b85 ci: Partially hardcode the fedora image path 2019-12-05 17:31:46 +01:00
Benjamin Berg
0a475196e0 ci: Use CI generated build image 2019-12-05 14:38:46 +01:00
Benjamin Berg
1dee7985b9 ci: Remove Dockerfile as it is replaced by new logic 2019-12-05 14:38:46 +01:00
Benjamin Berg
a1a3933191 ci: Add fedora image builder target for schedule 2019-12-05 14:38:46 +01:00
Benjamin Berg
9c8360ad67 ci: Do not run usual targets from a scheduled job
This is in preparation to building docker images automatically.
2019-12-05 14:14:13 +01:00
Benjamin Berg
0c7d2d8ecd ci: Define a variable for the fedora docker image 2019-12-05 13:56:12 +01:00
Benjamin Berg
6209b22e3b print: Fix match error propagation
The FPI_MATCH_ERROR constant was set to 0, however it is propagated to
the task completion using g_task_propagate_int. As g_task_propagate_int
will always return -1 on error, we either need to add an explicit -1
check or we just need to match the semantics.

Change the constant to -1, also rearange FP_MATCH_SUCCESS so that it
does not end up being 0.
2019-12-05 11:46:11 +00:00
Benjamin Berg
f404a69b73 tests: Test finger removal after minutiae scan completion 2019-12-04 19:49:07 +00:00
Benjamin Berg
50a837573d tests: Update helper functions for new virtual-image features
This also changes the code to keep the connection open and adds
automatic mainloop iteration to ensure the driver processes the request.
This is important so we will not deadlock when we send multiple
requests.
2019-12-04 19:49:07 +00:00
Benjamin Berg
3e958ab7b4 virtual-image: Allow fine control over the finger state
Add commands to disable automatic finger reporting for images and to
send a specific finger report. This is useful to test more code paths
inside the image-device code.
2019-12-04 19:49:07 +00:00
Benjamin Berg
a8a2a757ed virtual-image: Only print warnings for actual errors
No need to warn for lost connections (if we don't expect more data) or
cancellations.
2019-12-04 19:49:07 +00:00
Benjamin Berg
702255b182 image-device: Print warning for incorrect deactivation
Drivers may not handle deactivation properly when they are awaiting a
finger. This should be prevented by the internal FpImageDevice state
machine.
2019-12-04 19:49:07 +00:00
Marco Trevisan (Treviño)
a64ac2296b vfs0051: Use named SSMs for usb async exchanges 2019-12-04 20:43:53 +01:00
Marco Trevisan (Treviño)
a522e3fd6f fpi-ssm: Improve debugging of SSM using driver infos
Always mention the driver that is triggering it
2019-12-04 20:43:53 +01:00
Marco Trevisan (Treviño)
65828e0e56 fpi-ssm: Support named SSMs and use a fallback macro
Add fpi_ssm_new_full() that allows to pass a name to the state-machine
constructor, not to change all the drivers, provide a fpi_ssm_new() macro
that stringifies the nr_parameters value (usually an enum value) as the name
so that we can use it for better debugging.
2019-12-04 20:43:53 +01:00
Marco Trevisan (Treviño)
fe967d0ac2 ci: Build flatpak automatically only on master and tagso
While allowing to build it manually in other cases
2019-12-04 19:49:40 +01:00
Benjamin Berg
10c5bdade7 uru4000: Fix control transfer request type
During porting the request type was accidentally changed from VENDOR to
DEVICE. Change the type back to VENDOR.

See: #205
2019-12-04 18:00:02 +00:00
Benjamin Berg
8f21aa1b26 uru4000: Fix state change from IRQ handler
The IRQ handler will re-register itself automatically. However, if this
happens after the callback is called, then the check whether the IRQ
handler is running fails.

Re-start the IRQ handler before calling the callback. This way the state
changes happening from the callback will see the correct IRQ handler
registration state.

See: #205
2019-12-04 18:00:02 +00:00
Benjamin Berg
7b68344394 image-device: Prevent deactivation when waiting for finger
At the end of enroll, the image device would put the driver into the
AWAIT_FINGER_ON state and then deactivate the device afterwards. Doing
this adds additional complexity to drivers which would need to handle
both cancellation and normal deactivation from that state.

Only put the device into the AWAIT_FINGER_ON state when we know that
another enroll stage is needed. This avoids the critical state
transition simplifying the driver state machine.

Fixes: #203
Fixes: 689aff0232
2019-12-04 18:00:02 +00:00
Benjamin Berg
dccb5b3ab2 elan: Fix internal state machine to ensure correct deactivation
During calibration, the internal state was stored as INACTIVE. This is
not true though, the device is actively running state machines.

Move the state update to the start of the operation, therefore ensuring
we don't deactivate without completing the SSM.

Note that this will prevent a crash, but the driver still does not
behave quite correctly when such a state change does happen. However,
this is just a safety measure as the state change should not happen in
the first place.

See: #203
2019-12-04 18:00:02 +00:00
Marco Trevisan (Treviño)
2fcc2deb43 ci: Use --werror by default in meson at build time 2019-12-04 18:52:20 +01:00
Marco Trevisan (Treviño)
c678b9021c meson: Use stricter C arguments to compile libfprint
These are based on what mutter does, being a quite strict project on c code
quality.
2019-12-04 18:52:20 +01:00
Marco Trevisan (Treviño)
b2e55308d6 meson: Move generated source to fpi- prefix and use more readable code
Instead of concatenating strings, use an array of strings and finally join
them using newline.
2019-12-04 18:52:20 +01:00
Marco Trevisan (Treviño)
a176fa1d34 meson: Include fpi-context.h in generated fp-drivers.c 2019-12-04 18:52:19 +01:00
Marco Trevisan (Treviño)
cacce50ef9 vfs0050: Use proper casting summing pointers first
Cast the pointers as what fpi usb transfer expects.
2019-12-04 18:52:19 +01:00
Marco Trevisan (Treviño)
5ab4d6c454 vfs5011: Cast gpointer data values to proper type to do math operations 2019-12-04 18:52:19 +01:00
Marco Trevisan (Treviño)
0c655be159 gtk-demo: Use G_DECLARE to avoid missing declarations 2019-12-04 18:52:19 +01:00
Marco Trevisan (Treviño)
2b8c524928 cleanup: Use static functions for non-declared methods 2019-12-04 18:52:19 +01:00
Marco Trevisan (Treviño)
2f2ea65d32 fp-device: Remove unused timeout function and source data
These were probably added in previous iterations, but they are not uneeded
anymore as the GSource embeds already a callback function.

So make just this clearer in the dispatch function.
2019-12-04 18:52:18 +01:00
Marco Trevisan (Treviño)
1d48b70f38 storage: Include storage header so that we have declarations 2019-12-04 18:52:18 +01:00
Marco Trevisan (Treviño)
35e9f19c0c nbis: Make the extern global bozworth 'y' variable as bz_y
Othewise this could create issues with other 'y' variable definitions
shadowing it.

Add a cocci file that performs the change automatically
2019-12-04 18:52:18 +01:00
Marco Trevisan (Treviño)
70a0d6f0fe nbis/log: Don't use old-style function declarations 2019-12-04 18:52:18 +01:00
Marco Trevisan (Treviño)
7ed9b0c2f9 cleanup: Don't make nbis depend on libfprint built-sources
Now that nbis is a static library it should be possible to compile it
without any fprint-built dependency, although since it included fp_internal
there was a compile-time dependency on the fp-enums that can be generated at
later times.

So:
 - Move nbis-helpers to nbis includes (and remove inclusion in fp_internal)
 - Move the Minutiae definitions inside a standalone fpi-minutiae header
 - Include fpi-minutiae.h in fp_internal.h
 - Include nbis-hepers.h and fpi-minutiae.h in nbis' lfs.h
 - Adapt missing definitions in libfprint
2019-12-04 18:50:46 +01:00
Marco Trevisan (Treviño)
6a090656b6 nbis: Add a global include file with all the definitions ignoring erros
The nbis headers are full of redundant declarations, we can't fix them all
now, so in the mean time let's use an header using pragma to ignore such
errors.

Add the error to nbis private include folder that should be used only by
headers of libfprint-nbis.
2019-12-04 18:44:39 +01:00
Marco Trevisan (Treviño)
e1d181887f meson: Add the include directories to deps
So we don't have to repeat them everywhere.
2019-12-04 16:57:39 +01:00
Benjamin Berg
e143f12e57 meson: Build nbis separately to allow changing flags
As nbis is an external source bundle, it does not necessarily make sense
to enable/fix all warnings to the extend we do for our own library code.

As such, separate the build process into multiple stages.
2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño)
e64c18f8de cpp-test: Fix indentation 2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño)
7e70344b4a meson: Use add_project_arguments for common cflags
We were passing around the common cflags and setting them for each library
or executable, but this is just a repetition given we can just use
add_project_arguments for this.
2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño)
44af2173a8 fp-print: Clear the data not the description when setting the property 2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño)
e7c7f368c9 drivers, examples: Don't use -Wno-pointer-sign and fix relative errors 2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño)
a29586f398 fpi-usb: Use unsigned length for USB async transfers
Properly follow function signature using a temporary gsize variable address
to make the function use the same pointer type and avoid troubles at
deferencing it, while use automatic-casting to switch to signed one if
transfer succeeded.
2019-12-04 16:06:24 +01:00
Marco Trevisan (Treviño)
98cd1c2680 ci: Use a docker image for builds and tests
Avoid repeating the machine updates and deps installation at every stage,
just reuse the docker image

Registered images are at:
  https://gitlab.freedesktop.org/libfprint/libfprint/container_registry
2019-12-04 14:59:03 +00:00
Benjamin Berg
ae285e790d tests: Fix image writing on big endian
The code tried to only write the RGB bytes of FORMAT_RGB24, however, the
in-memory layout is different on big-endian which would result in the
wrong bytes being written.

Fix this by simply also writing the byte we do not care about.
2019-12-04 13:23:08 +01:00
39 changed files with 510 additions and 228 deletions

View File

@@ -1,40 +1,46 @@
image: fedora:rawhide
variables:
FEDORA_TAG: rawhide
FEDORA_VERSION: rawhide
FEDORA_IMAGE: "$CI_REGISTRY/libfprint/$CI_PROJECT_NAME/fedora/$FEDORA_VERSION:$FEDORA_TAG"
BUNDLE: "org.freedesktop.libfprint.Demo.flatpak"
LAST_ABI_BREAK: "056ea541ddc97f5806cffbd99a12dc87e4da3546"
include:
- project: 'wayland/ci-templates'
ref: master
file: '/templates/fedora.yml'
stages:
- check-source
- build
- test
- flatpack
variables:
DEPENDENCIES: libgusb-devel glib2-devel nss-devel pixman-devel systemd meson gtk-doc
gcc gcc-c++ glibc-devel libX11-devel libXv-devel gtk3-devel flatpak-builder
gobject-introspection-devel python3-cairo python3-gobject umockdev
BUNDLE: "org.freedesktop.libfprint.Demo.flatpak"
LAST_ABI_BREAK: "056ea541ddc97f5806cffbd99a12dc87e4da3546"
image: "$FEDORA_IMAGE"
.build_one_driver_template: &build_one_driver
script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES
# Build with a driver that doesn't need imaging, or nss
- meson -Ddrivers=$driver . _build
- meson --werror -Ddrivers=$driver . _build
- ninja -C _build
- rm -rf _build/
.build_template: &build
script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES
# And build with everything
- meson -Ddrivers=all . _build
- meson --werror -Ddrivers=all . _build
- ninja -C _build
- ninja -C _build install
.build_template: &check_abi
script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES doxygen libabigail git
- ./.ci/check-abi ${LAST_ABI_BREAK} $(git rev-parse HEAD)
build:
stage: build
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
variables:
driver: virtual_image
<<: *build_one_driver
@@ -43,24 +49,30 @@ build:
test:
stage: test
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES
- meson -Ddrivers=all . _build
- meson --werror -Ddrivers=all . _build
- ninja -C _build
- meson test -C _build --verbose --no-stdsplit
test_valgrind:
stage: test
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES valgrind
- meson -Ddrivers=all . _build
- ninja -C _build
- meson test -C _build --verbose --no-stdsplit --setup=valgrind
test_indent:
stage: check-source
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck git uncrustify
- scripts/uncrustify.sh --check
.flatpak_script_template: &flatpak_script
@@ -86,9 +98,12 @@ test_indent:
<<: *flatpak_script
<<: *flatpak_artifacts
flatpak master:
.flatpak_master_template: &flatpak_master
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:3.32
stage: flatpack
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
variables:
MANIFEST_PATH: "demo/org.freedesktop.libfprint.Demo.json"
# From demo/org.freedesktop.libfprint.Demo.json
@@ -96,3 +111,51 @@ flatpak master:
FLATPAK_MODULE: "libfprint"
DBUS_ID: "org.freedesktop.libfprint.Demo"
<<: *flatpak
flatpak-auto master:
<<: *flatpak_master
when: always
only:
- tags
- master
flatpak-manual master:
<<: *flatpak_master
when: manual
except:
- tags
- master
# CONTAINERS creation stage
container_fedora_build:
extends: .fedora@container-build
only:
variables:
- $CI_PIPELINE_SOURCE == "schedule" && $CRON_TASK == "BUILD_CI_IMAGES"
variables:
GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
# a list of packages to install
FEDORA_RPMS:
doxygen
flatpak-builder
gcc
gcc-c++
git
glib2-devel
glibc-devel
gobject-introspection-devel
gtk-doc
gtk3-devel
libabigail
libgusb-devel
libX11-devel
libXv-devel
meson
nss-devel
pixman-devel
python3-cairo
python3-gobject
systemd
umockdev
uncrustify
valgrind

View File

@@ -22,9 +22,11 @@
#include <gtk/gtk.h>
#include <libfprint/fprint.h>
typedef GtkApplication LibfprintDemo;
typedef GtkApplicationClass LibfprintDemoClass;
struct _LibfprintDemo
{
GtkApplication parent;
};
G_DECLARE_FINAL_TYPE (LibfprintDemo, libfprint_demo, FP, DEMO, GtkApplication)
G_DEFINE_TYPE (LibfprintDemo, libfprint_demo, GTK_TYPE_APPLICATION)
typedef enum {
@@ -33,7 +35,7 @@ typedef enum {
IMAGE_DISPLAY_BINARY = 1 << 1
} ImageDisplayFlags;
typedef struct
struct _LibfprintDemoWindow
{
GtkApplicationWindow parent_instance;
@@ -52,10 +54,9 @@ typedef struct
FpImage *img;
ImageDisplayFlags img_flags;
} LibfprintDemoWindow;
typedef GtkApplicationWindowClass LibfprintDemoWindowClass;
};
G_DECLARE_FINAL_TYPE (LibfprintDemoWindow, libfprint_demo_window, FP, DEMO_WINDOW, GtkApplicationWindow)
G_DEFINE_TYPE (LibfprintDemoWindow, libfprint_demo_window, GTK_TYPE_APPLICATION_WINDOW)
typedef enum {

View File

@@ -13,10 +13,7 @@ executable('gtk-libfprint-test',
include_directories: [
root_inc,
],
c_args: [
common_cflags,
'-DPACKAGE_VERSION="' + meson.project_version() + '"'
],
c_args: '-DPACKAGE_VERSION="' + meson.project_version() + '"',
install: true,
install_dir: bindir)

View File

@@ -211,6 +211,7 @@ fpi_print_bz3_match
FpiSsmCompletedCallback
FpiSsmHandlerCallback
fpi_ssm_new
fpi_ssm_new_full
fpi_ssm_free
fpi_ssm_start
fpi_ssm_start_subsm

View File

@@ -6,10 +6,10 @@
int main (int argc, char **argv)
{
FpContext *ctx;
FpContext *ctx;
ctx = fp_context_new ();
g_object_unref (ctx);
ctx = fp_context_new ();
g_object_unref (ctx);
return 0;
return 0;
}

View File

@@ -6,8 +6,7 @@ foreach example: examples
dependencies: [ libfprint_dep, glib_dep ],
include_directories: [
root_inc,
],
c_args: common_cflags)
])
endforeach
executable('cpp-test',
@@ -15,5 +14,4 @@ executable('cpp-test',
dependencies: libfprint_dep,
include_directories: [
root_inc,
],
c_args: common_cflags)
])

View File

@@ -20,6 +20,7 @@
*/
#include <libfprint/fprint.h>
#include "storage.h"
#include <errno.h>
#include <stdio.h>
@@ -57,7 +58,7 @@ load_data (void)
GVariantDict *res;
GVariant *var;
g_autofree gchar *contents = NULL;
gssize length = 0;
gsize length = 0;
if (!g_file_get_contents (STORAGE_FILE, &contents, &length, NULL))
{

View File

@@ -686,7 +686,7 @@ enum activate_states {
ACTIVATE_NUM_STATES,
};
void
static void
activate_read_regs_cb (FpImageDevice *dev, GError *error,
unsigned char *regs, void *user_data)
{

View File

@@ -41,7 +41,7 @@
#include "drivers_api.h"
#include "elan.h"
unsigned char
static unsigned char
elan_get_pixel (struct fpi_frame_asmbl_ctx *ctx,
struct fpi_frame *frame, unsigned int x,
unsigned int y)
@@ -91,7 +91,7 @@ G_DECLARE_FINAL_TYPE (FpiDeviceElan, fpi_device_elan, FPI, DEVICE_ELAN,
FpImageDevice);
G_DEFINE_TYPE (FpiDeviceElan, fpi_device_elan, FP_TYPE_IMAGE_DEVICE);
int
static int
cmp_short (const void *a, const void *b)
{
return (int) (*(short *) a - *(short *) b);
@@ -320,6 +320,7 @@ elan_submit_image (FpImageDevice *dev)
g_slist_foreach (raw_frames, (GFunc) self->process_frame, &frames);
fpi_do_movement_estimation (&assembling_ctx, frames);
img = fpi_assemble_frames (&assembling_ctx, frames);
g_slist_free_full (frames, g_free);
fpi_image_device_image_captured (dev, img);
}
@@ -776,7 +777,6 @@ calibrate_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
}
else
{
self->dev_state = FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON;
elan_capture (dev);
}
@@ -966,6 +966,7 @@ elan_change_state (FpImageDevice *idev)
{
case FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON:
/* activation completed or another enroll stage started */
self->dev_state = FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON;
elan_calibrate (dev);
break;

View File

@@ -407,7 +407,7 @@ static gboolean
parse_print_data (GVariant *data,
guint8 *finger,
const guint8 **user_id,
gssize *user_id_len)
gsize *user_id_len)
{
g_autoptr(GVariant) user_id_var = NULL;
@@ -506,7 +506,7 @@ list_msg_cb (FpiDeviceSynaptics *self,
get_enroll_templates_resp->templates[n].user_id,
get_enroll_templates_resp->templates[n].finger_id);
userid = get_enroll_templates_resp->templates[n].user_id;
userid = (gchar *) get_enroll_templates_resp->templates[n].user_id;
print = fp_print_new (FP_DEVICE (self));
uid = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,

View File

@@ -375,7 +375,7 @@ read_msg_cb (FpiUsbTransfer *transfer, FpDevice *device,
goto err;
}
if (strncmp (udata->buffer, "Ciao", 4) != 0)
if (strncmp ((char *) udata->buffer, "Ciao", 4) != 0)
{
fp_err ("no Ciao for you!!");
error = fpi_device_error_new_msg (FP_DEVICE_ERROR_PROTO,

View File

@@ -332,6 +332,8 @@ irq_handler (FpiUsbTransfer *transfer,
return;
}
start_irq_handler (imgdev);
type = GUINT16_FROM_BE (*((uint16_t *) data));
fp_dbg ("recv irq type %04x", type);
@@ -344,8 +346,6 @@ irq_handler (FpiUsbTransfer *transfer,
urudev->irq_cb (imgdev, NULL, type, urudev->irq_cb_data);
else
fp_dbg ("ignoring interrupt");
start_irq_handler (imgdev);
}
static void

View File

@@ -399,7 +399,7 @@ interrupt_callback (FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error)
{
FpDeviceVfs0050 *self = FPI_DEVICE_VFS0050 (device);
char *interrupt = transfer->buffer;
unsigned char *interrupt = transfer->buffer;
/* we expect a cancellation error when the device is deactivating
* go into the SSM_CLEAR_EP2 state in that case. */
@@ -595,7 +595,8 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev)
/* Receive chunk of data */
transfer = fpi_usb_transfer_new (dev);
fpi_usb_transfer_fill_bulk_full (transfer, 0x82,
(void *) self->lines_buffer + self->bytes,
(guint8 *)
(self->lines_buffer + self->bytes),
VFS_USB_BUFFER_SIZE, NULL);
transfer->ssm = ssm;
fpi_usb_transfer_submit (transfer, VFS_USB_TIMEOUT, NULL,

View File

@@ -190,11 +190,13 @@ usbexchange_loop (FpiSsm *ssm, FpDevice *_dev)
static void
usb_exchange_async (FpiSsm *ssm,
struct usbexchange_data *data)
struct usbexchange_data *data,
const char *exchange_name)
{
FpiSsm *subsm = fpi_ssm_new (FP_DEVICE (data->device),
usbexchange_loop,
data->stepcount);
FpiSsm *subsm = fpi_ssm_new_full (FP_DEVICE (data->device),
usbexchange_loop,
data->stepcount,
exchange_name);
fpi_ssm_set_data (subsm, data, NULL);
fpi_ssm_start_subsm (ssm, subsm);
@@ -210,8 +212,8 @@ vfs5011_get_deviation2 (struct fpi_line_asmbl_ctx *ctx, GSList *row1, GSList *ro
int res = 0, mean = 0, i;
const int size = 64;
buf1 = row1->data + 56;
buf2 = row2->data + 168;
buf1 = (unsigned char *) row1->data + 56;
buf2 = (unsigned char *) row2->data + 168;
for (i = 0; i < size; i++)
mean += (int) buf1[i] + (int) buf2[i];
@@ -232,7 +234,7 @@ vfs5011_get_pixel (struct fpi_line_asmbl_ctx *ctx,
GSList *row,
unsigned x)
{
unsigned char *data = row->data + 8;
unsigned char *data = (unsigned char *) row->data + 8;
return data[x];
}
@@ -684,7 +686,7 @@ activate_loop (FpiSsm *ssm, FpDevice *_dev)
self->init_sequence.receive_buf =
g_malloc0 (VFS5011_RECEIVE_BUF_SIZE);
self->init_sequence.timeout = 1000;
usb_exchange_async (ssm, &self->init_sequence);
usb_exchange_async (ssm, &self->init_sequence, "ACTIVATE REQUEST");
break;
case DEV_ACTIVATE_INIT_COMPLETE:
@@ -716,7 +718,7 @@ activate_loop (FpiSsm *ssm, FpDevice *_dev)
self->init_sequence.receive_buf =
g_malloc0 (VFS5011_RECEIVE_BUF_SIZE);
self->init_sequence.timeout = VFS5011_DEFAULT_WAIT_TIMEOUT;
usb_exchange_async (ssm, &self->init_sequence);
usb_exchange_async (ssm, &self->init_sequence, "PREPARE CAPTURE");
break;
}
@@ -769,7 +771,7 @@ open_loop (FpiSsm *ssm, FpDevice *_dev)
self->init_sequence.receive_buf =
g_malloc0 (VFS5011_RECEIVE_BUF_SIZE);
self->init_sequence.timeout = VFS5011_DEFAULT_WAIT_TIMEOUT;
usb_exchange_async (ssm, &self->init_sequence);
usb_exchange_async (ssm, &self->init_sequence, "DEVICE OPEN");
break;
}
;

View File

@@ -47,6 +47,7 @@ struct _FpDeviceVirtualImage
gint socket_fd;
gint client_fd;
gboolean automatic_finger;
FpImage *recv_img;
gint recv_img_hdr[2];
};
@@ -75,9 +76,9 @@ recv_image_img_recv_cb (GObject *source_object,
{
if (!success)
{
g_warning ("Error receiving header for image data: %s", error->message);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
return;
g_warning ("Error receiving header for image data: %s", error->message);
}
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
@@ -89,9 +90,11 @@ recv_image_img_recv_cb (GObject *source_object,
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
device = FP_IMAGE_DEVICE (self);
fpi_image_device_report_finger_status (device, TRUE);
if (self->automatic_finger)
fpi_image_device_report_finger_status (device, TRUE);
fpi_image_device_image_captured (device, g_steal_pointer (&self->recv_img));
fpi_image_device_report_finger_status (device, FALSE);
if (self->automatic_finger)
fpi_image_device_report_finger_status (device, FALSE);
/* And, listen for more images from the same client. */
recv_image (self, G_INPUT_STREAM (source_object));
@@ -113,9 +116,10 @@ recv_image_hdr_recv_cb (GObject *source_object,
{
if (!success)
{
g_warning ("Error receiving header for image data: %s", error->message);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) ||
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CLOSED))
return;
g_warning ("Error receiving header for image data: %s", error->message);
}
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
@@ -147,6 +151,17 @@ recv_image_hdr_recv_cb (GObject *source_object,
fpi_device_error_new (self->recv_img_hdr[1]));
break;
case -3:
/* -3 sets/clears automatic finger detection for images */
self->automatic_finger = !!self->recv_img_hdr[1];
break;
case -4:
/* -4 submits a finger detection report */
fpi_image_device_report_finger_status (FP_IMAGE_DEVICE (self),
!!self->recv_img_hdr[1]);
break;
default:
/* disconnect client, it didn't play fair */
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
@@ -213,6 +228,7 @@ new_connection_cb (GObject *source_object, GAsyncResult *res, gpointer user_data
}
dev->connection = connection;
dev->automatic_finger = TRUE;
stream = g_io_stream_get_input_stream (G_IO_STREAM (connection));
recv_image (dev, stream);

View File

@@ -1382,23 +1382,11 @@ fp_device_list_prints_finish (FpDevice *device,
typedef struct
{
GSource source;
FpDevice *device;
FpTimeoutFunc callback;
gpointer user_data;
GSource source;
FpDevice *device;
} FpDeviceTimeoutSource;
gboolean
device_timeout_cb (gpointer user_data)
{
FpDeviceTimeoutSource *source = user_data;
source->callback (source->device, source->user_data);
return G_SOURCE_REMOVE;
}
void
static void
timeout_finalize (GSource *source)
{
FpDeviceTimeoutSource *timeout_source = (FpDeviceTimeoutSource *) source;
@@ -1409,11 +1397,12 @@ timeout_finalize (GSource *source)
}
static gboolean
timeout_dispatch (GSource *source, GSourceFunc callback, gpointer user_data)
timeout_dispatch (GSource *source, GSourceFunc gsource_func, gpointer user_data)
{
FpDeviceTimeoutSource *timeout_source = (FpDeviceTimeoutSource *) source;
FpTimeoutFunc callback = (FpTimeoutFunc) gsource_func;
((FpTimeoutFunc) callback)(timeout_source->device, user_data);
callback (timeout_source->device, user_data);
return G_SOURCE_REMOVE;
}
@@ -1496,7 +1485,6 @@ fpi_device_add_timeout (FpDevice *device,
source = (FpDeviceTimeoutSource *) g_source_new (&timeout_funcs,
sizeof (FpDeviceTimeoutSource));
source->device = device;
source->user_data = user_data;
g_source_attach (&source->source, NULL);
g_source_set_callback (&source->source, (GSourceFunc) func, user_data, destroy_notify);

View File

@@ -50,7 +50,9 @@ typedef struct
{
FpImageDeviceState state;
gboolean active;
gboolean cancelling;
gboolean enroll_await_on_pending;
gint enroll_stage;
guint pending_activation_timeout_id;
@@ -139,6 +141,9 @@ fp_image_device_deactivate (FpDevice *device)
fp_dbg ("Already deactivated, ignoring request.");
return;
}
if (!priv->cancelling && priv->state == FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON)
g_warning ("Deactivating image device while waiting for finger, this should not happen.");
priv->state = FP_IMAGE_DEVICE_STATE_INACTIVE;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]);
@@ -202,6 +207,7 @@ static void
fp_image_device_cancel_action (FpDevice *device)
{
FpImageDevice *self = FP_IMAGE_DEVICE (device);
FpImageDevicePrivate *priv = fp_image_device_get_instance_private (self);
FpDeviceAction action;
action = fpi_device_get_current_action (device);
@@ -213,7 +219,9 @@ fp_image_device_cancel_action (FpDevice *device)
action == FP_DEVICE_ACTION_IDENTIFY ||
action == FP_DEVICE_ACTION_CAPTURE)
{
priv->cancelling = TRUE;
fp_image_device_deactivate (FP_DEVICE (self));
priv->cancelling = FALSE;
/* XXX: Some nicer way of doing this would be good. */
fpi_device_action_error (FP_DEVICE (self),
@@ -256,6 +264,7 @@ fp_image_device_start_capture_action (FpDevice *device)
}
priv->enroll_stage = 0;
priv->enroll_await_on_pending = FALSE;
/* The device might still be deactivating from a previous call.
* In that situation, try to wait for a bit before reporting back an
@@ -385,6 +394,22 @@ fp_image_device_init (FpImageDevice *self)
}
static void
fp_image_device_enroll_maybe_await_finger_on (FpImageDevice *self)
{
FpImageDevicePrivate *priv = fp_image_device_get_instance_private (self);
if (priv->enroll_await_on_pending)
{
priv->enroll_await_on_pending = FALSE;
fp_image_device_change_state (self, FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON);
}
else
{
priv->enroll_await_on_pending = TRUE;
}
}
static void
fpi_image_device_minutiae_detected (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
@@ -446,11 +471,16 @@ fpi_image_device_minutiae_detected (GObject *source_object, GAsyncResult *res, g
fpi_device_enroll_progress (device, priv->enroll_stage,
g_steal_pointer (&print), error);
/* Start another scan or deactivate. */
if (priv->enroll_stage == IMG_ENROLL_STAGES)
{
fpi_device_enroll_complete (device, g_object_ref (enroll_print), NULL);
fp_image_device_deactivate (device);
}
else
{
fp_image_device_enroll_maybe_await_finger_on (FP_IMAGE_DEVICE (device));
}
}
else if (action == FP_DEVICE_ACTION_VERIFY)
{
@@ -572,13 +602,15 @@ fpi_image_device_report_finger_status (FpImageDevice *self,
* 2. We are still deactivating the device after an action completed
* 3. We were waiting for finger removal to start the new action
* Either way, we always end up deactivating except for the enroll case.
* XXX: This is not quite correct though, as we assume we need another finger
* scan even though we might be processing the last one (successfully).
*
* The enroll case is special as AWAIT_FINGER_ON should only happen after
* minutiae detection to prevent deactivation (without cancellation)
* from the AWAIT_FINGER_ON state.
*/
if (action != FP_DEVICE_ACTION_ENROLL)
fp_image_device_deactivate (device);
else
fp_image_device_change_state (self, FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON);
fp_image_device_enroll_maybe_await_finger_on (self);
}
}

View File

@@ -19,8 +19,9 @@
*/
#include "fpi-image.h"
#include "fpi-log.h"
#include "nbis/include/lfs.h"
#include <nbis.h>
#if HAVE_PIXMAN
#include <pixman.h>

View File

@@ -20,10 +20,10 @@
#include "fpi-print.h"
#include "fpi-image.h"
#include "fpi-log.h"
#include "fpi-device.h"
#include "nbis/include/bozorth.h"
#include "nbis/include/lfs.h"
#include <nbis.h>
/**
* SECTION: fp-print
@@ -207,7 +207,7 @@ fp_print_set_property (GObject *object,
break;
case PROP_FPI_DATA:
g_clear_pointer (&self->description, g_variant_unref);
g_clear_pointer (&self->data, g_variant_unref);
self->data = g_value_dup_variant (value);
break;

View File

@@ -1,6 +1,6 @@
/*
* Internal/private definitions for libfprint
* Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
* Copyright (C) 2019 Marco Trevisan <marco.trevisan@canonical.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -17,38 +17,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef __FPRINT_INTERNAL_H__
#define __FPRINT_INTERNAL_H__
#pragma once
#include "fpi-log.h"
#include "nbis-helpers.h"
#include "fpi-image.h"
#include "fpi-image-device.h"
/* fp_minutia structure definition */
struct fp_minutia
{
int x;
int y;
int ex;
int ey;
int direction;
double reliability;
int type;
int appearing;
int feature_id;
int *nbrs;
int *ridge_counts;
int num_nbrs;
};
/* fp_minutiae structure definition */
struct fp_minutiae
{
int alloc;
int num;
struct fp_minutia **list;
};
#endif
#include "fpi-minutiae.h"

45
libfprint/fpi-minutiae.h Normal file
View File

@@ -0,0 +1,45 @@
/*
* Internal/private definitions for libfprint
* Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
/* fp_minutia structure definition */
struct fp_minutia
{
int x;
int y;
int ex;
int ey;
int direction;
double reliability;
int type;
int appearing;
int feature_id;
int *nbrs;
int *ridge_counts;
int num_nbrs;
};
/* fp_minutiae structure definition */
struct fp_minutiae
{
int alloc;
int num;
struct fp_minutia **list;
};

View File

@@ -21,13 +21,13 @@ typedef enum {
/**
* FpiMatchResult:
* @FPI_MATCH_ERROR: An error occured during matching
* @FPI_MATCH_SUCCESS: The prints matched
* @FPI_MATCH_FAIL: The prints did not match
* @FPI_MATCH_SUCCESS: The prints matched
*/
typedef enum {
FPI_MATCH_ERROR = 0,
FPI_MATCH_SUCCESS,
FPI_MATCH_ERROR = -1, /* -1 for g_task_propagate_int */
FPI_MATCH_FAIL,
FPI_MATCH_SUCCESS,
} FpiMatchResult;
void fpi_print_add_print (FpPrint *print,

View File

@@ -81,6 +81,7 @@
struct _FpiSsm
{
FpDevice *dev;
const char *name;
FpiSsm *parentsm;
gpointer ssm_data;
GDestroyNotify ssm_data_destroy;
@@ -103,13 +104,29 @@ struct _FpiSsm
*
* Allocate a new ssm, with @nr_states states. The @handler callback
* will be called after each state transition.
* This is a macro that calls fpi_ssm_new_full() using the stringified
* version of @nr_states, so will work better with named parameters.
*
* Returns: a new #FpiSsm state machine
*/
/**
* fpi_ssm_new_full:
* @dev: a #fp_dev fingerprint device
* @handler: the callback function
* @nr_states: the number of states
* @name: the name of the state machine (for debug purposes)
*
* Allocate a new ssm, with @nr_states states. The @handler callback
* will be called after each state transition.
*
* Returns: a new #FpiSsm state machine
*/
FpiSsm *
fpi_ssm_new (FpDevice *dev,
FpiSsmHandlerCallback handler,
int nr_states)
fpi_ssm_new_full (FpDevice *dev,
FpiSsmHandlerCallback handler,
int nr_states,
const char *name)
{
FpiSsm *machine;
@@ -120,6 +137,7 @@ fpi_ssm_new (FpDevice *dev,
machine->handler = handler;
machine->nr_states = nr_states;
machine->dev = dev;
machine->name = g_strdup (name);
machine->completed = TRUE;
return machine;
}
@@ -251,6 +269,7 @@ fpi_ssm_free (FpiSsm *machine)
if (machine->ssm_data_destroy)
g_clear_pointer (&machine->ssm_data, machine->ssm_data_destroy);
g_clear_pointer (&machine->error, g_error_free);
g_clear_pointer (&machine->name, g_free);
fpi_ssm_clear_delayed_action (machine);
g_free (machine);
}
@@ -259,7 +278,8 @@ fpi_ssm_free (FpiSsm *machine)
static void
__ssm_call_handler (FpiSsm *machine)
{
fp_dbg ("%p entering state %d", machine, machine->cur_state);
fp_dbg ("[%s] %s entering state %d", fp_device_get_driver (machine->dev),
machine->name, machine->cur_state);
machine->handler (machine, machine->dev);
}
@@ -337,9 +357,11 @@ fpi_ssm_mark_completed (FpiSsm *machine)
machine->completed = TRUE;
if (machine->error)
fp_dbg ("%p completed with error: %s", machine, machine->error->message);
fp_dbg ("[%s] %s completed with error: %s", fp_device_get_driver (machine->dev),
machine->name, machine->error->message);
else
fp_dbg ("%p completed successfully", machine);
fp_dbg ("[%s] %s completed successfully", fp_device_get_driver (machine->dev),
machine->name);
if (machine->callback)
{
GError *error = machine->error ? g_error_copy (machine->error) : NULL;
@@ -383,9 +405,9 @@ fpi_ssm_mark_completed_delayed (FpiSsm *machine,
on_device_timeout_complete, cancellable,
machine, NULL);
source_name = g_strdup_printf ("[%s] ssm %p complete %d",
source_name = g_strdup_printf ("[%s] ssm %s complete %d",
fp_device_get_device_id (machine->dev),
machine, machine->cur_state + 1);
machine->name, machine->cur_state + 1);
g_source_set_name (machine->timeout, source_name);
}
@@ -402,12 +424,15 @@ fpi_ssm_mark_failed (FpiSsm *machine, GError *error)
g_assert (error);
if (machine->error)
{
fp_warn ("SSM already has an error set, ignoring new error %s", error->message);
fp_warn ("[%s] SSM %s already has an error set, ignoring new error %s",
fp_device_get_driver (machine->dev), machine->name, error->message);
g_error_free (error);
return;
}
fp_dbg ("SSM failed in state %d with error: %s", machine->cur_state, error->message);
fp_dbg ("[%s] SSM %s failed in state %d with error: %s",
fp_device_get_driver (machine->dev), machine->name,
machine->cur_state, error->message);
machine->error = g_steal_pointer (&error);
fpi_ssm_mark_completed (machine);
}
@@ -482,9 +507,9 @@ fpi_ssm_next_state_delayed (FpiSsm *machine,
on_device_timeout_next_state, cancellable,
machine, NULL);
source_name = g_strdup_printf ("[%s] ssm %p jump to next state %d",
source_name = g_strdup_printf ("[%s] ssm %s jump to next state %d",
fp_device_get_device_id (machine->dev),
machine, machine->cur_state + 1);
machine->name, machine->cur_state + 1);
g_source_set_name (machine->timeout, source_name);
}
@@ -559,9 +584,9 @@ fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
on_device_timeout_jump_to_state,
cancellable, data, g_free);
source_name = g_strdup_printf ("[%s] ssm %p jump to state %d",
source_name = g_strdup_printf ("[%s] ssm %s jump to state %d",
fp_device_get_device_id (machine->dev),
machine, state);
machine->name, state);
g_source_set_name (machine->timeout, source_name);
}

View File

@@ -60,9 +60,12 @@ typedef void (*FpiSsmHandlerCallback)(FpiSsm *ssm,
FpDevice *dev);
/* for library and drivers */
FpiSsm *fpi_ssm_new (FpDevice *dev,
FpiSsmHandlerCallback handler,
int nr_states);
#define fpi_ssm_new(dev, handler, nr_states) \
fpi_ssm_new_full (dev, handler, nr_states, #nr_states)
FpiSsm *fpi_ssm_new_full (FpDevice *dev,
FpiSsmHandlerCallback handler,
int nr_states,
const char *machine_name);
void fpi_ssm_free (FpiSsm *machine);
void fpi_ssm_start (FpiSsm *ssm,
FpiSsmCompletedCallback callback);

View File

@@ -298,7 +298,7 @@ fpi_usb_transfer_fill_interrupt_full (FpiUsbTransfer *transfer,
transfer->free_buffer = free_func;
}
void
static void
transfer_finish_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
GError *error = NULL;
@@ -454,6 +454,7 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
GError **error)
{
gboolean res;
gsize actual_length;
g_return_val_if_fail (transfer, FALSE);
@@ -469,7 +470,7 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
transfer->endpoint,
transfer->buffer,
transfer->length,
&transfer->actual_length,
&actual_length,
timeout_ms,
NULL,
error);
@@ -485,7 +486,7 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
transfer->idx,
transfer->buffer,
transfer->length,
&transfer->actual_length,
&actual_length,
timeout_ms,
NULL,
error);
@@ -496,7 +497,7 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
transfer->endpoint,
transfer->buffer,
transfer->length,
&transfer->actual_length,
&actual_length,
timeout_ms,
NULL,
error);
@@ -511,6 +512,8 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
if (!res)
transfer->actual_length = -1;
else
transfer->actual_length = actual_length;
return res;
}

View File

@@ -172,29 +172,43 @@ fpi_enums = gnome.mkenums_simple('fpi-enums',
fpi_enums_h = fpi_enums[1]
drivers_sources += configure_file(input: 'empty_file',
output: 'fp-drivers.c',
output: 'fpi-drivers.c',
capture: true,
command: [
'echo',
drivers_type_list + '\n\n' + drivers_type_func
'\n'.join(drivers_type_list + [] + drivers_type_func)
])
mapfile = 'libfprint.ver'
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
deps = [ mathlib_dep, glib_dep, gusb_dep, nss_dep, imaging_dep, gio_dep ]
deps += declare_dependency(include_directories: [
root_inc,
include_directories('nbis/include'),
include_directories('nbis/libfprint-include'),
])
libnbis = static_library('nbis',
nbis_sources,
dependencies: deps,
c_args: cc.get_supported_arguments([
'-Wno-error=redundant-decls',
'-Wno-redundant-decls',
'-Wno-discarded-qualifiers',
]),
install: false)
libfprint = library('fprint',
libfprint_sources + fp_enums + fpi_enums +
drivers_sources + nbis_sources + other_sources,
drivers_sources + other_sources,
soversion: soversion,
version: libversion,
c_args: common_cflags + drivers_cflags,
include_directories: [
root_inc,
include_directories('nbis/include'),
],
c_args: drivers_cflags,
link_args : vflag,
link_depends : mapfile,
link_with: libnbis,
dependencies: deps,
install: true)
@@ -207,9 +221,6 @@ install_headers(['fprint.h'] + libfprint_public_headers, subdir: 'libfprint')
udev_rules = executable('fprint-list-udev-rules',
'fprint-list-udev-rules.c',
include_directories: [
root_inc,
],
dependencies: [ deps, libfprint_dep ],
install: false)
@@ -224,9 +235,6 @@ endif
supported_devices = executable('fprint-list-supported-devices',
'fprint-list-supported-devices.c',
include_directories: [
root_inc,
],
dependencies: [ deps, libfprint_dep ],
install: false)

View File

@@ -896,7 +896,7 @@ for ( k = 0; k < np - 1; k++ ) {
for ( i = 0; i < tot; i++ ) {
int colp_value = colp[ y[i]-1 ][0];
int colp_value = colp[ bz_y[i]-1 ][0];
if ( colp_value < 0 ) {
kk += colp_value;
n++;
@@ -933,7 +933,7 @@ for ( k = 0; k < np - 1; k++ ) {
kk = 0;
for ( i = 0; i < tot; i++ ) {
int diff = colp[ y[i]-1 ][0] - jj;
int diff = colp[ bz_y[i]-1 ][0] - jj;
j = SQUARED( diff );
@@ -942,7 +942,7 @@ for ( k = 0; k < np - 1; k++ ) {
if ( j > TXS && j < CTXS )
kk++;
else
y[i-kk] = y[i];
bz_y[i-kk] = bz_y[i];
} /* END FOR i */
tot -= kk; /* Adjust the total edge pairs TOT based on # of edge pairs skipped */
@@ -958,7 +958,7 @@ for ( k = 0; k < np - 1; k++ ) {
for ( i = tot-1 ; i >= 0; i-- ) {
int idx = y[i] - 1;
int idx = bz_y[i] - 1;
if ( rk[idx] == 0 ) {
sc[idx] = -1;
} else {
@@ -976,7 +976,7 @@ for ( k = 0; k < np - 1; k++ ) {
int pd = 0;
for ( i = 0; i < tot; i++ ) {
int idx = y[i] - 1;
int idx = bz_y[i] - 1;
for ( ii = 1; ii < 4; ii++ ) {
@@ -1476,7 +1476,7 @@ return match_score;
/* extern int rk[ RK_SIZE ]; */
/* extern int cp[ CP_SIZE ]; */
/* extern int rp[ RP_SIZE ]; */
/* extern int y[ Y_SIZE ]; */
/* extern int bz_y[ Y_SIZE ]; */
void bz_sift(
int * ww, /* INPUT and OUTPUT; endpoint groups index; *ww may be bumped by one or by two */
@@ -1507,7 +1507,7 @@ if ( n == 0 && t == 0 ) {
if ( sc[kx-1] != ftt ) {
y[ (*tot)++ ] = kx;
bz_y[ (*tot)++ ] = kx;
rk[kx-1] = sc[kx-1];
sc[kx-1] = ftt;
}
@@ -1553,7 +1553,7 @@ if ( n == l ) {
qq[*qh] = kz;
zz[kz-1] = (*qh)++;
}
y[(*tot)++] = kx;
bz_y[(*tot)++] = kx;
rk[kx-1] = sc[kx-1];
sc[kx-1] = ftt;
}
@@ -1697,12 +1697,12 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
}
t = 0;
y[0] = lim;
bz_y[0] = lim;
cp[0] = 1;
b = 0;
n = 1;
do { /* looping until T < 0 ... */
if ( y[t] - cp[t] > 1 ) {
if (bz_y[t] - cp[t] > 1 ) {
k = sct[cp[t]][t];
j = ctt[k] + 1;
for ( i = 0; i < j; i++ ) {
@@ -1715,25 +1715,25 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
do {
while ( rp[jj] < sct[kk][t] && jj < j )
jj++;
while ( rp[jj] > sct[kk][t] && kk < y[t] )
while ( rp[jj] > sct[kk][t] && kk < bz_y[t] )
kk++;
while ( rp[jj] == sct[kk][t] && kk < y[t] && jj < j ) {
while ( rp[jj] == sct[kk][t] && kk < bz_y[t] && jj < j ) {
sct[k][t+1] = sct[kk][t];
k++;
kk++;
jj++;
}
} while ( kk < y[t] && jj < j );
} while ( kk < bz_y[t] && jj < j );
t++;
cp[t] = 1;
y[t] = k;
bz_y[t] = k;
b = t;
n = 1;
} else {
int tot = 0;
lim = y[t];
lim = bz_y[t];
for ( i = n-1; i < lim; i++ ) {
tot += ct[ sct[i][t] ];
}
@@ -1750,7 +1750,7 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
{
int rk_index = b;
lim = y[t];
lim = bz_y[t];
for ( i = n-1; i < lim; ) {
rk[ rk_index++ ] = sct[ i++ ][ t ];
}
@@ -1760,7 +1760,7 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
t--;
if ( t >= 0 ) {
++cp[t];
n = y[t];
n = bz_y[t];
}
} /* END IF */

View File

@@ -102,7 +102,7 @@ int yl[ YL_SIZE_1 ][ YL_SIZE_2 ];
int rf[RF_SIZE_1][RF_SIZE_2];
int cf[CF_SIZE_1][CF_SIZE_2];
int y[20000];
int bz_y[20000];
#else
int rq[ RQ_SIZE ] = {};
int tq[ TQ_SIZE ] = {};
@@ -122,6 +122,6 @@ int yl[ YL_SIZE_1 ][ YL_SIZE_2 ];
int rf[RF_SIZE_1][RF_SIZE_2] = {};
int cf[CF_SIZE_1][CF_SIZE_2] = {};
int y[20000] = {};
int bz_y[20000] = {};
#endif

View File

@@ -245,7 +245,7 @@ extern int cp[ CP_SIZE ];
extern int rp[ RP_SIZE ];
extern int rf[RF_SIZE_1][RF_SIZE_2];
extern int cf[CF_SIZE_1][CF_SIZE_2];
extern int y[20000];
extern int bz_y[20000];
/**************************************************************************/
/**************************************************************************/

View File

@@ -66,7 +66,8 @@ of the software.
#include <math.h>
#include <stdio.h>
#include <fp_internal.h>
#include <nbis-helpers.h>
#include <fpi-minutiae.h>
/*************************************************************************/
/* OUTPUT FILE EXTENSIONS */

View File

@@ -1,15 +1,16 @@
--- include/lfs.h 2018-08-24 15:31:54.535579623 +0200
+++ include/lfs.h.orig 2018-08-24 15:31:48.781587933 +0200
@@ -66,7 +43,7 @@ of the software.
--- include/lfs.h
+++ include/lfs.h
@@ -66,7 +66,8 @@ of the software.
#include <math.h>
#include <stdio.h>
-#include <an2k.h> /* Needed by to_type9.c */
+#include <fp_internal.h>
+#include <nbis-helpers.h>
+#include <fpi-minutiae.h>
/*************************************************************************/
/* OUTPUT FILE EXTENSIONS */
@@ -154,26 +131,8 @@ typedef struct rotgrids{
@@ -154,26 +155,8 @@ typedef struct rotgrids{
#define DISAPPEARING 0
#define APPEARING 1
@@ -38,7 +39,7 @@
typedef struct feature_pattern{
int type;
@@ -1185,17 +1185,6 @@ extern void bubble_sort_double_inc_2(double *, int *, const int);
@@ -1203,17 +1186,6 @@ extern void bubble_sort_double_inc_2(double *, int *, const int);
extern void bubble_sort_double_dec_2(double *, int *, const int);
extern void bubble_sort_int_inc(int *, const int);

View File

@@ -0,0 +1,35 @@
/*
* Example fingerprint device prints listing and deletion
* Enrolls your right index finger and saves the print to disk
* Copyright (C) 2019 Marco Trevisan <marco.trevisan@canonical.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wredundant-decls"
#include <bozorth.h>
#include <bz_array.h>
#include <defs.h>
#include <lfs.h>
#include <log.h>
#include <morph.h>
#include <mytime.h>
#include <sunrast.h>
#pragma GCC diagnostic pop

View File

@@ -66,7 +66,7 @@ of the software.
/***************************************************************************/
/***************************************************************************/
int open_logfile()
int open_logfile(void)
{
#ifdef LOG_REPORT
fprintf(stderr, "ERROR : open_logfile : fopen : %s\n", LOG_FILE);
@@ -91,7 +91,7 @@ void print2log(char *fmt, ...)
/***************************************************************************/
/***************************************************************************/
int close_logfile()
int close_logfile(void)
{
#ifdef LOG_REPORT
fprintf(stderr, "ERROR : close_logfile : fclose : %s\n", LOG_FILE);

View File

@@ -0,0 +1,21 @@
@ global_y @
identifier y;
@@
int
- y
+ bz_y
[20000];
@@
identifier global_y.y;
@@
- y
+ bz_y
[...]
@@
@@
int
- y
+ bz_y
[20000] = {};

View File

@@ -179,9 +179,16 @@ sed -i 's/[ \t]*$//' `find -name "*.[ch]"`
# Remove usebsd.h
sed -i '/usebsd.h/d' `find -name "*.[ch]"`
# Replace functions with empty parameters using (void)
sed -i 's/^\([[:space:]]*[[:alnum:]_]\+[\*[:space:]]\+'\
'[[:alnum:]_]\+[[:space:]]*\)([[:space:]]*)/\1(void)/g' `find -name "*.[ch]"`
# Use GLib memory management
spatch --sp-file glib-memory.cocci --dir . --in-place
# Rename global "y" variable in "bz_y"
spatch --sp-file remove-global-y.cocci bozorth3/* include/bozorth.h --in-place
# The above leaves an unused variable around, triggering a warning
# remove it.
patch -p0 < glib-mem-warning.patch
patch -p0 < glib-mem-warning.patch

View File

@@ -10,9 +10,6 @@ project('libfprint', [ 'c', 'cpp' ],
gnome = import('gnome')
add_project_arguments([ '-D_GNU_SOURCE' ], language: 'c')
add_project_arguments([ '-DG_LOG_DOMAIN="libfprint"' ], language: 'c')
libfprint_conf = configuration_data()
cc = meson.get_compiler('c')
@@ -23,19 +20,53 @@ glib_min_version = '2.56'
glib_version_def = 'GLIB_VERSION_@0@_@1@'.format(
glib_min_version.split('.')[0], glib_min_version.split('.')[1])
common_cflags = cc.get_supported_arguments([
'-fgnu89-inline',
'-std=gnu99',
'-Wall',
'-Wcast-align',
'-Wformat-nonliteral',
'-Wformat-security',
'-Wformat=2',
'-Wignored-qualifiers',
'-Wlogical-op',
'-Wmissing-declarations',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wpointer-arith',
'-Wshadow',
'-Wtype-limits',
'-Wundef',
'-Wunused',
'-Wstrict-prototypes',
'-Werror-implicit-function-declaration',
'-Wno-pointer-sign',
'-Wshadow',
'-Werror=address',
'-Werror=array-bounds',
'-Werror=empty-body',
'-Werror=init-self',
'-Werror=int-to-pointer-cast',
'-Werror=main',
'-Werror=missing-braces',
'-Werror=nonnull',
'-Werror=redundant-decls',
'-Werror=return-type',
'-Werror=sequence-point',
'-Werror=trigraphs',
'-Werror=write-strings',
'-fno-strict-aliasing',
'-DGLIB_VERSION_MIN_REQUIRED=' + glib_version_def,
'-DGLIB_VERSION_MAX_ALLOWED=' + glib_version_def,
'-D_GNU_SOURCE',
'-DG_LOG_DOMAIN="libfprint"',
])
c_cflags = cc.get_supported_arguments([
'-std=gnu99',
'-Wimplicit-function-declaration',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wold-style-definition',
'-Wstrict-prototypes',
'-Werror=implicit',
'-Werror=pointer-to-int-cast',
])
add_project_arguments(common_cflags + c_cflags, language: 'c')
add_project_arguments(common_cflags, language: 'cpp')
# maintaining compatibility with the previous libtool versioning
# current = binary - interface
@@ -115,14 +146,22 @@ foreach driver: drivers
endforeach
# Export the drivers' types to the core code
drivers_type_list = '#include <glib-object.h>\n'
drivers_type_func = 'void fpi_get_driver_types(GArray *drivers)\n{\n\tGType t;\n'
drivers_type_list = []
drivers_type_func = []
drivers_type_list += '#include <glib-object.h>'
drivers_type_list += '#include "fpi-context.h"'
drivers_type_list += ''
drivers_type_func += 'void fpi_get_driver_types (GArray *drivers)'
drivers_type_func += ' {'
drivers_type_func += ' GType t;'
drivers_type_func += ''
foreach driver: drivers
drivers_type_list += 'extern GType (fpi_device_' + driver + '_get_type) (void);\n'
drivers_type_func += ' t = fpi_device_' + driver + '_get_type(); g_array_append_val (drivers, t);\n'
drivers_type_list += 'extern GType (fpi_device_' + driver + '_get_type) (void);'
drivers_type_func += ' t = fpi_device_' + driver + '_get_type ();'
drivers_type_func += ' g_array_append_val (drivers, t);\n'
endforeach
drivers_type_list += ''
drivers_type_func += '};'
drivers_type_func += '}'
root_inc = include_directories('.')

View File

@@ -36,10 +36,12 @@ c_buf = c_img.get_data()
for x in range(width):
for y in range(height):
# The upper byte is don't care, but the location depends on endianness,
# so just set all of them.
c_buf[y * c_rowstride + x * 4 + 0] = buf[y * width + x]
c_buf[y * c_rowstride + x * 4 + 1] = buf[y * width + x]
c_buf[y * c_rowstride + x * 4 + 2] = buf[y * width + x]
# Byte 4 is don't care
c_buf[y * c_rowstride + x * 4 + 3] = buf[y * width + x]
c_img.mark_dirty()
c_img.write_to_png(sys.argv[1])

View File

@@ -24,20 +24,6 @@ if wrapper:
os.unsetenv('LIBFPRINT_TEST_WRAPPER')
sys.exit(subprocess.check_call(wrap_cmd))
class Connection:
def __init__(self, addr):
self.addr = addr
def __enter__(self):
self.con = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.con.connect(self.addr)
return self.con
def __exit__(self, exc_type, exc_val, exc_tb):
self.con.close()
del self.con
def load_image(img):
png = cairo.ImageSurface.create_from_png(img)
@@ -101,24 +87,51 @@ class VirtualImage(unittest.TestCase):
def setUp(self):
self.dev.open_sync()
self.con = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.con.connect(self.sockaddr)
def tearDown(self):
self.con.close()
del self.con
self.dev.close_sync()
def report_finger(self, state):
with Connection(self.sockaddr) as con:
con.write(struct.pack('ii', -1, 1 if state else 0))
def send_retry(self, retry_error=1, iterate=True):
# The default (1) is too-short
self.sendall(struct.pack('ii', -1, retry_error))
while iterate and ctx.pending():
ctx.iteration(False)
def send_image(self, image):
def send_error(self, device_error=0, iterate=True):
# The default (0) is a generic error
self.sendall(struct.pack('ii', -1, retry_error))
while iterate and ctx.pending():
ctx.iteration(False)
def send_finger_automatic(self, automatic, iterate=True):
# Set whether finger on/off is reported around images
self.con.sendall(struct.pack('ii', -3, 1 if automatic else 0))
while iterate and ctx.pending():
ctx.iteration(False)
def send_finger_report(self, has_finger, iterate=True):
# Send finger on/off
self.con.sendall(struct.pack('ii', -4, 1 if has_finger else 0))
while iterate and ctx.pending():
ctx.iteration(False)
def send_image(self, image, iterate=True):
img = self.prints[image]
with Connection(self.sockaddr) as con:
mem = img.get_data()
mem = mem.tobytes()
assert len(mem) == img.get_width() * img.get_height()
encoded_img = struct.pack('ii', img.get_width(), img.get_height())
encoded_img += mem
mem = img.get_data()
mem = mem.tobytes()
assert len(mem) == img.get_width() * img.get_height()
con.sendall(encoded_img)
encoded_img = struct.pack('ii', img.get_width(), img.get_height())
encoded_img += mem
self.con.sendall(encoded_img)
while iterate and ctx.pending():
ctx.iteration(False)
def test_capture_prevents_close(self):
cancel = Gio.Cancellable()
@@ -169,10 +182,16 @@ class VirtualImage(unittest.TestCase):
while self._step < 1:
ctx.iteration(True)
# Test the image-device path where the finger is removed after
# the minutiae scan is completed.
self.send_finger_automatic(False)
self.send_finger_report(True)
self.send_image(image)
while self._step < 2:
ctx.iteration(True)
self.send_finger_report(False)
self.send_finger_automatic(True)
self.send_image(image)
while self._step < 3:
ctx.iteration(True)