{"id":16130,"url":"https://patchwork.libcamera.org/api/1.1/patches/16130/?format=json","web_url":"https://patchwork.libcamera.org/patch/16130/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220601231802.16735-5-Rauch.Christian@gmx.de>","date":"2022-06-01T23:18:02","name":"[libcamera-devel,v5,4/4] libcamera: controls: Apply explicit fixed-sized Span type casts","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c350fc5d7a95480479b2ebb696e7a057d2aab438","submitter":{"id":111,"url":"https://patchwork.libcamera.org/api/1.1/people/111/?format=json","name":"Christian Rauch","email":"Rauch.Christian@gmx.de"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16130/mbox/","series":[{"id":3152,"url":"https://patchwork.libcamera.org/api/1.1/series/3152/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3152","date":"2022-06-01T23:17:58","name":"generate and use fixed-sized Span Control types","version":5,"mbox":"https://patchwork.libcamera.org/series/3152/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16130/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16130/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 20110C326F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Jun 2022 23:18:21 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5A05565643;\n\tThu,  2 Jun 2022 01:18:20 +0200 (CEST)","from mout.gmx.net (mout.gmx.net [212.227.17.21])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 923FA65633\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Jun 2022 01:18:16 +0200 (CEST)","from localhost.localdomain ([92.18.80.244]) by mail.gmx.net\n\t(mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id\n\t1N9Mtg-1nhzJc0EeC-015KkG; Thu, 02 Jun 2022 01:18:16 +0200"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654125500;\n\tbh=9jrZMPAxGAv+cComYWDwcLi+XVv2D7JD4nqcULpKv2s=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=nTK7RgipkfaLqzEJEP2LVQvObLsjOamPNx6vCY1ox78gVQ10W9kkOEFtfJ7Mf7KQ2\n\t6BOyLczJr1W+hb/M7qnQMe4Yvk8zNJqeIt7e4P41CXeNJFUM5Fifx8F9OXzwhIzS1d\n\tArHwtZiV6Rng4hyLkHY5hFzKsDQqki+YLuyqhd95t7wiLJmtPjqrnZY6g5rlVa/5ch\n\tQS02UikBuY49btdLKMMqEhcPhzCN+ChXqm7qPhszR7I9R4K1Zav1T61plOWN5y+W5w\n\tdwZQdZDz3bXSCaLyjw6IUw/bmahhNvota015HNSfqQRJ3v1diL4VdJRnt85Kq81pcM\n\tg+rwXl8vJ/v9Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;\n\ts=badeba3b8450; t=1654125496;\n\tbh=9jrZMPAxGAv+cComYWDwcLi+XVv2D7JD4nqcULpKv2s=;\n\th=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References;\n\tb=FS5SowBDLUFGXXrPkAF4vexMswvrmwuxYFVLy5q8YCUVGhkzKMbo8Ke4e76UyxuBu\n\twKGuOVndV8hXlaaTlZBETdYSbtv5+4e5aQcKvj2c0DPV2xfHxJkvWJzNSWW3qnoiKS\n\tXMNoCyabRobq2buARZlrnGcrt5kZJV1x4Y+Tjb1Q="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=gmx.net header.i=@gmx.net\n\theader.b=\"FS5SowBD\"; dkim-atps=neutral","X-UI-Sender-Class":"01bb95c1-4bf8-414a-932a-4f6e2808ef9c","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  2 Jun 2022 00:18:02 +0100","Message-Id":"<20220601231802.16735-5-Rauch.Christian@gmx.de>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220601231802.16735-1-Rauch.Christian@gmx.de>","References":"<20220601231802.16735-1-Rauch.Christian@gmx.de>","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","X-Provags-ID":"V03:K1:N1Bb9Bu9/QY0qxxGTU1wEItAuEyXaXXjC/GoD2ndqH2P1SnwGfv\n\tyQ37TX5hwniioGsi5Q+/QBXXbftxCDwqSgcz9ZdZqwwrHbJEB9ai1TLX4TR97GHcWZ7qij9\n\t6YU/uweV0hoRxyE/rh1aEoWqCf5NR5tufqKA756nZ5g/UBAjIrjARyHM+sgrbtWj1RLQzKt\n\tXiP6FzFMt0CsIwKKSLo1w==","X-Spam-Flag":"NO","X-UI-Out-Filterresults":"notjunk:1; V03:K0:lAB8M/NbZT4=:bx7IRQFPq7M66p7BCaX09X\n\tXyGZIlvcsl47F7xUDA6be8HN2Igvt9ts98hsu9QV/05vapaL65fCRxn11yv8woTDq+tN4VzPi\n\t84m7CTnl19HUTtq0ipq159fELhuQ363n1gsJ/fkT3QhyT+SUQe0qNzSFncexvDHSlX5O9pbDX\n\tMIGpysLXGmFYURDhxss1/kvlPSgf22tYyq6ngic1U3ZE5J/YqcxkWKxhN3UEsyU9y3fuYudSH\n\tFJ5ZHk7eAdAHw3vfTKCCGvyJQb7rjH1Xt7SR3l/0t5ByJkecnY0U2qHCuqiCmXAogpnQt4YPz\n\tajDSUiF19+belsTfBWOhyb0quTSJZmJEv/s/TyOuIksBXGNCF2MbAWcfxj8AE260sG7GVGD+5\n\tG2/c6Ytqe5VVgZDmEpI0mPGTnN5um+93DaoI66yAH5CZ6knZOcE/EujkwFU9cce1Z9YbE5okB\n\tkq+A+vHkEdNeJbfrFy8fQ0wqorDgATtmtJV1C7EdQFrEA5eL+ATRMEfUgWMN7gs2LsdWQaWqd\n\tA208Zon4sdx4RITF0eufXlPKRGrvenr0Gr5mjNW2L2/QMXo/sApKpsMtyYVsPK75MBOLenWRu\n\t2U3zQqufA4oKaQcoHgHRegAHUYA2iG6tdpWZJUaWgyneBLdwdASGmU3hrIgoxqBTTveaIGozQ\n\tdeTFulxflTB6ye1FRjyioNPimjADRT0e5j3tijA12Ihkg+oHIimGhSCxdnb4uzNf3qyOk+Z3G\n\tAmj9wmGechN6+Pb1BCY2T1qgYmO6XALw/VlLxji4/4BtPf6zw5eC9YcsO+25V5tJ2nDcCwM3v\n\tU3V3QaiBVrlUf+BWRSJE6tMW1UXNtuK3X1/Xmz+4CtGruX0W8E6DYwmAR7uXgZUnlFGe7mMt+\n\tKIt5swBXTX7YcYn07OVKRRP9BuSRXQd+2d1evj7clg/Xw1ffxP/r70bdw47eI+wny+i/2js9o\n\tXwrEnWNzVNDOcalNvifmWjYXGnMB/rbiAzl+jCtqZOMdE21x5MqAHOa1tMTs9Gmlv8JKwCCFv\n\t953yEAe8lci1JFiExoOojve5qXnbZpeO39FHzliR56a2aUNJ5QQwkc1oLm25qtZmj18KfT+lo\n\tBRIiG2O18eqyXHO63TAFn9WuS/77/Xc3OSxd70tOtDPvroZaK9kk0jjBA==","Subject":"[libcamera-devel] [PATCH v5 4/4] libcamera: controls: Apply\n\texplicit fixed-sized Span type casts","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Christian Rauch via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Christian Rauch <Rauch.Christian@gmx.de>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The change of types of some Controls from variable- to fixed-sized requires\nexplicit casting of FrameDurationLimits, ColourGains and SensorBlackLevels.\n\nSigned-off-by: Christian Rauch <Rauch.Christian@gmx.de>\n---\n src/ipa/raspberrypi/raspberrypi.cpp           | 19 ++++++++++---------\n .../pipeline/raspberrypi/raspberrypi.cpp      |  4 ++--\n src/qcam/dng_writer.cpp                       | 12 ++++++------\n 3 files changed, 18 insertions(+), 17 deletions(-)\n\n--\n2.34.1","diff":"diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 00600a2e..54a16ac2 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -505,18 +505,19 @@ void IPARPi::reportMetadata()\n\n \tAwbStatus *awbStatus = rpiMetadata_.GetLocked<AwbStatus>(\"awb.status\");\n \tif (awbStatus) {\n-\t\tlibcameraMetadata_.set(controls::ColourGains, { static_cast<float>(awbStatus->gain_r),\n-\t\t\t\t\t\t\t\tstatic_cast<float>(awbStatus->gain_b) });\n+\t\tlibcameraMetadata_.set(controls::ColourGains,\n+\t\t\t\t       Span<const float, 2>({ static_cast<float>(awbStatus->gain_r),\n+\t\t\t\t\t\t\t      static_cast<float>(awbStatus->gain_b) }));\n \t\tlibcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperature_K);\n \t}\n\n \tBlackLevelStatus *blackLevelStatus = rpiMetadata_.GetLocked<BlackLevelStatus>(\"black_level.status\");\n \tif (blackLevelStatus)\n \t\tlibcameraMetadata_.set(controls::SensorBlackLevels,\n-\t\t\t\t       { static_cast<int32_t>(blackLevelStatus->black_level_r),\n-\t\t\t\t\t static_cast<int32_t>(blackLevelStatus->black_level_g),\n-\t\t\t\t\t static_cast<int32_t>(blackLevelStatus->black_level_g),\n-\t\t\t\t\t static_cast<int32_t>(blackLevelStatus->black_level_b) });\n+\t\t\t\t       Span<const int32_t, 4>({ static_cast<int32_t>(blackLevelStatus->black_level_r),\n+\t\t\t\t\t\t\t\tstatic_cast<int32_t>(blackLevelStatus->black_level_g),\n+\t\t\t\t\t\t\t\tstatic_cast<int32_t>(blackLevelStatus->black_level_g),\n+\t\t\t\t\t\t\t\tstatic_cast<int32_t>(blackLevelStatus->black_level_b) }));\n\n \tFocusStatus *focusStatus = rpiMetadata_.GetLocked<FocusStatus>(\"focus.status\");\n \tif (focusStatus && focusStatus->num == 12) {\n@@ -821,7 +822,7 @@ void IPARPi::queueRequest(const ControlList &controls)\n \t\t\tif (gains[0] != 0.0f && gains[1] != 0.0f)\n \t\t\t\t/* A gain of 0.0f will switch back to auto mode. */\n \t\t\t\tlibcameraMetadata_.set(controls::ColourGains,\n-\t\t\t\t\t\t       { gains[0], gains[1] });\n+\t\t\t\t\t\t       Span<const float, 2>({ gains[0], gains[1] }));\n \t\t\tbreak;\n \t\t}\n\n@@ -1105,8 +1106,8 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur\n\n \t/* Return the validated limits via metadata. */\n \tlibcameraMetadata_.set(controls::FrameDurationLimits,\n-\t\t\t       { static_cast<int64_t>(minFrameDuration_.get<std::micro>()),\n-\t\t\t\t static_cast<int64_t>(maxFrameDuration_.get<std::micro>()) });\n+\t\t\t       Span<const int64_t, 2>({ static_cast<int64_t>(minFrameDuration_.get<std::micro>()),\n+\t\t\t\t\t\t\tstatic_cast<int64_t>(maxFrameDuration_.get<std::micro>()) }));\n\n \t/*\n \t * Calculate the maximum exposure time possible for the AGC to use.\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 556af882..af7c8927 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1706,9 +1706,9 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList &\n \t * V4L2_CID_NOTIFY_GAINS control (which means notifyGainsUnity_ is set).\n \t */\n \tif (notifyGainsUnity_ && controls.contains(libcamera::controls::ColourGains)) {\n-\t\tlibcamera::Span<const float> colourGains =\n+\t\tlibcamera::Span<const float, 2> colourGains =\n \t\t\tcontrols.get(libcamera::controls::ColourGains).\\\n-\t\t\t\tvalue_or(libcamera::Span<const float>({ 0, 0 }));\n+\t\t\t\tvalue_or(libcamera::Span<const float, 2>({ 0, 0 }));\n \t\t/* The control wants linear gains in the order B, Gb, Gr, R. */\n \t\tControlList ctrls(sensor_->controls());\n \t\tstd::array<int32_t, 4> gains{\ndiff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp\nindex e119ca52..030432e3 100644\n--- a/src/qcam/dng_writer.cpp\n+++ b/src/qcam/dng_writer.cpp\n@@ -438,8 +438,8 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n \tconst double eps = 1e-2;\n\n \tif (metadata.contains(controls::ColourGains)) {\n-\t\tSpan<const float> const &colourGains =\n-\t\t\tmetadata.get(controls::ColourGains).value_or(libcamera::Span<const float>({ 0, 0 }));\n+\t\tSpan<const float, 2> const &colourGains =\n+\t\t\tmetadata.get(controls::ColourGains).value_or(libcamera::Span<const float, 2>({ 0, 0 }));\n \t\tif (colourGains[0] > eps && colourGains[1] > eps) {\n \t\t\twbGain = Matrix3d::diag(colourGains[0], 1, colourGains[1]);\n \t\t\tneutral[0] = 1.0 / colourGains[0]; /* red */\n@@ -447,8 +447,8 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n \t\t}\n \t}\n \tif (metadata.contains(controls::ColourCorrectionMatrix)) {\n-\t\tSpan<const float> const &coeffs =\n-\t\t\tmetadata.get(controls::ColourCorrectionMatrix).value_or(Span<const float>({ 0, 0, 0, 0, 0, 0, 0, 0, 0 }));\n+\t\tSpan<const float, 9> const &coeffs =\n+\t\t\tmetadata.get(controls::ColourCorrectionMatrix).value_or(Span<const float, 9>({ 0, 0, 0, 0, 0, 0, 0, 0, 0 }));\n \t\tMatrix3d ccmSupplied(coeffs);\n \t\tif (ccmSupplied.determinant() > eps)\n \t\t\tccm = ccmSupplied;\n@@ -517,8 +517,8 @@ int DNGWriter::write(const char *filename, const Camera *camera,\n \tuint32_t whiteLevel = (1 << info->bitsPerSample) - 1;\n\n \tif (metadata.contains(controls::SensorBlackLevels)) {\n-\t\tSpan<const int32_t> levels =\n-\t\t\tmetadata.get(controls::SensorBlackLevels).value_or(Span<const int32_t>({ 0, 0, 0, 0 }));\n+\t\tSpan<const int32_t, 4> levels =\n+\t\t\tmetadata.get(controls::SensorBlackLevels).value_or(Span<const int32_t, 4>({ 0, 0, 0, 0 }));\n\n \t\t/*\n \t\t * The black levels control is specified in R, Gr, Gb, B order.\n","prefixes":["libcamera-devel","v5","4/4"]}