hadess / iio-sensor-proxy

IIO accelerometer sensor to input device proxy
196 stars 64 forks source link

Thinkpad Yoga 370 screen rotation doesn't work #164

Closed detached closed 7 years ago

detached commented 7 years ago

I am running the Lenovo Thinkpad Yoga 370 with Fedora 25 (4.10.13-200.fc25.x86_64).

The monitor-sensors command doesn't output anything:

[root@localhost /]# monitor-sensor 
    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: undefined)
=== Has ambient light sensor (value: 0.000000, unit: lux)

When running the iio-sensors-proxy in debug mode the accelerometer is correctly detected, but no data is incoming:

[root@localhost /]# G_MESSAGES_DEBUG=all /usr/sbin/iio-sensor-proxy
** (process:16437): DEBUG: Found IIO buffer ALS at /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0001/HID-SENSOR-200041.2.auto/iio:device0
** (process:16437): DEBUG: Found device /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0001/HID-SENSOR-200041.2.auto/iio:device0 of type ambient light sensor at IIO Buffer Light sensor
** (process:16437): DEBUG: Found associated trigger at /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200073.10.auto/trigger3
** (process:16437): DEBUG: Found IIO buffer accelerometer at /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200073.10.auto/iio:device3
** (process:16437): DEBUG: Found device /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200073.10.auto/iio:device3 of type accelerometer at IIO Buffer accelerometer
** (process:16437): DEBUG: Found IIO buffer compass at /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200083.13.auto/iio:device4
** (process:16437): DEBUG: Found device /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200083.13.auto/iio:device4 of type compass at IIO Buffer Compass
** (process:16437): DEBUG: Found associated trigger at /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200073.10.auto/trigger3
** (process:16437): DEBUG: Already enabled sensor /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200073.10.auto/iio:device3/scan_elements/in_accel_y_en
** (process:16437): DEBUG: Already enabled sensor /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200073.10.auto/iio:device3/scan_elements/in_accel_x_en
** (process:16437): DEBUG: Already enabled sensor /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200073.10.auto/iio:device3/scan_elements/in_accel_z_en
** (process:16437): DEBUG: Got type for in_accel_y: is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Got type for in_accel_x: is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Got type for in_accel_z: is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Built channel array for in_accel_x: index: 0, is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Built channel array for in_accel_y: index: 1, is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Built channel array for in_accel_z: index: 2, is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Found associated trigger at /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0001/HID-SENSOR-200041.2.auto/trigger0
** (process:16437): DEBUG: Already enabled sensor /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0001/HID-SENSOR-200041.2.auto/iio:device0/scan_elements/in_intensity_both_en
** (process:16437): DEBUG: Got type for in_intensity_both: is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Built channel array for in_intensity_both: index: 0, is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Found associated trigger at /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200083.13.auto/trigger4
** (process:16437): DEBUG: Already enabled sensor /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200083.13.auto/iio:device4/scan_elements/in_magn_z_en
** (process:16437): DEBUG: Already enabled sensor /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200083.13.auto/iio:device4/scan_elements/in_magn_y_en
** (process:16437): DEBUG: Already enabled sensor /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200083.13.auto/iio:device4/scan_elements/in_rot_from_north_magnetic_tilt_comp_en
** (process:16437): DEBUG: Already enabled sensor /sys/devices/pci0000:00/0000:00:13.0/{33AECD58-B679-4E54-9BD9-A04D34F0C226}/001F:8086:22D8.0002/HID-SENSOR-200083.13.auto/iio:device4/scan_elements/in_magn_x_en
** (process:16437): DEBUG: Got type for in_magn_z: is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Got type for in_magn_y: is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Got type for in_rot_from_north_magnetic_tilt_comp: is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Got type for in_magn_x: is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Built channel array for in_magn_x: index: 0, is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Built channel array for in_magn_y: index: 1, is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Built channel array for in_magn_z: index: 2, is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Built channel array for in_rot_from_north_magnetic_tilt_comp: index: 3, is signed: 1, bytes: 4, bits_used: 32, shift: 0, mask: 0x0, be: 0
** (process:16437): DEBUG: Handling driver refcounting method 'ClaimLight' for ambient light sensor device
** (process:16437): DEBUG: Handling driver refcounting method 'ClaimAccelerometer' for accelerometer device
** (process:16437): DEBUG: Handling driver refcounting method 'ClaimAccelerometer' for accelerometer device
** (process:16437): DEBUG: No new data available on 'iio:device0'
** (process:16437): DEBUG: No new data available on 'iio:device3'
** (process:16437): DEBUG: No new data available on 'iio:device0'

And the strange thing is that in_accel_x_raw outputs values and rotates the screen when read:

cat /sys/devices/pci0000:00/0000:00:13.0/\{33AECD58-B679-4E54-9BD9-A04D34F0C226\}/001F:8086:22D8.0002/HID-SENSOR-200073.10.auto/iio:device3/in_accel_x_raw

But it looks like the iio:device3 buffer doesn't contain any data. I added an extra log line to drv-iio-buffer-accel.c which writes:

Read from /dev/iio:device3: alloc buf: 1524, try read: 1524, read: -1

Any idea what is wrong?

detached commented 7 years ago

The content of the buffer directory of the device is

cat ./buffer/enable
1

cat ./buffer/length
128

cat ./buffer/watermark
1

And the scan_elements:

cat ./scan_elements/in_accel_x_en
1
cat ./scan_elements/in_accel_x_index
0
cat ./scan_elements/in_accel_x_type
le:s32/32>>0
cat ./scan_elements/in_accel_y_en
1
cat ./scan_elements/in_accel_y_index
1
cat ./scan_elements/in_accel_y_type
le:s32/32>>0
cat ./scan_elements/in_accel_z_en
1
cat ./scan_elements/in_accel_z_index
2
cat ./scan_elements/in_accel_z_type
le:s32/32>>0
detached commented 7 years ago

It looks like this is a bug of the hid-sensor-hub that doesn't setup the sensor well.

detached commented 7 years ago

Works now with Kernel 4.11.3-200.fc25.x86_64