accel-location: Handle cros-ec sensor location

All devices with "Chromium embedded controllers have their display
sensor location set as "lid" and that sensor location is only
available through sysfs.

Prior to this commit, chromebooks with two accelerometers had their
base sensor being used as display.

See: f678d6da74/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c (L137)

Closes: #278
This commit is contained in:
Daniel Stuart
2019-07-25 19:17:54 -03:00
committed by Bastien Nocera
parent d250ef0c68
commit 924b2ad331

View File

@@ -22,9 +22,16 @@ setup_accel_location (GUdevDevice *device)
g_warning ("Failed to parse ACCEL_LOCATION ('%s') from udev",
location);
} else {
g_debug ("No autodetected location, falling back to display location");
}
location = g_udev_device_get_sysfs_attr (device, "location");
if (location) {
if (parse_accel_location (location, &ret))
return ret;
g_warning ("Failed to parse location ('%s') from sysfs",
location);
}
g_debug ("No auto-detected location, falling back to display location");
ret = ACCEL_LOCATION_DISPLAY;
return ret;
@@ -36,7 +43,8 @@ parse_accel_location (const char *location, AccelLocation *value)
/* Empty string means we use the display location */
if (location == NULL ||
*location == '\0' ||
g_str_equal (location, "display")) {
g_str_equal (location, "display") ||
g_str_equal (location, "lid")) {
*value = ACCEL_LOCATION_DISPLAY;
return TRUE;
} else if (g_str_equal (location, "base")) {