From patchwork Tue Nov 29 13:45:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17912 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 BB51FBE08B for ; Tue, 29 Nov 2022 13:45:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6FFE663348; Tue, 29 Nov 2022 14:45:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729546; bh=VmJ10ySTnoK2DomNYykhigrgND5ZRn760On8UiajsLA=; 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=HA6TEcnf+GG+aE4x6w8OahF4lD3R1NCOudZtj2HVTkXRB9fJO2YXALgkgc79nKcI5 SUmhU3HyS4LeF+mHt1urZCQvyctKmaXnOw49Ztf43vmNJS5I67IslEx9Mjo2ULg8RL 9XovygDveGo4cJENrMoE1hkFZ8xeRNfe+4g2+qxHEMoXQ5JOlc8JHhTTYNOu740IvH 7NtmtcKxuNJmyWMpnMk3FrPSUYpghcoeBVZRaWzpoFOm4RGYCYNaj8R67b+xIbL23p 2HMIFJCBUS1SF81HxaihkAhsnIBad2g3QaI96k5BzET4m1G1DFChD9wm7etQhA8Fmi trrjOTc8essDw== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CE3F063334 for ; Tue, 29 Nov 2022 14:45:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="S7laaz2r"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id o5so13157503wrm.1 for ; Tue, 29 Nov 2022 05:45:41 -0800 (PST) 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 :message-id:reply-to; bh=s6JWaOD5ahc87t7hdCafQKuhJnaZNJKSyQwGAo5ftKI=; b=S7laaz2rPkTC20d47V0XF+vz1wSwI1B38r3HNqqHBzJPHG/W+PU51olc73DjaVBZs7 /9FQb0yys4Os0tpe9CakwMnttxHtwJLwIbMVE95sM0dhiotNayMNXRU1D9TvsYDR1dHT R8HWaaMXj2+8tLWdXkQ3sTfzppoNPcQ35HIPbyiTBhkshw8jpdX+0p9uMHdXXd8gn0eb PHj3PuqoAnrBN7ob2vCWaRSrBDz+xTFOBmyJ6v9bcCZ/Dybgh5bWtd2ACYog80eJ/avR dlYuviKhRNBY+k4HGrokT0UlTNIKfc9INdiINcrcTHj9Ewt76URDOse4vCQQ8BAKBN2h 83Cw== 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:message-id:reply-to; bh=s6JWaOD5ahc87t7hdCafQKuhJnaZNJKSyQwGAo5ftKI=; b=zyf8iSIZJt5dePqPYpSoQbKbJAh1QPudDBGc5Ce7lomTo1DpKF4AmMCENE165aSK4j C47ixtWn22rxZoKHXh4vd5+Siqo0ufth0IALruRleDwnET1wgYI9R34Du7r+BmavyvJD /YiWEa520YYDTavjoPSgty8N+qREhC9QU9ZKFskxs454BDZNyyShWpYs08zv/QEnlawc g9QBT3UnyXg42p+PoDxvXogCRKWM/HVnOv4RK2OIF53qst8qMr4k0lLWikfisZiNxI+N oCcjMc87ImFyFLpTn426F3PBaw9veYnDhCu7uITfMKTOan6ASP6Nu6MBQI648YTdajRg rfbQ== X-Gm-Message-State: ANoB5pllyEMX3V7HXY0QL8abJ3zPcB1FjMpuAQ1CpYmf9vCXOaXuSXPd joRVWNld2jD3MMSoswpJkSq5Uj0F6c95Ew== X-Google-Smtp-Source: AA0mqf66cN5QDHIZclC7A5vDNOfcaB9d31PTwv7OvBzbSyGJCzY7JWbIR/e3eul7lL2QMMkYFPTYOg== X-Received: by 2002:adf:ab1d:0:b0:242:e73:f642 with SMTP id q29-20020adfab1d000000b002420e73f642mr9098390wrc.184.1669729541340; Tue, 29 Nov 2022 05:45:41 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:40 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:29 +0000 Message-Id: <20221129134534.2933-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 05/10] pipeline: raspberrypi: Disable 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: 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" If the pipeline handler is required to drop startup frames by the IPA, do not call StreamOn on the ISP Output0 and Output1 device nodes from PipelineHandlerRPi::start. This stops the ISP from generating output on those channels giving improving latency, and more crucially does not require internal buffers to be allocated to deal with this condition. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/default.json | 2 +- .../pipeline/raspberrypi/raspberrypi.cpp | 34 ++++++++++++++++--- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json index d709e31850af..a7ea735c87f4 100644 --- a/src/libcamera/pipeline/raspberrypi/data/default.json +++ b/src/libcamera/pipeline/raspberrypi/data/default.json @@ -14,7 +14,7 @@ # min_total_unicam_buffers - external buffer count) "min_total_unicam_buffers": 4, - # The number of internal buffers used for ISP Output0. This must be set to 1. + # The number of internal buffers used for ISP Output0. "num_output0_buffers": 1 } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index ce411453db0a..86eb43a3a3c5 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1094,8 +1094,18 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) data->state_ = RPiCameraData::State::Idle; - /* Start all streams. */ + /* + * Start all streams with the exception of ISP Output0 and Output1 if + * we are dropping some start-up frames. This saves a tiny bit of latency + * and avoids the need for allocating an Output0 buffer only to handle + * startup drop frame conditions. + */ for (auto const stream : data->streams_) { + if (data->dropFrameCount_ && + (stream == &data->isp_[Isp::Output0] || + stream == &data->isp_[Isp::Output1])) + continue; + ret = stream->dev()->streamOn(); if (ret) { stop(camera); @@ -1500,6 +1510,13 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera) if (ret < 0) return ret; } else { + /* + * We don't enable streaming for Output0 and Output1 for + * startup frame drops, so don't queue any buffers. + */ + if (stream == &data->isp_[Isp::Output0] || + stream == &data->isp_[Isp::Output1]) + continue; /* * For external streams, we must queue up a set of internal * buffers to handle the number of drop frames requested by @@ -2169,16 +2186,25 @@ void RPiCameraData::checkRequestCompleted() } /* - * Make sure we have three outputs completed in the case of a dropped - * frame. + * Only the ISP statistics output is generated when we are dropping + * frames on startup. */ if (state_ == State::IpaComplete && - ((ispOutputCount_ == 3 && dropFrameCount_) || requestCompleted)) { + ((ispOutputCount_ == 1 && dropFrameCount_) || requestCompleted)) { state_ = State::Idle; if (dropFrameCount_) { dropFrameCount_--; LOG(RPI, Debug) << "Dropping frame at the request of the IPA (" << dropFrameCount_ << " left)"; + /* + * If we have finished dropping startup frames, start + * streaming on the ISP Output0 and Output1 nodes for + * normal operation. + */ + if (!dropFrameCount_) { + isp_[Isp::Output0].dev()->streamOn(); + isp_[Isp::Output1].dev()->streamOn(); + } } } }