Patch Detail
Show a patch.
GET /api/patches/16115/?format=api
{ "id": 16115, "url": "https://patchwork.libcamera.org/api/patches/16115/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16115/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20220530142722.57618-9-tomi.valkeinen@ideasonboard.com>", "date": "2022-05-30T14:27:14", "name": "[libcamera-devel,v4,08/16] py: MappedFrameBuffer: Support non-contextmanager use", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "76073f2cb2f68edc773ee81f4af2436ca529546d", "submitter": { "id": 109, "url": "https://patchwork.libcamera.org/api/people/109/?format=api", "name": "Tomi Valkeinen", "email": "tomi.valkeinen@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16115/mbox/", "series": [ { "id": 3149, "url": "https://patchwork.libcamera.org/api/series/3149/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3149", "date": "2022-05-30T14:27:06", "name": "More misc Python patches", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3149/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16115/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16115/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 E84B6C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 May 2022 14:27:51 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 864526564D;\n\tMon, 30 May 2022 16:27:51 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5E22560411\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 May 2022 16:27:43 +0200 (CEST)", "from deskari.lan (91-156-85-209.elisa-laajakaista.fi\n\t[91.156.85.209])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BE0821287;\n\tMon, 30 May 2022 16:27:42 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653920871;\n\tbh=UkzTO1W+wg3gwxN5XqnlVlliRzafRc+gxBtG4GGaOsU=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=K0bAJSy/9T83aftfJgfvp2F1JBZ8XcY1Rou3f6Q3clcSTdzTOqulQ/Zrj5/E4IDxm\n\tYVoeB35x+tuEHOszjVWyRSX6kwkOoyUYHc1+VXkFATrv+sSenr65h6fBqR+YJbtsWm\n\tOf4KpTvgB3xerEyQiirIOImeS2dcAua6wZyzooMOsSM0mBRiwHrUIpE5Zw92B4hC+t\n\tDotcW13ihk6twEwlZ4yeATNUpkVkB3gletzjkLAZlBSHrUuCOxI/mgsje/XupKrTxm\n\tbBnen4kZQPrcQilHL/7L+2rsb6sLK+outgdkGxu7m9hEsuWBHlYHKHA6Two8oTvFAg\n\ttcvsoL14E6m7Q==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653920863;\n\tbh=UkzTO1W+wg3gwxN5XqnlVlliRzafRc+gxBtG4GGaOsU=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=OlVcfBir3IORTor3L/JhhasXzh+BrpL3dUrLcD/RF2ZwaL+kx03V5vp5le8Gf2+uj\n\ttro5IQPnNJjxz4EFW8vC/xE9H1dNxQgGsRUUO3kh1p6uPmlMpEkN8+tvvNxyFXFKf1\n\t+sAMZIoQrVpoFv3G622jD0Yzr1/+jOa+pMp7K3Q0=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"OlVcfBir\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org,\n\tDavid Plowman <david.plowman@raspberrypi.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo@jmondi.org>", "Date": "Mon, 30 May 2022 17:27:14 +0300", "Message-Id": "<20220530142722.57618-9-tomi.valkeinen@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220530142722.57618-1-tomi.valkeinen@ideasonboard.com>", "References": "<20220530142722.57618-1-tomi.valkeinen@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 08/16] py: MappedFrameBuffer: Support\n\tnon-contextmanager use", "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>", "From": "Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>", "Reply-To": "Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Implement non-contextmanager use to MappedFrameBuffer so that we can\neither:\n\nwith MappedFrameBuffer(fb) as mfb:\n\t...\n\nor\n\nmfb = MappedFrameBuffer(fb)\nmfb.mmap()\n...\nmfb.munmap()\n\nWhile at it, improve the error handling a bit.\n\nNote that the mmap() returns self. In other words, one can do this:\n\nmfb = MappedFrameBuffer(fb).mmap()\n...\nmfb.munmap()\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/py/libcamera/utils/MappedFrameBuffer.py | 22 ++++++++++++++++++++-\n 1 file changed, 21 insertions(+), 1 deletion(-)", "diff": "diff --git a/src/py/libcamera/utils/MappedFrameBuffer.py b/src/py/libcamera/utils/MappedFrameBuffer.py\nindex a8502d51..c300a6d7 100644\n--- a/src/py/libcamera/utils/MappedFrameBuffer.py\n+++ b/src/py/libcamera/utils/MappedFrameBuffer.py\n@@ -10,8 +10,19 @@ class MappedFrameBuffer:\n \"\"\"\n def __init__(self, fb: libcamera.FrameBuffer):\n self.__fb = fb\n+ self.__planes = ()\n+ self.__maps = ()\n \n def __enter__(self):\n+ return self.mmap()\n+\n+ def __exit__(self, exc_type, exc_value, exc_traceback):\n+ self.munmap()\n+\n+ def mmap(self):\n+ if self.__planes:\n+ raise RuntimeError('MappedFrameBuffer already mmapped')\n+\n import os\n import mmap\n \n@@ -68,14 +79,23 @@ class MappedFrameBuffer:\n \n return self\n \n- def __exit__(self, exc_type, exc_value, exc_traceback):\n+ def munmap(self):\n+ if not self.__planes:\n+ raise RuntimeError('MappedFrameBuffer not mmapped')\n+\n for p in self.__planes:\n p.release()\n \n for mm in self.__maps:\n mm.close()\n \n+ self.__planes = ()\n+ self.__maps = ()\n+\n @property\n def planes(self) -> Tuple[memoryview, ...]:\n \"\"\"memoryviews for the planes\"\"\"\n+ if not self.__planes:\n+ raise RuntimeError('MappedFrameBuffer not mmapped')\n+\n return self.__planes\n", "prefixes": [ "libcamera-devel", "v4", "08/16" ] }