diff --git a/data/10-generic-keyboard.quirks b/data/10-generic-keyboard.quirks index 3063dad6..103d05a6 100644 --- a/data/10-generic-keyboard.quirks +++ b/data/10-generic-keyboard.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Serial Keyboards] MatchUdevType=keyboard MatchBus=ps2 diff --git a/data/10-generic-lid.quirks b/data/10-generic-lid.quirks index f3748e16..1c20acd2 100644 --- a/data/10-generic-lid.quirks +++ b/data/10-generic-lid.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Lid Switch Ct9] MatchName=*Lid Switch* MatchDMIModalias=dmi:*:ct9:* diff --git a/data/10-generic-trackball.quirks b/data/10-generic-trackball.quirks index a554a44d..eba32afd 100644 --- a/data/10-generic-trackball.quirks +++ b/data/10-generic-trackball.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Trackball] MatchName=*Trackball* ModelTrackball=1 diff --git a/data/30-vendor-aiptek.quirks b/data/30-vendor-aiptek.quirks index 24abb134..e5319d5a 100644 --- a/data/30-vendor-aiptek.quirks +++ b/data/30-vendor-aiptek.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Aiptek No Tilt Tablet] MatchUdevType=tablet MatchBus=usb diff --git a/data/30-vendor-alps.quirks b/data/30-vendor-alps.quirks index 706a3f7a..2f020d1e 100644 --- a/data/30-vendor-alps.quirks +++ b/data/30-vendor-alps.quirks @@ -1,9 +1,36 @@ -[AlpsTouchpadDualPoint] +# Do not edit this file, it will be overwritten on update + +# 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 */ + +[ALPS Serial Touchpads] MatchUdevType=touchpad -MatchName=*AlpsPS/2 ALPS DualPoint TouchPad +MatchBus=ps2 +MatchVendor=0x0002 +MatchProduct=0x0008 ModelALPSTouchpad=1 -[AlpsTouchpadGlidePoint] +[ALPS v8 Touchpads] MatchUdevType=touchpad -MatchName=*AlpsPS/2 ALPS GlidePoint -ModelALPSTouchpad=1 +MatchBus=ps2 +MatchVendor=0x0002 +MatchProduct=0x0008 +MatchVersion=0x0800 +AttrSizeHint=100x55 + +[ALPS v8 Trackpoint] +MatchUdevType=pointingstick +MatchBus=ps2 +MatchVendor=0x0002 +MatchProduct=0x0008 +MatchVersion=0x0800 +AttrTrackpointRange=160 diff --git a/data/30-vendor-cyapa.quirks b/data/30-vendor-cyapa.quirks index b58a5541..9d89a0ec 100644 --- a/data/30-vendor-cyapa.quirks +++ b/data/30-vendor-cyapa.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Cyapa Touchpads] MatchName=*Cypress APA Trackpad ?cyapa? AttrPressureRange=10:8 diff --git a/data/30-vendor-elantech.quirks b/data/30-vendor-elantech.quirks index 59a8157f..e49c3415 100644 --- a/data/30-vendor-elantech.quirks +++ b/data/30-vendor-elantech.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Elantech Touchpads] MatchName=*Elantech Touchpad* AttrResolutionHint=31x31 diff --git a/data/30-vendor-huion.quirks b/data/30-vendor-huion.quirks index 65f3b2c1..0e46d208 100644 --- a/data/30-vendor-huion.quirks +++ b/data/30-vendor-huion.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + # HUION PenTablet device. Some of these devices send a BTN_TOOL_PEN event # with value 1 on the first event received by the device but never send the # matching BTN_TOOL_PEN value 0 event. The device appears as if it was diff --git a/data/30-vendor-ibm.quirks b/data/30-vendor-ibm.quirks index 195fc21a..988d2a90 100644 --- a/data/30-vendor-ibm.quirks +++ b/data/30-vendor-ibm.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + # IBM/Lenovo Scrollpoint mouse. Instead of a scroll wheel these mice # feature trackpoint-like sticks which generate a huge amount of scroll # events that need to be handled differently than scroll wheel events diff --git a/data/30-vendor-logitech.quirks b/data/30-vendor-logitech.quirks index ebbc9cc2..12b48e4b 100644 --- a/data/30-vendor-logitech.quirks +++ b/data/30-vendor-logitech.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Logitech M570] MatchName=*Logitech M570* ModelTrackball=1 diff --git a/data/30-vendor-microsoft.quirks b/data/30-vendor-microsoft.quirks index c38f30dd..286b902e 100644 --- a/data/30-vendor-microsoft.quirks +++ b/data/30-vendor-microsoft.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Microsoft Surface 3 Lid Switch] MatchName=*Lid Switch* MatchDMIModalias=dmi:*svnMicrosoftCorporation:pnSurface3:* diff --git a/data/30-vendor-razer.quirks b/data/30-vendor-razer.quirks index f69e1e54..b3cd8170 100644 --- a/data/30-vendor-razer.quirks +++ b/data/30-vendor-razer.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Razer Blade Keyboard] MatchUdevType=keyboard MatchBus=usb diff --git a/data/30-vendor-synaptics.quirks b/data/30-vendor-synaptics.quirks index ffb7cd58..3cdeb45d 100644 --- a/data/30-vendor-synaptics.quirks +++ b/data/30-vendor-synaptics.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Synaptics Serial Touchpads] MatchUdevType=touchpad MatchBus=ps2 diff --git a/data/30-vendor-wacom.quirks b/data/30-vendor-wacom.quirks index 87a2eeca..2613d0d2 100644 --- a/data/30-vendor-wacom.quirks +++ b/data/30-vendor-wacom.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Wacom Touchpads] MatchUdevType=touchpad MatchBus=usb diff --git a/data/50-system-apple.quirks b/data/50-system-apple.quirks index 0b1552a0..fbbb1be0 100644 --- a/data/50-system-apple.quirks +++ b/data/50-system-apple.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Apple Touchpads USB] MatchVendor=0x05AC MatchBus=usb diff --git a/data/50-system-asus.quirks b/data/50-system-asus.quirks index ad120df5..8d7fca54 100644 --- a/data/50-system-asus.quirks +++ b/data/50-system-asus.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Asus X555LAB] MatchName=*ETPS/2 Elantech Touchpad* MatchDMIModalias=dmi:*svnASUSTeKCOMPUTERINC.:pnX555LAB:* diff --git a/data/50-system-chicony.quirks b/data/50-system-chicony.quirks index 808427f5..8f71e92f 100644 --- a/data/50-system-chicony.quirks +++ b/data/50-system-chicony.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + # Acer Hawaii Keyboard, uses Chicony VID [Acer Hawaii Keyboard] MatchUdevType=touchpad diff --git a/data/50-system-cyborg.quirks b/data/50-system-cyborg.quirks index 06137ae9..d999dc82 100644 --- a/data/50-system-cyborg.quirks +++ b/data/50-system-cyborg.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Saitek Cyborg RAT5] MatchUdevType=mouse MatchBus=usb diff --git a/data/50-system-dell.quirks b/data/50-system-dell.quirks index 083fcdd3..c3026495 100644 --- a/data/50-system-dell.quirks +++ b/data/50-system-dell.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Dell Touchpads] MatchName=* Touchpad MatchDMIModalias=dmi:*svnDellInc.:* diff --git a/data/50-system-google.quirks b/data/50-system-google.quirks index 14f727d0..cd312973 100644 --- a/data/50-system-google.quirks +++ b/data/50-system-google.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Google Chromebook R13 CB5-312T] MatchName=*Elan Touchpad* MatchDeviceTree=*Chromebook R13 CB5-312T* diff --git a/data/50-system-hp.quirks b/data/50-system-hp.quirks index 0d127dcd..19a91a75 100644 --- a/data/50-system-hp.quirks +++ b/data/50-system-hp.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [HP Compaq 6910p] MatchName=*SynPS/2 Synaptics TouchPad MatchDMIModalias=dmi:*svnHewlett-Packard:*pnHPCompaq6910p* diff --git a/data/50-system-lenovo.quirks b/data/50-system-lenovo.quirks index b365fc3c..a59e97a5 100644 --- a/data/50-system-lenovo.quirks +++ b/data/50-system-lenovo.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [Lenovo Thinkpad Touchpad] MatchName=*Synaptics* MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPad*:* @@ -64,11 +66,13 @@ MatchName=*ALPS TrackPoint* MatchDMIModalias=dmi:*svnLENOVO:*:pvrThinkPadX280:* AttrTrackpointRange=70 -# Lenovo Thinkpad X1 Yoga disables the keyboard anyway but has the same device -# use a windows key on the screen and volume rocker on the side (#103749) -[Lenovo Thinkpad X1 Yoga] +# Lenovo Thinkpad Yoga (not the consumer versions) disables the keyboard +# mechanically. We must not disable the keyboard because some keys are +# still accessible on the screen and volume rocker. +# Initially #103749 and extended by #106799 comment 7 +[Lenovo Thinkpad Yoga] MatchName=AT Translated Set 2 keyboard -MatchDMIModalias=dmi:*svnLENOVO:*pvrThinkPadX1Yoga1st:* +MatchDMIModalias=dmi:*svnLENOVO:*pvrThinkPad*Yoga*:* ModelTabletModeNoSuspend=1 # Lenovo Carbon X1 6th gen (RMI4 only, PS/2 is broken on this device) @@ -76,3 +80,8 @@ ModelTabletModeNoSuspend=1 MatchName=Synaptics TM3288-010 MatchDMIModalias=dmi:*svnLenovo:*pvrThinkPadX1Carbon6th:* ModelLenovoCarbonX16th=1 + +[Lenovo X41 Tablet] +MatchName=AT Translated Set 2 keyboard +MatchDMIModalias=dmi:*svnIBM:*pvrThinkPadX41Tablet:* +ModelTabletModeNoSuspend=1 diff --git a/data/50-system-system76.quirks b/data/50-system-system76.quirks index 15dd6108..2e8eb800 100644 --- a/data/50-system-system76.quirks +++ b/data/50-system-system76.quirks @@ -1,3 +1,5 @@ +# Do not edit this file, it will be overwritten on update + [System76 Bonobo Professional] MatchName=SynPS/2 Synaptics TouchPad MatchDMIModalias=dmi:*svnSystem76*pvrbonp5* diff --git a/src/quirks.c b/src/quirks.c index 3f133015..b1be3d57 100644 --- a/src/quirks.c +++ b/src/quirks.c @@ -85,8 +85,9 @@ enum match_flags { M_DMI = (1 << 4), M_UDEV_TYPE = (1 << 5), M_DT = (1 << 6), + M_VERSION = (1 << 7), - M_LAST = M_DT, + M_LAST = M_VERSION, }; enum bustype { @@ -121,6 +122,7 @@ struct match { enum bustype bus; uint32_t vendor; uint32_t product; + uint32_t version; char *dmi; /* dmi modalias with preceding "dmi:" */ @@ -275,6 +277,7 @@ matchflagname(enum match_flags f) case M_BUS: return "MatchBus"; break; case M_VID: return "MatchVendor"; break; case M_PID: return "MatchProduct"; break; + case M_VERSION: return "MatchVersion"; break; case M_DMI: return "MatchDMIModalias"; break; case M_UDEV_TYPE: return "MatchUdevType"; break; case M_DT: return "MatchDeviceTree"; break; @@ -489,6 +492,16 @@ parse_match(struct quirks_context *ctx, goto out; s->match.product = product; + } else if (streq(key, "MatchVersion")) { + unsigned int version; + + check_set_bit(s, M_VERSION); + if (!strneq(value, "0x", 2) || + !safe_atou_base(value, &version, 16) || + version > 0xFFFF) + goto out; + + s->match.version = version; } else if (streq(key, "MatchDMIModalias")) { check_set_bit(s, M_DMI); if (!strneq(value, "dmi:", 4)) { @@ -1147,7 +1160,8 @@ match_fill_bus_vid_pid(struct match *m, m->product = product; m->vendor = vendor; - m->bits |= M_PID|M_VID; + m->version = version; + m->bits |= M_PID|M_VID|M_VERSION; switch (bus) { case BUS_USB: m->bus = BT_USB; @@ -1295,6 +1309,10 @@ quirk_match_section(struct quirks_context *ctx, if (m->product == s->match.product) matched_flags |= flag; break; + case M_VERSION: + if (m->version == s->match.version) + matched_flags |= flag; + break; case M_DMI: if (fnmatch(s->match.dmi, m->dmi, 0) == 0) matched_flags |= flag; diff --git a/test/test-quirks.c b/test/test-quirks.c index 16bbacf0..be488a7e 100644 --- a/test/test-quirks.c +++ b/test/test-quirks.c @@ -578,6 +578,67 @@ START_TEST(quirks_parse_product_invalid) } END_TEST +START_TEST(quirks_parse_version) +{ + struct quirks_context *ctx; + const char quirks_file[] = + "[Section name]\n" + "MatchVersion=0x0000\n" + "ModelAppleTouchpad=1\n" + "\n" + "[Section name]\n" + "MatchVersion=0x0001\n" + "ModelAppleTouchpad=1\n" + "\n" + "[Section name]\n" + "MatchVersion=0x2343\n" + "ModelAppleTouchpad=1\n"; + struct data_dir dd = make_data_dir(quirks_file); + + ctx = quirks_init_subsystem(dd.dirname, + NULL, + log_handler, + NULL, + QLOG_CUSTOM_LOG_PRIORITIES); + ck_assert_notnull(ctx); + quirks_context_unref(ctx); + cleanup_data_dir(dd); +} +END_TEST + +START_TEST(quirks_parse_version_invalid) +{ + struct quirks_context *ctx; + const char *quirks_file[] = { + "[Section name]\n" + "MatchVersion=-1\n" + "ModelAppleTouchpad=1\n", + "[Section name]\n" + "MatchVersion=abc\n" + "ModelAppleTouchpad=1\n", + "[Section name]\n" + "MatchVersion=0xFFFFF\n" + "ModelAppleTouchpad=1\n", + "[Section name]\n" + "MatchVersion=123\n" + "ModelAppleTouchpad=1\n", + }; + const char **qf; + + ARRAY_FOR_EACH(quirks_file, qf) { + struct data_dir dd = make_data_dir(*qf); + + ctx = quirks_init_subsystem(dd.dirname, + NULL, + log_handler, + NULL, + QLOG_CUSTOM_LOG_PRIORITIES); + ck_assert(ctx == NULL); + cleanup_data_dir(dd); + } +} +END_TEST + START_TEST(quirks_parse_name) { struct quirks_context *ctx; @@ -939,6 +1000,8 @@ TEST_COLLECTION(quirks) litest_add_for_device("quirks:parsing", quirks_parse_vendor_invalid, LITEST_MOUSE); litest_add_for_device("quirks:parsing", quirks_parse_product, LITEST_MOUSE); litest_add_for_device("quirks:parsing", quirks_parse_product_invalid, LITEST_MOUSE); + litest_add_for_device("quirks:parsing", quirks_parse_version, LITEST_MOUSE); + litest_add_for_device("quirks:parsing", quirks_parse_version_invalid, LITEST_MOUSE); litest_add_for_device("quirks:parsing", quirks_parse_name, LITEST_MOUSE); litest_add_for_device("quirks:parsing", quirks_parse_name_invalid, LITEST_MOUSE); litest_add_for_device("quirks:parsing", quirks_parse_udev, LITEST_MOUSE);