From 9f366b943de79689123e6d875e0fb08f8c60724d Mon Sep 17 00:00:00 2001 From: Boian Bonev Date: Thu, 22 Sep 2022 01:28:34 +0300 Subject: [PATCH] hwdb: Add Chromebook accel orientation quirks based on sysfs label The base-mounted accelerometer on Chromebooks return values same as the display when the lid angle is 180 degrees, instead of when the lid is closed. To match userspace expectations we must further rotate the existing accelerometer mounting matrix by 180 degrees around the X axis: [[-1, 0, 0], [[ 1, 0, 0], [[-1, 0, 0], [ 0, -1, 0], X [ 0, -1, 0], = [ 0, 1, 0], [ 0, 0, -1]] [ 0, 0, -1]] [ 0, 0, 1]] A previous commit lets us distinguish between the two cros-ec-accel devices on these boards by their 'label' sysfs file. Add hwdb entries that make base-mounted accelerometers use this correct matrix, and display-mounted ones use the existing one. Note that the cros-ec-accel drivers use 'label' only since Linux v6.0. The old match strings are not removed to support older kernels, even though they are only correct for the display-mounted sensor. systemd-commit fea267f8c71d0edffee5ccbb806755fb626c5e29 Author: Alper Nebi Yasak Date: Thu Aug 18 18:24:05 2022 +0300 --- hwdb/60-sensor.hwdb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hwdb/60-sensor.hwdb b/hwdb/60-sensor.hwdb index ecd10f292..f1a068106 100644 --- a/hwdb/60-sensor.hwdb +++ b/hwdb/60-sensor.hwdb @@ -402,6 +402,17 @@ sensor:modalias:platform:cros-ec-accel:dmi:*svnGoogle:pnVayne*:* sensor:modalias:platform:cros-ec-accel:dmi:*Google_Nocturne*:* ACCEL_MOUNT_MATRIX=1, 0, 0; 0, -1, 0; 0, 0, 1 +sensor:modalias:platform:cros-ec-accel:* +sensor:accel-display:modalias:platform:cros-ec-accel:* +sensor:accel-display:modalias:platform:cros-ec-accel-legacy:* + ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, -1, 0; 0, 0, -1 + +# Base accel reports the same as display when lid angle is 180 degrees (vs 0), +# so it needs an additional 180 degree rotation around the X axis. +sensor:accel-base:modalias:platform:cros-ec-accel:* +sensor:accel-base:modalias:platform:cros-ec-accel-legacy:* + ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1 + ######################################### # GP-electronic #########################################