From patchwork Mon Mar 29 00:27:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11752 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 38C12C32ED for ; Mon, 29 Mar 2021 00:27:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EA8FD6878B; Mon, 29 Mar 2021 02:27:29 +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="AYzK/x21"; dkim-atps=neutral Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 76D626877C for ; Mon, 29 Mar 2021 02:27:27 +0200 (CEST) Received: by mail-pl1-x62a.google.com with SMTP id g10so3577665plt.8 for ; Sun, 28 Mar 2021 17:27:27 -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=wdPP1Ko5IWsl0/+XDtJ9kFAPZim+486TEQ9K9uaCUEo=; b=AYzK/x212EgUM4i2AawObJZJp4w4XkD5R54CXIBkyQ+Jk1JNb8BksXJRWnd6c9rLjY buzC4o7QXXs88d/mX7YX+qRLJ9mVSyaZ6ZWFqgRITWsBvlZxx7Pz9HnwQXryZwAq9Y+R 6mbF5eV1HfWMVFEvOfaepyF2epPsh2eZPlCBM= 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=wdPP1Ko5IWsl0/+XDtJ9kFAPZim+486TEQ9K9uaCUEo=; b=iBCwhCFuqTQl+P0JXqhWNxymKjmwS2a9Con0AxBmTU1tXIJkHCZiDME6WNbzV4WyXm Gvn9nYop4PqL/Sin5c+wL229d0+Wb7dnVu00FgvuFIrf53/4Kf4Xdq1lX2lg2fGsCCzK R9IPlMOob/Q8NNVKM2ru5iYqdR9G4tQ70ysWKti4zmfLply+oPUWh71A55Ns3NRpuWeV N4+xaa+aoVckS8GpDXl+A2IF1PD5rK4ZLOGT1Qkz5LwPkvm0EF+EvjTQzE44G6lBdy2P GARLpPbwGedskOuQNKbXTcq+V0N0J2x9aXDWAYjRhserhthslzm+/3FN9x4MAoZAmCd7 8DQw== X-Gm-Message-State: AOAM532qLHVugWHkf9P2oXmHADUGYtlDHMtggUEkeT1XUAmRy94IsLHm eYxGoGdPAhOuqZQ56JHBOAeHFyEDV0EwRQ== X-Google-Smtp-Source: ABdhPJzSzsQfwDWfIZwXsBNfys2eg/f8vIsrubw3VMNG7wLFTrTTwRWb9abBD3GgI44RGhFtq7HZuw== X-Received: by 2002:a17:902:a9c2:b029:e7:147f:76a1 with SMTP id b2-20020a170902a9c2b02900e7147f76a1mr21486022plr.5.1616977645973; Sun, 28 Mar 2021 17:27:25 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:1db7:ae60:9288:b906]) by smtp.gmail.com with ESMTPSA id j188sm15227209pfd.64.2021.03.28.17.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Mar 2021 17:27:25 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Mar 2021 09:27:14 +0900 Message-Id: <20210329002715.74403-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.0.291.g576ba9dcdaf-goog In-Reply-To: <20210329002715.74403-1-hiroh@chromium.org> References: <20210329002715.74403-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] libcamera: Request: Add an error value 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" libcamera::Request returned by Camera::requestComplete() is always assumed. Therefore, an error occurred in PipelineHandler::queueRequest() is ignored. This adds an error value, which is zero on success, to libcamera::Request() so that a Camera client can know the request error in completing request. Signed-off-by: Hirokazu Honda --- include/libcamera/request.h | 2 ++ src/libcamera/pipeline_handler.cpp | 6 ++++-- src/libcamera/request.cpp | 21 ++++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/include/libcamera/request.h b/include/libcamera/request.h index 6e5aad5f..60e91d5f 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -52,6 +52,7 @@ public: uint64_t cookie() const { return cookie_; } Status status() const { return status_; } + int result() const { return result_; } bool hasPendingBuffers() const { return !pending_.empty(); } @@ -73,6 +74,7 @@ private: const uint64_t cookie_; Status status_; + int result_; bool cancelled_; }; diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 05b807d6..a9a5523b 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -383,8 +383,10 @@ void PipelineHandler::queueRequest(Request *request) data->queuedRequests_.push_back(request); int ret = queueRequestDevice(camera, request); - if (ret) - data->queuedRequests_.remove(request); + if (ret) { + request->result_ = ret; + completeRequest(request); + } } /** diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index 0071667e..8106437e 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -72,7 +72,7 @@ LOG_DEFINE_CATEGORY(Request) * */ Request::Request(Camera *camera, uint64_t cookie) - : camera_(camera), cookie_(cookie), status_(RequestPending), + : camera_(camera), cookie_(cookie), status_(RequestPending), result_(0), cancelled_(false) { /** @@ -236,15 +236,26 @@ FrameBuffer *Request::findBuffer(const Stream *stream) const * \fn Request::status() * \brief Retrieve the request completion status * - * The request status indicates whether the request has completed successfully - * or with an error. When requests are created and before they complete the - * request status is set to RequestPending, and is updated at completion time - * to RequestComplete. If a request is cancelled at capture stop before it has + * The request status indicates whether the request has pended, completed or + * cancelled.. When requests are created and before they complete the request + * status is set to RequestPending, and is updated at completion time to + * RequestComplete. If a request is cancelled at capture stop before it has * completed, its status is set to RequestCancelled. * * \return The request completion status */ +/** + * \fn Request::result() + * \brief Retrieve the error value of the request . + * + * The request error indicates whether the request has completed successfully or + * with an error. It is a negative value if an error happens in queueing and + * processing the request, or 0 on success. + * + * \return The request error value. + */ + /** * \fn Request::hasPendingBuffers() * \brief Check if a request has buffers yet to be completed