From patchwork Wed Apr 26 13:10:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18560 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 6DBDCC3275 for ; Wed, 26 Apr 2023 13:13:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1EDB3627FF; Wed, 26 Apr 2023 15:13:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1682514824; bh=oY+NgQ2D+mWVJsnVUJdRNmCftrAmbxszpbVYstEIXzo=; 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=bui+jd2/0713KThCN1uGyCouuDjn7KKGTmLB3/ooXDxGoEswIG0XFt74cWX1HAdNg iy4AtiLUZ/rRSNhO0xWE1e5+fnu4QWZXyk4SG3yxNsRCjgQjSW6uyuNsB7S5YhazHc OIk5E+PNgUQDk16pVTAWdcb6nlvuPO1TXP8weqo2E90PNP2vfeL/fbx67XUOZsfaWa 5tmn9mIeTES4n5omCZtjr6/4UCTQuzxUldDVlpgarmaOKX62CmpZVdPi+MDjrdhmnM Kr8wIsQ2xCzCioURWuzklk8zfin7EVLKIUKpp8HdXxA0stPl1Arziz8+HTCytws6vO HZ8feF+R4T99Q== Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7BAD8627E4 for ; Wed, 26 Apr 2023 15:13:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="hpMjk2ty"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-3f1cfed93e2so43567585e9.3 for ; Wed, 26 Apr 2023 06:13:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1682514822; x=1685106822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OSX7rX2yvtgqkMky+H6ao7ePsv7HtXEeq3H1rxSd1s0=; b=hpMjk2tyXf7CbHbA8SfpqctftPf/osyxor5WsxzHFiBd5LoG5bL/irrYt6C9ZPx+Za BMqdAcs9QQX7j/bVDweCO8vHY7+pwYBFmrAL+QYNn6FOAuMhRjHLQj863sVK5/G8el3M PnSI4XFr1l1UMJ8GmsSrUW8lF3pGLELOkrhOMr1EpijcmS7ikW4H4UNTlpTdqXskx4A+ Lci3P5jYYMQLn6IflKN6JvSUrTVSO3nh1xb5VnbjiEP2UgYz983daooWljyTmNbdBcl8 sYqLEvonZtx9mM86YIe6p11qa/rJUg1u8Zf8OUTFHZ+qCoWRJRXTJel99tl1tlb8PHnG ub0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682514822; x=1685106822; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OSX7rX2yvtgqkMky+H6ao7ePsv7HtXEeq3H1rxSd1s0=; b=GNnnlCkWDhehH5OrOzfUwQ33YJhGvE0rLgMkpUbD+8MRUXZOWMCHvVWGs6tTNK1vu1 PhRzgp4E012QpDDpQXa60n3lRtlJoK8VVBBv00eAntwnEbbTSkVxfZgTw6p3yuJGGuwu ULAR0/XIOF7Nb8shBuHvgv7XgUNIjNHSPKZxAPSurQJV2PVprAB+01kl8bx3a3A9ZHiT SHGqZFTrEkxCBdplw7P0VN01CgIkdg98ZYvuqXiAbK1ux23Kzm3RR11XPjizRehDZzOk iJ2sKWJv3N3vPdupIL2XYBnzLj+15i8DVy4oymLg71E4cZrb8HSugDMp3e8sd0O7PUjZ u0lw== X-Gm-Message-State: AAQBX9cd/CCb+Zj89O9UTNTYXH1CS/r8iQdYkH6SqdPM4AL6YGtNYyvj SrJGNF3cnz0enCA4QMoHI9/kMDp55qdDyIhG+j37bA== X-Google-Smtp-Source: AKy350YlAofyDRw1OzbgnKdWPhP9hsd1mNW8xscNxLEq+kdp3fHXA0ikyVd/nzmfZC5Q83G7KOMuPA== X-Received: by 2002:a5d:4f07:0:b0:2f0:bd17:2d2c with SMTP id c7-20020a5d4f07000000b002f0bd172d2cmr13468851wru.9.1682514821870; Wed, 26 Apr 2023 06:13:41 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id k5-20020adff5c5000000b002f103ca90cdsm15780949wrp.101.2023.04.26.06.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Apr 2023 06:13:41 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 26 Apr 2023 14:10:57 +0100 Message-Id: <20230426131057.21550-14-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230426131057.21550-1-naush@raspberrypi.com> References: <20230426131057.21550-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 13/13] pipeline: vc4: Connect/disconnect IPA and dequeue signals on start/stop 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" We currently rely on a state check to see if any of the IPA and buffer dequeue signal functions need to run. Replace this check by explicitly disconnecting the appropriate signals on camera stop. Re-connect the signals on camera start. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/rpi/vc4/vc4.cpp | 54 +++++++++++--------------- 1 file changed, 23 insertions(+), 31 deletions(-) diff --git a/src/libcamera/pipeline/rpi/vc4/vc4.cpp b/src/libcamera/pipeline/rpi/vc4/vc4.cpp index bd7bfb3a7663..4b3f5a7fc9fe 100644 --- a/src/libcamera/pipeline/rpi/vc4/vc4.cpp +++ b/src/libcamera/pipeline/rpi/vc4/vc4.cpp @@ -315,11 +315,8 @@ int PipelineHandlerVc4::platformRegister(std::unique_ptr &camer /* An embedded data node will not be present if the sensor does not support it. */ MediaEntity *unicamEmbedded = unicam->getEntityByName("unicam-embedded"); - if (unicamEmbedded) { + if (unicamEmbedded) data->unicam_[Unicam::Embedded] = RPi::Stream("Unicam Embedded", unicamEmbedded); - data->unicam_[Unicam::Embedded].dev()->bufferReady.connect(data, - &Vc4CameraData::unicamBufferDequeue); - } /* Tag the ISP input stream as an import stream. */ data->isp_[Isp::Input] = RPi::Stream("ISP Input", ispOutput0, Flag::ImportOnly); @@ -327,18 +324,9 @@ int PipelineHandlerVc4::platformRegister(std::unique_ptr &camer data->isp_[Isp::Output1] = RPi::Stream("ISP Output1", ispCapture2); data->isp_[Isp::Stats] = RPi::Stream("ISP Stats", ispCapture3); - /* Wire up all the buffer connections. */ - data->unicam_[Unicam::Image].dev()->bufferReady.connect(data, &Vc4CameraData::unicamBufferDequeue); - data->isp_[Isp::Input].dev()->bufferReady.connect(data, &Vc4CameraData::ispInputDequeue); - data->isp_[Isp::Output0].dev()->bufferReady.connect(data, &Vc4CameraData::ispOutputDequeue); - data->isp_[Isp::Output1].dev()->bufferReady.connect(data, &Vc4CameraData::ispOutputDequeue); - data->isp_[Isp::Stats].dev()->bufferReady.connect(data, &Vc4CameraData::ispOutputDequeue); - if (data->sensorMetadata_ ^ !!data->unicam_[Unicam::Embedded].dev()) { LOG(RPI, Warning) << "Mismatch between Unicam and CamHelper for embedded data usage!"; data->sensorMetadata_ = false; - if (data->unicam_[Unicam::Embedded].dev()) - data->unicam_[Unicam::Embedded].dev()->bufferReady.disconnect(); } /* @@ -367,9 +355,7 @@ int PipelineHandlerVc4::platformRegister(std::unique_ptr &camer return -EINVAL; } - /* Write up all the IPA connections. */ - data->ipa_->processStatsComplete.connect(data, &Vc4CameraData::processStatsComplete); - data->ipa_->prepareIspComplete.connect(data, &Vc4CameraData::prepareIspComplete); + /* Wire up the default IPA connections. The others get connected on start() */ data->ipa_->setIspControls.connect(data, &Vc4CameraData::setIspControls); data->ipa_->setCameraTimeout.connect(data, &Vc4CameraData::setCameraTimeout); @@ -691,10 +677,31 @@ int Vc4CameraData::platformConfigureIpa(ipa::RPi::ConfigParams ¶ms) void Vc4CameraData::platformStart() { + unicam_[Unicam::Image].dev()->bufferReady.connect(this, &Vc4CameraData::unicamBufferDequeue); + isp_[Isp::Input].dev()->bufferReady.connect(this, &Vc4CameraData::ispInputDequeue); + isp_[Isp::Output0].dev()->bufferReady.connect(this, &Vc4CameraData::ispOutputDequeue); + isp_[Isp::Output1].dev()->bufferReady.connect(this, &Vc4CameraData::ispOutputDequeue); + isp_[Isp::Stats].dev()->bufferReady.connect(this, &Vc4CameraData::ispOutputDequeue); + ipa_->processStatsComplete.connect(this, &Vc4CameraData::processStatsComplete); + ipa_->prepareIspComplete.connect(this, &Vc4CameraData::prepareIspComplete); + + if (sensorMetadata_) + unicam_[Unicam::Embedded].dev()->bufferReady.connect(this, &Vc4CameraData::unicamBufferDequeue); } void Vc4CameraData::platformStop() { + unicam_[Unicam::Image].dev()->bufferReady.disconnect(); + isp_[Isp::Input].dev()->bufferReady.disconnect(); + isp_[Isp::Output0].dev()->bufferReady.disconnect(); + isp_[Isp::Output1].dev()->bufferReady.disconnect(); + isp_[Isp::Stats].dev()->bufferReady.disconnect(); + ipa_->processStatsComplete.disconnect(); + ipa_->prepareIspComplete.disconnect(); + + if (sensorMetadata_) + unicam_[Unicam::Embedded].dev()->bufferReady.disconnect(); + bayerQueue_ = {}; embeddedQueue_ = {}; } @@ -704,9 +711,6 @@ void Vc4CameraData::unicamBufferDequeue(FrameBuffer *buffer) RPi::Stream *stream = nullptr; unsigned int index; - if (!isRunning()) - return; - for (RPi::Stream &s : unicam_) { index = s.getBufferId(buffer); if (index) { @@ -743,9 +747,6 @@ void Vc4CameraData::unicamBufferDequeue(FrameBuffer *buffer) void Vc4CameraData::ispInputDequeue(FrameBuffer *buffer) { - if (!isRunning()) - return; - LOG(RPI, Debug) << "Stream ISP Input buffer complete" << ", buffer id " << unicam_[Unicam::Image].getBufferId(buffer) << ", timestamp: " << buffer->metadata().timestamp; @@ -760,9 +761,6 @@ void Vc4CameraData::ispOutputDequeue(FrameBuffer *buffer) RPi::Stream *stream = nullptr; unsigned int index; - if (!isRunning()) - return; - for (RPi::Stream &s : isp_) { index = s.getBufferId(buffer); if (index) { @@ -803,9 +801,6 @@ void Vc4CameraData::ispOutputDequeue(FrameBuffer *buffer) void Vc4CameraData::processStatsComplete(const ipa::RPi::BufferIds &buffers) { - if (!isRunning()) - return; - FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(buffers.stats & RPi::MaskID); handleStreamBuffer(buffer, &isp_[Isp::Stats]); @@ -846,9 +841,6 @@ void Vc4CameraData::prepareIspComplete(const ipa::RPi::BufferIds &buffers) unsigned int bayer = buffers.bayer & RPi::MaskID; FrameBuffer *buffer; - if (!isRunning()) - return; - buffer = unicam_[Unicam::Image].getBuffers().at(bayer & RPi::MaskID); LOG(RPI, Debug) << "Input re-queue to ISP, buffer id " << (bayer & RPi::MaskID) << ", timestamp: " << buffer->metadata().timestamp;