From patchwork Thu Apr 8 08:51:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11868 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 48528BD16B for ; Thu, 8 Apr 2021 08:51:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 093E068800; Thu, 8 Apr 2021 10:51:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="J6Rt6StR"; dkim-atps=neutral Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5450687FB for ; Thu, 8 Apr 2021 10:51:12 +0200 (CEST) Received: by mail-pf1-x429.google.com with SMTP id n38so1324532pfv.2 for ; Thu, 08 Apr 2021 01:51:12 -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=AlMFdpjld/thmoA4QQbI8zwGsWKIYqW7MNGUakZcOnM=; b=J6Rt6StR8+HQt/WsIiA5kKMi5HfGDUdKkITXynfJOD+cgXyQXVpBKHTKQjJuInBJ93 uExRxwvQGGtn++pfBDzMMluCoxwjBPmNdB9mEeV77t+XvbeCZVyaUURg9tFFeiMtnmeK tVV4iSUh/ZlaKgdq5G/5L0AKtWfuHQkOZBEDI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AlMFdpjld/thmoA4QQbI8zwGsWKIYqW7MNGUakZcOnM=; b=QSxsY0SciP+2ZwgzD1Rj7iTlGX9zOGt3LTjMbzxUjM3Uy3UoAxSyh5Ufd116JTeqsK ko6760ZmeGJNqlgXPnLRitYVd95+DM5Q5qo1LlWVuD2xrEtCtndlXWVDnGydXiFMW6P0 6aoRFDNQ3jTkpLXE8MInhMvdvAj77eWtkkedCaYuJ1pCc9GTPwnxi+Ptq6NM1GdHmKnP b01H35il4Z0c5RHdwxtDpAaKXlbAGTqm5DEUYyA4E6gC30qq9ZxyD3qO+eZScAl/zp3C R8qsTkjZ5vVvt4VZU0rh6s7xlkpyjCjRRLWfngyyv75Eikl1LWA45Cck/T5/ffOj246T kYow== X-Gm-Message-State: AOAM533BJY5Q8pvpHCt3DWfBxswpKDQetNY6C5e1FlVZeRY6bsj9SYN/ Rl3k4eiYSGvW/EZ38i6sVyb7bBcxZnixzw== X-Google-Smtp-Source: ABdhPJzOZ1ldWj2T3o6zfR+eXro004N+iFHRSCogJiBvCjC7tEG6VGD+kBZ1F52n16mNs1ojLPlYMw== X-Received: by 2002:a63:ed49:: with SMTP id m9mr7158345pgk.323.1617871870548; Thu, 08 Apr 2021 01:51:10 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:8822:ec6c:14d8:eea9]) by smtp.gmail.com with ESMTPSA id g80sm1755993pfb.181.2021.04.08.01.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 01:51:10 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 8 Apr 2021 17:51:00 +0900 Message-Id: <20210408085101.1691729-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210408085101.1691729-1-hiroh@chromium.org> References: <20210408085101.1691729-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v3 2/3] libcamera: ipu3: Try queuing pending requests if a buffer is available 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" IPU3CameraData stores requests that have been failed due to a buffer shortage. The requests should be retried once enough buffers are available. This sets the retry function as signal to CIO2Device and IPU3Frame, and invokes it from CIO2Device::tryReturnBuffer() and IPU3Frame::remove(). Signed-off-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/cio2.cpp | 4 +++- src/libcamera/pipeline/ipu3/cio2.h | 3 +++ src/libcamera/pipeline/ipu3/frames.cpp | 6 ++++-- src/libcamera/pipeline/ipu3/frames.h | 5 +++++ src/libcamera/pipeline/ipu3/ipu3.cpp | 4 ++++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp index 3cd777d1..6490fd46 100644 --- a/src/libcamera/pipeline/ipu3/cio2.cpp +++ b/src/libcamera/pipeline/ipu3/cio2.cpp @@ -272,7 +272,7 @@ FrameBuffer *CIO2Device::queueBuffer(Request *request, FrameBuffer *rawBuffer) /* If no buffer is provided in the request, use an internal one. */ if (!buffer) { if (availableBuffers_.empty()) { - LOG(IPU3, Error) << "CIO2 buffer underrun"; + LOG(IPU3, Debug) << "CIO2 buffer underrun"; return nullptr; } @@ -302,6 +302,8 @@ void CIO2Device::tryReturnBuffer(FrameBuffer *buffer) break; } } + + bufferAvailable_.emit(); } void CIO2Device::freeBuffers() diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h index 5ecc4f47..8f37ee35 100644 --- a/src/libcamera/pipeline/ipu3/cio2.h +++ b/src/libcamera/pipeline/ipu3/cio2.h @@ -54,6 +54,7 @@ public: FrameBuffer *queueBuffer(Request *request, FrameBuffer *rawBuffer); void tryReturnBuffer(FrameBuffer *buffer); Signal &bufferReady() { return output_->bufferReady; } + Signal<> &bufferAvailable() { return bufferAvailable_; } Signal &frameStart() { return csi2_->frameStart; } private: @@ -65,6 +66,8 @@ private: std::unique_ptr csi2_; std::unique_ptr output_; + Signal<> bufferAvailable_; + std::vector> buffers_; std::queue availableBuffers_; }; diff --git a/src/libcamera/pipeline/ipu3/frames.cpp b/src/libcamera/pipeline/ipu3/frames.cpp index 03e8131c..58a47f98 100644 --- a/src/libcamera/pipeline/ipu3/frames.cpp +++ b/src/libcamera/pipeline/ipu3/frames.cpp @@ -44,12 +44,12 @@ IPU3Frames::Info *IPU3Frames::create(Request *request) unsigned int id = request->sequence(); if (availableParamBuffers_.empty()) { - LOG(IPU3, Error) << "Parameters buffer underrun"; + LOG(IPU3, Debug) << "Parameters buffer underrun"; return nullptr; } if (availableStatBuffers_.empty()) { - LOG(IPU3, Error) << "Statistics buffer underrun"; + LOG(IPU3, Debug) << "Statistics buffer underrun"; return nullptr; } @@ -86,6 +86,8 @@ void IPU3Frames::remove(IPU3Frames::Info *info) /* Delete the extended frame information. */ frameInfo_.erase(info->id); + + bufferAvailable_.emit(); } bool IPU3Frames::tryComplete(IPU3Frames::Info *info) diff --git a/src/libcamera/pipeline/ipu3/frames.h b/src/libcamera/pipeline/ipu3/frames.h index 4acdf48e..d2e5fbb9 100644 --- a/src/libcamera/pipeline/ipu3/frames.h +++ b/src/libcamera/pipeline/ipu3/frames.h @@ -12,6 +12,8 @@ #include #include +#include + namespace libcamera { class FrameBuffer; @@ -49,10 +51,13 @@ public: Info *find(unsigned int id); Info *find(FrameBuffer *buffer); + Signal<> &bufferAvailable() { return bufferAvailable_; } private: std::queue availableParamBuffers_; std::queue availableStatBuffers_; + Signal<> bufferAvailable_; + std::map> frameInfo_; }; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index c73e4f7c..462a0d9b 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -699,6 +699,8 @@ int PipelineHandlerIPU3::allocateBuffers(Camera *camera) data->ipa_->mapBuffers(ipaBuffers_); data->frameInfos_.init(imgu->paramBuffers_, imgu->statBuffers_); + data->frameInfos_.bufferAvailable().connect( + data, &IPU3CameraData::queuePendingRequests); return 0; } @@ -1123,6 +1125,8 @@ int PipelineHandlerIPU3::registerCameras() */ data->cio2_.bufferReady().connect(data.get(), &IPU3CameraData::cio2BufferReady); + data->cio2_.bufferAvailable().connect( + data.get(), &IPU3CameraData::queuePendingRequests); data->imgu_->input_->bufferReady.connect(&data->cio2_, &CIO2Device::tryReturnBuffer); data->imgu_->output_->bufferReady.connect(data.get(),