From patchwork Sat Jun 27 03:00:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8443 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 F35D7C2E66 for ; Sat, 27 Jun 2020 03:00:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D7EA060A16; Sat, 27 Jun 2020 05:00:50 +0200 (CEST) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A31CF609C8 for ; Sat, 27 Jun 2020 05:00:49 +0200 (CEST) X-Halon-ID: 53b3a6d1-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 53b3a6d1-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:16 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:31 +0200 Message-Id: <20200627030043.2088585-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 01/13] libcamera: ipu3: Remove unused name_ filed from IPU3Stream 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 is never used, remove it. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 6c43169eb0915965..fba45935741e0e4e 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -109,7 +109,6 @@ public: bool active_; bool raw_; - std::string name_; ImgUDevice::ImgUOutput *device_; }; @@ -867,11 +866,8 @@ int PipelineHandlerIPU3::registerCameras() */ data->imgu_ = numCameras ? &imgu1_ : &imgu0_; data->outStream_.device_ = &data->imgu_->output_; - data->outStream_.name_ = "output"; data->vfStream_.device_ = &data->imgu_->viewfinder_; - data->vfStream_.name_ = "viewfinder"; data->rawStream_.raw_ = true; - data->rawStream_.name_ = "raw"; /* * Connect video devices' 'bufferReady' signals to their From patchwork Sat Jun 27 03:00:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8444 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 8D3AFC2E66 for ; Sat, 27 Jun 2020 03:00:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6831560AF2; Sat, 27 Jun 2020 05:00:53 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0ACF1609D6 for ; Sat, 27 Jun 2020 05:00:50 +0200 (CEST) X-Halon-ID: 53f3bd94-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 53f3bd94-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:16 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:32 +0200 Message-Id: <20200627030043.2088585-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 02/13] libcamera: ipu3: Import instead of allocate statistic buffers 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" Statistics buffers are not yet used by the IPU3 pipeline, they are never queued to the video device or in any other way consumed. The kernel driver will however not allow video streaming to start if buffers are not either allocated or imported on the video device. Instead of allocating the buffers wasting memory that is never used import buffers. Signed-off-by: Niklas Söderlund --- src/libcamera/pipeline/ipu3/ipu3.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index fba45935741e0e4e..405550b1302fb370 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -1135,11 +1135,13 @@ int ImgUDevice::allocateBuffers(IPU3CameraData *data, unsigned int bufferCount) } /* - * Use for the stat's internal pool the same number of buffers as for - * the input pool. + * The kernel fails to start if buffers are not either imported or + * allocated for the statisitcs video device. As statistics buffers are + * not yet used by the pipeline import buffers to save memory. + * * \todo To be revised when we'll actually use the stat node. */ - ret = stat_.dev->allocateBuffers(bufferCount, &stat_.buffers); + ret = stat_.dev->importBuffers(bufferCount); if (ret < 0) { LOG(IPU3, Error) << "Failed to allocate ImgU stat buffers"; goto error; From patchwork Sat Jun 27 03:00:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8445 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 C7346C2E66 for ; Sat, 27 Jun 2020 03:00:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9F18E60AF7; Sat, 27 Jun 2020 05:00:54 +0200 (CEST) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 768A1609C8 for ; Sat, 27 Jun 2020 05:00:52 +0200 (CEST) X-Halon-ID: 5436d7ec-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 5436d7ec-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:19 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:33 +0200 Message-Id: <20200627030043.2088585-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 03/13] libcamera: ipu3: Always import buffers for ImgU sinks 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" When the IPU3 pipeline was first developed buffers of sinks from the ImgU that where not active still needed to have allocated buffers associated with them or streaming was not allowed to start. This is no longer true, it's enough that the sinks have imported buffers for streaming to start. As we already need to import buffers for streams that are active we can align the two cases and always import buffers. With this there is no longer a reason to store the allocated FrameBuffers to keep them alive and the vector tracking them can be removed. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/ipu3.cpp | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 405550b1302fb370..5a473e18c082cee8 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -49,7 +49,6 @@ public: V4L2VideoDevice *dev; unsigned int pad; std::string name; - std::vector> buffers; }; ImgUDevice() @@ -1124,9 +1123,6 @@ int ImgUDevice::configureOutput(ImgUOutput *output, */ int ImgUDevice::allocateBuffers(IPU3CameraData *data, unsigned int bufferCount) { - IPU3Stream *outStream = &data->outStream_; - IPU3Stream *vfStream = &data->vfStream_; - /* Share buffers between CIO2 output and ImgU input. */ int ret = input_->importBuffers(bufferCount); if (ret) { @@ -1147,28 +1143,15 @@ int ImgUDevice::allocateBuffers(IPU3CameraData *data, unsigned int bufferCount) goto error; } - /* - * Allocate buffers for both outputs. If an output is active, prepare - * for buffer import, otherwise allocate internal buffers. Use the same - * number of buffers in either case. - */ - if (outStream->active_) - ret = output_.dev->importBuffers(bufferCount); - else - ret = output_.dev->allocateBuffers(bufferCount, - &output_.buffers); + ret = output_.dev->importBuffers(bufferCount); if (ret < 0) { - LOG(IPU3, Error) << "Failed to allocate ImgU output buffers"; + LOG(IPU3, Error) << "Failed to import ImgU output buffers"; goto error; } - if (vfStream->active_) - ret = viewfinder_.dev->importBuffers(bufferCount); - else - ret = viewfinder_.dev->allocateBuffers(bufferCount, - &viewfinder_.buffers); + ret = viewfinder_.dev->importBuffers(bufferCount); if (ret < 0) { - LOG(IPU3, Error) << "Failed to allocate ImgU viewfinder buffers"; + LOG(IPU3, Error) << "Failed to import ImgU viewfinder buffers"; goto error; } From patchwork Sat Jun 27 03:00:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8446 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 2CFB5C2E67 for ; Sat, 27 Jun 2020 03:00:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C551760AFA; Sat, 27 Jun 2020 05:00:54 +0200 (CEST) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E8FB9609C8 for ; Sat, 27 Jun 2020 05:00:52 +0200 (CEST) X-Halon-ID: 55b301e4-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 55b301e4-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:19 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:34 +0200 Message-Id: <20200627030043.2088585-5-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 04/13] libcamera: ipu3: Remove usage of IPU3CameraData from ImgUDevice 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 IPU3CameraData argument to allocateBuffers() and freeBuffers() is no longer used and can be removed. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/ipu3.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 5a473e18c082cee8..36413a824ebbf564 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -34,8 +34,6 @@ namespace libcamera { LOG_DEFINE_CATEGORY(IPU3) -class IPU3CameraData; - class ImgUDevice { public: @@ -75,8 +73,8 @@ public: const StreamConfiguration &cfg, V4L2DeviceFormat *outputFormat); - int allocateBuffers(IPU3CameraData *data, unsigned int bufferCount); - void freeBuffers(IPU3CameraData *data); + int allocateBuffers(unsigned int bufferCount); + void freeBuffers(); int start(); int stop(); @@ -665,7 +663,7 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera) data->rawStream_.configuration().bufferCount, }); - ret = imgu->allocateBuffers(data, bufferCount); + ret = imgu->allocateBuffers(bufferCount); if (ret < 0) return ret; @@ -676,7 +674,7 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera) { IPU3CameraData *data = cameraData(camera); - data->imgu_->freeBuffers(data); + data->imgu_->freeBuffers(); return 0; } @@ -1121,7 +1119,7 @@ int ImgUDevice::configureOutput(ImgUOutput *output, /** * \brief Allocate buffers for all the ImgU video devices */ -int ImgUDevice::allocateBuffers(IPU3CameraData *data, unsigned int bufferCount) +int ImgUDevice::allocateBuffers(unsigned int bufferCount) { /* Share buffers between CIO2 output and ImgU input. */ int ret = input_->importBuffers(bufferCount); @@ -1158,7 +1156,7 @@ int ImgUDevice::allocateBuffers(IPU3CameraData *data, unsigned int bufferCount) return 0; error: - freeBuffers(data); + freeBuffers(); return ret; } @@ -1166,7 +1164,7 @@ error: /** * \brief Release buffers for all the ImgU video devices */ -void ImgUDevice::freeBuffers(IPU3CameraData *data) +void ImgUDevice::freeBuffers() { int ret; From patchwork Sat Jun 27 03:00:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8447 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 887F3C2E66 for ; Sat, 27 Jun 2020 03:00:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 45C89609DF; Sat, 27 Jun 2020 05:00:58 +0200 (CEST) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 80A9D609E1 for ; Sat, 27 Jun 2020 05:00:54 +0200 (CEST) X-Halon-ID: 55f9c200-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 55f9c200-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:20 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:35 +0200 Message-Id: <20200627030043.2088585-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 05/13] libcamera: ipu3: imgu: Move the ImgUDevice class to separate files 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" In preparation of refactoring the IPU3 pipeline handler breakout the ImgUDevice into its own .cpp and .h file, no functional change. Signed-off-by: Niklas Söderlund --- src/libcamera/pipeline/ipu3/imgu.cpp | 351 +++++++++++++++++++++ src/libcamera/pipeline/ipu3/imgu.h | 86 +++++ src/libcamera/pipeline/ipu3/ipu3.cpp | 399 +----------------------- src/libcamera/pipeline/ipu3/meson.build | 1 + 4 files changed, 439 insertions(+), 398 deletions(-) create mode 100644 src/libcamera/pipeline/ipu3/imgu.cpp create mode 100644 src/libcamera/pipeline/ipu3/imgu.h diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp new file mode 100644 index 0000000000000000..26a95979d0c7735a --- /dev/null +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -0,0 +1,351 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * imgu.cpp - Intel IPU3 ImgU + */ + +#include "imgu.h" + +#include + +#include + +#include + +#include "libcamera/internal/log.h" +#include "libcamera/internal/media_device.h" + +namespace libcamera { + +LOG_DECLARE_CATEGORY(IPU3) + +/** + * \brief Initialize components of the ImgU instance + * \param[in] mediaDevice The ImgU instance media device + * \param[in] index The ImgU instance index + * + * Create and open the V4L2 devices and subdevices of the ImgU instance + * with \a index. + * + * In case of errors the created V4L2VideoDevice and V4L2Subdevice instances + * are destroyed at pipeline handler delete time. + * + * \return 0 on success or a negative error code otherwise + */ +int ImgUDevice::init(MediaDevice *media, unsigned int index) +{ + int ret; + + index_ = index; + name_ = "ipu3-imgu " + std::to_string(index_); + media_ = media; + + /* + * The media entities presence in the media device has been verified + * by the match() function: no need to check for newly created + * video devices and subdevice validity here. + */ + imgu_ = V4L2Subdevice::fromEntityName(media, name_); + ret = imgu_->open(); + if (ret) + return ret; + + input_ = V4L2VideoDevice::fromEntityName(media, name_ + " input"); + ret = input_->open(); + if (ret) + return ret; + + output_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " output"); + ret = output_.dev->open(); + if (ret) + return ret; + + output_.pad = PAD_OUTPUT; + output_.name = "output"; + + viewfinder_.dev = V4L2VideoDevice::fromEntityName(media, + name_ + " viewfinder"); + ret = viewfinder_.dev->open(); + if (ret) + return ret; + + viewfinder_.pad = PAD_VF; + viewfinder_.name = "viewfinder"; + + stat_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat"); + ret = stat_.dev->open(); + if (ret) + return ret; + + stat_.pad = PAD_STAT; + stat_.name = "stat"; + + return 0; +} + +/** + * \brief Configure the ImgU unit input + * \param[in] size The ImgU input frame size + * \param[in] inputFormat The format to be applied to ImgU input + * \return 0 on success or a negative error code otherwise + */ +int ImgUDevice::configureInput(const Size &size, + V4L2DeviceFormat *inputFormat) +{ + /* Configure the ImgU input video device with the requested sizes. */ + int ret = input_->setFormat(inputFormat); + if (ret) + return ret; + + LOG(IPU3, Debug) << "ImgU input format = " << inputFormat->toString(); + + /* + * \todo The IPU3 driver implementation shall be changed to use the + * input sizes as 'ImgU Input' subdevice sizes, and use the desired + * GDC output sizes to configure the crop/compose rectangles. + * + * The current IPU3 driver implementation uses GDC sizes as the + * 'ImgU Input' subdevice sizes, and the input video device sizes + * to configure the crop/compose rectangles, contradicting the + * V4L2 specification. + */ + Rectangle rect = { + .x = 0, + .y = 0, + .width = inputFormat->size.width, + .height = inputFormat->size.height, + }; + ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_CROP, &rect); + if (ret) + return ret; + + ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_COMPOSE, &rect); + if (ret) + return ret; + + LOG(IPU3, Debug) << "ImgU input feeder and BDS rectangle = " + << rect.toString(); + + V4L2SubdeviceFormat imguFormat = {}; + imguFormat.mbus_code = MEDIA_BUS_FMT_FIXED; + imguFormat.size = size; + + ret = imgu_->setFormat(PAD_INPUT, &imguFormat); + if (ret) + return ret; + + LOG(IPU3, Debug) << "ImgU GDC format = " << imguFormat.toString(); + + return 0; +} + +/** + * \brief Configure the ImgU unit \a id video output + * \param[in] output The ImgU output device to configure + * \param[in] cfg The requested configuration + * \return 0 on success or a negative error code otherwise + */ +int ImgUDevice::configureOutput(ImgUOutput *output, + const StreamConfiguration &cfg, + V4L2DeviceFormat *outputFormat) +{ + V4L2VideoDevice *dev = output->dev; + unsigned int pad = output->pad; + + V4L2SubdeviceFormat imguFormat = {}; + imguFormat.mbus_code = MEDIA_BUS_FMT_FIXED; + imguFormat.size = cfg.size; + + int ret = imgu_->setFormat(pad, &imguFormat); + if (ret) + return ret; + + /* No need to apply format to the stat node. */ + if (output == &stat_) + return 0; + + *outputFormat = {}; + outputFormat->fourcc = dev->toV4L2PixelFormat(formats::NV12); + outputFormat->size = cfg.size; + outputFormat->planesCount = 2; + + ret = dev->setFormat(outputFormat); + if (ret) + return ret; + + LOG(IPU3, Debug) << "ImgU " << output->name << " format = " + << outputFormat->toString(); + + return 0; +} + +/** + * \brief Allocate buffers for all the ImgU video devices + */ +int ImgUDevice::allocateBuffers(unsigned int bufferCount) +{ + /* Share buffers between CIO2 output and ImgU input. */ + int ret = input_->importBuffers(bufferCount); + if (ret) { + LOG(IPU3, Error) << "Failed to import ImgU input buffers"; + return ret; + } + + /* + * The kernel fails to start if buffers are not either imported or + * allocated for the statisitcs video device. As statistics buffers are + * not yet used by the pipeline import buffers to save memory. + * + * \todo To be revised when we'll actually use the stat node. + */ + ret = stat_.dev->importBuffers(bufferCount); + if (ret < 0) { + LOG(IPU3, Error) << "Failed to allocate ImgU stat buffers"; + goto error; + } + + ret = output_.dev->importBuffers(bufferCount); + if (ret < 0) { + LOG(IPU3, Error) << "Failed to import ImgU output buffers"; + goto error; + } + + ret = viewfinder_.dev->importBuffers(bufferCount); + if (ret < 0) { + LOG(IPU3, Error) << "Failed to import ImgU viewfinder buffers"; + goto error; + } + + return 0; + +error: + freeBuffers(); + + return ret; +} + +/** + * \brief Release buffers for all the ImgU video devices + */ +void ImgUDevice::freeBuffers() +{ + int ret; + + ret = output_.dev->releaseBuffers(); + if (ret) + LOG(IPU3, Error) << "Failed to release ImgU output buffers"; + + ret = stat_.dev->releaseBuffers(); + if (ret) + LOG(IPU3, Error) << "Failed to release ImgU stat buffers"; + + ret = viewfinder_.dev->releaseBuffers(); + if (ret) + LOG(IPU3, Error) << "Failed to release ImgU viewfinder buffers"; + + ret = input_->releaseBuffers(); + if (ret) + LOG(IPU3, Error) << "Failed to release ImgU input buffers"; +} + +int ImgUDevice::start() +{ + int ret; + + /* Start the ImgU video devices. */ + ret = output_.dev->streamOn(); + if (ret) { + LOG(IPU3, Error) << "Failed to start ImgU output"; + return ret; + } + + ret = viewfinder_.dev->streamOn(); + if (ret) { + LOG(IPU3, Error) << "Failed to start ImgU viewfinder"; + return ret; + } + + ret = stat_.dev->streamOn(); + if (ret) { + LOG(IPU3, Error) << "Failed to start ImgU stat"; + return ret; + } + + ret = input_->streamOn(); + if (ret) { + LOG(IPU3, Error) << "Failed to start ImgU input"; + return ret; + } + + return 0; +} + +int ImgUDevice::stop() +{ + int ret; + + ret = output_.dev->streamOff(); + ret |= viewfinder_.dev->streamOff(); + ret |= stat_.dev->streamOff(); + ret |= input_->streamOff(); + + return ret; +} + +/** + * \brief Enable or disable a single link on the ImgU instance + * + * This method assumes the media device associated with the ImgU instance + * is open. + * + * \return 0 on success or a negative error code otherwise + */ +int ImgUDevice::linkSetup(const std::string &source, unsigned int sourcePad, + const std::string &sink, unsigned int sinkPad, + bool enable) +{ + MediaLink *link = media_->link(source, sourcePad, sink, sinkPad); + if (!link) { + LOG(IPU3, Error) + << "Failed to get link: '" << source << "':" + << sourcePad << " -> '" << sink << "':" << sinkPad; + return -ENODEV; + } + + return link->setEnabled(enable); +} + +/** + * \brief Enable or disable all media links in the ImgU instance to prepare + * for capture operations + * + * \todo This method will probably be removed or changed once links will be + * enabled or disabled selectively. + * + * \return 0 on success or a negative error code otherwise + */ +int ImgUDevice::enableLinks(bool enable) +{ + std::string viewfinderName = name_ + " viewfinder"; + std::string outputName = name_ + " output"; + std::string statName = name_ + " 3a stat"; + std::string inputName = name_ + " input"; + int ret; + + ret = linkSetup(inputName, 0, name_, PAD_INPUT, enable); + if (ret) + return ret; + + ret = linkSetup(name_, PAD_OUTPUT, outputName, 0, enable); + if (ret) + return ret; + + ret = linkSetup(name_, PAD_VF, viewfinderName, 0, enable); + if (ret) + return ret; + + return linkSetup(name_, PAD_STAT, statName, 0, enable); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h new file mode 100644 index 0000000000000000..9bb1b88e2ca8ea2d --- /dev/null +++ b/src/libcamera/pipeline/ipu3/imgu.h @@ -0,0 +1,86 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * imgu.h - Intel IPU3 ImgU + */ +#ifndef __LIBCAMERA_PIPELINE_IPU3_IMGU_H__ +#define __LIBCAMERA_PIPELINE_IPU3_IMGU_H__ + +#include +#include +#include + +#include "libcamera/internal/v4l2_subdevice.h" +#include "libcamera/internal/v4l2_videodevice.h" + +namespace libcamera { + +class FrameBuffer; +class MediaDevice; +struct Size; +struct StreamConfiguration; + +class ImgUDevice +{ +public: + static constexpr unsigned int PAD_INPUT = 0; + static constexpr unsigned int PAD_OUTPUT = 2; + static constexpr unsigned int PAD_VF = 3; + static constexpr unsigned int PAD_STAT = 4; + + /* ImgU output descriptor: group data specific to an ImgU output. */ + struct ImgUOutput { + V4L2VideoDevice *dev; + unsigned int pad; + std::string name; + }; + + ImgUDevice() + : imgu_(nullptr), input_(nullptr) + { + output_.dev = nullptr; + viewfinder_.dev = nullptr; + stat_.dev = nullptr; + } + + ~ImgUDevice() + { + delete imgu_; + delete input_; + delete output_.dev; + delete viewfinder_.dev; + delete stat_.dev; + } + + int init(MediaDevice *media, unsigned int index); + int configureInput(const Size &size, V4L2DeviceFormat *inputFormat); + int configureOutput(ImgUOutput *output, const StreamConfiguration &cfg, + V4L2DeviceFormat *outputFormat); + + int allocateBuffers(unsigned int bufferCount); + void freeBuffers(); + + int start(); + int stop(); + + int linkSetup(const std::string &source, unsigned int sourcePad, + const std::string &sink, unsigned int sinkPad, + bool enable); + int enableLinks(bool enable); + + unsigned int index_; + std::string name_; + MediaDevice *media_; + + V4L2Subdevice *imgu_; + V4L2VideoDevice *input_; + ImgUOutput output_; + ImgUOutput viewfinder_; + ImgUOutput stat_; + /* \todo Add param video device for 3A tuning */ +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_PIPELINE_IPU3_IMGU_H__ */ diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 36413a824ebbf564..b41a789e8dc2a7b2 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -11,8 +11,6 @@ #include #include -#include - #include #include #include @@ -25,77 +23,14 @@ #include "libcamera/internal/pipeline_handler.h" #include "libcamera/internal/utils.h" #include "libcamera/internal/v4l2_controls.h" -#include "libcamera/internal/v4l2_subdevice.h" -#include "libcamera/internal/v4l2_videodevice.h" #include "cio2.h" +#include "imgu.h" namespace libcamera { LOG_DEFINE_CATEGORY(IPU3) -class ImgUDevice -{ -public: - static constexpr unsigned int PAD_INPUT = 0; - static constexpr unsigned int PAD_OUTPUT = 2; - static constexpr unsigned int PAD_VF = 3; - static constexpr unsigned int PAD_STAT = 4; - - /* ImgU output descriptor: group data specific to an ImgU output. */ - struct ImgUOutput { - V4L2VideoDevice *dev; - unsigned int pad; - std::string name; - }; - - ImgUDevice() - : imgu_(nullptr), input_(nullptr) - { - output_.dev = nullptr; - viewfinder_.dev = nullptr; - stat_.dev = nullptr; - } - - ~ImgUDevice() - { - delete imgu_; - delete input_; - delete output_.dev; - delete viewfinder_.dev; - delete stat_.dev; - } - - int init(MediaDevice *media, unsigned int index); - int configureInput(const Size &size, - V4L2DeviceFormat *inputFormat); - int configureOutput(ImgUOutput *output, - const StreamConfiguration &cfg, - V4L2DeviceFormat *outputFormat); - - int allocateBuffers(unsigned int bufferCount); - void freeBuffers(); - - int start(); - int stop(); - - int linkSetup(const std::string &source, unsigned int sourcePad, - const std::string &sink, unsigned int sinkPad, - bool enable); - int enableLinks(bool enable); - - unsigned int index_; - std::string name_; - MediaDevice *media_; - - V4L2Subdevice *imgu_; - V4L2VideoDevice *input_; - ImgUOutput output_; - ImgUOutput viewfinder_; - ImgUOutput stat_; - /* \todo Add param video device for 3A tuning */ -}; - class IPU3Stream : public Stream { public: @@ -952,338 +887,6 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) imgu_->input_->queueBuffer(buffer); } -/* ----------------------------------------------------------------------------- - * ImgU Device - */ - -/** - * \brief Initialize components of the ImgU instance - * \param[in] mediaDevice The ImgU instance media device - * \param[in] index The ImgU instance index - * - * Create and open the V4L2 devices and subdevices of the ImgU instance - * with \a index. - * - * In case of errors the created V4L2VideoDevice and V4L2Subdevice instances - * are destroyed at pipeline handler delete time. - * - * \return 0 on success or a negative error code otherwise - */ -int ImgUDevice::init(MediaDevice *media, unsigned int index) -{ - int ret; - - index_ = index; - name_ = "ipu3-imgu " + std::to_string(index_); - media_ = media; - - /* - * The media entities presence in the media device has been verified - * by the match() function: no need to check for newly created - * video devices and subdevice validity here. - */ - imgu_ = V4L2Subdevice::fromEntityName(media, name_); - ret = imgu_->open(); - if (ret) - return ret; - - input_ = V4L2VideoDevice::fromEntityName(media, name_ + " input"); - ret = input_->open(); - if (ret) - return ret; - - output_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " output"); - ret = output_.dev->open(); - if (ret) - return ret; - - output_.pad = PAD_OUTPUT; - output_.name = "output"; - - viewfinder_.dev = V4L2VideoDevice::fromEntityName(media, - name_ + " viewfinder"); - ret = viewfinder_.dev->open(); - if (ret) - return ret; - - viewfinder_.pad = PAD_VF; - viewfinder_.name = "viewfinder"; - - stat_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat"); - ret = stat_.dev->open(); - if (ret) - return ret; - - stat_.pad = PAD_STAT; - stat_.name = "stat"; - - return 0; -} - -/** - * \brief Configure the ImgU unit input - * \param[in] size The ImgU input frame size - * \param[in] inputFormat The format to be applied to ImgU input - * \return 0 on success or a negative error code otherwise - */ -int ImgUDevice::configureInput(const Size &size, - V4L2DeviceFormat *inputFormat) -{ - /* Configure the ImgU input video device with the requested sizes. */ - int ret = input_->setFormat(inputFormat); - if (ret) - return ret; - - LOG(IPU3, Debug) << "ImgU input format = " << inputFormat->toString(); - - /* - * \todo The IPU3 driver implementation shall be changed to use the - * input sizes as 'ImgU Input' subdevice sizes, and use the desired - * GDC output sizes to configure the crop/compose rectangles. - * - * The current IPU3 driver implementation uses GDC sizes as the - * 'ImgU Input' subdevice sizes, and the input video device sizes - * to configure the crop/compose rectangles, contradicting the - * V4L2 specification. - */ - Rectangle rect = { - .x = 0, - .y = 0, - .width = inputFormat->size.width, - .height = inputFormat->size.height, - }; - ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_CROP, &rect); - if (ret) - return ret; - - ret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_COMPOSE, &rect); - if (ret) - return ret; - - LOG(IPU3, Debug) << "ImgU input feeder and BDS rectangle = " - << rect.toString(); - - V4L2SubdeviceFormat imguFormat = {}; - imguFormat.mbus_code = MEDIA_BUS_FMT_FIXED; - imguFormat.size = size; - - ret = imgu_->setFormat(PAD_INPUT, &imguFormat); - if (ret) - return ret; - - LOG(IPU3, Debug) << "ImgU GDC format = " << imguFormat.toString(); - - return 0; -} - -/** - * \brief Configure the ImgU unit \a id video output - * \param[in] output The ImgU output device to configure - * \param[in] cfg The requested configuration - * \return 0 on success or a negative error code otherwise - */ -int ImgUDevice::configureOutput(ImgUOutput *output, - const StreamConfiguration &cfg, - V4L2DeviceFormat *outputFormat) -{ - V4L2VideoDevice *dev = output->dev; - unsigned int pad = output->pad; - - V4L2SubdeviceFormat imguFormat = {}; - imguFormat.mbus_code = MEDIA_BUS_FMT_FIXED; - imguFormat.size = cfg.size; - - int ret = imgu_->setFormat(pad, &imguFormat); - if (ret) - return ret; - - /* No need to apply format to the stat node. */ - if (output == &stat_) - return 0; - - *outputFormat = {}; - outputFormat->fourcc = dev->toV4L2PixelFormat(formats::NV12); - outputFormat->size = cfg.size; - outputFormat->planesCount = 2; - - ret = dev->setFormat(outputFormat); - if (ret) - return ret; - - LOG(IPU3, Debug) << "ImgU " << output->name << " format = " - << outputFormat->toString(); - - return 0; -} - -/** - * \brief Allocate buffers for all the ImgU video devices - */ -int ImgUDevice::allocateBuffers(unsigned int bufferCount) -{ - /* Share buffers between CIO2 output and ImgU input. */ - int ret = input_->importBuffers(bufferCount); - if (ret) { - LOG(IPU3, Error) << "Failed to import ImgU input buffers"; - return ret; - } - - /* - * The kernel fails to start if buffers are not either imported or - * allocated for the statisitcs video device. As statistics buffers are - * not yet used by the pipeline import buffers to save memory. - * - * \todo To be revised when we'll actually use the stat node. - */ - ret = stat_.dev->importBuffers(bufferCount); - if (ret < 0) { - LOG(IPU3, Error) << "Failed to allocate ImgU stat buffers"; - goto error; - } - - ret = output_.dev->importBuffers(bufferCount); - if (ret < 0) { - LOG(IPU3, Error) << "Failed to import ImgU output buffers"; - goto error; - } - - ret = viewfinder_.dev->importBuffers(bufferCount); - if (ret < 0) { - LOG(IPU3, Error) << "Failed to import ImgU viewfinder buffers"; - goto error; - } - - return 0; - -error: - freeBuffers(); - - return ret; -} - -/** - * \brief Release buffers for all the ImgU video devices - */ -void ImgUDevice::freeBuffers() -{ - int ret; - - ret = output_.dev->releaseBuffers(); - if (ret) - LOG(IPU3, Error) << "Failed to release ImgU output buffers"; - - ret = stat_.dev->releaseBuffers(); - if (ret) - LOG(IPU3, Error) << "Failed to release ImgU stat buffers"; - - ret = viewfinder_.dev->releaseBuffers(); - if (ret) - LOG(IPU3, Error) << "Failed to release ImgU viewfinder buffers"; - - ret = input_->releaseBuffers(); - if (ret) - LOG(IPU3, Error) << "Failed to release ImgU input buffers"; -} - -int ImgUDevice::start() -{ - int ret; - - /* Start the ImgU video devices. */ - ret = output_.dev->streamOn(); - if (ret) { - LOG(IPU3, Error) << "Failed to start ImgU output"; - return ret; - } - - ret = viewfinder_.dev->streamOn(); - if (ret) { - LOG(IPU3, Error) << "Failed to start ImgU viewfinder"; - return ret; - } - - ret = stat_.dev->streamOn(); - if (ret) { - LOG(IPU3, Error) << "Failed to start ImgU stat"; - return ret; - } - - ret = input_->streamOn(); - if (ret) { - LOG(IPU3, Error) << "Failed to start ImgU input"; - return ret; - } - - return 0; -} - -int ImgUDevice::stop() -{ - int ret; - - ret = output_.dev->streamOff(); - ret |= viewfinder_.dev->streamOff(); - ret |= stat_.dev->streamOff(); - ret |= input_->streamOff(); - - return ret; -} - -/** - * \brief Enable or disable a single link on the ImgU instance - * - * This method assumes the media device associated with the ImgU instance - * is open. - * - * \return 0 on success or a negative error code otherwise - */ -int ImgUDevice::linkSetup(const std::string &source, unsigned int sourcePad, - const std::string &sink, unsigned int sinkPad, - bool enable) -{ - MediaLink *link = media_->link(source, sourcePad, sink, sinkPad); - if (!link) { - LOG(IPU3, Error) - << "Failed to get link: '" << source << "':" - << sourcePad << " -> '" << sink << "':" << sinkPad; - return -ENODEV; - } - - return link->setEnabled(enable); -} - -/** - * \brief Enable or disable all media links in the ImgU instance to prepare - * for capture operations - * - * \todo This method will probably be removed or changed once links will be - * enabled or disabled selectively. - * - * \return 0 on success or a negative error code otherwise - */ -int ImgUDevice::enableLinks(bool enable) -{ - std::string viewfinderName = name_ + " viewfinder"; - std::string outputName = name_ + " output"; - std::string statName = name_ + " 3a stat"; - std::string inputName = name_ + " input"; - int ret; - - ret = linkSetup(inputName, 0, name_, PAD_INPUT, enable); - if (ret) - return ret; - - ret = linkSetup(name_, PAD_OUTPUT, outputName, 0, enable); - if (ret) - return ret; - - ret = linkSetup(name_, PAD_VF, viewfinderName, 0, enable); - if (ret) - return ret; - - return linkSetup(name_, PAD_STAT, statName, 0, enable); -} - REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3); } /* namespace libcamera */ diff --git a/src/libcamera/pipeline/ipu3/meson.build b/src/libcamera/pipeline/ipu3/meson.build index b2602d30123f908d..d60e07ae6ccac2bc 100644 --- a/src/libcamera/pipeline/ipu3/meson.build +++ b/src/libcamera/pipeline/ipu3/meson.build @@ -2,5 +2,6 @@ libcamera_sources += files([ 'cio2.cpp', + 'imgu.cpp', 'ipu3.cpp', ]) From patchwork Sat Jun 27 03:00:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8448 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 E3D88C2E67 for ; Sat, 27 Jun 2020 03:00:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A34AE60B09; Sat, 27 Jun 2020 05:00:58 +0200 (CEST) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 060F260A16 for ; Sat, 27 Jun 2020 05:00:54 +0200 (CEST) X-Halon-ID: 56ea8c4c-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 56ea8c4c-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:21 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:36 +0200 Message-Id: <20200627030043.2088585-7-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 06/13] libcamera: ipu3: imgu: Do not cache index 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 numerical index of the imgu is only used to create its name in string form. There is no need to keep it around after that, remove it. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/imgu.cpp | 3 +-- src/libcamera/pipeline/ipu3/imgu.h | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index 26a95979d0c7735a..5d11539605f26303 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -37,8 +37,7 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index) { int ret; - index_ = index; - name_ = "ipu3-imgu " + std::to_string(index_); + name_ = "ipu3-imgu " + std::to_string(index); media_ = media; /* diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h index 9bb1b88e2ca8ea2d..ad5aabf134e2099d 100644 --- a/src/libcamera/pipeline/ipu3/imgu.h +++ b/src/libcamera/pipeline/ipu3/imgu.h @@ -69,7 +69,6 @@ public: bool enable); int enableLinks(bool enable); - unsigned int index_; std::string name_; MediaDevice *media_; From patchwork Sat Jun 27 03:00:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8449 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 85AC0C2E66 for ; Sat, 27 Jun 2020 03:00:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 30C4E60B0A; Sat, 27 Jun 2020 05:00:59 +0200 (CEST) Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8FB1D609C9 for ; Sat, 27 Jun 2020 05:00:55 +0200 (CEST) X-Halon-ID: 57347ce0-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 57347ce0-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:22 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:37 +0200 Message-Id: <20200627030043.2088585-8-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 07/13] libcamera: ipu3: imgu: Mark things that are internal as private 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" Mark all variables and functions that are only used internally as private. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/imgu.h | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h index ad5aabf134e2099d..b6b08b4fef2d3a9d 100644 --- a/src/libcamera/pipeline/ipu3/imgu.h +++ b/src/libcamera/pipeline/ipu3/imgu.h @@ -24,11 +24,6 @@ struct StreamConfiguration; class ImgUDevice { public: - static constexpr unsigned int PAD_INPUT = 0; - static constexpr unsigned int PAD_OUTPUT = 2; - static constexpr unsigned int PAD_VF = 3; - static constexpr unsigned int PAD_STAT = 4; - /* ImgU output descriptor: group data specific to an ImgU output. */ struct ImgUOutput { V4L2VideoDevice *dev; @@ -64,20 +59,27 @@ public: int start(); int stop(); - int linkSetup(const std::string &source, unsigned int sourcePad, - const std::string &sink, unsigned int sinkPad, - bool enable); int enableLinks(bool enable); - std::string name_; - MediaDevice *media_; - V4L2Subdevice *imgu_; V4L2VideoDevice *input_; ImgUOutput output_; ImgUOutput viewfinder_; ImgUOutput stat_; /* \todo Add param video device for 3A tuning */ + +private: + static constexpr unsigned int PAD_INPUT = 0; + static constexpr unsigned int PAD_OUTPUT = 2; + static constexpr unsigned int PAD_VF = 3; + static constexpr unsigned int PAD_STAT = 4; + + int linkSetup(const std::string &source, unsigned int sourcePad, + const std::string &sink, unsigned int sinkPad, + bool enable); + + std::string name_; + MediaDevice *media_; }; } /* namespace libcamera */ From patchwork Sat Jun 27 03:00:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8450 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 06EF0C2E66 for ; Sat, 27 Jun 2020 03:01:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B22E160B03; Sat, 27 Jun 2020 05:00:59 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 31EAD609C8 for ; Sat, 27 Jun 2020 05:00:56 +0200 (CEST) X-Halon-ID: 578059bb-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 578059bb-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:22 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:38 +0200 Message-Id: <20200627030043.2088585-9-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 08/13] libcamera: ipu3: imgu: Use specific functions to configure each sink 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" When the IPU3 pipeline only provided streams to applications that came from the ImgU it made sens to have a generic function to configure all the different outputs. With the addition of the RAW stream this begins to be cumbersome to read and make sens of in the PipelineHandlerIPU3 code. Replace the generic function that takes a specific argument for which sink to configure with a specific function for each sink. This makes the code easier to follow as it's always clear which of the ImgU sinks are being configured without knowing the content of a generically named variable. It also paves way for future improvements. Signed-off-by: Niklas Söderlund --- src/libcamera/pipeline/ipu3/imgu.cpp | 34 ++++++++++++++++--------- src/libcamera/pipeline/ipu3/imgu.h | 11 +++++++- src/libcamera/pipeline/ipu3/ipu3.cpp | 38 +++++++++++++++------------- 3 files changed, 53 insertions(+), 30 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index 5d11539605f26303..d54e844d9bfc5147 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -139,19 +139,28 @@ int ImgUDevice::configureInput(const Size &size, return 0; } -/** - * \brief Configure the ImgU unit \a id video output - * \param[in] output The ImgU output device to configure - * \param[in] cfg The requested configuration - * \return 0 on success or a negative error code otherwise - */ -int ImgUDevice::configureOutput(ImgUOutput *output, - const StreamConfiguration &cfg, +int ImgUDevice::configureOutput(const StreamConfiguration &cfg, V4L2DeviceFormat *outputFormat) { - V4L2VideoDevice *dev = output->dev; - unsigned int pad = output->pad; + return configureVideoDevice(output_.dev, PAD_OUTPUT, cfg, outputFormat); +} +int ImgUDevice::configureViewfinder(const StreamConfiguration &cfg, + V4L2DeviceFormat *outputFormat) +{ + return configureVideoDevice(viewfinder_.dev, PAD_VF, cfg, outputFormat); +} + +int ImgUDevice::configureStat(const StreamConfiguration &cfg, + V4L2DeviceFormat *outputFormat) +{ + return configureVideoDevice(stat_.dev, PAD_STAT, cfg, outputFormat); +} + +int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad, + const StreamConfiguration &cfg, + V4L2DeviceFormat *outputFormat) +{ V4L2SubdeviceFormat imguFormat = {}; imguFormat.mbus_code = MEDIA_BUS_FMT_FIXED; imguFormat.size = cfg.size; @@ -161,7 +170,7 @@ int ImgUDevice::configureOutput(ImgUOutput *output, return ret; /* No need to apply format to the stat node. */ - if (output == &stat_) + if (dev == stat_.dev) return 0; *outputFormat = {}; @@ -173,7 +182,8 @@ int ImgUDevice::configureOutput(ImgUOutput *output, if (ret) return ret; - LOG(IPU3, Debug) << "ImgU " << output->name << " format = " + const char *name = dev == output_.dev ? "output" : "viewfinder"; + LOG(IPU3, Debug) << "ImgU " << name << " format = " << outputFormat->toString(); return 0; diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h index b6b08b4fef2d3a9d..f8fd54089753b40e 100644 --- a/src/libcamera/pipeline/ipu3/imgu.h +++ b/src/libcamera/pipeline/ipu3/imgu.h @@ -49,9 +49,14 @@ public: } int init(MediaDevice *media, unsigned int index); + int configureInput(const Size &size, V4L2DeviceFormat *inputFormat); - int configureOutput(ImgUOutput *output, const StreamConfiguration &cfg, + int configureOutput(const StreamConfiguration &cfg, V4L2DeviceFormat *outputFormat); + int configureViewfinder(const StreamConfiguration &cfg, + V4L2DeviceFormat *outputFormat); + int configureStat(const StreamConfiguration &cfg, + V4L2DeviceFormat *outputFormat); int allocateBuffers(unsigned int bufferCount); void freeBuffers(); @@ -78,6 +83,10 @@ private: const std::string &sink, unsigned int sinkPad, bool enable); + int configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad, + const StreamConfiguration &cfg, + V4L2DeviceFormat *outputFormat); + std::string name_; MediaDevice *media_; }; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index b41a789e8dc2a7b2..ae7a01b81dacf498 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -504,19 +504,25 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) stream->active_ = true; cfg.setStream(stream); - /* - * The RAW still capture stream just copies buffers from the - * internal queue and doesn't need any specific configuration. - */ - if (stream->raw_) { + if (stream == outStream) { + ret = imgu->configureOutput(cfg, &outputFormat); + if (ret) + return ret; + + cfg.stride = outputFormat.planes[0].bpl; + } else if (stream == vfStream) { + ret = imgu->configureViewfinder(cfg, &outputFormat); + if (ret) + return ret; + + cfg.stride = outputFormat.planes[0].bpl; + } else { + /* + * The RAW still capture stream just copies buffers from + * the internal queue and doesn't need any specific + * configuration. + */ cfg.stride = cio2Format.planes[0].bpl; - } else { - ret = imgu->configureOutput(stream->device_, cfg, - &outputFormat); - if (ret) - return ret; - - cfg.stride = outputFormat.planes[0].bpl; } } @@ -526,15 +532,13 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) * be at least one active stream in the configuration request). */ if (!outStream->active_) { - ret = imgu->configureOutput(outStream->device_, config->at(0), - &outputFormat); + ret = imgu->configureOutput(config->at(0), &outputFormat); if (ret) return ret; } if (!vfStream->active_) { - ret = imgu->configureOutput(vfStream->device_, config->at(0), - &outputFormat); + ret = imgu->configureViewfinder(config->at(0), &outputFormat); if (ret) return ret; } @@ -546,7 +550,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) StreamConfiguration statCfg = {}; statCfg.size = cio2Format.size; - ret = imgu->configureOutput(&imgu->stat_, statCfg, &outputFormat); + ret = imgu->configureStat(statCfg, &outputFormat); if (ret) return ret; From patchwork Sat Jun 27 03:00:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8451 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 8F539C2E66 for ; Sat, 27 Jun 2020 03:01:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4969360B04; Sat, 27 Jun 2020 05:01:00 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BC721609E1 for ; Sat, 27 Jun 2020 05:00:56 +0200 (CEST) X-Halon-ID: 57ec3987-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 57ec3987-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:23 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:39 +0200 Message-Id: <20200627030043.2088585-10-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 09/13] libcamera: ipu3: Do not duplicate data in IPU3Stream 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" Do not keep the duplicated ImgUDevice::ImgUOutput information in both the stream and camera data classes. Remove it from the stream and only access it from the camera data class. Which stream is which can instead be checked by comparing it to the known streams in camera data. This match how streams are checked in other parts of the code making the driver more coherent. Signed-off-by: Niklas Söderlund --- src/libcamera/pipeline/ipu3/ipu3.cpp | 31 +++++++++++++++------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index ae7a01b81dacf498..1f320dc166767bab 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -35,13 +35,11 @@ class IPU3Stream : public Stream { public: IPU3Stream() - : active_(false), raw_(false), device_(nullptr) + : active_(false) { } bool active_; - bool raw_; - ImgUDevice::ImgUOutput *device_; }; class IPU3CameraData : public CameraData @@ -276,7 +274,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() const StreamConfiguration oldCfg = cfg; const IPU3Stream *stream = streams_[i]; - if (stream->raw_) { + if (stream == &data_->rawStream_) { cfg = cio2Configuration_; } else { bool scale = stream == &data_->vfStream_; @@ -572,13 +570,16 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream, std::vector> *buffers) { IPU3CameraData *data = cameraData(camera); - IPU3Stream *ipu3stream = static_cast(stream); unsigned int count = stream->configuration().bufferCount; - if (ipu3stream->raw_) + if (stream == &data->outStream_) + return data->imgu_->output_.dev->exportBuffers(count, buffers); + else if (stream == &data->vfStream_) + return data->imgu_->viewfinder_.dev->exportBuffers(count, buffers); + else if (stream == &data->rawStream_) return data->cio2_.exportBuffers(count, buffers); - return ipu3stream->device_->dev->exportBuffers(count, buffers); + return -EINVAL; } /** @@ -685,11 +686,16 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) /* Queue all buffers from the request aimed for the ImgU. */ for (auto it : request->buffers()) { IPU3Stream *stream = static_cast(it.first); - if (stream->raw_) - continue; - FrameBuffer *buffer = it.second; - int ret = stream->device_->dev->queueBuffer(buffer); + int ret; + + if (stream == &data->outStream_) + ret = data->imgu_->output_.dev->queueBuffer(buffer); + else if (stream == &data->vfStream_) + ret = data->imgu_->viewfinder_.dev->queueBuffer(buffer); + else + continue; + if (ret < 0) error = ret; } @@ -801,9 +807,6 @@ int PipelineHandlerIPU3::registerCameras() * second. */ data->imgu_ = numCameras ? &imgu1_ : &imgu0_; - data->outStream_.device_ = &data->imgu_->output_; - data->vfStream_.device_ = &data->imgu_->viewfinder_; - data->rawStream_.raw_ = true; /* * Connect video devices' 'bufferReady' signals to their From patchwork Sat Jun 27 03:00:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8452 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 E735FC2E67 for ; Sat, 27 Jun 2020 03:01:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A552260B05; Sat, 27 Jun 2020 05:01:00 +0200 (CEST) Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 43F8A609E1 for ; Sat, 27 Jun 2020 05:00:57 +0200 (CEST) X-Halon-ID: 583ef079-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 583ef079-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:23 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:40 +0200 Message-Id: <20200627030043.2088585-11-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 10/13] libcamera: ipu3: Remove the active flag from IPU3Stream 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 active_ flag is only used inside one function, remove the global flag and handle it inside the single function. Signed-off-by: Niklas Söderlund --- src/libcamera/pipeline/ipu3/ipu3.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 1f320dc166767bab..b72b631cdc051aab 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -33,13 +33,6 @@ LOG_DEFINE_CATEGORY(IPU3) class IPU3Stream : public Stream { -public: - IPU3Stream() - : active_(false) - { - } - - bool active_; }; class IPU3CameraData : public CameraData @@ -486,8 +479,8 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) return ret; /* Apply the format to the configured streams output devices. */ - outStream->active_ = false; - vfStream->active_ = false; + bool outActive = false; + bool vfActive = false; for (unsigned int i = 0; i < config->size(); ++i) { /* @@ -499,7 +492,6 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) IPU3Stream *stream = const_cast(config->streams()[i]); StreamConfiguration &cfg = (*config)[i]; - stream->active_ = true; cfg.setStream(stream); if (stream == outStream) { @@ -508,12 +500,14 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) return ret; cfg.stride = outputFormat.planes[0].bpl; + outActive = true; } else if (stream == vfStream) { ret = imgu->configureViewfinder(cfg, &outputFormat); if (ret) return ret; cfg.stride = outputFormat.planes[0].bpl; + vfActive = true; } else { /* * The RAW still capture stream just copies buffers from @@ -529,13 +523,13 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) * the configuration of the active one for that purpose (there should * be at least one active stream in the configuration request). */ - if (!outStream->active_) { + if (!outActive) { ret = imgu->configureOutput(config->at(0), &outputFormat); if (ret) return ret; } - if (!vfStream->active_) { + if (!vfActive) { ret = imgu->configureViewfinder(config->at(0), &outputFormat); if (ret) return ret; @@ -555,7 +549,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) /* Apply the "pipe_mode" control to the ImgU subdevice. */ ControlList ctrls(imgu->imgu_->controls()); ctrls.set(V4L2_CID_IPU3_PIPE_MODE, - static_cast(vfStream->active_ ? IPU3PipeModeVideo : + static_cast(vfActive ? IPU3PipeModeVideo : IPU3PipeModeStillCapture)); ret = imgu->imgu_->setControls(&ctrls); if (ret) { From patchwork Sat Jun 27 03:00:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8453 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 39974C2E66 for ; Sat, 27 Jun 2020 03:01:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 13F9760AFF; Sat, 27 Jun 2020 05:01:03 +0200 (CEST) Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA467609A5 for ; Sat, 27 Jun 2020 05:00:57 +0200 (CEST) X-Halon-ID: 588fc2f9-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 588fc2f9-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:24 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:41 +0200 Message-Id: <20200627030043.2088585-12-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 11/13] libcamera: ipu3: Remove IPU3Stream 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 pipeline specific subclass of the pipeline is empty, remove it. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/ipu3.cpp | 32 ++++++++++++---------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index b72b631cdc051aab..0ebd762982142471 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -31,10 +31,6 @@ namespace libcamera { LOG_DEFINE_CATEGORY(IPU3) -class IPU3Stream : public Stream -{ -}; - class IPU3CameraData : public CameraData { public: @@ -49,9 +45,9 @@ public: CIO2Device cio2_; ImgUDevice *imgu_; - IPU3Stream outStream_; - IPU3Stream vfStream_; - IPU3Stream rawStream_; + Stream outStream_; + Stream vfStream_; + Stream rawStream_; }; class IPU3CameraConfiguration : public CameraConfiguration @@ -62,7 +58,7 @@ public: Status validate() override; const StreamConfiguration &cio2Format() const { return cio2Configuration_; }; - const std::vector &streams() { return streams_; } + const std::vector &streams() { return streams_; } private: static constexpr unsigned int IPU3_BUFFER_COUNT = 4; @@ -80,7 +76,7 @@ private: const IPU3CameraData *data_; StreamConfiguration cio2Configuration_; - std::vector streams_; + std::vector streams_; }; class PipelineHandlerIPU3 : public PipelineHandler @@ -144,7 +140,7 @@ void IPU3CameraConfiguration::assignStreams() * resolution is equal to the sensor resolution, and the viewfinder * stream otherwise. */ - std::set availableStreams = { + std::set availableStreams = { &data_->outStream_, &data_->vfStream_, &data_->rawStream_, @@ -162,7 +158,7 @@ void IPU3CameraConfiguration::assignStreams() for (const StreamConfiguration &cfg : config_) { const PixelFormatInfo &info = PixelFormatInfo::info(cfg.pixelFormat); - const IPU3Stream *stream; + const Stream *stream; if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) stream = &data_->rawStream_; @@ -265,7 +261,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() for (unsigned int i = 0; i < config_.size(); ++i) { StreamConfiguration &cfg = config_[i]; const StreamConfiguration oldCfg = cfg; - const IPU3Stream *stream = streams_[i]; + const Stream *stream = streams_[i]; if (stream == &data_->rawStream_) { cfg = cio2Configuration_; @@ -297,7 +293,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera, { IPU3CameraData *data = cameraData(camera); IPU3CameraConfiguration *config; - std::set streams = { + std::set streams = { &data->outStream_, &data->vfStream_, &data->rawStream_, @@ -307,7 +303,7 @@ CameraConfiguration *PipelineHandlerIPU3::generateConfiguration(Camera *camera, for (const StreamRole role : roles) { StreamConfiguration cfg = {}; - IPU3Stream *stream = nullptr; + Stream *stream = nullptr; cfg.pixelFormat = formats::NV12; @@ -415,8 +411,8 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) IPU3CameraConfiguration *config = static_cast(c); IPU3CameraData *data = cameraData(camera); - IPU3Stream *outStream = &data->outStream_; - IPU3Stream *vfStream = &data->vfStream_; + Stream *outStream = &data->outStream_; + Stream *vfStream = &data->vfStream_; CIO2Device *cio2 = &data->cio2_; ImgUDevice *imgu = data->imgu_; V4L2DeviceFormat outputFormat; @@ -489,7 +485,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) * unwanted modifications of camera data in the configuration * validate() implementation. */ - IPU3Stream *stream = const_cast(config->streams()[i]); + Stream *stream = const_cast(config->streams()[i]); StreamConfiguration &cfg = (*config)[i]; cfg.setStream(stream); @@ -679,7 +675,7 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) /* Queue all buffers from the request aimed for the ImgU. */ for (auto it : request->buffers()) { - IPU3Stream *stream = static_cast(it.first); + Stream *stream = static_cast(it.first); FrameBuffer *buffer = it.second; int ret; From patchwork Sat Jun 27 03:00:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8454 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 87EBAC2E67 for ; Sat, 27 Jun 2020 03:01:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 35B9A60B08; Sat, 27 Jun 2020 05:01:03 +0200 (CEST) Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 85F5C60B08 for ; Sat, 27 Jun 2020 05:00:58 +0200 (CEST) X-Halon-ID: 58ed2642-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 58ed2642-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:25 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:42 +0200 Message-Id: <20200627030043.2088585-13-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 12/13] libcamera: ipu3: Align how CIO2 and ImgU are stored in CameraData 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" One is a pointer and the other is not. It is unintuitive to interact with and with our current design of one ImgU for each camera there is no advantage of having it as a pointer. Our current design is unlikely to change as the system really only has one ImgU. Align the two to make the pipeline more consistent. Signed-off-by: Niklas Söderlund --- src/libcamera/pipeline/ipu3/ipu3.cpp | 48 ++++++++++++---------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 0ebd762982142471..6ae4728b470f9487 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -43,7 +43,7 @@ public: void cio2BufferReady(FrameBuffer *buffer); CIO2Device cio2_; - ImgUDevice *imgu_; + ImgUDevice imgu_; Stream outStream_; Stream vfStream_; @@ -117,8 +117,6 @@ private: int allocateBuffers(Camera *camera); int freeBuffers(Camera *camera); - ImgUDevice imgu0_; - ImgUDevice imgu1_; MediaDevice *cio2MediaDev_; MediaDevice *imguMediaDev_; }; @@ -414,7 +412,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) Stream *outStream = &data->outStream_; Stream *vfStream = &data->vfStream_; CIO2Device *cio2 = &data->cio2_; - ImgUDevice *imgu = data->imgu_; + ImgUDevice *imgu = &data->imgu_; V4L2DeviceFormat outputFormat; int ret; @@ -456,7 +454,7 @@ int PipelineHandlerIPU3::configure(Camera *camera, CameraConfiguration *c) * stream which is for raw capture, in which case no buffers will * ever be queued to the ImgU. */ - ret = data->imgu_->enableLinks(true); + ret = data->imgu_.enableLinks(true); if (ret) return ret; @@ -563,9 +561,9 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream, unsigned int count = stream->configuration().bufferCount; if (stream == &data->outStream_) - return data->imgu_->output_.dev->exportBuffers(count, buffers); + return data->imgu_.output_.dev->exportBuffers(count, buffers); else if (stream == &data->vfStream_) - return data->imgu_->viewfinder_.dev->exportBuffers(count, buffers); + return data->imgu_.viewfinder_.dev->exportBuffers(count, buffers); else if (stream == &data->rawStream_) return data->cio2_.exportBuffers(count, buffers); @@ -583,7 +581,7 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream, int PipelineHandlerIPU3::allocateBuffers(Camera *camera) { IPU3CameraData *data = cameraData(camera); - ImgUDevice *imgu = data->imgu_; + ImgUDevice *imgu = &data->imgu_; unsigned int bufferCount; int ret; @@ -604,7 +602,7 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera) { IPU3CameraData *data = cameraData(camera); - data->imgu_->freeBuffers(); + data->imgu_.freeBuffers(); return 0; } @@ -613,7 +611,7 @@ int PipelineHandlerIPU3::start(Camera *camera) { IPU3CameraData *data = cameraData(camera); CIO2Device *cio2 = &data->cio2_; - ImgUDevice *imgu = data->imgu_; + ImgUDevice *imgu = &data->imgu_; int ret; /* Allocate buffers for internal pipeline usage. */ @@ -650,7 +648,7 @@ void PipelineHandlerIPU3::stop(Camera *camera) IPU3CameraData *data = cameraData(camera); int ret = 0; - ret |= data->imgu_->stop(); + ret |= data->imgu_.stop(); ret |= data->cio2_.stop(); if (ret) LOG(IPU3, Warning) << "Failed to stop camera " @@ -680,9 +678,9 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) int ret; if (stream == &data->outStream_) - ret = data->imgu_->output_.dev->queueBuffer(buffer); + ret = data->imgu_.output_.dev->queueBuffer(buffer); else if (stream == &data->vfStream_) - ret = data->imgu_->viewfinder_.dev->queueBuffer(buffer); + ret = data->imgu_.viewfinder_.dev->queueBuffer(buffer); else continue; @@ -757,16 +755,6 @@ bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) */ int PipelineHandlerIPU3::registerCameras() { - int ret; - - ret = imgu0_.init(imguMediaDev_, 0); - if (ret) - return ret; - - ret = imgu1_.init(imguMediaDev_, 1); - if (ret) - return ret; - /* * For each CSI-2 receiver on the IPU3, create a Camera if an * image sensor is connected to it and the sensor can produce images @@ -774,6 +762,8 @@ int PipelineHandlerIPU3::registerCameras() */ unsigned int numCameras = 0; for (unsigned int id = 0; id < 4 && numCameras < 2; ++id) { + int ret; + std::unique_ptr data = std::make_unique(this); std::set streams = { @@ -796,7 +786,9 @@ int PipelineHandlerIPU3::registerCameras() * only, and assign imgu0 to the first one and imgu1 to the * second. */ - data->imgu_ = numCameras ? &imgu1_ : &imgu0_; + ret = data->imgu_.init(imguMediaDev_, numCameras); + if (ret) + return ret; /* * Connect video devices' 'bufferReady' signals to their @@ -808,11 +800,11 @@ int PipelineHandlerIPU3::registerCameras() */ data->cio2_.bufferReady.connect(data.get(), &IPU3CameraData::cio2BufferReady); - data->imgu_->input_->bufferReady.connect(&data->cio2_, + data->imgu_.input_->bufferReady.connect(&data->cio2_, &CIO2Device::tryReturnBuffer); - data->imgu_->output_.dev->bufferReady.connect(data.get(), + data->imgu_.output_.dev->bufferReady.connect(data.get(), &IPU3CameraData::imguOutputBufferReady); - data->imgu_->viewfinder_.dev->bufferReady.connect(data.get(), + data->imgu_.viewfinder_.dev->bufferReady.connect(data.get(), &IPU3CameraData::imguOutputBufferReady); /* Create and register the Camera instance. */ @@ -881,7 +873,7 @@ void IPU3CameraData::cio2BufferReady(FrameBuffer *buffer) return; } - imgu_->input_->queueBuffer(buffer); + imgu_.input_->queueBuffer(buffer); } REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3); From patchwork Sat Jun 27 03:00:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 8455 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 E354CC2E66 for ; Sat, 27 Jun 2020 03:01:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4FCBD60C50; Sat, 27 Jun 2020 05:01:03 +0200 (CEST) Received: from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net [195.74.38.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 51B7E60BEB for ; Sat, 27 Jun 2020 05:00:59 +0200 (CEST) X-Halon-ID: 594ea5c4-b822-11ea-86ee-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de [79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 594ea5c4-b822-11ea-86ee-0050569116f7; Sat, 27 Jun 2020 05:00:25 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 27 Jun 2020 05:00:43 +0200 Message-Id: <20200627030043.2088585-14-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> References: <20200627030043.2088585-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 13/13] libcamera: ipu3: imgu: Remove ImgUOutput 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 struct ImgUOutput now only contains one member that are in use, the video device. Remove the struct and use the video device directly instead. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/ipu3/imgu.cpp | 55 ++++++++++++---------------- src/libcamera/pipeline/ipu3/imgu.h | 25 ++++--------- src/libcamera/pipeline/ipu3/ipu3.cpp | 12 +++--- 3 files changed, 37 insertions(+), 55 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/imgu.cpp b/src/libcamera/pipeline/ipu3/imgu.cpp index d54e844d9bfc5147..a601ca3fa2b1803f 100644 --- a/src/libcamera/pipeline/ipu3/imgu.cpp +++ b/src/libcamera/pipeline/ipu3/imgu.cpp @@ -55,31 +55,22 @@ int ImgUDevice::init(MediaDevice *media, unsigned int index) if (ret) return ret; - output_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " output"); - ret = output_.dev->open(); + output_ = V4L2VideoDevice::fromEntityName(media, name_ + " output"); + ret = output_->open(); if (ret) return ret; - output_.pad = PAD_OUTPUT; - output_.name = "output"; - - viewfinder_.dev = V4L2VideoDevice::fromEntityName(media, + viewfinder_ = V4L2VideoDevice::fromEntityName(media, name_ + " viewfinder"); - ret = viewfinder_.dev->open(); + ret = viewfinder_->open(); if (ret) return ret; - viewfinder_.pad = PAD_VF; - viewfinder_.name = "viewfinder"; - - stat_.dev = V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat"); - ret = stat_.dev->open(); + stat_ = V4L2VideoDevice::fromEntityName(media, name_ + " 3a stat"); + ret = stat_->open(); if (ret) return ret; - stat_.pad = PAD_STAT; - stat_.name = "stat"; - return 0; } @@ -142,19 +133,19 @@ int ImgUDevice::configureInput(const Size &size, int ImgUDevice::configureOutput(const StreamConfiguration &cfg, V4L2DeviceFormat *outputFormat) { - return configureVideoDevice(output_.dev, PAD_OUTPUT, cfg, outputFormat); + return configureVideoDevice(output_, PAD_OUTPUT, cfg, outputFormat); } int ImgUDevice::configureViewfinder(const StreamConfiguration &cfg, V4L2DeviceFormat *outputFormat) { - return configureVideoDevice(viewfinder_.dev, PAD_VF, cfg, outputFormat); + return configureVideoDevice(viewfinder_, PAD_VF, cfg, outputFormat); } int ImgUDevice::configureStat(const StreamConfiguration &cfg, V4L2DeviceFormat *outputFormat) { - return configureVideoDevice(stat_.dev, PAD_STAT, cfg, outputFormat); + return configureVideoDevice(stat_, PAD_STAT, cfg, outputFormat); } int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad, @@ -170,7 +161,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad, return ret; /* No need to apply format to the stat node. */ - if (dev == stat_.dev) + if (dev == stat_) return 0; *outputFormat = {}; @@ -182,7 +173,7 @@ int ImgUDevice::configureVideoDevice(V4L2VideoDevice *dev, unsigned int pad, if (ret) return ret; - const char *name = dev == output_.dev ? "output" : "viewfinder"; + const char *name = dev == output_ ? "output" : "viewfinder"; LOG(IPU3, Debug) << "ImgU " << name << " format = " << outputFormat->toString(); @@ -208,19 +199,19 @@ int ImgUDevice::allocateBuffers(unsigned int bufferCount) * * \todo To be revised when we'll actually use the stat node. */ - ret = stat_.dev->importBuffers(bufferCount); + ret = stat_->importBuffers(bufferCount); if (ret < 0) { LOG(IPU3, Error) << "Failed to allocate ImgU stat buffers"; goto error; } - ret = output_.dev->importBuffers(bufferCount); + ret = output_->importBuffers(bufferCount); if (ret < 0) { LOG(IPU3, Error) << "Failed to import ImgU output buffers"; goto error; } - ret = viewfinder_.dev->importBuffers(bufferCount); + ret = viewfinder_->importBuffers(bufferCount); if (ret < 0) { LOG(IPU3, Error) << "Failed to import ImgU viewfinder buffers"; goto error; @@ -241,15 +232,15 @@ void ImgUDevice::freeBuffers() { int ret; - ret = output_.dev->releaseBuffers(); + ret = output_->releaseBuffers(); if (ret) LOG(IPU3, Error) << "Failed to release ImgU output buffers"; - ret = stat_.dev->releaseBuffers(); + ret = stat_->releaseBuffers(); if (ret) LOG(IPU3, Error) << "Failed to release ImgU stat buffers"; - ret = viewfinder_.dev->releaseBuffers(); + ret = viewfinder_->releaseBuffers(); if (ret) LOG(IPU3, Error) << "Failed to release ImgU viewfinder buffers"; @@ -263,19 +254,19 @@ int ImgUDevice::start() int ret; /* Start the ImgU video devices. */ - ret = output_.dev->streamOn(); + ret = output_->streamOn(); if (ret) { LOG(IPU3, Error) << "Failed to start ImgU output"; return ret; } - ret = viewfinder_.dev->streamOn(); + ret = viewfinder_->streamOn(); if (ret) { LOG(IPU3, Error) << "Failed to start ImgU viewfinder"; return ret; } - ret = stat_.dev->streamOn(); + ret = stat_->streamOn(); if (ret) { LOG(IPU3, Error) << "Failed to start ImgU stat"; return ret; @@ -294,9 +285,9 @@ int ImgUDevice::stop() { int ret; - ret = output_.dev->streamOff(); - ret |= viewfinder_.dev->streamOff(); - ret |= stat_.dev->streamOff(); + ret = output_->streamOff(); + ret |= viewfinder_->streamOff(); + ret |= stat_->streamOff(); ret |= input_->streamOff(); return ret; diff --git a/src/libcamera/pipeline/ipu3/imgu.h b/src/libcamera/pipeline/ipu3/imgu.h index f8fd54089753b40e..2ac77ce5719f88f1 100644 --- a/src/libcamera/pipeline/ipu3/imgu.h +++ b/src/libcamera/pipeline/ipu3/imgu.h @@ -24,28 +24,19 @@ struct StreamConfiguration; class ImgUDevice { public: - /* ImgU output descriptor: group data specific to an ImgU output. */ - struct ImgUOutput { - V4L2VideoDevice *dev; - unsigned int pad; - std::string name; - }; - ImgUDevice() - : imgu_(nullptr), input_(nullptr) + : imgu_(nullptr), input_(nullptr), output_(nullptr), + viewfinder_(nullptr), stat_(nullptr) { - output_.dev = nullptr; - viewfinder_.dev = nullptr; - stat_.dev = nullptr; } ~ImgUDevice() { delete imgu_; delete input_; - delete output_.dev; - delete viewfinder_.dev; - delete stat_.dev; + delete output_; + delete viewfinder_; + delete stat_; } int init(MediaDevice *media, unsigned int index); @@ -68,9 +59,9 @@ public: V4L2Subdevice *imgu_; V4L2VideoDevice *input_; - ImgUOutput output_; - ImgUOutput viewfinder_; - ImgUOutput stat_; + V4L2VideoDevice *output_; + V4L2VideoDevice *viewfinder_; + V4L2VideoDevice *stat_; /* \todo Add param video device for 3A tuning */ private: diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 6ae4728b470f9487..c25bcaaeb5fb813f 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -561,9 +561,9 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream, unsigned int count = stream->configuration().bufferCount; if (stream == &data->outStream_) - return data->imgu_.output_.dev->exportBuffers(count, buffers); + return data->imgu_.output_->exportBuffers(count, buffers); else if (stream == &data->vfStream_) - return data->imgu_.viewfinder_.dev->exportBuffers(count, buffers); + return data->imgu_.viewfinder_->exportBuffers(count, buffers); else if (stream == &data->rawStream_) return data->cio2_.exportBuffers(count, buffers); @@ -678,9 +678,9 @@ int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) int ret; if (stream == &data->outStream_) - ret = data->imgu_.output_.dev->queueBuffer(buffer); + ret = data->imgu_.output_->queueBuffer(buffer); else if (stream == &data->vfStream_) - ret = data->imgu_.viewfinder_.dev->queueBuffer(buffer); + ret = data->imgu_.viewfinder_->queueBuffer(buffer); else continue; @@ -802,9 +802,9 @@ int PipelineHandlerIPU3::registerCameras() &IPU3CameraData::cio2BufferReady); data->imgu_.input_->bufferReady.connect(&data->cio2_, &CIO2Device::tryReturnBuffer); - data->imgu_.output_.dev->bufferReady.connect(data.get(), + data->imgu_.output_->bufferReady.connect(data.get(), &IPU3CameraData::imguOutputBufferReady); - data->imgu_.viewfinder_.dev->bufferReady.connect(data.get(), + data->imgu_.viewfinder_->bufferReady.connect(data.get(), &IPU3CameraData::imguOutputBufferReady); /* Create and register the Camera instance. */