From patchwork Tue Jul 19 10:31:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 16685 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 51A80BE173 for ; Tue, 19 Jul 2022 10:31:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1868A63315; Tue, 19 Jul 2022 12:31:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658226710; bh=jp4nxfN6xfM63XVDRGE0HJVJVRZ4VxQmFjEaedaqgKQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=C4AsX4Nhkk9tHqmKYrJUvU9I1EZ7nSgu5aevmtHUlJj1jSNgWBQE8EaH54/PTn8Wm urb4Tlk9VBu3ID8dC/9mzwnXQmRSqLh9nT5OH1147DXjozaT1yngXiMg+aeJSQvR+A uaeWSFOFkmXOBpeAvD7z2KhU7BTa727NDJBksVBWub5Zqb6AqvFBiPKmBxB1t1MH1L QYSpJj6PySCCCCt3/uq8ZxsNUkLlr9R9gUr3Eb7DWpuTjDZolw1I8iXIXkxc1Kp2Nu mpPWxI63WhogLpoMcMuGfckzgxmg+qCljNETsgMKUZxNPx+FWHzfD+wy6rcwoMVZw1 xNhlp5YS10GPQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A1E4F6330E for ; Tue, 19 Jul 2022 12:31:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="k+ffmEAl"; dkim-atps=neutral Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 15DDA896; Tue, 19 Jul 2022 12:31:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1658226708; bh=jp4nxfN6xfM63XVDRGE0HJVJVRZ4VxQmFjEaedaqgKQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+ffmEAltQCtb40knznrzBvBY+Tefjxy3xSr71NKQ96Tc9D3p8KI0JA0qU58bFfmQ +uncwfgkyUcOZCjFRuR5UUppoBHB+MTHkVPzw3gRoLPKoGRrhIR69Gy9mPABvUwuAl cuFRvBIIYXoJgGintRJnn0AEH9K9RKmIJUasbNaE= To: libcamera devel Date: Tue, 19 Jul 2022 11:31:43 +0100 Message-Id: <20220719103144.3686313-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220719103144.3686313-1-kieran.bingham@ideasonboard.com> References: <20220719103144.3686313-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: request: Add support for error flags 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Paul Elder Add error flags to the Request to indicate non-fatal errors. Applications should check the error() state of the Request to determine if any fault occured while processing the request. Initially, a single error flag ControlError is added to allow a pipeline handler to report a failure to set controls on a hardware device while processing the request. ControlErrors occur when a Request was asked to set a control and the pipeline handler attempted to do so, but it was rejected by the kernel. Signed-off-by: Paul Elder Signed-off-by: Kieran Bingham --- include/libcamera/internal/request.h | 3 +++ include/libcamera/request.h | 9 +++++++ src/libcamera/request.cpp | 36 ++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/include/libcamera/internal/request.h b/include/libcamera/internal/request.h index 9dadd6c60361..8e592272cfae 100644 --- a/include/libcamera/internal/request.h +++ b/include/libcamera/internal/request.h @@ -38,6 +38,7 @@ public: void complete(); void cancel(); void reuse(); + void setErrorFlags(ErrorFlags flags); void prepare(std::chrono::milliseconds timeout = 0ms); Signal<> prepared; @@ -59,6 +60,8 @@ private: std::unordered_set pending_; std::map> notifiers_; std::unique_ptr timer_; + + ErrorFlags error_; }; } /* namespace libcamera */ diff --git a/include/libcamera/request.h b/include/libcamera/request.h index dffde1536cad..992629e11aa4 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -43,6 +44,13 @@ public: ReuseBuffers = (1 << 0), }; + enum ErrorFlag { + NoError = 0, + ControlError = (1 << 0), + }; + + using ErrorFlags = Flags; + using BufferMap = std::map; Request(Camera *camera, uint64_t cookie = 0); @@ -60,6 +68,7 @@ public: uint32_t sequence() const; uint64_t cookie() const { return cookie_; } Status status() const { return status_; } + ErrorFlags error() const; bool hasPendingBuffers() const; diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index 07613cb33709..d585ef0b0ae4 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -162,6 +162,7 @@ void Request::Private::cancel() */ void Request::Private::reuse() { + error_ = Request::NoError; sequence_ = 0; cancelled_ = false; prepared_ = false; @@ -284,6 +285,11 @@ void Request::Private::notifierActivated(FrameBuffer *buffer) emitPrepareCompleted(); } +void Request::Private::setErrorFlags(ErrorFlags flags) +{ + error_ |= flags; +} + void Request::Private::timeout() { /* A timeout can only happen if there are fences not yet signalled. */ @@ -318,6 +324,22 @@ void Request::Private::timeout() * Reuse the buffers that were previously added by addBuffer() */ +/** + * \enum Request::ErrorFlag + * Flags to report non-fatal errors + * \var Request::NoError + * No error + * \var Request::ControlError + * Control Error. At least on control was not able to be applied to the device. + * The application should compare the metadata to the requested control values + * to check which controls weren't applied. + */ + +/** + * \typedef Request::ErrorFlags + * The error state of the request. + */ + /** * \typedef Request::BufferMap * \brief A map of Stream to FrameBuffer pointers @@ -560,6 +582,20 @@ uint32_t Request::sequence() const * \return The request completion status */ +/** + * \brief Retrieve the error flags + * + * The request could complete with non-fatal error. The completion status will + * indicate success. This function returns the non-fatal errors that the + * request completed with + * + * \return Flags of non-fatal errors that the request completed with + */ +Request::ErrorFlags Request::error() const +{ + return _d()->error_; +} + /** * \brief Check if a request has buffers yet to be completed * From patchwork Tue Jul 19 10:31:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 16686 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 CB731BE173 for ; Tue, 19 Jul 2022 10:31:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8904463317; Tue, 19 Jul 2022 12:31:52 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658226712; bh=IGBbScQGZcbTQmRMFjagqowF/O41SSAC2/ooNjSvQ8s=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=MMh1Yj8Odsf3KqiM02oXW91LSOQwVmCgtE3p/6zqcKaqjAPP2HSyEfcu8XvJx3SPq jlitQhyiP2N5cYFfWb2HejKww74WS9LR/casyNsej4WJZibJs1wxysxuZWjgngauwH 4u/Ej9skqZOMPWmXTvlZ4YYSh+sq7crESXPjuVe+/QPc+bpaUDU8C67dWnG32XZuhJ NZFUKxLD+zplR1kexo4gmZ9lqaM3sCZFaq6dtzX44j3GkAllpNzKLcsr6CYKT6DRPS qO7dHPT8z8fGIVgIvDBw3ZRWsG8vxgsB4w+kwnrhc9cURA8F/SObh4qAVvjfbBm0QD iNkqV6mDUSIbQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B523660489 for ; Tue, 19 Jul 2022 12:31:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CaaWYwDt"; dkim-atps=neutral Received: from Monstersaurus.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5D8BA8B1; Tue, 19 Jul 2022 12:31:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1658226708; bh=IGBbScQGZcbTQmRMFjagqowF/O41SSAC2/ooNjSvQ8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CaaWYwDtmFq5llvTiwQga6d72o4DuBpxmzcT+kjZNvpCE5IRs32G7F+ot7g+tcoJj aYrYGAsjCi6WnCslQ3upr+5awB/OkkASJGUOBQigdYYMPKUsotVuZkhmnA6s9xXm/T ayF4gsEyI41RD70Csq8T9jahvlCuHY/5ry/gvavI= To: libcamera devel Date: Tue, 19 Jul 2022 11:31:44 +0100 Message-Id: <20220719103144.3686313-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220719103144.3686313-1-kieran.bingham@ideasonboard.com> References: <20220719103144.3686313-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: pipeline: uvcvideo: Report control errors 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Report an error when failing to process controls, but still allow the request to process and complete where possible. The Request ControlError flag is raised on the request. Bug: https://bugs.libcamera.org/show_bug.cgi?id=135 Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- src/libcamera/pipeline/uvcvideo/uvcvideo.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp index 53b2f23ab029..1f282f26bec3 100644 --- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp +++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp @@ -26,6 +26,7 @@ #include "libcamera/internal/device_enumerator.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" +#include "libcamera/internal/request.h" #include "libcamera/internal/sysfs.h" #include "libcamera/internal/v4l2_videodevice.h" @@ -373,8 +374,10 @@ int PipelineHandlerUVC::queueRequestDevice(Camera *camera, Request *request) } int ret = processControls(data, request); - if (ret < 0) - return ret; + if (ret < 0) { + LOG(UVC, Error) << "Failed to process controls"; + request->_d()->setErrorFlags(Request::ControlError); + } ret = data->video_->queueBuffer(buffer); if (ret < 0)