From patchwork Fri Jan 27 15:43:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18205 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 920FCC3242 for ; Fri, 27 Jan 2023 15:43:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 08DC9625FE; Fri, 27 Jan 2023 16:43:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674834225; bh=LSY3MtkRkonnhlfUVdGTa0WEosqs8kEbZpn/jYt5LZY=; 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=a8D+0brLNSlrtXMPTxP8iNwmOenJD5NwdakEo/B5yKQQxwXcl7qKyK/pNJOkCuZQn GtmO+f7IHrR6KNGzThzkMP0hWm/F/+h+yGcKzHL2eHVXesNdLwwVjNN3dmOYLnkc+G UedVKG1esAn9S3lTm4z++D13Wh0sqahOBPFVE2b9LH06KFd65YCV1HsW3SQg2L5Yc2 Ktia/uS46rC+Pf17G+0PPC3bYRMDQCr/yjnSkjHVG7wMn0mH/U1lVp5NgyooZvdrTu Y8PBE9EBVOC4XlA1FtFfeLxroePhTc5iJ5sfkBkPwjg6e+yazXmYTq/KnVg2PSrUll qtZfEDaFn37lQ== Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DFC8A625EA for ; Fri, 27 Jan 2023 16:43:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="pgE6kJY/"; dkim-atps=neutral Received: by mail-wm1-x334.google.com with SMTP id m5-20020a05600c4f4500b003db03b2559eso3769664wmq.5 for ; Fri, 27 Jan 2023 07:43:38 -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=Gu7pQeRtJKEaZCE/Wr2FRS5oI/UGPEaX00FNTi5YwBM=; b=pgE6kJY/paPxzankVf1PJOunKzUYED3veXEDEpnt0KyoNweXNj6u9jQ/kp//BlIOah 4vNpkgbCvzHmDIeuPBo5wxy6zKNkYe0bVFfkbe/MzrKnDOZr1a80coyNFA/PYotPgf/6 0z57w789a+P7ZQjOWr1/HDMyTmLY7QU/ojW1B4mpUH2jJtiCum1UaAad+cqcbNtaZi+/ UZn4GKjhLTxhTjnLK1NDGYKh8GvsJhe3g8TeczHwtkbJeqx7Rv0NITkZC3ucZ4SCMZdr RTdwlPMf0xvxt4wt5mWpqfmbrjH3U0hW36OyRr6rLphrcJEZsPZzvtaHAScIWqwUuEzt lT3w== 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=Gu7pQeRtJKEaZCE/Wr2FRS5oI/UGPEaX00FNTi5YwBM=; b=wHWNQYcWdaHgNyn6514uDf1L3oMSYZc0Glc6vOXuQUBXxKwe9dAPdWNxhVg8otw/Kk VsH96CikUvhnSOD2POMPE9Rwlo2PCgCymqT9Ub2aqAZ3nx8E2Nmwyfo6jGPib9lWvJtw gkRbFniIxqTzMgbWCPS+cd28kHi/Wml+4mgj5ib1x16+91GTlIqfbw39VVwQ2lTdX18l fe2tEDHWZzU9+t41jQ+7f77deFwuby1bUEwaqFoyN4vRqoMsfuzrRhz8lC7FKbQeccXC YSvScUGywd8cNgVHx2VAC4J7sFsHGAAij2QbFgR1lJqNmtPrTmyNj7L5WgjZHo1n9ZjZ RuIw== X-Gm-Message-State: AFqh2kodKcOb57/UCGfaIR81xNN/KV8PzSb5oVpZcEdMe5CgmkupT87Y l3WMJ5hC94uoc3t7gFVSIL5D6iI7oMft4W+kZgE= X-Google-Smtp-Source: AMrXdXuV7SP6+X9wg7d8aYWTl4OQ/jBQtdAOofrGdwGio5YM0SymVnZsKerqlCMzc8+z5HzQdf4B2g== X-Received: by 2002:a05:600c:500c:b0:3db:2537:5ad3 with SMTP id n12-20020a05600c500c00b003db25375ad3mr33419995wmr.30.1674834218437; Fri, 27 Jan 2023 07:43:38 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h18-20020a05600c30d200b003c21ba7d7d6sm4549566wmn.44.2023.01.27.07.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Jan 2023 07:43:38 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 27 Jan 2023 15:43:12 +0000 Message-Id: <20230127154322.29019-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127154322.29019-1-naush@raspberrypi.com> References: <20230127154322.29019-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 05/15] pipeline: raspberrypi: Handle MandatoryStream 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 MandatoryStream 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 | 34 +++++++++++++++---- 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 8aa83aa76ae0..44b1727678c7 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1452,12 +1452,33 @@ int PipelineHandlerRPi::queueAllBuffers(Camera *camera) int PipelineHandlerRPi::prepareBuffers(Camera *camera) { RPiCameraData *data = cameraData(camera); + unsigned int minUnicamBuffers = data->config_.minUnicamBuffers; + unsigned int minTotalUnicamBuffers = data->config_.minTotalUnicamBuffers; unsigned int 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::MandatoryStream) { + if (data->dropFrameCount_) { + minUnicamBuffers = std::max(1u, minUnicamBuffers); + minTotalUnicamBuffers = + std::max(minUnicamBuffers, minTotalUnicamBuffers); + } else { + minUnicamBuffers = 0; + minTotalUnicamBuffers = 0; + } + } + break; } } @@ -1469,7 +1490,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 @@ -1477,8 +1497,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 @@ -1486,15 +1506,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,