From patchwork Thu Apr 8 08:50:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11867 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 E291FBD16B for ; Thu, 8 Apr 2021 08:51:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9D173687F5; Thu, 8 Apr 2021 10:51:12 +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="ZedJYsVd"; dkim-atps=neutral Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D174F687F3 for ; Thu, 8 Apr 2021 10:51:10 +0200 (CEST) Received: by mail-pj1-x1036.google.com with SMTP id nh5so750424pjb.5 for ; Thu, 08 Apr 2021 01:51:10 -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=jfeyZ2yvrHTGMVCEciDVuNQQtKjTpqBhEM2MU+DjD78=; b=ZedJYsVdw0/R6tucllKAqrcPeETfisZsq9nTfyJwzvF2o4p32aOb0xgppf6ePTT2Ws AarcJOrDyW/wC2bTPkbv9PNjmR6m48mBFMpd0yWE8LxN4pgUcHiLSvkxxGo4+Z/MhMFE SLLZk7pbdKWKzzugXRpHBuYZOwDAd0EbOupDQ= 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=jfeyZ2yvrHTGMVCEciDVuNQQtKjTpqBhEM2MU+DjD78=; b=h6ltvNWFnG/aU0eDqZlKd3MuGmpThnHy/+6v/hcVfv+Henwm4o9xxRJsZFmC7SUTGS 5MdpbKq1cRidssHUFp2rCEyL/BW5QDnR36RCKdDO3i/udv7m0YOcVJWl/DEFf+6ZAHCs ZmF5IM/WYXXO/+e8DppaxRG0MptCXkxV6E6q+anl/ye5hgjV29nFQgQw90tlXes3KgC2 qpfNv024VE8QVDzo1uKEwIPFQRvc+0AdtBd6cbdhKhpV2BkZuIf68bk8BD+/JXM+gqTD PgMGkr2oqDT18+5WEtnggWKz9m95v1hJHYhTfjZig3FeZ/FK4GvV2QGAwaaDtRQCJXAl AT2Q== X-Gm-Message-State: AOAM532Tv/tvIJfZOAF4Jv4UYIv0Mu5fEUokkrs2Taz2nRpr5R86rX0I u7mRhpdzjtKTL6xQ9HiE842dM/0TkdLemQ== X-Google-Smtp-Source: ABdhPJyDT5wq/hNwi/rllrKbH1VQB5XhMyMDG5Gyo2aC3QECUBa8d48lsr1MEZKwDN+P9bm9NkmtKA== X-Received: by 2002:a17:902:b783:b029:e9:3a03:2a5c with SMTP id e3-20020a170902b783b02900e93a032a5cmr6758487pls.79.1617871869065; Thu, 08 Apr 2021 01:51:09 -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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 01:51:08 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 8 Apr 2021 17:50:59 +0900 Message-Id: <20210408085101.1691729-2-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 1/3] pipeline: ipu3: Store requests in the case a buffer shortage 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" PipelineHandlerIPU3 returns -ENOBUFS and -ENOMEM on queueing a request when there are not sufficient buffers for the request. Since the request will be successful if it is queued later when enough buffers are available. The requests failed due to a buffer shortage should be stored and retried later in the FIFO order. This introduces the queue in IPU3CameraData to do that. Signed-off-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/ipu3.cpp | 58 ++++++++++++++++++---------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 519cad4f..c73e4f7c 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -66,6 +66,7 @@ public: void cio2BufferReady(FrameBuffer *buffer); void paramBufferReady(FrameBuffer *buffer); void statBufferReady(FrameBuffer *buffer); + int queuePendingRequests(); CIO2Device cio2_; ImgUDevice *imgu_; @@ -84,6 +85,7 @@ public: std::unique_ptr ipa_; + std::queue pendingRequests_; private: void queueFrameAction(unsigned int id, const ipa::ipu3::IPU3Action &action); @@ -764,6 +766,8 @@ void PipelineHandlerIPU3::stop(Camera *camera) IPU3CameraData *data = cameraData(camera); int ret = 0; + data->pendingRequests_ = {}; + data->ipa_->stop(); ret |= data->imgu_->stop(); @@ -774,36 +778,48 @@ void PipelineHandlerIPU3::stop(Camera *camera) freeBuffers(camera); } -int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) +int IPU3CameraData::queuePendingRequests() { - IPU3CameraData *data = cameraData(camera); + while (!pendingRequests_.empty()) { + Request *request = pendingRequests_.front(); - IPU3Frames::Info *info = data->frameInfos_.create(request); - if (!info) - return -ENOBUFS; + IPU3Frames::Info *info = frameInfos_.create(request); + if (!info) + break; - /* - * Queue a buffer on the CIO2, using the raw stream buffer provided in - * the request, if any, or a CIO2 internal buffer otherwise. - */ - FrameBuffer *reqRawBuffer = request->findBuffer(&data->rawStream_); - FrameBuffer *rawBuffer = data->cio2_.queueBuffer(request, reqRawBuffer); - if (!rawBuffer) { - data->frameInfos_.remove(info); - return -ENOMEM; - } + /* + * Queue a buffer on the CIO2, using the raw stream buffer + * provided in the request, if any, or a CIO2 internal buffer + * otherwise. + */ + FrameBuffer *reqRawBuffer = request->findBuffer(&rawStream_); + FrameBuffer *rawBuffer = cio2_.queueBuffer(request, reqRawBuffer); + if (!rawBuffer) { + frameInfos_.remove(info); + break; + } - info->rawBuffer = rawBuffer; + info->rawBuffer = rawBuffer; - ipa::ipu3::IPU3Event ev; - ev.op = ipa::ipu3::EventProcessControls; - ev.frame = info->id; - ev.controls = request->controls(); - data->ipa_->processEvent(ev); + ipa::ipu3::IPU3Event ev; + ev.op = ipa::ipu3::EventProcessControls; + ev.frame = info->id; + ev.controls = request->controls(); + ipa_->processEvent(ev); + + pendingRequests_.pop(); + } return 0; } +int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) +{ + IPU3CameraData *data = cameraData(camera); + data->pendingRequests_.emplace(request); + return data->queuePendingRequests(); +} + bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) { int ret; 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(), From patchwork Thu Apr 8 08:51:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11869 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 D7FD4BD16B 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 913C5687F6; 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="ZgJOGWmy"; dkim-atps=neutral Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AA38D687F3 for ; Thu, 8 Apr 2021 10:51:13 +0200 (CEST) Received: by mail-pl1-x634.google.com with SMTP id y2so672557plg.5 for ; Thu, 08 Apr 2021 01:51:13 -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=mQqZcpFm3UO7FM2H86Vrjewz6c/Xzh1LXMTgj5/NsN4=; b=ZgJOGWmye3XJ2bJSQKPNxpp++dn2EEUIrzOo9xXGdSuYsl2Uv5jDl+yE2at2YaD//j /3oM2xhQpVtULseI6n8zUekOBBiPsacSyM7k3xjcDP55/a+ghHqVEtqMluvXOewq7KsF jl5AyL/hW3EIy8C0bNx2gHUVIhiNfvbMLhEC0= 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=mQqZcpFm3UO7FM2H86Vrjewz6c/Xzh1LXMTgj5/NsN4=; b=ZvKkxj71jw3sWMrZNEhnXL+WUpekT45rqj7yUsnl4g8kCyqYnSBUKbMbSa/4nh3xbJ LE02fuAG7srh02A7V/sbPzkyEjXePrWc5P2LRovSlpzxHMyiGMurvnl1zI5sCrk2/ETE MVfVUZB60BIlDXI77uZFTv8eF61GeKo2xkQ6Rnu24RTpeNHiL6RC5+Pm+oQuZ4RWYY+E sZ/RD1oipOhFjAwN7VS5ROc0fokAuOTCoC/LeGNG0hU97Z8An0pTNuwJZLZ33irc6uuR xzeTP0uxXAUhRjw4C7pmsVBKCtwyMftFvZn0tFpBQsrs1LVEudqwqb1xOuLDYqso40iB tJRw== X-Gm-Message-State: AOAM530MKY4IjHh+MX8+KdyPJ6DhdapT9Yjj8G7a/AAfBg0jcrp1RmgT 9qSx9hpcVIcp+z0Lg1YBZwiU1iRmJOSePQ== X-Google-Smtp-Source: ABdhPJyLDLerA6PMhDotUtv3n4BjwQMaNYWbjtGg6W6MOwZ5Y7dxj97gUs5SYsxXZ4MuvgRbprdIgQ== X-Received: by 2002:a17:902:b201:b029:e8:bf9e:990a with SMTP id t1-20020a170902b201b02900e8bf9e990amr6781413plr.56.1617871871983; Thu, 08 Apr 2021 01:51:11 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Apr 2021 01:51:11 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 8 Apr 2021 17:51:01 +0900 Message-Id: <20210408085101.1691729-4-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 3/3] libcamera: ipu3: Cancel pending requests correctly 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 are not queued yet to a camera node. They should be reported as cancel upon PipelineHandlerIPU3::stop(). Signed-off-by: Hirokazu Honda --- include/libcamera/buffer.h | 3 +++ src/libcamera/pipeline/ipu3/ipu3.cpp | 19 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index 620f8a66..72c62144 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -58,6 +58,9 @@ private: friend class V4L2VideoDevice; /* Needed to update metadata_. */ + /*! HACK! */ + friend class IPU3CameraData; /* Needed to update metadata_. */ + std::vector planes_; Request *request_; diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 462a0d9b..f89b8f3f 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -66,6 +66,7 @@ public: void cio2BufferReady(FrameBuffer *buffer); void paramBufferReady(FrameBuffer *buffer); void statBufferReady(FrameBuffer *buffer); + void cancelPendingRequests(); int queuePendingRequests(); CIO2Device cio2_; @@ -768,7 +769,7 @@ void PipelineHandlerIPU3::stop(Camera *camera) IPU3CameraData *data = cameraData(camera); int ret = 0; - data->pendingRequests_ = {}; + data->cancelPendingRequests(); data->ipa_->stop(); @@ -780,6 +781,22 @@ void PipelineHandlerIPU3::stop(Camera *camera) freeBuffers(camera); } +void IPU3CameraData::cancelPendingRequests() +{ + while (!pendingRequests_.empty()) { + Request *request = pendingRequests_.front(); + + for (auto it : request->buffers()) { + FrameBuffer *buffer = it.second; + buffer->metadata_.status = FrameMetadata::FrameCancelled; + pipe_->completeBuffer(request, buffer); + } + + pipe_->completeRequest(request); + pendingRequests_.pop(); + } +} + int IPU3CameraData::queuePendingRequests() { while (!pendingRequests_.empty()) {