Patch Detail
Show a patch.
GET /api/patches/16117/?format=api
{ "id": 16117, "url": "https://patchwork.libcamera.org/api/patches/16117/?format=api", "web_url": "https://patchwork.libcamera.org/patch/16117/", "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-11-tomi.valkeinen@ideasonboard.com>", "date": "2022-05-30T14:27:16", "name": "[libcamera-devel,v4,10/16] py: cam: cam_qt: mmap the fbs only once", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "1822c7e45b3ea4a12c2363810b59bee2d9c4d82a", "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/16117/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/16117/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/16117/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 87ED7C3274\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 30 May 2022 14:27:53 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E82E165645;\n\tMon, 30 May 2022 16:27:52 +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 6841165647\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 30 May 2022 16:27:44 +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 CC021110E;\n\tMon, 30 May 2022 16:27:43 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653920872;\n\tbh=n+W+jX0Fs4ev88/WDptxjT/u3x5ep0kwU/KdgsI3Z4w=;\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=B47wvHVEUC25FmY6oiuctty3PDy2IsxW/XtZ1Yvvz2oe0V5NVXu9P5QNh7aljnuU4\n\t2pSTmVJl18NbXoDah5Qa1UTeCFW+vpGlCpwh969MKsNEErVkDfeKBt9cpMTFPIGuaM\n\t07gPhiuUQ+pLMCl1dWndHGpu90iAWkITHHdB+X27MVJMjiImDT1+eYYtdb1TK0ZJa/\n\t+Ediv6374K+4kIts8m88ohAQaWOwiOr7EViSui04ebX1EKkITLkhsmVODfSfTYzn26\n\tjfMX5hLlEQj7y/JUW9wEQrGS5vfBUtFFAcMKv7x3+LSF4LEkth40+PGDo7+3b7HBYm\n\tCdQOaobFQ/nlQ==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653920864;\n\tbh=n+W+jX0Fs4ev88/WDptxjT/u3x5ep0kwU/KdgsI3Z4w=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=WlFi6YWq8VkpYZMmY5s4KIftdrNBW+1c5n+c1LO6igBRMwy1DeYjsTKRnrRFCs+el\n\tXkNz0172pLjMWcMDo5AJtC/J1Z9YZ6NAy0MV224pN0w4N1ertWIUSAInVBT+DPoc3f\n\tlCs7yDe6viHlHRf0RtUXQi6ghQm38l/ZTdrvXexQ=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"WlFi6YWq\"; 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:16 +0300", "Message-Id": "<20220530142722.57618-11-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 10/16] py: cam: cam_qt: mmap the fbs\n\tonly once", "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": "Instead of doing an mmap and munmap every time a Request is complete,\nmmap all the buffers once at the start of the program.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/py/cam/cam_qt.py | 39 +++++++++++++++++++++++++--------------\n 1 file changed, 25 insertions(+), 14 deletions(-)", "diff": "diff --git a/src/py/cam/cam_qt.py b/src/py/cam/cam_qt.py\nindex b6412bdf..c1723b44 100644\n--- a/src/py/cam/cam_qt.py\n+++ b/src/py/cam/cam_qt.py\n@@ -52,6 +52,16 @@ class QtRenderer:\n \n self.windows = windows\n \n+ buf_mmap_map = {}\n+\n+ for ctx in self.contexts:\n+ for stream in ctx.streams:\n+ for buf in ctx.allocator.buffers(stream):\n+ mfb = libcamera.utils.MappedFrameBuffer(buf).mmap()\n+ buf_mmap_map[buf] = mfb\n+\n+ self.buf_mmap_map = buf_mmap_map\n+\n def run(self):\n camnotif = QtCore.QSocketNotifier(self.cm.event_fd, QtCore.QSocketNotifier.Read)\n camnotif.activated.connect(lambda _: self.readcam())\n@@ -81,7 +91,9 @@ class QtRenderer:\n for stream, fb in buffers.items():\n wnd = next(wnd for wnd in self.windows if wnd.stream == stream)\n \n- wnd.handle_request(stream, fb)\n+ mfb = self.buf_mmap_map[fb]\n+\n+ wnd.handle_request(stream, mfb)\n \n self.state.request_processed(ctx, req)\n \n@@ -145,26 +157,25 @@ class MainWindow(QtWidgets.QWidget):\n \n controlsLayout.addStretch()\n \n- def buf_to_qpixmap(self, stream, fb):\n- with libcamera.utils.MappedFrameBuffer(fb) as mfb:\n- cfg = stream.configuration\n+ def buf_to_qpixmap(self, stream, mfb):\n+ cfg = stream.configuration\n \n- if cfg.pixel_format == libcam.formats.MJPEG:\n- pix = QtGui.QPixmap(cfg.size.width, cfg.size.height)\n- pix.loadFromData(mfb.planes[0])\n- else:\n- rgb = mfb_to_rgb(mfb, cfg)\n- if rgb is None:\n- raise Exception('Format not supported: ' + cfg.pixel_format)\n+ if cfg.pixel_format == libcam.formats.MJPEG:\n+ pix = QtGui.QPixmap(cfg.size.width, cfg.size.height)\n+ pix.loadFromData(mfb.planes[0])\n+ else:\n+ rgb = mfb_to_rgb(mfb, cfg)\n+ if rgb is None:\n+ raise Exception('Format not supported: ' + cfg.pixel_format)\n \n- pix = rgb_to_pix(rgb)\n+ pix = rgb_to_pix(rgb)\n \n return pix\n \n- def handle_request(self, stream, fb):\n+ def handle_request(self, stream, mfb):\n ctx = self.ctx\n \n- pix = self.buf_to_qpixmap(stream, fb)\n+ pix = self.buf_to_qpixmap(stream, mfb)\n self.label.setPixmap(pix)\n \n self.frameLabel.setText('Queued: {}\\nDone: {}\\nFps: {:.2f}'\n", "prefixes": [ "libcamera-devel", "v4", "10/16" ] }