Commit 870ddce9 authored by Peter Hutterer's avatar Peter Hutterer

Drop the udev hwdb model quirks

Replaced with the quirks files in merge commit
000ac14cSigned-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent a7d19e44
Pipeline #1395 passed with stage
in 6 minutes and 5 seconds
......@@ -116,13 +116,6 @@ executable('libinput-model-quirks',
install : true,
install_dir : udev_dir)
model_quirks = files('udev/90-libinput-model-quirks.hwdb')
parse_hwdb_py = find_program('udev/parse_hwdb.py')
test('parse-hwdb',
parse_hwdb_py,
args : model_quirks)
udev_rules_config = configuration_data()
udev_rules_config.set('UDEV_TEST_PATH', '')
configure_file(input : 'udev/80-libinput-device-groups.rules.in',
......@@ -130,16 +123,6 @@ configure_file(input : 'udev/80-libinput-device-groups.rules.in',
install : true,
install_dir : udev_rules_dir,
configuration : udev_rules_config)
configure_file(input : 'udev/90-libinput-model-quirks.rules.in',
output : '90-libinput-model-quirks.rules',
install : true,
install_dir : udev_rules_dir,
configuration : udev_rules_config)
configure_file(input : model_quirks,
output : '90-libinput-model-quirks.hwdb',
install : true,
install_dir : udev_hwdb_dir,
configuration : udev_rules_config)
litest_udev_rules_config = configuration_data()
litest_udev_rules_config.set('UDEV_TEST_PATH', meson.build_root() + '/')
......@@ -147,10 +130,6 @@ litest_groups_rules_file = configure_file(input : 'udev/80-libinput-device-group
output : '80-libinput-device-groups-litest.rules',
install : false,
configuration : litest_udev_rules_config)
litest_model_quirks_file = configure_file(input : 'udev/90-libinput-model-quirks.rules.in',
output : '90-libinput-model-quirks-litest.rules',
install : false,
configuration : litest_udev_rules_config)
############ libinput-util.a ############
src_libinput_util = [
......@@ -812,10 +791,6 @@ if get_option('tests')
install : false,
configuration : udev_rules_config)
config_h.set_quoted('LIBINPUT_MODEL_QUIRKS_UDEV_RULES_FILE',
join_paths(meson.build_root(), '90-libinput-model-quirks.rules'))
config_h.set_quoted('LIBINPUT_MODEL_QUIRKS_UDEV_HWDB_FILE',
join_paths(meson.build_root(), '90-libinput-model-quirks.hwdb'))
config_h.set_quoted('LIBINPUT_TEST_DEVICE_RULES_FILE',
join_paths(meson.build_root(), '80-libinput-test-device.rules'))
config_h.set_quoted('LIBINPUT_DEVICE_GROUPS_RULES_FILE',
......
......@@ -1185,16 +1185,6 @@ litest_install_model_quirks(struct list *created_files_list)
"#################################################################\n\n";
struct created_file *file;
file = litest_copy_file(UDEV_MODEL_QUIRKS_RULE_FILE,
LIBINPUT_MODEL_QUIRKS_UDEV_RULES_FILE,
warning);
list_insert(created_files_list, &file->link);
file = litest_copy_file(UDEV_MODEL_QUIRKS_HWDB_FILE,
LIBINPUT_MODEL_QUIRKS_UDEV_HWDB_FILE,
warning);
list_insert(created_files_list, &file->link);
file = litest_copy_file(UDEV_TEST_DEVICE_RULE_FILE,
LIBINPUT_TEST_DEVICE_RULES_FILE,
warning);
......
This diff is collapsed.
# Do not edit this file, it will be overwritten on update
#
# This file contains lookup rules for libinput model-specific quirks.
# The contents of this file are a contract between libinput, udev rules and
# the hwdb.
# IT IS NOT A STABLE API AND SUBJECT TO CHANGE AT ANY TIME
#
# The hwdb database is in:
# 90-libinput-model-quirks.hwdb
ACTION!="add|change", GOTO="libinput_model_quirks_end"
KERNEL!="event*", GOTO="libinput_model_quirks_end"
# libinput:touchpad:<modalias>
ENV{ID_INPUT_TOUCHPAD}=="1", \
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:touchpad:"
# libinput:tablet:<modalias>
ENV{ID_INPUT_TABLET}=="1", \
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:tablet:"
# libinput:mouse:<modalias>
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:"
# libinput:name:<name>:dmi:<dmi string>
KERNELS=="input*", \
IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:$attr{[dmi/id]modalias}'"
# libinput:name:<name>:dt:<device-tree string>
KERNELS=="input*", \
IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:dt:$attr{[devicetree/base]model}'"
LABEL="libinput_model_quirks_end"
#!/usr/bin/env python3
# vim: set expandtab shiftwidth=4:
# -*- Mode: python; coding: utf-8; indent-tabs-mode: nil -*- */
#
# ANY MODIFICATIONS TO THIS FILE SHOULD BE MERGED INTO THE SYSTEMD UPSTREAM
#
# This file is part of systemd. It is distributed under the MIT license, see
# below.
#
# Copyright 2016 Zbigniew Jędrzejewski-Szmek
#
# The MIT License (MIT)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import functools
import glob
import string
import sys
import os
try:
from pyparsing import (Word, White, Literal, ParserElement, Regex,
LineEnd, OneOrMore, Combine, Or, Optional,
Suppress, Group, nums, alphanums, printables,
stringEnd, pythonStyleComment,
ParseBaseException)
except ImportError:
print('pyparsing is not available')
sys.exit(77)
try:
from evdev.ecodes import ecodes
except ImportError:
ecodes = None
print('WARNING: evdev is not available')
EOL = LineEnd().suppress()
EMPTYLINE = LineEnd()
COMMENTLINE = pythonStyleComment + EOL
INTEGER = Word(nums)
REAL = Combine((INTEGER + Optional('.' + Optional(INTEGER))) ^ ('.' + INTEGER))
UDEV_TAG = Word(string.ascii_uppercase, alphanums + '_')
TYPES = {
'libinput': ('name', 'touchpad', 'mouse', 'keyboard', 'tablet', 'pointingstick'),
}
@functools.lru_cache()
def hwdb_grammar():
ParserElement.setDefaultWhitespaceChars('')
prefix = Or(category + ':' + Or(conn) + ':'
for category, conn in TYPES.items())
matchline = Combine(prefix + Word(printables + ' ' + '®')) + EOL
propertyline = (
White(' ', exact=1).suppress()
+ Combine(UDEV_TAG
- '='
- Word(alphanums + '_=:@*.! ')
- Optional(pythonStyleComment))
+ EOL
)
propertycomment = White(' ', exact=1) + pythonStyleComment + EOL
group = (
OneOrMore(matchline('MATCHES*') ^ COMMENTLINE.suppress())
- OneOrMore(propertyline('PROPERTIES*') ^ propertycomment.suppress())
- (EMPTYLINE ^ stringEnd()).suppress()
)
commentgroup = OneOrMore(COMMENTLINE).suppress() - EMPTYLINE.suppress()
grammar = OneOrMore(group('GROUPS*') ^ commentgroup) + stringEnd()
return grammar
@functools.lru_cache()
def property_grammar():
ParserElement.setDefaultWhitespaceChars(' ')
model_props = [
Regex(r'LIBINPUT_MODEL_[_0-9A-Z]+')('NAME') -
Suppress('=') - (Literal('1'))('VALUE')
]
dimension = INTEGER('X') + Suppress('x') + INTEGER('Y')
crange = INTEGER('X') + Suppress(':') + INTEGER('Y')
vprops = (
('LIBINPUT_ATTR_SIZE_HINT', Group(dimension('SETTINGS*'))),
('LIBINPUT_ATTR_RESOLUTION_HINT', Group(dimension('SETTINGS*'))),
('LIBINPUT_ATTR_PRESSURE_RANGE', Group(crange('SETTINGS*'))),
('LIBINPUT_ATTR_TOUCH_SIZE_RANGE', Group(crange('SETTINGS*'))),
('LIBINPUT_ATTR_TPKBCOMBO_LAYOUT', Or(('below'))),
('LIBINPUT_ATTR_LID_SWITCH_RELIABILITY', Or(('reliable', 'write_open'))),
('LIBINPUT_ATTR_KEYBOARD_INTEGRATION', Or(('internal', 'external'))),
('LIBINPUT_ATTR_TRACKPOINT_RANGE', INTEGER('Y')),
('LIBINPUT_ATTR_THUMB_PRESSURE_THRESHOLD', INTEGER('Y')),
)
value_props = [Literal(name)('NAME') - Suppress('=') - val('VALUE') for
name, val in vprops]
tprops = (
('LIBINPUT_ATTR_PALM_PRESSURE_THRESHOLD', INTEGER('X')),
('LIBINPUT_ATTR_PALM_SIZE_THRESHOLD', INTEGER('X')),
)
typed_props = [Literal(name)('NAME') - Suppress('=') - val
for name, val in tprops]
grammar = Or(model_props + value_props + typed_props)
return grammar
ERROR = False
def error(fmt, *args, **kwargs):
global ERROR
ERROR = True
print(fmt.format(*args, **kwargs))
def convert_properties(group):
matches = [m[0] for m in group.MATCHES]
props = [p[0] for p in group.PROPERTIES]
return matches, props
def parse(fname):
grammar = hwdb_grammar()
try:
parsed = grammar.parseFile(fname)
except ParseBaseException as e:
error('Cannot parse {}: {}', fname, e)
return []
return [convert_properties(g) for g in parsed.GROUPS]
def check_match_uniqueness(groups):
matches = sum((group[0] for group in groups), [])
matches.sort()
prev = None
for match in matches:
if match == prev:
error('Match {!r} is duplicated', match)
prev = match
def check_one_dimension(prop, value):
if int(value[0]) <= 0 or int(value[1]) <= 0:
error('Dimension {} invalid', value)
def check_properties(groups):
grammar = property_grammar()
for matches, props in groups:
prop_names = set()
for prop in props:
# print('--', prop)
prop = prop.partition('#')[0].rstrip()
try:
parsed = grammar.parseString(prop)
except ParseBaseException as e:
error('Failed to parse: {!r}', prop)
continue
# print('{!r}'.format(parsed))
if parsed.NAME in prop_names:
error('Property {} is duplicated', parsed.NAME)
prop_names.add(parsed.NAME)
if parsed.NAME == "LIBINPUT_ATTR_SIZE_HINT" or \
parsed.NAME == "LIBINPUT_ATTR_RESOLUTION_HINT":
check_one_dimension(prop, parsed.VALUE)
def print_summary(fname, groups):
print('{}: {} match groups, {} matches, {} properties'
.format(fname,
len(groups),
sum(len(matches) for matches, props in groups),
sum(len(props) for matches, props in groups),
))
if __name__ == '__main__':
args = sys.argv[1:] or glob.glob(os.path.dirname(sys.argv[0]) + '/*.hwdb')
for fname in args:
groups = parse(fname)
print_summary(fname, groups)
check_match_uniqueness(groups)
check_properties(groups)
sys.exit(ERROR)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment