From patchwork Thu Jun 18 12:38:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 26987 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4F180C3329 for ; Thu, 18 Jun 2026 12:39:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4F20C6571B; Thu, 18 Jun 2026 14:39:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PHW0wEEW"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 51F8362988 for ; Thu, 18 Jun 2026 14:38:53 +0200 (CEST) Received: from pb-laptop.local (185.182.214.63.nat.pool.zt.hu [185.182.214.63]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6C314DF3 for ; Thu, 18 Jun 2026 14:38:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1781786298; bh=sopiKBDQMtAt07ooCAVtMn05RUsUGv007Kpx1frGX9s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=PHW0wEEWkCZ58pFgwQjK4geQ8tMk9UWux2UthiBkwScSTrKzL+ESRfXMxpAAASHOA zXmHjMYY4Nnw0qnuwZbX5+JOV6RIQ8U9YfXeHcDXaGvCJpD5kUQ1Sxs+7vcZWkIxmE HUunU/1pqI0Kp0pNoHqTYzEXsOpLHo0dc3Jrp+VE= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 24/27] v4l2: v4l2_camera: Use buffer cookie for indexing Date: Thu, 18 Jun 2026 14:38:41 +0200 Message-ID: <20260618123844.656396-25-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260618123844.656396-1-barnabas.pocze@ideasonboard.com> References: <20260618123844.656396-1-barnabas.pocze@ideasonboard.com> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use the buffer cookie to store the index of the buffer instead of relying on the 1-to-1 association between requests and buffers, which will be broken by the split of requests and buffers. Signed-off-by: Barnabás Pőcze --- src/v4l2/v4l2_camera.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp index 75428b8adc..7dd0ea1ef9 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -87,7 +87,7 @@ void V4L2Camera::requestComplete(Request *request) /* We only have one stream at the moment. */ bufferLock_.lock(); FrameBuffer *buffer = request->buffers().begin()->second; - completedBuffers_.emplace_back(request->cookie(), buffer->metadata()); + completedBuffers_.emplace_back(buffer->cookie(), buffer->metadata()); bufferLock_.unlock(); uint64_t data = 1; @@ -171,6 +171,8 @@ int V4L2Camera::allocBuffers() return -ENOMEM; } requestPool_.push_back(std::move(request)); + + buffers[i]->setCookie(i); } return buffers.size();