From patchwork Tue Aug 2 10:29:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 16903 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 51D3BC3276 for ; Tue, 2 Aug 2022 10:29:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0F5246331C; Tue, 2 Aug 2022 12:29:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1659436198; bh=FtFd22lL6VR968rYEokrScVZxJZYgXXbbuNzHEkOY4w=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Pt0kopp1g9hNtfJ+rL5GyvpdNp/sGcaLQG8M7xu3biiQRB9gI95/V5kLLFc8WxMdc E3A6ifywcZn+yJCTl+zOvErbiPZZYcjPJ115f/1Ve5oR3qffcRNsZHhpzFKSD25kyF 7PYGbVXyw1rM3PBZ2QX+2aik+D8KWK1HOwIGIdaNpNEYrFTkQ0w8gtK187o1SbjpeJ K+B+hALupTLDJq/m96Mf2/TN6eRLwhhWFqc+65hvu6u9XrPwWsbTcPyonInBcm+NFg p+HO355tm4k+RpP1RjyHZX5qDtZY871LWct5wWbU06JnDnHvRU6gqDUoh0X/Qmjo8k VI0M5Pujm7BFw== Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DA7F86331B for ; Tue, 2 Aug 2022 12:29:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="TqJKO6sH"; dkim-atps=neutral Received: by mail-pg1-x52f.google.com with SMTP id d7so8949308pgc.13 for ; Tue, 02 Aug 2022 03:29:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jbu0snkTEI4cpm0JAWs7QyslODoBJyLzd9cT/bBu3p8=; b=TqJKO6sHdAVQnSl5XEzzBzWpHxLfK3iOW1TwtUk8ocGRSQN7Me50Wn+Hzxy37zFlE7 sRkLha/EKt2/kjuGRqQb6QUdOSXA0rlGoYwTB2a7hPnAhSncEYom1OggBW/LBhWGT3jw nokv/LAQOB5GWNkrIM2mma9T1XwdwcFotxisI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jbu0snkTEI4cpm0JAWs7QyslODoBJyLzd9cT/bBu3p8=; b=aVig1wFGs4Kr8cbaasi9RFC13tVfKYNkY6+cvutRUEtlzSCnWKSt5l9sbt/xwCvW/J B/GvGLluvNDd7fMpY9ardFcUw89X0UdCnT2UUi6tBqcH6MZ6M0OGVVGZUnFgW1IrjvUy b1GfxHg7Zpfoj9XmjXYTikYVvihcyvC6JbxvNL1CUlOTdhCwiyuJYAuKMfCXGgW/BlQf 3LtmDtlq/evRcHiuRvFjZGRzxcAdLlSTRyed8hEv65OqCSXwqDuwC4E2H6f05Ph49XXF 6bZ99+MTuU2VHmEgi54ocAaaSOBzMpJsawVXFM3ZFt3DnVAWc2Qpu6q57gFy4PvxMa/T CS2w== X-Gm-Message-State: AJIora86Jp9QJlnPTq+tH1QJb+uQwV9MpbRw60prNQn60zWIutaBYWMz bkU1a+gABglVOSlCUQXa6hWouQWww4Zadw== X-Google-Smtp-Source: AGRyM1uyXNcUn/uagE6Ic0VubDA6blZ/Qn2VKURU9OQPQmC9KJdJLsUk5EGULNbYFOxzOsd7PaetjA== X-Received: by 2002:a63:1510:0:b0:41b:3901:2c13 with SMTP id v16-20020a631510000000b0041b39012c13mr15835487pgl.341.1659436194957; Tue, 02 Aug 2022 03:29:54 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (231.137.80.34.bc.googleusercontent.com. [34.80.137.231]) by smtp.gmail.com with ESMTPSA id t15-20020a170902e84f00b0016db88f69a2sm1955128plg.141.2022.08.02.03.29.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 03:29:54 -0700 (PDT) X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Date: Tue, 2 Aug 2022 10:29:38 +0000 Message-Id: <20220802102943.3221109-5-chenghaoyang@google.com> X-Mailer: git-send-email 2.37.1.455.g008518b4e5-goog In-Reply-To: <20220802102943.3221109-1-chenghaoyang@google.com> References: <20220802102943.3221109-1-chenghaoyang@google.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 4/9] ipu3: Add StillCapture stream and imgu1 param 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: , X-Patchwork-Original-From: Harvey Yang via libcamera-devel From: Cheng-Hao Yang Reply-To: Harvey Yang Cc: Harvey Yang Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Harvey Yang This patch adds the StillCapture stream and ImgU1 param buffers. ImgU1 statistics buffers will be ignored, as they're not needed for 3A. The following patches will enable imgu1 to handle StillCapture stream specifically, when the imgu0 is needed to handle video/preview streams. Signed-off-by: Harvey Yang --- src/libcamera/pipeline/ipu3/frames.cpp | 23 +++++++++++++++++++++-- src/libcamera/pipeline/ipu3/frames.h | 8 +++++++- src/libcamera/pipeline/ipu3/ipu3.cpp | 20 +++++++++++++++++++- 3 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/frames.cpp b/src/libcamera/pipeline/ipu3/frames.cpp index a4c3477c..f9b705a5 100644 --- a/src/libcamera/pipeline/ipu3/frames.cpp +++ b/src/libcamera/pipeline/ipu3/frames.cpp @@ -23,7 +23,8 @@ IPU3Frames::IPU3Frames() } void IPU3Frames::init(const std::vector> ¶mBuffers, - const std::vector> &statBuffers) + const std::vector> &statBuffers, + const std::vector> &captureParamBuffers) { for (const std::unique_ptr &buffer : paramBuffers) availableParamBuffers_.push(buffer.get()); @@ -31,6 +32,9 @@ void IPU3Frames::init(const std::vector> ¶mBuff for (const std::unique_ptr &buffer : statBuffers) availableStatBuffers_.push(buffer.get()); + for (const std::unique_ptr &buffer : captureParamBuffers) + availableCaptureParamBuffers_.push(buffer.get()); + frameInfo_.clear(); } @@ -38,6 +42,7 @@ void IPU3Frames::clear() { availableParamBuffers_ = {}; availableStatBuffers_ = {}; + availableCaptureParamBuffers_ = {}; } IPU3Frames::Info *IPU3Frames::create(Request *request) @@ -54,14 +59,22 @@ IPU3Frames::Info *IPU3Frames::create(Request *request) return nullptr; } + if (availableCaptureParamBuffers_.empty()) { + LOG(IPU3, Debug) << "Capture parameters buffer underrun"; + return nullptr; + } + FrameBuffer *paramBuffer = availableParamBuffers_.front(); FrameBuffer *statBuffer = availableStatBuffers_.front(); + FrameBuffer *captureParamBuffer = availableCaptureParamBuffers_.front(); paramBuffer->_d()->setRequest(request); statBuffer->_d()->setRequest(request); + captureParamBuffer->_d()->setRequest(request); availableParamBuffers_.pop(); availableStatBuffers_.pop(); + availableCaptureParamBuffers_.pop(); /* \todo Remove the dynamic allocation of Info */ std::unique_ptr info = std::make_unique(); @@ -71,7 +84,9 @@ IPU3Frames::Info *IPU3Frames::create(Request *request) info->rawBuffer = nullptr; info->paramBuffer = paramBuffer; info->statBuffer = statBuffer; + info->captureParamBuffer = captureParamBuffer; info->paramDequeued = false; + info->captureParamDequeued = false; info->metadataProcessed = false; frameInfo_[id] = std::move(info); @@ -84,6 +99,7 @@ void IPU3Frames::remove(IPU3Frames::Info *info) /* Return params and stat buffer for reuse. */ availableParamBuffers_.push(info->paramBuffer); availableStatBuffers_.push(info->statBuffer); + availableCaptureParamBuffers_.push(info->captureParamBuffer); /* Delete the extended frame information. */ frameInfo_.erase(info->id); @@ -102,6 +118,9 @@ bool IPU3Frames::tryComplete(IPU3Frames::Info *info) if (!info->paramDequeued) return false; + if (!info->captureParamDequeued) + return false; + remove(info); bufferAvailable.emit(); @@ -131,7 +150,7 @@ IPU3Frames::Info *IPU3Frames::find(FrameBuffer *buffer) return info; if (info->rawBuffer == buffer || info->paramBuffer == buffer || - info->statBuffer == buffer) + info->statBuffer == buffer || info->captureParamBuffer == buffer) return info; } diff --git a/src/libcamera/pipeline/ipu3/frames.h b/src/libcamera/pipeline/ipu3/frames.h index 6e3cb915..8fcb8a14 100644 --- a/src/libcamera/pipeline/ipu3/frames.h +++ b/src/libcamera/pipeline/ipu3/frames.h @@ -36,16 +36,20 @@ public: FrameBuffer *paramBuffer; FrameBuffer *statBuffer; + FrameBuffer *captureParamBuffer; + ControlList effectiveSensorControls; bool paramDequeued; + bool captureParamDequeued; bool metadataProcessed; }; IPU3Frames(); void init(const std::vector> ¶mBuffers, - const std::vector> &statBuffers); + const std::vector> &statBuffers, + const std::vector> &captureParamBuffers); void clear(); Info *create(Request *request); @@ -61,6 +65,8 @@ private: std::queue availableParamBuffers_; std::queue availableStatBuffers_; + std::queue availableCaptureParamBuffers_; + std::map> frameInfo_; }; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index c3e90f22..4efa1019 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -70,6 +70,7 @@ public: Stream outStream_; Stream vfStream_; Stream rawStream_; + Stream outCaptureStream_; Rectangle cropRegion_; bool supportsFlips_; @@ -693,6 +694,8 @@ int PipelineHandlerIPU3::exportFrameBuffers(Camera *camera, Stream *stream, return imgu0_.viewfinder_->exportBuffers(count, buffers); else if (stream == &data->rawStream_) return data->cio2_.exportBuffers(count, buffers); + else if (stream == &data->outCaptureStream_) + return imgu1_.output_->exportBuffers(count, buffers); return -EINVAL; } @@ -715,11 +718,17 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera) data->outStream_.configuration().bufferCount, data->vfStream_.configuration().bufferCount, data->rawStream_.configuration().bufferCount, + data->outCaptureStream_.configuration().bufferCount, }); ret = imgu0_.allocateBuffers(bufferCount); if (ret < 0) return ret; + ret = imgu1_.allocateBuffers(bufferCount); + if (ret < 0) { + imgu0_.freeBuffers(); + return ret; + } /* Map buffers to the IPA. */ unsigned int ipaBufferId = 1; @@ -734,9 +743,14 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera) ipaBuffers_.emplace_back(buffer->cookie(), buffer->planes()); } + for (const std::unique_ptr &buffer : imgu1_.paramBuffers_) { + buffer->setCookie(ipaBufferId++); + ipaBuffers_.emplace_back(buffer->cookie(), buffer->planes()); + } + data->ipa_->mapBuffers(ipaBuffers_); - data->frameInfos_.init(imgu0_.paramBuffers_, imgu0_.statBuffers_); + data->frameInfos_.init(imgu0_.paramBuffers_, imgu0_.statBuffers_, imgu1_.paramBuffers_); data->frameInfos_.bufferAvailable.connect( data, &IPU3CameraData::queuePendingRequests); @@ -757,6 +771,7 @@ int PipelineHandlerIPU3::freeBuffers(Camera *camera) ipaBuffers_.clear(); imgu0_.freeBuffers(); + imgu1_.freeBuffers(); return 0; } @@ -1135,6 +1150,7 @@ int PipelineHandlerIPU3::registerCameras() &data->outStream_, &data->vfStream_, &data->rawStream_, + &data->outCaptureStream_, }; CIO2Device *cio2 = &data->cio2_; @@ -1310,6 +1326,8 @@ void IPU3CameraData::paramsBufferReady(unsigned int id) imgu0_->param_->queueBuffer(info->paramBuffer); imgu0_->stat_->queueBuffer(info->statBuffer); imgu0_->input_->queueBuffer(info->rawBuffer); + + info->captureParamDequeued = true; } void IPU3CameraData::metadataReady(unsigned int id, const ControlList &metadata)