From patchwork Wed Jan 18 08:59:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18131 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 4199DC3295 for ; Wed, 18 Jan 2023 09:01:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 98314625FA; Wed, 18 Jan 2023 10:01:22 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1674032482; bh=jhW47XycTJeJKViSSbDzQOA0ZeuaoMQvJsIW4Wz891g=; 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=qq+lbWLtaJASzBFws9XupzDV4V2NYSjJVMKqC2aELekNSm5cCMkXoHB/84cO2ywE2 eDEa55EwQ6J/OOgtrK49etTEmURFleGro/riRtEy61QaYO4im6QrsNb8oLnd/ZubiF OtQ4EkeUnHID0/Tg+KVgq+VUTrNDkKCx7RfMeV4isvEiVz2GBcxZX0KwRbvD4OSRFE FFzcP1xUFNoe991sLTVZqqVKYmChaBqJII22BCmDs2DCSmqQwZn/VbbN6/vdVIqxB3 WQIYCvt817/DvJOXPoilcdn+LW+Te7D/CQ6KGOG7tF1gQvbhGxKqruEcP7hGS0M+mB bzj/AlRpe5Cdg== Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F28261EFD for ; Wed, 18 Jan 2023 10:01:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="OO7hxI4I"; dkim-atps=neutral Received: by mail-wr1-x434.google.com with SMTP id n7so7117659wrx.5 for ; Wed, 18 Jan 2023 01:01:19 -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=MF/+iG7HIHFeXPj2IZioMbRFhVvgaszMfkZq5nsWvdw=; b=OO7hxI4Iya5vUbhk+KHdOtX1hJf3OPBlxmJjpEsB3Z5XsZxNSWyCaIeDVoi0bsjaoD NLOtTEjevAg8GAT0dmOs6koUowv5jpgBVLy627N4D2w02pRB5Y2E3HoG8xNisI56q+hi AtrZv9OQqb1FJpMPqjBMqlDT19wGIeq7uGbOCv0Lrop1PLY0xXOR5Bm6znmvz5BlJeJe 9bvCnGXRfYb1S9TSyx6M2nt8HigEnfa0Pk9O2PH0FO46/6pev7r04h8Q0ZKqlPNOqfLk fzdiCme3Rh624YIYJoW/+8FoJ4Gb4i5YkKge4tzgw1YVNXn37mmt82/yLnbx2hPzYtJr 4HgA== 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=MF/+iG7HIHFeXPj2IZioMbRFhVvgaszMfkZq5nsWvdw=; b=tVSs2Jo6MWqyGb+ZHoqd1Y3BDIZJ4ax9JCmyG8feQHVJc8I0l1sOcwV+99hHwTfwB7 pgTi/la6cit/oNZIREv113MH10fsUY0jp1uwL8evqb6kqnjeXr5p3xpDyQMekYg4S44C xmx4kqizgpfHB0gkAdxzu6iiAKFjJqZkcCyILm8kSgietnwVPAWid+gbps2pleU7ITdq OpzpA6ZxIGMWGjy2ab4YK4v1GDsJAaZLFws4ao6FduN/WSPvRoN044D64GYZ+0r5SmBZ sBYQ+Ff09VEPPKrIpm0u0J9E7v+0OE7MxwRfscg6RY4c56rmoB0Nh59ud0Vz0IJoZ2Ex jhfw== X-Gm-Message-State: AFqh2kqVJJEfFWpe+YjtR9uOe4oJbYwNBhW0QdbkBsisn8I3phB00CR7 sKrQWOcSCgKU+JbbyVpDAKc+ui+fqcvForoFUmg= X-Google-Smtp-Source: AMrXdXsNSb5pPN8Ey2hLWPziQkgq56hIFDQICQrKzEGB9VhZIRsF+TCKmPMv83X17hJP3Yr+Fd9D7w== X-Received: by 2002:adf:e991:0:b0:2b9:1a52:4f50 with SMTP id h17-20020adfe991000000b002b91a524f50mr13724505wrm.6.1674032478718; Wed, 18 Jan 2023 01:01:18 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id i6-20020adfe486000000b002423dc3b1a9sm30312464wrm.52.2023.01.18.01.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Jan 2023 01:01:18 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Wed, 18 Jan 2023 08:59:46 +0000 Message-Id: <20230118085953.7027-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230118085953.7027-1-naush@raspberrypi.com> References: <20230118085953.7027-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 05/12] pipeline: raspberrypi: Handle OptionalStream 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 OptionalStream flag in the hints field of the Unicam Image StreamConfiguration structure. If this flag is not 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 8d325c7a18c5..6ed4cc2c7ba7 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1448,12 +1448,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::OptionalStream)) { + if (data->dropFrameCount_) { + minUnicamBuffers = std::max(1u, minUnicamBuffers); + minTotalUnicamBuffers = + std::max(minUnicamBuffers, minTotalUnicamBuffers); + } else { + minUnicamBuffers = 0; + minTotalUnicamBuffers = 0; + } + } + break; } } @@ -1465,7 +1486,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 @@ -1473,8 +1493,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 @@ -1482,15 +1502,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,