commit | e9dba29a8fb92729abd207896fdf09a09d1581ca | [log] [tgz] |
---|---|---|
author | Harvey Yang <chenghaoyang@chromium.org> | Tue May 19 06:43:03 2020 |
committer | Commit Bot <commit-bot@chromium.org> | Fri May 29 21:51:15 2020 |
tree | 02e49cf22481be2a30e7d03488bc0ca9b3d2e008 | |
parent | 2e986c3f49fccf70a683ec2c6deeea45716b55e3 [diff] |
libmems: Add GetBufferFd in IioDevice This commit adds GetBufferFd to let users wait for events without being blocked by polling the file descriptor. It's mainly used in the sensor service (iioservice). BUG=chromium:1006141 TEST=builds Change-Id: I82cadb1d19f7d82c32502141b403b7912506565b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2208520 Commit-Queue: Cheng-Hao Yang <chenghaoyang@chromium.org> Tested-by: Cheng-Hao Yang <chenghaoyang@chromium.org> Auto-Submit: Cheng-Hao Yang <chenghaoyang@chromium.org> Reviewed-by: Eric Caruso <ejcaruso@chromium.org> Cr-Mirrored-From: https://chromium.googlesource.com/chromiumos/platform2 Cr-Mirrored-Commit: e8b301b6d6541bb839ae3ddad74e35532de6a006
Project goal and motivation
This library provides a set of wrapper and test helpers around libiio.
It is meant to provide a common foundation for Chrome OS to access and interface IIO sensors, with:
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 IioChannel
s, which can individually be enabled and disabled.
Useful mocks for the core classes are provided, such that a test author can focus on the logic of the unit tests and share a common testing language with other engineers working in this space. Sharing the foundation of testing IIO sensor access helps ensure that any improvement in this area can benefit all clients.