From patchwork Thu Jul 9 08:41:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 8704 X-Patchwork-Delegate: jacopo@jmondi.org 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 740BBBD790 for ; Thu, 9 Jul 2020 08:38:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3AC04611AE; Thu, 9 Jul 2020 10:38:18 +0200 (CEST) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6165561158 for ; Thu, 9 Jul 2020 10:38:16 +0200 (CEST) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id ADE34100004; Thu, 9 Jul 2020 08:38:15 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Jul 2020 10:41:21 +0200 Message-Id: <20200709084128.5316-14-jacopo@jmondi.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200709084128.5316-1-jacopo@jmondi.org> References: <20200709084128.5316-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 13/20] libcamera: ipu3: Store CameraData as mutable in CameraConfiguration 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" A reference to the CameraData sub-class is stored in the IPU3CameraConfiguration as a const pointer, as the now removed comment reports "to allow the compiler catch un-wanted modifications during validate()". As the CameraData contains pointers to the available streams, which are actually assigned during validate, the comment and the rationale behind that choice seems now moot. Store CameraData as a mutable pointer and remove the comment and the const_cast<> required to assign streams. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund --- src/libcamera/pipeline/ipu3/ipu3.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index feabffe641e1..9fed6c1e5aa7 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -75,7 +75,7 @@ private: * reference to the camera data, store a new reference to the camera. */ std::shared_ptr camera_; - const IPU3CameraData *data_; + IPU3CameraData *data_; StreamConfiguration cio2Configuration_; std::vector streams_; @@ -207,7 +207,7 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() cfg.size = cio2Configuration_.size; cfg.pixelFormat = cio2Configuration_.pixelFormat; cfg.bufferCount = cio2Configuration_.bufferCount; - cfg.setStream(const_cast(&data_->rawStream_)); + cfg.setStream(&data_->rawStream_); LOG(IPU3, Debug) << "Assigned " << cfg.toString() << " to the raw stream"; @@ -256,27 +256,19 @@ CameraConfiguration::Status IPU3CameraConfiguration::validate() cfg.bufferCount = IPU3_BUFFER_COUNT; cfg.pixelFormat = formats::NV12; - /* - * Use a const_cast<> here instead of storing a mutable stream - * pointer in the configuration to let the compiler catch - * unwanted modifications of camera data in the configuration - * validate() implementation. - */ - Stream *stream; if (mainOutputAvailable && (oldCfg.size == yuvSize || outCount == 1)) { - stream = const_cast(&data_->outStream_); + cfg.setStream(&data_->outStream_); mainOutputAvailable = false; LOG(IPU3, Debug) << "Assigned " << cfg.toString() << " to the main output"; } else { - stream = const_cast(&data_->vfStream_); + cfg.setStream(&data_->vfStream_); LOG(IPU3, Debug) << "Assigned " << cfg.toString() << " to the viewfinder output"; } - cfg.setStream(stream); if (cfg.pixelFormat != oldCfg.pixelFormat || cfg.size != oldCfg.size) {