From patchwork Tue Nov 29 13:45:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17914 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 7EC4DC3286 for ; Tue, 29 Nov 2022 13:45:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3F5E763348; Tue, 29 Nov 2022 14:45:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669729550; bh=xiZKOmMKgh4C0BiQ8C7Rx95IlKX9+MUIw2e5+Hw+o4I=; 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=SMdqRRTfFQhfYbELezwVbRSTU28gNpdy5iYn3UlzcM0Ut0j/nQeUtor0erkepH+jb W5R82LoCVH8XzU40Kg/obhfGINzO6QdSHTfvX3g6wMzNfy+fZzfzCATdwrJxFzy/cU uPhC7jjT9SeteTiF4eA1SLqrSJkGUHSL7W1v/OFGkAVcQitEMY/Xpt8TfQEbDNct3h lZ50nloKe8jSX0W4l+ABB7GZ91ejYU/mU9MvPf9M6ar108IzucMNROisRuBhoKcyop UcAnx6s4HI9o/q7AU51RXBTvw6M68nrEbEZdmYBGt3xaQ++/7+jtJ47Y7Gpo+tnjGs 81cViQ2sY1jRw== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 650CA63349 for ; Tue, 29 Nov 2022 14:45:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="DKkjlUnq"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id x17so22144311wrn.6 for ; Tue, 29 Nov 2022 05:45:43 -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=0JEGK22eBqrjF4esosBG7CRFyk4lPiCqUBabBHzNiq0=; b=DKkjlUnq2Tr3oePdX2JuR74hGcSR9SKcrUHduqKsithxqWE3K/FtpeyPe42vTveX4f r38YtPUC1IYUWAtNlS5lKsBSTzliF1XcYY42XjyPtk0KHJOkx3hETlr2cQojIDhZBLeK U2vcrl1e5PwcuXAm9CuVbFVUticwQH+gnh6WBolNtcP8Oqga8bDThOOnKg3l6dCi9Q26 eg0/6CBoKkaJUjbCEKkniASdwWPLjitS+7QO/xRRvUfFT/rXHCq6oZyXz8ZFQmMIffJP Uq7c3to8M58Y5RogtFKyGF2agO394Nk2WzuuwCdEY0hkuo9cNhsyFD3SkizwksPwRBxS xtqg== 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=0JEGK22eBqrjF4esosBG7CRFyk4lPiCqUBabBHzNiq0=; b=wQ794QyI0lVuxOmmGjyhJmaYoMa4T+7nvU9rNi5VNXCJA/i2a7lgn5lstztUcaX2ZW KkFoCEtNgbgQfbHu0C5PtBa1jFjdTnZIQ8cYyk8qqNs44APV1sWgJkFgmhH0iqK7QdKG 4GlB6W1fDLuo1gxEpz08S+0JdzOr73K7nvUOz6p5RTC7Iji7qB85UeodEthMRWIvu92r 4T5GwZFWf3tfe9A2u/HFK8L+Mr2UX+QuztFB4CLTS2RmaGCrJdo69l6G3Jv4VzorfmUA 3l4K+kQnRY+Xr7iOVs57plIRtDpXUPVnRzO+k8EXuKgETlQ77bhzaFW1BaLLsjpkuWQJ rUgQ== X-Gm-Message-State: ANoB5pkJxsxAQwviDLVkpbRNEUifTkq3xkWoVkQfIXQy+rQ4w5EOQ47p TVFVKYHzqm9ASLenb8hJtT051VQ7c+Eg9Q== X-Google-Smtp-Source: AA0mqf6RRYAoCmdunkfZsiEZOJHCdIUh1jPG2vb/9P8823Kza5DrJ85LSTdhsLHOrViZvLVj7cCQkQ== X-Received: by 2002:adf:f8c4:0:b0:242:82f:88c8 with SMTP id f4-20020adff8c4000000b00242082f88c8mr12400365wrq.151.1669729542767; Tue, 29 Nov 2022 05:45:42 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n8-20020a05600c3b8800b003cfbbd54178sm3565636wms.2.2022.11.29.05.45.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Nov 2022 05:45:42 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Nov 2022 13:45:31 +0000 Message-Id: <20221129134534.2933-8-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221129134534.2933-1-naush@raspberrypi.com> References: <20221129134534.2933-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 07/10] pipeline: raspberrypi: Add a parameter to disable startup drop frames 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" Add a new pipeline config parameter "disable_startup_frame_drops" to disable any startup drop frames, overriding the IPA request. When this parameter is set, it allows the pipeline handler to run with no internally allocated Unicam buffers ("min_unicam_buffers"). Add a validation to ensure if "disable_startup_frame_drops" is false, at least one internal Unicam buffer is allocated, possibly overriding the "min_unicam_buffers" parameter. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/data/default.json | 7 +++++-- .../pipeline/raspberrypi/raspberrypi.cpp | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/data/default.json b/src/libcamera/pipeline/raspberrypi/data/default.json index a7ea735c87f4..707414bcc5c5 100644 --- a/src/libcamera/pipeline/raspberrypi/data/default.json +++ b/src/libcamera/pipeline/raspberrypi/data/default.json @@ -5,7 +5,7 @@ "pipeline_handler": { # The minimum number of internal buffers to be allocated for Unicam. - # This value must be greater than 0, but less than or equal to min_total_unicam_buffers. + # This value must less than or equal to min_total_unicam_buffers. "min_unicam_buffers": 2, # The minimum total (internal + external) buffer count used for Unicam. @@ -15,6 +15,9 @@ "min_total_unicam_buffers": 4, # The number of internal buffers used for ISP Output0. - "num_output0_buffers": 1 + "num_output0_buffers": 1, + + # Override any request from the IPA to drop a number of startup frames. + "disable_startup_frame_drops": false } } diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 742521927780..ef49d32037af 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -312,6 +312,11 @@ public: * stream. */ unsigned int numOutput0Buffers; + /* + * Override any request from the IPA to drop a number of startup + * frames. + */ + bool disableStartupFrameDrops; }; Config config_; @@ -1058,7 +1063,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) data->setSensorControls(startConfig.controls); /* Configure the number of dropped frames required on startup. */ - data->dropFrameCount_ = startConfig.dropFrameCount; + data->dropFrameCount_ = data->config_.disableStartupFrameDrops ? 0 : startConfig.dropFrameCount; for (auto const stream : data->streams_) stream->resetBuffers(); @@ -1451,6 +1456,7 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) .minUnicamBuffers = 2, .minTotalUnicamBuffers = 4, .numOutput0Buffers = 1, + .disableStartupFrameDrops = false, }; char const *configFromEnv = utils::secure_getenv("LIBCAMERA_RPI_CONFIG_FILE"); @@ -1485,6 +1491,8 @@ int PipelineHandlerRPi::configurePipelineHandler(RPiCameraData *data) phConfig["min_total_unicam_buffers"].get(config.minTotalUnicamBuffers); config.numOutput0Buffers = phConfig["num_output0_buffers"].get(config.numOutput0Buffers); + config.disableStartupFrameDrops = + phConfig["disable_startup_frame_drops"].get(config.disableStartupFrameDrops); if (config.minTotalUnicamBuffers < config.minUnicamBuffers) { LOG(RPI, Error) << "Invalid configuration: min_total_unicam_buffers must be >= min_unicam_buffers!"; @@ -1569,6 +1577,15 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) */ numBuffers = std::max(data->config_.minUnicamBuffers, minBuffers - numRawBuffers); + + if (numBuffers == 0 && data->dropFrameCount_) { + LOG(RPI, Warning) + << "Configured with no Unicam buffers," + " but the IPA requested startup frame drops." + " Increasing to one buffer."; + numBuffers = 1; + } + data->numUnicamBuffers = numBuffers; } else if (stream == &data->isp_[Isp::Input]) { /*