Compare commits

...

7 Commits

Author SHA1 Message Date
Saeed/Ali Rk (PesarAmmehZa)
6d4335341d Merge branch 'egiscalib' into 'master'
fix: calibration for egis0570

See merge request libfprint/libfprint!548
2025-10-29 11:41:17 +00:00
saeedark
b0ce1291de test: edit to pass testes 2025-10-29 15:08:32 +03:30
Saeed/Ali Rk (PesarAmmehZa)
bef518281a Merge branch 'egiscalib-test-new' into 'egiscalib'
egis0570: add new test data

See merge request saeedark/libfprint!1
2025-10-29 11:32:14 +00:00
Jack Morton
8000439c5b egis0570: add new test data 2025-10-29 09:16:48 +00:00
saeedark
05f7631023 chore: clean up 2025-10-28 17:18:58 +03:30
saeedark
2050902767 fix: calibration for egis0570 2025-10-26 21:00:35 +03:30
Benjamin Berg
7c97dcd985 device: Add API for perstistent data storage
API consumers should fetch the persistent data when they are done and
store it to disk. It is undefined when this data is updated by the
driver, but in general, it should only be updated once the first time
a device is used.
2025-10-22 20:27:30 +03:30
10 changed files with 1753 additions and 110 deletions

View File

@@ -40,6 +40,8 @@ fp_device_has_feature
fp_device_has_storage
fp_device_supports_identify
fp_device_supports_capture
fp_device_get_persistent_data
fp_device_set_persistent_data
fp_device_is_open
fp_device_open
fp_device_close

File diff suppressed because it is too large Load Diff

View File

