{"id":14896,"url":"https://patchwork.libcamera.org/api/1.1/patches/14896/?format=json","web_url":"https://patchwork.libcamera.org/patch/14896/","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":"<20211130124428.2163669-3-hiroh@chromium.org>","date":"2021-11-30T12:44:28","name":"[libcamera-devel,2/2] android: camera_stream: Use PlatformFrameBufferAllocator","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"a9da3517b4505ce35cc2a2473038eca7396a1119","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14896/mbox/","series":[{"id":2784,"url":"https://patchwork.libcamera.org/api/1.1/series/2784/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2784","date":"2021-11-30T12:44:26","name":"Use PlatfromFrameBufferAllocator in CameraStream","version":1,"mbox":"https://patchwork.libcamera.org/series/2784/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14896/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14896/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 D0321C324F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 12:44:42 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 130C560724;\n\tTue, 30 Nov 2021 13:44:42 +0100 (CET)","from mail-pg1-x536.google.com (mail-pg1-x536.google.com\n\t[IPv6:2607:f8b0:4864:20::536])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DC87560719\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 13:44:39 +0100 (CET)","by mail-pg1-x536.google.com with SMTP id 137so12543159pgg.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 04:44:39 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:c90a:5a53:b139:1336])\n\tby smtp.gmail.com with ESMTPSA id\n\tbt2sm2424135pjb.33.2021.11.30.04.44.36\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 30 Nov 2021 04:44:37 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"aGVHxYAw\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=g3zl3ugPG4zxeEpyn5onMqpqJa2iG+SbBcZnGA8ucV8=;\n\tb=aGVHxYAw0mZoiWakdg3wLjRH+yecNESpM8pfSNIfifxfCf+0SmLiNE2oXv/vzDXh7U\n\tEKVT8m8OzmZKivphvhUpVuJQMrCz14+zLP/ofbAouS44RVTi207n9pFDU4EPNysTHQUa\n\tlJHHDT516jjpLOZLTLaj5zBoiNnGdB7KEqikA=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=g3zl3ugPG4zxeEpyn5onMqpqJa2iG+SbBcZnGA8ucV8=;\n\tb=6reQ+K8sE2y1WnGVIYGAto0iXVxsrn7UaJPGml4We0+NKvJ9spTIWMk7/X9iRb1+ci\n\toUOaqJ9oMAjxNeeox3uMVpV0xe8FgLxjbsdYJndrKSoCIgM1wPDj7SsQYzC2UsjjLKqP\n\t51dWmOvN/rk+6yoPkGAyzYCPdk1rerXDU/OCl8imI0KTmmAp8AL+xCWJbJl1pEkL5tJN\n\tOC/FoimDfpsmbRQLqwgwXzWg5AQlW7uwlU7sMBKCCbWlfgCvziiZV0fE8F3AleG43pUC\n\tQjojqbavkb3homDkx9Uj+fglTvyU4tdGPpJAF3VJEkmRXBgcjjezbiJ/N7R0PXQjn+RL\n\tEHAw==","X-Gm-Message-State":"AOAM53231NbOmqoW9+mh4oMWyUaQgjiZjzGlnIgER5+7x7SskAmlmKiV\n\tQGSeq3EEWhIO3UJUzzcYv90eijskc6tsEw==","X-Google-Smtp-Source":"ABdhPJz1aisYk5T8AduDL4JK6RFM578sFyxuq4K2akZmdAcabX4In6bhn/+a1DOo8gNyAUsrugiK9g==","X-Received":"by 2002:a63:6b81:: with SMTP id\n\tg123mr363996pgc.140.1638276278058; \n\tTue, 30 Nov 2021 04:44:38 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 30 Nov 2021 21:44:28 +0900","Message-Id":"<20211130124428.2163669-3-hiroh@chromium.org>","X-Mailer":"git-send-email 2.34.0.rc2.393.gf8c9666880-goog","In-Reply-To":"<20211130124428.2163669-1-hiroh@chromium.org>","References":"<20211130124428.2163669-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH 2/2] android: camera_stream: Use\n\tPlatformFrameBufferAllocator","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"CameraStream originally creates FrameBuffers by\nFrameBufferAllocator and thus buffers are allocated in V4L2 API.\nThis replaces the allocator in CameraStream with\nPlatformFrameBufferAllocator. It allocates a buffer in a platform\ndependent graphic buffer allocation API.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/android/camera_stream.cpp | 24 +++++++++++++-----------\n src/android/camera_stream.h   |  5 +++--\n 2 files changed, 16 insertions(+), 13 deletions(-)","diff":"diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp\nindex 9023c13c..d22dd6b3 100644\n--- a/src/android/camera_stream.cpp\n+++ b/src/android/camera_stream.cpp\n@@ -22,6 +22,7 @@\n #include \"camera_capabilities.h\"\n #include \"camera_device.h\"\n #include \"camera_metadata.h\"\n+#include \"frame_buffer_allocator.h\"\n #include \"post_processor.h\"\n \n using namespace libcamera;\n@@ -118,16 +119,8 @@ int CameraStream::configure()\n \t}\n \n \tif (type_ == Type::Internal) {\n-\t\tallocator_ = std::make_unique<FrameBufferAllocator>(cameraDevice_->camera());\n+\t\tallocator_ = std::make_unique<PlatformFrameBufferAllocator>(cameraDevice_);\n \t\tmutex_ = std::make_unique<std::mutex>();\n-\n-\t\tint ret = allocator_->allocate(stream());\n-\t\tif (ret < 0)\n-\t\t\treturn ret;\n-\n-\t\t/* Save a pointer to the reserved frame buffers */\n-\t\tfor (const auto &frameBuffer : allocator_->buffers(stream()))\n-\t\t\tbuffers_.push_back(frameBuffer.get());\n \t}\n \n \tcamera3Stream_->max_buffers = configuration().bufferCount;\n@@ -211,8 +204,17 @@ FrameBuffer *CameraStream::getBuffer()\n \tstd::lock_guard<std::mutex> locker(*mutex_);\n \n \tif (buffers_.empty()) {\n-\t\tLOG(HAL, Error) << \"Buffer underrun\";\n-\t\treturn nullptr;\n+\t\tconst int frameFormat =\n+\t\t\tcameraDevice_->capabilities()->toAndroidFormat(\n+\t\t\t\tconfiguration().pixelFormat);\n+\t\tif (frameFormat == -1)\n+\t\t\treturn nullptr;\n+\n+\t\tauto frameBuffer = allocator_->allocate(frameFormat,\n+\t\t\t\t\t\t\tconfiguration().size,\n+\t\t\t\t\t\t\tcamera3Stream_->usage);\n+\t\tallocatedBuffers_.push_back(std::move(frameBuffer));\n+\t\tbuffers_.emplace_back(allocatedBuffers_.back().get());\n \t}\n \n \tFrameBuffer *buffer = buffers_.back();\ndiff --git a/src/android/camera_stream.h b/src/android/camera_stream.h\nindex 0c402deb..190ac6c0 100644\n--- a/src/android/camera_stream.h\n+++ b/src/android/camera_stream.h\n@@ -19,7 +19,6 @@\n \n #include <libcamera/camera.h>\n #include <libcamera/framebuffer.h>\n-#include <libcamera/framebuffer_allocator.h>\n #include <libcamera/geometry.h>\n #include <libcamera/pixel_format.h>\n \n@@ -27,6 +26,7 @@\n #include \"post_processor.h\"\n \n class CameraDevice;\n+class PlatformFrameBufferAllocator;\n \n class CameraStream\n {\n@@ -168,7 +168,8 @@ private:\n \tcamera3_stream_t *camera3Stream_;\n \tconst unsigned int index_;\n \n-\tstd::unique_ptr<libcamera::FrameBufferAllocator> allocator_;\n+\tstd::unique_ptr<PlatformFrameBufferAllocator> allocator_;\n+\tstd::vector<std::unique_ptr<libcamera::FrameBuffer>> allocatedBuffers_;\n \tstd::vector<libcamera::FrameBuffer *> buffers_;\n \t/*\n \t * The class has to be MoveConstructible as instances are stored in\n","prefixes":["libcamera-devel","2/2"]}