HowTo correct the screen orientation detection issue with Chuwi HI13 on Linux – Fedora 26

When installing Fedora 26 on my Chuwi Hi13, automatic screen rotation was properly working in Gnome but screen is always inverted (ie bottom up when in normal position).
This behaviour is related to the accelerometer orientation which is not mounted as the screen

In order to correct the behaviour, I create a updated ACCEL_MOUNT_MATRIX (Reference)

  1. Go to /usr/lib/udev/hwdb.d
  2. Create, as root, a « 61-sensor-local.hwdb » file
  3. Edit, as root, « 61-sensor-local.hwdb » with
     ACCEL_MOUNT_MATRIX=1, 0, 0; 0, -1, 0; 0, 0, 1

    KIOX000A is the driver. I retrieved this information querying udev for iio device

    [as root]
    udevadm info -n  /dev/iio\:device0 
    P: /devices/pci0000:00/0000:00:17.0/i2c_designware.4/i2c-9/i2c-KIOX000Ad:00/iio:
    N: iio:device0
    E: DEVNAME=/dev/iio:device0
    E: DEVPATH=/devices/pci0000:00/0000:00:17.0/i2c_designware.4/i2c-9/i2c-KIOX000A:
    E: DEVTYPE=iio_device
    E: IIO_SENSOR_PROXY_TYPE=iio-buffer-accel
    E: MAJOR=243
    E: MINOR=0
    E: SUBSYSTEM=iio
    E: SYSTEMD_WANTS=iio-sensor-proxy.service
    E: TAGS=:systemd:

    DMI define the product to which the ACCEL_MOUNT_MATRIX apply. Based on dmidecode return, the system vendor name (svn) start with « Chuwi » and the product name (pn) is Hi13

    [as root] 
    Handle 0x0001, DMI type 1, 27 bytes
    System Information
    	Manufacturer: Chuwi Co. Ltd.
    	Product Name: Hi13
    	Version: Default string
    	Serial Number: To Be Filled By O.E.M
    	UUID: 03000200-0400-0500-0006-000700080009
    	Wake-up Type: Power Switch
    	SKU Number: 0001
    	Family: Tablet
  4. Update udev hardware database (located in /etc/udev/hwdb.bin)
    [as root]
    systemd-hwdb update
  5. Verify that the ACCEL_MOUNT_MATRIX is properly taken into account
    [as root]
    udevadm trigger
    udevadm info -export-db | grep ACCEL

    The latest command should provide an entry with the ACCEL_MOUNT_MATRIX:

    E: ACCEL_MOUNT_MATRIX=1, 0, 0; 0, -1, 0; 0, 0, 1
  6. Reboot for the kernel to read the newly updated hwdb.bin and enjoy proper screen rotation!