mincrmatt12 / elan-spi-fingerprint

prototype linux driver for elantech spi-based fingerprint sensors
39 stars 4 forks source link

VivoBook Flip 14 TP412 #11

Open so-saf opened 2 years ago

so-saf commented 2 years ago

Successfully launched with TP_VID = 0x04F3, TP_PID = 0x241F, ACPI_HID = "ELAN7001". Images are obtained like this: 1 The problem is that my fingerprint scanner is an i2c device and libfprint does not see it because it is not in lsusb. Can you tell me what to do?

Just in case, here is the output of some commands:

~ » xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ XiaoMi Mi Wireless Mouse                  id=9    [slave  pointer  (2)]
⎜   ↳ XiaoMi Mi Wireless Mouse Consumer Control id=10   [slave  pointer  (2)]
⎜   ↳ ELAN1300:00 04F3:310C Mouse               id=13   [slave  pointer  (2)]
⎜   ↳ ELAN1300:00 04F3:310C Touchpad            id=14   [slave  pointer  (2)]
⎜   ↳ ELAN2097:00 04F3:241F                     id=15   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Power Button                              id=8    [slave  keyboard (3)]
    ↳ XiaoMi Mi Wireless Mouse System Control   id=11   [slave  keyboard (3)]
    ↳ USB2.0 VGA UVC WebCam: USB2.0 V           id=12   [slave  keyboard (3)]
    ↳ ELAN2097:00 04F3:241F Stylus              id=16   [slave  keyboard (3)]
    ↳ Intel HID events                          id=17   [slave  keyboard (3)]
    ↳ Intel HID 5 button array                  id=18   [slave  keyboard (3)]
    ↳ Asus WMI hotkeys                          id=19   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=20   [slave  keyboard (3)]
    ↳ XiaoMi Mi Wireless Mouse Consumer Control id=21   [slave  keyboard (3)]
    ↳ MAJOR III BLUETOOTH (AVRCP)               id=22   [slave  keyboard (3)]
