evdev: add support for LIBINPUT_MODEL_* udev tags

Some devices need specific configuration or different defaults.
Push that into udev rules and a hwdb file, that's where detection is the
easiest. The LIBINPUT_MODEL_ prefix is used to determine some type of device
model. Note that this property is a private API and subject to change at
any time without notice.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Tested-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
Peter Hutterer 2015-04-20 14:29:44 -04:00
parent b81afb019a
commit 0515a670af
6 changed files with 91 additions and 1 deletions

View file

@ -63,6 +63,9 @@ libinput_pointer_get_axis_source() for details.
<dt>POINTINGSTICK_CONST_ACCEL</dt>
<dd>A constant (linear) acceleration factor to apply to pointingstick deltas
to normalize them.
<dt>LIBINPUT_MODEL_*</dt>
<dd><b>This prefix is reserved as private API, do not use.</b>. See @ref
model_specific_configuration for details.
</dd>
</dl>
@ -98,4 +101,16 @@ ACTION=="add|change", KERNEL=="event[0-9]*", ENV{ID_VENDOR_ID}=="012a", \
ENV{ID_MODEL_ID}=="034b", ENV{ID_INPUT_TOUCHPAD}="", ENV{ID_INPUT_TABLET}="1"
@endcode
@section model_specific_configuration Model-specific configuration
libinput reserves the property prefix <b>LIBINPUT_MODEL_</b> for
model-specific configuration. <b>This prefix is reserved as private API, do
not use.</b>
The effect of this property may be to enable or disable certain
features on a specific device or set of devices, to change configuration
defaults or any other reason. The effects of setting this property, the
format of the property and the value of the property are subject to change
at any time.
*/

View file

@ -1422,6 +1422,27 @@ evdev_read_dpi_prop(struct evdev_device *device)
return dpi;
}
static inline enum evdev_device_model
evdev_read_model(struct evdev_device *device)
{
const struct model_map {
const char *property;
enum evdev_device_model model;
} model_map[] = {
{ NULL, EVDEV_MODEL_DEFAULT },
};
const struct model_map *m = model_map;
while (m->property) {
if (!!udev_device_get_property_value(device->udev_device,
m->property))
break;
m++;
}
return m->model;
}
/* Return 1 if the given resolutions have been set, or 0 otherwise */
inline int
evdev_fix_abs_resolution(struct evdev_device *device,
@ -1950,6 +1971,7 @@ evdev_device_create(struct libinput_seat *seat,
device->scroll.wheel_click_angle =
evdev_read_wheel_click_prop(device);
device->dpi = evdev_read_dpi_prop(device);
device->model = evdev_read_model(device);
/* at most 5 SYN_DROPPED log-messages per 30s */
ratelimit_init(&device->syn_drop_limit, 30ULL * 1000, 5);

View file

@ -93,6 +93,10 @@ enum evdev_middlebutton_event {
MIDDLEBUTTON_EVENT_ALL_UP,
};
enum evdev_device_model {
EVDEV_MODEL_DEFAULT,
};
struct mt_slot {
int32_t seat_slot;
struct device_coords point;
@ -202,6 +206,8 @@ struct evdev_device {
int dpi; /* HW resolution */
struct ratelimit syn_drop_limit; /* ratelimit for SYN_DROPPED logging */
enum evdev_device_model model;
};
#define EVDEV_UNHANDLED_DEVICE ((struct evdev_device *) 1)

View file

@ -0,0 +1,16 @@
# Do not edit this file, it will be overwritten on update
#
# This file contains hwdb matches 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 lookup keys are composed in:
# 90-libinput-model-quirks.rules
#
# Match string formats:
# libinput:<modalias>
# libinput:name:<name>:dmi:<dmi string>
#
# Sort by brand, model

View file

@ -0,0 +1,25 @@
# 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"
# hwdb matches:
#
# libinput:<modalias>
IMPORT{builtin}="hwdb --subsystem=input --lookup-prefix=libinput:", \
GOTO="libinput_model_quirks_end"
# libinput:name:<name>:dmi:<dmi string>
KERNELS=="input*", \
IMPORT{builtin}="hwdb 'libinput:name:$attr{name}:$attr{[dmi/id]modalias}'", \
GOTO="libinput_model_quirks_end"
LABEL="libinput_model_quirks_end"

View file

@ -6,4 +6,10 @@ libinput_device_group_CFLAGS = $(LIBUDEV_CFLAGS) $(GCC_CFLAGS)
libinput_device_group_LDADD = $(LIBUDEV_LIBS)
udev_rulesdir=$(UDEV_DIR)/rules.d
dist_udev_rules_DATA = 80-libinput-device-groups.rules
dist_udev_rules_DATA = \
80-libinput-device-groups.rules \
90-libinput-model-quirks.rules
udev_hwdbdir=$(UDEV_DIR)/hwdb.d
dist_udev_hwdb_DATA = \
90-libinput-model-quirks.hwdb