mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-05-22 16:18:13 +02:00
Apply uncrustify formatting to all validity driver and test files to pass the CI test_indent check. Fix two pre-existing test failures: - test-validity-capture: LED command blobs are 125 bytes, not 128 - test-validity-enroll: add 2-byte length prefix to test data to match parser's expected format, fix empty-data assertion (parser returns FALSE for data_len < 2) All 41 tests pass, 0 failures.
169 lines
6.6 KiB
C
169 lines
6.6 KiB
C
/*
|
|
* Hardware Abstraction Layer for Validity/Synaptics VCSFW fingerprint sensors
|
|
*
|
|
* Per-device blob data, flash partition layouts, and pairing constants.
|
|
*
|
|
* Copyright (C) 2024 libfprint contributors
|
|
*
|
|
* 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
|
|
*/
|
|
|
|
#define FP_COMPONENT "validity"
|
|
|
|
#include "validity_hal.h"
|
|
#include "fpi-log.h"
|
|
|
|
/* ================================================================
|
|
* Include auto-generated blob data for each PID
|
|
* ================================================================ */
|
|
|
|
#include "validity_blobs_0090.inc"
|
|
#include "validity_blobs_0097.inc"
|
|
#include "validity_blobs_009a.inc"
|
|
#include "validity_blobs_009d.inc"
|
|
|
|
/* ================================================================
|
|
* Include pairing constants (partition signatures, CA cert, keys)
|
|
* ================================================================ */
|
|
|
|
#include "validity_pair_constants.inc"
|
|
|
|
/* ================================================================
|
|
* Flash partition layouts
|
|
*
|
|
* Standard layout: used by PID 0097, 009a, 009d
|
|
* Partition 4 (template DB) = 0x80000 bytes
|
|
*
|
|
* PID 0090 layout: smaller DB partition
|
|
* Partition 4 (template DB) = 0x30000 bytes
|
|
* ================================================================ */
|
|
|
|
/* Standard partition table (0097, 009a, 009d) */
|
|
static const ValidityPartition flash_partitions_standard[] = {
|
|
{ .id = 1, .type = 4, .access_lvl = 7, .offset = 0x00001000, .size = 0x00001000 }, /* cert store */
|
|
{ .id = 2, .type = 1, .access_lvl = 2, .offset = 0x00002000, .size = 0x0003e000 }, /* xpfwext */
|
|
{ .id = 5, .type = 5, .access_lvl = 3, .offset = 0x00040000, .size = 0x00008000 }, /* reserved */
|
|
{ .id = 6, .type = 6, .access_lvl = 3, .offset = 0x00048000, .size = 0x00008000 }, /* calibration */
|
|
{ .id = 4, .type = 3, .access_lvl = 5, .offset = 0x00050000, .size = 0x00080000 }, /* template DB */
|
|
};
|
|
|
|
/* PID 0090 partition table (smaller DB) */
|
|
static const ValidityPartition flash_partitions_0090[] = {
|
|
{ .id = 1, .type = 4, .access_lvl = 7, .offset = 0x00001000, .size = 0x00001000 }, /* cert store */
|
|
{ .id = 2, .type = 1, .access_lvl = 2, .offset = 0x00002000, .size = 0x0003e000 }, /* xpfwext */
|
|
{ .id = 5, .type = 5, .access_lvl = 3, .offset = 0x00040000, .size = 0x00008000 }, /* reserved */
|
|
{ .id = 6, .type = 6, .access_lvl = 3, .offset = 0x00048000, .size = 0x00008000 }, /* calibration */
|
|
{ .id = 4, .type = 3, .access_lvl = 5, .offset = 0x00050000, .size = 0x00030000 }, /* template DB */
|
|
};
|
|
|
|
/* Layout descriptors */
|
|
static const ValidityFlashLayout flash_layout_standard = {
|
|
.partitions = flash_partitions_standard,
|
|
.num_partitions = G_N_ELEMENTS (flash_partitions_standard),
|
|
.partition_sig = partition_sig_standard,
|
|
.partition_sig_len = sizeof (partition_sig_standard),
|
|
};
|
|
|
|
static const ValidityFlashLayout flash_layout_0090 = {
|
|
.partitions = flash_partitions_0090,
|
|
.num_partitions = G_N_ELEMENTS (flash_partitions_0090),
|
|
.partition_sig = partition_sig_0090,
|
|
.partition_sig_len = sizeof (partition_sig_0090),
|
|
};
|
|
|
|
/* ================================================================
|
|
* Per-device descriptors
|
|
* ================================================================ */
|
|
|
|
static const ValidityDeviceDesc device_table[] = {
|
|
[VALIDITY_HAL_DEV_90] = {
|
|
.vid = 0x138a,
|
|
.pid = 0x0090,
|
|
.init_hardcoded = init_hardcoded_0090,
|
|
.init_hardcoded_len = sizeof (init_hardcoded_0090),
|
|
.init_clean_slate = NULL, /* not available for this PID */
|
|
.init_clean_slate_len = 0,
|
|
.reset_blob = reset_blob_0090,
|
|
.reset_blob_len = sizeof (reset_blob_0090),
|
|
.db_write_enable = db_write_enable_0090,
|
|
.db_write_enable_len = sizeof (db_write_enable_0090),
|
|
.flash_layout = &flash_layout_0090,
|
|
},
|
|
|
|
[VALIDITY_HAL_DEV_97] = {
|
|
.vid = 0x138a,
|
|
.pid = 0x0097,
|
|
.init_hardcoded = init_hardcoded_0097,
|
|
.init_hardcoded_len = sizeof (init_hardcoded_0097),
|
|
.init_clean_slate = init_hardcoded_clean_slate_0097,
|
|
.init_clean_slate_len = sizeof (init_hardcoded_clean_slate_0097),
|
|
.reset_blob = reset_blob_0097,
|
|
.reset_blob_len = sizeof (reset_blob_0097),
|
|
.db_write_enable = db_write_enable_0097,
|
|
.db_write_enable_len = sizeof (db_write_enable_0097),
|
|
.flash_layout = &flash_layout_standard,
|
|
},
|
|
|
|
[VALIDITY_HAL_DEV_9A] = {
|
|
.vid = 0x06cb,
|
|
.pid = 0x009a,
|
|
.init_hardcoded = init_hardcoded_009a,
|
|
.init_hardcoded_len = sizeof (init_hardcoded_009a),
|
|
.init_clean_slate = init_hardcoded_clean_slate_009a,
|
|
.init_clean_slate_len = sizeof (init_hardcoded_clean_slate_009a),
|
|
.reset_blob = reset_blob_009a,
|
|
.reset_blob_len = sizeof (reset_blob_009a),
|
|
.db_write_enable = db_write_enable_009a,
|
|
.db_write_enable_len = sizeof (db_write_enable_009a),
|
|
.flash_layout = &flash_layout_standard,
|
|
},
|
|
|
|
[VALIDITY_HAL_DEV_9D] = {
|
|
.vid = 0x138a,
|
|
.pid = 0x009d,
|
|
.init_hardcoded = init_hardcoded_009d,
|
|
.init_hardcoded_len = sizeof (init_hardcoded_009d),
|
|
.init_clean_slate = init_hardcoded_clean_slate_009d,
|
|
.init_clean_slate_len = sizeof (init_hardcoded_clean_slate_009d),
|
|
.reset_blob = reset_blob_009d,
|
|
.reset_blob_len = sizeof (reset_blob_009d),
|
|
.db_write_enable = db_write_enable_009d,
|
|
.db_write_enable_len = sizeof (db_write_enable_009d),
|
|
.flash_layout = &flash_layout_standard,
|
|
},
|
|
};
|
|
|
|
/* ================================================================
|
|
* Lookup functions
|
|
* ================================================================ */
|
|
|
|
const ValidityDeviceDesc *
|
|
validity_hal_device_lookup (guint dev_type)
|
|
{
|
|
if (dev_type >= G_N_ELEMENTS (device_table))
|
|
return NULL;
|
|
|
|
return &device_table[dev_type];
|
|
}
|
|
|
|
const ValidityDeviceDesc *
|
|
validity_hal_device_lookup_by_pid (guint16 vid, guint16 pid)
|
|
{
|
|
for (gsize i = 0; i < G_N_ELEMENTS (device_table); i++)
|
|
if (device_table[i].vid == vid && device_table[i].pid == pid)
|
|
return &device_table[i];
|
|
|
|
return NULL;
|
|
}
|