~ » sudo dmesg | grep "ELAN"                                                                                                                                                                      130 ↵ sosaf@sosaf
[    2.570917] input: ELAN1300:00 04F3:310C Mouse as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-6/i2c-ELAN1300:00/0018:04F3:310C.0002/input/input10
[    2.571072] input: ELAN1300:00 04F3:310C Touchpad as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-6/i2c-ELAN1300:00/0018:04F3:310C.0002/input/input11
[    2.571284] hid-generic 0018:04F3:310C.0002: input,hidraw1: I2C HID v1.00 Mouse [ELAN1300:00 04F3:310C] on i2c-ELAN1300:00
[    2.681427] input: ELAN2097:00 04F3:241F Touchscreen as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-7/i2c-ELAN2097:00/0018:04F3:241F.0003/input/input14
[    2.681604] input: ELAN2097:00 04F3:241F as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-7/i2c-ELAN2097:00/0018:04F3:241F.0003/input/input15
[    2.681777] input: ELAN2097:00 04F3:241F as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-7/i2c-ELAN2097:00/0018:04F3:241F.0003/input/input16
[    2.681909] input: ELAN2097:00 04F3:241F Stylus as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-7/i2c-ELAN2097:00/0018:04F3:241F.0003/input/input17
[    2.682050] hid-generic 0018:04F3:241F.0003: input,hidraw2: I2C HID v1.00 Device [ELAN2097:00 04F3:241F] on i2c-ELAN2097:00
[    3.248653] input: ELAN1300:00 04F3:310C Mouse as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-6/i2c-ELAN1300:00/0018:04F3:310C.0002/input/input20
[    3.249531] input: ELAN1300:00 04F3:310C Touchpad as /devices/pci0000:00/0000:00:15.0/i2c_designware.0/i2c-6/i2c-ELAN1300:00/0018:04F3:310C.0002/input/input21
[    3.252320] hid-multitouch 0018:04F3:310C.0002: input,hidraw1: I2C HID v1.00 Mouse [ELAN1300:00 04F3:310C] on i2c-ELAN1300:00
[    3.474932] input: ELAN2097:00 04F3:241F as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-7/i2c-ELAN2097:00/0018:04F3:241F.0003/input/input23
[    3.475101] input: ELAN2097:00 04F3:241F UNKNOWN as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-7/i2c-ELAN2097:00/0018:04F3:241F.0003/input/input24
[    3.475313] input: ELAN2097:00 04F3:241F UNKNOWN as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-7/i2c-ELAN2097:00/0018:04F3:241F.0003/input/input25
[    3.475420] input: ELAN2097:00 04F3:241F Stylus as /devices/pci0000:00/0000:00:15.1/i2c_designware.1/i2c-7/i2c-ELAN2097:00/0018:04F3:241F.0003/input/input26
[    3.476119] hid-multitouch 0018:04F3:241F.0003: input,hidraw2: I2C HID v1.00 Device [ELAN2097:00 04F3:241F] on i2c-ELAN2097:00
[    3.476569] i2c_hid_acpi i2c-ELAN2097:00: i2c_hid_get_input: IRQ triggered but there's no data
~ » lsusb                                                                                                                                                                                               sosaf@sosaf
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 04f2:b568 Chicony Electronics Co., Ltd USB2.0 VGA UVC WebCam
Bus 001 Device 004: ID 8087:0aaa Intel Corp. Bluetooth 9460/9560 Jefferson Peak (JfP)
Bus 001 Device 002: ID 2717:5013 Xiaomi Inc. Mi Wireless Mouse
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~ » lspci                                                                                                                                                                                               sosaf@sosaf
00:00.0 Host bridge: Intel Corporation Coffee Lake HOST and DRAM Controller (rev 0b)
00:02.0 VGA compatible controller: Intel Corporation WhiskeyLake-U GT2 [UHD Graphics 620]
00:04.0 Signal processing controller: Intel Corporation Xeon E3-1200 v5/E3-1500 v5/6th Gen Core Processor Thermal Subsystem (rev 0b)
00:08.0 System peripheral: Intel Corporation Xeon E3-1200 v5/v6 / E3-1500 v5 / 6th/7th/8th Gen Core Processor Gaussian Mixture Model
00:12.0 Signal processing controller: Intel Corporation Cannon Point-LP Thermal Controller (rev 30)
00:13.0 Serial controller: Intel Corporation Cannon Point-LP Integrated Sensor Hub (rev 30)
00:14.0 USB controller: Intel Corporation Cannon Point-LP USB 3.1 xHCI Controller (rev 30)
00:14.2 RAM memory: Intel Corporation Cannon Point-LP Shared SRAM (rev 30)
00:14.3 Network controller: Intel Corporation Cannon Point-LP CNVi [Wireless-AC] (rev 30)
00:15.0 Serial bus controller: Intel Corporation Cannon Point-LP Serial IO I2C Controller #0 (rev 30)
00:15.1 Serial bus controller: Intel Corporation Cannon Point-LP Serial IO I2C Controller #1 (rev 30)
00:16.0 Communication controller: Intel Corporation Cannon Point-LP MEI Controller #1 (rev 30)
00:17.0 RAID bus controller: Intel Corporation 82801 Mobile SATA Controller [RAID mode] (rev 30)
00:1d.0 PCI bridge: Intel Corporation Cannon Point-LP PCI Express Root Port #9 (rev f0)
00:1e.0 Communication controller: Intel Corporation Cannon Point-LP Serial IO UART Controller #2 (rev 30)
00:1e.3 Serial bus controller: Intel Corporation Cannon Point-LP Serial IO SPI Controller (rev 30)
00:1f.0 ISA bridge: Intel Corporation Cannon Point-LP LPC Controller (rev 30)
00:1f.3 Audio device: Intel Corporation Cannon Point-LP High Definition Audio Controller (rev 30)
00:1f.4 SMBus: Intel Corporation Cannon Point-LP SMBus Controller (rev 30)
00:1f.5 Serial bus controller: Intel Corporation Cannon Point-LP SPI Controller (rev 30)
01:00.0 Non-Volatile memory controller: Intel Corporation SSD 660P Series (rev 03)
mincrmatt12 commented 2 years ago

