From patchwork Wed Mar 31 08:45:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11804 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 5F377C0DA3 for ; Wed, 31 Mar 2021 08:45:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8B4F368781; Wed, 31 Mar 2021 10:45:48 +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="D523aVMB"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 45C07602D7 for ; Wed, 31 Mar 2021 10:45:47 +0200 (CEST) Received: by mail-pf1-x42c.google.com with SMTP id l123so14035482pfl.8 for ; Wed, 31 Mar 2021 01:45:47 -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:mime-version :content-transfer-encoding; bh=aHI2JGTQNu5bzQSr5oxtVmpRHNClhnSkZaRmqTHn6yY=; b=D523aVMBaloHjxguQ0AybHxJey/PfpsTvPKW1cCobOp5UshCiK4Vhdj598sigisyGV OpkgPtohMCkVaF4Y9mmNp2naM8V8VRjm8lSoSnogoH6nZYDxfJdDTbDuN0oRI8N8rANM bZF3k6+1RVCfi95N5vA9oqVx2Jeq0Qkkm44U8= 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:mime-version :content-transfer-encoding; bh=aHI2JGTQNu5bzQSr5oxtVmpRHNClhnSkZaRmqTHn6yY=; b=jR1unBjzLmGkCeqaSamcrAtE7C/yXHDaEo6Ex9GY/J5Srf9j2gaif9Bzo7Okavwa3T GB0Yo+eMjgYMF2JJ4n9QMAq2DS3nCADBWDLmSMPOkDALZwNUawdzhSfrjjANqzDPU84k pexQQcubOYXjycUD0NiMP1+CwB4F/fsqTvKl50L/qHs/vDHVCFg7RiCq5vcu0bZqNXL/ uN0Donf8H+UlGE3Q6eoZ86ix2g+gFgYH45CF4wT8MnW9iNqp3pjR+zK6mCBFGOzQhooF Fd0UAQ9eWHmKMePsn5zXSKaGWQZ9shOFNB9bQIuT5+WxE3PtMPdIPul7ixZ5IyJqKY4D KaNQ== X-Gm-Message-State: AOAM533DcFHwho9lImGh3HSwBtrtJuslcvVTJ/XBWUKkXcvyJo0/URr7 6/cKA3XDnoVM7h9PhkmUTyy/Oy1r74eAug== X-Google-Smtp-Source: ABdhPJzBoix6FX4jIoBpcr5nqBBjf7mhzKZDZdgJPNzKzHsy5R/xGZPJiaqT8DRAC0JHTYS2ERmUdw== X-Received: by 2002:a65:430b:: with SMTP id j11mr2311683pgq.143.1617180345536; Wed, 31 Mar 2021 01:45:45 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:c112:2822:484f:486]) by smtp.gmail.com with ESMTPSA id k19sm1864981pgl.1.2021.03.31.01.45.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Mar 2021 01:45:45 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 31 Mar 2021 17:45:39 +0900 Message-Id: <20210331084539.930233-1-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] 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 PipelineHandlerIPU3 to do that. Signed-off-by: Hirokazu Honda --- src/libcamera/pipeline/ipu3/ipu3.cpp | 62 ++++++++++++++++++---------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index 519cad4f..71dd311f 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -153,12 +153,16 @@ private: int allocateBuffers(Camera *camera); int freeBuffers(Camera *camera); + int queuePendingRequests(); + ImgUDevice imgu0_; ImgUDevice imgu1_; MediaDevice *cio2MediaDev_; MediaDevice *imguMediaDev_; std::vector ipaBuffers_; + + std::queue> pendingRequests_; }; IPU3CameraConfiguration::IPU3CameraConfiguration(IPU3CameraData *data) @@ -764,6 +768,8 @@ void PipelineHandlerIPU3::stop(Camera *camera) IPU3CameraData *data = cameraData(camera); int ret = 0; + pendingRequests_ = {}; + data->ipa_->stop(); ret |= data->imgu_->stop(); @@ -774,36 +780,50 @@ void PipelineHandlerIPU3::stop(Camera *camera) freeBuffers(camera); } -int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) +int PipelineHandlerIPU3::queuePendingRequests() { - IPU3CameraData *data = cameraData(camera); + while (!pendingRequests_.empty()) { + IPU3CameraData *data = pendingRequests_.front().first; + Request *request = pendingRequests_.front().second; - IPU3Frames::Info *info = data->frameInfos_.create(request); - if (!info) - return -ENOBUFS; + IPU3Frames::Info *info = data->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(&data->rawStream_); + FrameBuffer *rawBuffer = data->cio2_.queueBuffer(request, reqRawBuffer); + if (!rawBuffer) { + data->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(); + data->ipa_->processEvent(ev); + + pendingRequests_.pop(); + } return 0; } +int PipelineHandlerIPU3::queueRequestDevice(Camera *camera, Request *request) +{ + IPU3CameraData *data = cameraData(camera); + + pendingRequests_.emplace(data, request); + return queuePendingRequests(); +} + bool PipelineHandlerIPU3::match(DeviceEnumerator *enumerator) { int ret;