From patchwork Fri Sep 16 10:05:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17372 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 C90FAC0DA4 for ; Fri, 16 Sep 2022 10:05:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1A4C561FB0; Fri, 16 Sep 2022 12:05:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1663322727; bh=bdeiGJbr7u7LP9iu01w1eABMxGGF0KnxyR9VCC3RH8w=; 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=Lp4q8Nb3vF7xlhX/A56pU+sM51bEbZqlZwYsbgi/vkWwVDhHLInJxzTopHMGdH9rR BZ3Qmr40TQkhKfohMY/x3FIgNiJDy3rfb73EBH0SV2ks2XHE4XtJx9TZj+ArrRwnjz Wofo/24Yi2Abf6qHiUpRZr1e8NjxcQ6wA26KDPs6gIdPmQdwhir7OLL3uFopytVNxT c1kfP4Kg0TegLmT/knZe/WC1A2oUKFZ9Abd9dP2dqirKbghBXuCVDpMx5BsNez205n 18zeMN03AWNW3DX2wvx6peuVrOedUxOneDFVHTZX832+noLFT2jv0a8ygdZbSm/0Hj JH3L39yweK1rw== Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CDB0C6099B for ; Fri, 16 Sep 2022 12:05:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="QH5QneBI"; dkim-atps=neutral Received: by mail-wr1-x429.google.com with SMTP id z6so2704807wrq.1 for ; Fri, 16 Sep 2022 03:05:25 -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=++Pp3uxOune9JHLV8GT78Y14hhcSIm7V/rRyxRBxhtE=; b=QH5QneBIvJoNtRKiCIXxr/XhHI/9IjblztCw09+GviQ8vJI5PyiHrN7IWc52KkDvt3 Q5fcXmEqzjdYrOmBIwocZTN+pp5zAwquGUL8NKlmIWN2ygYNq2aBznvNMNDpn5T6j3f3 IoCkDjjVAPxtmU2X6oJGJi6RI286TTsoAEA41/J+3wpY4ylB7llZGVg+fjtcHs6/cZeI JHZ/S8NkOLQ/lYRmsYp5mOrwJWxGPIapdcJRrfrXbZvbLWCB5U8FSPQofZ92YR0TQWpK GEhfBgo8jQH5GSFMYzLrJGKFghSDDRZHwnYBdg1VjfG9n5eQByTEYpsAoFpF2z7QTK8B JMSQ== 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=++Pp3uxOune9JHLV8GT78Y14hhcSIm7V/rRyxRBxhtE=; b=L+k2HpmM2atdnflpOjw8zB61KZgK/Gb33Kqrwd0Qk0VA8wuTgmOjz9L0VL2/TclFqp WNUqQrgyQa9XunI6Q+3te1q3xyG5kIgJJz9c4i4pLtSWTB4Qesw0fEG9RmVmbT6ACfPP tKPF7CQjbHxibqXtjXP/FEg/jyW5r313HIj00ZDiISwySEbgjFQo7Yiu3Z4HxrIlbpyc 4G4PNEoE7vTeB0rSUd5c33kzhQDvQbitfBO+l0r+xPGvusRCZIHaL+D3Rv06IEh8GE8v BD+5c2AmdbpfPVKxtK7llezB2u8+uQ8jEDE36PPtQ2VAmiKtKgljLz4b2DWKOV38l7b7 tzcg== X-Gm-Message-State: ACrzQf3OaWtqHK7f0eKPRqP1P04xueEYEGe4A+gutOqQgzYrricmlO6I AKGWMkorRp9QehD1ZvAciAOGsuQc6PCyHOBN X-Google-Smtp-Source: AMsMyM5G7Gfi+aZnJs6Tv5eItK0g/17NJgVKvKayJgwirGE7tqIQkSJe8/iv1LEeDmGs/iuwRSl0Kw== X-Received: by 2002:adf:d1ce:0:b0:22a:36d6:da05 with SMTP id b14-20020adfd1ce000000b0022a36d6da05mr2434562wrd.719.1663322725098; Fri, 16 Sep 2022 03:05:25 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id e13-20020adfa74d000000b002286231f479sm4632026wrd.50.2022.09.16.03.05.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 03:05:24 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Sep 2022 11:05:16 +0100 Message-Id: <20220916100517.12446-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220916100517.12446-1-naush@raspberrypi.com> References: <20220916100517.12446-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 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. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- .../pipeline/raspberrypi/raspberrypi.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index b4094898ca6c..d429cb444d58 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -253,7 +253,7 @@ 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_; struct BayerFrame { @@ -1109,7 +1109,8 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request) { RPiCameraData *data = cameraData(camera); - if (data->state_ == RPiCameraData::State::Stopped) + if (data->state_ == RPiCameraData::State::Stopped || + data->state_ == RPiCameraData::State::Error) return -EINVAL; LOG(RPI, Debug) << "queueRequestDevice: New request."; @@ -1708,7 +1709,7 @@ void RPiCameraData::enumerateVideoDevices(MediaLink *link) void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &controls) { - if (state_ == State::Stopped) + if (state_ == State::Stopped || state_ == State::Error) return; FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId); @@ -1744,7 +1745,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList & void RPiCameraData::runIsp(uint32_t bufferId) { - if (state_ == State::Stopped) + if (state_ == State::Stopped || state_ == State::Error) return; FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId); @@ -1759,7 +1760,7 @@ void RPiCameraData::runIsp(uint32_t bufferId) void RPiCameraData::embeddedComplete(uint32_t bufferId) { - if (state_ == State::Stopped) + if (state_ == State::Stopped || state_ == State::Error) return; FrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId); @@ -1825,7 +1826,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) RPi::Stream *stream = nullptr; int index; - if (state_ == State::Stopped) + if (state_ == State::Stopped || state_ == State::Error) return; for (RPi::Stream &s : unicam_) { @@ -1864,7 +1865,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) void RPiCameraData::ispInputDequeue(FrameBuffer *buffer) { - if (state_ == State::Stopped) + if (state_ == State::Stopped || state_ == State::Error) return; LOG(RPI, Debug) << "Stream ISP Input buffer complete" @@ -1881,7 +1882,7 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer) RPi::Stream *stream = nullptr; int index; - if (state_ == State::Stopped) + if (state_ == State::Stopped || state_ == State::Error) return; for (RPi::Stream &s : isp_) { @@ -1991,6 +1992,7 @@ void RPiCameraData::handleState() switch (state_) { case State::Stopped: case State::Busy: + case State::Error: break; case State::IpaComplete: From patchwork Fri Sep 16 10:05:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17373 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 0D804C327D for ; Fri, 16 Sep 2022 10:05:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A31E561FF4; Fri, 16 Sep 2022 12:05:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1663322729; bh=EzWkA6pk8E2g3hENOYf1fsFrzDirRIxhvEn2CQmvTgE=; 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=yObepkHa5Nczxe9YQLj7CGhKRG19HN+TCBGroGMsNKBq4Rsnf1DrdJMBcIxBhCwym A94wLuaLbfIEjgkLNDsyhnzn2baT9Y3wo9eM9mXeOJzCpScIsjm6es6DHzDE5tr+SK jtcnHjQhWlR0yjmAijRyEtTaZ1lKTqmsPy2GyP7s9s7yCEmX4i9n7bPs75wwofMsPr OLpbnViPpeATvQLWsfdD4VkjpjYYxXFszzIS20ckfRqkQVpIR5cLnsca0VVqnDqENO ZJvmc/+aMTh0pOy8zIMmANuiaHA8XbTaoRXRl9F4KDa67Mf+1dmc1MJsrokMCCiVfZ Szqb8vPicTG6w== Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B064361FB4 for ; Fri, 16 Sep 2022 12:05:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="sZufrU+Y"; dkim-atps=neutral Received: by mail-wr1-x42a.google.com with SMTP id t7so35167877wrm.10 for ; Fri, 16 Sep 2022 03:05:26 -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=zBdSbHDzOYtFo6cBPiKh6r56tg2FXiywwgw/c3JyCU0=; b=sZufrU+Yx/28YbXGUlV8FkyiR7HIMoXyMqFoIGOgrV/FdMituA7Skx1Ed3+NAuN5fg yZ/kZCjR9gb/ACuuQaX/HWf6t12FAgL2E8VpMEKSDxSSv2JyN/jJ2QgtCIajMoD8stKR 4Z4zL0ckJiP968Uh9bcG2kHmxMwI6rc3OW7rh/kxCWqi9Nfb31K1Q5eYgo0kEsQ0k4rk scopXNKowk0BY9gKRZtCbBhp5cOi4V+PDSgo2/oZreOoZy5FQ4dWGXe+2uLphW+t9f3F X1tTXC5enjFT7IU1us+kFKDfh3X9txr29jjg9DNdX68suwI9wQV7PmfJUvEUIhjumQfw YLTw== 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=zBdSbHDzOYtFo6cBPiKh6r56tg2FXiywwgw/c3JyCU0=; b=tTqlcb525OP6VWHr/5QU6ELd0RviFUdePHReG74YT3BkMgCxTUTnQipeAwKdO0QlnV 3tNZdqNDWqJTyT3E6rn+/kKU3OgVOqE4grSrvNRl61PDvfPtgCY+uWlv8lugOa5uLTYd SMrAfyj45WhF2Vx7cfES34tijP4BOtWSBWmB0mUjpi2kgwqlecTztvYKcJR/lOft/DA4 apvQ9IgwT5V2FxEwVt6CChFwo+EO1eRmIi6H+lZbvfLFtNRuh103eUIOHS4Y73uThsRf ozhgc2we9kB4Bn1SWtHQq9kDurpG5rWeif3YFDA+HMa1B6mpRnvxFv8xKNyuK3Mk0v+A NBSw== X-Gm-Message-State: ACrzQf1XKKtDJtmWX5jfcY3lK7+S6Cads4xazEIh0B/SE15tXObeJitn ZRzFWmaBtdo8yt1lK+uAXasFlaYrJLkr+bIr X-Google-Smtp-Source: AMsMyM7nFZYGP9bG2pgnG/Xr+7eyb5EqVyjjhESZfIdeqjvu0m5JoUiXeR3k6NDYkCxSQ4vKddjNmA== X-Received: by 2002:a05:6000:1048:b0:228:6898:aa50 with SMTP id c8-20020a056000104800b002286898aa50mr2277813wrx.233.1663322725996; Fri, 16 Sep 2022 03:05:25 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id e13-20020adfa74d000000b002286231f479sm4632026wrd.50.2022.09.16.03.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Sep 2022 03:05:25 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Sep 2022 11:05:17 +0100 Message-Id: <20220916100517.12446-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220916100517.12446-1-naush@raspberrypi.com> References: <20220916100517.12446-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/2] pipeline: raspberrypi: Improve Unicam timeout handling 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" Currently, if a Unicam timeout is signalled, the pipeline handler only raises an error message. Update the error handling to put the pipeline handler in an internal error state, disable all device streams, and return all outstanding requests as cancelled. Any subsequent requests that come into the pipeline handler will also be returned as cancelled. Any further error handling (e.g. a reset with camera stop()/start()) is up to the application to perform as it requires. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index d429cb444d58..4464d4d07f15 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1819,6 +1819,17 @@ void RPiCameraData::unicamTimeout() LOG(RPI, Error) << "Unicam has timed out!"; LOG(RPI, Error) << "Please check that your camera sensor connector is attached securely."; LOG(RPI, Error) << "Alternatively, try another cable and/or sensor."; + + state_ = RPiCameraData::State::Error; + /* + * To allow the application to attempt a recovery from this timeout, + * stop all device streaming, and return any outstanding requests as + * incomplete and cancelled. + */ + for (auto const stream : streams_) + stream->dev()->streamOff(); + + clearIncompleteRequests(); } void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)