*

Android: Enabling mainline graphics

Robert Foss avatar

Posted on 29/03/2017 by Robert Foss

Share this post:

Android uses the HWC API to communicate with graphics hardware. This API is not supported on the mainline Linux graphics stack, but by using drm_hwcomposer as a shim it now is.

The HWC (Hardware Composer) API is used by SurfaceFlinger for compositing layers to the screen. The HWC abstracts objects such as overlays and 2D blitters and helps offload some work that would normally be done with OpenGL. SurfaceFlinger on the other hand accepts buffers from multiple sources, composites them, and sends them to the display.

Figure 1. The traditional Android graphics stack.


This is where drm_hwcomposer comes into play. Since the mainline kernel graphics stack doesn't offer the HWC API, drm_hwcomposer is introduced to interface with the mainline graphics stack through mesa and libdrm. Before this work drm_hwcomposer only offered the HWC1 API. Since Android 7.0 version 2 of the HWC API is used by SurfaceFlinger. HWC2 differs in a few ways from the previous version, for example the semantics of fence support were changed and the GPU can now be used as a fallback when compositing layers. Up until recently the mainline kernel lacked the fence primitive offered by Android used in HWC1 and HWC2.

But after my fellow Collaboran Gustavo Padovan's work on adding fence support to the mainline kernel was upstreamed in v4.10, the mainline kernel now has fence support equivalent to that of Android. The new fence support enabled work on drm_hwcomposer to add HWC2 support. And with it we are now able to boot Android on the db410c running the freedreno driver. But in theory it should work on any mainline kernel graphics stack enabled GPU. Currently the work is being upstreamed to the ChromiumOS repo which is the official upstream for drm_hwcomposer. A number of projects have seen contributions in order to enable this work:

  • kernel - sync_file, in-fence and out-fence support added.
  • libdrm - fence support added.
  • mesa - support for passing fences added.
  • intel-gpu-tools - sync and fence tests added.
  • drm_hwcomposer - HWC2 and fence support added.


Thanks

This drm_hwcomposer work is part of long-standing collaboration between Google's ChromeOS team and Collabora.

 

Original post

Comments (4)

  1. John :
    Mar 30, 2017 at 11:16 AM

    What are mainline graphics?

    What sort of real-world example would take advantage of this feature?

    E.G. do mainline graphics enable Android to use a Linux window manager/desktop?

    Thanks...

    Reply to this comment

    Reply to this comment

    1. Robert Foss:
      Mar 30, 2017 at 05:20 PM

      Mainline graphics refers to the open source graphics stack (open source driver/mesa/libdrm etc).

      A real-world example is running Android on the Raspberry Pi using the normal open source drivers.

      No, this wouldnt allow you to allow you to run a regular Linux window manager/desktop on Android,
      but that should already be possible theoretically. Practically it surely would be a lot of work.

      Reply to this comment

      Reply to this comment

  2. Jayaraj Chanku:
    Mar 16, 2018 at 03:54 PM

    Hi Robert,
    Amazing information. After this read only I came to know that enabling the the open source graphics stack is this much easy and thanks for sharing this post.

    Reply to this comment

    Reply to this comment

    1. Robert Foss:
      Mar 20, 2018 at 02:45 PM

      Hey Jayaraj,

      I'm glad this is useful to people, thanks for the feedback :)


      Rob.

      Reply to this comment

      Reply to this comment


Add a Comment






Allowed tags: <b><i><br>Add a new comment:


Latest Blog Posts

Quick hack: Speed up your GitLab CI

06/11/2018

Did you know you could register your own PC, or a spare laptop collecting dust in a drawer, to get instant CI going on GitLab? Not only…

Introducing Zink, an OpenGL implementation on top of Vulkan

31/10/2018

For the last month or so, I've been playing with a new project during my work at Collabora, and as I've already briefly talked about at…

On the low adoption of automated testing in FOSS

18/10/2018

For projects of any value and significance, having a comprehensive automated test suite is nowadays considered a standard software engineering…

Recently in Geoclue

12/10/2018

After I started working for Collabora in April, I've finally been able to put some time on maintenance and development of Geoclue again.…

The beauty of Open Source

10/10/2018

Like all software, Open Source software isn't without it's bugs and issues. However, thanks to the nature of Open Source, resolving or mitigating…

MicroDebConf Brasilia

02/10/2018

Last month, the first "MicroDebConf" took place at the Gama campus of the University of Brasilia. Here's a look at how this one day event…

Open Since 2005 logo

We use cookies on this website to ensure that you get the best experience. By continuing to use this website you are consenting to the use of these cookies. To find out more please follow this link.

Collabora Ltd © 2005-2018. All rights reserved. Website sitemap.