From patchwork Wed Apr 6 14:17:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 15639 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 7F7C3C3256 for ; Wed, 6 Apr 2022 14:17:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4A11765649; Wed, 6 Apr 2022 16:17:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1649254656; bh=OguJDJPfaEXUOIkbJ7xjx5mE7uSsWhyhsfTUwBVetwM=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=Mzq7midEXfuxmMaZ4SWiGla18RthZbquVl8H+mIotCe0JxHG0wA6UV1MJpecaKRTs 0kZydeIWSLqahPVfqTlqS2m43QNSEqFbaX9OfjVQVGY2jwnxzfR61jzl+pm4Voqr6b bxvHgn+N2HKUxawHU6PrHJFUwVhCoEbBcgupG5OWpqIFydFNsWe5Cl0zaRVklSuoYp LSU4agn2bvtVdaecW9jcyIumJxCWeu5NSCUtdRkpDUr49jOFpMcJ4e7H5SaTGveuP/ /fMArkObaRcRWNV1Xtzur9Z5JImKprvZIlRPYaX4jSg/I+6qKnm8Wdra4dc0/zj9g5 2xOOBJBDpK3Rw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id ED43C633A4 for ; Wed, 6 Apr 2022 16:17:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cZSMxoGw"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [27.57.186.178]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 098E5482; Wed, 6 Apr 2022 16:17:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1649254654; bh=OguJDJPfaEXUOIkbJ7xjx5mE7uSsWhyhsfTUwBVetwM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cZSMxoGwUIsGN+pvxyHli1ru6Lb5fEXUw00ppXnZB4JMzbPNBlZvTahiylibHFIOZ iB3egoueImhwXZqjvYLGwGsSeK6SWhRT8vrvZ54O/pbpCqkUptfGufduzNrfaJQQw9 lHLmalyK9LhrN7C0wHaORqVMuEqW6mJMnYFoiX6U= To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Apr 2022 19:47:07 +0530 Message-Id: <20220406141709.164794-5-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220406141709.164794-1-umang.jain@ideasonboard.com> References: <20220406141709.164794-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [IPAIPU3 PATCH v5 4/6] ipu3: Use the new IPAIPU3 interface X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Use the new IPAIPU3 interface that migrates the event-based ops to dedication functions. Signed-off-by: Umang Jain Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- ipu3.cpp | 101 ++++++++++++++++++++++--------------------------------- 1 file changed, 40 insertions(+), 61 deletions(-) diff --git a/ipu3.cpp b/ipu3.cpp index 6ab86e0..b6d2129 100644 --- a/ipu3.cpp +++ b/ipu3.cpp @@ -49,13 +49,16 @@ public: void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; - void processEvent(const IPU3Event &event) override; + void queueRequest(const uint32_t frame, const ControlList &controls) override; + void fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) override; + void processStatsBuffer(const uint32_t frame, const int64_t frameTimestamp, + const uint32_t bufferId, + const ControlList &sensorControls) override; private: void updateControls(const IPACameraSensorInfo &sensorInfo, const ControlInfoMap &sensorControls, ControlInfoMap *ipaControls); - void processControls(unsigned int frame, const ControlList &metadata); void runAiq(unsigned int frame); void fillParams(unsigned int frame, ipu3_uapi_params *params); void parseStatistics(unsigned int frame, @@ -321,54 +324,41 @@ void IPAIPU3::unmapBuffers(const std::vector &ids) } } -void IPAIPU3::processEvent(const IPU3Event &event) +void IPAIPU3::queueRequest([[maybe_unused]] unsigned int frame, + [[maybe_unused]] const ControlList &controls) { - switch (event.op) { - case EventProcessControls: { - processControls(event.frame, event.controls); - break; - } - case EventStatReady: { - auto it = buffers_.find(event.bufferId); - if (it == buffers_.end()) { - LOG(IPAIPU3, Error) << "Could not find stats buffer!"; - return; - } - - Span mem = it->second.maps()[0]; - const ipu3_uapi_stats_3a *stats = - reinterpret_cast(mem.data()); - - parseStatistics(event.frame, - event.frameTimestamp, - stats, - event.sensorControls); - break; - } - case EventFillParams: { - auto it = buffers_.find(event.bufferId); - if (it == buffers_.end()) { - LOG(IPAIPU3, Error) << "Could not find param buffer!"; - return; - } - - Span mem = it->second.maps()[0]; - ipu3_uapi_params *params = - reinterpret_cast(mem.data()); - - fillParams(event.frame, params); - break; - } - default: - LOG(IPAIPU3, Error) << "Unknown event " << event.op; - break; + /* \todo Start processing for 'frame' based on 'controls'. */ +} + +void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) +{ + auto it = buffers_.find(bufferId); + if (it == buffers_.end()) { + LOG(IPAIPU3, Error) << "Could not find params buffer"; + return; } + + Span mem = it->second.maps()[0]; + ipu3_uapi_params *params = + reinterpret_cast(mem.data()); + + fillParams(frame, params); } -void IPAIPU3::processControls([[maybe_unused]] unsigned int frame, - [[maybe_unused]] const ControlList &controls) +void IPAIPU3::processStatsBuffer(const uint32_t frame, const int64_t frameTimestamp, + const uint32_t bufferId, const ControlList &sensorControls) { - /* \todo Start processing for 'frame' based on 'controls'. */ + auto it = buffers_.find(bufferId); + if (it == buffers_.end()) { + LOG(IPAIPU3, Error) << "Could not find stats buffer"; + return; + } + + Span mem = it->second.maps()[0]; + const ipu3_uapi_stats_3a *stats = + reinterpret_cast(mem.data()); + + parseStatistics(frame, frameTimestamp, stats, sensorControls); } void IPAIPU3::runAiq([[maybe_unused]] unsigned int frame) @@ -424,10 +414,7 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params) setControls(frame); - IPU3Action op; - op.op = ActionParamFilled; - - queueFrameAction.emit(frame, op); + paramsBufferReady.emit(frame); } void IPAIPU3::parseStatistics(unsigned int frame, @@ -488,27 +475,19 @@ void IPAIPU3::parseStatistics(unsigned int frame, (sensorInfo_.pixelRate / 1e6); ctrls.set(controls::FrameDuration, frameDuration); - IPU3Action op; - op.op = ActionMetadataReady; - op.controls = ctrls; - - queueFrameAction.emit(frame, op); + metadataReady.emit(frame, ctrls); } void IPAIPU3::setControls(unsigned int frame) { - IPU3Action op; - op.op = ActionSetSensorControls; - ControlList sensorCtrls(ctrls_); sensorCtrls.set(V4L2_CID_EXPOSURE, static_cast(exposure_)); sensorCtrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain_)); - op.sensorControls = sensorCtrls; - - op.lensControls.set(V4L2_CID_FOCUS_ABSOLUTE, lensPosition_); + ControlList lensCtrls(ctrls_); + lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE, lensPosition_); - queueFrameAction.emit(frame, op); + setSensorControls.emit(frame, sensorCtrls, lensCtrls); } } /* namespace ipa::ipu3 */