Patch Detail
Show a patch.
GET /api/1.1/patches/9663/?format=api
{ "id": 9663, "url": "https://patchwork.libcamera.org/api/1.1/patches/9663/?format=api", "web_url": "https://patchwork.libcamera.org/patch/9663/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200918135041.91492-6-jacopo@jmondi.org>", "date": "2020-09-18T13:50:38", "name": "[libcamera-devel,v2,5/8] android: camera_device: Allocate buffer pools", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "1c3b813e6b09abbb97d0e69952b254772b15ed57", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/9663/mbox/", "series": [ { "id": 1296, "url": "https://patchwork.libcamera.org/api/1.1/series/1296/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1296", "date": "2020-09-18T13:50:33", "name": "android: camera_device: Add support for internal buffers", "version": 2, "mbox": "https://patchwork.libcamera.org/series/1296/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/9663/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/9663/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 CFFC8BF01C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Sep 2020 13:47:24 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id AEA5362FCB;\n\tFri, 18 Sep 2020 15:47:24 +0200 (CEST)", "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4E1B262FAB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Sep 2020 15:47:22 +0200 (CEST)", "from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 4E28E40010;\n\tFri, 18 Sep 2020 13:47:21 +0000 (UTC)" ], "X-Originating-IP": "93.34.118.233", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 18 Sep 2020 15:50:38 +0200", "Message-Id": "<20200918135041.91492-6-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.28.0", "In-Reply-To": "<20200918135041.91492-1-jacopo@jmondi.org>", "References": "<20200918135041.91492-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v2 5/8] android: camera_device: Allocate\n\tbuffer pools", "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>", "Cc": "hanlinchen@chromium.org", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "After the Camera has been configured, walk the list of collected\nCameraStream instances and allocate memory for the ones that needs\nintermediate buffers reserved by the libcamera FrameBufferAllocator.\n\nMaintain a map between each Stream and a vector of pointers to the\nassociated buffers.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 36 +++++++++++++++++++++++++++++++++++\n src/android/camera_device.h | 6 ++++++\n 2 files changed, 42 insertions(+)", "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 42fb9ea4e113..f96ea7321a67 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1189,6 +1189,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \tstreams_.clear();\n \tstreams_.reserve(stream_list->num_streams);\n \tallocator_.clear();\n+\tbufferPool_.clear();\n \n \t/* First handle all non-MJPEG streams. */\n \tcamera3_stream_t *jpegStream = nullptr;\n@@ -1336,6 +1337,25 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)\n \t\treturn ret;\n \t}\n \n+\t/*\n+\t * Now that the camera has been configured allocate buffers for\n+\t * the streams that need memory reserved by libcamera.\n+\t */\n+\tfor (const CameraStream &cameraStream : streams_) {\n+\t\tconst StreamConfiguration &cfg = config_->at(cameraStream.index());\n+\t\tStream *stream = cfg.stream();\n+\n+\t\tif (cameraStream.type() != CameraStream::Type::Internal)\n+\t\t\tcontinue;\n+\n+\t\tret = allocateBuffersPool(stream);\n+\t\tif (ret) {\n+\t\t\tLOG(HAL, Error) << \"Failed to allocate buffers for stream \"\n+\t\t\t\t\t<< cameraStream.index();\n+\t\t\treturn ret;\n+\t\t}\n+\t}\n+\n \treturn 0;\n }\n \n@@ -1369,6 +1389,22 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer\n \treturn new FrameBuffer(std::move(planes));\n }\n \n+int CameraDevice::allocateBuffersPool(Stream *stream)\n+{\n+\tint ret = allocator_.allocate(stream);\n+\tif (ret < 0)\n+\t\treturn ret;\n+\n+\t/*\n+\t * Save a pointer to the reserved frame buffer for usage in\n+\t * the HAL.\n+\t */\n+\tfor (const auto &frameBuffer : allocator_.buffers(stream))\n+\t\tbufferPool_[stream].push_back(frameBuffer.get());\n+\n+\treturn 0;\n+}\n+\n int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request)\n {\n \tif (!camera3Request->num_output_buffers) {\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 84f636f7a93c..4cef34c01a49 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -166,6 +166,9 @@ protected:\n \tstd::string logPrefix() const override;\n \n private:\n+\tusing FrameBufferPool = std::map<libcamera::Stream *,\n+\t\t\t\t\t std::vector<libcamera::FrameBuffer *>>;\n+\n \tCameraDevice(unsigned int id, const std::shared_ptr<libcamera::Camera> &camera);\n \n \tstruct Camera3RequestDescriptor {\n@@ -194,6 +197,8 @@ private:\n \n \tstd::tuple<uint32_t, uint32_t> calculateStaticMetadataSize();\n \tlibcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);\n+\tint allocateBuffersPool(libcamera::Stream *stream);\n+\n \tvoid notifyShutter(uint32_t frameNumber, uint64_t timestamp);\n \tvoid notifyError(uint32_t frameNumber, camera3_stream_t *stream);\n \tCameraMetadata *requestTemplatePreview();\n@@ -208,6 +213,7 @@ private:\n \tstd::shared_ptr<libcamera::Camera> camera_;\n \tstd::unique_ptr<libcamera::CameraConfiguration> config_;\n \tlibcamera::FrameBufferAllocator allocator_;\n+\tFrameBufferPool bufferPool_;\n \n \tCameraMetadata *staticMetadata_;\n \tstd::map<unsigned int, const CameraMetadata *> requestTemplates_;\n", "prefixes": [ "libcamera-devel", "v2", "5/8" ] }