Patch Detail
Show a patch.
GET /api/1.1/patches/11395/?format=api
{ "id": 11395, "url": "https://patchwork.libcamera.org/api/1.1/patches/11395/?format=api", "web_url": "https://patchwork.libcamera.org/patch/11395/", "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": "<20210226132932.165484-3-jacopo@jmondi.org>", "date": "2021-02-26T13:29:22", "name": "[libcamera-devel,02/12] android: Introduce CameraBuffer interface", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "2070cf33bccb26bb2eca120fd0469be05d35b172", "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/11395/mbox/", "series": [ { "id": 1731, "url": "https://patchwork.libcamera.org/api/1.1/series/1731/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1731", "date": "2021-02-26T13:29:20", "name": "android: Support memory backends", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1731/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/11395/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/11395/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 2DC1FBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 26 Feb 2021 13:29:19 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7374C68A64;\n\tFri, 26 Feb 2021 14:29:16 +0100 (CET)", "from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[217.70.178.232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E0AAC60106\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Feb 2021 14:29:13 +0100 (CET)", "from uno.LocalDomain (93-61-96-190.ip145.fastwebnet.it\n\t[93.61.96.190]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay12.mail.gandi.net (Postfix) with ESMTPSA id A4C77200005\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 26 Feb 2021 13:29:13 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 26 Feb 2021 14:29:22 +0100", "Message-Id": "<20210226132932.165484-3-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.30.0", "In-Reply-To": "<20210226132932.165484-1-jacopo@jmondi.org>", "References": "<20210226132932.165484-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 02/12] android: Introduce CameraBuffer\n\tinterface", "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>", "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": "In order to provide support for different memory backends,\nmove the MappedCamera3Buffer class definition outside of the\nCameraDevice class to its own file.\n\nThe interface defined in camera_buffer.h will be implemented by\ndifferent backends that will be placed in the src/android/mm\nsubdirectory.\n\nProvide a first implementation for the 'generic android' backend which\nmatches the existing one.\n\nThe MappedCamera3Buffer interface will be renamed in CameraBuffer\nin the next patch to match the name of the file and not in this patch\nto ease review.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_buffer.h | 21 ++++++++++\n src/android/camera_device.cpp | 30 --------------\n src/android/camera_device.h | 7 +---\n src/android/meson.build | 2 +\n src/android/mm/android_generic_buffer.cpp | 48 +++++++++++++++++++++++\n src/android/mm/meson.build | 6 +++\n 6 files changed, 78 insertions(+), 36 deletions(-)\n create mode 100644 src/android/camera_buffer.h\n create mode 100644 src/android/mm/android_generic_buffer.cpp\n create mode 100644 src/android/mm/meson.build", "diff": "diff --git a/src/android/camera_buffer.h b/src/android/camera_buffer.h\nnew file mode 100644\nindex 000000000000..a1fb97a3c6db\n--- /dev/null\n+++ b/src/android/camera_buffer.h\n@@ -0,0 +1,21 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google Inc.\n+ *\n+ * camera_buffer.h - Frame buffer handling interface definition\n+ */\n+#ifndef __ANDROID_CAMERA_BUFFER_H__\n+#define __ANDROID_CAMERA_BUFFER_H__\n+\n+#include <hardware/camera3.h>\n+\n+#include <libcamera/internal/buffer.h>\n+\n+class MappedCamera3Buffer : public libcamera::MappedBuffer\n+{\n+public:\n+\tMappedCamera3Buffer(const buffer_handle_t camera3buffer, int flags);\n+\t~MappedCamera3Buffer();\n+};\n+\n+#endif /* __ANDROID_CAMERA_BUFFER_H__ */\ndiff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 16cb8c6d2b84..a7a5b7986aa4 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -257,36 +257,6 @@ void sortCamera3StreamConfigs(std::vector<Camera3StreamConfig> &unsortedConfigs,\n \n } /* namespace */\n \n-MappedCamera3Buffer::MappedCamera3Buffer(const buffer_handle_t camera3buffer,\n-\t\t\t\t\t int flags)\n-{\n-\tmaps_.reserve(camera3buffer->numFds);\n-\terror_ = 0;\n-\n-\tfor (int i = 0; i < camera3buffer->numFds; i++) {\n-\t\tif (camera3buffer->data[i] == -1)\n-\t\t\tcontinue;\n-\n-\t\toff_t length = lseek(camera3buffer->data[i], 0, SEEK_END);\n-\t\tif (length < 0) {\n-\t\t\terror_ = -errno;\n-\t\t\tLOG(HAL, Error) << \"Failed to query plane length\";\n-\t\t\tbreak;\n-\t\t}\n-\n-\t\tvoid *address = mmap(nullptr, length, flags, MAP_SHARED,\n-\t\t\t\t camera3buffer->data[i], 0);\n-\t\tif (address == MAP_FAILED) {\n-\t\t\terror_ = -errno;\n-\t\t\tLOG(HAL, Error) << \"Failed to mmap plane\";\n-\t\t\tbreak;\n-\t\t}\n-\n-\t\tmaps_.emplace_back(static_cast<uint8_t *>(address),\n-\t\t\t\t static_cast<size_t>(length));\n-\t}\n-}\n-\n /*\n * \\struct Camera3RequestDescriptor\n *\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 9cbfcad38433..e6c192c2100b 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -24,17 +24,12 @@\n #include \"libcamera/internal/log.h\"\n #include \"libcamera/internal/message.h\"\n \n+#include \"camera_buffer.h\"\n #include \"camera_metadata.h\"\n #include \"camera_stream.h\"\n #include \"camera_worker.h\"\n #include \"jpeg/encoder.h\"\n \n-class MappedCamera3Buffer : public libcamera::MappedBuffer\n-{\n-public:\n-\tMappedCamera3Buffer(const buffer_handle_t camera3buffer, int flags);\n-};\n-\n class CameraDevice : protected libcamera::Loggable\n {\n public:\ndiff --git a/src/android/meson.build b/src/android/meson.build\nindex a13ce63b1d58..fd41c74f78ef 100644\n--- a/src/android/meson.build\n+++ b/src/android/meson.build\n@@ -57,6 +57,8 @@ android_hal_sources = files([\n 'yuv/post_processor_yuv.cpp'\n ])\n \n+subdir('mm')\n+\n android_camera_metadata_sources = files([\n 'metadata/camera_metadata.c',\n ])\ndiff --git a/src/android/mm/android_generic_buffer.cpp b/src/android/mm/android_generic_buffer.cpp\nnew file mode 100644\nindex 000000000000..2504d9276e9e\n--- /dev/null\n+++ b/src/android/mm/android_generic_buffer.cpp\n@@ -0,0 +1,48 @@\n+/* SPDX-License-Identifier: LGPL-2.1-or-later */\n+/*\n+ * Copyright (C) 2021, Google Inc.\n+ *\n+ * android_generic_buffer.cpp - Generic Android frame buffer backend\n+ */\n+\n+#include \"../camera_buffer.h\"\n+\n+#include \"libcamera/internal/log.h\"\n+\n+using namespace libcamera;\n+\n+LOG_DECLARE_CATEGORY(HAL)\n+\n+MappedCamera3Buffer::MappedCamera3Buffer(const buffer_handle_t camera3buffer,\n+\t\t\t\t\t int flags)\n+{\n+\tmaps_.reserve(camera3buffer->numFds);\n+\terror_ = 0;\n+\n+\tfor (int i = 0; i < camera3buffer->numFds; i++) {\n+\t\tif (camera3buffer->data[i] == -1)\n+\t\t\tcontinue;\n+\n+\t\toff_t length = lseek(camera3buffer->data[i], 0, SEEK_END);\n+\t\tif (length < 0) {\n+\t\t\terror_ = -errno;\n+\t\t\tLOG(HAL, Error) << \"Failed to query plane length\";\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tvoid *address = mmap(nullptr, length, flags, MAP_SHARED,\n+\t\t\t\t camera3buffer->data[i], 0);\n+\t\tif (address == MAP_FAILED) {\n+\t\t\terror_ = -errno;\n+\t\t\tLOG(HAL, Error) << \"Failed to mmap plane\";\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tmaps_.emplace_back(static_cast<uint8_t *>(address),\n+\t\t\t\t static_cast<size_t>(length));\n+\t}\n+}\n+\n+MappedCamera3Buffer::~MappedCamera3Buffer()\n+{\n+}\ndiff --git a/src/android/mm/meson.build b/src/android/mm/meson.build\nnew file mode 100644\nindex 000000000000..39be8fec8567\n--- /dev/null\n+++ b/src/android/mm/meson.build\n@@ -0,0 +1,6 @@\n+# SPDX-License-Identifier: CC0-1.0\n+\n+memory_backend = get_option('android_memory_backend')\n+if memory_backend == 'android_generic'\n+ android_hal_sources += files(['android_generic_buffer.cpp'])\n+endif\n", "prefixes": [ "libcamera-devel", "02/12" ] }