From patchwork Tue Jan 9 10:25:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Plowman X-Patchwork-Id: 19378 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 E7C09C3240 for ; Tue, 9 Jan 2024 10:25:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CE2C962B3F; Tue, 9 Jan 2024 11:25:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1704795953; bh=sk7VkbU94NQuRCEFYbnRPk9Zsntk86lan3bWahTyVUo=; 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=tIMrSE9yvmwxNcdql+plTOIfC2PKH3sxjLijIN5aQ0sbrDo+U+ZSb/2y4gkW6QSHJ MxkYY9hv6iq0D+jd0z6jTgAUuCf9tzgloXjB9CCjbucb8j9cHkLKj/V63LT6p+Mzrn 2eDbuM6W342TIAUKwn9sTCOTHCaKV+pX6sZ+kwQBs6o346lZzPCZPg55yOhNbEX8Sw Daw4QjGeo1rdrMZBRMIvcQAsL5caBickc91K41nzE2GcuIEpMWHjLz+uDko3jGn+rX PPsHkXsyd150T23o+bKKJGgWK7/VAk0o3wBSHFad52GS/iJciS589lr9B+mslakUYs 8AggHCqzKUu1A== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DB24F62B32 for ; Tue, 9 Jan 2024 11:25:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="lmjErkdq"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-40d604b4b30so21879465e9.1 for ; Tue, 09 Jan 2024 02:25:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1704795950; x=1705400750; 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=x8k0NAvoRYRsE3vDJDFTshG7FA7sFPwGxhdu55F3+b8=; b=lmjErkdq1SaEMUbzTOiiIFdr9RXXLloSfwy7H5Sym0IbvvdsQtnxC/KYc5nAHaBTvY j3Zr7IInRnT3eSOwlsNd8YyUnA+yJsN4H78BP196Ft7C9B3icPf3nkGPrWX7hUcE/KVS iF8dBLTtM7TRzql9B3jK1WJDjzJ4CGavJYhJ9ducC1B5yI9t5YHBqMuP6+41fxrSz2uc MO1ZliwJ6I2d/uw3wtbLdl+ucxJP+zegBswpNNnsqN+DyNeoeFlTVdtlWHjOvoCmK5r2 WwqFvn0dhYRNzSjV6YpspV5qx5wadObMkm7pHA+d2uJ7TYnub2b0qY7qe8HsvwxnaC8/ j13w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704795950; x=1705400750; 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=x8k0NAvoRYRsE3vDJDFTshG7FA7sFPwGxhdu55F3+b8=; b=oHPet5AnbXhDbl1gyZBK56xZA2XSOyVmjLy9wIfS4Oaw54k12oaGtXwDyxV2Islm5l RqK6wnauk4f8p10IWb6ro2M6ySJ914GaRlO5MPxtx9o8SrXt4YjzTBxT2DHhSuQnegR3 JwBvP6vNwYNnDlbvPgvVcWE3dNMGCPLeeU5cb5i+bW762PhBvLhBv7nZaQiEx4hrbV0A TlyNhFE+nrAoPTxDXKoprTX97Zmbea+fNIJoOcKR5yqHQlOoIut1JZkS2InA74CGSUch qtY0JF/2z+h6qYHXU2xhNqQXVpln870DhN5vxzC0E6tLJ8kQHgblHC0OeBDaXhfzZ0u2 ICZg== X-Gm-Message-State: AOJu0YwiudiIAjRThMoxfIPbWyFxtaCs+sEAvRCCho03XkJdGO86mtno 5mwhsZ50YY37hHtlMnmZhN18pwepvK3DxSMHXeMx6T7FKxk= X-Google-Smtp-Source: AGHT+IE6p80SKaSNKe4VIonS4dfqe9IEVJa68lVKbUrfeyMPTd+F5Cofhua7ej2hi+vbPzCbavO0Lw== X-Received: by 2002:a05:600c:3109:b0:40d:8ed9:ce8c with SMTP id g9-20020a05600c310900b0040d8ed9ce8cmr301529wmo.120.1704795950144; Tue, 09 Jan 2024 02:25:50 -0800 (PST) Received: from pi4-davidp.pitowers.org ([2001:4d4e:300:1f:70fb:d051:958c:e7b3]) by smtp.gmail.com with ESMTPSA id c15-20020a5d4ccf000000b00336765e9babsm2005086wrt.83.2024.01.09.02.25.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 02:25:49 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Jan 2024 10:25:46 +0000 Message-Id: <20240109102547.2762-2-david.plowman@raspberrypi.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240109102547.2762-1-david.plowman@raspberrypi.com> References: <20240109102547.2762-1-david.plowman@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 1/2] ipa: rpi: Implement HDR 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: David Plowman via libcamera-devel From: David Plowman Reply-To: David Plowman Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Sufficient plumbing is added so that the HDR mode control can be used to engage HDR modes on platforms that support them. On the vc4 platform, this allows multi-channel AGC to run, though there is no image merging. Signed-off-by: David Plowman Reviewed-by: Naushir Patuck --- src/ipa/rpi/common/ipa_base.cpp | 49 +++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/ipa/rpi/common/ipa_base.cpp b/src/ipa/rpi/common/ipa_base.cpp index 6ec91575..632b8d2f 100644 --- a/src/ipa/rpi/common/ipa_base.cpp +++ b/src/ipa/rpi/common/ipa_base.cpp @@ -24,6 +24,8 @@ #include "controller/ccm_status.h" #include "controller/contrast_algorithm.h" #include "controller/denoise_algorithm.h" +#include "controller/hdr_algorithm.h" +#include "controller/hdr_status.h" #include "controller/lux_status.h" #include "controller/sharpen_algorithm.h" #include "controller/statistics.h" @@ -67,6 +69,7 @@ const ControlInfoMap::Map ipaControls{ { &controls::AeFlickerPeriod, ControlInfo(100, 1000000) }, { &controls::Brightness, ControlInfo(-1.0f, 1.0f, 0.0f) }, { &controls::Contrast, ControlInfo(0.0f, 32.0f, 1.0f) }, + { &controls::HdrMode, ControlInfo(controls::HdrModeValues) }, { &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)) }, @@ -688,9 +691,17 @@ static const std::map AfPauseTable { controls::AfPauseResume, RPiController::AfAlgorithm::AfPauseResume }, }; +static const std::map HdrModeTable = { + { controls::HdrModeOff, "Off" }, + { controls::HdrModeMultiExposure, "MultiExposure" }, + { controls::HdrModeSingleExposure, "SingleExposure" }, +}; + void IpaBase::applyControls(const ControlList &controls) { + using RPiController::AgcAlgorithm; using RPiController::AfAlgorithm; + using RPiController::HdrAlgorithm; /* Clear the return metadata buffer. */ libcameraMetadata_.clear(); @@ -1162,6 +1173,34 @@ void IpaBase::applyControls(const ControlList &controls) break; } + case controls::HDR_MODE: { + HdrAlgorithm *hdr = dynamic_cast(controller_.getAlgorithm("hdr")); + if (!hdr) { + LOG(IPARPI, Warning) << "No HDR algorithm available"; + break; + } + + auto mode = HdrModeTable.find(ctrl.second.get()); + if (mode == HdrModeTable.end()) { + LOG(IPARPI, Warning) << "Unrecognised HDR mode"; + break; + } + + AgcAlgorithm *agc = dynamic_cast(controller_.getAlgorithm("agc")); + if (!agc) { + LOG(IPARPI, Warning) << "HDR requires an AGC algorithm"; + break; + } + + if (hdr->setMode(mode->second) == 0) + agc->setActiveChannels(hdr->getChannels()); + else + LOG(IPARPI, Warning) + << "HDR mode " << mode->second << " not supported"; + + break; + } + default: LOG(IPARPI, Warning) << "Ctrl " << controls::controls.at(ctrl.first)->name() @@ -1309,6 +1348,16 @@ void IpaBase::reportMetadata(unsigned int ipaContext) libcameraMetadata_.set(controls::AfPauseState, p); } + const HdrStatus *hdrStatus = rpiMetadata.getLocked("hdr.status"); + if (hdrStatus) { + if (hdrStatus->channel == "short") + libcameraMetadata_.set(controls::HdrChannel, controls::HdrChannelShort); + else if (hdrStatus->channel == "long") + libcameraMetadata_.set(controls::HdrChannel, controls::HdrChannelLong); + else + libcameraMetadata_.set(controls::HdrChannel, controls::HdrChannelNone); + } + metadataReady.emit(libcameraMetadata_); }