Libhybris Let You Use Android Drivers & HW Libraries in Linux

One of the main issues with Linux on ARM is the lack of proper GPU drivers for the platform, as most silicon manufacturers now only focus on Android drivers which are not compatible with the Linux kernel, because Android is based on Bionic C library, whereas Linux is based on glibc or its variants. There are two ways to solve this issue:

  • Open Source GPU drivers. This would be the ideal solution, as you would just be able to cross-compile the drivers for the proper, as well as fix bugs without having to ask the silicon manufacturer to fix the driver for you.
  • Bionic to Glibc library. Such library acts like libdl, and allows to load Bionic library and overrides some symbols from bionic with glibc based ones. This is exactly what libhybris does.

Ubuntu Touch is capable of using Android GPU drivers to run Ubuntu thanks to this library, and Libhybris will provides the interface between the HAL and Mir display server for Ubuntu 14.04.

Libhybris is released under an Apache 2.0 license, and the source code, written in C, is available in github. This library is based on the initial work of .

There are 3 main directories in the source tree:

  • compat
    • ui – Some wrapper for Android UI.
  • hybris
    • common –  Common parts, including parsing /system/build.prop and matching common C functions (e.g. pthread*, str*…) between Bionic and glibc
    • egl – EGL support
    • gles2 – OpenGL ES 2 support
    • hardware – Loads /system/lib/libhardware.so
    • tests – Test programs for egl, gles2, lights, sensors, offscreen rendering, and ui
    • ui – Loads /system/lib/libui_compat_layer.so and creates bindings for the related functions.
  • utils –  Contains load_sym_files.py utility that loads symbol files for debugging.

Libhybris not only let you access the GPU, but also other hardware such as lights and sensors. I assume, but I may be wrong, that it could also be used with Wi-Fi and Bluetooth closed source drivers. Hopefully, work can also be done for VPU (Video Processing Unit) support in order to take advantage of hardware video decoding and encoding in Linux with Android libs, but I’m not knowledgeable enough to know if it’s feasible or not.

Using Libhybris is not an optimal solution, as there may be a small performance degradation, and you’ll be using the Android kernel, so many of the things you’d got used to with the Linux kernel won’t be available, and you’ll have to use the “Android” way. The implementation is not straightforward either, as Canonical’s Ubuntu Touch preview makes use of SurfaceFlinger which means applications relying on X11, GTK… will not work at the beginning, and you’ll have to wait until 2014 and and implementation with Mir display server to get a full solution based on libhybris with X11 compatibility. Nevertheless, even though libhybris is not a perfect solution, it’s a practical one, as it’s a technical solution, and not one which relies on convincing management and lawyers to release open source drivers.

There’s also some work on reverse-engineered open source GPU drivers such as the lima project, and some companies, e.g. Freescale / Vivante, release proper (closed-source) drivers for ARM Linux, but the company with the highest market share, namely Imagination Technologies, does not participate in any of those initiatives, and libhybris could become the way of the future, so most people may end-up using Android kernels on their ARM “Linux” distribution. Comments are welcome!

Share this:
FacebookTwitterHacker NewsSlashdotRedditLinkedInPinterestFlipboardMeWeLineEmailShare

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard

8 Replies to “Libhybris Let You Use Android Drivers & HW Libraries in Linux”

  1. @Sander
    I guess it’s a little different as you’d use the Android kernel + drivers + libraries related to hardware, and the rootfs can keep using glibc thanks to this library.

    For example, you can look at the diagram in http://www.cnx-software.com/2013/03/05/future-versions-of-ubuntu-to-feature-mir-display-server-compatible-with-android-graphics-drivers/. It shows the Android part (Kernel + HAL), and libhybris being the interface between “Android space” and “Ubuntu space”.

  2. @Sander nah..NDISwrapper is something at more upper level..
    it does not modify *anything* at the source code level rather it just acts as an “interface”.

    On the other hand Libhybris is actually modifying compile time flags and some more stuff..in order to make android driver’s source “compatible” to be run on linux.

  3. Yep, it’s pretty much like NDISwrapper in idea, so one may only wonder why it took so long to come up with it, and why it’s still so little known in the community. And there’s of course no need to wait for 14.04, just go port http://en.wikipedia.org/wiki/KDrive to run against libhybris (because full X.org is bloat) and enjoy your X.

    Also, “Android” kernel doesn’t differ much from “Linux” kernel, not more than kernel of one Linux distro differs from another. Most things possible on “Linux” kernel certainly possible on “Android” kernel.

Leave a Reply

Your email address will not be published. Required fields are marked *

Khadas VIM4 SBC
Khadas VIM4 SBC