[fprint] [PATCH] imgdev: add support for FP_IMGDRV_NEEDS_REACTIVATION_BETWEEN_ENROLLS flag

Igor Filatov ia.filatov at gmail.com
Fri Feb 16 07:58:09 UTC 2018


I think it would be better if libfprint simply called dev_activate each
time it needed an image, including each enroll step, and then called
dev_deactivate when it's done. Drivers should know whether they need to
reactivate or not. But this will require changes to all the drivers of the
devices that return images... which should actually amount to a few deleted
lines.

On Fri, Feb 16, 2018 at 3:57 AM Marco Trevisan (TreviƱo) <mail at 3v1n0.net>
wrote:

> When a device has this flag set, it has to be re-activated at
> each enroll step, without performing any other cleanup.
>
> This allows to solve this such case in a cleaner way inside
> drivers.
> ---
>  libfprint/fp_internal.h |  1 +
>  libfprint/imgdev.c      | 30 +++++++++++++++++++++++++++---
>  2 files changed, 28 insertions(+), 3 deletions(-)
>
> diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h
> index 74c5f7f..ea46b1e 100644
> --- a/libfprint/fp_internal.h
> +++ b/libfprint/fp_internal.h
> @@ -232,6 +232,7 @@ enum fp_print_data_type
> fpi_driver_get_data_type(struct fp_driver *drv);
>   /* flags for fp_img_driver.flags */
>  #define FP_IMGDRV_SUPPORTS_UNCONDITIONAL_CAPTURE (1 << 0)
> +#define FP_IMGDRV_NEEDS_REACTIVATION_BETWEEN_ENROLLS (1 << 1)
>   struct fp_img_driver {
>         struct fp_driver driver;
> diff --git a/libfprint/imgdev.c b/libfprint/imgdev.c
> index 4408c23..20a1559 100644
> --- a/libfprint/imgdev.c
> +++ b/libfprint/imgdev.c
> @@ -27,6 +27,9 @@
>  #define BOZORTH3_DEFAULT_THRESHOLD 40
>  #define IMG_ENROLL_STAGES 5
>  +static int dev_activate(struct fp_img_dev *imgdev, enum
> fp_imgdev_state state);
> +static void dev_deactivate(struct fp_img_dev *imgdev);
> +
>  static int img_dev_open(struct fp_dev *dev, unsigned long driver_data)
>  {
>         struct fp_img_dev *imgdev = g_malloc0(sizeof(*imgdev));
> @@ -124,6 +127,7 @@ void fpi_imgdev_report_finger_status(struct
> fp_img_dev *imgdev,
>         int r = imgdev->action_result;
>         struct fp_print_data *data = imgdev->acquire_data;
>         struct fp_img *img = imgdev->acquire_img;
> +       struct fp_img_driver *imgdrv =
> fpi_driver_to_img_driver(imgdev->dev->drv);
>         fp_dbg(present ? "finger on sensor" : "finger removed");
>  @@ -158,8 +162,14 @@ void fpi_imgdev_report_finger_status(struct
> fp_img_dev *imgdev,
>                 if (imgdev->action == IMG_ACTION_ENROLL &&
>                     r > 0 && r != FP_ENROLL_COMPLETE && r !=
> FP_ENROLL_FAIL) {
>                         imgdev->action_result = 0;
> -                       imgdev->action_state =
> IMG_ACQUIRE_STATE_AWAIT_FINGER_ON;
> -                       dev_change_state(imgdev,
> IMGDEV_STATE_AWAIT_FINGER_ON);
> +
> +                       if (imgdrv->flags &
> FP_IMGDRV_NEEDS_REACTIVATION_BETWEEN_ENROLLS) {
> +                               imgdev->action_state =
> IMG_ACQUIRE_STATE_DEACTIVATING;
> +                               dev_deactivate(imgdev);
> +                       } else {
> +                               imgdev->action_state =
> IMG_ACQUIRE_STATE_AWAIT_FINGER_ON;
> +                               dev_change_state(imgdev,
> IMGDEV_STATE_AWAIT_FINGER_ON);
> +                       }
>                 }
>                 break;
>         case IMG_ACTION_VERIFY:
> @@ -332,11 +342,16 @@ void fpi_imgdev_session_error(struct fp_img_dev
> *imgdev, int error)
>   void fpi_imgdev_activate_complete(struct fp_img_dev *imgdev, int status)
>  {
> +       struct fp_img_driver *imgdrv =
> fpi_driver_to_img_driver(imgdev->dev->drv);
> +
>         fp_dbg("status %d", status);
>         switch (imgdev->action) {
>         case IMG_ACTION_ENROLL:
> -               fpi_drvcb_enroll_started(imgdev->dev, status);
> +               if (!(imgdrv->flags &
> FP_IMGDRV_NEEDS_REACTIVATION_BETWEEN_ENROLLS) ||
> +                   imgdev->dev->state != DEV_STATE_ENROLLING) {
> +                       fpi_drvcb_enroll_started(imgdev->dev, status);
> +               }
>                 break;
>         case IMG_ACTION_VERIFY:
>                 fpi_drvcb_verify_started(imgdev->dev, status);
> @@ -360,10 +375,19 @@ void fpi_imgdev_activate_complete(struct
> fp_img_dev *imgdev, int status)
>   void fpi_imgdev_deactivate_complete(struct fp_img_dev *imgdev)
>  {
> +       struct fp_img_driver *imgdrv =
> fpi_driver_to_img_driver(imgdev->dev->drv);
> +
>         fp_dbg("");
>         switch (imgdev->action) {
>         case IMG_ACTION_ENROLL:
> +               if ((imgdrv->flags &
> FP_IMGDRV_NEEDS_REACTIVATION_BETWEEN_ENROLLS) &&
> +                       imgdev->dev->state == DEV_STATE_ENROLLING) {
> +                       imgdev->action_state =
> IMG_ACQUIRE_STATE_ACTIVATING;
> +                       dev_activate(imgdev, IMGDEV_STATE_AWAIT_FINGER_ON);
> +                       return;
> +               }
> +
>                 fpi_drvcb_enroll_stopped(imgdev->dev);
>                 break;
>         case IMG_ACTION_VERIFY:
> --
> 2.7.4
>
> _______________________________________________
> fprint mailing list
> fprint at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/fprint
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/fprint/attachments/20180216/d0ec82c9/attachment.html>


More information about the fprint mailing list