Commit Graph

370 Commits

Author SHA1 Message Date
Bastien Nocera
62bdf03fab build: Add COPYING file 2020-06-26 18:16:42 +02:00
Bastien Nocera
cf1ac31f55 build: Add meson build system files 2020-06-26 18:16:42 +02:00
Bastien Nocera
52e701aa8a main: Move _GNU_SOURCE definition to the build files 2020-06-26 17:56:50 +02:00
Bastien Nocera
b802147fd9 main: Fix support for older polling accelerometers
Add support for per-axis accel scaling as required for older
accelerometers:
"
It used to be hard to have the same range out of the plane of the silicon
than within it, so was common to have sensors with different ranges and
hence scales in z direction from x and y.
"

Fetch the scale for each axis from sysfs for polling accelerometers.
2020-05-04 14:52:25 +02:00
Bastien Nocera
eaa3fbc800 main: Use AccelScale everywhere
Use AccelScale, which supports per-axis accelerometer scaling everywhere
we would have had a single scale value.

This adds per-axis support from the ring-buffer for accelerometers
with triggers.
2020-05-04 14:49:55 +02:00
Bastien Nocera
1b8c1c6b37 accel: Add per-axis accel scale helpers 2020-05-04 12:00:42 +02:00
Your Name
ed427251b7 proximity: Get near-level from sysfs if available
DT based devices can set the near-level via sysfs. Parse it from
there too.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
Closes: #297
2020-03-25 12:11:03 +01:00
Bastien Nocera
a4e4e55c06 3.0 2020-03-23 10:59:29 +01:00
Bastien Nocera
876987b418 main: Reword "no supported sensors" debug message
To stop users thinking that we'd be responsible for providing support
for their sensors when it's the kernel's job.
2020-03-23 10:58:40 +01:00
Guido Günther
fcf951b3bc data: Don't overwrite IIO_SENSOR_PROXY_TYPE
Don't overwrite an already set type for light and ambient to support
multi channel sensors.

This reverts commit 5ef75b57a988a8a6acc2611cde760f28fc7b48d6.
2020-03-04 09:41:44 +00:00
Guido Günther
de1e1ea35a drivers: Support multi-function sensors
There are multi channel sensors like the vcnl4040 that provide
als and proximity information via the same device but different
sysfs files.
2020-03-04 09:41:44 +00:00
Guido Günther
aca6f81e25 monitor-sensor: support proximity 2020-03-04 09:39:50 +00:00
Guido Günther
1a9489afb6 data: Detect proximity sensors 2020-03-04 09:39:50 +00:00
Guido Günther
1497d965a3 proximity: Use a margin around near_level
This makes sure we don't trigger too often on small movements
around the near level.
2020-03-04 09:39:50 +00:00
Guido Günther
11778ab603 proximity: Read near level from udev property
The levels are sensor dependend and are also affected by how the sensor
is built into the device (e.g. the distance to the cover glass).

Android even does this in sensor specific code. Android x86 works
around this by using setprop:

