[{"id":30390,"web_url":"https://patchwork.libcamera.org/comment/30390/","msgid":"<15dea924-1575-4787-8a1a-58ab7cc08698@ideasonboard.com>","date":"2024-07-12T15:13:15","subject":"Re: [PATCH v1 1/5] ipa: rkisp1: awb: Clamp gains to machine limits","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Stefan, thanks for the set\n\nOn 12/07/2024 15:32, Stefan Klug wrote:\n> When the color gains where set manually it was possible to specify a\n> gain that wrapped the hardware limits. It would also be possible to\n> further tune the floating point limits, but that is an error prone\n> approach. So the limits are imposed on the integers, just before writing\n> to the hardware. This noticeably reduces some oscillations in the awb\n> regulation.\n>\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n\nThe code change is fine:\n\nReviewed-by: Daniel Scally <dan.scally@ideasonboard.com>\n\n\nBut how's it possible that you get values larger than 1023 here? The control value is declared with \na range of 0 to 3.996; is it that the limits aren't checked when controls are set, or is there some \nfloating point magic going on?\n\n>   src/ipa/rkisp1/algorithms/awb.cpp | 12 ++++++++----\n>   1 file changed, 8 insertions(+), 4 deletions(-)\n>\n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index a01fe5d90973..1a5d4776970a 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -120,10 +120,14 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n>   \t\tframeContext.awb.gains.blue = context.activeState.awb.gains.automatic.blue;\n>   \t}\n>   \n> -\tparams->others.awb_gain_config.gain_green_b = 256 * frameContext.awb.gains.green;\n> -\tparams->others.awb_gain_config.gain_blue = 256 * frameContext.awb.gains.blue;\n> -\tparams->others.awb_gain_config.gain_red = 256 * frameContext.awb.gains.red;\n> -\tparams->others.awb_gain_config.gain_green_r = 256 * frameContext.awb.gains.green;\n> +\tparams->others.awb_gain_config.gain_green_b =\n> +\t\tstd::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);\n> +\tparams->others.awb_gain_config.gain_blue =\n> +\t\tstd::clamp<int>(256 * frameContext.awb.gains.blue, 0, 0x3ff);\n> +\tparams->others.awb_gain_config.gain_red =\n> +\t\tstd::clamp<int>(256 * frameContext.awb.gains.red, 0, 0x3ff);\n> +\tparams->others.awb_gain_config.gain_green_r =\n> +\t\tstd::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);\n>   \n>   \t/* Update the gains. */\n>   \tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;","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 5959CBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 12 Jul 2024 15:13:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0950D6336D;\n\tFri, 12 Jul 2024 17:13:21 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D29B463369\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Jul 2024 17:13:18 +0200 (CEST)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 350EA735\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Jul 2024 17:12:44 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"s0Uh6OOA\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1720797164;\n\tbh=7B2n8yb/K57FUW/LhHSu7et6iRVccFSVk2ow3QKVlFM=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=s0Uh6OOA/I+mMSjsey/1JIBabLaRxtCf/7eJEN8H9+94EOy2g9Prz1BR7rHkayZPk\n\tE9X9+8B7ROjsHdJ39qEUKRffAf4xXp1AJOvHDl8DXxBItHizNc+CZ0d6JJ7XJ6hyH2\n\tKkzAYKZyPaPpRwybk6TlOtLFkMW//OVixy88cHi8=","Message-ID":"<15dea924-1575-4787-8a1a-58ab7cc08698@ideasonboard.com>","Date":"Fri, 12 Jul 2024 16:13:15 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v1 1/5] ipa: rkisp1: awb: Clamp gains to machine limits","To":"libcamera-devel@lists.libcamera.org","References":"<20240712143227.3036702-1-stefan.klug@ideasonboard.com>\n\t<20240712143227.3036702-2-stefan.klug@ideasonboard.com>","Content-Language":"en-US","From":"Dan Scally <dan.scally@ideasonboard.com>","Autocrypt":"addr=dan.scally@ideasonboard.com; keydata=\n\txsFNBGLydlEBEADa5O2s0AbUguprfvXOQun/0a8y2Vk6BqkQALgeD6KnXSWwaoCULp18etYW\n\tB31bfgrdphXQ5kUQibB0ADK8DERB4wrzrUb5CMxLBFE7mQty+v5NsP0OFNK9XTaAOcmD+Ove\n\teIjYvqurAaro91jrRVrS1gBRxIFqyPgNvwwL+alMZhn3/2jU2uvBmuRrgnc/e9cHKiuT3Dtq\n\tMHGPKL2m+plk+7tjMoQFfexoQ1JKugHAjxAhJfrkXh6uS6rc01bYCyo7ybzg53m1HLFJdNGX\n\tsUKR+dQpBs3SY4s66tc1sREJqdYyTsSZf80HjIeJjU/hRunRo4NjRIJwhvnK1GyjOvvuCKV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LNrPoxKyaytC4R6BTxVriTJjWK8mbo9jZIRM4vkwkZZ2bu98EweSucxbp\n\tvjESsvMXGgxniqV/RQ/3T7LABYRoIUutARYq58p5HwSP0frF0fdFHYdTa2g7MYZl1ur2JzOC\n\tFHRpGadlNzKDE3fEdoMobxHB3Lm6FDml5GyBAA8+dQYVI0oDwJ3gpZPZ0J5Vx9RbqXe8RDuR\n\tdu90hvCJkq7/tzSQ0GeD3BwXb9/R/A4dVXhaDd91Q1qQXidI+2jwhx8iqiYxbT+DoAUkQRQy\n\txBtoCM1CxH7u45URUgD//fxYr3D4B1SlonA6vdaEdHZOGwECnDpTxecENMbz/Bx7qfrmd901\n\tD+N9SjIwrbVhhSyUXYnSUb8F+9g2RDY42Sk7GcYxIeON4VzKqWM7hpkXZ47pkK0YodO+dRKM\n\tyMcoUWrTK0Uz6UzUGKoJVbxmSW/EJLEGoI5p3NWxWtScEVv8mO49gqQdrRIOheZycDmHnItt\n\t9Qjv00uFhEwv2YfiyGk6iGF2W40s2pH2t6oeuGgmiZ7g6d0MEK8Ql/4zPItvr1c1rpwpXUC1\n\tu1kQWgtnNjFHX3KiYdqjcZeRBiry1X0zY+4Y24wUU0KsEewJwjhmCKAsju1RpdlPg2kC","In-Reply-To":"<20240712143227.3036702-2-stefan.klug@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30405,"web_url":"https://patchwork.libcamera.org/comment/30405/","msgid":"<172100025713.4121597.13086467583081373749@ping.linuxembedded.co.uk>","date":"2024-07-14T23:37:37","subject":"Re: [PATCH v1 1/5] ipa: rkisp1: awb: Clamp gains to machine limits","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Stefan Klug (2024-07-12 15:32:02)\n> When the color gains where set manually it was possible to specify a\n> gain that wrapped the hardware limits. It would also be possible to\n> further tune the floating point limits, but that is an error prone\n> approach. So the limits are imposed on the integers, just before writing\n> to the hardware. This noticeably reduces some oscillations in the awb\n> regulation.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 12 ++++++++----\n>  1 file changed, 8 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index a01fe5d90973..1a5d4776970a 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -120,10 +120,14 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n>                 frameContext.awb.gains.blue = context.activeState.awb.gains.automatic.blue;\n>         }\n>  \n> -       params->others.awb_gain_config.gain_green_b = 256 * frameContext.awb.gains.green;\n> -       params->others.awb_gain_config.gain_blue = 256 * frameContext.awb.gains.blue;\n> -       params->others.awb_gain_config.gain_red = 256 * frameContext.awb.gains.red;\n> -       params->others.awb_gain_config.gain_green_r = 256 * frameContext.awb.gains.green;\n> +       params->others.awb_gain_config.gain_green_b =\n\nAre these parameters clamped/verified by the kernel ? Is that where the\noscillations come from (if the kernel applies different values than we\ntrack/believe/expect?)\n\nShould we be clamping frameContext.awb.gains.green so we track what\nvalue actually is applied in the frame context?\n\n> +               std::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);\n> +       params->others.awb_gain_config.gain_blue =\n> +               std::clamp<int>(256 * frameContext.awb.gains.blue, 0, 0x3ff);\n> +       params->others.awb_gain_config.gain_red =\n> +               std::clamp<int>(256 * frameContext.awb.gains.red, 0, 0x3ff);\n> +       params->others.awb_gain_config.gain_green_r =\n> +               std::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);\n>  \n\nThough - I don't object to ensuring we clamp before setting in the param\nbuffer - but it scares me thinking there are a lot more values we need\nto perhaps validate before storing in the parameter buffers?\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n>         /* Update the gains. */\n>         params->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;\n> -- \n> 2.43.0\n>","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 EB43CBD87C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSun, 14 Jul 2024 23:37:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C68F36336F;\n\tMon, 15 Jul 2024 01:37:42 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D746A63364\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 15 Jul 2024 01:37:40 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6940D496;\n\tMon, 15 Jul 2024 01:37:04 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"i6PnZ+U9\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1721000224;\n\tbh=+r3X6ddsZCvNsobSHFNYKjWfqTFmzNB7DeQgR0hf6KA=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=i6PnZ+U93kxuzC4rLMeyNvqVPx2h3Za9LphjZ5Mk/cCnkXvaRFyYqZDlJ4BuU4XZj\n\ttayPu+6RzNACf9zE4FSpBhlWQcIuZqbAmdBJ+tBFXD0BXfekJFjSQbZZCnHl/GK7el\n\twh/tuW4ZWA0znpJmfO7dsHUJVLs4AJA26XUqdqOM=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240712143227.3036702-2-stefan.klug@ideasonboard.com>","References":"<20240712143227.3036702-1-stefan.klug@ideasonboard.com>\n\t<20240712143227.3036702-2-stefan.klug@ideasonboard.com>","Subject":"Re: [PATCH v1 1/5] ipa: rkisp1: awb: Clamp gains to machine limits","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Mon, 15 Jul 2024 00:37:37 +0100","Message-ID":"<172100025713.4121597.13086467583081373749@ping.linuxembedded.co.uk>","User-Agent":"alot/0.10","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":30433,"web_url":"https://patchwork.libcamera.org/comment/30433/","msgid":"<ZpoSsuRWwREu-R8A@pyrite.rasen.tech>","date":"2024-07-19T07:16:02","subject":"Re: [PATCH v1 1/5] ipa: rkisp1: awb: Clamp gains to machine limits","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"On Fri, Jul 12, 2024 at 04:32:02PM +0200, Stefan Klug wrote:\n> When the color gains where set manually it was possible to specify a\n\ns/where/are/\n\n> gain that wrapped the hardware limits. It would also be possible to\n> further tune the floating point limits, but that is an error prone\n> approach. So the limits are imposed on the integers, just before writing\n> to the hardware. This noticeably reduces some oscillations in the awb\n> regulation.\n> \n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n\ntbh these should be protected against once in the kernel and against in\nthe ControlInfo but until those are fixed we need this.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/ipa/rkisp1/algorithms/awb.cpp | 12 ++++++++----\n>  1 file changed, 8 insertions(+), 4 deletions(-)\n> \n> diff --git a/src/ipa/rkisp1/algorithms/awb.cpp b/src/ipa/rkisp1/algorithms/awb.cpp\n> index a01fe5d90973..1a5d4776970a 100644\n> --- a/src/ipa/rkisp1/algorithms/awb.cpp\n> +++ b/src/ipa/rkisp1/algorithms/awb.cpp\n> @@ -120,10 +120,14 @@ void Awb::prepare(IPAContext &context, const uint32_t frame,\n>  \t\tframeContext.awb.gains.blue = context.activeState.awb.gains.automatic.blue;\n>  \t}\n>  \n> -\tparams->others.awb_gain_config.gain_green_b = 256 * frameContext.awb.gains.green;\n> -\tparams->others.awb_gain_config.gain_blue = 256 * frameContext.awb.gains.blue;\n> -\tparams->others.awb_gain_config.gain_red = 256 * frameContext.awb.gains.red;\n> -\tparams->others.awb_gain_config.gain_green_r = 256 * frameContext.awb.gains.green;\n> +\tparams->others.awb_gain_config.gain_green_b =\n> +\t\tstd::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);\n> +\tparams->others.awb_gain_config.gain_blue =\n> +\t\tstd::clamp<int>(256 * frameContext.awb.gains.blue, 0, 0x3ff);\n> +\tparams->others.awb_gain_config.gain_red =\n> +\t\tstd::clamp<int>(256 * frameContext.awb.gains.red, 0, 0x3ff);\n> +\tparams->others.awb_gain_config.gain_green_r =\n> +\t\tstd::clamp<int>(256 * frameContext.awb.gains.green, 0, 0x3ff);\n>  \n>  \t/* Update the gains. */\n>  \tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_AWB_GAIN;\n> -- \n> 2.43.0\n>","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 D0601BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 19 Jul 2024 07:16:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C206863372;\n\tFri, 19 Jul 2024 09:16:10 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C74CC619A3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Jul 2024 09:16:08 +0200 (CEST)","from pyrite.rasen.tech (h175-177-049-024.catv02.itscom.jp\n\t[175.177.49.24])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9391D471;\n\tFri, 19 Jul 2024 09:15:28 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Im0zfLhu\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1721373329;\n\tbh=OW3UHBD1rYtFPqhgtjQOzjqDK598thhXdsoNgs8qEe0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Im0zfLhu0yxxrGD4QONwVJAc+3GvJOh2A/ACcEN7qTv0StcgYxJMHxRk2itRIgfSa\n\tVX3W5wmZlBekvtNTSr/ZI4rrkPiwN1U7YZGrOFia/qBiOfJGcpU9Cn1THpeN7j57O4\n\toKJ8MV+npEYaJgh12DrIfqyU/5xJkhk9/pkWxAmU=","Date":"Fri, 19 Jul 2024 16:16:02 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v1 1/5] ipa: rkisp1: awb: Clamp gains to machine limits","Message-ID":"<ZpoSsuRWwREu-R8A@pyrite.rasen.tech>","References":"<20240712143227.3036702-1-stefan.klug@ideasonboard.com>\n\t<20240712143227.3036702-2-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20240712143227.3036702-2-stefan.klug@ideasonboard.com>","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]