From 17a13fec10129faf5cf88d2b8efcb2d8c49bc826 Mon Sep 17 00:00:00 2001 From: Nikolay Metchev Date: Thu, 23 Apr 2026 11:03:14 +0100 Subject: [PATCH] upeksonly: use Windows trace sequence for 147e:1002 --- libfprint/drivers/upeksonly.c | 12 +++++++++--- libfprint/drivers/upeksonly.h | 22 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/libfprint/drivers/upeksonly.c b/libfprint/drivers/upeksonly.c index 3a20ce92..fe3c110d 100644 --- a/libfprint/drivers/upeksonly.c +++ b/libfprint/drivers/upeksonly.c @@ -864,7 +864,10 @@ awfsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev) break; case AWFSM_1000_WRITEV_2: - sm_write_regs (ssm, _dev, awfsm_1000_writev_2, G_N_ELEMENTS (awfsm_1000_writev_2)); + if (FPI_DEVICE_UPEKSONLY (_dev)->dev_model == UPEKSONLY_1002) + sm_write_regs (ssm, _dev, awfsm_1002_writev_2, G_N_ELEMENTS (awfsm_1002_writev_2)); + else + sm_write_regs (ssm, _dev, awfsm_1000_writev_2, G_N_ELEMENTS (awfsm_1000_writev_2)); break; } } @@ -889,8 +892,8 @@ enum capsm_1000_states { enum capsm_1002_states { CAPSM_1002_INIT, - CAPSM_1002_FIRE_BULK, CAPSM_1002_WRITEV, + CAPSM_1002_FIRE_BULK, CAPSM_1002_NUM_STATES, }; @@ -1192,7 +1195,10 @@ initsm_1000_run_state (FpiSsm *ssm, FpDevice *_dev) switch (fpi_ssm_get_cur_state (ssm)) { case INITSM_1000_WRITEV_1: - sm_write_regs (ssm, _dev, initsm_1000_writev_1, G_N_ELEMENTS (initsm_1000_writev_1)); + if (FPI_DEVICE_UPEKSONLY (_dev)->dev_model == UPEKSONLY_1002) + sm_write_regs (ssm, _dev, initsm_1002_writev_1, G_N_ELEMENTS (initsm_1002_writev_1)); + else + sm_write_regs (ssm, _dev, initsm_1000_writev_1, G_N_ELEMENTS (initsm_1000_writev_1)); break; } } diff --git a/libfprint/drivers/upeksonly.h b/libfprint/drivers/upeksonly.h index d637fe71..596249ff 100644 --- a/libfprint/drivers/upeksonly.h +++ b/libfprint/drivers/upeksonly.h @@ -65,6 +65,11 @@ static const struct sonly_regwrite awfsm_1000_writev_2[] = { { 0x30, 0xe1 }, { 0x15, 0x06 }, { 0x15, 0x86 }, }; +static const struct sonly_regwrite awfsm_1002_writev_2[] = { + /* Windows enables 147e:1002 finger detection with bit 0x01 clear here. */ + { 0x30, 0xe1 }, { 0x15, 0x05 }, { 0x15, 0x85 }, +}; + static const struct sonly_regwrite awfsm_2016_writev_3[] = { { 0x13, 0x45 }, { 0x30, 0xe0 }, { 0x12, 0x01 }, { 0x20, 0x01 }, { 0x09, 0x20 }, { 0x0a, 0x00 }, { 0x30, 0xe0 }, { 0x20, 0x01 }, @@ -94,11 +99,12 @@ static const struct sonly_regwrite capsm_1000_writev[] = { static const struct sonly_regwrite capsm_1002_writev[] = { /* 147e:1002 appears close to the 1000 family for init/interrupts, but it - * does not start streaming image data with the plain 1000 capture writes. - * Try the broader capture-mode enable sequence used by the 2016 variant. + * does not start streaming image data with the plain 1000/2016 capture + * writes. This sequence matches the Windows driver immediately before bulk + * image packets start arriving on endpoint 0x81. */ - { 0x09, 0x28 }, { 0x13, 0x55 }, { 0x0b, 0x80 }, { 0x04, 0x00 }, - { 0x05, 0x00 }, + { 0x15, 0x25 }, { 0x30, 0xe0 }, { 0x09, 0x23 }, { 0x13, 0x75 }, + { 0x0b, 0x80 }, }; static const struct sonly_regwrite capsm_1001_writev_1[] = { @@ -200,6 +206,14 @@ static const struct sonly_regwrite initsm_1000_writev_1[] = { { 0x0b, 0x00 }, { 0x08, 0x00 }, /* Initialize capture control registers */ }; +static const struct sonly_regwrite initsm_1002_writev_1[] = { + /* Captured from the Windows 147e:1002 driver before finger detection. */ + { 0x49, 0x08 }, + { 0x3e, 0x3d }, { 0x3e, 0x18 }, { 0x3e, 0x38 }, { 0x3e, 0x63 }, + { 0x3e, 0x9d }, { 0x3e, 0x5c }, { 0x3e, 0xb1 }, { 0x3e, 0x1f }, + { 0x1a, 0x01 }, { 0x1a, 0x03 }, { 0x0b, 0x00 }, { 0x49, 0x0c }, +}; + static const struct sonly_regwrite initsm_1001_writev_1[] = { { 0x4a, 0x9d }, { 0x4f, 0x06 },