https://groups.google.com/forum/#!topic/android-x86/RFXYW5MNCuk
2020-03-04 09:39:50 +00:00
Guido Günther
7024b9c45a Support proximity polling sensors 2020-03-04 09:39:50 +00:00
Guido Günther
9e22ff5d9d README: Document udev property needed for proximity sensor 2020-03-04 09:39:49 +00:00
Guido Günther
4be24633cf build: Require glib 2.56
This allows us to use g_clear_handle_id()
2020-03-04 09:39:49 +00:00
Guido Günther
ba7a80dc93 main: Use g_autoptr(GError)
This does away with some cleanups.
2020-03-04 09:22:52 +01:00
Guido Günther
cec37ef8f4 monitor-sensor: Fix memory leak
Use g_autoptr in place of the missing g_error_free().
2020-03-04 09:22:43 +01:00
Bastien Nocera
16983e0d2a README: Add note about mount-matrix on DeviceTree devices 2020-03-03 12:28:04 +01:00
Bastien Nocera
9ddf394c32 ci: Enable GPG checks on package install 2020-02-19 14:46:07 +01:00
Dmitry Osipenko
9fdbb36363 mount-matrix: Support IIO sysfs in_accel_mount_matrix
Linux kernel IIO drivers provide mount matrix via standardized sysfs
interface. The IIO mount matrix could specified by "directory" and by
"type", this patch adds support for the "by type" option which is used
by drivers that use individual matrices for each of the sensors. Tested
on Nexus 7 and Acer A500 tablet devices using MPU6050 and KXTF9 IIO drivers
respectively, now monitor-sensor reports display's orientation correctly
on these devices.
2020-01-20 23:04:52 +03:00
Dmitry Osipenko
e11bb33e7b mount-matrix: Support IIO sysfs in_mount_matrix
Linux kernel IIO drivers provide mount matrix via standardized sysfs
interface. The IIO mount matrix could specified by "directory" and by
"type", this patch adds support for the "directory" type which may be
used by drivers that use the same shared matrix for all of the sensors
or if driver provides only one accelerometer sensor at all.
2020-01-20 23:02:23 +03:00
Bastien Nocera
2d818e0992 iio: Check for fscanf() return values
Fixes the build on Ubuntu systems.

Closes: #248
2020-01-09 17:28:05 +01:00
Guido Günther
1d56dca339 fake-input-accelerometer: Expand warn_unused_result check
With

   CPPFLAGS='-D_FORTIFY_SOURCE=2'   ./configure

we otherwise fail like

fake-input-accelerometer.c:90:8: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   90 |  (void)write (data->uinput, &ev, sizeof(ev));
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fake-input-accelerometer.c:94:8: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   94 |  (void)write (data->uinput, &ev, sizeof(ev));
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fake-input-accelerometer.c:98:8: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
   98 |  (void)write (data->uinput, &ev, sizeof(ev));
      |        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fake-input-accelerometer.c:104:9: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result]
  104 |  (void) write (data->uinput, &ev, sizeof(ev));
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The '!' trick is from https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34

Closes: #248
2020-01-09 17:28:05 +01:00
Bastien Nocera
3694cd3101 ci: Build with -D_FORTIFY_SOURCE=2
As Debian and Ubuntu do.
2020-01-09 17:28:05 +01:00
Bastien Nocera
d8b70e735d ci: Fix CI
Don't "allow_failure", install packages from the correct variable and
add some missing dependencies.
2020-01-09 17:17:01 +01:00
Bastien Nocera
69cca75e12 ci: Add CI 2020-01-09 16:43:04 +01:00
Bastien Nocera
4dda433e92 light: Add support for "illuminance0" light sensors
That would be used in the tsl2772 and lm3533 kernel drivers, as well as
devices with multiple channels, such as combined proximity and light
sensors, which use "illuminance0" as the channel name instead of
"illuminance".

Closes: #290
2020-01-09 16:14:02 +01:00
Daniel Stuart
43e5ff769e accel: Fix getting scale for sensors with IIO_SHARED_BY_ALL mask
Properties with the IIO_SHARED_BY_ALL mask don't have the sensor type prefix
before the filename, causing some devices to not have a scale set from sysfs.

Fix this by searching through sysfs for both properties name: scale and
in_accel_scale.

