fpi-core.h 3.52 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/*
 * Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
 * Copyright (C) 2018 Bastien Nocera <hadess@hadess.net>
 *
 * 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
 */

20 21 22
#ifndef __FPI_CORE_H__
#define __FPI_CORE_H__

23
#include <fprint.h>
24
#include "fpi-dev-img.h"
25

26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
/**
 * usb_id:
 * @vendor: the USB vendor ID
 * @product: the USB product ID
 * @driver_data: data to differentiate devices of different
 *   vendor and product IDs.
 *
 * The struct #usb_id is used to declare devices supported by a
 * particular driver. The @driver_data information is used to
 * differentiate different models of devices which only need
 * small changes compared to the default driver behaviour to function.
 *
 * For example, a device might have a different initialisation from
 * the stock device, so the driver could do:
 *
 * |[<!-- language="C" -->
 *    if (driver_data == MY_DIFFERENT_DEVICE_QUIRK) {
 *        ...
 *    } else {
 *        ...
 *    }
 * ]|
 *
 * The default value is zero, so the @driver_data needs to be a
 * non-zero to be useful.
 */
52 53 54 55 56 57
struct usb_id {
	uint16_t vendor;
	uint16_t product;
	unsigned long driver_data;
};

58 59 60 61 62 63 64
/**
 * fp_driver_type:
 * @DRIVER_PRIMITIVE: primitive, non-imaging, driver
 * @DRIVER_IMAGING: imaging driver
 *
 * The type of device the driver supports.
 */
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
enum fp_driver_type {
	DRIVER_PRIMITIVE = 0,
	DRIVER_IMAGING = 1,
};

struct fp_driver {
	const uint16_t id;
	const char *name;
	const char *full_name;
	const struct usb_id * const id_table;
	enum fp_driver_type type;
	enum fp_scan_type scan_type;

	/* Device operations */
	int (*discover)(struct libusb_device_descriptor *dsc, uint32_t *devtype);
	int (*open)(struct fp_dev *dev, unsigned long driver_data);
	void (*close)(struct fp_dev *dev);
	int (*enroll_start)(struct fp_dev *dev);
	int (*enroll_stop)(struct fp_dev *dev);
	int (*verify_start)(struct fp_dev *dev);
	int (*verify_stop)(struct fp_dev *dev, gboolean iterating);
	int (*identify_start)(struct fp_dev *dev);
	int (*identify_stop)(struct fp_dev *dev, gboolean iterating);
	int (*capture_start)(struct fp_dev *dev);
	int (*capture_stop)(struct fp_dev *dev);
};

92 93 94 95 96 97 98 99 100 101
/**
 * FpiImgDriverFlags:
 * @FP_IMGDRV_SUPPORTS_UNCONDITIONAL_CAPTURE: Whether the driver supports
 *   unconditional image capture. No driver currently does.
 *
 * Flags used in the #fp_img_driver to advertise the capabilities of drivers.
 */
typedef enum {
	FP_IMGDRV_SUPPORTS_UNCONDITIONAL_CAPTURE = 1 << 0
} FpiImgDriverFlags;
102 103 104

struct fp_img_driver {
	struct fp_driver driver;
105
	FpiImgDriverFlags flags;
106 107 108 109 110 111 112 113 114 115 116 117 118
	int img_width;
	int img_height;
	int bz3_threshold;

	/* Device operations */
	int (*open)(struct fp_img_dev *dev, unsigned long driver_data);
	void (*close)(struct fp_img_dev *dev);
	int (*activate)(struct fp_img_dev *dev, enum fp_imgdev_state state);
	int (*change_state)(struct fp_img_dev *dev, enum fp_imgdev_state state);
	void (*deactivate)(struct fp_img_dev *dev);
};

#endif