From patchwork Tue Dec 1 08:37:59 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: 29120 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 DC048C3355 for ; Tue, 1 Dec 2026 08:38:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D21FD6AAB9; Tue, 1 Dec 2026 09:38:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qspoeynI"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AD21B6AA9E 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 CC2179A4 for ; 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=1796114131; bh=G+72YFqXYq5pqC/CbG2JbcWfmCMcEbRANBe5DWWjnvw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qspoeynI5UWfCZOEqsiYK2vRzMWTBZ6BacF0mVK4QyGeSsMSOH5xMLsJKhnvZcDgV 0s1MD7tvfdchAe8hAFbmowpT/WES9CzH6Rc3DBJPCmhhcKSz/jRMYH64U5465ft1J8 py4agHTfG0gtW8KRlnj7fU9KDW365Ue9VuMjgSZE= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 3/9] v4l2: v4l2_camera_proxy: Remove `bufferCount_` Date: Tue, 1 Dec 2026 09:37:59 +0100 Message-ID: <20261201083805.496809-4-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 The field always has the same value as `buffers_.size()`, so use that. Signed-off-by: Barnabás Pőcze --- src/v4l2/v4l2_camera_proxy.cpp | 22 ++++++++++------------ src/v4l2/v4l2_camera_proxy.h | 1 - 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 3c9ec8f9c6..b79d7d9af6 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -41,7 +41,7 @@ LOG_DECLARE_CATEGORY(V4L2Compat) V4L2CameraProxy::V4L2CameraProxy(unsigned int index, std::shared_ptr camera) - : refcount_(0), index_(index), bufferCount_(0), currentBuf_(0), + : refcount_(0), index_(index), currentBuf_(0), vcam_(std::make_unique(camera)), owner_(nullptr) { querycap(camera); @@ -392,7 +392,7 @@ int V4L2CameraProxy::vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg) Size size(arg->fmt.pix.width, arg->fmt.pix.height); V4L2PixelFormat v4l2Format = V4L2PixelFormat(arg->fmt.pix.pixelformat); ret = vcam_->configure(&streamConfig_, size, v4l2Format.toPixelFormat(), - bufferCount_); + buffers_.size()); if (ret < 0) return -EINVAL; @@ -494,7 +494,6 @@ void V4L2CameraProxy::freeBuffers() { vcam_->freeBuffers(); buffers_.clear(); - bufferCount_ = 0; } int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg) @@ -532,7 +531,7 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf return 0; } - if (bufferCount_ > 0) + if (!buffers_.empty()) freeBuffers(); Size size(v4l2PixFormat_.width, v4l2PixFormat_.height); @@ -545,7 +544,6 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf setFmtFromConfig(streamConfig_); arg->count = streamConfig_.bufferCount; - bufferCount_ = arg->count; ret = vcam_->allocBuffers(arg->count); if (ret < 0) { @@ -579,7 +577,7 @@ int V4L2CameraProxy::vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *a LOG(V4L2Compat, Debug) << "[" << file->description() << "] " << __func__ << "()"; - if (arg->index >= bufferCount_) + if (arg->index >= buffers_.size()) return -EINVAL; if (!validateBufferType(arg->type)) @@ -601,7 +599,7 @@ int V4L2CameraProxy::vidioc_prepare_buf(V4L2CameraFile *file, struct v4l2_buffer if (!hasOwnership(file)) return -EBUSY; - if (arg->index >= bufferCount_) + if (arg->index >= buffers_.size()) return -EINVAL; if (arg->flags & V4L2_BUF_FLAG_REQUEST_FD) @@ -630,7 +628,7 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg) << "[" << file->description() << "] " << __func__ << "(index=" << arg->index << ")"; - if (arg->index >= bufferCount_) + if (arg->index >= buffers_.size()) return -EINVAL; if (buffers_[arg->index].flags & V4L2_BUF_FLAG_QUEUED) @@ -661,7 +659,7 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, LOG(V4L2Compat, Debug) << "[" << file->description() << "] " << __func__ << "()"; - if (arg->index >= bufferCount_) + if (arg->index >= buffers_.size()) return -EINVAL; if (!hasOwnership(file)) @@ -702,7 +700,7 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, */ buf.flags &= ~V4L2_BUF_FLAG_ERROR; - currentBuf_ = (currentBuf_ + 1) % bufferCount_; + currentBuf_ = (currentBuf_ + 1) % buffers_.size(); uint64_t data; int ret = ::read(file->efd(), &data, sizeof(data)); @@ -724,7 +722,7 @@ int V4L2CameraProxy::vidioc_expbuf(V4L2CameraFile *file, struct v4l2_exportbuffe if (!validateBufferType(arg->type)) return -EINVAL; - if (arg->index >= bufferCount_) + if (arg->index >= buffers_.size()) return -EINVAL; if (arg->flags & ~(O_CLOEXEC | O_ACCMODE)) @@ -744,7 +742,7 @@ int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg) LOG(V4L2Compat, Debug) << "[" << file->description() << "] " << __func__ << "()"; - if (bufferCount_ == 0) + if (buffers_.empty()) return -EINVAL; if (!validateBufferType(*arg)) diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h index 5aa352c36f..6ef23fd82c 100644 --- a/src/v4l2/v4l2_camera_proxy.h +++ b/src/v4l2/v4l2_camera_proxy.h @@ -80,7 +80,6 @@ private: unsigned int index_; libcamera::StreamConfiguration streamConfig_; - unsigned int bufferCount_; unsigned int currentBuf_; unsigned int sizeimage_;