[{"id":26509,"web_url":"https://patchwork.libcamera.org/comment/26509/","msgid":"<87ttz43nhj.fsf@baylibre.com>","date":"2023-03-01T08:05:44","subject":"Re: [libcamera-devel] [PATCH v2] android: mm: generic: use\n\tGRALLOC_HARDWARE_MODULE_ID","submitter":{"id":153,"url":"https://patchwork.libcamera.org/api/people/153/","name":"Mattijs Korpershoek","email":"mkorpershoek@baylibre.com"},"content":"On mar., févr. 28, 2023 at 15:15, Mattijs Korpershoek <mkorpershoek@baylibre.com> wrote:\n\n> PlatformFrameBufferAllocator is an abstraction over gralloc.\n> Right now hardwareModule_ points towards a CAMERA_HARDWARE_MODULE_ID.\n>\n> When gralloc_open() is called we observe:\n> libcamera: DEBUG HAL camera3_hal.cpp:75 Open camera gpu0\n> libcamera: ERROR Camera camera.cpp:524 Camera in Configured state trying acquire() requiring state Available\n> 01-23 14:14:04.742   370   416 E libcamera: FATAL HAL generic_frame_buffer_allocator.cpp:105 gralloc_open() failed: -87\n>\n> Which is wrong, gralloc_open() is attempting to re-open the camera HAL,\n> instead of the gralloc HAL.\n>\n> Point to a GRALLOC_HARDWARE_MODULE_ID instead so that we can request\n> buffers from gralloc in android.\n>\n> Note: this add a new dependency on android's libhardware [1]\n>\n> [1] https://android.googlesource.com/platform/hardware/libhardware\n>\n> Fixes: c58662c5770e (\"android: Introduce PlatformFrameBufferAllocator\")\n> Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\n> ---\n> * Tested on an integration branch in Android 12 (Using android.bp)\n> * Build tested with meson.\n> ---\n> Changes in v2:\n> - Add dlclose() in PlatformFrameBufferAllocator destructor (Laurent)\n> - Removed RFC, as linking against an AOSP lib for android is OK.\n\nI'm missing a meson build system change here as pointed out in\nhttps://lists.libcamera.org/pipermail/libcamera-devel/2023-March/036890.html\n\nSorry for the noise. I will send a v3.\n\n> - Link to v1: https://lists.libcamera.org/pipermail/libcamera-devel/2023-February/036857.html\n> ---\n>  src/android/mm/generic_frame_buffer_allocator.cpp | 7 +++++--\n>  1 file changed, 5 insertions(+), 2 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 3750e1bf52a9..7ecef2c669df 100644\n> --- a/src/android/mm/generic_frame_buffer_allocator.cpp\n> +++ b/src/android/mm/generic_frame_buffer_allocator.cpp\n> @@ -5,6 +5,7 @@\n>   * generic_camera_buffer.cpp - Allocate FrameBuffer using gralloc API\n>   */\n>  \n> +#include <dlfcn.h>\n>  #include <memory>\n>  #include <vector>\n>  \n> @@ -72,9 +73,10 @@ class PlatformFrameBufferAllocator::Private : public Extensible::Private\n>  public:\n>  \tPrivate(CameraDevice *const cameraDevice)\n>  \t\t: cameraDevice_(cameraDevice),\n> -\t\t  hardwareModule_(cameraDevice->camera3Device()->common.module),\n> +\t\t  hardwareModule_(nullptr),\n>  \t\t  allocDevice_(nullptr)\n>  \t{\n> +\t\thw_get_module(GRALLOC_HARDWARE_MODULE_ID, &hardwareModule_);\n>  \t\tASSERT(hardwareModule_);\n>  \t}\n>  \n> @@ -85,7 +87,7 @@ public:\n>  \n>  private:\n>  \tconst CameraDevice *const cameraDevice_;\n> -\tstruct hw_module_t *const hardwareModule_;\n> +\tconst struct hw_module_t *hardwareModule_;\n>  \tstruct alloc_device_t *allocDevice_;\n>  };\n>  \n> @@ -93,6 +95,7 @@ PlatformFrameBufferAllocator::Private::~Private()\n>  {\n>  \tif (allocDevice_)\n>  \t\tgralloc_close(allocDevice_);\n> +\tdlclose(hardwareModule_->dso);\n>  }\n>  \n>  std::unique_ptr<HALFrameBuffer>\n>\n> ---\n> base-commit: 58e0b6e18c425072a47594f42fc0b61801403aca\n> change-id: 20230227-android-gralloc-04e31d5edc68\n>\n> Best regards,\n> -- \n> Mattijs Korpershoek <mkorpershoek@baylibre.com>","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 AB5A7BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Mar 2023 08:05:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 18F9C6267E;\n\tWed,  1 Mar 2023 09:05:48 +0100 (CET)","from mail-wm1-x336.google.com (mail-wm1-x336.google.com\n\t[IPv6:2a00:1450:4864:20::336])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E00D161EE0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Mar 2023 09:05:45 +0100 (CET)","by mail-wm1-x336.google.com with SMTP id\n\tl7-20020a05600c4f0700b003e79fa98ce1so7295793wmq.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 01 Mar 2023 00:05:45 -0800 (PST)","from localhost ([2a01:cb19:85e6:1900:2bf7:7388:731d:c4e1])\n\tby smtp.gmail.com with ESMTPSA id\n\tg10-20020a7bc4ca000000b003dc4a47605fsm18724169wmk.8.2023.03.01.00.05.44\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 01 Mar 2023 00:05:45 -0800 (PST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1677657948;\n\tbh=5aba2mcOYYp8mo0WlldxZ54MgyiFFl09JU8cUhWTajk=;\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:\n\tFrom;\n\tb=eY4wVeK2cAHRZCAZCOn3MRcJJikTQuAdV3UFgWkMf/XFD2GS8Sc60DWc3ycv4q1OL\n\tcod4LVhMIeCQS2bAFKkO7XxfakjVF0svh13Ko27SBsK4S6460JSmDdztzu/Re05eLL\n\t6Ub+Wue7Mn3HjQnCPrhlBSmXl+EnylFgsIl5m5MkvqTGSkIAsBzycxRG0vZYcaWD3v\n\tngjOTp9qQastHxqjJUbGzuFof6ZIyD4XLoyLujTN8Lwrby41tjAxiuQ6D00fN57pwt\n\tk1dybnT7+3zt1mstakpTU3uLZIV+eClLtq+0GS/Ij2JhvsrFLGgJuYDVMdIKgFUVFV\n\t3N9fUrj9NaOag==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20210112.gappssmtp.com; s=20210112; t=1677657945;\n\th=content-transfer-encoding:mime-version:message-id:date:references\n\t:in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id\n\t:reply-to; bh=k1clYm0u/aLfEB1Q2YkBCzzxr+HUYUrzoN3fRsMJwyY=;\n\tb=Hu1AUqWYwdYqXlUFxR8f6MSd4OI5x+x94GN089vcqFeRbijtl0Dk94awcd36+MZob+\n\tr1QqE1cUotLDZZn1/38I5KStAV4rAORrlciGcYPa+DK7ERn22BlAoNQ4Ec4OgQsGAgI3\n\t9XbZoEIYXI0B3hjvEKHTClctS+qjy2sif6EfZet3O/0sprTAwLWoB+qU9yenU8Rjelzr\n\trBmyFAmWN3+fpdIGFbuwG1QcWczBrj7K118fvCil0J7A6sZxwE8bz6ZMHiicDExd5Kfb\n\tIkziarmdtWGC4cfqoBq6DE+DNowRfNW16pFhFzYZbpy2pI3Y8cJraqmnMKDvfdvKa/r5\n\tMMCQ=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected)\n\theader.d=baylibre-com.20210112.gappssmtp.com\n\theader.i=@baylibre-com.20210112.gappssmtp.com header.b=\"Hu1AUqWY\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112; t=1677657945;\n\th=content-transfer-encoding:mime-version:message-id:date:references\n\t:in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=k1clYm0u/aLfEB1Q2YkBCzzxr+HUYUrzoN3fRsMJwyY=;\n\tb=6CclXw5HfwMsN2LpBXICLw4OTRo0Ev4XoBHkhsGVTW88vWpwGFt2Sx8EoRCPcksHYU\n\t5f35NGC8C21PjKhirJH4i+Gvr4oqnVZDDNVlLJtmo381pE4GeUZ6IugWmbbQf7iIDmYB\n\tpYdjyB9t2oTDfUeU/JRg3QDI0PdSaNxuUhGwCdeIiQdr3h2BjRt1yO2QJK2SZY1N/SX6\n\tgy+uk8BcK8cWKkDudDbtmZFBoUAmKtPsmw+Vi/W+zLNaBpoI3xe0jHpUsrIJSZ8aTKCT\n\tbkNHDLQKOMbNu2i6jxS9UWCz/EPpOHx7lcumEBQfp5wxPNP+CY7rWGCe1QWxH2jovTRK\n\tFhfQ==","X-Gm-Message-State":"AO0yUKWLkY1h9om9VLZz/AtDoqLlhzDwI+MWctHoobaoLOUar1fo7msh\n\tK3I3FvIGkdjC42ye/rDamBLflT197ZM/dbuYcFc=","X-Google-Smtp-Source":"AK7set9Q60ZypZNwC/5KQWEB/N45Tfk2b06pxCcR9W1/p/S430HEj3DarIec7BZwEXDW6oPIbp6yVg==","X-Received":"by 2002:a05:600c:331b:b0:3df:fbd5:690 with SMTP id\n\tq27-20020a05600c331b00b003dffbd50690mr3989627wmp.17.1677657945357; \n\tWed, 01 Mar 2023 00:05:45 -0800 (PST)","To":"libcamera-devel@lists.libcamera.org","In-Reply-To":"<20230227-android-gralloc-v2-1-029b4d2a0c4d@baylibre.com>","References":"<20230227-android-gralloc-v2-1-029b4d2a0c4d@baylibre.com>","Date":"Wed, 01 Mar 2023 09:05:44 +0100","Message-ID":"<87ttz43nhj.fsf@baylibre.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","Subject":"Re: [libcamera-devel] [PATCH v2] android: mm: generic: use\n\tGRALLOC_HARDWARE_MODULE_ID","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]