]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hwdb: Add Chromebook accel orientation quirks based on sysfs label
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>
Thu, 18 Aug 2022 15:24:05 +0000 (18:24 +0300)
committerAlper Nebi Yasak <alpernebiyasak@gmail.com>
Thu, 18 Aug 2022 18:17:19 +0000 (21:17 +0300)
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.

hwdb.d/60-sensor.hwdb

index b8331243c629f3c48914d4361875f71db9575567..a0f870bd0a50336fe835a8a8adfc823607e42ea9 100644 (file)
@@ -413,11 +413,17 @@ sensor:modalias:acpi:KXCJ9000*:dmi:*:bvrZY-8-BI-PX4S70VTR400-X423B-005-D:*:rvnAM
 # CrOS EC & kernel drivers internally correct for per-board sensor orientations,
 # but they return values in the inverse direction (Android & W3C specs vs HID).
 sensor:modalias:platform:cros-ec-accel:*
- ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, -1, 0; 0, 0, -1
-
 sensor:modalias:platform:cros-ec-accel-legacy:*
+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
 #########################################