From patchwork Mon Jun 29 16:29:35 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: 27091 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 D0DDDC3261 for ; Mon, 29 Jun 2026 16:30:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2889F65F82; Mon, 29 Jun 2026 18:30:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="iGzZ79M9"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 977CC65F39 for ; Mon, 29 Jun 2026 18:30:23 +0200 (CEST) Received: from pb-laptop.local (185.221.140.128.nat.pool.zt.hu [185.221.140.128]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 60B13E91; Mon, 29 Jun 2026 18:29:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1782750580; bh=tnSy/eZmIIF5YrJtuFfnYAzv1u7FY/Wjzbz6Ecb77Us=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iGzZ79M92UDDcFQibz8ZKGWkzqLtsXar5p8u5F901qHtb8d1smE4DdLpach9B1IRk gPbFGa05o1wfTP2ukmm77a9aF50LLWrTyeKYvKOtV/LLL+0hiGOFnFv/4fTvBytHNS ccWmTvKerdPj1KC90Asxk3vfrbVvu5rjyOi/waMk= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi , Laurent Pinchart Subject: [RFC PATCH v1 12/54] v4l2: v4l2_camera: Use buffer cookie for indexing Date: Mon, 29 Jun 2026 18:29:35 +0200 Message-ID: <20260629163017.863145-13-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260629163017.863145-1-barnabas.pocze@ideasonboard.com> References: <20260629163017.863145-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 Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- 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();