@@ -18,10 +18,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "drivers_api.h"
#ifndef __EGIS0570_H
#define __EGIS0570_H 1
/*
* Device data
*/
@@ -54,6 +57,33 @@
#define EGIS0570_INIT_TOTAL (sizeof ((init_pkts)) / sizeof ((init_pkts[0])))
// static unsigned char init_pkts[][EGIS0570_PKTSIZE] =
// {
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x20, 0x3f },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x58, 0x3f },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x21, 0x09 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x57, 0x09 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x22, 0x03 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x56, 0x03 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x23, 0x01 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x55, 0x01 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x24, 0x01 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x54, 0x01 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x3e },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x0b },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x14, 0x03 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x00 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x0f },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x10, 0x00 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x11, 0x38 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x12, 0x00 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x13, 0x71 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x03, 0x80 },
// { 0x45, 0x47, 0x49, 0x53, 0x00, 0x02, 0x80 },
// { 0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x2f },
// { 0x45, 0x47, 0x49, 0x53, 0x06, 0x00, 0xfe } /* image returned after this packet */
// };
static unsigned char init_pkts[][EGIS0570_PKTSIZE] =
{
{ 0x45, 0x47, 0x49, 0x53, 0x01, 0x20, 0x3f },
@@ -66,6 +96,8 @@ static unsigned char init_pkts[][EGIS0570_PKTSIZE] =
{ 0x45, 0x47, 0x49, 0x53, 0x01, 0x55, 0x01 },
{ 0x45, 0x47, 0x49, 0x53, 0x01, 0x24, 0x01 },
{ 0x45, 0x47, 0x49, 0x53, 0x01, 0x54, 0x01 },
{ 0x45, 0x47, 0x49, 0x53, 0x01, 0x25, 0x00 },
{ 0x45, 0x47, 0x49, 0x53, 0x01, 0x53, 0x00 },
{ 0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x3e },
{ 0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x0b },
{ 0x45, 0x47, 0x49, 0x53, 0x01, 0x14, 0x03 },
@@ -175,3 +207,386 @@ static unsigned char repeat_pkts[][EGIS0570_PKTSIZE] =
#define EGIS0570_RESIZE 2
#endif
// Calibration
enum driver_version {
PACKET_CALIBRATION,
PACKET_VERSION_1,
NONE,
};
#define PRESISTENT_DATA_LENGTH 9
#define EGIS0570_CAL_IMG_TOT 22 //124
#define EGIS0570_CAL_INPSIZE 6528
#define EGIS0570_CAL_BS_ELM 7
#define IMG_COL_IGNORE 23
#define TARGET_UPPER 80
#define TARGET_LOWER 70
// #define SIDE_DIFF (-10)
#define SIDE_DIFF (+5)
/* static pkts */
static guint8 EGIS0570_CAL_CONFIGURATION_MODE_PKT[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0d, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0e, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x1f},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x05, 0x08},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x03, 0xff}
};
static guint8 EGIS0570_CAL_PKT_ZERO_RANGE[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x01, 0x10},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x03, 0x80},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x04, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x05, 0x08},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x06, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x07, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x08, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x0a},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0a, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0b, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0c, 0xff},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0d, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0e, 0x00}
};
static guint8 EGIS0570_CAL_CAPTURING_AREA[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x10, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x11, 0x38},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x12, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x13, 0x71}
};
static guint8 EGIS0570_CAL_SENSOR_AND_EMITTER[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x14, 0x15},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x08}
};
static guint8 EGIS0570_CAL_WHITE_SETTING[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x0f},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x14, 0x3f},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x00, 0x02, 0x00}
};
static guint8 EGIS0570_CAL_BLACK_WHITE_GET_IMAGE[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x20},
{0x45, 0x47, 0x49, 0x53, 0x06, 0x00, 0x33}
};
static guint8 EGIS0570_CAL_BLACK_WHITE_AFTER_IMAGE[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x00}
};
static guint8 EGIS0570_CAL_BLACK_SETTING[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x14, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x03},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0xff},
{0x45, 0x47, 0x49, 0x53, 0x00, 0x02, 0xff}
};
static guint8 EGIS0570_CAL_BLACK_WHITE_CLEAR[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x14, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x0f},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x03, 0x80},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x14, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x00}
};
static guint8 EGIS0570_CAL_MIDDLE_BLACK_SETTING[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x0a},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x7f},
{0x45, 0x47, 0x49, 0x53, 0x00, 0x02, 0x7f},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x2f}
};
static guint8 EGIS0570_CAL_GET_IMAGE[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x06, 0x00, 0x33}
};
static guint8 EGIS0570_CAL_AFTER_IMAGE[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x0f}
};
static guint8 EGIS0570_CAL_REPEAT[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x00, 0x02, 0x0f},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x2f}
};
static guint8 EGIS0570_CAL_BORDER_WHITE_SETTING[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x0a},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x3f},
{0x45, 0x47, 0x49, 0x53, 0x00, 0x02, 0x3f},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x2f}
};
static guint8 EGIS0570_CAL_FIRST_BS_SETTING[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x00},
};
static guint8 EGIS0570_CAL_BEFORE_GET_IMAGE[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x2f}
};
static guint8 EGIS0570_CAL_NO_IMAGE_CAPTURING_AREA[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x10, 0x1c},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x11, 0x1c},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x12, 0x31},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x13, 0x40}
};
static guint8 EGIS0570_CAL_NO_IMAGE_SETTING_0[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x09, 0x05},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x14, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x15, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x16, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x08, 0x1c}
};
static guint8 EGIS0570_CAL_NO_IMAGE_BINARY_14_SETTING[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0b, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0c, 0xff},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0d, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x0e, 0xff},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x02, 0x1d},
{0x45, 0x47, 0x49, 0x53, 0x01, 0x04, 0x00}
};
static guint8 EGIS0570_CAL_NO_IMAGE_PRE_FIRST[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x01, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x00, 0x01, 0x00}
};
static guint8 EGIS0570_CAL_NO_IMAGE_REQUEST[][EGIS0570_PKTSIZE] =
{
{0x45, 0x47, 0x49, 0x53, 0x01, 0x01, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x00, 0x01, 0x00},
{0x45, 0x47, 0x49, 0x53, 0x00, 0x01, 0x00}
};
#define EGIS0570_CAL_STATIC_LIST_SIZEOF (sizeof ((EGIS0570_CAL_STATIC_LIST)) / sizeof ((EGIS0570_CAL_STATIC_LIST[0])))
static guint8 * EGIS0570_CAL_STATIC_LIST[] = {
*EGIS0570_CAL_CONFIGURATION_MODE_PKT,
*EGIS0570_CAL_PKT_ZERO_RANGE,
*EGIS0570_CAL_CAPTURING_AREA,
*EGIS0570_CAL_SENSOR_AND_EMITTER,
*EGIS0570_CAL_WHITE_SETTING,
*EGIS0570_CAL_BLACK_WHITE_GET_IMAGE,
*EGIS0570_CAL_BLACK_WHITE_AFTER_IMAGE,
*EGIS0570_CAL_BLACK_SETTING,
*EGIS0570_CAL_BLACK_WHITE_CLEAR,
*EGIS0570_CAL_MIDDLE_BLACK_SETTING,
*EGIS0570_CAL_GET_IMAGE,
*EGIS0570_CAL_AFTER_IMAGE,
*EGIS0570_CAL_REPEAT,
*EGIS0570_CAL_BORDER_WHITE_SETTING,
*EGIS0570_CAL_FIRST_BS_SETTING,
*EGIS0570_CAL_BEFORE_GET_IMAGE,
*EGIS0570_CAL_NO_IMAGE_CAPTURING_AREA,
*EGIS0570_CAL_NO_IMAGE_SETTING_0,
*EGIS0570_CAL_NO_IMAGE_BINARY_14_SETTING,
*EGIS0570_CAL_NO_IMAGE_PRE_FIRST,
*EGIS0570_CAL_NO_IMAGE_REQUEST,
};
#define EGIS0570_HELPER_PKT_SIZEOF(x) (sizeof (x) / sizeof (x[0]))
static guint8 EGIS0570_CAL_STATIC_LIST_SIZE[] = {
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_CONFIGURATION_MODE_PKT),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_PKT_ZERO_RANGE),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_CAPTURING_AREA),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_SENSOR_AND_EMITTER),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_WHITE_SETTING),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_BLACK_WHITE_GET_IMAGE),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_BLACK_WHITE_AFTER_IMAGE),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_BLACK_SETTING),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_BLACK_WHITE_CLEAR),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_MIDDLE_BLACK_SETTING),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_GET_IMAGE),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_AFTER_IMAGE),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_REPEAT),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_BORDER_WHITE_SETTING),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_FIRST_BS_SETTING),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_BEFORE_GET_IMAGE),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_NO_IMAGE_CAPTURING_AREA),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_NO_IMAGE_SETTING_0),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_NO_IMAGE_BINARY_14_SETTING),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_NO_IMAGE_PRE_FIRST),
EGIS0570_HELPER_PKT_SIZEOF (EGIS0570_CAL_NO_IMAGE_REQUEST),
};
/* Calibration logic */
enum cal_proc_en {
CAL_CONF_PKT,
CAL_PKT_ZERO_RNG,
CAL_CAPT_AREA,
CAL_SENS_AND_EMIT,
CAL_RNG_20_58,
CAL_RNG_60_D0,
CAL_WHITE_SET,
CAL_BLACK_WHITE_GET_IMG,
CAL_BLACK_WHITE_AFTER_IMAGE,
CAL_BLACK_SET,
CAL_CHECK_BLACK_WHITE,
CAL_5_ROWS_ZEROS,
CAL_BLACK_WHITE_CLEAR,
CAL_RNG_60_D1,
CAL_MID_BLACK_SET,
CAL_GET_IMG,
CAL_AFTER_IMG,
CAL_GET_9,
CAL_BORDER_WHITE_SET,
CAL_FIRST_BS_SET,
CAL_BS_CHK_SET,
CAL_PKT_02,
CAL_BEFORE_IMG,
CAL_BS_JUMP,
CAL_BS_END,
CAL_PKT_15_0,
CAL_PKT_16_3C,
CAL_CHK_NEW_CONF,
CAL_GET_21,
CAL_NO_IMG_CAP_AREA,
CAL_NO_IMG_SET_0,
CAL_NO_IMG_03_1C,
CAL_NO_CHK_03_80,
CAL_NO_SET_03_80,
CAL_NO_IMG_14_BS_SET,
CAL_NO_IMG_14_BS_CHK_SET,
CAL_NO_IMG_PRE_FIRST,
CAL_NO_IMG_GET_8,
CAL_NO_IMG_14_BS_JUMP,
CAL_NO_IMG_14_BS_END,
CAL_NO_IMG_16_BS_SET,
CAL_NO_IMG_16_BS_CHK_SET_15,
CAL_NO_IMG_16_BS_SET_16,
CAL_NO_IMG_16_BS_JUMP,
CAL_NO_IMG_16_BS_END,
CAL_END,
};
#define EGIS0570_CAL_PROC_SIZEOF (sizeof ((calibration_procedure)) / sizeof ((calibration_procedure[0])))
static guint8 calibration_procedure[] = {
// conf
CAL_CONF_PKT,
// sensor check
CAL_PKT_ZERO_RNG,
CAL_CAPT_AREA,
CAL_SENS_AND_EMIT,
CAL_RNG_20_58,
CAL_RNG_60_D0,
CAL_WHITE_SET,
CAL_BLACK_WHITE_GET_IMG,
CAL_BLACK_WHITE_AFTER_IMAGE,
CAL_BLACK_SET,
CAL_BLACK_WHITE_GET_IMG,
CAL_BLACK_WHITE_AFTER_IMAGE,
CAL_CHECK_BLACK_WHITE,
// not binary 16
CAL_CAPT_AREA,
CAL_5_ROWS_ZEROS,
CAL_BLACK_WHITE_CLEAR,
CAL_RNG_20_58,
CAL_RNG_60_D1,
CAL_MID_BLACK_SET,
CAL_GET_IMG,
CAL_AFTER_IMG,
CAL_GET_9,
CAL_BORDER_WHITE_SET,
CAL_GET_IMG,
CAL_AFTER_IMG,
CAL_GET_9,
// binary
CAL_FIRST_BS_SET,
CAL_BS_CHK_SET, // 0
CAL_PKT_02, // 1
CAL_BEFORE_IMG, // 2
CAL_GET_IMG, // 3
CAL_AFTER_IMG, // 4
CAL_GET_9, // 5
CAL_BS_JUMP, // 6
CAL_BS_END, // 7
// check pictures.
CAL_PKT_15_0,
CAL_PKT_16_3C,
CAL_CHK_NEW_CONF,
CAL_PKT_02,
CAL_BEFORE_IMG,
CAL_GET_IMG,
CAL_AFTER_IMG,
CAL_GET_21,
// no image 14
CAL_NO_IMG_CAP_AREA,
CAL_NO_IMG_SET_0,
CAL_NO_IMG_03_1C,
CAL_NO_CHK_03_80,
CAL_NO_SET_03_80,
CAL_NO_IMG_14_BS_SET,
CAL_NO_IMG_14_BS_CHK_SET, // 0
CAL_NO_IMG_PRE_FIRST, // 1
CAL_NO_IMG_GET_8, // 2
CAL_NO_IMG_14_BS_JUMP, // 3
CAL_NO_IMG_14_BS_END, // 4
// no image 16
CAL_NO_IMG_16_BS_SET,
CAL_NO_IMG_16_BS_CHK_SET_15, // 0
CAL_NO_IMG_16_BS_SET_16, // 1
CAL_NO_IMG_PRE_FIRST, // 2
CAL_NO_IMG_GET_8, // 3
CAL_NO_IMG_16_BS_JUMP, // 4
CAL_NO_IMG_16_BS_END, // 5
// end
CAL_CONF_PKT,
CAL_CONF_PKT,
CAL_END,
};

