From patchwork Tue Dec 1 08:38:00 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: 29121 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 69A76C3304 for ; Tue, 1 Dec 2026 08:38:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 59ABF6AABF; Tue, 1 Dec 2026 09:38:16 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="D3XebKHq"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D61FA6AA9F for ; Tue, 1 Dec 2026 09:38:09 +0100 (CET) Received: from pb-laptop.local (185.182.215.119.nat.pool.zt.hu [185.182.215.119]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 04356C36; Tue, 1 Dec 2026 09:35:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1796114132; bh=B/485zTK6AYDYtNe7LN945PNw+GTVHWd+tLECdGdp/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D3XebKHq/+SZKNpo2fCbGlVvY+86nI5jKM+P+njlLcIRMRLhdADkEbMB1fEsmqUpX qQ5RELLanQHIBjpOYoNfoGynCtEUGlQOvlGGPtehA9ezdEtjum49tnkrYuGY1lnQT8 1E+lIwIwHo7e4by8JtCCg0Z37Nv/wLYP1lnnkLFQ= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Cc: Jacopo Mondi Subject: [PATCH v1 4/9] v4l2: v4l2_camera: Use actually allocated buffer count Date: Tue, 1 Dec 2026 09:38:00 +0100 Message-ID: <20261201083805.496809-5-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201083805.496809-1-barnabas.pocze@ideasonboard.com> References: <20261201083805.496809-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 Make `V4L2Camera::allocBuffers()` simply create as many requests as the number of buffers allocated instead of taking it as an argument. The two should be the same, so no functional changes intended. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/v4l2/v4l2_camera.cpp | 8 +++++--- src/v4l2/v4l2_camera.h | 2 +- src/v4l2/v4l2_camera_proxy.cpp | 10 +++++----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp index e524bfd053..13d58bba5b 100644 --- a/src/v4l2/v4l2_camera.cpp +++ b/src/v4l2/v4l2_camera.cpp @@ -155,7 +155,7 @@ int V4L2Camera::validateConfiguration(const PixelFormat &pixelFormat, return 0; } -int V4L2Camera::allocBuffers(unsigned int count) +int V4L2Camera::allocBuffers() { Stream *stream = config_->at(0).stream(); @@ -163,7 +163,9 @@ int V4L2Camera::allocBuffers(unsigned int count) if (ret < 0) return ret; - for (unsigned int i = 0; i < count; i++) { + const auto &buffers = bufferAllocator_->buffers(stream); + + for (size_t i = 0; i < buffers.size(); i++) { std::unique_ptr request = camera_->createRequest(i); if (!request) { requestPool_.clear(); @@ -172,7 +174,7 @@ int V4L2Camera::allocBuffers(unsigned int count) requestPool_.push_back(std::move(request)); } - return ret; + return buffers.size(); } void V4L2Camera::freeBuffers() diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h index 1528f9aad8..8a58169d89 100644 --- a/src/v4l2/v4l2_camera.h +++ b/src/v4l2/v4l2_camera.h @@ -54,7 +54,7 @@ public: libcamera::ControlList &controls() { return controls_; } const libcamera::ControlInfoMap &controlInfo() { return camera_->controls(); } - int allocBuffers(unsigned int count); + int allocBuffers(); void freeBuffers(); int getBufferFd(unsigned int index); diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index b79d7d9af6..af1df6dfcf 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -541,16 +541,16 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf if (ret < 0) return -EINVAL; - setFmtFromConfig(streamConfig_); - - arg->count = streamConfig_.bufferCount; - - ret = vcam_->allocBuffers(arg->count); + ret = vcam_->allocBuffers(); if (ret < 0) { arg->count = 0; return ret; } + arg->count = ret; + + setFmtFromConfig(streamConfig_); + buffers_.resize(arg->count); for (unsigned int i = 0; i < arg->count; i++) { struct v4l2_buffer buf = {};