udev: hwdb: Add orientation quirk for base-mounted accelerometers on Chromebooks#24353
Merged
yuwata merged 3 commits intosystemd:mainfrom Aug 19, 2022
Merged
udev: hwdb: Add orientation quirk for base-mounted accelerometers on Chromebooks#24353yuwata merged 3 commits intosystemd:mainfrom
yuwata merged 3 commits intosystemd:mainfrom
Conversation
The IIO subsystem exposes a 'label' sysfs file to help userspace better identify its devices [1]. Standardized labels include the sensor type along with its location, including 'accel-base' and 'accel-display'. Most Chrome OS boards have two accelerometers that are indistinguishable except for this label (or a 'location' sysfs file before Linux v6.0), and need different mounting matrix corrections based on their location. Add a udev rule that matches hwdb entries using this label, so we can correct both accelerometers on these devices with hwdb entries. The existing rules and hwdb entries are not modified to keep potential out-of-tree entries working, but new entries in this form will override existing ones. Also add currently standardized labels to parse-hwdb.py. [1] https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio
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.
The cros-ec-accel devices report their mounting location by the 'label' sysfs file only since Linux v6.0. With earlier kernels, a nonstandard 'location' file reports this, but slightly differently (lid instead of display) [1]. Add udev rules to import the correct hwdb entries based on this 'location' file for cros-ec-accel devices, so that the base-mounted accel matrix has the correct value for older kernels as well. [1] https://kernel.org/doc/Documentation/ABI/testing/sysfs-bus-iio-cros-ec
4287937 to
ac3c031
Compare
Contributor
Author
|
|
|
You are on a roll! Looks good to me.
@gwendalg, any concerns? |
Contributor
|
Thanks, |
yuwata
approved these changes
Aug 19, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a follow-up to #24276, which added generic hwdb entries for cros-ec-accel devices. Also see the post-merge comments to that. In short, the existing hwdb fragment is correct for the display-mounted accelerometer, but not for the base-mounted one. The only way to distinguish the two devices is a
locationsysfs file before Linux v6.0, and alabelfile after that version.The iio device
labellooks like it would be useful for similar cases later on, so the first commit adds a rule to match it in the hwdb entries. The second commit adds entries in this style for cros-ec-accel. The third commit tries to import these rules based on thelocationfile for older kernels, though I guess it's not essential and can be dropped if you want to keep driver-specific things out of the rules.