[PATCH libinput 1/2] udev: drop the custom firmware detection code in favor of a modalias

Peter Hutterer peter.hutterer at who-t.net
Wed May 30 22:28:42 UTC 2018


This was overengineered. The separation between the model quirks file and the
udev hwdb matches allowed for more complex firmware detection. Except we never
used it anywhere but on ALPS and there we can, thankfully, just get it from
the version number in the input_id field exposed in the modalias.

So let's drop this and use that match instead. We just need an extra udev rule
to match on ID_INPUT_POINTINGSTICKs so we can differ between ALPS touchpads
and ALPS trackpoints.

https://bugs.freedesktop.org/show_bug.cgi?id=106323

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 udev/90-libinput-model-quirks.hwdb     | 17 +++++++++++++----
 udev/90-libinput-model-quirks.rules.in | 21 ++++----------------
 udev/libinput-model-quirks.c           | 35 ----------------------------------
 3 files changed, 17 insertions(+), 56 deletions(-)

diff --git a/udev/90-libinput-model-quirks.hwdb b/udev/90-libinput-model-quirks.hwdb
index 6b3ca196..8135665e 100644
--- a/udev/90-libinput-model-quirks.hwdb
+++ b/udev/90-libinput-model-quirks.hwdb
@@ -13,7 +13,6 @@
 #	libinput:touchpad:<modalias>
 #	libinput:name:<name>:dmi:<dmi string>
 #	libinput:name:<name>:dt:<device-tree string>
-#	libinput:name:<name>:fwversion:<version>
 #
 # Sort by brand, model
 
@@ -45,11 +44,21 @@ libinput:name:*AlpsPS/2 ALPS DualPoint TouchPad:dmi:*
 libinput:name:*AlpsPS/2 ALPS GlidePoint:dmi:*
  LIBINPUT_MODEL_ALPS_TOUCHPAD=1
 
-libinput:name:*AlpsPS/2 ALPS DualPoint TouchPad:fwversion:800
-libinput:name:*AlpsPS/2 ALPS GlidePoint:fwversion:800
+# ALPS firmware versions:
+# V1		= 0x100
+# V2		= 0x200
+# V3		= 0x300
+# V3_RUSHMORE	= 0x310
+# V4		= 0x400
+# V5		= 0x500
+# V6		= 0x600
+# V7		= 0x700	/* t3btl t4s */
+# V8		= 0x800	/* SS4btl SS4s */
+# V9		= 0x900	/* ss3btl */
+libinput:touchpad:input:b0011v0002p0008e0800*
  LIBINPUT_ATTR_SIZE_HINT=100x55
 
-libinput:name:*AlpsPS/2 ALPS DualPoint Stick:fwversion:800
+libinput:pointingstick:input:b0011v0002p0008e0800*
  LIBINPUT_ATTR_TRACKPOINT_RANGE=160
 
 ##########################################
diff --git a/udev/90-libinput-model-quirks.rules.in b/udev/90-libinput-model-quirks.rules.in
index f29cb8a2..cab8dcda 100644
--- a/udev/90-libinput-model-quirks.rules.in
+++ b/udev/90-libinput-model-quirks.rules.in
@@ -11,23 +11,6 @@
 ACTION!="add|change", GOTO="libinput_model_quirks_end"
 KERNEL!="event*", GOTO="libinput_model_quirks_end"
 
-# Firmware detection, two-stage process.
-# First, run the program and import the LIBINPUT_MODEL_FIRMWARE_VERSION
-# environment (if any)
-KERNELS=="*input*", \
-  ENV{ID_INPUT_TOUCHPAD}=="1", \
-  ENV{.DETECT_FWVERSION}="1"
-KERNELS=="*input*", \
-  ENV{ID_INPUT_POINTINGSTICK}=="1", \
-  ENV{.DETECT_FWVERSION}="1"
-ENV{.DETECT_FWVERSION}!="1", GOTO="skip_fwversion"
-
-IMPORT{program}="@UDEV_TEST_PATH at libinput-model-quirks %S%p"
-ENV{LIBINPUT_MODEL_FIRMWARE_VERSION}!="", \
-  IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:fwversion:$env{LIBINPUT_MODEL_FIRMWARE_VERSION}'"
-# End of touchpad firmware detection
-LABEL="skip_fwversion"
-
 # libinput:touchpad:<modalias>
 ENV{ID_INPUT_TOUCHPAD}=="1", \
   IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:touchpad:"
@@ -40,6 +23,10 @@ ENV{ID_INPUT_TABLET}=="1", \
 ENV{ID_INPUT_MOUSE}=="1", \
   IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:mouse:"
 
+# libinput:pointingstick:<modalias>
+ENV{ID_INPUT_POINTINGSTICK}=="1", \
+  IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:pointingstick:"
+
 # libinput:touchpad:<modalias>
 ENV{ID_INPUT_KEYBOARD}=="1", \
   IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:keyboard:"
diff --git a/udev/libinput-model-quirks.c b/udev/libinput-model-quirks.c
index 9eb15054..728f182f 100644
--- a/udev/libinput-model-quirks.c
+++ b/udev/libinput-model-quirks.c
@@ -51,24 +51,6 @@ prop_value(struct udev_device *device,
 	return prop_value;
 }
 
-static void
-handle_touchpad_alps(struct udev_device *device)
-{
-	const char *product;
-	int bus, vid, pid, version;
-
-	product = prop_value(device, "PRODUCT");
-	if (!product)
-		return;
-
-	if (sscanf(product, "%x/%x/%x/%x", &bus, &vid, &pid, &version) != 4)
-		return;
-
-	/* ALPS' firmware version is the version */
-	if (version)
-		printf("LIBINPUT_MODEL_FIRMWARE_VERSION=%x\n", version);
-}
-
 static void
 handle_touchpad_synaptics(struct udev_device *device)
 {
@@ -102,25 +84,10 @@ handle_touchpad(struct udev_device *device)
 	if (!name)
 		return;
 
-	if (strstr(name, "AlpsPS/2 ALPS") != NULL)
-		handle_touchpad_alps(device);
 	if (strstr(name, "Synaptics ") != NULL)
 		handle_touchpad_synaptics(device);
 }
 
-static void
-handle_pointingstick(struct udev_device *device)
-{
-	const char *name = NULL;
-
-	name = prop_value(device, "NAME");
-	if (!name)
-		return;
-
-	if (strstr(name, "AlpsPS/2 ALPS") != NULL)
-		handle_touchpad_alps(device);
-}
-
 /**
  * For a non-zero fuzz on the x/y axes, print that fuzz as property and
  * reset the kernel's fuzz to 0.
@@ -200,8 +167,6 @@ int main(int argc, char **argv)
 
 	if (prop_value(device, "ID_INPUT_TOUCHPAD"))
 		handle_touchpad(device);
-	if (prop_value(device, "ID_INPUT_POINTINGSTICK"))
-		handle_pointingstick(device);
 
 	rc = 0;
 
-- 
2.14.3



More information about the wayland-devel mailing list