From patchwork Mon Dec 4 16:19:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19278 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 A97C6C3226 for ; Mon, 4 Dec 2023 16:18:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D41BE629D6; Mon, 4 Dec 2023 17:18:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1701706730; bh=XCNQAjyiCKSxnl5IWKcZDrrgC0QxdTKi+qvoTnnl+f8=; 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=1K01OK5b+IsfZqpV/RtO7H/JRtkIDABLkgg4+Bhpb0TpqMdPcgIhZOCi6HDrWNm4E jkhzLWTWmLTjdK45Az1AewQLqyAlJKjHD79LDBLU0zlZJvKwhSlNV+jcIMGECC+FWv M0S6KvOZ4Zxl9yIq9+303dqEpsfkgMH6zG1xHcmuQba430GnF7scz/QPq483/ljM6a lfIc/rzwwlNh53c5nTlcQTm9aNfEIcbpS5f5/X9QERorcfkU8UANxzdBxlxmY0JouX oLcqEppwe5ceiNQ5yVHqHPv7r/U2dRQMR5k0tqFZes/vZ9mgiuoaODg2VLxNeHdr0S sQWKh8gFHPkEw== Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 55F7A629CF for ; Mon, 4 Dec 2023 17:18:49 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="JcP2QhPF"; dkim-atps=neutral Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a0029289b1bso603999966b.1 for ; Mon, 04 Dec 2023 08:18:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1701706728; x=1702311528; darn=lists.libcamera.org; 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=HTKr+T3yK1rgst9SoGWu8BhqjJkOk+nmHY9N+xMaOlI=; b=JcP2QhPFT7hjEX4clRXl4/cnBW4HHoUW+KkkFh7DWOVif1yxSiNZtPudRfV8ZxTFry MvrOB+bru0Tno7L/Tjp/xCvhgof8UN4FobNStpcocTcfgPZ6AJ0p7+6bnIB3zTF/0AyS IkpqnyRImXJEgY9nWbJEnrTq0tDvN/g7yJCNs+DYv8M6cGLpDs8GxieFC7obmi6zEpOm omt/H0E3hNyR6H0WmASzTwRebb7Can7Xyk8xfNyWTHKA9T27v527/2pQoNSgBOUiVAKi 2FR4b3cbrZaLXP/TaH6mQrao5btbmuhEcj0TQ+9uKKsJrODQoem5ozH445Akd0F/UUwr gIIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701706728; x=1702311528; 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=HTKr+T3yK1rgst9SoGWu8BhqjJkOk+nmHY9N+xMaOlI=; b=MkdqIlkF2osqDggsdN36gOUnW0lYC0kujkaktOjdg9E6iicp7ZVXW2HEcNEBXy4rgB yw64ysj3Du3S3bKH4X61iazRjRCPYMqTjTnRDaXmYVqXqWo6lHEfckUcGQdtcgDINafD TDnHcYamUCm7jcGFewL3MkYXs9Tie6/YEQNlNmwHBVX2Jo8CBoRuvDeztNFlgXd8wBaQ EBRc7Tl8RpAt/yZGsQRsb4hO/GBT1tCVlg+HLWHdQ+Cpu3XBs6+SJEx7gA1FLXDlOQON WmkoySkOLDRZ+fIlJ8GJOdlX278tWN3cCUnrZOzKTY/irmy2gfCOImiBhw9DWWXi106P U2oQ== X-Gm-Message-State: AOJu0Yx6dBzrFnELSd5q7jeAMr5SM4y8/YOxFHiwGYIDWiRqrMOwwvO1 GqxcFikqG6hx2VWhtgOhJFXbMC3pg17F7T+MTDXrbw== X-Google-Smtp-Source: AGHT+IGPnyz4/ZmaghAgy/EXyMdi/Jyqxfv1Do+nDWAhv7cwmhFz2S14b71AO983ZrxznD0wR6b3AQ== X-Received: by 2002:a17:906:e12:b0:a18:bb79:9a0 with SMTP id l18-20020a1709060e1200b00a18bb7909a0mr3349352eji.58.1701706728510; Mon, 04 Dec 2023 08:18:48 -0800 (PST) Received: from localhost.localdomain ([188.39.149.98]) by smtp.gmail.com with ESMTPSA id g5-20020a170906198500b009c5c5c2c5a4sm5445134ejd.219.2023.12.04.08.18.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 08:18:47 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Mon, 4 Dec 2023 16:19:01 +0000 Message-Id: <20231204161901.6632-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231204161901.6632-1-naush@raspberrypi.com> References: <20231204161901.6632-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 2/2] ipa: vc4: Implement the StatsOutputEnable vendor control 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" Implement the StatsOutputEnable control for the VC4 IPA. When set, this outputs the ISP statistics as a uint8_t span through the Bcm2835StatsOutput metadata control. To get this working, IpaBase::libcameraMetadata_ is moved from a private to a protected member variable. This makes it accessable to the VC4 derived IPA class. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: Kieran Bingham --- src/ipa/rpi/common/ipa_base.cpp | 12 +++++++++--- src/ipa/rpi/common/ipa_base.h | 3 ++- src/ipa/rpi/vc4/vc4.cpp | 6 ++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 6ac9d5de2f88..c4d17a2130c8 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -70,7 +70,8 @@ const ControlInfoMap::Map ipaControls{ { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) }, { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, { &controls::FrameDurationLimits, ControlInfo(INT64_C(33333), INT64_C(120000)) }, - { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) } + { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) }, + { &controls::rpi::StatsOutputEnable, ControlInfo(false, true) }, }; /* IPA controls handled conditionally, if the sensor is not mono */ @@ -100,8 +101,9 @@ LOG_DEFINE_CATEGORY(IPARPI) namespace ipa::RPi { IpaBase::IpaBase() - : controller_(), frameLengths_(FrameLengthsQueueSize, 0s), frameCount_(0), - mistrustCount_(0), lastRunTimestamp_(0), firstStart_(true), flickerState_({ 0, 0s }) + : controller_(), frameLengths_(FrameLengthsQueueSize, 0s), statsMetadataOutput_(false), + frameCount_(0), mistrustCount_(0), lastRunTimestamp_(0), firstStart_(true), + flickerState_({ 0, 0s }) { } @@ -1135,6 +1137,10 @@ void IpaBase::applyControls(const ControlList &controls) break; } + case controls::rpi::STATS_OUTPUT_ENABLE: + statsMetadataOutput_ = ctrl.second.get(); + break; + default: LOG(IPARPI, Warning) << "Ctrl " << controls::controls.at(ctrl.first)->name() diff --git a/src/ipa/rpi/common/ipa_base.h b/src/ipa/rpi/common/ipa_base.h index eaa9f71182ed..4db4411eed7c 100644 --- a/src/ipa/rpi/common/ipa_base.h +++ b/src/ipa/rpi/common/ipa_base.h @@ -61,6 +61,8 @@ protected: /* Track the frame length times over FrameLengthsQueueSize frames. */ std::deque frameLengths_; utils::Duration lastTimeout_; + ControlList libcameraMetadata_; + bool statsMetadataOutput_; private: /* Number of metadata objects available in the context list. */ @@ -89,7 +91,6 @@ private: bool lensPresent_; bool monoSensor_; - ControlList libcameraMetadata_; std::array rpiMetadata_; diff --git a/src/ipa/rpi/vc4/vc4.cpp b/src/ipa/rpi/vc4/vc4.cpp index c165a5b8b0b6..ccd4141943dd 100644 --- a/src/ipa/rpi/vc4/vc4.cpp +++ b/src/ipa/rpi/vc4/vc4.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include @@ -245,6 +246,11 @@ RPiController::StatisticsPtr IpaVc4::platformProcessStats(Span mem) stats->focus_stats[i].contrast_val_num[1][1], stats->focus_stats[i].contrast_val_num[1][0] }); + if (statsMetadataOutput_) { + Span statsSpan((uint8_t *)(stats), sizeof(bcm2835_isp_stats)); + libcameraMetadata_.set(controls::rpi::Bcm2835StatsOutput, statsSpan); + } + return statistics; }