Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SPI Support #125

Merged
merged 8 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ Right now umockdev supports the following features:

- Recording and replay of evdev (touch pads, Wacom tablets, etc.) ioctls.

- Recording and replay of spidev ioctls and read/write commands using ``--ioctl``
for both ``umockdev-record`` and ``umockdev-run``. This is an in-order
record/replay of all SPI transfers. Similar to ``scripts``
with the difference that full duplex transfers via ioctl are supported.
Timinges/errors are currently not recorded.

- Recording and replay of evdev input events using the evemu events format
(https://github.com/bentiss/evemu/blob/master/README.md). Unlike recorded
evdev scripts these are architecture independent and human readable.
Expand Down
57 changes: 57 additions & 0 deletions devices/spi/elanfingerprint.ioctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
@DEV /dev/spidev0.0 (SPI)
TW 03ff
CR 81
TW 31
TW 08ff
CR 5f
TW 09ff
CR 5f
TW 57
CR af
TW 0aff
CR 09
TW 31
TW 7d
CR 10
TW bd10
TW a878
TW 68
CR 00
TW 67
CR 96
TW 8b72
TW 8c62
TW 805a
TW 04
TW aa07
TW 8560
TW 86c0
TW 8780
TW 8804
TW 8a97
TW 8b72
TW 8c69
TW 8f2a
TW 912a
TW 9327
TW 9567
TW 9804
TW a120
TW a236
TW aa5f
TW abc0
TW aeff
TW 01
TW 03ff
CR 40
TW 03ff
CR 40
TW 03ff
CR 40
TW 03ff
CR 4c
TW 1000
CR 2938295029532943296329712970294e295029582942294529552952296029442933296e293129392934294f295b29512958292329462928292b291c292f295529522946292f29252959291a2944293f2918294b29212936293c29322945293e29342914293e292a28f829262931293729292901290728f7292229202927291e290c291b292d291c293c294429272951293329392933294f295a29472904294129292924294a29282938294e296c2933295a291f293d29372924294029792983
TW 03ff
CR 44
# Truncated, original from libfprint
169 changes: 169 additions & 0 deletions devices/spi/elanfingerprint.umockdev
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
P: /devices/pci0000:00/0000:00:1e.2/pxa2xx-spi.3/spi_master/spi0/spi-ELAN7001:00/spidev/spidev0.0
N: spidev0.0
E: DEVNAME=/dev/spidev0.0
E: MAJOR=153
E: MINOR=0
E: SUBSYSTEM=spidev
A: dev=153:0\n
L: device=../../../spi-ELAN7001:00
A: power/async=disabled\n
A: power/control=auto\n
A: power/runtime_active_kids=0\n
A: power/runtime_active_time=0\n
A: power/runtime_enabled=disabled\n
A: power/runtime_status=unsupported\n
A: power/runtime_suspended_time=0\n
A: power/runtime_usage=0\n

P: /devices/pci0000:00/0000:00:1e.2/pxa2xx-spi.3/spi_master/spi0/spi-ELAN7001:00
E: DRIVER=spidev
E: MODALIAS=acpi:ELAN7001:
E: SUBSYSTEM=spi
E: ID_VENDOR_FROM_DATABASE=ELAD srl
L: driver=../../../../../../../bus/spi/drivers/spidev
A: driver_override=spidev\n
L: firmware_node=../../../../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:73/ELAN7001:00
A: modalias=acpi:ELAN7001:\n
A: power/async=disabled\n
A: power/control=auto\n
A: power/runtime_active_kids=0\n
A: power/runtime_active_time=0\n
A: power/runtime_enabled=disabled\n
A: power/runtime_status=unsupported\n
A: power/runtime_suspended_time=0\n
A: power/runtime_usage=0\n
A: statistics/bytes=23208391
A: statistics/bytes_rx=22185696
A: statistics/bytes_tx=1191980
A: statistics/errors=0
A: statistics/messages=519673
A: statistics/spi_async=0
A: statistics/spi_sync=519673
A: statistics/spi_sync_immediate=519673
A: statistics/timedout=0
A: statistics/transfer_bytes_histo_0-1=398920
A: statistics/transfer_bytes_histo_1024-2047=0
A: statistics/transfer_bytes_histo_128-255=113366
A: statistics/transfer_bytes_histo_16-31=0
A: statistics/transfer_bytes_histo_16384-32767=0
A: statistics/transfer_bytes_histo_2-3=517580
A: statistics/transfer_bytes_histo_2048-4095=0
A: statistics/transfer_bytes_histo_256-511=0
A: statistics/transfer_bytes_histo_32-63=0
A: statistics/transfer_bytes_histo_32768-65535=0
A: statistics/transfer_bytes_histo_4-7=0
A: statistics/transfer_bytes_histo_4096-8191=0
A: statistics/transfer_bytes_histo_512-1023=0
A: statistics/transfer_bytes_histo_64-127=0
A: statistics/transfer_bytes_histo_65536+=0
A: statistics/transfer_bytes_histo_8-15=0
A: statistics/transfer_bytes_histo_8192-16383=0
A: statistics/transfers=1029866
A: statistics/transfers_split_maxsize=0

P: /devices/pci0000:00/0000:00:1e.2/pxa2xx-spi.3/spi_master/spi0
E: SUBSYSTEM=spi_master
L: device=../../../pxa2xx-spi.3
A: power/async=disabled\n
A: power/control=auto\n
A: power/runtime_active_kids=0\n
A: power/runtime_active_time=0\n
A: power/runtime_enabled=disabled\n
A: power/runtime_status=unsupported\n
A: power/runtime_suspended_time=0\n
A: power/runtime_usage=0\n
A: statistics/bytes=23208391
A: statistics/bytes_rx=22185696
A: statistics/bytes_tx=1191980
A: statistics/errors=0
A: statistics/messages=519673
A: statistics/spi_async=0
A: statistics/spi_sync=519673
A: statistics/spi_sync_immediate=519673
A: statistics/timedout=0
A: statistics/transfer_bytes_histo_0-1=398920
A: statistics/transfer_bytes_histo_1024-2047=0
A: statistics/transfer_bytes_histo_128-255=113366
A: statistics/transfer_bytes_histo_16-31=0
A: statistics/transfer_bytes_histo_16384-32767=0
A: statistics/transfer_bytes_histo_2-3=517580
A: statistics/transfer_bytes_histo_2048-4095=0
A: statistics/transfer_bytes_histo_256-511=0
A: statistics/transfer_bytes_histo_32-63=0
A: statistics/transfer_bytes_histo_32768-65535=0
A: statistics/transfer_bytes_histo_4-7=0
A: statistics/transfer_bytes_histo_4096-8191=0
A: statistics/transfer_bytes_histo_512-1023=0
A: statistics/transfer_bytes_histo_64-127=0
A: statistics/transfer_bytes_histo_65536+=0
A: statistics/transfer_bytes_histo_8-15=0
A: statistics/transfer_bytes_histo_8192-16383=0
A: statistics/transfers=1029866
A: statistics/transfers_split_maxsize=0

P: /devices/pci0000:00/0000:00:1e.2/pxa2xx-spi.3
E: DEVTYPE=mfd_device
E: DRIVER=pxa2xx-spi
E: MODALIAS=platform:pxa2xx-spi
E: SUBSYSTEM=platform
E: ID_PATH=pci-0000:00:1e.2-platform-pxa2xx-spi.3
E: ID_PATH_TAG=pci-0000_00_1e_2-platform-pxa2xx-spi_3
L: driver=../../../../bus/platform/drivers/pxa2xx-spi
A: driver_override=(null)\n
L: firmware_node=../../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:73
A: modalias=platform:pxa2xx-spi\n
A: power/async=disabled\n
A: power/autosuspend_delay_ms=50\n
A: power/control=auto\n
A: power/runtime_active_kids=0\n
A: power/runtime_active_time=65446\n
A: power/runtime_enabled=enabled\n
A: power/runtime_status=suspended\n
A: power/runtime_suspended_time=14155204\n
A: power/runtime_usage=0\n

P: /devices/pci0000:00/0000:00:1e.2
E: DRIVER=intel-lpss
E: PCI_CLASS=118000
E: PCI_ID=8086:9D29
E: PCI_SUBSYS_ID=1043:1D2D
E: PCI_SLOT_NAME=0000:00:1e.2
E: MODALIAS=pci:v00008086d00009D29sv00001043sd00001D2Dbc11sc80i00
E: SUBSYSTEM=pci
E: ID_PCI_CLASS_FROM_DATABASE=Signal processing controller
E: ID_PCI_SUBCLASS_FROM_DATABASE=Signal processing controller
E: ID_VENDOR_FROM_DATABASE=Intel Corporation
E: ID_MODEL_FROM_DATABASE=Sunrise Point-LP Serial IO SPI Controller
A: ari_enabled=0\n
A: broken_parity_status=0\n
A: class=0x118000\n
H: config=8680299D060010002100801110008000043013EF00000000000000000000000000000000000000000000000043102D1D000000008000000000000000FF030000
A: consistent_dma_mask_bits=64\n
A: d3cold_allowed=1\n
A: device=0x9d29\n
A: dma_mask_bits=32\n
L: driver=../../../bus/pci/drivers/intel-lpss
A: driver_override=(null)\n
A: enable=1\n
L: firmware_node=../../LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:73
A: irq=22\n
A: local_cpulist=0-7\n
A: local_cpus=ff\n
A: modalias=pci:v00008086d00009D29sv00001043sd00001D2Dbc11sc80i00\n
A: msi_bus=1\n
A: numa_node=-1\n
A: pools=poolinfo - 0.1\ndma3chan1 0 102 40 1\ndma3chan0 0 102 40 1\n
A: power/async=enabled\n
A: power/control=on\n
A: power/pm_qos_latency_tolerance_us=auto\n
A: power/runtime_active_kids=0\n
A: power/runtime_active_time=9330720\n
A: power/runtime_enabled=forbidden\n
A: power/runtime_status=active\n
A: power/runtime_suspended_time=4891014\n
A: power/runtime_usage=1\n
A: resource=0x00000000ef133000 0x00000000ef133fff 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=0x1d2d\n
A: subsystem_vendor=0x1043\n
A: vendor=0x8086\n
5 changes: 4 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ gio = dependency('gio-2.0', version: '>= 2.32.0')
gio_unix = dependency('gio-unix-2.0', version: '>= 2.32.0')
libudev = dependency('libudev')
libpcap = dependency('libpcap')
pthread = cc.find_library('pthread', required: true)
gudev = dependency('gudev-1.0', required: false)
python = find_program('python3', 'python', required: false)

Expand Down Expand Up @@ -87,7 +88,7 @@ preload_lib = shared_library('umockdev-preload',
'src/ioctl_tree.c'],
c_args: ['-fvisibility=default'],
version: '0.0.0',
dependencies: [dl],
dependencies: [dl, pthread],
install: true)

