From patchwork Mon Mar 21 23:02:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Rauch X-Patchwork-Id: 15490 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 3D780BD80A for ; Mon, 21 Mar 2022 23:02:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 61DBC604DC; Tue, 22 Mar 2022 00:02:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1647903772; bh=wmCXtR2FbgbBhVrJeez6j8+XAIfFqgoFlpLCZmTLjLY=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=qiLI20fvUURnJePtv3QGVdqeO5yceVHt09hEJ5MF/s4tX2ZGi/3ZmoGPafNjIYLE9 ZL5wnNZOdM9d8YASCSU60oLgSjnMmFCGQz2oj/zAkulkVe+M8era79APjIH0WSFfDZ fVJhqEW8s3KbPQHsiTonJ/rosFfOPneJqA48nfbr9y5Dgu6M1kcMGrCOxz49jM2ftI wdDIItNejJyBesPzfF3Md8AiHIzfVD4/bVjRSUf0eHycXzJKeI4IyjhiWDnNdU23fo 1CmDssh9ayaYVlpFjbIUKDu4qcjeF0WuGsyxtkxoTLD6wChYLL78qWHM9cUdBTAehJ 2vojd54fD6mWg== Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1BFB8604C7 for ; Tue, 22 Mar 2022 00:02:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=gmx.net header.i=@gmx.net header.b="FF3Wnk75"; dkim-atps=neutral DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1647903769; bh=wmCXtR2FbgbBhVrJeez6j8+XAIfFqgoFlpLCZmTLjLY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=FF3Wnk75SoalXBAymepKS5+K7vqxrrHMROgolwhvLWKhdqSrTI6wVsTCpaD4Z5S1c wR2Mw4XBQUlREFLDjfZSsHrC6WwObhH8EVrT3jNiJoF0qOp3TcyevRMoyd2wINxrSH RUWUjdNRd02qBBlaLyIvNadHLUlW6e4mpVi9cKLg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from localhost.localdomain ([92.10.251.63]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MPokD-1njzz82Uj5-00MrEp; Tue, 22 Mar 2022 00:02:49 +0100 To: libcamera-devel@lists.libcamera.org Date: Mon, 21 Mar 2022 23:02:46 +0000 Message-Id: <20220321230246.663401-1-Rauch.Christian@gmx.de> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Provags-ID: V03:K1:K8EpVn94cOgA9l7oQthv1+aP95+slVAEyuwRRfnRz+NvDn/hbq2 QCA/gpAgtX/ZB/RxRCi1uNhDonsoIjZxm5UmNzGHjKKPAVVvgBo/ajQwb5IAJbsFiuKi4Dy 4VaA7DbggTylZ+jiJpQ+i6atxuROkLA64wR1ayC4IfcXYUekrrNx3Gc5HUZzmZrBGkB20e7 SQ2eI5uKlE57U5PzqN58g== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:W0q3Uz6BaGo=:YYzgxrvJBevjp3D+3VhsR4 U/JQmDECd2TvetvESvPSe7kVLoaGd3mWRuxUh+YpA7hzcvnjiSMgOTw0frfJb08juh+Hyd0Gl Wjdfqv/ll4PxXMy4CTvjDgYOrosdMTC2DoEe+FOh3gwmj8vZfjc3syb1bE7F0/M25CGoNZstL lBHicBlNKhipCNTAr/sivUjTji/qEeCae1erz+TK5mIzEaeorMSVs1GzB5Tyl3org9NI50GsQ jAYD9dAOxwdnm3ibLCS2FIws2/PteoAMcb0aLtpZWpDIeA1oeOSPvc1KwWmeIHLijmaXmQ0mN FCfGxUMF3h8KQcve6pMy0s1H+DBENi0EcMokWDUpp605J1MdRobC9VWLL/P9FiTx0o7Vy4HjP bOK/Hxd/xSRr+cq1q054h2cjUPAq7Cb4drWdoKYt9yHA5PE5z+2MaF6+ns3Htv5+wDoHorEfU VJ0RFDcmuxpzXlcP0RqWWGPY8wRFozEyLUtPA8nVeBJSQsjL7re4mKlYEoiiWrb5stoLdNUF2 WQhzIaMh+E+CHfvbZUd9062+/XPxPUOriVY/0VtXQ76byqXIlkSTS1kWL5wKOVCt1zE539uwa VPt95f8VHoYl3/xDE+yfr80MDTF8mCStT2/xahPEt01GDv2YSX+Up+UnZeSEDYU9dlCxdEwXs 6VXh90gr38/DDuQx1ca3HPSnv317ngcVav0xNlwcsSk37aiJnPvCPQcHAGLuclQ5l2jXJkioW r23YOxRvDEffgoda7dwPFw30W4WNOQndw/NJGHty8di1JodaaqYmRY5ky2t0exRsz1vJNM4de Xq/7aYTk9CyQeQfkRctBTdfPQFLW4rXSULgVCzA0nbDwuos5eRbALEwq4axGP7HYJf4cyqyfk nb04RNLdhyoug836r5zFN34o0aN+n9IrWOH0bf93FfC3ICu+Hvan5n4VMZM0/AbT7P43UvJvO R37OPVGwwXp4F+ZHYRkCEaTRDneaY3L4MSPvZQAHiDrgeHwkEkL3nkPao/o1K7ml1ZaNErYy0 387zHdAIzttBATOGZeaUJoVIuAFwj6t9V17C+imBK2+xHFMgLSw9mBsOvwLsL0b9Q9X6RRWQK ATJAv2vKf4ZEwA= Subject: [libcamera-devel] [PATCH] fix ControlInfo for Span 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: Christian Rauch via libcamera-devel From: Christian Rauch Reply-To: Christian Rauch Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Some control properties are typed with a Span to store an array of values. Currently those are ColourGains, SensorBlackLevels, ColourCorrectionMatrix and FrameDurationLimits. The value range and defaults in the ControlInfo of those Controls is currently defined as scalar. This prevents accessing the ControlInfo via the native Span type. By defining the ControlInfo in terms of Spans, we can avoid this issue. --- include/libcamera/ipa/raspberrypi.h | 52 ++++++++++++------- src/ipa/ipu3/ipu3.cpp | 6 +-- .../ipa_data_serializer_test.cpp | 8 +-- 3 files changed, 40 insertions(+), 26 deletions(-) -- 2.25.1 diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h index 7f705e49..fb5188a1 100644 --- a/include/libcamera/ipa/raspberrypi.h +++ b/include/libcamera/ipa/raspberrypi.h @@ -27,26 +27,38 @@ namespace RPi { * and the pipeline handler may be reverted so that it aborts when an * unsupported control is encountered. */ -static const ControlInfoMap Controls({ - { &controls::AeEnable, ControlInfo(false, true) }, - { &controls::ExposureTime, ControlInfo(0, 999999) }, - { &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) }, - { &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeValues) }, - { &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) }, - { &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) }, - { &controls::ExposureValue, ControlInfo(0.0f, 16.0f) }, - { &controls::AwbEnable, ControlInfo(false, true) }, - { &controls::ColourGains, ControlInfo(0.0f, 32.0f) }, - { &controls::AwbMode, ControlInfo(controls::AwbModeValues) }, - { &controls::Brightness, ControlInfo(-1.0f, 1.0f) }, - { &controls::Contrast, ControlInfo(0.0f, 32.0f) }, - { &controls::Saturation, ControlInfo(0.0f, 32.0f) }, - { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) }, - { &controls::ColourCorrectionMatrix, ControlInfo(-16.0f, 16.0f) }, - { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, - { &controls::FrameDurationLimits, ControlInfo(INT64_C(1000), INT64_C(1000000000)) }, - { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) } - }, controls::controls); +static const ControlInfoMap Controls( + { { &controls::AeEnable, ControlInfo(false, true) }, + { &controls::ExposureTime, ControlInfo(0, 999999) }, + { &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) }, + { &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeValues) }, + { &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) }, + { &controls::AeExposureMode, ControlInfo(controls::AeExposureModeValues) }, + { &controls::ExposureValue, ControlInfo(0.0f, 16.0f) }, + { &controls::AwbEnable, ControlInfo(false, true) }, + { &controls::ColourGains, ControlInfo{ + Span({ 0, 0 }), + Span({ 32, 32 }), + Span({ 0, 0 }), + } }, + { &controls::AwbMode, ControlInfo(controls::AwbModeValues) }, + { &controls::Brightness, ControlInfo(-1.0f, 1.0f) }, + { &controls::Contrast, ControlInfo(0.0f, 32.0f) }, + { &controls::Saturation, ControlInfo(0.0f, 32.0f) }, + { &controls::Sharpness, ControlInfo(0.0f, 16.0f, 1.0f) }, + { &controls::ColourCorrectionMatrix, ControlInfo{ + Span({ -16, -16, -16, -16, -16, -16, -16, -16, -16 }), + Span({ 16, 16, 16, 16, 16, 16, 16, 16, 16 }), + Span({ 1, 0, 0, 0, 1, 0, 0, 0, 1 }), + } }, + { &controls::ScalerCrop, ControlInfo(Rectangle{}, Rectangle(65535, 65535, 65535, 65535), Rectangle{}) }, + { &controls::FrameDurationLimits, ControlInfo{ + Span({ 1000, 1000 }), + Span({ 1000000000, 1000000000 }), + Span({ 1000, 1000 }), + } }, + { &controls::draft::NoiseReductionMode, ControlInfo(controls::draft::NoiseReductionModeValues) } }, + controls::controls); } /* namespace RPi */ diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp index 1ea2c898..e64fc2bb 100644 --- a/src/ipa/ipu3/ipu3.cpp +++ b/src/ipa/ipu3/ipu3.cpp @@ -267,9 +267,9 @@ void IPAIPU3::updateControls(const IPACameraSensorInfo &sensorInfo, frameDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U); } - controls[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0], - frameDurations[1], - frameDurations[2]); + controls[&controls::FrameDurationLimits] = ControlInfo{ Span({ frameDurations[0], frameDurations[0] }), + Span({ frameDurations[1], frameDurations[1] }), + Span({ frameDurations[2], frameDurations[2] }) }; *ipaControls = ControlInfoMap(std::move(controls), controls::controls); } diff --git a/test/serialization/ipa_data_serializer_test.cpp b/test/serialization/ipa_data_serializer_test.cpp index d2050a86..5503cc8a 100644 --- a/test/serialization/ipa_data_serializer_test.cpp +++ b/test/serialization/ipa_data_serializer_test.cpp @@ -32,13 +32,15 @@ using namespace std; using namespace libcamera; -static const ControlInfoMap Controls = ControlInfoMap({ +static const ControlInfoMap Controls = ControlInfoMap( + { { &controls::AeEnable, ControlInfo(false, true) }, { &controls::ExposureTime, ControlInfo(0, 999999) }, { &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) }, - { &controls::ColourGains, ControlInfo(0.0f, 32.0f) }, + { &controls::ColourGains, ControlInfo{ Span({ 0, 0 }), Span({ 32, 32 }), Span({ 0, 0 }) } }, { &controls::Brightness, ControlInfo(-1.0f, 1.0f) }, - }, controls::controls); + }, + controls::controls); namespace libcamera {