drm_hwcomposer: add scene flattening

Flattening of a scene is triggered if it doesn't change for a while.
As of now there is a separate thread which triggers flattening if the
scene did not change in last 60 vsyncs.

There are two options for flattening a scene:
* Serial, by using a writeback connector attached to the same crtc as
  the one driving the display. This happens only if possible_clones
  mask reports that the display encoder and writeback encoder could
  work simultaneously.
The steps for achieving this are:
1. Build a commit that enables writeback connector, we don't need to
   build a commit that contains the entire active_composition, just
   set the writeback specific properties a let the kernel duplicate
   the rest of the state.
2. Commit and wait for writeback_fence to fire.
3. Setup a composition with just one plane enabled.
4. Apply the composition if a new one has not been applied meanwhile.

* Concurrent, by comitting the scene to a new unused crtc (state !=
  DRM_MODE_CONNECTED) and getting the result back through a writeback
  connector.
The steps for achieving this are:
1. Copy layers from active composition.
2. Plan layers of copy on the unused crtc. This is realized by using a
   newly created DrmDisplayCompositor object.
3. Commit copy to the unsed crtc and get the result as a drmhwclayer.
4. Setup a composition with just one plane enabled. Re-importing the
   buffers might be needed since we might have been using a different
   dri node.
5. Apply the composition if a new one has not been applied while doing
   the flattening

Signed-off-by: Alexandru Gheorghe <alexandru-cosmin.gheorghe@arm.com>
9 files changed
tree: 87d19fd10c6b702a71ba086b1b7e62cabad32a6e
  1. tests/
  2. .clang-format
  3. .gitlab-ci.yml
  4. Android.mk
  5. autofd.h
  6. autolock.cpp
  7. autolock.h
  8. drmconnector.cpp
  9. drmconnector.h
  10. drmcrtc.cpp
  11. drmcrtc.h
  12. drmdevice.cpp
  13. drmdevice.h
  14. drmdisplaycomposition.cpp
  15. drmdisplaycomposition.h
  16. drmdisplaycompositor.cpp
  17. drmdisplaycompositor.h
  18. drmencoder.cpp
  19. drmencoder.h
  20. drmeventlistener.cpp
  21. drmeventlistener.h
  22. drmframebuffer.h
  23. drmhwcgralloc.h
  24. drmhwcomposer.h
  25. drmhwctwo.cpp
  26. drmhwctwo.h
  27. drmmode.cpp
  28. drmmode.h
  29. drmplane.cpp
  30. drmplane.h
  31. drmproperty.cpp
  32. drmproperty.h
  33. hwcutils.cpp
  34. MODULE_LICENSE_APACHE2
  35. NOTICE
  36. platform.cpp
  37. platform.h
  38. platformdrmgeneric.cpp
  39. platformdrmgeneric.h
  40. platformhisi.cpp
  41. platformhisi.h
  42. platformminigbm.cpp
  43. platformminigbm.h
  44. README.md
  45. resourcemanager.cpp
  46. resourcemanager.h
  47. vsyncworker.cpp
  48. vsyncworker.h
  49. worker.cpp
  50. worker.h
README.md

drm_hwcomposer

Patches to drm_hwcomposer are very much welcome, we really want this to be the universal HW composer implementation for Android and similar platforms So please bring on porting patches, bugfixes, improvements for documentation and new features.

A short list of contribution guidelines:

  • Submit changes via gitlab merge requests on gitlab.freedesktop.org

  • drm_hwcomposer is Apache 2.0 Licensed and we require contributions to follow the developer's certificate of origin: http://developercertificate.org/

  • When submitting new code please follow the naming conventions documented in the generated documentation. Also please make full use of all the helpers and convenience macros provided by drm_hwcomposer. The below command can help you with formatting of your patches:

    `git diff | clang-format-diff-3.5 -p 1 -style=file`
    
  • Hardware specific changes should be tested on relevant platforms before committing.

If you need inspiration, please checkout our TODO issues

Happy hacking!