From patchwork Fri Oct 18 15:42:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 2197 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com Return-Path: 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 460CD600EB for ; Fri, 18 Oct 2019 17:42:06 +0200 (CEST) Received: from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BCD6D3FDC; Fri, 18 Oct 2019 17:42:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1571413325; bh=2pjPnWZo4ouaEFErbLhOVYg5wbz9U5Kpqk4b/TBxLes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hVYYb0SD6ZtnKYGssGFFlvyor6SNEaOhvtrd01tnsCKYoHfc4qKVm3F1Kl6suhpGC SgfTQ6o4oYRbDPBk7ZA2eygXNFXfTqCwWIf7cxRXKzSR31YjolaRxnRNI1Awp9r8Dd yn2PEKOgx50SWRv41RjmXtyB7NyYSuXq+VmyLY+k= From: Kieran Bingham To: LibCamera Devel Date: Fri, 18 Oct 2019 16:42:00 +0100 Message-Id: <20191018154201.13540-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191018154201.13540-1-kieran.bingham@ideasonboard.com> References: <20191018154201.13540-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: v4l2_videodevice: Normalise multiPlanar configuration 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: , X-List-Received-Date: Fri, 18 Oct 2019 15:42:07 -0000 The use of either single planar or multi planar API is constant throughout the usage of a device, based upon the buffer type of the stream, and once determined it does not change. Rather than interrogate the bufferType_ each time, set a device flag at open() time as to whether we are using planar or multi-planar buffer APIs. Signed-off-by: Kieran Bingham --- src/libcamera/include/v4l2_videodevice.h | 1 + src/libcamera/v4l2_videodevice.cpp | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h index 4b8cf9394eb9..60fca01670c6 100644 --- a/src/libcamera/include/v4l2_videodevice.h +++ b/src/libcamera/include/v4l2_videodevice.h @@ -182,6 +182,7 @@ private: enum v4l2_buf_type bufferType_; enum v4l2_memory memoryType_; + bool multiPlanar_; BufferPool *bufferPool_; std::map queuedBuffers_; diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 208ab54199b1..37f61b90ac46 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -350,6 +350,8 @@ int V4L2VideoDevice::open() return -EINVAL; } + multiPlanar_ = V4L2_TYPE_IS_MULTIPLANAR(bufferType_); + fdEvent_->activated.connect(this, &V4L2VideoDevice::bufferAvailable); fdEvent_->setEnabled(false); @@ -436,6 +438,8 @@ int V4L2VideoDevice::open(int handle, enum v4l2_buf_type type) return -EINVAL; } + multiPlanar_ = V4L2_TYPE_IS_MULTIPLANAR(bufferType_); + fdEvent_->activated.connect(this, &V4L2VideoDevice::bufferAvailable); fdEvent_->setEnabled(false); @@ -870,7 +874,7 @@ int V4L2VideoDevice::exportBuffers(BufferPool *pool) break; } - if (V4L2_TYPE_IS_MULTIPLANAR(buf.type)) { + if (multiPlanar_) { for (unsigned int p = 0; p < buf.length; ++p) { ret = createPlane(&buffer, i, p, buf.m.planes[p].length); @@ -993,12 +997,11 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer) buf.memory = memoryType_; buf.field = V4L2_FIELD_NONE; - bool multiPlanar = V4L2_TYPE_IS_MULTIPLANAR(buf.type); BufferMemory *mem = &bufferPool_->buffers()[buf.index]; const std::vector &planes = mem->planes(); if (buf.memory == V4L2_MEMORY_DMABUF) { - if (multiPlanar) { + if (multiPlanar_) { for (unsigned int p = 0; p < planes.size(); ++p) v4l2Planes[p].m.fd = planes[p].dmabuf(); } else { @@ -1006,7 +1009,7 @@ int V4L2VideoDevice::queueBuffer(Buffer *buffer) } } - if (multiPlanar) { + if (multiPlanar_) { buf.length = planes.size(); buf.m.planes = v4l2Planes; } @@ -1099,7 +1102,7 @@ Buffer *V4L2VideoDevice::dequeueBuffer() buf.type = bufferType_; buf.memory = memoryType_; - if (V4L2_TYPE_IS_MULTIPLANAR(buf.type)) { + if (multiPlanar_) { buf.length = VIDEO_MAX_PLANES; buf.m.planes = planes; }