From patchwork Fri Feb 3 09:44:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18247 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 DA0B7C323E for ; Fri, 3 Feb 2023 09:44:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D769A625EA; Fri, 3 Feb 2023 10:44:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1675417471; bh=WsKEAbgG9IiE5tFzEqPV+5BgzO8xIyNo52sfMFQqOyo=; 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=iSaMcTGfwx4Gommcjq+rij+YagSCelrPS88uJYVaNIiVRlhdgCHGVv0C1USyKzml+ U+s0EYc+CpllvawJybYyeQXOOOefftOR+Srr4aEfLODU9wuv24oVMRoaku0v1NUQ6G rGUI2BUQ8bGm9p2AmCpIp6snP6UPOVYVFRqXveFWEMiRtD1Y1/VF1YtSpIHRE4jRk1 UlLKYZZ8+PpMA3WDx6OwqH3LCTIesI5mg6S++Z/TttSrwpiGChvdnHZ7nMbDRzHHay 8deJ1Ts3LiKwj5MP2HUVbhxSR5XqNMG+C20i0lEo9CihTPZVVOfiem5N8+Lgr2eDKO gXTtWB3rxD7sQ== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1BE38625E8 for ; Fri, 3 Feb 2023 10:44:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="cU6m2sJf"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id d14so4088636wrr.9 for ; Fri, 03 Feb 2023 01:44:29 -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=xsXDGZ71N+GwEVQMLu8d8M3IAh85egvxBwrqphOJo0g=; b=cU6m2sJfTCx45df1eJFGTyXv9Ua+NnNCv5PsX+amdOCtiwK7pnlkhU17W9XcAv4Tp2 yVDfDnOtunuAge6Wpm4+lwcEhKLDrgDq4W9GP+2QSweSqo9b64AFdynv2/HIcY7T+Y6j n9sLsiIOVdHJKYLhpb+4GSvLEVwKGRgSs3D9l/pApQwEfvXcnL+R3Si2k0t8jO/qLgJR mSBtzsenepFZB5waLX5y0yZxqDS/WfTnfj9wfdNVYAj2hfG9gsJbFGbZdEcn+MIGMJKG C8MbC36q9c50zRF3vGhK0o8b9ALxkO1Hn5sKe1xaxt4WZ7ilQn0D9wQaJE+8eLrbH3Gn +2Bg== 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=xsXDGZ71N+GwEVQMLu8d8M3IAh85egvxBwrqphOJo0g=; b=0LBEXaC2ICmpMEFKZn0k5hVPRcZ53ARXOuQiOOTJgJu/0sHN6Oz9ZJNPlNJi3+aqLK XBdfRZUg8tyX5+ulFSUv3bx5yuSU9H88sI9v36bqavJfcvhgnxle7QiaoMbZkHJkQS7f rR+7r73CPKh7OMgIumrRRqcAHSxcq0QwRxCycvr0aWQcfKPViI3/uOhP+Giy3f3rrT5i ow3DZXwx/w9I6RvYRxPyIU0toAV/JWlItpuV7JnyHRs7VnFClKPlNk0nGYaeJJoXoRhM HOYLhhSi9E4ISLs5lKmNDrw/X2q/1evRA3NONFRmcZZvRc3Scnug+r/fjX6FZpnRBAy+ D7mw== X-Gm-Message-State: AO0yUKUjyDBy1XDSS9bT94EgHozaHxCCylgF3xmHL45BKZC5k7HjHssd wMR1hCg7nMGUBBDtrvLYog+OvPyS5u3fOPa+v1Na4A== X-Google-Smtp-Source: AK7set9qm4FtxfCgwu6JeJaCTvTCOQV1OwSfHuj70zaAqhYxNjyD4f7wqmm4gQZtZZUeG1mwobrNwg== X-Received: by 2002:a5d:6d05:0:b0:2bf:dd84:adf6 with SMTP id e5-20020a5d6d05000000b002bfdd84adf6mr10270074wrq.60.1675417468543; Fri, 03 Feb 2023 01:44:28 -0800 (PST) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f17-20020a5d50d1000000b002bfe266d710sm1562503wrt.90.2023.02.03.01.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 01:44:28 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 3 Feb 2023 09:44:18 +0000 Message-Id: <20230203094424.25243-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230203094424.25243-1-naush@raspberrypi.com> References: <20230203094424.25243-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/8] 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 d752911ddfff..7d786fe839f7 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1520,12 +1520,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; } } @@ -1537,7 +1558,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 @@ -1545,8 +1565,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 @@ -1554,15 +1574,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,