Patch Detail
Show a patch.
GET /api/1.1/patches/16094/?format=api
{ "id": 16094, "url": "https://patchwork.libcamera.org/api/1.1/patches/16094/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16094/", "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": "<20220527144447.94891-25-tomi.valkeinen@ideasonboard.com>", "date": "2022-05-27T14:44:41", "name": "[libcamera-devel,v3,24/30] 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/1.1/people/109/?format=api", "name": "Tomi Valkeinen", "email": "tomi.valkeinen@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/16094/mbox/", "series": [ { "id": 3146, "url": "https://patchwork.libcamera.org/api/1.1/series/3146/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3146", "date": "2022-05-27T14:44:17", "name": "More misc Python patches", "version": 3, "mbox": "https://patchwork.libcamera.org/series/3146/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/16094/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16094/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 B123EC326E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 May 2022 14:45:36 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 70A186565D;\n\tFri, 27 May 2022 16:45:36 +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 E5F306565C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 May 2022 16:45:16 +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 58F2E10CA;\n\tFri, 27 May 2022 16:45:16 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653662736;\n\tbh=uHPpsYlvDhUb28WKb9TZp8sVFeHN/J/uHXXmuPnsmS8=;\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=d6F4UMDPLJ7tpdQzt6ABXRiE4shjH8w6JoDevXW1L0TCuBWiIXeJ5HkOwQc8pIVLt\n\takCyw8hrLpezEt1/djYnHOaAS5oZ4CSWNazcSuuFyccMXE0eALrJsJ7C1/S70TsT4z\n\tnInRumRhlTnmD5gDIA3+Ipf36uI13l8OE3PUlOE2KbVDxLwjic/ksaUgioFtOn7yqs\n\tbhBLCDtMF3YLneP7zCLjgwde2xZhPKgmmPb6CHb7WbQZKxuggfk0JHogHBLH9+lRio\n\tlc8rrHYtt3oN+fywSzE9FK1VtaDvIsjM9GUIBeBpFL6CfWxKDU1qfi1vHk1dE2wy1M\n\tLJ1tlgVI727UA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653662716;\n\tbh=uHPpsYlvDhUb28WKb9TZp8sVFeHN/J/uHXXmuPnsmS8=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=u81QOrZgvKCvTPk/CNc4Z27JH+vESqBRwWYGkmw3ohSW+OyckaoVBBAYGwdnFuJIW\n\tTB9TrfQg9gDQk66ec1UvYDq0BAziWBWknTaW5Np9Y5+qjef8KXdGyeeM+c8mw0wUnY\n\tiiJ5C0n1P0AixgmTyuLnoSMqJbFAXAOxSj1LZZvs=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"u81QOrZg\"; 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": "Fri, 27 May 2022 17:44:41 +0300", "Message-Id": "<20220527144447.94891-25-tomi.valkeinen@ideasonboard.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20220527144447.94891-1-tomi.valkeinen@ideasonboard.com>", "References": "<20220527144447.94891-1-tomi.valkeinen@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 24/30] 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>\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 69315e76..4b20f904 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", "v3", "24/30" ] }