[{"id":25110,"web_url":"https://patchwork.libcamera.org/comment/25110/","msgid":"<CAHW6GYJqjCwKwO6xnXqWCDhQ_uSWp0EOvhq7NvjAvjozz5xjEA@mail.gmail.com>","date":"2022-09-23T09:07:14","subject":"Re: [libcamera-devel] [PATCH v2 1/2] pipeline: raspberrypi: Add an\n\terror state","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nThanks for this patch!\n\nOn Wed, 21 Sept 2022 at 09:03, Naushir Patuck via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> Add an error state used internally in the Raspberry Pi pipeline handler.\n> Currently this state is never set, but will be in a subsequent commit when a\n> device timeout has been signalled.\n>\n> Add a isRunning() helper to identify if the state machine is in a stopped/error\n> state.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks\nDavid\n\n> ---\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 22 ++++++++++++-------\n>  1 file changed, 14 insertions(+), 8 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index b4094898ca6c..5c8c89585200 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -253,9 +253,14 @@ public:\n>          * thread. So, we do not need to have any mutex to protect access to any\n>          * of the variables below.\n>          */\n> -       enum class State { Stopped, Idle, Busy, IpaComplete };\n> +       enum class State { Stopped, Idle, Busy, IpaComplete, Error };\n>         State state_;\n>\n> +       bool isRunning()\n> +       {\n> +               return state_ != State::Stopped && state_ != State::Error;\n> +       }\n> +\n>         struct BayerFrame {\n>                 FrameBuffer *buffer;\n>                 ControlList controls;\n> @@ -1109,7 +1114,7 @@ int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)\n>  {\n>         RPiCameraData *data = cameraData(camera);\n>\n> -       if (data->state_ == RPiCameraData::State::Stopped)\n> +       if (!data->isRunning())\n>                 return -EINVAL;\n>\n>         LOG(RPI, Debug) << \"queueRequestDevice: New request.\";\n> @@ -1708,7 +1713,7 @@ void RPiCameraData::enumerateVideoDevices(MediaLink *link)\n>\n>  void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &controls)\n>  {\n> -       if (state_ == State::Stopped)\n> +       if (!isRunning())\n>                 return;\n>\n>         FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId);\n> @@ -1744,7 +1749,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &\n>\n>  void RPiCameraData::runIsp(uint32_t bufferId)\n>  {\n> -       if (state_ == State::Stopped)\n> +       if (!isRunning())\n>                 return;\n>\n>         FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId);\n> @@ -1759,7 +1764,7 @@ void RPiCameraData::runIsp(uint32_t bufferId)\n>\n>  void RPiCameraData::embeddedComplete(uint32_t bufferId)\n>  {\n> -       if (state_ == State::Stopped)\n> +       if (!isRunning())\n>                 return;\n>\n>         FrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId);\n> @@ -1825,7 +1830,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n>         RPi::Stream *stream = nullptr;\n>         int index;\n>\n> -       if (state_ == State::Stopped)\n> +       if (!isRunning())\n>                 return;\n>\n>         for (RPi::Stream &s : unicam_) {\n> @@ -1864,7 +1869,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n>\n>  void RPiCameraData::ispInputDequeue(FrameBuffer *buffer)\n>  {\n> -       if (state_ == State::Stopped)\n> +       if (!isRunning())\n>                 return;\n>\n>         LOG(RPI, Debug) << \"Stream ISP Input buffer complete\"\n> @@ -1881,7 +1886,7 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer)\n>         RPi::Stream *stream = nullptr;\n>         int index;\n>\n> -       if (state_ == State::Stopped)\n> +       if (!isRunning())\n>                 return;\n>\n>         for (RPi::Stream &s : isp_) {\n> @@ -1991,6 +1996,7 @@ void RPiCameraData::handleState()\n>         switch (state_) {\n>         case State::Stopped:\n>         case State::Busy:\n> +       case State::Error:\n>                 break;\n>\n>         case State::IpaComplete:\n> --\n> 2.25.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id D34E2BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Sep 2022 09:07:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 364726222D;\n\tFri, 23 Sep 2022 11:07:28 +0200 (CEST)","from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com\n\t[IPv6:2a00:1450:4864:20::22e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 268ED621BC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Sep 2022 11:07:26 +0200 (CEST)","by mail-lj1-x22e.google.com with SMTP id l12so13897005ljg.9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Sep 2022 02:07:26 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1663924048;\n\tbh=1LujY4sJhOO7efQJ/5KiFkXuDkc5H1c5eBEULnBIsss=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Z5krRr19S4MiK1iOAkmN4fM7IhEbxd7v3NQjdpFgWSl0k07pylTqszPVrL8hi1ruV\n\tl1uEf6XV0M0PMpmY4LTdpZIVR1nEdwc3dVXmXK3JMn9h97QylFgGVvkO9G8asQBTR/\n\t4Z8sB3j05X8+zwHl0ghM5QOA/At7vei+YYoXBtEPN4ZbFpBn7fo/VJSxa+PVPHCa+H\n\tWMthuZ9xeMV4HpNU6MQonBrm0U3GPWvqX9uwyAZGJaqxkGDtecFtNJNDyMDGxv/NJI\n\tQYuTRVlwFtdYyhpQ2b34RHVPd0p+z8wYHaLViAc/LX3tCNPr1zYBGaeWtHJ3s+5VFM\n\tthKWduSRmfgIA==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date;\n\tbh=bUXhOz+I2U68C2TVGb2kA8DKrwuUA6FoWdwUI32zOZU=;\n\tb=KLYK9thASp1N7rGMB6KHFZghcio7MqSldYuCXZFNkh4WQn+VSUU4TZVCLRzPBTcjbc\n\tfT6fPfjHtqgBInscOtBhzk5jkQi6fsTsDTcKGutXrBsgKnCmrO8CXe5Sbq+UWQnoE2AN\n\tNYxtWonQGFKOSLyQawTRX286iIGAnAf+HqIJxSIVREaKvo8PDdKrgtAzhNs3NPIVR9eM\n\tX20Hx+jymR/fcxT5VcbAyDJlu4Q/TD0v0/iAUd0kTC6+RQsvRNZL9pPICo0do0rlAFHp\n\twRT24WREikAp+SdAFnNblt/fEiw72Xdba951hm2C63dF+Cotyb1l7V7GeYV0vX3xuywA\n\tYJ0A=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"KLYK9thA\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date;\n\tbh=bUXhOz+I2U68C2TVGb2kA8DKrwuUA6FoWdwUI32zOZU=;\n\tb=TIXzjJkXpky6yU2T0tncIDjOcilFl8y4xh9glGYYAlk8ixK16kp9FjgeBIoeoVclUh\n\tDjZ5Qb7eaSn9Yz2dZC4RCfj5tzHmxjKddxIAgXgGPZslj+R86iCQ+/hKrRhP3Hjw+xDw\n\tTctBCa27Mj8FbliXDwBr1468COr0xF/kN7emf6TVjgz2qJyKkUyEEy5QqHZfTnCgKKtp\n\t5Z/MSTQyoVIhYsvoJFZfcqQCvykiqLhWreB3kE/DPDCoSSr2KNU2088r6QAumFutYm1+\n\twWsWfqJpe+ax56OjKn2eloPvvFLqMttnTodl6dSouYD9gq6bJA18x3Wsb3biAKJC6TBZ\n\tYz/w==","X-Gm-Message-State":"ACrzQf1EU6fTSHsf3Dx5zJY5CAGetEo0SEgmebErbZFk4jJLTtkHYcMA\n\t2yr+1IP9508FGSFIJyPKtYr/dddZ/yFyyl7/StE5aQ==","X-Google-Smtp-Source":"AMsMyM7vw14fRiucN5svNrtlcaDe8xoAqpEsMwUY9zia4Admo3JMfQpY00CzXbsBu6NEBoKChHVz/HlSfz8lBagk/V4=","X-Received":"by 2002:a05:651c:548:b0:26c:71fb:93a with SMTP id\n\tq8-20020a05651c054800b0026c71fb093amr2065770ljp.301.1663924045303;\n\tFri, 23 Sep 2022 02:07:25 -0700 (PDT)","MIME-Version":"1.0","References":"<20220921080258.5268-1-naush@raspberrypi.com>\n\t<20220921080258.5268-2-naush@raspberrypi.com>","In-Reply-To":"<20220921080258.5268-2-naush@raspberrypi.com>","Date":"Fri, 23 Sep 2022 10:07:14 +0100","Message-ID":"<CAHW6GYJqjCwKwO6xnXqWCDhQ_uSWp0EOvhq7NvjAvjozz5xjEA@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 1/2] pipeline: raspberrypi: Add an\n\terror state","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]