#
Expand All @@ -104,6 +105,7 @@ umockdev_lib = shared_library('umockdev',
['src/umockdev.vala',
'src/umockdev-ioctl.vala',
'src/umockdev-pcap.vala',
'src/umockdev-spi.vala',
'src/uevent_sender.vapi',
'src/uevent_sender.c',
'src/ioctl_tree.vapi',
Expand Down Expand Up @@ -164,6 +166,7 @@ umockdev_record_exe = executable('umockdev-record',
['src/umockdev-record.vala',
'src/umockdev-ioctl.vala',
'src/umockdev-pcap.vala',
'src/umockdev-spi.vala',
'src/ioctl_tree.vapi',
'src/ioctl_tree.c',
'src/debug.c'],
Expand Down
41 changes: 41 additions & 0 deletions src/ioctl.vapi
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,46 @@ namespace Ioctl {
uint signr;
void *usercontext;
}

[CCode (cheader_filename = "linux/spi/spidev.h")]
public int SPI_IOC_MESSAGE(int len);
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_RD_MODE;
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_WR_MODE;
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_RD_MODE32;
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_WR_MODE32;
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_RD_LSB_FIRST;
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_WR_LSB_FIRST;
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_RD_BITS_PER_WORD;
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_WR_BITS_PER_WORD;
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_RD_MAX_SPEED_HZ;
[CCode (cheader_filename = "linux/spi/spidev.h")]
public const int SPI_IOC_WR_MAX_SPEED_HZ;

[CCode (cname="struct spi_ioc_transfer", cheader_filename = "linux/spi/spidev.h",
destroy_function="")]
public struct spi_ioc_transfer {
uint64 tx_buf;
uint64 rx_buf;

uint32 len;
uint32 speed_hz;

uint16 delay_usecs;
uint8 bits_per_word;
uint8 cs_change;
uint8 tx_nbits;
uint8 rx_nbits;
uint8 word_delay_usecs;
uint8 pad;
}
}

Loading