From patchwork Tue Dec 6 13:54:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17948 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 DC333BE08B for ; Tue, 6 Dec 2022 13:55:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6529F63355; Tue, 6 Dec 2022 14:55:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1670334914; 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=sLSYMpbghkoDOQbYvLqMNnXqrjE+CZQhjxHms1NuvjASAfAS70UrLC9vm8aXT/+CO LJoBC1yhXO3QETMUVU5imSlqzz+Uf9SWw/zMlNHY2y7sqvxEsVx2r5tBQ2u2f/koa8 I2702NpZ3gy58Uuyb8Ax+x2HMzK4CLZzuZbIM5/KTzU6XeqliLA9X9F0qYj2AColog khFPoTX6Q6f6Kzwj/QvoxTJoeuJuVcO0szo9wNowabbiHendwZr0pOnahretlyjR7i DU4qmYi+Qi46uz/OKq65vY9tIKrpJJ+23xytC6LKhgbTYbm0YfgKiAvQE82M1DAx8R sg+YWLo2PbrDg== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7908463340 for ; Tue, 6 Dec 2022 14:55:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="TwdQq6sO"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id j5-20020a05600c410500b003cfa9c0ea76so12704468wmi.3 for ; Tue, 06 Dec 2022 05:55:09 -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=TwdQq6sOPdWFHPp3QNwdjsMceu4HFp/ks/BI2u0/ua623bFbZjAcRxytt71CT+SeOA mCSNd93NZVvyEp+Em4lGZStW2SjrfzYWmaHDuWU2BQ/a+IKuDZSjHzuW0CL8weqmrApd ceBvAFvkonR9XHUVFfanxFrW8SXT0AWv0jBFo+whYMB96zllP6SjWYRu23+2ZOEmUZ96 ajeMByXGGFjC8uv4G+FvGH+DlclKwZ4wcZ1pDkwUjm366AvYTiaU3A6R772cLL1tkcNr 2XyrPT/XgvegKItvnSYXr5+iUH58o+Jpc8kvArQWC4yitFExepB9imE0y/iLwUsSjhEs mt7w== 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=UoLfdoIMG11Wp1yaPDoMF5nUrsZjUDzsxnQrtUnbRB+ZqsONniuOA36iDwQFurMuEd 8pYQMQFXrbpkSvOiEX4v2xRM+fZXKti5YCaTDcjqBAnWi1SNDdTDC1ahkl5KHUWDVVvi QjGTOGedfDOGdp/0Z6en7qkd8hgzOShZmngaqkC7SlLqyhWAO4AN9bAM4AsGF3hYqtc+ /a0nyuxCcw/QYTAuP5SKXa5G0XWjRCIwa1N+5GL1fVehkKrj2eOB+gEKY2YXNWkWnF81 8SW9VDO7HKg0CEu3WZ8L3L4FGkF6/5A9QWNZPkbYNwUvlTPOrASRk7qOjVtRrgJuNxeH PRnA== X-Gm-Message-State: ANoB5pn+KhqzpFQCWq1YYFN0LALwRHAiWTvxM+EQzvMoAJ9Y90xc5MZS 3MtN8TO14adtzaKcSt68t6cOfshIHjDCSrvq X-Google-Smtp-Source: AA0mqf442stBLjas1vQV4VmPGSCW5FNbFzU8O1zLS8Dr5qzJlWGCnFFNS+Ia6tpmS+3CEYMCivL5Yg== X-Received: by 2002:a05:600c:792:b0:3cf:6a83:bd19 with SMTP id z18-20020a05600c079200b003cf6a83bd19mr56099201wmo.29.1670334908902; Tue, 06 Dec 2022 05:55:08 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id q6-20020a05600c2e4600b003c6bd91caa5sm19444059wmf.17.2022.12.06.05.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Dec 2022 05:55:08 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 6 Dec 2022 13:54:51 +0000 Message-Id: <20221206135459.25521-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221206135459.25521-1-naush@raspberrypi.com> References: <20221206135459.25521-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 05/13] 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,