502 Commits

Author SHA1 Message Date
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
Bastien Nocera
2fb71895dd iio: Add stub for 1 byte channels 2019-05-14 12:47:26 +02:00
Bastien Nocera
e941f9ff5d iio: Break from the loop when we've found the right channel
No need to keep looping once we've found it.
2019-05-14 12:47:26 +02:00
Bastien Nocera
4f850f0be5 iio: Simplify setting the scale and presence return values
The scale should always be set to 1.0 by default, and only ever be
overridden if we could successfully read it from sysfs, and ch_present
is obviously false until we've found the channel in question.
2019-05-14 12:47:26 +02:00
Bastien Nocera
ec0d992c18 iio: Check whether getting float values fails
If we cannot parse the contents of sysfs attribute that's supposed to
contain floats, throw an error.
2019-05-14 12:47:26 +02:00
Bastien Nocera
f521ed1d87 iio: Use info temporary variable
Using a temporary struct iio_channel_info makes that piece of code much
more readable.
2019-05-14 12:47:26 +02:00
Bastien Nocera
55cf113780 iio: Better struct documentation for iio_channel_info 2019-05-14 12:47:26 +02:00
Bastien Nocera
51524ec8b4 iio: Fix possible crash on device removal
Check whether we managed to open the index file instead of crashing.

 #0  0x00007f31843660c7 in __vfscanf_internal () at /lib64/libc.so.6
 #1  0x00007f31843657ed in __isoc99_fscanf () at /lib64/libc.so.6
 #2  0x0000560bfd6b942b in build_channel_array (counter=0x560bfdea01c8, device_dir=0x560bfde90810 "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/0003:273F:1008.0044/HID-SENSOR-200041.2.auto/iio:device0")
     at iio-buffer-utils.c:320
 #3  0x0000560bfd6b942b in build_channels (data=0x560bfdea01b0) at iio-buffer-utils.c:739

(gdb) frame 2
 #2  0x0000560bfd6b942b in build_channel_array (counter=0x560bfdea01c8, device_dir=0x560bfde90810 "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/0003:273F:1008.0044/HID-SENSOR-200041.2.auto/iio:device0")
    at iio-buffer-utils.c:320
320				fscanf (sysfsfp, "%u", &current->index);
(gdb) p sysfsfp
$1 = (FILE *) 0x0
2019-05-14 12:47:26 +02:00
Bastien Nocera
1585412ef7 iio: Fix incorrect error debug in iioutils_get_param_float()
The "ret" variable was not set, so we'd end up with "failed: success".
2019-05-14 12:47:26 +02:00
Bastien Nocera
746271f238 iio: Simplify signchar parsing 2019-05-14 12:47:26 +02:00
Bastien Nocera
f90db92ca1 iio: Add documentation references for iioutils_get_type()
Link to where the structure and format are defined.
2019-05-14 12:47:26 +02:00
Bastien Nocera
afd8707998 README: Remove "Tested on" list
It was useful when we only had a couple of entries, but it's rather
pointless now that pretty much all the systems should work, and the ones
that don't should be listed in open issues on GitHub.
2019-05-02 09:38:42 +02:00
Luís Ferreira
c42fdc460e accel-location: add tests for accel location property 2019-05-02 09:34:07 +02:00
Luís Ferreira
a67fd98895 accel-location: Ignore accel sensors with 'base' location 2019-05-02 09:34:07 +02:00
Luís Ferreira
c2a10a108e accel-location: add location to driver data 2019-05-02 09:34:07 +02:00
Luís Ferreira
f14d26d14c accel-location: add helper functions for ACCEL_LOCATION udev property 2019-05-02 09:34:07 +02:00
Daniel Drake
25cb8f3f17 mount-matrix: Read mount matrix from sysfs
If we don't have an ACCEL_MOUNT_MATRIX property for this device,
then check if there is a mount matrix available in sysfs.
Some kernel drivers export the mount matrix there, e.g. st_accel.

This fixes an issue where the screen was automatically rotated to
an incorrect orientation on Acer Veriton Z4660G/Z6860G/A890.
2019-03-21 08:55:12 +01:00
Daniel Drake
83875cc4e9 mount-matrix: move setup to a helper function
The logic to parse the mount matrix from udev is duplicated in 3
places. Move it to a common helper function.
2019-03-21 08:55:12 +01:00
Bastien Nocera
43fb8be70b iio: More debug in process_scan_1() 2019-03-16 12:26:01 +01:00