Patch Detail
Show a patch.
GET /api/1.1/patches/3113/?format=api
{ "id": 3113, "url": "https://patchwork.libcamera.org/api/1.1/patches/3113/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3113/", "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": "<20200316024146.2474424-5-niklas.soderlund@ragnatech.se>", "date": "2020-03-16T02:41:44", "name": "[libcamera-devel,RFC,4/6] libcamera: buffer: Add helper to memcopy a FrameBuffer", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "adff3681a18bad9ac5237432d8041e1645c5e515", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": { "id": 16, "url": "https://patchwork.libcamera.org/api/1.1/users/16/?format=api", "username": "neg", "first_name": "Niklas", "last_name": "Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "mbox": "https://patchwork.libcamera.org/patch/3113/mbox/", "series": [ { "id": 722, "url": "https://patchwork.libcamera.org/api/1.1/series/722/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=722", "date": "2020-03-16T02:41:40", "name": "libcamera: Add support for a RAW still capture stream", "version": 1, "mbox": "https://patchwork.libcamera.org/series/722/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3113/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3113/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BD1760417\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Mar 2020 03:42:33 +0100 (CET)", "from bismarck.berto.se (p4fca2392.dip0.t-ipconnect.de\n\t[79.202.35.146]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid b7223de9-672f-11ea-9f40-0050569116f7;\n\tMon, 16 Mar 2020 03:42:02 +0100 (CET)" ], "X-Halon-ID": "b7223de9-672f-11ea-9f40-0050569116f7", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 16 Mar 2020 03:41:44 +0100", "Message-Id": "<20200316024146.2474424-5-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.25.1", "In-Reply-To": "<20200316024146.2474424-1-niklas.soderlund@ragnatech.se>", "References": "<20200316024146.2474424-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC 4/6] libcamera: buffer: Add helper to\n\tmemcopy a FrameBuffer", "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>", "X-List-Received-Date": "Mon, 16 Mar 2020 02:42:33 -0000" }, "content": "This helper may be used to memory copy a while FrameBuffer content to\nanother buffer. The operation is not fast and should not be used without\ngrate care by pipelines.\n\nThe intended use-case is to have an option to copy out RAW buffers from\nthe middle of an pipeline.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/buffer.h | 1 +\n src/libcamera/buffer.cpp | 43 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 44 insertions(+)", "diff": "diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h\nindex 8e5ec699e3925eee..669d2591a90e5f37 100644\n--- a/include/libcamera/buffer.h\n+++ b/include/libcamera/buffer.h\n@@ -60,6 +60,7 @@ public:\n private:\n \tfriend class Request; /* Needed to update request_. */\n \tfriend class V4L2VideoDevice; /* Needed to update metadata_. */\n+\tfriend int FrameBufferMemCopy(FrameBuffer *destination, const FrameBuffer *source);\n \n \tstd::vector<Plane> planes_;\n \ndiff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp\nindex 673a63d3d1658190..f680d1879b57a68b 100644\n--- a/src/libcamera/buffer.cpp\n+++ b/src/libcamera/buffer.cpp\n@@ -211,4 +211,47 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)\n * core never modifies the buffer cookie.\n */\n \n+int FrameBufferMemCopy(FrameBuffer *dst, const FrameBuffer *src)\n+{\n+\tif (dst->planes_.size() != src->planes_.size()) {\n+\t\tLOG(Buffer, Error) << \"Different number of planes\";\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tfor (unsigned int i = 0; i < dst->planes_.size(); i++) {\n+\t\tif (dst->planes_[i].length < src->planes_[i].length) {\n+\t\t\tLOG(Buffer, Error) << \"Plane \" << i << \" is too small\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\t}\n+\n+\tfor (unsigned int i = 0; i < dst->planes_.size(); i++) {\n+\t\tvoid *out = mmap(NULL, dst->planes_[i].length, PROT_WRITE, MAP_SHARED,\n+\t\t\t dst->planes_[i].fd.fd(), 0);\n+\n+\t\tif (out == MAP_FAILED) {\n+\t\t\tLOG(Buffer, Error) << \"Failed to map output plane \" << i;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tvoid *in = mmap(NULL, src->planes_[i].length, PROT_READ, MAP_SHARED,\n+\t\t\t src->planes_[i].fd.fd(), 0);\n+\n+\t\tif (in == MAP_FAILED) {\n+\t\t\tmunmap(out, dst->planes_[i].length);\n+\t\t\tLOG(Buffer, Error) << \"Failed to map input plane \" << i;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tmemcpy(out, in, src->planes_[i].length);\n+\n+\t\tmunmap(in, src->planes_[i].length);\n+\t\tmunmap(out, dst->planes_[i].length);\n+\t}\n+\n+\tdst->metadata_ = src->metadata_;\n+\n+\treturn 0;\n+}\n+\n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "RFC", "4/6" ] }