[{"id":30657,"web_url":"https://patchwork.libcamera.org/comment/30657/","msgid":"<172302479516.1687952.14127695837729893701@ping.linuxembedded.co.uk>","date":"2024-08-07T09:59:55","subject":"Re: [PATCH v1 2/2] ipa: rpi: Adding IMX283 support","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Naushir Patuck (2024-08-07 10:34:49)\n> From: will whang <will@willwhang.com>\n> \n> Add support for the IMX283 sensor for the VC4 target.\n> \n> Signed-off-by: will whang <will@willwhang.com>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  src/ipa/rpi/cam_helper/cam_helper_imx283.cpp |  73 +++++\n>  src/ipa/rpi/cam_helper/meson.build           |   1 +\n>  src/ipa/rpi/vc4/data/imx283.json             | 313 +++++++++++++++++++\n>  src/ipa/rpi/vc4/data/meson.build             |   1 +\n>  4 files changed, 388 insertions(+)\n>  create mode 100644 src/ipa/rpi/cam_helper/cam_helper_imx283.cpp\n>  create mode 100644 src/ipa/rpi/vc4/data/imx283.json\n> \n> diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx283.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx283.cpp\n> new file mode 100644\n> index 000000000000..1fd4d7f31b04\n> --- /dev/null\n> +++ b/src/ipa/rpi/cam_helper/cam_helper_imx283.cpp\n> @@ -0,0 +1,73 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Copyright (C) 2024, Raspberry Pi Ltd\n> + *\n> + * cam_helper_Imx283.cpp - camera information for Imx283 sensor\n> + */\n> +\n> +#include <assert.h>\n> +\n> +#include \"cam_helper.h\"\n> +#include \"math.h\"\n> +using namespace RPiController;\n> +\n> +class CamHelperImx283 : public CamHelper\n> +{\n> +public:\n> +       CamHelperImx283();\n> +       uint32_t gainCode(double gain) const override;\n> +       double gain(uint32_t gainCode) const override;\n> +       void getDelays(int &exposureDelay, int &gainDelay,\n> +                      int &vblankDelay, int &hblankDelay) const override;\n> +       unsigned int hideFramesModeSwitch() const override;\n> +\n> +private:\n> +       /*\n> +        * Smallest difference between the frame length and integration time,\n> +        * in units of lines.\n> +        */\n> +       static constexpr int frameIntegrationDiff = 4;\n> +};\n> +\n> +/*\n> + * Imx283 doesn't output metadata, so we have to use the delayed controls which\n> + * works by counting frames.\n> + */\n> +\n> +CamHelperImx283::CamHelperImx283()\n> +       : CamHelper({}, frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx283::gainCode(double gain) const\n> +{\n> +       return static_cast<uint32_t>(2048.0 - 2048.0 / gain);\n> +}\n> +\n> +double CamHelperImx283::gain(uint32_t gainCode) const\n> +{\n> +       return static_cast<double>(2048.0 / (2048 - gainCode));\n> +}\n> +\n> +void CamHelperImx283::getDelays(int &exposureDelay, int &gainDelay,\n> +                               int &vblankDelay, int &hblankDelay) const\n> +{\n> +       /* The driver appears to behave as follows: */\n> +       exposureDelay = 2;\n> +       gainDelay = 2;\n> +       vblankDelay = 2;\n> +       hblankDelay = 2;\n> +}\n> +\n> +unsigned int CamHelperImx283::hideFramesModeSwitch() const\n> +{\n> +       /* After a mode switch, we seem to get 1 bad frame. */\n> +       return 1;\n> +}\n> +\n> +static CamHelper *create()\n> +{\n> +       return new CamHelperImx283();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx283\", &create);\n> diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build\n> index 7262505742f3..1e43f1da29cd 100644\n> --- a/src/ipa/rpi/cam_helper/meson.build\n> +++ b/src/ipa/rpi/cam_helper/meson.build\n> @@ -4,6 +4,7 @@ rpi_ipa_cam_helper_sources = files([\n>      'cam_helper.cpp',\n>      'cam_helper_ov5647.cpp',\n>      'cam_helper_imx219.cpp',\n> +    'cam_helper_imx283.cpp',\n>      'cam_helper_imx290.cpp',\n>      'cam_helper_imx296.cpp',\n>      'cam_helper_imx477.cpp',\n> diff --git a/src/ipa/rpi/vc4/data/imx283.json b/src/ipa/rpi/vc4/data/imx283.json\n> new file mode 100644\n> index 000000000000..bfacecc8e3c2\n> --- /dev/null\n> +++ b/src/ipa/rpi/vc4/data/imx283.json\n> @@ -0,0 +1,313 @@\n> +{\n> +    \"version\": 2.0,\n> +    \"target\": \"bcm2835\",\n> +    \"algorithms\": [\n> +        {\n> +            \"rpi.black_level\":\n> +            {\n> +                \"black_level\": 3200\n> +            }\n> +        },\n> +        {\n> +            \"rpi.dpc\": { }\n> +        },\n> +        {\n> +            \"rpi.lux\":\n> +            {\n> +                \"reference_shutter_speed\": 2461,\n> +                \"reference_gain\": 1.0,\n> +                \"reference_aperture\": 1.0,\n> +                \"reference_lux\": 1148,\n> +                \"reference_Y\": 13314\n> +            }\n> +        },\n> +        {\n> +            \"rpi.noise\":\n> +            {\n> +                \"reference_constant\": 0,\n> +                \"reference_slope\": 2.204\n> +            }\n> +        },\n> +        {\n> +            \"rpi.geq\":\n> +            {\n> +                \"offset\": 199,\n> +                \"slope\": 0.01947\n> +            }\n> +        },\n> +        {\n> +            \"rpi.sdn\": { }\n> +        },\n> +        {\n> +            \"rpi.awb\":\n> +            {\n> +                \"priors\": [\n> +                    {\n> +                        \"lux\": 0,\n> +                        \"prior\":\n> +                        [\n> +                            2000, 1.0,\n> +                            3000, 0.0,\n> +                            13000, 0.0\n> +                        ]\n> +                    },\n> +                    {\n> +                        \"lux\": 800,\n> +                        \"prior\":\n> +                        [\n> +                            2000, 0.0,\n> +                            6000, 2.0,\n> +                            13000, 2.0\n> +                        ]\n> +                    },\n> +                    {\n> +                        \"lux\": 1500,\n> +                        \"prior\":\n> +                        [\n> +                            2000, 0.0,\n> +                            4000, 1.0,\n> +                            6000, 6.0,\n> +                            6500, 7.0,\n> +                            7000, 1.0,\n> +                            13000, 1.0\n> +                        ]\n> +                    }\n> +                ],\n> +                \"modes\":\n> +                {\n> +                    \"auto\":\n> +                    {\n> +                        \"lo\": 2500,\n> +                        \"hi\": 8000\n> +                    },\n> +                    \"incandescent\":\n> +                    {\n> +                        \"lo\": 2500,\n> +                        \"hi\": 3000\n> +                    },\n> +                    \"tungsten\":\n> +                    {\n> +                        \"lo\": 3000,\n> +                        \"hi\": 3500\n> +                    },\n> +                    \"fluorescent\":\n> +                    {\n> +                        \"lo\": 4000,\n> +                        \"hi\": 4700\n> +                    },\n> +                    \"indoor\":\n> +                    {\n> +                        \"lo\": 3000,\n> +                        \"hi\": 5000\n> +                    },\n> +                    \"daylight\":\n> +                    {\n> +                        \"lo\": 5500,\n> +                        \"hi\": 6500\n> +                    }\n> +                },\n> +                \"bayes\": 1,\n> +                \"ct_curve\":\n> +                [\n> +                    2213.0, 0.9607, 0.2593,\n> +                    5313.0, 0.4822, 0.5909,\n> +                    6237.0, 0.4739, 0.6308\n> +                ],\n> +                \"sensitivity_r\": 1.0,\n> +                \"sensitivity_b\": 1.0,\n> +                \"transverse_pos\": 0.0144,\n> +                \"transverse_neg\": 0.01\n> +            }\n> +        },\n> +        {\n> +            \"rpi.agc\":\n> +            {\n> +                \"metering_modes\":\n> +                {\n> +                    \"centre-weighted\":\n> +                    {\n> +                        \"weights\":\n> +                        [\n> +                            3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0\n> +                        ]\n> +                    },\n> +                    \"spot\":\n> +                    {\n> +                        \"weights\":\n> +                        [\n> +                            2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n> +                        ]\n> +                    },\n> +                    \"matrix\":\n> +                    {\n> +                        \"weights\":\n> +                        [\n> +                            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n> +                        ]\n> +                    }\n> +                },\n> +                \"exposure_modes\":\n> +                {\n> +                    \"normal\":\n> +                    {\n> +                        \"shutter\": [ 100, 10000, 30000, 60000, 120000 ],\n> +                        \"gain\": [ 1.0, 2.0, 4.0, 6.0, 6.0 ]\n> +                    },\n> +                    \"short\":\n> +                    {\n> +                        \"shutter\": [ 100, 5000, 10000, 20000, 120000 ],\n> +                        \"gain\": [ 1.0, 2.0, 4.0, 6.0, 6.0 ]\n> +                    }\n> +                },\n> +                \"constraint_modes\":\n> +                {\n> +                    \"normal\": [\n> +                        {\n> +                            \"bound\": \"LOWER\",\n> +                            \"q_lo\": 0.98,\n> +                            \"q_hi\": 1.0,\n> +                            \"y_target\":\n> +                            [\n> +                                0, 0.5,\n> +                                1000, 0.5\n> +                            ]\n> +                        }\n> +                    ],\n> +                    \"highlight\": [\n> +                        {\n> +                            \"bound\": \"LOWER\",\n> +                            \"q_lo\": 0.98,\n> +                            \"q_hi\": 1.0,\n> +                            \"y_target\":\n> +                            [\n> +                                0, 0.5,\n> +                                1000, 0.5\n> +                            ]\n> +                        },\n> +                        {\n> +                            \"bound\": \"UPPER\",\n> +                            \"q_lo\": 0.98,\n> +                            \"q_hi\": 1.0,\n> +                            \"y_target\":\n> +                            [\n> +                                0, 0.8,\n> +                                1000, 0.8\n> +                            ]\n> +                        }\n> +                    ]\n> +                },\n> +                \"y_target\":\n> +                [\n> +                    0, 0.16,\n> +                    1000, 0.165,\n> +                    10000, 0.17\n> +                ]\n> +            }\n> +        },\n> +        {\n> +            \"rpi.alsc\":\n> +            {\n> +                \"omega\": 1.3,\n> +                \"n_iter\": 100,\n> +                \"luminance_strength\": 0.7\n> +            }\n> +        },\n> +        {\n> +            \"rpi.contrast\":\n> +            {\n> +                \"ce_enable\": 1,\n> +                \"gamma_curve\":\n> +                [\n> +                    0, 0,\n> +                    1024, 5040,\n> +                    2048, 9338,\n> +                    3072, 12356,\n> +                    4096, 15312,\n> +                    5120, 18051,\n> +                    6144, 20790,\n> +                    7168, 23193,\n> +                    8192, 25744,\n> +                    9216, 27942,\n> +                    10240, 30035,\n> +                    11264, 32005,\n> +                    12288, 33975,\n> +                    13312, 35815,\n> +                    14336, 37600,\n> +                    15360, 39168,\n> +                    16384, 40642,\n> +                    18432, 43379,\n> +                    20480, 45749,\n> +                    22528, 47753,\n> +                    24576, 49621,\n> +                    26624, 51253,\n> +                    28672, 52698,\n> +                    30720, 53796,\n> +                    32768, 54876,\n> +                    36864, 57012,\n> +                    40960, 58656,\n> +                    45056, 59954,\n> +                    49152, 61183,\n> +                    53248, 62355,\n> +                    57344, 63419,\n> +                    61440, 64476,\n> +                    65535, 65535\n> +                ]\n> +            }\n> +        },\n> +        {\n> +            \"rpi.ccm\":\n> +            {\n> +                \"ccms\": [\n> +                    {\n> +                        \"ct\": 2213,\n> +                        \"ccm\":\n> +                        [\n> +                            1.91264, -0.27609, -0.63655,\n> +                            -0.65708, 2.11718, -0.46009,\n> +                            0.03629, -1.38441, 2.34811\n> +                        ]\n> +                    },\n> +                    {\n> +                        \"ct\": 2255,\n> +                        \"ccm\":\n> +                        [\n> +                            1.90369, -0.29309, -0.61059,\n> +                            -0.64693, 2.08169, -0.43476,\n> +                            0.04086, -1.29999, 2.25914\n> +                        ]\n> +                    },\n> +                    {\n> +                        \"ct\": 2259,\n> +                        \"ccm\":\n> +                        [\n> +                            1.92762, -0.35134, -0.57628,\n> +                            -0.63523, 2.08481, -0.44958,\n> +                            0.06754, -1.32953, 2.26199\n> +                        ]\n> +                    },\n> +                    {\n> +                        \"ct\": 5313,\n> +                        \"ccm\":\n> +                        [\n> +                            1.75924, -0.54053, -0.21871,\n> +                            -0.38159, 1.88671, -0.50511,\n> +                            -0.00747, -0.53492, 1.54239\n> +                        ]\n> +                    },\n> +                    {\n> +                        \"ct\": 6237,\n> +                        \"ccm\":\n> +                        [\n> +                            2.19299, -0.74764, -0.44536,\n> +                            -0.51678, 2.27651, -0.75972,\n> +                            -0.06498, -0.74269, 1.80767\n> +                        ]\n> +                    }\n> +                ]\n> +            }\n> +        },\n> +        {\n> +            \"rpi.sharpen\": { }\n> +        }\n> +    ]\n> +}\n> diff --git a/src/ipa/rpi/vc4/data/meson.build b/src/ipa/rpi/vc4/data/meson.build\n> index afbf875a113a..60477c112196 100644\n> --- a/src/ipa/rpi/vc4/data/meson.build\n> +++ b/src/ipa/rpi/vc4/data/meson.build\n> @@ -3,6 +3,7 @@\n>  conf_files = files([\n>      'imx219.json',\n>      'imx219_noir.json',\n> +    'imx283.json',\n>      'imx290.json',\n>      'imx296.json',\n>      'imx296_mono.json',\n> -- \n> 2.34.1\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 06A7BBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Aug 2024 10:00:00 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D07B363382;\n\tWed,  7 Aug 2024 11:59:59 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4FC1A61946\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Aug 2024 11:59:58 +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 829792EC;\n\tWed,  7 Aug 2024 11:59:05 +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=\"c8fiyckg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1723024745;\n\tbh=Ycc2z9+phWDkz6F1yIYDMYiZhm3ytuSvFCpUBLdhB4k=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=c8fiyckgbavOkp42+nVHM1pm/unCLWcQtcFHGvVzO7yYIzHNjwt26OG6epIYBn3aL\n\tCnQiQ3wL0PmDLJF+5lC69Ns8F5pgIBfS5EPblpHgR/Ts15zFjK7C6/suWTFITS3TgH\n\tqJIKlxNFi7sIo6bUkynNNNaYkXmYN8UyKBwVbMBM=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20240807093449.1926-3-naush@raspberrypi.com>","References":"<20240807093449.1926-1-naush@raspberrypi.com>\n\t<20240807093449.1926-3-naush@raspberrypi.com>","Subject":"Re: [PATCH v1 2/2] ipa: rpi: Adding IMX283 support","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"will whang <will@willwhang.com>, Naushir Patuck <naush@raspberrypi.com>","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Wed, 07 Aug 2024 10:59:55 +0100","Message-ID":"<172302479516.1687952.14127695837729893701@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>"}}]