From patchwork Sat Jul 4 00:52:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 8616 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 C21ECBE905 for ; Sat, 4 Jul 2020 00:52:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8ABAC60DF3; Sat, 4 Jul 2020 02:52:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PcC8wWHm"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 723E460DE4 for ; Sat, 4 Jul 2020 02:52:42 +0200 (CEST) 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 EC771814; Sat, 4 Jul 2020 02:52:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593823962; bh=KyOfb9eDOXqb+ehjjLEXoRYfLNnQuSMh6/4DDgSR4lA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PcC8wWHmDDTMGVbceQRv5IR7CaZWSiRz3TzDPW2SFGyRljL9aCXMzf/bdZeGVAWNS CEVQwTVQ64yX+dIHBlAQBEsc3tTHj22eL83+En4AOFzp7JWlT8FIkFUTxU2PHhGBpE dhdMWulRkB9cNFAA8FL2lS2iHymdWHPRnzC939I0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Sat, 4 Jul 2020 03:52:27 +0300 Message-Id: <20200704005227.21782-13-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> References: <20200704005227.21782-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 12/12] libcamera: pipeline: raspberrypi: Start IPA when starting camera 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 IPA is meant to be started when starting the camera, and stopped when stopping it. It was so far start early in order to handle the IPAInterface::processEvent() call related to lens shading table allocation before IPAInterface::configure() to pass the table to the IPA. Now that the lens shading table is passed through configure(), starting the IPA early isn't needed anymore. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi Reviewed-by: Naushir Patuck --- .../pipeline/raspberrypi/raspberrypi.cpp | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 9babf9f4a19c..c877820a6e1e 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -303,10 +303,6 @@ public: vcsm_.free(lsTable_); lsTable_ = nullptr; } - - /* Stop the IPA proxy thread. */ - if (ipa_) - ipa_->stop(); } void frameStarted(uint32_t sequence); @@ -800,6 +796,16 @@ int PipelineHandlerRPi::start(Camera *camera) ret = queueAllBuffers(camera); if (ret) { LOG(RPI, Error) << "Failed to queue buffers"; + stop(camera); + return ret; + } + + /* Start the IPA. */ + ret = data->ipa_->start(); + if (ret) { + LOG(RPI, Error) + << "Failed to start IPA for " << camera->name(); + stop(camera); return ret; } @@ -810,8 +816,10 @@ int PipelineHandlerRPi::start(Camera *camera) V4L2DeviceFormat sensorFormat; data->unicam_[Unicam::Image].dev()->getFormat(&sensorFormat); ret = data->isp_[Isp::Input].dev()->setFormat(&sensorFormat); - if (ret) + if (ret) { + stop(camera); return ret; + } /* Enable SOF event generation. */ data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(true); @@ -855,6 +863,9 @@ void PipelineHandlerRPi::stop(Camera *camera) data->bayerQueue_ = std::queue{}; data->embeddedQueue_ = std::queue{}; + /* Stop the IPA. */ + data->ipa_->stop(); + freeBuffers(camera); } @@ -1107,15 +1118,7 @@ int RPiCameraData::loadIPA() .configurationFile = ipa_->configurationFile(sensor_->model() + ".json") }; - ipa_->init(settings); - - /* - * Startup the IPA thread now. Without this call, none of the IPA API - * functions will run. - * - * It only gets stopped in the class destructor. - */ - return ipa_->start(); + return ipa_->init(settings); } int RPiCameraData::configureIPA()