From patchwork Sat Mar 14 23:57:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 3096 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5C8CD628BD for ; Sun, 15 Mar 2020 00:57:41 +0100 (CET) Received: from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EF7351163 for ; Sun, 15 Mar 2020 00:57:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1584230261; bh=e6xscaDEWFpZBhVwPrGz6mQnBSH4JfkxTy8WU1akbNA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mCoW6YFT8CtZ2VkZ5eEj0ai6iCE6g/kjjhds/53uI9J4wa40jC8ogFA5Cu582MPTW nJNaqnJidY5Drw6uzUnDmvV5NucMoUd/RNHhCYS92IDL1H+IbkS8u91UXcAkgzVgJ1 2c0tVOrCnTy6A9PWQ0L8Alj6PqxDSk428h+X9ou4= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sun, 15 Mar 2020 01:57:22 +0200 Message-Id: <20200314235728.15495-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200314235728.15495-1-laurent.pinchart@ideasonboard.com> References: <20200314235728.15495-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/9] libcamera: v4l2_videodevice: Pass memory type to reqbufs() 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: Sat, 14 Mar 2020 23:57:41 -0000 To prepare for the rework of buffer export, pass the memory type explicitly to the V4L2VideoDevice::reqbufs() function. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/include/v4l2_videodevice.h | 2 +- src/libcamera/v4l2_videodevice.cpp | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h index 893d28c7db88..26f5e5917716 100644 --- a/src/libcamera/include/v4l2_videodevice.h +++ b/src/libcamera/include/v4l2_videodevice.h @@ -227,7 +227,7 @@ private: int setSelection(unsigned int target, Rectangle *rect); - int requestBuffers(unsigned int count); + int requestBuffers(unsigned int count, enum v4l2_memory memoryType); std::unique_ptr createBuffer(const struct v4l2_buffer &buf); FileDescriptor exportDmabufFd(unsigned int index, unsigned int plane); diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index aea7a4ea3a23..6911ab024fd7 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1013,14 +1013,15 @@ int V4L2VideoDevice::setSelection(unsigned int target, Rectangle *rect) return 0; } -int V4L2VideoDevice::requestBuffers(unsigned int count) +int V4L2VideoDevice::requestBuffers(unsigned int count, + enum v4l2_memory memoryType) { struct v4l2_requestbuffers rb = {}; int ret; rb.count = count; rb.type = bufferType_; - rb.memory = memoryType_; + rb.memory = memoryType; ret = ioctl(VIDIOC_REQBUFS, &rb); if (ret < 0) { @@ -1033,7 +1034,7 @@ int V4L2VideoDevice::requestBuffers(unsigned int count) if (rb.count < count) { LOG(V4L2, Error) << "Not enough buffers provided by V4L2VideoDevice"; - requestBuffers(0); + requestBuffers(0, memoryType); return -ENOMEM; } @@ -1059,7 +1060,7 @@ int V4L2VideoDevice::allocateBuffers(unsigned int count, memoryType_ = V4L2_MEMORY_MMAP; - int ret = requestBuffers(count); + int ret = requestBuffers(count, V4L2_MEMORY_MMAP); if (ret < 0) return ret; @@ -1096,7 +1097,7 @@ int V4L2VideoDevice::allocateBuffers(unsigned int count, return count; err_buf: - requestBuffers(0); + requestBuffers(0, V4L2_MEMORY_MMAP); buffers->clear(); @@ -1166,7 +1167,7 @@ int V4L2VideoDevice::importBuffers(unsigned int count) memoryType_ = V4L2_MEMORY_DMABUF; - int ret = requestBuffers(count); + int ret = requestBuffers(count, V4L2_MEMORY_DMABUF); if (ret) return ret; @@ -1187,7 +1188,7 @@ int V4L2VideoDevice::releaseBuffers() delete cache_; cache_ = nullptr; - return requestBuffers(0); + return requestBuffers(0, memoryType_); } /**