From patchwork Mon Jun 29 16:29:33 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: 27089 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 C6D35C3261 for ; Mon, 29 Jun 2026 16:30:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 644CD65F80; Mon, 29 Jun 2026 18:30:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="pEvNkkSr"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 10A0B65F30 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 E1E8E12D6 for ; Mon, 29 Jun 2026 18:29:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1782750580; bh=aan4wQ65l6eE6m4pO2bt+MtuqPUHjFp7LdA2bFqlQ+s=; h=From:To:Subject:Date:In-Reply-To:References:From; b=pEvNkkSrEz/8UsxcoQpgDc4CnPvukMrp58FeE9IlH91/f/RKuo/QQc2vGfzFJe7AF XllDChZWhyNGDVATNy2+qjaXzDj9ba9xRQBsW9YI87o8XgC4DXgPMI+vzdYM5IE9IT aNExzt0Tu83MIlGafkUr52stTcbLWBvrabOPMGZg= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [RFC PATCH v1 10/54] v4l2: v4l2_camera_proxy: Remove `bufferCount_` Date: Mon, 29 Jun 2026 18:29:33 +0200 Message-ID: <20260629163017.863145-11-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" 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 b4f06c1c51..94c0006cf3 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); @@ -393,7 +393,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; @@ -495,7 +495,6 @@ void V4L2CameraProxy::freeBuffers() { vcam_->freeBuffers(); buffers_.clear(); - bufferCount_ = 0; } int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg) @@ -533,7 +532,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); @@ -546,7 +545,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) @@ -660,7 +658,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)) @@ -695,7 +693,7 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, buf.length = sizeimage_; *arg = buf; - currentBuf_ = (currentBuf_ + 1) % bufferCount_; + currentBuf_ = (currentBuf_ + 1) % buffers_.size(); uint64_t data; int ret = ::read(file->efd(), &data, sizeof(data)); @@ -717,7 +715,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)) @@ -737,7 +735,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_;