Tested on: Cyan (Acer Chromebook R11, with 2 accelerometers)
Affects: All chromebooks with cros-ec sensors
https://github.com/torvalds/linux/tree/master/drivers/iio/common/cros_ec_sensors
2020-01-08 15:13:06 +01:00
Guido Günther
eb8fde8fd2 light: Support sensors using raw values as well
E.g. the vcnl4000 class devices reports a raw value and a scale
to calculate lux.
2020-01-06 17:42:02 +01:00
Dominik Gedon
ee95466d80 README: Correct GeoClue spelling
See: https://github.com/hadess/iio-sensor-proxy/pull/286
2019-10-30 12:30:45 +01:00
Dominik Gedon
2d28421c99 README: Fixed 60-sensor.hwdb link
See: https://github.com/hadess/iio-sensor-proxy/pull/286
2019-10-30 12:30:33 +01:00
Bastien Nocera
b7abe1286f 2.8 2019-09-04 18:16:55 +02:00
Nikita Malyavin
bb5fbcc2f9 orientation: Correct handling of orientation on threshold
The old code gave a priority to portrait orientation, so that if
rotation reached the portrait threshold, it switched straight away.

This is problematic if the device you're dealing with isn't a mostly
portrait phone, but a tablet that can be used in both orientations
equally.

Landscape thresholds and portrait thresholds can (and they do) overlap.
In the overlapping area we should try to keep the previous orientation
until that threshold has passed.

[Bastien Nocera: Added test change]
2019-09-04 18:11:45 +02:00
Bastien Nocera
1400548215 tests: Add a test for the orientation threshold switch
See https://github.com/hadess/iio-sensor-proxy/pull/279
2019-09-04 18:11:45 +02:00
Bastien Nocera
818a9902ba tests: Fix comment about verbosity and immediate failure
It was the wrong way around
2019-09-04 18:11:45 +02:00
Bastien Nocera
017bd70d70 tests: Add labels to the GTK spinbuttons 2019-09-04 18:11:45 +02:00
Bastien Nocera
0b38704a95 tests: Fix incorrect mount matrix in test-orientation.c
WARNING **: In mount matrix '0, -1, 0; -1, 0, 0; 0, 0, 0', axis z is all zeroes, which is invalid
2019-09-04 17:03:45 +03:00
Bastien Nocera
e49753003f tests: Run tests as part of "make check" 2019-09-04 17:03:45 +03:00
Daniel Stuart
924b2ad331 accel-location: Handle cros-ec sensor location
All devices with "Chromium embedded controllers have their display
sensor location set as "lid" and that sensor location is only
available through sysfs.

Prior to this commit, chromebooks with two accelerometers had their
base sensor being used as display.

See: f678d6da74/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c (L137)

Closes: #278
2019-08-20 11:30:41 +02:00
Bastien Nocera
d250ef0c68 accel-location: Some style changes 2019-08-20 11:24:17 +02:00
Bastien Nocera
d3d3c79096 2.7 2019-05-20 10:59:29 +02:00
Brett Dutro
9615ceac7c iio: Fix possible incorrect mask calculation
On some machines, iio-sensor-proxy was returning all 0's for IIO sensor
values. It turns out that the bits_used for this sensor is 32, which makes
the mask calculation:

*mask = (1 << 32) - 1;

If the compiler interprets the 1 literals as 32-bit ints, it generates
undefined behavior depending on compiler version and optimization level.
On my system, it optimizes out the shift, so the mask value becomes

*mask = (1) - 1;

With a mask value of 0, iio-sensor-proxy will always return 0 for every axis.

Avoid incorrect 0 values caused by compiler optimization.

Closes: #270
2019-05-20 10:47:19 +02:00
Bastien Nocera
b320a3207b 2.6 2019-05-14 12:47:43 +02:00
Bastien Nocera
0321041ac2 NEWS: Fix typo in 2.5 release text 2019-05-14 12:47:43 +02:00
Bastien Nocera
1ed26fd8e4 iio: And turn channel value processing into a macro
So that the code is shared between all 4 value sizes.
2019-05-14 12:47:26 +02:00
Bastien Nocera
b468ed6384 iio: Implement support for 8-, 16- and 64- bits channels 2019-05-14 12:47:26 +02:00
Bastien Nocera
6a67ead786 iio: Simplify getting 32-bit channel values
Use code from the IIO example tools at tools/iio/iio_generic_buffer.c in
the Linux kernel tree to parse the IIO data.
2019-05-14 12:47:26 +02:00