The sensors handled by this repository (and indeed the one that you have) utilize SPI, not I2C. It's the touchpad that's connected via I2C.

You need to add the sensor to the id_table in the elanspi driver which is now merged into upstream libfprint.

Based on the image you have (from which I'm guessing the sensor is rotated 90 degrees, you might need to experiment with the various rotation values) you'd need to try something like

diff --git a/libfprint/drivers/elanspi.h b/libfprint/drivers/elanspi.h
index ffe3416..986010e 100644
--- a/libfprint/drivers/elanspi.h
+++ b/libfprint/drivers/elanspi.h
@@ -348,6 +348,7 @@ static const FpIdEntry elanspi_id_table[] = {
   {.udev_types = ELANSPI_UDEV_TYPES, .spi_acpi_id = "ELAN7001", .hid_id = {.vid = ELANSPI_TP_VID, .pid = 0x30b2}, .driver_data = ELANSPI_NO_ROTATE},
   {.udev_types = ELANSPI_UDEV_TYPES, .spi_acpi_id = "ELAN70A1", .hid_id = {.vid = ELANSPI_TP_VID, .pid = 0x30b2}, .driver_data = ELANSPI_NO_ROTATE},
   {.udev_types = ELANSPI_UDEV_TYPES, .spi_acpi_id = "ELAN7001", .hid_id = {.vid = ELANSPI_TP_VID, .pid = 0x309f}, .driver_data = ELANSPI_180_ROTATE},
+  {.udev_types = ELANSPI_UDEV_TYPES, .spi_acpi_id = "ELAN7001", .hid_id = {.vid = ELANSPI_TP_VID, .pid = 0x241f}, .driver_data = ELANSPI_90RIGHT_ROTATE},
   {.udev_types = 0}
 };

If that works, please report so on the actual libfprint issue tracker or create a merge request there so this device can be supported out of the box in the future.

so-saf commented 2 years ago

Thank you for your answer, the libfprint driver is working (by the way, the sensor rotation is not needed). First, please tell me how to create a merge request? Unfortunately I don't really understand how to do this( Secondly, how can I now use my scanner for authorization, given the fact that this is an i2c device and it is not visible in the lsusb output (this is where the fingerprint-gui is looking for). Thanks again.

mincrmatt12 commented 2 years ago

(by the way, the sensor rotation is not needed).

do you mean that it works with the .driver_data set to ELANSPI_NO_ROTATE or that you didn't need to rotate your finger with the configuration I gave?

First, please tell me how to create a merge request? Unfortunately I don't really understand how to do this(

Eh don't worry about it, I can create it

Secondly, how can I now use my scanner for authorization, given the fact that this is an i2c device and it is not visible in the lsusb output (this is where the fingerprint-gui is looking for).

I'm not sure if fingerprint-gui is even still maintained, or at least kept up to date with modern libfprint; is there a reason why just using fprintd doesn't work? afaik most desktop environments integrate with it fairly directly nowadays.

so-saf commented 2 years ago

Thank you for creating the merge request for me)

do you mean that it works with the .driver_data set to ELANSPI_NO_ROTATE or that you didn't need to rotate your finger with the configuration I gave?

I mean, it works with this line:

{.udev_types = ELANSPI_UDEV_TYPES, .spi_acpi_id = "ELAN7001", .hid_id = {.vid = ELANSPI_TP_VID, .pid = 0x241f}, .driver_data = ELANSPI_NO_ROTATE}

is there a reason why just using fprintd doesn't work?

Yes, fprintd does not see my scanner:

~ » fprintd-enroll
Impossible to enroll: GDBus.Error:net.reactivated.Fprint.Error.NoSuchDevice: No devices available

Maybe I'm doing something wrong, let me describe to you the actions that I did:

git clone https://github.com/freedesktop/libfprint.git
cd libfprint

I inserted into elanspi.h the line that I wrote before.

meson build -D drivers=all
cd build
meson compile

After that , I ran the script ./img-capture that produced the image: finger

Then I thought that everything was working and installed the driver:

sudo meson install

I think it's important to say that fprint was installed before all these actions. If you try to install after, then pacman (btw I use arch) will not allow you to do this because 70-libfprint-2.rules already exists.