{"id":19082,"url":"https://patchwork.libcamera.org/api/1.1/patches/19082/?format=json","web_url":"https://patchwork.libcamera.org/patch/19082/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20230923-gralloc-api-v4-v3-3-9a9e039284ba@baylibre.com>","date":"2023-09-23T16:23:33","name":"[libcamera-devel,v3,3/4] android: Stub GraphicBufferAllocator for build tests","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"6814a50359fc2854a9b6eaf59482145b65394244","submitter":{"id":153,"url":"https://patchwork.libcamera.org/api/1.1/people/153/?format=json","name":"Mattijs Korpershoek","email":"mkorpershoek@baylibre.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19082/mbox/","series":[{"id":4035,"url":"https://patchwork.libcamera.org/api/1.1/series/4035/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4035","date":"2023-09-23T16:23:30","name":"android: switch over to modern gralloc API via libui","version":3,"mbox":"https://patchwork.libcamera.org/series/4035/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19082/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19082/checks/","tags":{},"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 4377FC326B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 23 Sep 2023 16:23:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 14DE46294D;\n\tSat, 23 Sep 2023 18:23:45 +0200 (CEST)","from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com\n\t[IPv6:2a00:1450:4864:20::32b])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 04E1C62936\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Sep 2023 18:23:41 +0200 (CEST)","by mail-wm1-x32b.google.com with SMTP id\n\t5b1f17b1804b1-4051fea48a8so43645385e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 23 Sep 2023 09:23:41 -0700 (PDT)","from [192.168.0.39] ([2a01:e0a:324:38a0:25d4:3d10:65f9:654e])\n\tby smtp.gmail.com with ESMTPSA id\n\ty7-20020adfd087000000b00317f70240afsm7200595wrh.27.2023.09.23.09.23.40\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSat, 23 Sep 2023 09:23:40 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1695486225;\n\tbh=7OX63jm5dduEX5c+tg950hHKvEZVt60LzRJGFDLdW30=;\n\th=Date:References:In-Reply-To:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=hbRgnpFTxd+bm61BZl0JZv2dBFupkL42sR+glbBJE5JfI9aJeZj8xpSt5K6rHnM/p\n\tDIwfd+XwNn60E7uswUUfhrkKaBh1HcEstlK0/jslavpF5rbbJf6lkfDiDvJg9nQpKt\n\tT4c/OBToP607f+tiWWqBE4augxA4jvohO08nXnrIA7eKu2/elZjTQYPw2xSzHK8sFb\n\tTJym90uyUkjRHNkWso/0D0We14yrt3fU1EKMnrUNPOwkPaxyRyFm4khTnNmbVdWIbr\n\twcSfJ3qmX8oz8oDYSbAnd/05sc9kq3PnCGmHHcHTyFIQxNB1FVUlD9rrxHiCa66lRS\n\tV+h6zpikUEx2Q==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1695486221;\n\tx=1696091021; darn=lists.libcamera.org; \n\th=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n\t:mime-version:subject:date:from:from:to:cc:subject:date:message-id\n\t:reply-to; bh=syzQyd55bfiNG/ZNBdoFgZkiR6y0jT/ireZI6tbrAfk=;\n\tb=0zQQEyJRlYEaiNH0YN4lx2zqeweTAFa0hSkyf7M3ToC+o1tzBsRN3lOJMPMLBGPlaF\n\tdZmtXIxmTJfT2mPds2DWz4uYOYJXX+uHv7k9c/K8bWieeKn4fTc29H33tMRPXRXLc5aT\n\tDn7YL9Qlsrru2UunQPErT3AJb0eOCLezX9hYtE9aJUqO02Qt3w0E11Qq8f34gtq3wKyU\n\tDTnYKP0ZQI0F4K0tFDFPXxURTFY7XnjoyciwmPKniU82Bt6GiekFGfyvkR37mVE9rPDO\n\tkDeSBmgyrOKowA4AwsXOpqGYmbDGHwRQwL4lndoRQXvKoXmV/2hJZNcDI6R0yuM/s0b7\n\t7jCQ=="],"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=\"0zQQEyJR\"; \n\tdkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1695486221; x=1696091021;\n\th=cc:to:in-reply-to:references:message-id:content-transfer-encoding\n\t:mime-version:subject:date:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=syzQyd55bfiNG/ZNBdoFgZkiR6y0jT/ireZI6tbrAfk=;\n\tb=DBlfj2van4SHaiqdu9ooej2hAxW3at8RE0lr3/qssmEf/Ye73jPqEgQJmQa0KnjP+5\n\tt0j4KqAAGlGc77Hm8DDNZCVmaMTmvv/FXA/x+vnGJZkYiaTK+chzLPsyCgM5ih7KtKhR\n\t7L5+IC/PSw/XuWVtxHpDZLUjRQW4WgBMY/zT4NX9jIHCVCXpW8aGlI72SZhnFDgm8pbI\n\t7+AeQRSjO/wJHPPllk3x5lnJEkOetYYLpgu+yFLSD+w5pJqyOc8lgApyP8NGH0cP7HGV\n\tDziTD8I4/HIffhC/VcNCY5wPW4eEv5FuDuiK7M2K7E4j2zHyvXEn6TZuzv9JyPnz/4HN\n\tNsbw==","X-Gm-Message-State":"AOJu0YwLC626IKU0vXoNkztCCnjH/NSXM+KkxIZU66WwGq8LvKHglYSD\n\tkftf28QR30dDD4aZwd5mDzEKLg==","X-Google-Smtp-Source":"AGHT+IEwbKeibtjzBSmf+u9g5ZW1F0I5qpeXrRur9brQXpqrHF4x2DPRHv+qE4TUjaCMHA6Tv8D3hg==","X-Received":"by 2002:adf:f68a:0:b0:320:447:3bcc with SMTP id\n\tv10-20020adff68a000000b0032004473bccmr2293444wrp.51.1695486220946; \n\tSat, 23 Sep 2023 09:23:40 -0700 (PDT)","Date":"Sat, 23 Sep 2023 18:23:33 +0200","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20230923-gralloc-api-v4-v3-3-9a9e039284ba@baylibre.com>","References":"<20230923-gralloc-api-v4-v3-0-9a9e039284ba@baylibre.com>","In-Reply-To":"<20230923-gralloc-api-v4-v3-0-9a9e039284ba@baylibre.com>","To":"libcamera-devel@lists.libcamera.org","X-Mailer":"b4 0.12.4-dev-6aa5d","Subject":"[libcamera-devel] [PATCH v3 3/4] android: Stub\n\tGraphicBufferAllocator for build tests","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":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>,\n\tGuillaume La Roque <glaroque@baylibre.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"If we want to keep building libcamera on traditional Linux systems with:\n  -Dandroid=enabled -Dandroid_platform=generic\n\nWe should stub GraphicBufferAllocator, which is not available.\nIt's only available when building with the VNDK or when building within the\nAOSP tree.\n\nAlso remove some deprecated methods and inclusions which are not needed for\nthe stub class.\n\nNote: the imported headers from Android generate the -Wextra-semi warning.\n      To avoid patching the files, a pragma has been added before inclusion.\n\nSigned-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>\nReviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n .../libs/ui/include/ui/GraphicBufferAllocator.h    | 30 ------------\n src/android/mm/graphic_buffer_allocator_stub.cpp   | 54 ++++++++++++++++++++++\n src/android/mm/meson.build                         |  7 +++\n 3 files changed, 61 insertions(+), 30 deletions(-)","diff":"diff --git a/include/android/frameworks/native/libs/ui/include/ui/GraphicBufferAllocator.h b/include/android/frameworks/native/libs/ui/include/ui/GraphicBufferAllocator.h\nindex e4674d746e37..9eac5bbe8324 100644\n--- a/include/android/frameworks/native/libs/ui/include/ui/GraphicBufferAllocator.h\n+++ b/include/android/frameworks/native/libs/ui/include/ui/GraphicBufferAllocator.h\n@@ -29,15 +29,10 @@\n #include <ui/PixelFormat.h>\n \n #include <utils/Errors.h>\n-#include <utils/KeyedVector.h>\n-#include <utils/Mutex.h>\n #include <utils/Singleton.h>\n \n namespace android {\n \n-class GrallocAllocator;\n-class GraphicBufferMapper;\n-\n class GraphicBufferAllocator : public Singleton<GraphicBufferAllocator>\n {\n public:\n@@ -52,25 +47,6 @@ public:\n                       uint64_t usage, buffer_handle_t* handle, uint32_t* stride,\n                       std::string requestorName);\n \n-    /**\n-     * Allocates and does NOT import a gralloc buffer. Buffers cannot be used until they have\n-     * been imported. This function is for advanced use cases only.\n-     *\n-     * The raw native handle must be freed by calling native_handle_close() followed by\n-     * native_handle_delete().\n-     */\n-    status_t allocateRawHandle(uint32_t w, uint32_t h, PixelFormat format, uint32_t layerCount,\n-                               uint64_t usage, buffer_handle_t* handle, uint32_t* stride,\n-                               std::string requestorName);\n-\n-    /**\n-     * DEPRECATED: GraphicBufferAllocator does not use the graphicBufferId.\n-     */\n-    status_t allocate(uint32_t w, uint32_t h, PixelFormat format,\n-            uint32_t layerCount, uint64_t usage,\n-            buffer_handle_t* handle, uint32_t* stride, uint64_t graphicBufferId,\n-            std::string requestorName);\n-\n     status_t free(buffer_handle_t handle);\n \n     uint64_t getTotalSize() const;\n@@ -94,15 +70,9 @@ protected:\n                             uint64_t usage, buffer_handle_t* handle, uint32_t* stride,\n                             std::string requestorName, bool importBuffer);\n \n-    static Mutex sLock;\n-    static KeyedVector<buffer_handle_t, alloc_rec_t> sAllocList;\n-\n     friend class Singleton<GraphicBufferAllocator>;\n     GraphicBufferAllocator();\n     ~GraphicBufferAllocator();\n-\n-    GraphicBufferMapper& mMapper;\n-    std::unique_ptr<const GrallocAllocator> mAllocator;\n };\n \n // ---------------------------------------------------------------------------\ndiff --git a/src/android/mm/graphic_buffer_allocator_stub.cpp b/src/android/mm/graphic_buffer_allocator_stub.cpp\nnew file mode 100644\nindex 000000000000..7e412c956887\n--- /dev/null\n+++ b/src/android/mm/graphic_buffer_allocator_stub.cpp\n@@ -0,0 +1,54 @@\n+/* SPDX-License-Identifier: Apache-2.0 */\n+/*\n+ * Copyright (C) 2023, Ideas on Board\n+ * Copyright (C) 2023, BayLibre\n+ *\n+ * graphic_buffer_allocator_stub.cpp - Android GraphicBufferAllocator\n+ * stub for compile-testing\n+ */\n+\n+#pragma GCC diagnostic push\n+#pragma GCC diagnostic ignored \"-Wextra-semi\"\n+#include <ui/GraphicBufferAllocator.h>\n+#pragma GCC diagnostic pop\n+\n+namespace android {\n+\n+ANDROID_SINGLETON_STATIC_INSTANCE(GraphicBufferAllocator)\n+\n+GraphicBufferAllocator::GraphicBufferAllocator()\n+{\n+}\n+\n+GraphicBufferAllocator::~GraphicBufferAllocator()\n+{\n+}\n+\n+uint64_t GraphicBufferAllocator::getTotalSize() const\n+{\n+\treturn 0;\n+}\n+\n+#pragma GCC diagnostic push\n+#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n+status_t GraphicBufferAllocator::allocate(uint32_t width,\n+\t\t\t\t\t  uint32_t height,\n+\t\t\t\t\t  PixelFormat format,\n+\t\t\t\t\t  uint32_t layerCount,\n+\t\t\t\t\t  uint64_t usage,\n+\t\t\t\t\t  buffer_handle_t *handle,\n+\t\t\t\t\t  uint32_t *stride,\n+\t\t\t\t\t  std::string requestorName)\n+{\n+\t*handle = nullptr;\n+\t*stride = 0;\n+\treturn INVALID_OPERATION;\n+}\n+\n+status_t GraphicBufferAllocator::free(buffer_handle_t handle)\n+{\n+\treturn INVALID_OPERATION;\n+}\n+#pragma GCC diagnostic pop\n+\n+} // namespace android\ndiff --git a/src/android/mm/meson.build b/src/android/mm/meson.build\nindex e3e0484c3720..4d1fb718e94e 100644\n--- a/src/android/mm/meson.build\n+++ b/src/android/mm/meson.build\n@@ -12,6 +12,13 @@ if platform == 'generic'\n     else\n         android_hal_sources += files(['libhardware_stub.c'])\n     endif\n+\n+    libui = dependency('libui', required : false)\n+    if libui.found()\n+        android_deps += [libui]\n+     else\n+        android_hal_sources += files(['graphic_buffer_allocator_stub.cpp'])\n+    endif\n elif platform == 'cros'\n     android_hal_sources += files(['cros_camera_buffer.cpp',\n                                   'cros_frame_buffer_allocator.cpp'])\n","prefixes":["libcamera-devel","v3","3/4"]}