[{"id":25706,"web_url":"https://patchwork.libcamera.org/comment/25706/","msgid":"<CAHW6GYLzm5za2GRR1j6ZMiykSM4KtQr3L+4KiSE7uV66V=zXTA@mail.gmail.com>","date":"2022-11-01T12:05:17","subject":"Re: [libcamera-devel] [PATCH v1 05/10] pipeline: raspberrypi:\n\tDisable StreamOn for ISP Output0/1 when dropping frames","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 the patch!\n\nOn Fri, 14 Oct 2022 at 14:19, Naushir Patuck via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> If the pipeline handler is required to drop startup frames by the IPA, do not\n> call StreamOn on the ISP Output0 and Output1 device nodes from\n> PipelineHandlerRPi::start. This stops the ISP from generating output on those\n> channels giving improving latency, and more crucially does not require internal\n> buffers to be allocated to deal with this condition.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  .../pipeline/raspberrypi/data/default.json    |  2 +-\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 35 ++++++++++++++++---\n>  2 files changed, 32 insertions(+), 5 deletions(-)\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json\n> index d709e31850af..a7ea735c87f4 100644\n> --- a/src/libcamera/pipeline/raspberrypi/data/default.json\n> +++ b/src/libcamera/pipeline/raspberrypi/data/default.json\n> @@ -14,7 +14,7 @@\n>                  #                             min_total_unicam_buffers - external buffer count)\n>                  \"min_total_unicam_buffers\": 4,\n>\n> -                # The number of internal buffers used for ISP Output0. This must be set to 1.\n> +                # The number of internal buffers used for ISP Output0.\n>                  \"num_output0_buffers\": 1\n>          }\n>  }\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index bac7a66ba900..fc674e4f5bdd 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -1080,8 +1080,18 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls)\n>\n>         data->state_ = RPiCameraData::State::Idle;\n>\n> -       /* Start all streams. */\n> +       /*\n> +        * Start all streams with the exception of ISP Output0 and Output1 if\n> +        * we are dropping some start-up frames. This saves a tiny bit of latency\n> +        * and avoids the need for allocating an Output0 buffer only to handle\n> +        * startup drop frame conditions.\n> +        */\n>         for (auto const stream : data->streams_) {\n> +               if (data->dropFrameCount_ &&\n> +                   (stream == &data->isp_[Isp::Output0] ||\n> +                    stream == &data->isp_[Isp::Output1]))\n> +                       continue;\n> +\n>                 ret = stream->dev()->streamOn();\n>                 if (ret) {\n>                         stop(camera);\n> @@ -1474,6 +1484,13 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera)\n>                         if (ret < 0)\n>                                 return ret;\n>                 } else {\n> +                       /*\n> +                        * We don't enable streaming for Output0 and Output1 for\n> +                        * startup frame drops, so don't queue any buffers.\n> +                        */\n> +                       if (stream == &data->isp_[Isp::Output0] ||\n> +                           stream == &data->isp_[Isp::Output1])\n> +                               continue;\n>                         /*\n>                          * For external streams, we must queue up a set of internal\n>                          * buffers to handle the number of drop frames requested by\n> @@ -2143,16 +2160,26 @@ void RPiCameraData::checkRequestCompleted()\n>         }\n>\n>         /*\n> -        * Make sure we have three outputs completed in the case of a dropped\n> -        * frame.\n> +        * Only the ISP statistics output is generated when we are dropping\n> +        * frames on startup.\n>          */\n>         if (state_ == State::IpaComplete &&\n> -           ((ispOutputCount_ == 3 && dropFrameCount_) || requestCompleted)) {\n> +           ((ispOutputCount_ == 1 && dropFrameCount_) || requestCompleted)) {\n>                 state_ = State::Idle;\n>                 if (dropFrameCount_) {\n>                         dropFrameCount_--;\n>                         LOG(RPI, Debug) << \"Dropping frame at the request of the IPA (\"\n>                                         << dropFrameCount_ << \" left)\";\n> +\n> +                       /*\n> +                        * If we ahve finished dropping startup frames, start\n\ns/ahve/have     (sorry!)\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks!\nDavid\n\n> +                        * streaming on the ISP Output0 and Output1 nodes for\n> +                        * normal operation.\n> +                        */\n> +                       if (!dropFrameCount_) {\n> +                               isp_[Isp::Output0].dev()->streamOn();\n> +                               isp_[Isp::Output1].dev()->streamOn();\n> +                       }\n>                 }\n>         }\n>  }\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 004C4BD16B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  1 Nov 2022 12:05:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6910063031;\n\tTue,  1 Nov 2022 13:05:31 +0100 (CET)","from mail-pl1-x634.google.com (mail-pl1-x634.google.com\n\t[IPv6:2607:f8b0:4864:20::634])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D96063009\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  1 Nov 2022 13:05:29 +0100 (CET)","by mail-pl1-x634.google.com with SMTP id c2so13339096plz.11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 01 Nov 2022 05:05:29 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1667304331;\n\tbh=+Ru4D2KiZ3x7k08R1XxzgnY09cbq88egLRyyhotDyoA=;\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=uxcrSmgbY57DgwAy/Ce52Ctl/5fAVUEHWMXI8bLA1tTkqeqxvQcL5N9H3MH1VmYYW\n\t4ZDJI3IWdlIIqePNWs7qVEG6q1SEskGmrmTYc4OpJ+glosVBOcMAybHzJOk9Y6iv4S\n\trG4IyomSZTV2Td2j1Z8/GKjSRlkru5rNMV+H4nZmu/GvS/GUQE+QmlpQn87ypx1NvW\n\tQq7fu3t7k+2zD7p5RQYZ7DWgqdPDfTPzNgpEOc1QbLkhEIZMnHN9qkdLtPjXKBz0b6\n\t5cb08pEhbuGjoRF4aJF/8pSmAcQ6haf4uASQPDu9j4z6xshRU/M8VKLBwNT+Oyu9a4\n\tdRH27qx3yPsrQ==","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:message-id:reply-to;\n\tbh=dkmvACk0AnUn7zIIqyj554/cknrSVhH3tak/qp7ITP8=;\n\tb=RAbvnEdxmTg3Dv0xq3YO2U8p2M7nr3YQF1Sqt2/+5GCXzDEnd+/T0pg/9B1fT0Ut9k\n\tYcjd2PhpBCiu5fwDUX5XnBg+JL2nzOxD88/o0mooWV19onFMh9T2VBLNoi902xbvrnaw\n\tvyIeepS0DBgGBWCcKTfi8NaMsfya2M3kfrN6TdFNWrjNIRl5pTKkjqNUrcCc1u0zvJ4L\n\tPY2JojLHAuYzOnAfEMZE8esCzSA3EwfBWzWk6RMWQrDnA02lPyDKsGOuuzN0PfbjM6+Z\n\tlJqPLHF1DN9D5Oel/nv6kuxvIrYtVLPZ2L2P4+KBIoi736suRiedWi34LDtLHUqM/8Kb\n\tVKHg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"RAbvnEdx\"; 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:message-id\n\t:reply-to;\n\tbh=dkmvACk0AnUn7zIIqyj554/cknrSVhH3tak/qp7ITP8=;\n\tb=b27j1UL4UbM7oOM8F0P0mqwStDUJFZogHVzTGcaGV1orTiOaSk865pbUKwOWqjRXtu\n\tZDYDVeZCNoa2IP6OxBkrRuCAiS2jua81i4zqFN/YB8JcSCyd1fow14Osg/TzHFN0QG/p\n\tuwc3VozrkBFZ0bQ+lA/ZAegtgfiHikunFwKl/bKIBPV5x9lKW1iZoZ+WKkNapIQqTYoh\n\tufY6/AD1CyFTu7qFKCbUAwCAVB+YUeWEcOrA51cipvNM5t8oRty4T2T33I40ivZ2oqbY\n\tT9pI2AeeUf03rbC0w5Qz/H7WpacmauMaRhH/ZrNH6VJjF/saG3gOyA1ih/ZUBYJ8URuD\n\tcbAQ==","X-Gm-Message-State":"ACrzQf1ffVMTJBPKIzLrOfczUTOC+oYERSaeGCT8rOzPl6HuecRPidmA\n\tYzE/GhgyrnIFT4fWpQpb7UeN4Uw2r9+CvreB88YB+tOp4sU=","X-Google-Smtp-Source":"AMsMyM7t9rn/tNkTxXeWD9iw0foHuypj8KLEzq1KLRgP5yu76IkaCJStAFN5kOTgaSW31SeAS44dO8HuiW/JTEKTIdw=","X-Received":"by 2002:a17:90b:4f43:b0:214:21d4:503e with SMTP id\n\tpj3-20020a17090b4f4300b0021421d4503emr180442pjb.235.1667304327990;\n\tTue, 01 Nov 2022 05:05:27 -0700 (PDT)","MIME-Version":"1.0","References":"<20221014131846.27169-1-naush@raspberrypi.com>\n\t<20221014131846.27169-6-naush@raspberrypi.com>","In-Reply-To":"<20221014131846.27169-6-naush@raspberrypi.com>","Date":"Tue, 1 Nov 2022 12:05:17 +0000","Message-ID":"<CAHW6GYLzm5za2GRR1j6ZMiykSM4KtQr3L+4KiSE7uV66V=zXTA@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v1 05/10] pipeline: raspberrypi:\n\tDisable StreamOn for ISP Output0/1 when dropping frames","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>"}}]