{"id":16175,"url":"https://patchwork.libcamera.org/api/patches/16175/?format=json","web_url":"https://patchwork.libcamera.org/patch/16175/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/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":"<20220604211148.188421-6-Rauch.Christian@gmx.de>","date":"2022-06-04T21:11:48","name":"[libcamera-devel,v7,5/5] libcamera: controls: Apply explicit fixed-sized Span type casts","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a358875a43334b6d79c547a4343fd8a7c26da02c","submitter":{"id":111,"url":"https://patchwork.libcamera.org/api/people/111/?format=json","name":"Christian Rauch","email":"Rauch.Christian@gmx.de"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16175/mbox/","series":[{"id":3162,"url":"https://patchwork.libcamera.org/api/series/3162/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3162","date":"2022-06-04T21:11:43","name":"generate and use fixed-sized Span Control types","version":7,"mbox":"https://patchwork.libcamera.org/series/3162/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16175/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16175/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 8C44AC3276\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  4 Jun 2022 21:11:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DA39465646;\n\tSat,  4 Jun 2022 23:11:56 +0200 (CEST)","from mout.gmx.net (mout.gmx.net [212.227.15.19])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DD77D65633\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Jun 2022 23:11:52 +0200 (CEST)","from localhost.localdomain ([92.18.80.244]) by mail.gmx.net\n\t(mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id\n\t1MKbkM-1oE1Tw28Pk-00KvCJ; Sat, 04 Jun 2022 23:11:52 +0200"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654377116;\n\tbh=57RCMCH2ddS8uCZM3E90CIxLhQ7NCr8PSdJyCaYE2pE=;\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=gpasxA6GlGj6KWsCcrQ1QNfE1mnRlAUBbQsL24fhxjLrVLphT4HaipZd5ymZq9AFK\n\tr8Ti05af7ZLviXQli1rESKESHZxXctDthKc0pNUq6i0lCvATsy6kTBiPRGrp3uDpC4\n\tcT479Lxd+Jkd8e/0uPE53g4tYjDZ6YhP3OcaC58GBV8vRMy8sE6xRA1/KaGoR+KerC\n\tR7uBnljqnSNigZBDktgGyJ2FybHoPRbK6mdCYppUkgfNYb3JO07kv6LknkgMogNnIR\n\tIjDcoDk/7tUKe0uBpzYs5RXTonQCvPY1Ufm+YKpgtPEI5kKW3Mv2hEqJ/VJvfH5hst\n\tqm254nL9kiMQQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net;\n\ts=badeba3b8450; t=1654377112;\n\tbh=57RCMCH2ddS8uCZM3E90CIxLhQ7NCr8PSdJyCaYE2pE=;\n\th=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References;\n\tb=Vgvac8qbJynp3b9lo+V8AVUHYsD8EERXhOGd9osjMrfFwjdVsfzSHPtID5V981F4m\n\tHfgCGZTHiVg73D9UFAKH6FJkl5FMoq8ntY9maGGLc2CDQxcOTDq6vuoJqBD3Dj/mGU\n\tBHmX8JKLCQGnqYqlGBk9yb75Szu+aZU/0wBxESas="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=gmx.net header.i=@gmx.net\n\theader.b=\"Vgvac8qb\"; dkim-atps=neutral","X-UI-Sender-Class":"01bb95c1-4bf8-414a-932a-4f6e2808ef9c","To":"libcamera-devel@lists.libcamera.org","Date":"Sat,  4 Jun 2022 22:11:48 +0100","Message-Id":"<20220604211148.188421-6-Rauch.Christian@gmx.de>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20220604211148.188421-1-Rauch.Christian@gmx.de>","References":"<20220604211148.188421-1-Rauch.Christian@gmx.de>","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","X-Provags-ID":"V03:K1:mMcMWQsLWY5nZPbxwaVyw/Qzq162bIt00gDssAH8WRZd3ctWuy2\n\tuhEcVnPd5f8NTDiTiAtMtlz4asmHTDcyhu4X7Yezt2GKCoMhpz/IQPIlQJqi1aYMRSlPeGS\n\tD6XM6EwLjdqq+1tSA3waXxlu0+/VzMASXHIRSkfwQkKcT84NCTgmNqb8VfLnpiHnTjqW9v5\n\t1nho26pETxTQIFwkzJFnQ==","X-Spam-Flag":"NO","X-UI-Out-Filterresults":"notjunk:1; V03:K0:pG9P/BEcBIY=:h5q67KvBbz/Md9SKWVKGzj\n\turQ1imd1o9nNeAlS/AqEON4EHCTxP4SXEtyP37uLIwwcCGos/wWJWSpLqXSQANlLWwx0PZ+7/\n\tDZwppGgG7Ydu+POaDsbcHifNnXQIOZb/TBiW6Jgx3skSnqTkXOXnnXRL4mRpJ/ginnE39dIpf\n\tcpcd2a7lNvoGCoBhUXGuxPJNiE0VfuVJevswxI21F1ScpWgtY5gWEOuKqNQDzlKrzPnF3fxZH\n\t2HUHxgv42TPVp3cGQB/D2HtSa7IVVWD2JqBMPW52OUdZpBRLr9rmg3MGToKnOA/0nFnf11MnY\n\tvJ06ek1YbwAGyZH5frGCgKso1tpb8WJstRgpeyBTmBCUsByrxXrbt7bpkXtt6vMCMYSFMc7Ep\n\tCDQaN+DtppFUX2xoGZrMqpwSLeD+LOa5/wSorv9G8TEXIsbVL8of24yRzZuP6v3mIOrd3YbM6\n\tqmQ8hAnxuLWls1NcEuX0ln5bkl5lgk1xkaJiO8ZHsjPtVDK72hJNxG6ex8c7/v9GlklNhqdg2\n\t9ikr9sZbvMjtWRpin0wfGdHdwRDWXBl/FZ8qhnFVnlmjHXXaFRw19+ygIqr3x0wD3VR4vQY2i\n\t7bT6GkkxXwjjvtuBsPKaOZeO8g5MmzzSUm5v+AQg8CZFQtzRtcuT4w+7a4d0I86Mah9bv4mdS\n\tEASEHA0367m1eEHZfv90YaFARs+TxHxeywuWfD3nceaX1BJl7+RINUw2cXexpc1ywfOilfQNU\n\tNwLqEc8DEzGGCAkfy52JFt6D1x+5AprPk6KnWVBpGNR5iB3DiF4MWrpGGkwBY07TUR4Vt11bI\n\tCSYKB9enL83PGC1Ggvj++zo9aVTFW+CdByzsVjjlTGeINXrk6NmEci9Tpv6RmSsJ2F+U4p1My\n\tJqP0+SKjNqdW+pXUpI0aCkAReeuVkR4db+7eiQ/6M0fcR2XLOWaTlvnt0vKL8dtadNnFBP0qc\n\tA36IvqNjMl90w1W9BkwurgVPLp8pM8eLQBUj1/P6rEvSTlYCgA4k+7Cw18ahrQ/RA7XxdXE7N\n\tQ1PpQppx02lEgZO9euwbmES18zZTT9fYW7A9D6DcyHTAGsSSoXD9iseHq4Lva1d7dDbD70pzJ\n\tHEFLPD7B2pDtsqjZDleLZP3VdsoFSG4MXZuUTMPIzqhwVLmEKIVdFLtrg==","Subject":"[libcamera-devel] [PATCH v7 5/5] 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 include/libcamera/controls.h                  |  2 +-\n src/ipa/raspberrypi/raspberrypi.cpp           | 19 ++++++++++---------\n .../pipeline/raspberrypi/raspberrypi.cpp      |  2 +-\n src/qcam/dng_writer.cpp                       |  2 +-\n 4 files changed, 13 insertions(+), 12 deletions(-)\n\n--\n2.34.1","diff":"diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 192be784..a19f1845 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -168,7 +168,7 @@ public:\n\n \t\tusing V = typename T::value_type;\n \t\tconst V *value = reinterpret_cast<const V *>(data().data());\n-\t\treturn { value, numElements_ };\n+\t\treturn T{ value, numElements_ };\n \t}\n\n #ifndef __DOXYGEN__\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex f65a0680..203ae613 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>({ blackLevelStatus->black_level_r,\n+\t\t\t\t\t\t\t\tblackLevelStatus->black_level_g,\n+\t\t\t\t\t\t\t\tblackLevelStatus->black_level_g,\n+\t\t\t\t\t\t\t\tblackLevelStatus->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 a62afdd4..6efe7c3c 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1706,7 +1706,7 @@ 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\t*controls.get(libcamera::controls::ColourGains);\n \t\t/* The control wants linear gains in the order B, Gb, Gr, R. */\n \t\tControlList ctrls(sensor_->controls());\ndiff --git a/src/qcam/dng_writer.cpp b/src/qcam/dng_writer.cpp\nindex 4b5d8276..23612be0 100644\n--- a/src/qcam/dng_writer.cpp\n+++ b/src/qcam/dng_writer.cpp\n@@ -514,7 +514,7 @@ 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\tSpan<const int32_t, 4> levels =\n \t\t\t*metadata.get(controls::SensorBlackLevels);\n\n \t\t/*\n","prefixes":["libcamera-devel","v7","5/5"]}