Automatic screen rotation
#11
Thanks for posting this. Works great!
  Reply
#12
The command given previously, `sudo pacman -S iio-sensor-proxy` worked for me too. I did have to go into settings, display configuration and uncheck "only in tablet mode". If I kept that option checked, the screen was stuck in vertical mode but now it follows its orientation. Nice!
  Reply
#13
Screen rotation stopped working after recent upgrade. Running Arch Wayland:
Code:
$ uname -a

Linux pinetab2 6.6.13-danctnix1-1-pinetab2 #1 SMP PREEMPT_DYNAMIC Mon, 22 Jan 2024 11:53:08 +0000 aarch64 GNU/Linux

I tried to add a custom mount matrix to fix the problem, but I am not able to get any matrix to be applied. Here's what I did:

1) Install:
Code:
$ sudo pacman -S iio-sensor-proxy

2) Settings -> Display & Monitor: Orientation: "automatic" and "only when in tablet mode" selected (if these settings don't appear immediately, click to another settings panel, then back to "Display & Monitor")

3) Ensure that PineTab2 is attached to keyboard case

4) This command sometimes causes touchpad on case to become unresponsive; restart required: 
Code:
$ monitor-sensor --accel

    Waiting for iio-sensor-proxy to appear
+++ iio-sensor-proxy appeared
=== Has accelerometer (orientation: right-up)

5) remove PinTab2 from case, rotate 90 counter-clockwise (screen top switches from device's right edge to device's left edge)
Code:
    Accelerometer orientation changed: bottom-up

6) rotate 90 clockwise (screen top switches from device's left edge to device's bottom edge)
Code:
    Accelerometer orientation changed: right-up [or "normal"]

7) Ctrl-C to quit. Return PineTab2 to case (screen top switches back to device's right edge). Get device info (note lack of mount matrix entry):
Code:
$ udevadm info -n /dev/iio:device1

P: /devices/platform/fe5e0000.i2c/i2c-5/5-0018/iio:device1
M: iio:device1
R: 1
U: iio
T: iio_device
D: c 252:1
N: iio:device1
L: 0
E: DEVPATH=/devices/platform/fe5e0000.i2c/i2c-5/5-0018/iio:device1
E: DEVNAME=/dev/iio:device1
E: DEVTYPE=iio_device
E: OF_NAME=accelerometer
E: OF_FULLNAME=/i2c@fe5e0000/accelerometer@18
E: OF_COMPATIBLE_0=silan,sc7a20
E: OF_COMPATIBLE_N=1
E: MAJOR=252
E: MINOR=1
E: SUBSYSTEM=iio
E: USEC_INITIALIZED=9020319
E: IIO_SENSOR_PROXY_TYPE=iio-poll-accel iio-buffer-accel
E: SYSTEMD_WANTS=iio-sensor-proxy.service
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

8) Get current mount matrix:
Code:
$ cat /sys/devices/platform/fe5e0000.i2c/i2c-5/5-0018/iio:device1/mount_matrix

1, 0, 0; 0, 0, 1; 0, 1, 0

9) Add custom mount matrix:
Code:
$ sudo nano /etc/udev/hwdb.d/61-sensor-local.hwdb

# /etc/udev/hwdb.d/61-sensor-local.hwdb
sensor:modalias:*sc7a20:*
  ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1
# above matrix might not be correct rotation matrix: just testing

10) Update hwdb:
Code:
$ sudo systemd-hwdb update

11) Register trigger:
Code:
$ sudo udevadm trigger -v -p DEVNAME=/dev/iio:device1

/sys/devices/platform/fe5e0000.i2c/i2c-5/5-0018/iio:device1

12) Get device info (note: shows new mount matrix):
Code:
$ udevadm info -n /dev/iio:device1

P: /devices/platform/fe5e0000.i2c/i2c-5/5-0018/iio:device1
M: iio:device1
R: 1
U: iio
T: iio_device
D: c 252:1
N: iio:device1
L: 0
E: DEVPATH=/devices/platform/fe5e0000.i2c/i2c-5/5-0018/iio:device1
E: DEVNAME=/dev/iio:device1
E: DEVTYPE=iio_device
E: OF_NAME=accelerometer
E: OF_FULLNAME=/i2c@fe5e0000/accelerometer@18
E: OF_COMPATIBLE_0=silan,sc7a20
E: OF_COMPATIBLE_N=1
E: MAJOR=252
E: MINOR=1
E: SUBSYSTEM=iio
E: USEC_INITIALIZED=9020319
E: ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1
E: IIO_SENSOR_PROXY_TYPE=iio-poll-accel iio-buffer-accel
E: SYSTEMD_WANTS=iio-sensor-proxy.service
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

