Patch Detail
Show a patch.
GET /api/patches/27027/?format=api
{ "id": 27027, "url": "https://patchwork.libcamera.org/api/patches/27027/?format=api", "web_url": "https://patchwork.libcamera.org/patch/27027/", "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": "<20260624085849.873784-2-bryan.odonoghue@linaro.org>", "date": "2026-06-24T08:58:40", "name": "[01/10] libcamera: v4l2_videodevice: Output cache hit as a parameter", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "990c0026e8812352642ba86f79349ba52320f428", "submitter": { "id": 175, "url": "https://patchwork.libcamera.org/api/people/175/?format=api", "name": "Bryan O'Donoghue", "email": "bryan.odonoghue@linaro.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/27027/mbox/", "series": [ { "id": 6015, "url": "https://patchwork.libcamera.org/api/series/6015/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=6015", "date": "2026-06-24T08:58:39", "name": "libcamera: software_isp: gpu: Add go faster stripes", "version": 1, "mbox": "https://patchwork.libcamera.org/series/6015/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/27027/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/27027/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 7F52CC3306\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Jun 2026 08:59:07 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 39B126587E;\n\tWed, 24 Jun 2026 10:59:03 +0200 (CEST)", "from mail-wm1-x335.google.com (mail-wm1-x335.google.com\n\t[IPv6:2a00:1450:4864:20::335])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5186765871\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jun 2026 10:59:01 +0200 (CEST)", "by mail-wm1-x335.google.com with SMTP id\n\t5b1f17b1804b1-490cf322ed0so7761855e9.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jun 2026 01:59:01 -0700 (PDT)", "from inspiron14p-linux ([109.76.100.231])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-49261063d6esm25128375e9.2.2026.06.24.01.58.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 24 Jun 2026 01:58:59 -0700 (PDT)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"R1B/fOe+\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1782291541; x=1782896341;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=6h4OQ/s+gFr1NSlfpnHCoeE5/7D8tFJMOobc3VjW2hA=;\n\tb=R1B/fOe+2nUG5dz2edWTBmjuBLAHWEY6BsVHKYWtEZK6UMsqCrwAhvcHwkuRpTXblZ\n\tShuNuq4V8VWx2sW2CvR8FLy5hsZXkbwb0zEh4p0qGI7WIoIwcQfEarh0CRLxavNrLdcM\n\tRaaHCcE+j8xDzlWM05Wxe6U1l2krcjfT3z/P84qUsp7HfPzBgYCoa8I29e9W4heDzxCR\n\tMUaaLmbVHVIzBFES57YXNy72fD08/DdopZ0B8NePvESdRWjprz5nbIJ9+vlb+C1SNC/9\n\th72BpV8tOBOnt74wIpI/A72gcIQrzS15s7osZA46lFA2KJ30WrZaBtgCOOItKnE1TFKE\n\tIVxw==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1782291541; x=1782896341;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=6h4OQ/s+gFr1NSlfpnHCoeE5/7D8tFJMOobc3VjW2hA=;\n\tb=MMo+za2IsLETtJPw/ogFaZHhVEwkk2RwM6oHXxBIu7QOcgZPaLhTTtMzWhKZvohdRg\n\tYHiW4uMDOV54Bq6qORd3ud3le84sQe8+5erWGAWbtzxYn4S74E5cQHcrB8xfLy18TrBr\n\tK3yXMmW2a3ImPXYFCUY6Sm1YzPToXRzAFRmp1iN5WGH6E4bkDC8u2Ut0/CyI+xZSpwBL\n\tPCKflktVtMAvsuRBqNpYeR2zQwblmXgDnw5hltPcpCVmBPKZNvGCkbe5cBNAfgxkDsuo\n\t6Sg1Ew7iwPa1PfaHTGvWJp9xLzlkHp4CQt1sGEg0bc/ZFbbbUtkUB3lbOg1p3odmKYtP\n\twEbw==", "X-Gm-Message-State": "AOJu0Ywm7PQFnVYZHTvW0BczBIipH3tzgayWkR5SQ4Q5G0CeHcjZp1jR\n\tFUd1vXJl4kx0ht7eHK/rP55hGbYpvCVM3iYErc1pKT6E3RVePv+yGzTGJbBEVSEkovIJkrVLja4\n\tTa4JqQ8o=", "X-Gm-Gg": "AfdE7ckKlJwO5v8aOXdJdDHcG9atO0n2wTUDOLIeCsaOF4sF2bv/VyDgN9upYyu5DxL\n\tWb41igmbU0omeCxDSCdZJAs/vRSXkSijzmsqOt6vQUhB5cIfQpNRMKvpoyAXCh1RbqyD2jrAcZX\n\tLzPue0N9NicR17Tz/dY49mJ+SMM/nbjUUvC0PyEguAGvcFw3YDzhVkpu/mow/76tFdgCVHzVgxP\n\trDdQpQzuP/GL/yEqskmZvwR6i9IS+MkbT3UwWhtT9ut5+7NWcJAaQfX83vVQmPGTcKYa0s1tfY0\n\tWIopxEfP/rG0zyYG/MXdlXoTh85vLveNQO0JI7/gRkm13cgOOJ89ktA9aDig0ynJtKsU3QzVUa9\n\t6cm7ayM8cHAbyA00RqNaF2G4IJ/GS5sqn82F4RP5kZgDdoBG2pvpBwY8daK48hm/Yj1YAaldFun\n\tX9lIZD8C/SvZT/lmmUc0086nYbGYwIPSQvW2arYdo=", "X-Received": "by 2002:a05:600c:c494:b0:492:5a58:3c6a with SMTP id\n\t5b1f17b1804b1-492608496d5mr29809635e9.5.1782291540786; \n\tWed, 24 Jun 2026 01:59:00 -0700 (PDT)", "From": "Bryan O'Donoghue <bryan.odonoghue@linaro.org>", "To": "libcamera-devel@lists.libcamera.org", "Cc": "bryan.odonoghue@linaro.org,\n\tpavel@ucw.cz", "Subject": "[PATCH 01/10] libcamera: v4l2_videodevice: Output cache hit as a\n\tparameter", "Date": "Wed, 24 Jun 2026 09:58:40 +0100", "Message-ID": "<20260624085849.873784-2-bryan.odonoghue@linaro.org>", "X-Mailer": "git-send-email 2.54.0", "In-Reply-To": "<20260624085849.873784-1-bryan.odonoghue@linaro.org>", "References": "<20260624085849.873784-1-bryan.odonoghue@linaro.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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>", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "The existing V4L2BufferCache::get routine evaluates if a cache hit has\noccured by way of an internal variable. It is in fact very useful to a user\nof this API to understand if a hit has occured as using logic may wish to\ndifferentiate based on hit or miss.\n\nThis differentiation is required for GPUISP. Rather than add a routine to\ninterrogate if a cache hit exists - add an output parameter to the get\nroutine.\n\nIn simple terms if you are trying to cache data about the last thing you\nwant to to is interrogate the cache twice so, a `hit` output parameter adds\na small cost in the stack for a large pivot in using code's ability to\nunderstand how much work it needs to do on hit v miss.\n\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n include/libcamera/internal/v4l2_videodevice.h | 2 +-\n src/libcamera/v4l2_videodevice.cpp | 9 ++++++---\n test/v4l2_videodevice/buffer_cache.cpp | 14 +++++++++-----\n 3 files changed, 16 insertions(+), 9 deletions(-)", "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 10367e4e1..49165a565 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -129,7 +129,7 @@ public:\n \t~V4L2BufferCache();\n \n \tbool isEmpty() const;\n-\tint get(const FrameBuffer &buffer);\n+\tint get(const FrameBuffer &buffer, bool &hit);\n \tvoid put(unsigned int index);\n \n private:\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex ca8759830..6496eb324 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -217,6 +217,7 @@ bool V4L2BufferCache::isEmpty() const\n /**\n * \\brief Find the best V4L2 buffer for a FrameBuffer\n * \\param[in] buffer The FrameBuffer\n+ * \\param[out] hit. Indicates if there was a cache hit\n *\n * Find the best V4L2 buffer index to be used for the FrameBuffer \\a buffer\n * based on previous mappings of frame buffers to V4L2 buffers. If a free V4L2\n@@ -227,12 +228,13 @@ bool V4L2BufferCache::isEmpty() const\n * \\return The index of the best V4L2 buffer, or -ENOENT if no free V4L2 buffer\n * is available\n */\n-int V4L2BufferCache::get(const FrameBuffer &buffer)\n+int V4L2BufferCache::get(const FrameBuffer &buffer, bool &hit)\n {\n-\tbool hit = false;\n \tint use = -1;\n \tuint64_t oldest = UINT64_MAX;\n \n+\thit = false;\n+\n \tfor (unsigned int index = 0; index < cache_.size(); index++) {\n \t\tconst Entry &entry = cache_[index];\n \n@@ -1649,6 +1651,7 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer, const V4L2Request *request\n {\n \tstruct v4l2_plane v4l2Planes[VIDEO_MAX_PLANES] = {};\n \tstruct v4l2_buffer buf = {};\n+\tbool hit;\n \tint ret;\n \n \tif (state_ == State::Stopping) {\n@@ -1666,7 +1669,7 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer, const V4L2Request *request\n \t\treturn -ENOENT;\n \t}\n \n-\tret = cache_->get(*buffer);\n+\tret = cache_->get(*buffer, hit);\n \tif (ret < 0)\n \t\treturn ret;\n \ndiff --git a/test/v4l2_videodevice/buffer_cache.cpp b/test/v4l2_videodevice/buffer_cache.cpp\nindex 613e0d7ce..e41c30059 100644\n--- a/test/v4l2_videodevice/buffer_cache.cpp\n+++ b/test/v4l2_videodevice/buffer_cache.cpp\n@@ -35,7 +35,8 @@ public:\n \t{\n \t\tfor (unsigned int i = 0; i < buffers.size() * 100; i++) {\n \t\t\tint nBuffer = i % buffers.size();\n-\t\t\tint index = cache->get(*buffers[nBuffer].get());\n+\t\t\tbool hit;\n+\t\t\tint index = cache->get(*buffers[nBuffer].get(), hit);\n \n \t\t\tif (index != nBuffer) {\n \t\t\t\tstd::cout << \"Expected index \" << nBuffer\n@@ -60,7 +61,8 @@ public:\n \n \t\tfor (unsigned int i = 0; i < buffers.size() * 100; i++) {\n \t\t\tint nBuffer = dist(generator_);\n-\t\t\tint index = cache->get(*buffers[nBuffer].get());\n+\t\t\tbool hit;\n+\t\t\tint index = cache->get(*buffers[nBuffer].get(), hit);\n \n \t\t\tif (index < 0) {\n \t\t\t\tstd::cout << \"Failed lookup from cache\"\n@@ -90,7 +92,8 @@ public:\n \n \t\t/* Pick a hot buffer at random and store its index. */\n \t\tint hotBuffer = dist(generator_);\n-\t\tint hotIndex = cache->get(*buffers[hotBuffer].get());\n+\t\tbool hit;\n+\t\tint hotIndex = cache->get(*buffers[hotBuffer].get(), hit);\n \t\tcache->put(hotIndex);\n \n \t\t/*\n@@ -106,7 +109,7 @@ public:\n \t\t\telse\n \t\t\t\tnBuffer = dist(generator_);\n \n-\t\t\tindex = cache->get(*buffers[nBuffer].get());\n+\t\t\tindex = cache->get(*buffers[nBuffer].get(), hit);\n \n \t\t\tif (index < 0) {\n \t\t\t\tstd::cout << \"Failed lookup from cache\"\n@@ -135,7 +138,8 @@ public:\n \n \t\tfor (const auto &buffer : buffers) {\n \t\t\tFrameBuffer &b = *buffer.get();\n-\t\t\tcache.get(b);\n+\t\t\tbool hit;\n+\t\t\tcache.get(b, hit);\n \t\t}\n \n \t\tif (cache.isEmpty())\n", "prefixes": [ "01/10" ] }