From patchwork Mon Dec 4 16:19:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 19277 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 D9A5CC322E for ; Mon, 4 Dec 2023 16:18:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6BBCE629CF; 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=/v4zSQ7v4xevwPPInsO0BXWyq5rTpxgb/3gp4zmt90k=; 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=gn/ZtYNyx++U3C7s/ikU6bR6N/wwiCSEPbPOthI8iCnHa3olkalWfj7dzkkrpjXg6 NZdLHct+HbXnzkntWsaacUxQ/VcpAmlZN6RrTgpYUtqhrQBR1KP9O+HIsDd2csDV9b MmY01Fg0hMrNA8bKny9ni4TFPiB10bPP2Mxykk6c/1REBQ8MtE8oHPdAK7qQfxSreI KcFC6EFpwpGZ537pfoMulLhHH4En3v4gch3gYMw56G+V8P3SwqjoSY7AztDTnGs6vQ MJQoR/1SsdbB9g5Y6+CyHb3CXXofqOStZFXkXzRaJN8qmRdsWZEYXuDlJySeewlaFi h1WnSahI7RMhg== 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 57753629CD for ; Mon, 4 Dec 2023 17:18:48 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="AJ8uiKkq"; dkim-atps=neutral Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a18b0f69b33so831843866b.0 for ; Mon, 04 Dec 2023 08:18:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1701706727; x=1702311527; 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=y8ncGodAQ6bEVK+GpWf7ReWnK1V/zDtSzIhEDDR6iyo=; b=AJ8uiKkqKXNiyzQ1ZFtA09ktBmP1Q6rI+P+isPlV8v3AeFek29HBtk9dIwTKbW3Y+S adtOHQyMnBXwGRS9qjrwL2H5EM58kQAVuoC31VqeMcMmhhVpkqDD5kzxZlpk+6nEMlM3 QtFq88MFtePXN+ACUjAhw+W/vKYIXNxdNqUmERlzL1z5JWLIHjt+Lyk11LRQqTTbTmqW yPiuWU2tdWHkOBOsERZVaSrIUiTaixhI9o6/9jT3tFxfFEyfiaDc2weQBAQoa4T98hdY xkR04dKWEiezb+rhZvC+pqvky4fM1VW6L/bikrQ5jECQkjkuZdPWPRgzTeASxWqeAhID nHxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701706727; x=1702311527; 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=y8ncGodAQ6bEVK+GpWf7ReWnK1V/zDtSzIhEDDR6iyo=; b=KQR+DHjrseSTgKt7SKK7V1ETgxLBLkMHvvorBhiIjGqtPaBFfAe8jsIjYRXv0wceRP eL6URE59xUX79rtNB15L6vlXp/sKnmeCBncDrYrd0iCfXLE1kt3EL76tRzK8BHAff+e6 3jzQxKujkm7Yu9I3SKDoz00CQS8FdQ8mQJRp6+pLRs9dX8XPfcuCGi2L/OebcQ4XwS3e HBsBkAX3b4wryT6/wETDXmLI97UIwuMRxVNAWIuc99G/h3G0hShjWRv29jqSGyAIj0uP py8vBggeD5jP30T/JXbmMWLELdOSp3KtO1ppc9+cVRdjtYbKJDARjwq8KmHJzEmHVjAk 6qmg== X-Gm-Message-State: AOJu0YznY+ODhAhjo3yyqaWMhgAF/+ULoKkHnxDCPA9hDTwpM7NqkVOK au3JTDzboCmxAUuT+NqHuI9hNtJRBqY2Lxf9ECK/mA== X-Google-Smtp-Source: AGHT+IEFPUF8FVk1VtLgF5pdCYIlHO+QqdumsiGpIPydjcSWFC9QgWQhi99MCVPOE4DEq9pg32N4dQ== X-Received: by 2002:a17:906:ccc7:b0:9e8:2441:5cd4 with SMTP id ot7-20020a170906ccc700b009e824415cd4mr6093171ejb.17.1701706727676; Mon, 04 Dec 2023 08:18:47 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 08:18:46 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Mon, 4 Dec 2023 16:19:00 +0000 Message-Id: <20231204161901.6632-2-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 1/2] build: controls: Add Raspberry Pi vendor specific controls 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 control_ids_rpi.yaml file to hold the Raspberry Pi specific vendor controls. Define a control StatsOutputEnable to allow the ISP hardware statistics to be output through metadata via the Bcm2835StatsOutput control. The implementation of these controls will follow in a subsequent patch. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Reviewed-by: David Plowman --- include/libcamera/meson.build | 1 + src/libcamera/control_ids_rpi.yaml | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/libcamera/control_ids_rpi.yaml diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index bab858a3790f..84c6c4cb8bf6 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -36,6 +36,7 @@ controls_map = { 'controls': { 'draft': 'control_ids_draft.yaml', 'core': 'control_ids_core.yaml', + 'rpi/vc4': 'control_ids_rpi.yaml', }, 'properties': { diff --git a/src/libcamera/control_ids_rpi.yaml b/src/libcamera/control_ids_rpi.yaml new file mode 100644 index 000000000000..cb097f887e16 --- /dev/null +++ b/src/libcamera/control_ids_rpi.yaml @@ -0,0 +1,29 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +# +# Copyright (C) 2023, Raspberry Pi Ltd +# +%YAML 1.1 +--- +# Raspberry Pi (VC4 and PiSP) specific vendor controls +vendor: rpi +controls: + - StatsOutputEnable: + type: bool + description: | + Toggles the Raspberry Pi IPA to output a binary dump of the hardware + generated statistics through the Request metadata in the Bcm2835StatsOutput + control. + + \sa Bcm2835StatsOutput + + - Bcm2835StatsOutput: + type: uint8_t + size: [n] + description: | + Span of the BCM2835 ISP generated statistics for the current frame. This + is sent in the Request metadata if the StatsOutputEnable is set to true. + The statistics struct definition can be found in include/linux/bcm2835-isp.h. + + \sa StatsOutputEnable + +... 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; }