Skip to content

xiaomi-sm8450-kernel/manifest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Open Source Kernel for Xiaomi 12 and Xiaomi 12 Pro

The Xiaomi 12 and Xiaomi 12 Pro were released at the 31st December 2021. Fortunately Xiaomi has released the kernel sources with the release of the devices but unfortunately these released sources are incomplete. This Project aims at providing the missing sources and enables developers and enthusiats to get an easy start to compile a kernel for the Xiaomi 12 and/or Xiaomi 12 Pro.

How to build the kernel

  1. Intitalize your local repository using this manifest:
repo init -u https://github.com/xiaomi-sm8450-kernel/manifest.git -b zeus-s-oss
  1. Then to sync up:
repo sync
  1. Run the kernel build for your device. E.g for cupid:
./build.sh cupid
  1. Find the build artifacts in device/qcom/cupid-kernel/. This includes the kernel (Image), the kernel modules, dtb and dtbo, kernel headers and some host utilities.

What is missing in the official sources?

The official kernel sources insist of the following repositories:

  • Xiaomi_Kernel_Opensource This repository contains xiaomis fork of the msm-kernel and the camera-kernel and display-drivers techpack repositories.
  • vendor_qcom_opensource_audio-kernel This repository contains xiaomis fork of the qualcomm audio-kernel-ar repository.
  • vendor_qcom_opensource_wlan This repository contains xiaomis forks of the qualcomm qcacld-3.0, qca-wifi-host-cmn, fw-api and sigma-dut repositories.
  • kernel_devicetree This repository contains xiaomis forks of the proprietary qualcomm devicetree, camera-devicetree and display-devicetree.

Starting with the msm-kernel xiaomi has added their own hwid driver, which is used in kernel to differentiate between different xiaomi devices, to the .gitingore file in the repository and hence the whole source code of this driver is missing. reference Xiaomi is using an own driver for their touchfeature implementation and they are using a custom fts_spi kernel driver for the touchscreen but the inclusion of these drivers is commented. This indicates that xiaomi has moved these drivers to an external repository which they did not provide the source for. Both drivers source code is present in the kernel tree (although it's not being used due to the commented out inclusion) but unfortunately it is not the source being used on MIUI releases. The xiaomi touch driver on the oldest miui i could find is already significantly ahead of the public drivers state (E.g. /sys/devices/virtual/touch/touch_dev/fod_press_status is provided by the xiaomi touch driver on MIUI but the public driver does not provide a similar functionality). The FTS touchscreen driver is also behind the one shipped on MIUI and some basic functionality is broken (E.g. double tap to wake is broken). reference

Xiaomi does not provide the source code of many used qualcomm external kernel module repositories. Namely these are: mmrm-driver, mmrm-driver-test, video-driver, video-driver-test, cvp-kernel, dataipa, eva-kernel, touch-drivers, datarmnet and datarmnet-ext. These repositories might not have been changed by xiaomi but since their kernel is based on a pre-public caf tag one has to guess the used revision of all these repositories.

Xiaomi does not provide the source code of the following kernel modules which are not publicised by qualcomm: binder_prio.ko, sla.ko. It does not seem like they have a meaningful function.

Xiaomis proviced devicetree is incomplete and does not work because it misses the video, mmrm and audio devicetree techpacks. These techpack devicetrees are not publicised by qualcomm which makes it harder to get this working.

Fixes for the mentioned issues

The hwid driver

Xiaomi has used a similar hwid driver on older device generations already, so it was possible to import an older driver and update the defines of the internal codenames for Xiaomi 12 and Xiaomi 12 Pro. commit

The touchscreen drivers

The public fts and xiaomi touch drivers can be used and the basic functionality (E.g. touchscreen input) works fine. However double tap to wake and the under display fingerprint sensor do not work on MIUI with these drivers. The under display fingerprint sensor can be fixed with a custom implementation on custom ROMs or extensive reversing of the MIUI module. The issue with double tap to wake is that the touchscreen driver probes before the panel driver and hence fts_ts_check_panel fails to provide the active panel. As a result of this the drm notifier doesn't register and the touchscreen driver does not get to know about screen on/off events. That results in the touchscreen staying in the regular state and hence not registering gestures. To avoid this the probe of the touchscreen driver can be deferred until the panel is okay. To do so it is enough to uncomment this line. Xiaomi seems to have fixed that in a different way since their driver seems to probe later generally and doesn't fail the probe a few times until the panel driver is up like it does when deferring the probe like mentioned above.

The missing external kernel module repositories

As mentioned above xiaomi might not have touched these modules so i was able to guess revisions of the modules and include the repositories from qualcomm and it seems to work fine.

The mysterious binder_prio and sla kernel modules

The system seems to run fine without them.

The missing devicetree techpacks

Fortunately ASUS has properly released these sources for their Snapdragon 8G1 devices (link) and i was able to use them as a base to apply xiaomis changes on top of. The video and mmrm devicetrees do not have any changes and i have reversed their audio devicetree changes for Xiaomi 12 and Xiaomi 12 Pro. commit

Other issues

On qualcomm 5.10 devices the devicetree is built from multiple techpack repositories as multiple dtb(o)s which will be merged later. Xiaomi has introduced the xiaomi,miboard-id property to mark split devicetrees which are (in)compatible to merge. The public qualcomm script to merge dtbs does not respect this property and merges incompatible split devicetrees together which results in a broken devictree. This can be fixed by respecting the miboard-id in the merge dts script. commit

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published