{"id":17601,"url":"https://patchwork.libcamera.org/api/patches/17601/?format=json","web_url":"https://patchwork.libcamera.org/patch/17601/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20221014131846.27169-6-naush@raspberrypi.com>","date":"2022-10-14T13:18:41","name":"[libcamera-devel,v1,05/10] pipeline: raspberrypi: Disable StreamOn for ISP Output0/1 when dropping frames","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"0fd370f258a569d3189983d089174d096e279e78","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/17601/mbox/","series":[{"id":3555,"url":"https://patchwork.libcamera.org/api/series/3555/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3555","date":"2022-10-14T13:18:37","name":"Raspberry Pi: Platform configuration and buffer allocation improvements","version":1,"mbox":"https://patchwork.libcamera.org/series/3555/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/17601/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/17601/checks/","tags":{},"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 B0A62C3286\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 14 Oct 2022 13:19:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5E42A62DD1;\n\tFri, 14 Oct 2022 15:19:01 +0200 (CEST)","from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D86F62DBC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Oct 2022 15:18:56 +0200 (CEST)","by mail-wm1-x32e.google.com with SMTP id\n\to20-20020a05600c4fd400b003b4a516c479so3506547wmq.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 14 Oct 2022 06:18:56 -0700 (PDT)","from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tg17-20020a05600c001100b003c6bbe910fdsm8282458wmc.9.2022.10.14.06.18.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 14 Oct 2022 06:18:55 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1665753541;\n\tbh=Z09FsJ1eeq8/QE9utbzWP8pRJbtszBu1HTsfzhspEU8=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=fyp7x+rREq1wEQa895Ix0ZX//2SG4RR/zkdLeUKTPUJI2Iua3StxiZkItykOCX08Y\n\tKtnLIbd7kESaH28B5JJ5Mjjr9dCxfbFFY+uH3FJjzYBtLp/gAtCKCZVS5dQSXL+CMo\n\t95fFLzoaCjuLAV/x+pGF8jzyd4mNt8zyCgK4lKsKqswKMrYjIEiZMGWAJWYfB2h2ya\n\tvei2dbEC683R/rgJYRwuMpkFYqQXE+yzA9PMBe9yB/ps7RFeiryDnpAuVSjHGebo/B\n\tnnvzuG95Kc8socAVzIJXTkarWLcTNGBJZtWCB2uAJock9jnuwmXmRkJOYZWjHFAAJt\n\tD3u4x6MkwTLYw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=JxiJ0YIUaJLrBxVyStnydR+o/sXghSBmFy3EK7DLEUo=;\n\tb=mq+hM1ZEBTkBBT0hqJZpYrbBpctJEZDWlMGoKbZA9X7Gqane1IF4p9h2qZfa+P540N\n\tHhimNLB68itazPznfUxg42kyGivsg4Q7SAio7ceKgb9LTHGV0Fctfk5DQfM48wFUwQgK\n\tPayzEIidgGcOr4H8F26oFX6hesOWgfri/JIFrsz+3JqHVN8Fwecb5yeegE7JNvOmGjqA\n\t56hnuPXkT0SPhHJbjWfSVfEMs/IwvZB2fURcWHG0UNWqdPCP6IcxitGkyOiK/462JeCa\n\tREB2fSO5m96fzHAPpnaxqfmjOhzNONbsAIFVTGP+ikh77v2qfyx7AKd4ePo/I+5el3MY\n\tbiPg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"mq+hM1ZE\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=JxiJ0YIUaJLrBxVyStnydR+o/sXghSBmFy3EK7DLEUo=;\n\tb=kA2O+O6krNt88cU0AlV5MqRpSC2EKzgAWmzGsy8l3p6wiD6zwMOhy4BdJLZ/crnXd2\n\twBSYpkBPBj3b/qxIVc8/BmmKUyvwty7VKtWt18ayveyJ9DaCQYLOWEi3stW+SNfCQ4E1\n\tGd2KSyMEqQeqRM2995rcr7mspoZjv/sjAsLxzO5o8gH4JBGF51f/XbYyIy+F91ZG2mgv\n\tdgs7Pncp4AVvpuoyuFg2shacgewIDoqx70p1o23lk/pXDkSJIz8bwPrJ8vGwPX60WaH4\n\tjaoz0GYu7BLGvPb8h+LefPqww12ptFBlH1jza3ukdoa5h0TLaHZuSP1ZgNh95fZz9h0j\n\tR1Vw==","X-Gm-Message-State":"ACrzQf2iD48S0gv6M2B0IwjQFnEyS4du1dyJAtpveZpMKAA2mN1uhFJt\n\tmUvN8j0ZaUhncJkiKlPfr7SqAkUXMTwgJQ==","X-Google-Smtp-Source":"AMsMyM5vIkOgqEfFx7ccvQsz5PfgpXs2HTFsHXk7eQ4OsFQ/4c39Dr6eTlBZvS2Zdl4xRnZ5l7W4uQ==","X-Received":"by 2002:a7b:cb41:0:b0:3b3:34d6:189f with SMTP id\n\tv1-20020a7bcb41000000b003b334d6189fmr10476579wmj.6.1665753535483; \n\tFri, 14 Oct 2022 06:18:55 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 14 Oct 2022 14:18:41 +0100","Message-Id":"<20221014131846.27169-6-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20221014131846.27169-1-naush@raspberrypi.com>","References":"<20221014131846.27169-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1 05/10] pipeline: raspberrypi: Disable\n\tStreamOn 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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"If the pipeline handler is required to drop startup frames by the IPA, do not\ncall StreamOn on the ISP Output0 and Output1 device nodes from\nPipelineHandlerRPi::start. This stops the ISP from generating output on those\nchannels giving improving latency, and more crucially does not require internal\nbuffers to be allocated to deal with this condition.\n\nSigned-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(-)","diff":"diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json\nindex 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 }\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 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 \tdata->state_ = RPiCameraData::State::Idle;\n \n-\t/* Start all streams. */\n+\t/*\n+\t * Start all streams with the exception of ISP Output0 and Output1 if\n+\t * we are dropping some start-up frames. This saves a tiny bit of latency\n+\t * and avoids the need for allocating an Output0 buffer only to handle\n+\t * startup drop frame conditions.\n+\t */\n \tfor (auto const stream : data->streams_) {\n+\t\tif (data->dropFrameCount_ &&\n+\t\t    (stream == &data->isp_[Isp::Output0] ||\n+\t\t     stream == &data->isp_[Isp::Output1]))\n+\t\t\tcontinue;\n+\n \t\tret = stream->dev()->streamOn();\n \t\tif (ret) {\n \t\t\tstop(camera);\n@@ -1474,6 +1484,13 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera)\n \t\t\tif (ret < 0)\n \t\t\t\treturn ret;\n \t\t} else {\n+\t\t\t/*\n+\t\t\t * We don't enable streaming for Output0 and Output1 for\n+\t\t\t * startup frame drops, so don't queue any buffers.\n+\t\t\t */\n+\t\t\tif (stream == &data->isp_[Isp::Output0] ||\n+\t\t\t    stream == &data->isp_[Isp::Output1])\n+\t\t\t\tcontinue;\n \t\t\t/*\n \t\t\t * For external streams, we must queue up a set of internal\n \t\t\t * buffers to handle the number of drop frames requested by\n@@ -2143,16 +2160,26 @@ void RPiCameraData::checkRequestCompleted()\n \t}\n \n \t/*\n-\t * Make sure we have three outputs completed in the case of a dropped\n-\t * frame.\n+\t * Only the ISP statistics output is generated when we are dropping\n+\t * frames on startup.\n \t */\n \tif (state_ == State::IpaComplete &&\n-\t    ((ispOutputCount_ == 3 && dropFrameCount_) || requestCompleted)) {\n+\t    ((ispOutputCount_ == 1 && dropFrameCount_) || requestCompleted)) {\n \t\tstate_ = State::Idle;\n \t\tif (dropFrameCount_) {\n \t\t\tdropFrameCount_--;\n \t\t\tLOG(RPI, Debug) << \"Dropping frame at the request of the IPA (\"\n \t\t\t\t\t<< dropFrameCount_ << \" left)\";\n+\n+\t\t\t/*\n+\t\t\t * If we ahve finished dropping startup frames, start\n+\t\t\t * streaming on the ISP Output0 and Output1 nodes for\n+\t\t\t * normal operation.\n+\t\t\t */\n+\t\t\tif (!dropFrameCount_) {\n+\t\t\t\tisp_[Isp::Output0].dev()->streamOn();\n+\t\t\t\tisp_[Isp::Output1].dev()->streamOn();\n+\t\t\t}\n \t\t}\n \t}\n }\n","prefixes":["libcamera-devel","v1","05/10"]}