tree: 0db4322a81c0d9acf0039325a0c93d82271a18d1 [path history] [tgz]
  1. accelerometer_test.cc
  2. BUILD.gn
  3. configuration.cc
  4. configuration.h
  5. delegate.h
  6. delegate_impl.cc
  7. delegate_impl.h
  8. gyroscope_test.cc
  9. iio_channel.h
  10. iio_channel_impl.cc
  11. iio_channel_impl.h
  12. iio_context.h
  13. iio_context_impl.cc
  14. iio_context_impl.h
  15. iio_device.cc
  16. iio_device.h
  17. iio_device_impl.cc
  18. iio_device_impl.h
  19. main.cc
  20. OWNERS
  21. README.md
  22. sensor_kind.cc
  23. sensor_kind.h
  24. sensor_location.h
  25. test_helper.cc
  26. test_helper.h
  27. test_mocks.cc
  28. test_mocks.h
  29. vpd_loader_test.cc
mems_setup/README.md

Chrome OS MEMS Setup Code

/usr/sbin/mems_setup

This tool handles the boot-time setup of cros_ec sensors on the device, such as accelerometers, gyroscopes, and potentially other sensors in the future.

The goals of introducing this tool vs. using a shell script include:

  • improved testability;
  • more readable;
  • better performance.

This tool is based on libiio, and exposes a small wrapper on top of the library to aid in writing test cases.

Class hierarchy

At the root of the hierarchy, there exists the IioContext, which represents the IIO devices currently available on the system. These can be retrieved by name and inspected, via instances of IioDevice.

An IioDevice allows reading and writing attributes of an IIO device via type-safe helper APIs. It also offers support for configuring the buffer and trigger of an IIO device, which we use in order to allow the Chrome UI to read accelerometer data and support screen rotation.

An IioDevice also exposes a list of IioChannels, which can individually be enabled and disabled.

Configuration

Currently, the actions taken by the tool are statically determined by the type of sensor being initialized, and the only values that are discovered at runtime are the VPD calibrations. If your use case needs tweaking the behavior of this tool in other ways, please file a bug.