build: Generalize spi drivers detection

Don't be limited to elan only
This commit is contained in:
Marco Trevisan (Treviño)
2024-08-30 04:16:48 +02:00
parent 10e1cd76aa
commit 78c78432b9
2 changed files with 21 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
spi_sources = []
spi_headers = []
if 'elanspi' in drivers
if enabled_spi_drivers.length() > 0
spi_headers = ['fpi-spi-transfer.h']
spi_sources = ['fpi-spi-transfer.c']
endif

View File

@@ -97,6 +97,9 @@ cairo_dep = dependency('cairo', required: false)
# introspection scanning and Gio-2.0.gir
gobject_introspection = dependency('gobject-introspection-1.0', required: get_option('introspection'))
# SPI
have_spi = host_machine.system() == 'linux'
# Drivers
drivers = get_option('drivers').split(',')
virtual_drivers = [
@@ -137,9 +140,12 @@ default_drivers = [
'focaltech_moc',
]
# SPI
if host_machine.system() == 'linux'
default_drivers += ['elanspi']
spi_drivers = [
'elanspi'
]
if have_spi
default_drivers += spi_drivers
endif
# FIXME: All the drivers should be fixed by adjusting the byte order.
@@ -178,6 +184,17 @@ if drivers == [ 'default' ]
drivers = default_drivers
endif
enabled_spi_drivers = []
foreach driver : spi_drivers
if driver in drivers
enabled_spi_drivers += driver
endif
endforeach
if enabled_spi_drivers.length() > 0 and not have_spi
error('SPI drivers @0@ are not supported'.format(enabled_spi_drivers))
endif
driver_helper_mapping = {
'aes1610' : [ 'aeslib' ],
'aes1660' : [ 'aeslib', 'aesx660' ],