[libcamera-devel,v2,0/4] android: switch over to modern gralloc API via libui
mbox series

Message ID 20230912-gralloc-api-v4-v2-0-e859da63f98c@baylibre.com
Headers show
Series
  • android: switch over to modern gralloc API via libui
Related show

Message

Mattijs Korpershoek Sept. 12, 2023, 2:15 p.m. UTC
gralloc.h is a very old API that has been deprecated at least since
Android P (9).

Devices are encouraged to switch over to HIDL interface named
android.hardware.graphics.allocator@<VERSION>, where <VERSION> can be
2.0 ,3.0 or 4.0.

This is mandatory since Android Q (10) [1]

Fortunately, Android provides an abstraction on top of
android.hardware.graphics.allocator which is compatible with each
version.
This abstraction is implemented in libui, which is available in the
VNDK.

Import all necessary headers from AOSP and switch over the
generic_frame_buffer_allocator to use GraphicBufferAllocator.

This series has been build-tested on a linux host and functionally
tested on an AM62x SK EVM with Android 13. (preview and capture).

[1] https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/main/compatibility_matrices/compatibility_matrix.4.xml#195

Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
---
Changes in v2:
- Dropped additional ; in graphic_buffer_allocator_stub.cpp. (Kieran)
- Surrounded problematic includes with #pragma to avoid clang compile
  errors related to -Wextra-semi. (Kieran)
- Link to v1: https://lists.libcamera.org/pipermail/libcamera-devel/2023-September/038927.html

Tested on linux with:
CC=clang CXX=clang++ meson setup build -Dandroid=enabled -Dandroid_platform=generic
ninja -C build
And clang version clang++ (clang 16.0.6 "clang version 16.0.6 (Fedora 16.0.6-2.fc38)")

---
Mattijs Korpershoek (4):
      android: Import libutils/libui headers from vndk v33
      android: Import GraphicBufferAllocator header from vndk v33
      android: Stub GraphicBufferAllocator for build tests
      android: mm: generic: Use GraphicBufferAllocator instead of gralloc.h

 .../libs/ui/include/ui/GraphicBufferAllocator.h    |  81 ++++++++
 .../native/libs/ui/include/ui/PixelFormat.h        |  75 +++++++
 include/android/meson.build                        |   2 +
 .../system/core/libutils/include/utils/Compat.h    |  94 +++++++++
 .../system/core/libutils/include/utils/Errors.h    |  78 ++++++++
 .../system/core/libutils/include/utils/Mutex.h     | 219 +++++++++++++++++++++
 .../system/core/libutils/include/utils/Singleton.h | 102 ++++++++++
 .../system/core/libutils/include/utils/Timers.h    | 103 ++++++++++
 src/android/mm/generic_frame_buffer_allocator.cpp  |  61 ++----
 src/android/mm/graphic_buffer_allocator_stub.cpp   |  53 +++++
 src/android/mm/libhardware_stub.c                  |  17 --
 src/android/mm/meson.build                         |   9 +-
 12 files changed, 831 insertions(+), 63 deletions(-)
---
base-commit: 58e501c71c47e57f02afde1bd296a037038cd6d5
change-id: 20230824-gralloc-api-v4-e3388fd364c6

Best regards,