[{"id":27843,"web_url":"https://patchwork.libcamera.org/comment/27843/","msgid":"<zym5ds4llnmpt3kuzrbghdlh6anfbjicn6a4c2uroyzpo2hkgr@mlnmufyqolgp>","date":"2023-09-22T09:27:02","subject":"Re: [libcamera-devel] [PATCH v2 4/4] android: mm: generic: Use\n\tGraphicBufferAllocator instead of gralloc.h","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/people/143/","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"content":"HI Mattijs\n\n nice work!\n\nOn Tue, Sep 12, 2023 at 04:15:23PM +0200, Mattijs Korpershoek via libcamera-devel wrote:\n> gralloc.h is a very old API that has been deprecated at least since\n> Android P (9).\n>\n> Switch over to a higher level abstraction of gralloc from libui, which\n> is compatible with Android 11 and up.\n> Libui:\n> * is provided in the VNDK (so it's available to vendors).\n> * is also used in the camera vts test named VtsAidlHalCameraProvider_TargetTest.\n>\n> Drop the libhardware stub since we no longer need it.\n>\n> Notes:\n> * GraphicsBufferAllocator being a Singleton, buffer lifecycle\n>   management is easier.\n> * The imported headers from Android generate the -Wextra-semi warning.\n>   To avoid patching the files, a pragma has been added before inclusion.\n>\n> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n> ---\n>  src/android/mm/generic_frame_buffer_allocator.cpp | 61 ++++++++---------------\n>  src/android/mm/libhardware_stub.c                 | 17 -------\n>  src/android/mm/meson.build                        |  8 ++-\n>  3 files changed, 23 insertions(+), 63 deletions(-)\n>\n> diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp\n> index 7ecef2c669df..468579068c32 100644\n> --- a/src/android/mm/generic_frame_buffer_allocator.cpp\n> +++ b/src/android/mm/generic_frame_buffer_allocator.cpp\n> @@ -16,8 +16,11 @@\n>  #include \"libcamera/internal/framebuffer.h\"\n>\n>  #include <hardware/camera3.h>\n> -#include <hardware/gralloc.h>\n\nour version of include/android/system/core/include/system/camera.h\nstill includes gralloc.h. We should update all headers most probably\n\n> -#include <hardware/hardware.h>\n> +#pragma GCC diagnostic push\n> +#pragma GCC diagnostic ignored \"-Wextra-semi\"\n> +#include <ui/GraphicBufferAllocator.h>\n> +#pragma GCC diagnostic pop\n> +#include <utils/Errors.h>\n>\n>  #include \"../camera_device.h\"\n>  #include \"../frame_buffer_allocator.h\"\n> @@ -33,35 +36,28 @@ class GenericFrameBufferData : public FrameBuffer::Private\n>  \tLIBCAMERA_DECLARE_PUBLIC(FrameBuffer)\n>\n>  public:\n> -\tGenericFrameBufferData(struct alloc_device_t *allocDevice,\n> +\tGenericFrameBufferData(android::GraphicBufferAllocator &allocDevice,\n\nYou could\n\n        GenericFrameBufferData(buffer_handle_t handle,\n                               const std::vector<FrameBuffer::Plane> &planes)\n                : FrameBuffer::Private(planes),\n                  allocDevice_(android::GraphicBufferAllocator::get()),\n                  handle_(handle)\n\nInstead of passing it to the constructor of ::Private.\nIt does't make much different though, up to you!\n\n>  \t\t\t       buffer_handle_t handle,\n>  \t\t\t       const std::vector<FrameBuffer::Plane> &planes)\n>  \t\t: FrameBuffer::Private(planes), allocDevice_(allocDevice),\n>  \t\t  handle_(handle)\n>  \t{\n> -\t\tASSERT(allocDevice_);\n>  \t\tASSERT(handle_);\n>  \t}\n>\n>  \t~GenericFrameBufferData() override\n>  \t{\n>  \t\t/*\n> -\t\t * allocDevice_ is used to destroy handle_. allocDevice_ is\n> -\t\t * owned by PlatformFrameBufferAllocator::Private.\n> -\t\t * GenericFrameBufferData must be destroyed before it is\n> -\t\t * destroyed.\n> -\t\t *\n> -\t\t * \\todo Consider managing alloc_device_t with std::shared_ptr\n> -\t\t * if this is difficult to maintain.\n> -\t\t *\n\nnice!\n\n>  \t\t * \\todo Thread safety against alloc_device_t is not documented.\n>  \t\t * Is it no problem to call alloc/free in parallel?\n>  \t\t */\n> -\t\tallocDevice_->free(allocDevice_, handle_);\n> +\t\tandroid::status_t status = allocDevice_.free(handle_);\n\nOr you could even get the singleton instance here!\n\n> +\t\tif (status != android::NO_ERROR)\n> +\t\t\tLOG(HAL, Error) << \"Error freeing framebuffer: \" << status;\n>  \t}\n>\n>  private:\n> -\tstruct alloc_device_t *allocDevice_;\n> +\tandroid::GraphicBufferAllocator &allocDevice_;\n\nUsually reference class members are worrying to me, but this really\njust points to a system-wide component accessed via a singleton if i'm\nnot mistaken, so this should be fine!\n\n\n>  \tconst buffer_handle_t handle_;\n>  };\n>  } /* namespace */\n> @@ -73,50 +69,33 @@ class PlatformFrameBufferAllocator::Private : public Extensible::Private\n>  public:\n>  \tPrivate(CameraDevice *const cameraDevice)\n>  \t\t: cameraDevice_(cameraDevice),\n> -\t\t  hardwareModule_(nullptr),\n> -\t\t  allocDevice_(nullptr)\n> +\t\t  allocDevice_(android::GraphicBufferAllocator::get())\n>  \t{\n> -\t\thw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hardwareModule_);\n> -\t\tASSERT(hardwareModule_);\n>  \t}\n>\n> -\t~Private() override;\n> +\t~Private() = default;\n>\n>  \tstd::unique_ptr<HALFrameBuffer>\n>  \tallocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage);\n>\n>  private:\n>  \tconst CameraDevice *const cameraDevice_;\n> -\tconst struct hw_module_t *hardwareModule_;\n> -\tstruct alloc_device_t *allocDevice_;\n> +\tandroid::GraphicBufferAllocator &allocDevice_;\n>  };\n>\n> -PlatformFrameBufferAllocator::Private::~Private()\n> -{\n> -\tif (allocDevice_)\n> -\t\tgralloc_close(allocDevice_);\n> -\tdlclose(hardwareModule_->dso);\n> -}\n> -\n>  std::unique_ptr<HALFrameBuffer>\n>  PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,\n>  \t\t\t\t\t\tconst libcamera::Size &size,\n>  \t\t\t\t\t\tuint32_t usage)\n>  {\n> -\tif (!allocDevice_) {\n> -\t\tint ret = gralloc_open(hardwareModule_, &allocDevice_);\n> -\t\tif (ret) {\n> -\t\t\tLOG(HAL, Fatal) << \"gralloc_open() failed: \" << ret;\n> -\t\t\treturn nullptr;\n> -\t\t}\n> -\t}\n> -\n> -\tint stride = 0;\n> +\tuint32_t stride = 0;\n>  \tbuffer_handle_t handle = nullptr;\n> -\tint ret = allocDevice_->alloc(allocDevice_, size.width, size.height,\n> -\t\t\t\t      halPixelFormat, usage, &handle, &stride);\n> -\tif (ret) {\n> -\t\tLOG(HAL, Error) << \"failed buffer allocation: \" << ret;\n> +\n> +\tandroid::status_t status = allocDevice_.allocate(size.width, size.height, halPixelFormat,\n> +\t\t\t\t\t\t\t 1 /*layerCount*/, usage, &handle, &stride,\n> +\t\t\t\t\t\t\t \"libcameraHAL\");\n> +\tif (status != android::NO_ERROR) {\n> +\t\tLOG(HAL, Error) << \"failed buffer allocation: \" << status;\n>  \t\treturn nullptr;\n>  \t}\n>  \tif (!handle) {\n> diff --git a/src/android/mm/libhardware_stub.c b/src/android/mm/libhardware_stub.c\n> deleted file mode 100644\n> index 00f15cd90cac..000000000000\n> --- a/src/android/mm/libhardware_stub.c\n> +++ /dev/null\n> @@ -1,17 +0,0 @@\n> -/* SPDX-License-Identifier: Apache-2.0 */\n> -/*\n> - * Copyright (C) 2023, Ideas on Board\n> - *\n> - * libhardware_stub.c - Android libhardware stub for test compilation\n> - */\n> -\n> -#include <errno.h>\n> -\n> -#include <hardware/hardware.h>\n> -\n> -int hw_get_module(const char *id __attribute__((__unused__)),\n> -\t\t  const struct hw_module_t **module)\n> -{\n> -\t*module = NULL;\n> -\treturn -ENOTSUP;\n> -}\n> diff --git a/src/android/mm/meson.build b/src/android/mm/meson.build\n> index e9ceb3afba67..203b8c3e5804 100644\n> --- a/src/android/mm/meson.build\n> +++ b/src/android/mm/meson.build\n> @@ -4,13 +4,11 @@ platform = get_option('android_platform')\n>  if platform == 'generic'\n>      android_hal_sources += files(['generic_camera_buffer.cpp',\n>                                    'generic_frame_buffer_allocator.cpp'])\n> -    android_deps += [libdl]\n\nlibdl was used for ?\n\n>\n> -    libhardware = dependency('libhardware', required : false)\n> -    if libhardware.found()\n> -        android_deps += [libhardware]\n> +    libui = dependency('libui', required : false)\n> +    if libui.found()\n> +        android_deps += [libui]\n>      else\n> -        android_hal_sources += files(['libhardware_stub.c'])\n>          android_hal_sources += files(['graphic_buffer_allocator_stub.cpp'])\n>      endif\n>  elif platform == 'cros'\n\nAll nits\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n\nThanks\n  j\n\n>\n> --\n> 2.41.0\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 7CF18C326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 22 Sep 2023 09:27:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id F207E62944;\n\tFri, 22 Sep 2023 11:27:06 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7273662916\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 22 Sep 2023 11:27:05 +0200 (CEST)","from ideasonboard.com (93-46-82-201.ip106.fastwebnet.it\n\t[93.46.82.201])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 57EBC968;\n\tFri, 22 Sep 2023 11:25:27 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695374827;\n\tbh=jH5+tx4l+vtGDsv3f1/PjAePhSN6ZBvi6AyRnaIREOc=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=J4shF7XsC2cSRKlSd1hlvjOffVl1YPPfHwdvDWDlXnVONhTCMjDJkpInub/u1ahnL\n\tytxyGh4mEkiGwaKSM1EN4UkY6DJGzDjV1gVhbTHAkW47O0Bj3S2iFVshXxoHmNY43H\n\tkt1mtQZ7drXslMgj5/TEaaBZjzjbV1Sd5adEKlHvHFbzrMY0ybhhOM40QsKa4KzRhj\n\tEY4A05T73pOwgSlLDiKQ24LuCe7UmUasioyYho1bFcM3W1GVgFMnEp2QhX5n4FFko8\n\t/k+eBWD0aduVPzk2/0+Omv17W4PvEtZiMemxpfrpIFsiMMVHy9r+Q5oQsDAqa4fbkm\n\txgXnX/xAG9gbw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1695374727;\n\tbh=jH5+tx4l+vtGDsv3f1/PjAePhSN6ZBvi6AyRnaIREOc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=OpK7kYJGZDjxnRWlmiGXUEKshd9YYhtcf80O4cZgBmTmTXxdIQYsMQvqcfO0JEQqP\n\tnY1yLXVOVbdwPKTE9YFiTKP3M6+BSdg4G1CsqOvyS3S6rtSdo1nQmdgR+5GW6GhCj5\n\tE09SSv5vr9xfafPxO/KqbB/7nYr62AxuCUHNhn5Y="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"OpK7kYJG\"; dkim-atps=neutral","Date":"Fri, 22 Sep 2023 11:27:02 +0200","To":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","Message-ID":"<zym5ds4llnmpt3kuzrbghdlh6anfbjicn6a4c2uroyzpo2hkgr@mlnmufyqolgp>","References":"<20230912-gralloc-api-v4-v2-0-e859da63f98c@baylibre.com>\n\t<20230912-gralloc-api-v4-v2-4-e859da63f98c@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230912-gralloc-api-v4-v2-4-e859da63f98c@baylibre.com>","Subject":"Re: [libcamera-devel] [PATCH v2 4/4] android: mm: generic: Use\n\tGraphicBufferAllocator instead of gralloc.h","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tGuillaume La Roque <glaroque@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":27850,"web_url":"https://patchwork.libcamera.org/comment/27850/","msgid":"<875y4189ku.fsf@baylibre.com>","date":"2023-09-23T10:31:29","subject":"Re: [libcamera-devel] [PATCH v2 4/4] android: mm: generic: Use\n\tGraphicBufferAllocator instead of gralloc.h","submitter":{"id":153,"url":"https://patchwork.libcamera.org/api/people/153/","name":"Mattijs Korpershoek","email":"mkorpershoek@baylibre.com"},"content":"Hi Jacopo,\n\nThank you for your review.\n\nOn ven., sept. 22, 2023 at 11:27, Jacopo Mondi <jacopo.mondi@ideasonboard.com> wrote:\n\n> HI Mattijs\n>\n>  nice work!\n>\n> On Tue, Sep 12, 2023 at 04:15:23PM +0200, Mattijs Korpershoek via libcamera-devel wrote:\n>> gralloc.h is a very old API that has been deprecated at least since\n>> Android P (9).\n>>\n>> Switch over to a higher level abstraction of gralloc from libui, which\n>> is compatible with Android 11 and up.\n>> Libui\n:\n>> * is provided in the VNDK (so it's available to vendors).\n>> * is also used in the camera vts test named VtsAidlHalCameraProvider_TargetTest.\n>>\n>> Drop the libhardware stub since we no longer need it.\n>>\n>> Notes:\n>> * GraphicsBufferAllocator being a Singleton, buffer lifecycle\n>>   management is easier.\n>> * The imported headers from Android generate the -Wextra-semi warning.\n>>   To avoid patching the files, a pragma has been added before inclusion.\n>>\n>> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n>> ---\n>>  src/android/mm/generic_frame_buffer_allocator.cpp | 61 ++++++++---------------\n>>  src/android/mm/libhardware_stub.c                 | 17 -------\n>>  src/android/mm/meson.build                        |  8 ++-\n>>  3 files changed, 23 insertions(+), 63 deletions(-)\n>>\n>> diff --git a/src/android/mm/generic_frame_buffer_allocator.cpp b/src/android/mm/generic_frame_buffer_allocator.cpp\n>> index 7ecef2c669df..468579068c32 100644\n>> --- a/src/android/mm/generic_frame_buffer_allocator.cpp\n>> +++ b/src/android/mm/generic_frame_buffer_allocator.cpp\n>> @@ -16,8 +16,11 @@\n>>  #include \"libcamera/internal/framebuffer.h\"\n>>\n>>  #include <hardware/camera3.h>\n>> -#include <hardware/gralloc.h>\n>\n> our version of include/android/system/core/include/system/camera.h\n> still includes gralloc.h. We should update all headers most probably\n\nThat's also the case for the one in aosp main:\n\nhttps://cs.android.com/android/platform/superproject/main/+/main:system/core/libsystem/include/system/camera.h?q=camera.h%20&ss=android%2Fplatform%2Fsuperproject%2Fmain\n\nHow about, instead, we get rid of the unused headers (which were copied\nfrom AOSP) in the libcamera include/android tree instead?\n\nIf that seems fine, I will do some cleaning up and get rid of the\n\"no-longer needed\" headers in a new patch for v2.\n\n\n>\n>> -#include <hardware/hardware.h>\n>> +#pragma GCC diagnostic push\n>> +#pragma GCC diagnostic ignored \"-Wextra-semi\"\n>> +#include <ui/GraphicBufferAllocator.h>\n>> +#pragma GCC diagnostic pop\n>> +#include <utils/Errors.h>\n>>\n>>  #include \"../camera_device.h\"\n>>  #include \"../frame_buffer_allocator.h\"\n>> @@ -33,35 +36,28 @@ class GenericFrameBufferData : public FrameBuffer::Private\n>>  \tLIBCAMERA_DECLARE_PUBLIC(FrameBuffer)\n>>\n>>  public:\n>> -\tGenericFrameBufferData(struct alloc_device_t *allocDevice,\n>> +\tGenericFrameBufferData(android::GraphicBufferAllocator &allocDevice,\n>\n> You could\n>\n>         GenericFrameBufferData(buffer_handle_t handle,\n>                                const std::vector<FrameBuffer::Plane> &planes)\n>                 : FrameBuffer::Private(planes),\n>                   allocDevice_(android::GraphicBufferAllocator::get()),\n>                   handle_(handle)\n>\n> Instead of passing it to the constructor of ::Private.\n> It does't make much different though, up to you!\n\nI will give it some thought and either change it for v2 or put a note in\nthe cover to explain why I kept it the same.\n\n>\n>>  \t\t\t       buffer_handle_t handle,\n>>  \t\t\t       const std::vector<FrameBuffer::Plane> &planes)\n>>  \t\t: FrameBuffer::Private(planes), allocDevice_(allocDevice),\n>>  \t\t  handle_(handle)\n>>  \t{\n>> -\t\tASSERT(allocDevice_);\n>>  \t\tASSERT(handle_);\n>>  \t}\n>>\n>>  \t~GenericFrameBufferData() override\n>>  \t{\n>>  \t\t/*\n>> -\t\t * allocDevice_ is used to destroy handle_. allocDevice_ is\n>> -\t\t * owned by PlatformFrameBufferAllocator::Private.\n>> -\t\t * GenericFrameBufferData must be destroyed before it is\n>> -\t\t * destroyed.\n>> -\t\t *\n>> -\t\t * \\todo Consider managing alloc_device_t with std::shared_ptr\n>> -\t\t * if this is difficult to maintain.\n>> -\t\t *\n>\n> nice!\n>\n>>  \t\t * \\todo Thread safety against alloc_device_t is not documented.\n>>  \t\t * Is it no problem to call alloc/free in parallel?\n>>  \t\t */\n>> -\t\tallocDevice_->free(allocDevice_, handle_);\n>> +\t\tandroid::status_t status = allocDevice_.free(handle_);\n>\n> Or you could even get the singleton instance here!\n\nYou mean dropping the member and just getting the singleton instance with\nandroid::GraphicBufferAllocator::get() ?\n\nThat might be even simpler and avoid adding an additional member indeed.\n\n>\n>> +\t\tif (status != android::NO_ERROR)\n>> +\t\t\tLOG(HAL, Error) << \"Error freeing framebuffer: \" << status;\n>>  \t}\n>>\n>>  private:\n>> -\tstruct alloc_device_t *allocDevice_;\n>> +\tandroid::GraphicBufferAllocator &allocDevice_;\n>\n> Usually reference class members are worrying to me, but this really\n> just points to a system-wide component accessed via a singleton if i'm\n> not mistaken, so this should be fine!\n\nYes, that is correct. I will study to remove the member for v2.\n\n>\n>\n>>  \tconst buffer_handle_t handle_;\n>>  };\n>>  } /* namespace */\n>> @@ -73,50 +69,33 @@ class PlatformFrameBufferAllocator::Private : public Extensible::Private\n>>  public:\n>>  \tPrivate(CameraDevice *const cameraDevice)\n>>  \t\t: cameraDevice_(cameraDevice),\n>> -\t\t  hardwareModule_(nullptr),\n>> -\t\t  allocDevice_(nullptr)\n>> +\t\t  allocDevice_(android::GraphicBufferAllocator::get())\n>>  \t{\n>> -\t\thw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hardwareModule_);\n>> -\t\tASSERT(hardwareModule_);\n>>  \t}\n>>\n>> -\t~Private() override;\n>> +\t~Private() = default;\n>>\n>>  \tstd::unique_ptr<HALFrameBuffer>\n>>  \tallocate(int halPixelFormat, const libcamera::Size &size, uint32_t usage);\n>>\n>>  private:\n>>  \tconst CameraDevice *const cameraDevice_;\n>> -\tconst struct hw_module_t *hardwareModule_;\n>> -\tstruct alloc_device_t *allocDevice_;\n>> +\tandroid::GraphicBufferAllocator &allocDevice_;\n>>  };\n>>\n>> -PlatformFrameBufferAllocator::Private::~Private()\n>> -{\n>> -\tif (allocDevice_)\n>> -\t\tgralloc_close(allocDevice_);\n>> -\tdlclose(hardwareModule_->dso);\n>> -}\n>> -\n>>  std::unique_ptr<HALFrameBuffer>\n>>  PlatformFrameBufferAllocator::Private::allocate(int halPixelFormat,\n>>  \t\t\t\t\t\tconst libcamera::Size &size,\n>>  \t\t\t\t\t\tuint32_t usage)\n>>  {\n>> -\tif (!allocDevice_) {\n>> -\t\tint ret = gralloc_open(hardwareModule_, &allocDevice_);\n>> -\t\tif (ret) {\n>> -\t\t\tLOG(HAL, Fatal) << \"gralloc_open() failed: \" << ret;\n>> -\t\t\treturn nullptr;\n>> -\t\t}\n>> -\t}\n>> -\n>> -\tint stride = 0;\n>> +\tuint32_t stride = 0;\n>>  \tbuffer_handle_t handle = nullptr;\n>> -\tint ret = allocDevice_->alloc(allocDevice_, size.width, size.height,\n>> -\t\t\t\t      halPixelFormat, usage, &handle, &stride);\n>> -\tif (ret) {\n>> -\t\tLOG(HAL, Error) << \"failed buffer allocation: \" << ret;\n>> +\n>> +\tandroid::status_t status = allocDevice_.allocate(size.width, size.height, halPixelFormat,\n>> +\t\t\t\t\t\t\t 1 /*layerCount*/, usage, &handle, &stride,\n>> +\t\t\t\t\t\t\t \"libcameraHAL\");\n>> +\tif (status != android::NO_ERROR) {\n>> +\t\tLOG(HAL, Error) << \"failed buffer allocation: \" << status;\n>>  \t\treturn nullptr;\n>>  \t}\n>>  \tif (!handle) {\n>> diff --git a/src/android/mm/libhardware_stub.c b/src/android/mm/libhardware_stub.c\n>> deleted file mode 100644\n>> index 00f15cd90cac..000000000000\n>> --- a/src/android/mm/libhardware_stub.c\n>> +++ /dev/null\n>> @@ -1,17 +0,0 @@\n>> -/* SPDX-License-Identifier: Apache-2.0 */\n>> -/*\n>> - * Copyright (C) 2023, Ideas on Board\n>> - *\n>> - * libhardware_stub.c - Android libhardware stub for test compilation\n>> - */\n>> -\n>> -#include <errno.h>\n>> -\n>> -#include <hardware/hardware.h>\n>> -\n>> -int hw_get_module(const char *id __attribute__((__unused__)),\n>> -\t\t  const struct hw_module_t **module)\n>> -{\n>> -\t*module = NULL;\n>> -\treturn -ENOTSUP;\n>> -}\n>> diff --git a/src/android/mm/meson.build b/src/android/mm/meson.build\n>> index e9ceb3afba67..203b8c3e5804 100644\n>> --- a/src/android/mm/meson.build\n>> +++ b/src/android/mm/meson.build\n>> @@ -4,13 +4,11 @@ platform = get_option('android_platform')\n>>  if platform == 'generic'\n>>      android_hal_sources += files(['generic_camera_buffer.cpp',\n>>                                    'generic_frame_buffer_allocator.cpp'])\n>> -    android_deps += [libdl]\n>\n> libdl was used for ?\n\nfor dlclose() call done in PlatformFrameBufferAllocator::Private::~Private().\n\nFor some background of why this was needed, refer to:\n* 1450e09a0839 (\"android: mm: generic: use GRALLOC_HARDWARE_MODULE_ID\")\n* https://patchwork.libcamera.org/patch/18309/#26496\n\n\n>\n>>\n>> -    libhardware = dependency('libhardware', required : false)\n>> -    if libhardware.found()\n>> -        android_deps += [libhardware]\n>> +    libui = dependency('libui', required : false)\n>> +    if libui.found()\n>> +        android_deps += [libui]\n>>      else\n>> -        android_hal_sources += files(['libhardware_stub.c'])\n>>          android_hal_sources += files(['graphic_buffer_allocator_stub.cpp'])\n>>      endif\n>>  elif platform == 'cros'\n>\n> All nits\n> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n>\n> Thanks\n>   j\n>\n>>\n>> --\n>> 2.41.0\n>>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 687B2BE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 23 Sep 2023 10:31:35 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A01EF62944;\n\tSat, 23 Sep 2023 12:31:34 +0200 (CEST)","from mail-wm1-x333.google.com (mail-wm1-x333.google.com\n\t[IPv6:2a00:1450:4864:20::333])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 070A461DE7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Sep 2023 12:31:33 +0200 (CEST)","by mail-wm1-x333.google.com with SMTP id\n\t5b1f17b1804b1-404fbfac998so39350755e9.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Sep 2023 03:31:32 -0700 (PDT)","from localhost (92-184-117-148.mobile.fr.orangecustomers.net.\n\t[92.184.117.148]) by smtp.gmail.com with ESMTPSA id\n\tbg10-20020a05600c3c8a00b00405323d47fdsm6952625wmb.21.2023.09.23.03.31.31\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 23 Sep 2023 03:31:32 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695465094;\n\tbh=ZR/YPt13g32v7GXnNoxcBQp4YGXS7ujSVdJ2gHtALdc=;\n\th=To:In-Reply-To:References:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=TYIGCX83IwmJlnPPcIvMGbaqiDA+CCtzyi9KqnLdaV9JsFkZHO2ZpzEx+5A/D1VQv\n\tq6ljFoGxj3RHnIQGNKIbRgyWHiQVmnj0VwgaTuAX2Jjg8KZZvOw4/VuqfdE6L1lEDZ\n\tquTZ4Jby8Si5nxa8PLufCuu4T0RoHHI88erSwUne8lH2bwBi8dfzTTpOw8Vp1yFDB3\n\tGlzuUsnoMHXAzFrIKi0b2G1WqsQ//FzTScUQ2LiECo7b5vylKiLVrmxn7R0CQW2g66\n\tPJ0ZtjhhHaXzX0NB+cj736JkPiNL1GLrvqw5ksphR9pGvlfuDvgn93jjJiCw3htk6a\n\tRUKDlv4N6e7cg==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695465092;\n\tx=1696069892; darn=lists.libcamera.org; \n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:from:to:cc:subject:date:message-id:reply-to;\n\tbh=GPzIObG2jkk7+rOELEBQxsFyIRtUnLYLYfvF71WYlNQ=;\n\tb=L8UTbNxBQ5OxG+yXHhcRij/mBXiUhJaOeSm5IAbnv2VSqAwGyRNa0Xrgn0OUlyvF0j\n\t67ZKh187kruc0pWijL3wsLhjblueP3PpMA+ZWMxUPkf1aldeKgEDIlzeCMHN0xSl0SEX\n\tDGBbYvX72HX3uKJLlLKgir3hxztt3owEWVpA29RiPEY4D5xabTMYusoZjaVkQ9YQlZgO\n\txVDczjwPZseKTN1096wLNVW03a5KsN7sEA8IrAg8BGDCS7l0ehWRX3q+Wm4NDyHH7CwV\n\t9NtRunA3ywiK+fAYxwtA9A+K3bqGx0XygM9bIscgIoMrnvGLs1KtRQ9G2YqmAUPoIs8F\n\tsNPw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20230601.gappssmtp.com\n\theader.i=@baylibre-com.20230601.gappssmtp.com header.b=\"L8UTbNxB\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1695465092; x=1696069892;\n\th=mime-version:message-id:date:references:in-reply-to:subject:cc:to\n\t:from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; \n\tbh=GPzIObG2jkk7+rOELEBQxsFyIRtUnLYLYfvF71WYlNQ=;\n\tb=vU/BmQoX3xlooc51hGl+7FdCy6bL93RAAHECQUGbihXQoteus68SqtrVQGYmbn6UoX\n\t8aG8u50QETldGiSwN+9r4AvOtSdPoOXoW/1BsFH0XWoeGEZb/oMgzIJOHOUDQYiwDm+9\n\t11ff+EfvngPmPQpHm5psHvwyIJhorRBLW99QovO0y670kLLknl2k6u9+qgz92FsHi07X\n\t9phStJTZxk48fHU00pG8T/WbGfqQXobpn8o9H7w/BdXnYvItidK/a6sHJ9rwii0fI8pB\n\tevo7U389T99egeIuzqBnY5A/euM5naAHFE/FR8lj9YJux5SswO477l/YdToXkJa4HSrW\n\tajYw==","X-Gm-Message-State":"AOJu0Yw8CtTVFK11IN4U5LyKD8sxzwCHepLVhYrb1n5zpEbhAZQ2piCb\n\tRVWFjfRxEqs5j8yiKekkbGWvliGdp7q/W6VaBRo=","X-Google-Smtp-Source":"AGHT+IGCpmKAZpiJ6mJJog6w858Ykz4xxn1TuO51OrEhXCkX7sBND0ER+W5QqY+bkN9MCz/4OPRsng==","X-Received":"by 2002:a05:600c:230e:b0:3fe:3004:1ffd with SMTP id\n\t14-20020a05600c230e00b003fe30041ffdmr1477331wmo.4.1695465092469; \n\tSat, 23 Sep 2023 03:31:32 -0700 (PDT)","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","In-Reply-To":"<zym5ds4llnmpt3kuzrbghdlh6anfbjicn6a4c2uroyzpo2hkgr@mlnmufyqolgp>","References":"<20230912-gralloc-api-v4-v2-0-e859da63f98c@baylibre.com>\n\t<20230912-gralloc-api-v4-v2-4-e859da63f98c@baylibre.com>\n\t<zym5ds4llnmpt3kuzrbghdlh6anfbjicn6a4c2uroyzpo2hkgr@mlnmufyqolgp>","Date":"Sat, 23 Sep 2023 12:31:29 +0200","Message-ID":"<875y4189ku.fsf@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain","Subject":"Re: [libcamera-devel] [PATCH v2 4/4] android: mm: generic: Use\n\tGraphicBufferAllocator instead of gralloc.h","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Mattijs Korpershoek via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Mattijs Korpershoek <mkorpershoek@baylibre.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tGuillaume La Roque <glaroque@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]