Patch Detail
Show a patch.
GET /api/1.1/patches/18945/?format=api
{ "id": 18945, "url": "https://patchwork.libcamera.org/api/1.1/patches/18945/?format=api", "web_url": "https://patchwork.libcamera.org/patch/18945/", "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": "<20230821131039.127370-3-gabbymg94@gmail.com>", "date": "2023-08-21T13:10:36", "name": "[libcamera-devel,RFC,v2,2/5] libcamera: MappedFrameBuffer: Use stored plane offset", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "5d49610020d10fe3d7b91bdc3c8e767d2234f162", "submitter": { "id": 160, "url": "https://patchwork.libcamera.org/api/1.1/people/160/?format=api", "name": "Gabrielle George", "email": "gabbymg94@gmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/18945/mbox/", "series": [ { "id": 4004, "url": "https://patchwork.libcamera.org/api/1.1/series/4004/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4004", "date": "2023-08-21T13:10:34", "name": "Add UVC Metadata buffer timestamp support", "version": 2, "mbox": "https://patchwork.libcamera.org/series/4004/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/18945/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/18945/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 9532AC32B0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 21 Aug 2023 13:10:48 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 28305627E2;\n\tMon, 21 Aug 2023 15:10:48 +0200 (CEST)", "from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com\n\t[IPv6:2001:4860:4864:20::2c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 064B561E09\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Aug 2023 15:10:45 +0200 (CEST)", "by mail-oa1-x2c.google.com with SMTP id\n\t586e51a60fabf-1cca0a1b3c7so18548fac.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Aug 2023 06:10:44 -0700 (PDT)", "from localhost.localdomain (97-115-76-16.ptld.qwest.net.\n\t[97.115.76.16]) by smtp.gmail.com with ESMTPSA id\n\tci1-20020a056871c48100b001bb51450d85sm4160283oac.4.2023.08.21.06.10.42\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 21 Aug 2023 06:10:43 -0700 (PDT)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1692623448;\n\tbh=DMCXw05gQo2OpLrAzcVL4l/cyzLBkRuuVkgP6P5OnJs=;\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=R6ET98cO75JqwbCkjIefTgi6VnWjRvU+g3bNPpzFb7qBxmSqoe+9nAXXd08M34C/B\n\tMcZUl6CtrafHJL9Xpn7yYzQMuovMiwRUiAoZdUXvfnw7oraLGPp7FDvuqYcdf9D4G0\n\t/uP76GFrrmROWD/WVVO/Me1hyG0pfUZ9E522ucIBYI+hoHTMvh0gtgM5lfZ7d09YNC\n\tlujzGF2TY+0tQKTBdBZ/c1+UZAqjA6JeyOwJDBxhAEZN2l8LPKYTbtMgHlwo1azDz+\n\txnVD57mhXbKVdHOi9gE1ml4ZQaGQFRFM2wf/oUmGjlTS91ib9agrgbmVglEobWMuF4\n\tFXLVEQa1l/WMQ==", "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20221208; t=1692623443; x=1693228243;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:to:from:from:to:cc:subject:date:message-id\n\t:reply-to; bh=gLWaKmx/cdcNVCylxEJWFcipivTebMrGpD7wATBJy5o=;\n\tb=hqBJSkqa8Ng97Vz8RDYeQtRC/UYBC+PcpnOSFjDCGPLC3b4/lIe1rTyf45eeTYedPO\n\t6kqW2qFshq42FcAosQaF2seOXkkLwwMDfNnDBlxJbzhl0p+bh5MJv5DtXpvlwqtbcxq1\n\tuZsz6rbUXzSIKJ8asSJbPY8Tioy+MO15u0BdPIK/zfk7pJ7SOAhHIY1inRIsh8+nS+8J\n\tuzQLm7LDeEXwbJYcmSzgEJ7sdMleTmt+cSZB5ipwxsUunxzAzscWnDQoMDWzjMr+R+aa\n\t360999vvFvYMVSS9sqtxRFhJnsshKb+UUVIr/DlUdWFb9xOifI+rLyKqym8pmOpyrfhi\n\tWqHw==" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"hqBJSkqa\"; dkim-atps=neutral", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1692623443; x=1693228243;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=gLWaKmx/cdcNVCylxEJWFcipivTebMrGpD7wATBJy5o=;\n\tb=EGg+SLEEqeQfxLNTDKotmc1c3GPLBcaKbmY6Lc+7NALZgrhusNOw9OS6Qh3MkOZZAv\n\tWNnUdv++5VpevVB8jnkVYdWHnKyPirrIIjXHwrvMLU1QbxdnIfOD+A6ExaVQRl/7aSYI\n\tOVtrDF/bFyXPaOXM9tDXwRGfQWewIzLFajBZgwb8XJkUO4pFtbp310ytP66WPaIcoaej\n\takVRIhT2dNkTtjejALgHThpgQYj5dNqfna6Z7T7kbGuc0WNzCRATT7six2+IgzDU+bV3\n\tw1lzSmM6xDt0+YA9q8lLBYOEUzRQTTJT+E6wh2mYv8tBLekMAKT8NC117/Z1T2EgVpkw\n\tSIDw==", "X-Gm-Message-State": "AOJu0Yz6V6zLBhVkb6+jCCYTWkrRygq7MOJJxtMIPRnSYhQyDvkJ7ssD\n\tlKogWalcpVdVSQwBJuocWmLpUDUT4xY=", "X-Google-Smtp-Source": "AGHT+IFe737xihYZsVt677Rbiqp7a+FY84GHAlVGiU7VbU5CLiDUo6Rn9c9HDbqDe9RzwV6+uP+u/w==", "X-Received": "by 2002:a05:6870:40ca:b0:1bc:3f6:579b with SMTP id\n\tl10-20020a05687040ca00b001bc03f6579bmr10132146oal.22.1692623443533; \n\tMon, 21 Aug 2023 06:10:43 -0700 (PDT)", "To": "libcamera-devel@lists.libcamera.org, kieran.bingham@ideasonboard.com,\n\tvedantparanjape160201@gmail.com, gabbymg94@gmail.com", "Date": "Mon, 21 Aug 2023 06:10:36 -0700", "Message-Id": "<20230821131039.127370-3-gabbymg94@gmail.com>", "X-Mailer": "git-send-email 2.34.1", "In-Reply-To": "<20230821131039.127370-1-gabbymg94@gmail.com>", "References": "<20230821131039.127370-1-gabbymg94@gmail.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC PATCH v2 2/5] libcamera: MappedFrameBuffer:\n\tUse stored plane offset", "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": "Gabby George via libcamera-devel <libcamera-devel@lists.libcamera.org>", "Reply-To": "Gabby George <gabbymg94@gmail.com>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "As it is written, the MappedFrameBuffer causes a failure in mmap when\nattempting to map UVC metadata planes. UVC metadata (four character\ncode UVCH) does not support exporting buffers as file descriptors, so\nmmap can be used to give libcamera access to the metadata buffer\nplanes. It is convenient to use the already-existing\nMappedFrameBuffers class, but the class must be modified to support\nmapping using file descriptors of the video node itself.\n\nTo do this, mmap needs information obtained through a call to\nQUERYBUF, namely, the plane offset for buffer planes. Modify the\nconstructor of a MappedFrameBuffer to use the plane offset directly in\nthe call to mmap, rather than the hard-coded 0 value.\n\nThe current version does not work when a buffer cannot be exported as\na dma buf fd. The fd argument to mmap must be the one obtained on a\ncall to open() for the video node (ie, /dev/videoX). This method of\nmapping buffer planes requires the arguments to mmap to be exactly the\nlength and offset QUERYBUF provides. Mmap will return a -EINVAL if\nthis is not the case.\n\nSigned-off-by: Gabby George <gabbymg94@gmail.com>\n---\n .../libcamera/internal/mapped_framebuffer.h | 3 ++-\n src/libcamera/mapped_framebuffer.cpp | 20 ++++++++++++++-----\n 2 files changed, 17 insertions(+), 6 deletions(-)", "diff": "diff --git a/include/libcamera/internal/mapped_framebuffer.h b/include/libcamera/internal/mapped_framebuffer.h\nindex fb39adbf..04096d1b 100644\n--- a/include/libcamera/internal/mapped_framebuffer.h\n+++ b/include/libcamera/internal/mapped_framebuffer.h\n@@ -54,7 +54,8 @@ public:\n \n \tusing MapFlags = Flags<MapFlag>;\n \n-\tMappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags);\n+\tMappedFrameBuffer(const FrameBuffer *buffer,\n+\t\t\t MapFlags flags, bool usePlaneOffset = false);\n };\n \n LIBCAMERA_FLAGS_ENABLE_OPERATORS(MappedFrameBuffer::MapFlag)\ndiff --git a/src/libcamera/mapped_framebuffer.cpp b/src/libcamera/mapped_framebuffer.cpp\nindex 6860069b..3d2cc332 100644\n--- a/src/libcamera/mapped_framebuffer.cpp\n+++ b/src/libcamera/mapped_framebuffer.cpp\n@@ -172,12 +172,13 @@ MappedBuffer::~MappedBuffer()\n * \\brief Map all planes of a FrameBuffer\n * \\param[in] buffer FrameBuffer to be mapped\n * \\param[in] flags Protection flags to apply to map\n+ * \\param[in] usePlaneOffset Use offset stored in buffer's plane; default false\n *\n * Construct an object to map a frame buffer for CPU access. The mapping can be\n * made as Read only, Write only or support Read and Write operations by setting\n * the MapFlag flags accordingly.\n */\n-MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags)\n+MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags, bool usePlaneOffset)\n {\n \tASSERT(!buffer->planes().empty());\n \tplanes_.reserve(buffer->planes().size());\n@@ -223,8 +224,14 @@ MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags)\n \t\tconst int fd = plane.fd.get();\n \t\tauto &info = mappedBuffers[fd];\n \t\tif (!info.address) {\n-\t\t\tvoid *address = mmap(nullptr, info.mapLength, mmapFlags,\n-\t\t\t\t\t MAP_SHARED, fd, 0);\n+\t\t\tvoid *address;\n+\t\t\tif (usePlaneOffset) {\n+\t\t\t\taddress = mmap(nullptr, plane.length, mmapFlags,\n+\t\t\t\t\t MAP_SHARED, fd, plane.offset);\n+\t\t\t} else {\n+\t\t\t\taddress = mmap(nullptr, info.mapLength, mmapFlags,\n+\t\t\t\t\t MAP_SHARED, fd, 0);\n+\t\t\t}\n \t\t\tif (address == MAP_FAILED) {\n \t\t\t\terror_ = -errno;\n \t\t\t\tLOG(Buffer, Error) << \"Failed to mmap plane: \"\n@@ -233,10 +240,13 @@ MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags)\n \t\t\t}\n \n \t\t\tinfo.address = static_cast<uint8_t *>(address);\n-\t\t\tmaps_.emplace_back(info.address, info.mapLength);\n+\t\t\tmaps_.emplace_back(info.address, usePlaneOffset ? plane.length :\n+\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t info.mapLength);\n \t\t}\n \n-\t\tplanes_.emplace_back(info.address + plane.offset, plane.length);\n+\t\tuint8_t *storedAddress = usePlaneOffset ? info.address :\n+\t\t info.address + plane.offset;\n+\t\tplanes_.emplace_back(storedAddress, plane.length);\n \t}\n }\n \n", "prefixes": [ "libcamera-devel", "RFC", "v2", "2/5" ] }