From patchwork Tue Apr 6 08:51:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11841 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 C83C1C0DA3 for ; Tue, 6 Apr 2021 08:52:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 198DC68797; Tue, 6 Apr 2021 10:52:07 +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="fkTqdv5q"; dkim-atps=neutral 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 638DA60517 for ; Tue, 6 Apr 2021 10:52:03 +0200 (CEST) Received: by mail-pg1-x52f.google.com with SMTP id y32so6677772pga.11 for ; Tue, 06 Apr 2021 01:52:03 -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=fkTqdv5qS2pkEoy51RqTpWga1ZkEC/qjphtdVWgUW0McOD65f7kLsgBcCdO/Th7wtA 8uo5y8mXNwkSZISRyGouxO2Gqo7rTvh4c4uF/KMsA6CJYpVZRhnbic0znGpOrtSjW2Xi 4Ffpx8kJkdt9NzRvghSuR7EN5AmrxyR7zhx44= 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=pfP+1V0T5jbyPSsnUUHBeOuKJMTT5xDptQmBa8WGx6cKr0nDna8PHKcc00oNnj0Pw1 YKmWfyIfdNqg8n2Fgfz/E4oRNezsIAuKwSwZgkWqVdNXNa5zreapBjkh14uF9RxnNGmf DNX7ZibSCD8V3Htry/ap0UnLLOOnptpCH/AIGcoatj5qgH7dObv1/8zxKimJN26lq2FK wmglG+D+2SbmiuO0f+UG1VoBYNBfquJLfPvm0MI4UIqJPrtD1t9oHtVHy/ESUN5BhGxp UEOd1fKGIA/HIJ4ZTa2YJ3fqrGkkKK7vn1QnssPMG+dD5Hdl0aKsNfBXITtUJufCx15q /4ZA== X-Gm-Message-State: AOAM533GoVVNQ4PW4Ss5NDqoHMZztGtXjs1Q3VI0+vujZ/zslFrQK3e4 fD7w1GfIFcVx8ZanqW1lLoI/LVDkLKAF+A== X-Google-Smtp-Source: ABdhPJwjVBCBMEINL0QauX1/QGGQ6HLe+qF5vCpOVo7g/ElkGuDrwf1Cra4ktDBibK4kZA/yS08OsA== X-Received: by 2002:a62:e805:0:b029:1f8:16ba:4518 with SMTP id c5-20020a62e8050000b02901f816ba4518mr26364558pfi.37.1617699121796; Tue, 06 Apr 2021 01:52:01 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:4180:40db:6f79:a143]) by smtp.gmail.com with ESMTPSA id y7sm18070135pfq.70.2021.04.06.01.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Apr 2021 01:52:01 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Apr 2021 17:51:53 +0900 Message-Id: <20210406085153.3818580-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.208.g409f899ff0-goog In-Reply-To: <20210406085153.3818580-1-hiroh@chromium.org> References: <20210406085153.3818580-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] 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(),