*

Android: Enabling mainline graphics

Posted on 29/03/2017 by Robert Foss

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 (2)

  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


Add a Comment





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


Latest Blog Posts

ipcpipeline: Splitting a GStreamer pipeline into multiple processes

17/11/2017

Earlier this year I worked on a certain GStreamer plugin that is called “ipcpipeline”. This plugin provides elements that make it possible…

Quick hack: Experiments with crosvm

09/11/2017

Running crosvm outside Chromium OS is quite easy, with the only complication being that minijail isn't widely packaged in distros. In these…

Tracing memory leaks in the NFC Digital Protocol stack

06/11/2017

Kmemleak allows you to track possible memory leaks inside the Linux kernel. Basically, it tracks dynamically allocated memory blocks in…

Who knew we still had low-hanging fruit?

17/10/2017

Earlier this month I had the pleasure of attending the Web Engines Hackfest, hosted by Igalia at their offices in A Coruña, and also sponsored…

Performance analysis in Linux (continued)

06/10/2017

In this post, I will show one more example of how easy it is to disrupt performance of a modern CPU, and also run a quick discussion on…

XDC 2017 - Links to recorded presentations (videos)

23/09/2017

Many thanks to Google for recording all the XDC2017 talks. To make them easier to watch, here are direct links to each talk recorded at…

Open Since 2005

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-2017. All rights reserved. Website sitemap.