{"id":8900,"url":"https://patchwork.libcamera.org/api/1.1/patches/8900/?format=json","web_url":"https://patchwork.libcamera.org/patch/8900/","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":"<20200720224232.153717-9-kieran.bingham@ideasonboard.com>","date":"2020-07-20T22:42:32","name":"[libcamera-devel,RFC,8/8] RFC-Only: android: camera_device: Provide a MappedCamera3Buffer","commit_ref":null,"pull_url":null,"state":"rfc","archived":false,"hash":"c6a871ae3f1f61417445f3d3ade94f4e22df678d","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/1.1/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8900/mbox/","series":[{"id":1119,"url":"https://patchwork.libcamera.org/api/1.1/series/1119/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1119","date":"2020-07-20T22:42:24","name":"RFC MappedBuffers","version":1,"mbox":"https://patchwork.libcamera.org/series/1119/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8900/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8900/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 816D4C0109\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 Jul 2020 22:42:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4A1BD605C6;\n\tTue, 21 Jul 2020 00:42:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C9F7460868\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Jul 2020 00:42:39 +0200 (CEST)","from localhost.localdomain\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 66A8F2A4;\n\tTue, 21 Jul 2020 00:42:39 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"RlrB1Mpp\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1595284959;\n\tbh=b+RJdw7AB5+v7lD8xvW9oNeJ88FYZV30jIahUr+L2/s=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=RlrB1MppXjoINy8Oic1BAU82SCRU3ZjsmLoYksFyTO02cIRtbmsHbi0EC7YP/iYzh\n\t4P+ea9Ot5OeyAtSMdaQqC1cvcgXwehZJdHOl1Temq9XgXhyjCJMEDtU0UhGuzXEMkJ\n\t9fSB2EXD2gGuvkAfEzY/kwMe4HPRGg9QuFZ8qpfU=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Mon, 20 Jul 2020 23:42:32 +0100","Message-Id":"<20200720224232.153717-9-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200720224232.153717-1-kieran.bingham@ideasonboard.com>","References":"<20200720224232.153717-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [RFC PATCH 8/8] RFC-Only: android: camera_device:\n\tProvide a MappedCamera3Buffer","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":"Utilise the MappedBuffer interface to map each of the planes provided\nin the Camera3 buffer to facilitate use in software streams.\n\nThe buffers will be automatically unmapped when the object goes out of\nscope or is deleted.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n\nThis patch shows an addition of a new MappedBuffer type constructed from\na camera3buffer. The base class deals with the move-constructors and\ndestructor, and gives us a common interface to pass a set of mapped\ndmabufs around.\n\nI had hoped to use this to pass in the camera3buffer for writing jpeg\nbuffers to, giving the same interface for both the source and\ndestination buffer - but for JPEG, I do also need to return the number\nof bytes actually consumed, so this ended up potentially not adding the\nbenefits I hoped for.\n\nStill, it might still provide some benefits, so I've included it here as\nsomething to talk about.\n\n--\nKieran\n\n\n src/android/camera_device.cpp | 33 +++++++++++++++++++++++++++++++++\n 1 file changed, 33 insertions(+)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 6212ccdd61ec..f78486117e9f 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -86,6 +86,39 @@ const std::map<int, const Camera3Format> camera3FormatsMap = {\n \n LOG_DECLARE_CATEGORY(HAL);\n \n+class MappedCamera3Buffer : public MappedBuffer {\n+public:\n+\tMappedCamera3Buffer(const buffer_handle_t camera3buffer, int flags)\n+\t{\n+\t\tmaps_.reserve(camera3buffer->numFds);\n+\t\terror_ = 0;\n+\n+\t\tfor (int i = 0; i < camera3buffer->numFds; i++) {\n+\t\t\tif (camera3buffer->data[i] == -1)\n+\t\t\t\tcontinue;\n+\n+\t\t\toff_t length = lseek(camera3buffer->data[i], 0, SEEK_END);\n+\t\t\tif (length < 0) {\n+\t\t\t\terror_  = errno;\n+\t\t\t\tLOG(HAL, Error) << \"Failed to query plane length\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tvoid *address = mmap(nullptr, length, flags, MAP_SHARED,\n+\t\t\t\t\tcamera3buffer->data[i], 0);\n+\t\t\tif (address == MAP_FAILED) {\n+\t\t\t\terror_ = errno;\n+\t\t\t\tLOG(HAL, Error) << \"Failed to mmap plane\";\n+\t\t\t\tbreak;\n+\t\t\t}\n+\n+\t\t\tmaps_.push_back({address, static_cast<size_t>(length)});\n+\t\t}\n+\n+\t\tvalid_ = error_ == 0;\n+\t}\n+};\n+\n /*\n  * \\struct Camera3RequestDescriptor\n  *\n","prefixes":["libcamera-devel","RFC","8/8"]}