13) Repeat sensor test above:
Code:
$ monitor-sensor --accel

[Same result]

14) Repeat get current mount matrix:
Code:
$ cat /sys/devices/platform/fe5e0000.i2c/i2c-5/5-0018/iio:device1/mount_matrix

[Same result]

15) Journal shows nothing unless reboot with new settings:
Code:
$ journalctl --since=today | grep iio

pinetab2 kernel: iio iio:device1: interrupts on the falling edge or active low level
pinetab2 iio-sensor-prox[3129]: Could not find trigger name associated with /sys/devices/platform/fe5e0000.i2c/i2c-5/5-0018/iio:device1

I wasn't able to find any relevant leads by searching for terms from these journal entries.

Any suggestions?
  Reply
#14
I re-raise the question: Any suggestions?
  Reply
#15
I finally did an OS update today. After the last update rotation quit working for me. After this update, it was still broken.

(Unrelated: with the current update, I can shutdown the device with wifi on! Still seems to hang when it tries to sleep with wifi on, though.)

I went through the motions of the original fix:

1. sudo pacman -S iio-sensor-proxy #[was already installed]
2. create /etc/udev/hwdb.d/60-sensor.hwdb

sensor:modalias:*
ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1

3. Setting -> Display Configuration: Orientation = Automatic; Uncheck "Only when in tablet mode"

After a reboot, rotation seems to be mostly working.

"Mostly" because I can have it in a horizontal orientation, but if I lay the screen back too far (e.g., resting it against a pillow on the couch), it will change back to vertical orientation. I don't know if more tweaking of the matrix would help with this. But I can deal with it for now.
  Reply
#16
(04-10-2024, 06:37 AM)frtodd Wrote: I finally did an OS update today. After the last update rotation quit working for me. After this update, it was still broken.

(Unrelated: with the current update, I can shutdown the device with wifi on! Still seems to hang when it tries to sleep with wifi on, though.)

I went through the motions of the original fix:

1. sudo pacman -S iio-sensor-proxy #[was already installed]
2. create /etc/udev/hwdb.d/60-sensor.hwdb

sensor:modalias:*
  ACCEL_MOUNT_MATRIX=0, 1, 0; 1, 0, 0; 0, 0, 1

3. Setting -> Display Configuration: Orientation = Automatic; Uncheck "Only when in tablet mode"

After a reboot, rotation seems to be mostly working.

"Mostly" because I can have it in a horizontal orientation, but if I lay the screen back too far (e.g., resting it against a pillow on the couch), it will change back to vertical orientation. I don't know if more tweaking of the matrix would help with this. But I can deal with it for now.
This is interesting, it changed nothing at my side. The display is always rotated 90 degrees clockwise (but rotation itself works).
  Reply
#17
So I am definitely no expert.

But if rotation is working, just off by some value, that seems like a great sign.

My assumption is those matrix numbers are used to modify how the screen should be drawn relative to the rotation sensor. I wonder if it's possible if the rotation sensor could be oriented differently in different device and require different values in that matrix. 

If rotation is working, I'd be tempted to move those 1's around in the matrix (assuming one "1" per three digit set) to see if it changes things.

Good luck!

(ed: grammar)
  Reply
#18
This matrix is a permutation matrix. Like an identity matrix, but with some rows/columns permuted. Every row and every column should contain exactly one 1, all other entries should be 0. You can try all possible permutations, for a 3×3 matrix, there are 3!=1*2*3=6 possible permutations.

I believe that the mount matrix, in addition to such a permutation, can also apply mirroring, where you replace one or more of the 1 entries by -1.
  Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  PineTab 2 login screen rotation fix chzbacon 11 4,170 03-17-2024, 04:53 PM
Last Post: mtomaschett
  Ubuntu touch rotation GloriousCoffee 3 1,260 01-09-2024, 06:01 AM
Last Post: polrus
  Low-level persistent display rotation diodelass 8 10,364 10-06-2020, 07:17 AM
Last Post: tophneal

Forum Jump:


Users browsing this thread: 1 Guest(s)