From patchwork Fri Dec 9 09:00:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17969 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 38ADEBDE6B for ; Fri, 9 Dec 2022 09:01:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C4BB463365; Fri, 9 Dec 2022 10:01:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670576497; bh=TT8f77VfTo8ZsU6VKEbwskQdfs0h8NsHNAVP1IObN3A=; 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=Gtu68EU+I8O+RCi5ZJVeTH4vhzxIfFM5dfB12/BNndHJxkWQHfp67iRFBQjUoS67j wDIKDEDhG0//ws8N9d4BbcFAwKBX/W/oQPJ5svbOoC/4uMDLVhboa8vwmDMzujBvYV iI6ke1xx9CpHofx8QIQ2ZWGszbJXmg5hmuPHJxDCckjrVHGH6ivAZgubQUxVpsH/hf 8p4+14Mbac9uKDXPIyCFxOA78I4Hek8OslPgnWSoYIhzueuEdsqrAfxhS7dNKKKwv8 uxthOwiUVPfeteaG9asujN7nxt7/zCUtPmLJmoYVfbljwLbC+RLxB3LejnAi35cHYS YBsidFVGYPz4Q== Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EC7D063351 for ; Fri, 9 Dec 2022 10:01:32 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="jnN0rIhH"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id m4-20020a05600c3b0400b003d1cb516ce0so5261441wms.4 for ; Fri, 09 Dec 2022 01:01:32 -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=piRa1vTJhlTRtSSbS36pBvVbQZnm13Bd6mtMgWMjARU=; b=jnN0rIhH2Z8heL/iBwOqcHiaondBsziGzzjN1wJI4KgC8DHiGxOlGpfwaP9QDd2701 Mb6ubibkKdCmj261Y8/iOhQHGHXOzpC/+9U/yaXkEtBaTsQUo83MYWBHB2s0NU2Xgw4V wxOIttbgCd5c1g4JoQLMIuEHGE4FwxTdmWVQnfclYpIecpB7+fT1ivmh7b1erGnYOMq5 8RzqnEGMEfpIaB/f+npdvMu9KjD+IqLc1RLlAigl22j5wHuko+7rYXxN2aqcz+5kcpTs gpjp5boR6O6B9FutqIc85vEDlCfEFSZVxtKoMVvlY5l6X+Ue9w6y0ItnLGpzArJdaL3b HMpA== 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=piRa1vTJhlTRtSSbS36pBvVbQZnm13Bd6mtMgWMjARU=; b=t+uBqBHlQiex2kljRGYoQpFiNwFJGM3ocV58fx+hxv9SKWFAOcIiUAhHUQbpHghPfS 3zq4cxe/QwLsvjJII13GIHCDcysmX2COY1Y0oyERgYpOkQuqCZ1YCXRrADdLbo/zov6+ jQ26cRvnmQBwGlylMkBcoM0TO6G9GE5Nabh6S76+qpVjzU8B86FYCa5TQFvMSfzPd/Ny I41EE5jWe/TB4mq6Pf3x11ZEvmnCCglN/lHqnGAJk5IevjnK2CYe+bKG5TDej+SOD5vQ uWfzGj3iL7ygIanwHCBYOsdvi1EpZVKzn9auRr9O52doF8JWcrLqUNcRm7F7MU1vIg5t fCDw== X-Gm-Message-State: ANoB5pljSp6VhWNuCF4kCLEf8Gq0GU0f2Akv8XF8Adkxo+lkSeh7c29Y sz5U0S+jvvVl5CTAXNKQ3Yt2g0k+hCsxrPcT X-Google-Smtp-Source: AA0mqf6sVZLMIbxle3FItyBdI6o/1WnZcfUze/UowsAko0aTuFLLhiu/ZhAmh8lAgCCwUsXO//M0Xg== X-Received: by 2002:a05:600c:3b9c:b0:3d1:e710:98ec with SMTP id n28-20020a05600c3b9c00b003d1e71098ecmr5003710wms.21.1670576492195; Fri, 09 Dec 2022 01:01:32 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd10-20020a05600c1f0a00b003cf774c31a0sm7773674wmb.16.2022.12.09.01.01.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Dec 2022 01:01:31 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 9 Dec 2022 09:00:43 +0000 Message-Id: <20221209090050.19441-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221209090050.19441-1-naush@raspberrypi.com> References: <20221209090050.19441-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 05/12] pipeline: raspberrypi: Handle MandatoryRequestBuffer hints for Unicam Image 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" Look for MandatoryRequestBuffer flag in the hints field of the Unicam Image StreamConfiguration structure. If this flag is set, it guarantees that the application will provide buffers for Unicam Image, so override the minUnicamBuffers and minTotalUnicamBuffers config parameters in the following way: - If startup drop frames are required, allocate at least 1 internal buffer. - If no startup drop frames are required, do not allocate any internal buffers. All other buffer allocations remain unchanged. Signed-off-by: Naushir Patuck --- .../pipeline/raspberrypi/raspberrypi.cpp | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index c5a489fc7581..8be46962e825 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1447,12 +1447,33 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera) int PipelineHandlerRPi::prepareBuffers(Camera *camera) { RPiCameraData *data = cameraData(camera); - unsigned int numRawBuffers = 0; + unsigned int minUnicamBuffers = data->config_.minUnicamBuffers, + minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers, + numRawBuffers = 0; int ret; for (Stream *s : camera->streams()) { - if (isRaw(s->configuration().pixelFormat)) { + if (s == &data->unicam_[Unicam::Image]) { numRawBuffers = s->configuration().bufferCount; + /* + * If the application provides a guarantees that Unicam + * image buffers will always be provided for the RAW stream + * in a Request, we need: + * - at least 1 internal Unicam buffer to handle startup frame drops, + * - no internal Unicam buffers if there are no startup frame drops. + */ + if (s->configuration().hints & + StreamConfiguration::Hint::MandatoryRequestBuffer) { + if (data->dropFrameCount_) { + minUnicamBuffers = std::max(1u, minUnicamBuffers); + minTotalUnicamBuffers = + std::max(minUnicamBuffers, minTotalUnicamBuffers); + } else { + minUnicamBuffers = 0; + minTotalUnicamBuffers = 0; + } + } + break; } } @@ -1464,7 +1485,6 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * For Unicam, allocate a minimum number of buffers for internal * use as we want to avoid any frame drops. */ - const unsigned int minBuffers = data->config_.minTotalUnicamBuffers; if (stream == &data->unicam_[Unicam::Image]) { /* * If an application has configured a RAW stream, allocate @@ -1472,8 +1492,8 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * we have at least minUnicamBuffers of internal buffers * to use to minimise frame drops. */ - numBuffers = std::max(data->config_.minUnicamBuffers, - minBuffers - numRawBuffers); + numBuffers = std::max(minUnicamBuffers, + minTotalUnicamBuffers - numRawBuffers); } else if (stream == &data->isp_[Isp::Input]) { /* * ISP input buffers are imported from Unicam, so follow @@ -1481,15 +1501,15 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * available. */ numBuffers = numRawBuffers + - std::max(data->config_.minUnicamBuffers, - minBuffers - numRawBuffers); + std::max(minUnicamBuffers, + minTotalUnicamBuffers - numRawBuffers); } else if (stream == &data->unicam_[Unicam::Embedded]) { /* * Embedded data buffers are (currently) for internal use, * so allocate the minimum required to avoid frame drops. */ - numBuffers = minBuffers; + numBuffers = data->config_.minTotalUnicamBuffers; } else { /* * Since the ISP runs synchronous with the IPA and requests,