View File

@@ -61,6 +61,7 @@ typedef struct
FpDeviceFeature features;
guint64 driver_data;
GVariant *persistent_data;
gint nr_enroll_stages;
GSList *sources;

View File

@@ -54,6 +54,7 @@ enum {
PROP_FPI_UDEV_DATA_SPIDEV,
PROP_FPI_UDEV_DATA_HIDRAW,
PROP_FPI_DRIVER_DATA,
PROP_FPI_PERSISTENT_DATA,
N_PROPS
};
@@ -235,6 +236,8 @@ fp_device_finalize (GObject *object)
g_clear_pointer (&priv->udev_data.spidev_path, g_free);
g_clear_pointer (&priv->udev_data.hidraw_path, g_free);
g_clear_pointer (&priv->persistent_data, g_variant_unref);
G_OBJECT_CLASS (fp_device_parent_class)->finalize (object);
}
@@ -304,6 +307,10 @@ fp_device_get_property (GObject *object,
g_value_set_string (value, NULL);
break;
case PROP_FPI_PERSISTENT_DATA:
g_value_set_variant (value, priv->persistent_data);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -354,6 +361,11 @@ fp_device_set_property (GObject *object,
priv->driver_data = g_value_get_uint64 (value);
break;
case PROP_FPI_PERSISTENT_DATA:
g_clear_pointer (&priv->persistent_data, g_variant_unref);
priv->persistent_data = g_value_dup_variant (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -594,6 +606,21 @@ fp_device_class_init (FpDeviceClass *klass)
0,
G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY);
/**
* FpDevice::fpi-persistent-data: (skip)
*
* This property is only for internal purposes.
*
* Stability: private
*/
properties[PROP_FPI_PERSISTENT_DATA] =
g_param_spec_variant ("fpi-persistent-data",
"Persistent Driver Data",
"Private: Previously stored data for the device",
G_VARIANT_TYPE_ANY,
NULL,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE);
g_object_class_install_properties (object_class, N_PROPS, properties);
}
@@ -739,6 +766,139 @@ fp_device_get_temperature (FpDevice *device)
return priv->temp_current;
}
/**
* fp_device_get_persistent_data:
* @device: A #FpDevice
* @data: (array length=length) (transfer full) (out): Return location for data pointer
* @length: (transfer full) (out): Length of @data
* @error: Return location for error
*
* Retrieves persistent data that should be stored for this device. Storage
* needs to be device specific, i.e. device ID and driver must match when
* restored.
*
* Returns: (type void): %TRUE on success
*/
gboolean
fp_device_get_persistent_data (FpDevice *device,
guchar **data,
gsize *length,
GError **error)
{
g_autoptr(GVariant) res = NULL;
FpDevicePrivate *priv = fp_device_get_instance_private (device);
g_assert (data);
g_assert (length);
if (priv->persistent_data == NULL)
{
*data = NULL;
*length = 0;
return TRUE;
}
/* Version + variant from driver */
res = g_variant_new ("(issv)",
1,
fp_device_get_driver (device),
priv->device_id,
priv->persistent_data);
*length = g_variant_get_size (res);
*data = g_malloc (*length);
g_variant_store (res, *data);
return TRUE;
}
/**
* fp_device_get_persistent_data:
* @device: A #FpDevice
* @data: (array length=length) (transfer none): Persistent Data
* @length: (transfer none): Length of @data
* @error: Return location for error
*
* Load persistent data from storage. This function should be called after
* a device was discovered and before it is opened for the first time. It is
* an error to call it if data has already been set (or generated by the
* driver).
*
* Note that the driver may update the data. The API user should retrieve the
* value when done with the device and store it in a persistent location.
*
* Returns: (type void): %TRUE on success
*/
gboolean
fp_device_set_persistent_data (FpDevice *device,
guchar *data,
gsize length,
GError **error)
{
g_autoptr(GVariant) stored = NULL;
g_autoptr(GVariant) loaded = NULL;
FpDevicePrivate *priv = fp_device_get_instance_private (device);
guchar *copy;
gint version;
const gchar *device_id;
const gchar *driver;
if (priv->is_open)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"Data can only be set right after device creation");
return FALSE;
}
if (priv->persistent_data)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS,
"Data has already been set");
return FALSE;
}
if (length == 0)
{
g_clear_pointer (&priv->persistent_data, g_variant_unref);
g_object_notify_by_pspec (G_OBJECT (device), properties[PROP_FPI_PERSISTENT_DATA]);
return TRUE;
}
g_assert (data);
copy = g_memdup2 (data, length);
stored = g_variant_new_from_data (G_VARIANT_TYPE ("(issv)"), copy, length, FALSE, g_free, copy);
if (!stored)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
"Data could not be parsed");
return FALSE;
}
g_variant_get (stored, "(issv)", &version, &driver, &device_id, &loaded);
if (version != 1)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
"Unknown data storage version");
return FALSE;
}
if (g_strcmp0 (device_id, priv->device_id) != 0 ||
g_strcmp0 (driver, fp_device_get_driver (device)) != 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA,
"Driver or device ID mismatch!");
return FALSE;
}
g_clear_pointer (&priv->persistent_data, g_variant_unref);
priv->persistent_data = g_steal_pointer (&loaded);
g_object_notify_by_pspec (G_OBJECT (device), properties[PROP_FPI_PERSISTENT_DATA]);
return TRUE;
}
/**
* fp_device_supports_identify:
* @device: A #FpDevice

View File

@@ -233,6 +233,15 @@ FpDeviceFeature fp_device_get_features (FpDevice *device);
gboolean fp_device_has_feature (FpDevice *device,
FpDeviceFeature feature);
gboolean fp_device_get_persistent_data (FpDevice *device,
guchar **data,
gsize *length,
GError **error);
gboolean fp_device_set_persistent_data (FpDevice *device,
guchar *data,
gsize length,
GError **error);
/* Opening the device */
void fp_device_open (FpDevice *device,
GCancellable *cancellable,

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -1,30 +1,44 @@
P: /devices/pci0000:00/0000:00:14.0/usb1/1-9
N: bus/usb/001/005=12011001000000087A1C700541100102030109022000010100A0320904000002FF0000000705830240000007050402400003
E: DEVNAME=/dev/bus/usb/001/005
N: bus/usb/001/013=12011001000000087A1C700541100102030109022000010100A0320904000002FF0000000705830240000007050402400003
E: BUSNUM=001
E: CURRENT_TAGS=:seat:
E: DEVNAME=/dev/bus/usb/001/013
E: DEVNUM=013
E: DEVTYPE=usb_device
E: DRIVER=usb
E: PRODUCT=1c7a/570/1041
E: TYPE=0/0/0
E: BUSNUM=001
E: DEVNUM=005
E: MAJOR=189
E: MINOR=4
E: SUBSYSTEM=usb
E: ID_VENDOR=EgisTec
E: ID_VENDOR_ENC=EgisTec
E: ID_VENDOR_ID=1c7a
E: ID_AUTOSUSPEND=1
E: ID_BUS=usb
E: ID_FOR_SEAT=usb-pci-0000_00_14_0-usb-0_9
E: ID_MODEL=EgisTec_Touch_Fingerprint_Sensor
E: ID_MODEL_ENC=EgisTec\x20Touch\x20Fingerprint\x20Sensor
E: ID_MODEL_ID=0570
E: ID_REVISION=1041
E: ID_SERIAL=EgisTec_EgisTec_Touch_Fingerprint_Sensor_W700B41B
E: ID_SERIAL_SHORT=W700B41B
E: ID_BUS=usb
E: ID_USB_INTERFACES=:ff0000:
E: ID_VENDOR_FROM_DATABASE=LighTuning Technology Inc.
E: ID_PATH=pci-0000:00:14.0-usb-0:9
E: ID_PATH_TAG=pci-0000_00_14_0-usb-0_9
E: LIBFPRINT_DRIVER=Hardcoded allowlist
E: ID_PATH_WITH_USB_REVISION=pci-0000:00:14.0-usbv2-0:9
E: ID_PERSIST=0
E: ID_REVISION=1041
E: ID_SERIAL=EgisTec_EgisTec_Touch_Fingerprint_Sensor_0007989A
E: ID_SERIAL_SHORT=0007989A
E: ID_USB_INTERFACES=:ff0000:
E: ID_USB_MODEL=EgisTec_Touch_Fingerprint_Sensor
E: ID_USB_MODEL_ENC=EgisTec\x20Touch\x20Fingerprint\x20Sensor
E: ID_USB_MODEL_ID=0570
E: ID_USB_REVISION=1041
E: ID_USB_SERIAL=EgisTec_EgisTec_Touch_Fingerprint_Sensor_0007989A
E: ID_USB_SERIAL_SHORT=0007989A
E: ID_USB_VENDOR=EgisTec
E: ID_USB_VENDOR_ENC=EgisTec
E: ID_USB_VENDOR_ID=1c7a
E: ID_VENDOR=EgisTec
E: ID_VENDOR_ENC=EgisTec
E: ID_VENDOR_FROM_DATABASE=LighTuning Technology Inc.
E: ID_VENDOR_ID=1c7a
E: MAJOR=189
E: MINOR=12
E: PRODUCT=1c7a/570/1041
E: SUBSYSTEM=usb
E: TAGS=:seat:
E: TYPE=0/0/0
A: authorized=1\n
A: avoid_reset_quirk=0\n
A: bConfigurationValue=1\n
@@ -38,32 +52,34 @@ A: bNumInterfaces= 1\n
A: bcdDevice=1041\n
A: bmAttributes=a0\n
A: busnum=1\n
A: configuration=\n
A: configuration=
H: descriptors=12011001000000087A1C700541100102030109022000010100A0320904000002FF0000000705830240000007050402400003
A: dev=189:4\n
A: devnum=5\n
A: dev=189:12\n
A: devnum=13\n
A: devpath=9\n
L: driver=../../../../../bus/usb/drivers/usb
L: firmware_node=../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1d/device:1e/device:28
A: idProduct=0570\n
A: idVendor=1c7a\n
A: ltm_capable=no\n
A: manufacturer=EgisTec\n
A: maxchild=0\n
A: physical_location/dock=no\n
A: physical_location/horizontal_position=left\n
A: physical_location/lid=no\n
A: physical_location/panel=unknown\n
A: physical_location/vertical_position=upper\n
L: port=../1-0:1.0/usb1-port9
A: power/active_duration=362352\n
A: power/async=enabled\n
A: power/active_duration=434262\n
A: power/autosuspend=2\n
A: power/autosuspend_delay_ms=2000\n
A: power/connected_duration=5526124\n
A: power/connected_duration=2971461\n
A: power/control=auto\n
A: power/level=auto\n
A: power/persist=1\n
A: power/runtime_active_kids=0\n
A: power/runtime_active_time=365097\n
A: power/runtime_enabled=enabled\n
A: power/persist=0\n
A: power/runtime_active_time=436346\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=5160752\n
A: power/runtime_usage=0\n
A: power/runtime_suspended_time=2534879\n
A: power/wakeup=disabled\n
A: power/wakeup_abort_count=\n
A: power/wakeup_active=\n
@@ -77,41 +93,52 @@ A: product=EgisTec Touch Fingerprint Sensor\n
A: quirks=0x0\n
A: removable=fixed\n
A: rx_lanes=1\n
A: serial=W700B41B\n
A: serial=0007989A\n
A: speed=12\n
A: tx_lanes=1\n
A: urbnum=8040\n
A: urbnum=95937\n
A: version= 1.10\n
P: /devices/pci0000:00/0000:00:14.0/usb1
N: bus/usb/001/001=12010002090001406B1D020008050302010109021900010100E0000904000001090000000705810304000C
N: bus/usb/001/001=12010002090001406B1D020017060302010109021900010100E0000904000001090000000705810304000C
E: BUSNUM=001
E: CURRENT_TAGS=:seat:
E: DEVNAME=/dev/bus/usb/001/001
E: DEVNUM=001
E: DEVTYPE=usb_device
E: DRIVER=usb
E: PRODUCT=1d6b/2/508
E: TYPE=9/0/1
E: BUSNUM=001
E: DEVNUM=001
E: MAJOR=189
E: MINOR=0
E: SUBSYSTEM=usb
E: ID_VENDOR=Linux_5.8.0-59-generic_xhci-hcd
E: ID_VENDOR_ENC=Linux\x205.8.0-59-generic\x20xhci-hcd
E: ID_VENDOR_ID=1d6b
E: ID_AUTOSUSPEND=1
E: ID_BUS=usb
E: ID_FOR_SEAT=usb-pci-0000_00_14_0
E: ID_MODEL=xHCI_Host_Controller
E: ID_MODEL_ENC=xHCI\x20Host\x20Controller
E: ID_MODEL_ID=0002
E: ID_REVISION=0508
E: ID_SERIAL=Linux_5.8.0-59-generic_xhci-hcd_xHCI_Host_Controller_0000:00:14.0
E: ID_SERIAL_SHORT=0000:00:14.0
E: ID_BUS=usb
E: ID_USB_INTERFACES=:090000:
E: ID_VENDOR_FROM_DATABASE=Linux Foundation
E: ID_MODEL_FROM_DATABASE=2.0 root hub
E: ID_MODEL_ID=0002
E: ID_PATH=pci-0000:00:14.0
E: ID_PATH_TAG=pci-0000_00_14_0
E: ID_FOR_SEAT=usb-pci-0000_00_14_0
E: ID_REVISION=0617
E: ID_SERIAL=Linux_6.17.5-arch1-1_xhci-hcd_xHCI_Host_Controller_0000:00:14.0
E: ID_SERIAL_SHORT=0000:00:14.0
E: ID_USB_INTERFACES=:090000:
E: ID_USB_MODEL=xHCI_Host_Controller
E: ID_USB_MODEL_ENC=xHCI\x20Host\x20Controller
E: ID_USB_MODEL_ID=0002
E: ID_USB_REVISION=0617
E: ID_USB_SERIAL=Linux_6.17.5-arch1-1_xhci-hcd_xHCI_Host_Controller_0000:00:14.0
E: ID_USB_SERIAL_SHORT=0000:00:14.0
E: ID_USB_VENDOR=Linux_6.17.5-arch1-1_xhci-hcd
E: ID_USB_VENDOR_ENC=Linux\x206.17.5-arch1-1\x20xhci-hcd
E: ID_USB_VENDOR_ID=1d6b
E: ID_VENDOR=Linux_6.17.5-arch1-1_xhci-hcd
E: ID_VENDOR_ENC=Linux\x206.17.5-arch1-1\x20xhci-hcd
E: ID_VENDOR_FROM_DATABASE=Linux Foundation
E: ID_VENDOR_ID=1d6b
E: MAJOR=189
E: MINOR=0
E: PRODUCT=1d6b/2/617
E: SUBSYSTEM=usb
E: TAGS=:seat:
E: TYPE=9/0/1
A: authorized=1\n
A: authorized_default=1\n
A: avoid_reset_quirk=0\n
@@ -123,34 +150,31 @@ A: bMaxPacketSize0=64\n
A: bMaxPower=0mA\n
A: bNumConfigurations=1\n
A: bNumInterfaces= 1\n
A: bcdDevice=0508\n
A: bcdDevice=0617\n
A: bmAttributes=e0\n
A: busnum=1\n
A: configuration=\n
H: descriptors=12010002090001406B1D020008050302010109021900010100E0000904000001090000000705810304000C
A: configuration=
H: descriptors=12010002090001406B1D020017060302010109021900010100E0000904000001090000000705810304000C
A: dev=189:0\n
A: devnum=1\n
A: devpath=0\n
L: driver=../../../../bus/usb/drivers/usb
L: firmware_node=../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1d/device:1e
A: idProduct=0002\n
A: idVendor=1d6b\n
A: interface_authorized_default=1\n
A: ltm_capable=no\n
A: manufacturer=Linux 5.8.0-59-generic xhci-hcd\n
A: manufacturer=Linux 6.17.5-arch1-1 xhci-hcd\n
A: maxchild=12\n
A: power/active_duration=378024\n
A: power/async=enabled\n
A: power/active_duration=1253682\n
A: power/autosuspend=0\n
A: power/autosuspend_delay_ms=0\n
A: power/connected_duration=5527220\n
A: power/connected_duration=6204832\n
A: power/control=auto\n
A: power/level=auto\n
A: power/runtime_active_kids=1\n
A: power/runtime_active_time=377962\n
A: power/runtime_enabled=enabled\n
A: power/runtime_active_time=1253672\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=5149253\n
A: power/runtime_usage=0\n
A: power/runtime_suspended_time=4951157\n
A: power/wakeup=disabled\n
A: power/wakeup_abort_count=\n
A: power/wakeup_active=\n
@@ -167,62 +191,72 @@ A: rx_lanes=1\n
A: serial=0000:00:14.0\n
A: speed=480\n
A: tx_lanes=1\n
A: urbnum=956\n
A: urbnum=2401\n
A: version= 2.00\n
P: /devices/pci0000:00/0000:00:14.0
E: DRIVER=xhci_hcd
E: ID_AUTOSUSPEND=1
E: ID_MODEL_FROM_DATABASE=Sunrise Point-LP USB 3.0 xHCI Controller
E: ID_PATH=pci-0000:00:14.0
E: ID_PATH_TAG=pci-0000_00_14_0
E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
E: ID_PCI_INTERFACE_FROM_DATABASE=XHCI
E: ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
E: ID_VENDOR_FROM_DATABASE=Intel Corporation
E: MODALIAS=pci:v00008086d00009D2Fsv00001025sd0000118Cbc0Csc03i30
E: PCI_CLASS=C0330
E: PCI_ID=8086:9D2F
E: PCI_SUBSYS_ID=1025:118E
E: PCI_SLOT_NAME=0000:00:14.0
E: MODALIAS=pci:v00008086d00009D2Fsv00001025sd0000118Ebc0Csc03i30
E: PCI_SUBSYS_ID=1025:118C
E: SUBSYSTEM=pci
E: ID_PCI_CLASS_FROM_DATABASE=Serial bus controller
E: ID_PCI_SUBCLASS_FROM_DATABASE=USB controller
E: ID_PCI_INTERFACE_FROM_DATABASE=XHCI
E: ID_VENDOR_FROM_DATABASE=Intel Corporation
E: ID_MODEL_FROM_DATABASE=Sunrise Point-LP USB 3.0 xHCI Controller
A: ari_enabled=0\n
A: broken_parity_status=0\n
A: class=0x0c0330\n
H: config=86802F9D060490022130030C00008000040021A400000000000000000000000000000000000000000000000025108E11000000007000000000000000FF010000
H: config=86802F9D060490022130030C00008000040011B100000000000000000000000000000000000000000000000025108C11000000007000000000000000FF010000FD01348088C60F8000000000000000005B6ECE0F000000000000000000000000306000000000000000000000000000000180C2C10800000000000000000000000500B7001803E0FE0000000000000000090014F01000400100000000C10A080000080000001800008F400200000104000100000002000000100000000C000000000000000000000000000000000000000100000002000000000000000C000000000000000000000000000000000000000000000000000000B30F410800000000
A: consistent_dma_mask_bits=64\n
A: d3cold_allowed=1\n
A: dbc=disabled\n
A: dbc_bInterfaceProtocol=01\n
A: dbc_bcdDevice=0010\n
A: dbc_idProduct=0010\n
A: dbc_idVendor=1d6b\n
A: dbc_poll_interval_ms=64\n
A: device=0x9d2f\n
A: dma_mask_bits=64\n
L: driver=../../../bus/pci/drivers/xhci_hcd
A: driver_override=(null)\n
A: enable=1\n
A: irq=127\n
A: local_cpulist=0-7\n
A: local_cpus=ff\n
A: modalias=pci:v00008086d00009D2Fsv00001025sd0000118Ebc0Csc03i30\n
L: firmware_node=../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:1d
A: irq=123\n
A: local_cpulist=0-3\n
A: local_cpus=f\n
A: modalias=pci:v00008086d00009D2Fsv00001025sd0000118Cbc0Csc03i30\n
A: msi_bus=1\n
A: msi_irqs/123=msi\n
A: msi_irqs/124=msi\n
A: msi_irqs/125=msi\n
A: msi_irqs/126=msi\n
A: msi_irqs/127=msi\n
A: numa_node=-1\n
A: pools=poolinfo - 0.1\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\nxHCI 1KB stream ctx arrays 0 0 1024 0\nxHCI 256 byte stream ctx arrays 0 0 256 0\nxHCI input/output contexts 9 10 2112 10\nxHCI ring segments 32 36 4096 36\nbuffer-2048 1 2 2048 1\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\n
A: power/async=enabled\n
A: power/control=on\n
A: power/runtime_active_kids=1\n
A: power/runtime_active_time=5524703\n
A: power/runtime_enabled=forbidden\n
A: pools=poolinfo - 0.1\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\nxHCI 256 port bw ctx arrays 0 0 256 0\nxHCI 1KB stream ctx arrays 0 0 1024 0\nxHCI 256 byte stream ctx arrays 0 0 256 0\nxHCI input/output contexts 8 9 2112 9\nxHCI ring segments 33 33 4096 33\nbuffer-2048 0 0 2048 0\nbuffer-512 0 0 512 0\nbuffer-128 0 0 128 0\nbuffer-32 0 0 32 0\n
A: power/control=auto\n
A: power/runtime_active_time=1256085\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=3373\n
A: power/runtime_usage=1\n
A: power/runtime_suspended_time=4949020\n
A: power/wakeup=enabled\n
A: power/wakeup_abort_count=0\n
A: power/wakeup_active=0\n
A: power/wakeup_active_count=0\n
A: power/wakeup_active_count=7\n
A: power/wakeup_count=0\n
A: power/wakeup_expire_count=0\n
A: power/wakeup_last_time_ms=0\n
A: power/wakeup_max_time_ms=0\n
A: power/wakeup_total_time_ms=0\n
A: resource=0x00000000a4210000 0x00000000a421ffff 0x0000000000140204\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n
A: power/wakeup_expire_count=7\n
A: power/wakeup_last_time_ms=3233739\n
A: power/wakeup_max_time_ms=108\n
A: power/wakeup_total_time_ms=736\n
A: power_state=D0\n
A: resource=0x00000000b1110000 0x00000000b111ffff 0x0000000000140204\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n0x0000000000000000 0x0000000000000000 0x0000000000000000\n
A: revision=0x21\n
A: subsystem_device=0x118e\n
A: subsystem_device=0x118c\n
A: subsystem_vendor=0x1025\n
A: vendor=0x8086\n

View File

@@ -262,6 +262,53 @@ test_device_identify_null_prints (void)
g_assert_error (error, FP_DEVICE_ERROR, FP_DEVICE_ERROR_DATA_INVALID);
}
static void
test_device_persistent_data (void)
{
g_autoptr(FptContext) tctx = fpt_context_new_with_virtual_device (FPT_VIRTUAL_DEVICE_IMAGE);
g_autoptr(GVariant) initial = NULL;
g_autoptr(GVariant) loaded = NULL;
g_autoptr(GError) error = NULL;
guint8 *data = (guint8 *) 0xdeadbeef;
gsize length = 1;
initial = g_variant_ref_sink (g_variant_new ("(s)", "stored data"));
g_assert_true (fp_device_get_persistent_data (tctx->device, &data, &length, &error));
g_assert_cmpint (length, ==, 0);
g_assert_null (data);
g_assert_no_error (error);
/* Use the fact that this is a property that we can poke from the outside. */
g_object_set (tctx->device, "fpi-persistent-data", initial, NULL);
/* Works now */
g_assert_true (fp_device_get_persistent_data (tctx->device, &data, &length, &error));
g_assert_cmpint (length, !=, 0);
g_assert_nonnull (data);
g_assert_no_error (error);
/* We can't load the data, as data has been set already. */
g_assert_false (fp_device_set_persistent_data (tctx->device, data, length, &error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_EXISTS);
g_clear_pointer (&error, g_error_free);
/* Abuse that we can "load" again if the data is set to NULL.
* This is an implementation detail and just a lack of error checking. */
g_object_set (tctx->device, "fpi-persistent-data", NULL, NULL);
/* Incomplete data, causes parsing error */
g_assert_false (fp_device_set_persistent_data (tctx->device, data, 5, &error));
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_DATA);
g_clear_pointer (&error, g_error_free);
g_assert_true (fp_device_set_persistent_data (tctx->device, data, length, &error));
g_assert_no_error (error);
g_object_get (tctx->device, "fpi-persistent-data", &loaded, NULL);
g_assert_cmpvariant (initial, loaded);
}
int
main (int argc, char *argv[])
{
@@ -284,6 +331,7 @@ main (int argc, char *argv[])
g_test_add_func ("/device/sync/has_storage", test_device_has_storage);
g_test_add_func ("/device/sync/identify/cancelled", test_device_identify_cancelled);
g_test_add_func ("/device/sync/identify/null-prints", test_device_identify_null_prints);
g_test_add_func ("/device/persistent_data", test_device_persistent_data);
return g_test_run ();
}