From patchwork Wed Sep 21 08:02:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17385 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 8AC05C327D for ; Wed, 21 Sep 2022 08:03:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3646A621E1; Wed, 21 Sep 2022 10:03:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1663747386; bh=p76Ra6oGRS2oGIAl/DgzwgcUTg1Gtz3X4lYsY/MwjxI=; 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=RO7GmfKjPgMxb4ZGrEhyMkmbKw3a5wqSy0g57gh7lHtg7RaYgLJgmcVWVsrg7zbEv T8D4hvxt5eR2XJKoCwIqmKXPuoBXIcv9hD8KIf6TNI0+1h0YIQC9iUWA3DMkJYx2KT 7I1IxL0kX1eC42RKNKDTMAj+AkKoLOw+rMaDZnNIzeSB6FPdnEsoSUuhDEArU43OPI L8SCT0Ohn+R3kkzfMtnRQCNa7PpYhtx6SZ/P9faCndcVeOYHFUCYg4lp+kcxryN67P 6ThUyKfReL6stQ+90pptQh7rHSeXKjOS6g9eIET+CxeTOOCMJnYRBs9EWs6e7o+YVo 0hP3HbfKW9NLQ== Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1933C621DA for ; Wed, 21 Sep 2022 10:03:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="nqp0nAJr"; dkim-atps=neutral Received: by mail-wm1-x32a.google.com with SMTP id fn7-20020a05600c688700b003b4fb113b86so368408wmb.0 for ; Wed, 21 Sep 2022 01:03:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=Z7GOK/fFFzV59ouyerKPz+mBpJ1VsiYEYq2C9B2xYMM=; b=nqp0nAJrCbadCRxkmp1J58bibJdr8AgVciivCjZBTgfDjY1lo1mEF+SknyGIFo8+RO hcIebsEKzK+Qsquima5kNp9f4iUuo2vR29su9B9Th0uTFzkDtk1tkasNwCT0V2yxcZBU SkEpFZeFqFGNDPhntdmkgy2EQ/yr/WRIdTw4X+BzXWrci9aVl/MyGuikzZUdAdHnzNyv V+XO94OlHNP6KUl9fjUUogiWSe3KlcnQ+YVU4WT8ionVKHeoMBUETYvKKsNs9i0G8wmO 3QIZrKSBHGZGj4XYtr28/OnXhNhULIUjGqmAdcJu9gUUf0tBL0n0nFDGDQIiDEp/mwBY /QOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=Z7GOK/fFFzV59ouyerKPz+mBpJ1VsiYEYq2C9B2xYMM=; b=AKAGEDcKzvDb8v0E9i/65hUN0J4g7exRBLFO+Ck7wL3l0WmHKq8FGeYtZRCjS2fRKz nPCOatg0Ddwdzh5B/86jJs7HgKgTZ3Xkz3PKJzgmbnJX1cL8cVWBNq5YhTjKyMSVOQFo lYkLnob3ExqtuFP+f7Enf468hlxvqINDO1iDFjiFrECy3jxFptQQ663HGyw8JIRbL7X+ ZsIXoSfe3kae3Y1GKMXM2pq/HNv9NXdSb6sGd0nIXEMfNAG6P/5fb5hUbYdeRZBENWRW Vx3SXTzOKH92mlGUzamhWgNACiGYptMiVUlRVmlWGSuLkZVNo7D7eugLRTHf0qjcydUb nhLQ== X-Gm-Message-State: ACrzQf2dyC6udGLklLT1GeBDLMlu5YTtEfCg4KDW4HMq2mOUh8kGvpCL 0dRDBkV7RLgQFmnvrZ6SfE0AlbGqtbobrE0m X-Google-Smtp-Source: AMsMyM6z2OULktCCJ19wI90YcoipPi84X6Lwzdm23QRdQicjv10GXgmQ+lBjC38AxgmJmOEsECzS8g== X-Received: by 2002:a05:600c:22d3:b0:3a8:424d:f386 with SMTP id 19-20020a05600c22d300b003a8424df386mr4991159wmg.57.1663747382463; Wed, 21 Sep 2022 01:03:02 -0700 (PDT) Received: from naush-laptop.localdomain (global-5-56.n-1.net.cam.ac.uk. [131.111.5.56]) by smtp.gmail.com with ESMTPSA id l36-20020a05600c08a400b003b4727d199asm1905782wmp.15.2022.09.21.01.03.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Sep 2022 01:03:02 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 21 Sep 2022 09:02:57 +0100 Message-Id: <20220921080258.5268-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220921080258.5268-1-naush@raspberrypi.com> References: <20220921080258.5268-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] pipeline: raspberrypi: Add an error state 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an error state used internally in the Raspberry Pi pipeline handler. Currently this state is never set, but will be in a subsequent commit when a device timeout has been signalled. Add a isRunning() helper to identify if the state machine is in a stopped/error state. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: David Plowman --- .../pipeline/raspberrypi/raspberrypi.cpp | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index b4094898ca6c..5c8c89585200 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -253,9 +253,14 @@ public: * thread. So, we do not need to have any mutex to protect access to any * of the variables below. */ - enum class State { Stopped, Idle, Busy, IpaComplete }; + enum class State { Stopped, Idle, Busy, IpaComplete, Error }; State state_; + bool isRunning() + { + return state_ != State::Stopped && state_ != State::Error; + } + struct BayerFrame { FrameBuffer *buffer; ControlList controls; @@ -1109,7 +1114,7 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request) { RPiCameraData *data = cameraData(camera); - if (data->state_ == RPiCameraData::State::Stopped) + if (!data->isRunning()) return -EINVAL; LOG(RPI, Debug) << "queueRequestDevice: New request."; @@ -1708,7 +1713,7 @@ void RPiCameraData::enumerateVideoDevices(MediaLink *link) void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &controls) { - if (state_ == State::Stopped) + if (!isRunning()) return; FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId); @@ -1744,7 +1749,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList & void RPiCameraData::runIsp(uint32_t bufferId) { - if (state_ == State::Stopped) + if (!isRunning()) return; FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId); @@ -1759,7 +1764,7 @@ void RPiCameraData::runIsp(uint32_t bufferId) void RPiCameraData::embeddedComplete(uint32_t bufferId) { - if (state_ == State::Stopped) + if (!isRunning()) return; FrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId); @@ -1825,7 +1830,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) RPi::Stream *stream = nullptr; int index; - if (state_ == State::Stopped) + if (!isRunning()) return; for (RPi::Stream &s : unicam_) { @@ -1864,7 +1869,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) void RPiCameraData::ispInputDequeue(FrameBuffer *buffer) { - if (state_ == State::Stopped) + if (!isRunning()) return; LOG(RPI, Debug) << "Stream ISP Input buffer complete" @@ -1881,7 +1886,7 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer) RPi::Stream *stream = nullptr; int index; - if (state_ == State::Stopped) + if (!isRunning()) return; for (RPi::Stream &s : isp_) { @@ -1991,6 +1996,7 @@ void RPiCameraData::handleState() switch (state_) { case State::Stopped: case State::Busy: + case State::Error: break; case State::IpaComplete: