[{"id":15534,"web_url":"https://patchwork.libcamera.org/comment/15534/","msgid":"<YEZ7aRAOzrtZFRSQ@pendragon.ideasonboard.com>","date":"2021-03-08T19:30:49","subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Thu, Mar 04, 2021 at 03:31:20PM +0000, David Plowman wrote:\n> imx290 and imx327 share the same kernel driver (imx290.c) and are\n> therefore both recognised here as \"imx290\".\n\nAre there any differences between the two sensors that may need to be\nhandled anywhere in libcamera ?\n\n> We add the necessary\n> CamHelper for these sensors, as well as a camera tuning file.\n> \n> The tuning was done with an Innomaker STARVIS IMX327LQR module. These\n> have no IR cut filter so there is no proper colour tuning. However,\n> you should obtain reasonable results for most modules using this\n> sensor. Specific tunings for further modules can always be added\n> subsequently.\n> \n> To use this sensor on the Raspberry Pi platform, please add\n> \n> dtoverlay=imx290,clock-frequency=74250000\n> \n> into your /boot/config.txt file.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/cam_helper_imx290.cpp |  67 +++++++++\n>  src/ipa/raspberrypi/data/imx290.json      | 165 ++++++++++++++++++++++\n>  src/ipa/raspberrypi/data/meson.build      |   1 +\n>  src/ipa/raspberrypi/meson.build           |   1 +\n>  4 files changed, 234 insertions(+)\n>  create mode 100644 src/ipa/raspberrypi/cam_helper_imx290.cpp\n>  create mode 100644 src/ipa/raspberrypi/data/imx290.json\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> new file mode 100644\n> index 00000000..6f412e40\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> @@ -0,0 +1,67 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> + *\n> + * cam_helper_imx290.cpp - camera helper for imx290 sensor\n> + */\n> +\n> +#include <math.h>\n> +\n> +#include \"cam_helper.hpp\"\n> +\n> +using namespace RPiController;\n> +\n> +class CamHelperImx290 : public CamHelper\n> +{\n> +public:\n> +\tCamHelperImx290();\n> +\tuint32_t GainCode(double gain) const override;\n> +\tdouble Gain(uint32_t gain_code) const override;\n> +\tvoid GetDelays(int &exposure_delay, int &gain_delay,\n> +\t\t       int &vblank_delay) const override;\n> +\tunsigned int HideFramesModeSwitch() const override;\n> +\n> +private:\n> +\t/*\n> +\t * Smallest difference between the frame length and integration time,\n> +\t * in units of lines.\n> +\t */\n> +\tstatic constexpr int frameIntegrationDiff = 2;\n> +};\n> +\n> +CamHelperImx290::CamHelperImx290()\n> +\t: CamHelper(nullptr, frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx290::GainCode(double gain) const\n> +{\n> +\tint code = 66.6667 * log10(gain);\n> +\treturn std::max(0, std::min(code, 0xf0));\n> +}\n> +\n> +double CamHelperImx290::Gain(uint32_t gain_code) const\n> +{\n> +\treturn pow(10, 0.015 * gain_code);\n> +}\n> +\n> +void CamHelperImx290::GetDelays(int &exposure_delay, int &gain_delay,\n> +\t\t\t\tint &vblank_delay) const\n> +{\n> +\texposure_delay = 2;\n> +\tgain_delay = 2;\n> +\tvblank_delay = 2;\n> +}\n> +\n> +unsigned int CamHelperImx290::HideFramesModeSwitch() const\n> +{\n> +\t/* After a mode switch, we seem to get 1 bad frame. */\n> +\treturn 1;\n> +}\n> +\n> +static CamHelper *Create()\n> +{\n> +\treturn new CamHelperImx290();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx290\", &Create);\n> diff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json\n> new file mode 100644\n> index 00000000..6fb92cc4\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/data/imx290.json\n> @@ -0,0 +1,165 @@\n> +{\n> +    \"rpi.black_level\":\n> +    {\n> +        \"black_level\": 3840\n> +    },\n> +    \"rpi.dpc\":\n> +    {\n> +    },\n> +    \"rpi.lux\":\n> +    {\n> +        \"reference_shutter_speed\": 6813,\n> +        \"reference_gain\": 1.0,\n> +        \"reference_aperture\": 1.0,\n> +        \"reference_lux\": 890,\n> +        \"reference_Y\": 12900\n> +    },\n> +    \"rpi.noise\":\n> +    {\n> +        \"reference_constant\": 0,\n> +        \"reference_slope\": 2.67\n> +    },\n> +    \"rpi.geq\":\n> +    {\n> +        \"offset\": 187,\n> +        \"slope\": 0.00842\n> +    },\n> +    \"rpi.sdn\":\n> +    {\n> +    },\n> +    \"rpi.awb\":\n> +    {\n> +\t\"bayes\": 0\n> +    },\n> +    \"rpi.agc\":\n> +    {\n> +\t\"speed\": 0.2,\n> +        \"metering_modes\":\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> +            \"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> +        },\n> +        \"exposure_modes\":\n> +        {\n> +            \"normal\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    10, 30000, 60000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0,  2.0,   8.0\n> +                ]\n> +            },\n> +            \"sport\":\n> +            {\n> +                \"shutter\":\n> +                [\n> +                    10, 5000, 10000, 20000, 120000\n> +                ],\n> +                \"gain\":\n> +                [\n> +                    1.0, 2.0, 4.0, 6.0, 6.0\n> +                ]\n> +            }\n> +        },\n> +        \"constraint_modes\":\n> +        {\n> +            \"normal\":\n> +            [\n> +            ],\n> +            \"highlight\":\n> +            [\n> +                {\n> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> +                    [\n> +                        0, 0.5, 1000, 0.5\n> +                    ]\n> +                },\n> +                {\n> +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> +                    [\n> +                        0, 0.8, 1000, 0.8\n> +                    ]\n> +                }\n> +            ]\n> +        },\n> +        \"y_target\":\n> +        [\n> +            0, 0.16, 1000, 0.16, 10000, 0.16\n> +        ]\n> +    },\n> +    \"rpi.alsc\":\n> +    {\n> +        \"omega\": 1.3,\n> +        \"n_iter\": 100,\n> +        \"luminance_strength\": 0.7,\n> +        \"luminance_lut\":\n> +        [\n> +            2.844, 2.349, 2.018, 1.775, 1.599, 1.466, 1.371, 1.321, 1.306, 1.316, 1.357, 1.439, 1.552, 1.705, 1.915, 2.221,\n> +            2.576, 2.151, 1.851, 1.639, 1.478, 1.358, 1.272, 1.231, 1.218, 1.226, 1.262, 1.335, 1.438, 1.571, 1.766, 2.067,\n> +            2.381, 2.005, 1.739, 1.545, 1.389, 1.278, 1.204, 1.166, 1.153, 1.161, 1.194, 1.263, 1.356, 1.489, 1.671, 1.943,\n> +            2.242, 1.899, 1.658, 1.481, 1.329, 1.225, 1.156, 1.113, 1.096, 1.107, 1.143, 1.201, 1.289, 1.423, 1.607, 1.861,\n> +            2.152, 1.831, 1.602, 1.436, 1.291, 1.193, 1.121, 1.069, 1.047, 1.062, 1.107, 1.166, 1.249, 1.384, 1.562, 1.801,\n> +            2.104, 1.795, 1.572, 1.407, 1.269, 1.174, 1.099, 1.041, 1.008, 1.029, 1.083, 1.146, 1.232, 1.364, 1.547, 1.766,\n> +            2.104, 1.796, 1.572, 1.403, 1.264, 1.171, 1.097, 1.036, 1.001, 1.025, 1.077, 1.142, 1.231, 1.363, 1.549, 1.766,\n> +            2.148, 1.827, 1.594, 1.413, 1.276, 1.184, 1.114, 1.062, 1.033, 1.049, 1.092, 1.153, 1.242, 1.383, 1.577, 1.795,\n> +            2.211, 1.881, 1.636, 1.455, 1.309, 1.214, 1.149, 1.104, 1.081, 1.089, 1.125, 1.184, 1.273, 1.423, 1.622, 1.846,\n> +            2.319, 1.958, 1.698, 1.516, 1.362, 1.262, 1.203, 1.156, 1.137, 1.142, 1.171, 1.229, 1.331, 1.484, 1.682, 1.933,\n> +            2.459, 2.072, 1.789, 1.594, 1.441, 1.331, 1.261, 1.219, 1.199, 1.205, 1.232, 1.301, 1.414, 1.571, 1.773, 2.052,\n> +            2.645, 2.206, 1.928, 1.728, 1.559, 1.451, 1.352, 1.301, 1.282, 1.289, 1.319, 1.395, 1.519, 1.685, 1.904, 2.227\n> +        ],\n> +        \"sigma\": 0.005,\n> +        \"sigma_Cb\": 0.005\n> +    },\n> +    \"rpi.contrast\":\n> +    {\n> +        \"ce_enable\": 1,\n> +        \"gamma_curve\":\n> +        [\n> +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n> +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> +            65535, 65535\n> +        ]\n> +    },\n> +    \"rpi.sharpen\":\n> +    {\n> +    },\n> +    \"rpi.ccm\":\n> +    {\n> +        \"ccms\":\n> +\t[\n> +            {\n> +\t\t\"ct\": 3900, \"ccm\":\n> +\t\t[\n> +\t\t    1.54659, -0.17707, -0.36953, -0.51471, 1.72733, -0.21262, 0.06667, -0.92279, 1.85612\n> +\t\t]\n> +\t    }\n> +\t]\n> +    },\n> +    \"rpi.focus\":\n> +    {\n> +    }\n> +}\n> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> index 5236bf1e..509ad58b 100644\n> --- a/src/ipa/raspberrypi/data/meson.build\n> +++ b/src/ipa/raspberrypi/data/meson.build\n> @@ -3,6 +3,7 @@\n>  conf_files = files([\n>      'imx219.json',\n>      'imx477.json',\n> +    'imx290.json',\n\nAlphabetical order please.\n\n>      'ov5647.json',\n>      'uncalibrated.json',\n>  ])\n> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> index 59e49686..7e88f8e0 100644\n> --- a/src/ipa/raspberrypi/meson.build\n> +++ b/src/ipa/raspberrypi/meson.build\n> @@ -21,6 +21,7 @@ rpi_ipa_sources = files([\n>      'cam_helper_ov5647.cpp',\n>      'cam_helper_imx219.cpp',\n>      'cam_helper_imx477.cpp',\n> +    'cam_helper_imx290.cpp',\n\nHere too.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>      'controller/controller.cpp',\n>      'controller/histogram.cpp',\n>      'controller/algorithm.cpp',","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 74B94BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Mar 2021 19:31:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D531F68AA2;\n\tMon,  8 Mar 2021 20:31:22 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D4C060520\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Mar 2021 20:31:21 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7CFF6E7B;\n\tMon,  8 Mar 2021 20:31:20 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"FWRF2KCh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1615231880;\n\tbh=5uSkCQaG+QR/dOok+AZmvN51GPtue79FxGZiYfWh1Pw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FWRF2KChmfBUakhtx8bBlAdUnZ4HnHSUJG1wXZ4fbaOjppoOeQ9wj3Svj3t0KhzLe\n\tbmvlidMoTR5325kASZWyyg/UAn6c/e9WECUhjDa5FRLsiq6ortoyhHzCRtBTACR33X\n\tsK0Rq2TRsZRaOMnjlr+g5CQc/kKeH8YwCrI3GvNw=","Date":"Mon, 8 Mar 2021 21:30:49 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YEZ7aRAOzrtZFRSQ@pendragon.ideasonboard.com>","References":"<20210304153120.1904-1-david.plowman@raspberrypi.com>\n\t<20210304153120.1904-3-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210304153120.1904-3-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15537,"web_url":"https://patchwork.libcamera.org/comment/15537/","msgid":"<CAHW6GYLWOEPoJq0qMhZx0T2c8x8fWMvXUFMewmpfB0oF0ra+8g@mail.gmail.com>","date":"2021-03-08T22:11:35","subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent\n\nThanks also for this review!\n\nOn Mon, 8 Mar 2021 at 19:31, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> Thank you for the patch.\n>\n> On Thu, Mar 04, 2021 at 03:31:20PM +0000, David Plowman wrote:\n> > imx290 and imx327 share the same kernel driver (imx290.c) and are\n> > therefore both recognised here as \"imx290\".\n>\n> Are there any differences between the two sensors that may need to be\n> handled anywhere in libcamera ?\n\nGood question, and the answer is... I don't really know. I don't have\nany modules that I know to have an imx290 in them, but at some point\nI'm sure we or someone else will come across one and we'll find out.\nAt some point some we're going to have to start coping with different\nmodules with the same (or indistinguishable sensors) in them too.\n\n>\n> > We add the necessary\n> > CamHelper for these sensors, as well as a camera tuning file.\n> >\n> > The tuning was done with an Innomaker STARVIS IMX327LQR module. These\n> > have no IR cut filter so there is no proper colour tuning. However,\n> > you should obtain reasonable results for most modules using this\n> > sensor. Specific tunings for further modules can always be added\n> > subsequently.\n> >\n> > To use this sensor on the Raspberry Pi platform, please add\n> >\n> > dtoverlay=imx290,clock-frequency=74250000\n> >\n> > into your /boot/config.txt file.\n> >\n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > ---\n> >  src/ipa/raspberrypi/cam_helper_imx290.cpp |  67 +++++++++\n> >  src/ipa/raspberrypi/data/imx290.json      | 165 ++++++++++++++++++++++\n> >  src/ipa/raspberrypi/data/meson.build      |   1 +\n> >  src/ipa/raspberrypi/meson.build           |   1 +\n> >  4 files changed, 234 insertions(+)\n> >  create mode 100644 src/ipa/raspberrypi/cam_helper_imx290.cpp\n> >  create mode 100644 src/ipa/raspberrypi/data/imx290.json\n> >\n> > diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > new file mode 100644\n> > index 00000000..6f412e40\n> > --- /dev/null\n> > +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > @@ -0,0 +1,67 @@\n> > +/* SPDX-License-Identifier: BSD-2-Clause */\n> > +/*\n> > + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> > + *\n> > + * cam_helper_imx290.cpp - camera helper for imx290 sensor\n> > + */\n> > +\n> > +#include <math.h>\n> > +\n> > +#include \"cam_helper.hpp\"\n> > +\n> > +using namespace RPiController;\n> > +\n> > +class CamHelperImx290 : public CamHelper\n> > +{\n> > +public:\n> > +     CamHelperImx290();\n> > +     uint32_t GainCode(double gain) const override;\n> > +     double Gain(uint32_t gain_code) const override;\n> > +     void GetDelays(int &exposure_delay, int &gain_delay,\n> > +                    int &vblank_delay) 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 = 2;\n> > +};\n> > +\n> > +CamHelperImx290::CamHelperImx290()\n> > +     : CamHelper(nullptr, frameIntegrationDiff)\n> > +{\n> > +}\n> > +\n> > +uint32_t CamHelperImx290::GainCode(double gain) const\n> > +{\n> > +     int code = 66.6667 * log10(gain);\n> > +     return std::max(0, std::min(code, 0xf0));\n> > +}\n> > +\n> > +double CamHelperImx290::Gain(uint32_t gain_code) const\n> > +{\n> > +     return pow(10, 0.015 * gain_code);\n> > +}\n> > +\n> > +void CamHelperImx290::GetDelays(int &exposure_delay, int &gain_delay,\n> > +                             int &vblank_delay) const\n> > +{\n> > +     exposure_delay = 2;\n> > +     gain_delay = 2;\n> > +     vblank_delay = 2;\n> > +}\n> > +\n> > +unsigned int CamHelperImx290::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 CamHelperImx290();\n> > +}\n> > +\n> > +static RegisterCamHelper reg(\"imx290\", &Create);\n> > diff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json\n> > new file mode 100644\n> > index 00000000..6fb92cc4\n> > --- /dev/null\n> > +++ b/src/ipa/raspberrypi/data/imx290.json\n> > @@ -0,0 +1,165 @@\n> > +{\n> > +    \"rpi.black_level\":\n> > +    {\n> > +        \"black_level\": 3840\n> > +    },\n> > +    \"rpi.dpc\":\n> > +    {\n> > +    },\n> > +    \"rpi.lux\":\n> > +    {\n> > +        \"reference_shutter_speed\": 6813,\n> > +        \"reference_gain\": 1.0,\n> > +        \"reference_aperture\": 1.0,\n> > +        \"reference_lux\": 890,\n> > +        \"reference_Y\": 12900\n> > +    },\n> > +    \"rpi.noise\":\n> > +    {\n> > +        \"reference_constant\": 0,\n> > +        \"reference_slope\": 2.67\n> > +    },\n> > +    \"rpi.geq\":\n> > +    {\n> > +        \"offset\": 187,\n> > +        \"slope\": 0.00842\n> > +    },\n> > +    \"rpi.sdn\":\n> > +    {\n> > +    },\n> > +    \"rpi.awb\":\n> > +    {\n> > +     \"bayes\": 0\n> > +    },\n> > +    \"rpi.agc\":\n> > +    {\n> > +     \"speed\": 0.2,\n> > +        \"metering_modes\":\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> > +            \"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> > +        },\n> > +        \"exposure_modes\":\n> > +        {\n> > +            \"normal\":\n> > +            {\n> > +                \"shutter\":\n> > +                [\n> > +                    10, 30000, 60000\n> > +                ],\n> > +                \"gain\":\n> > +                [\n> > +                    1.0,  2.0,   8.0\n> > +                ]\n> > +            },\n> > +            \"sport\":\n> > +            {\n> > +                \"shutter\":\n> > +                [\n> > +                    10, 5000, 10000, 20000, 120000\n> > +                ],\n> > +                \"gain\":\n> > +                [\n> > +                    1.0, 2.0, 4.0, 6.0, 6.0\n> > +                ]\n> > +            }\n> > +        },\n> > +        \"constraint_modes\":\n> > +        {\n> > +            \"normal\":\n> > +            [\n> > +            ],\n> > +            \"highlight\":\n> > +            [\n> > +                {\n> > +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> > +                    [\n> > +                        0, 0.5, 1000, 0.5\n> > +                    ]\n> > +                },\n> > +                {\n> > +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> > +                    [\n> > +                        0, 0.8, 1000, 0.8\n> > +                    ]\n> > +                }\n> > +            ]\n> > +        },\n> > +        \"y_target\":\n> > +        [\n> > +            0, 0.16, 1000, 0.16, 10000, 0.16\n> > +        ]\n> > +    },\n> > +    \"rpi.alsc\":\n> > +    {\n> > +        \"omega\": 1.3,\n> > +        \"n_iter\": 100,\n> > +        \"luminance_strength\": 0.7,\n> > +        \"luminance_lut\":\n> > +        [\n> > +            2.844, 2.349, 2.018, 1.775, 1.599, 1.466, 1.371, 1.321, 1.306, 1.316, 1.357, 1.439, 1.552, 1.705, 1.915, 2.221,\n> > +            2.576, 2.151, 1.851, 1.639, 1.478, 1.358, 1.272, 1.231, 1.218, 1.226, 1.262, 1.335, 1.438, 1.571, 1.766, 2.067,\n> > +            2.381, 2.005, 1.739, 1.545, 1.389, 1.278, 1.204, 1.166, 1.153, 1.161, 1.194, 1.263, 1.356, 1.489, 1.671, 1.943,\n> > +            2.242, 1.899, 1.658, 1.481, 1.329, 1.225, 1.156, 1.113, 1.096, 1.107, 1.143, 1.201, 1.289, 1.423, 1.607, 1.861,\n> > +            2.152, 1.831, 1.602, 1.436, 1.291, 1.193, 1.121, 1.069, 1.047, 1.062, 1.107, 1.166, 1.249, 1.384, 1.562, 1.801,\n> > +            2.104, 1.795, 1.572, 1.407, 1.269, 1.174, 1.099, 1.041, 1.008, 1.029, 1.083, 1.146, 1.232, 1.364, 1.547, 1.766,\n> > +            2.104, 1.796, 1.572, 1.403, 1.264, 1.171, 1.097, 1.036, 1.001, 1.025, 1.077, 1.142, 1.231, 1.363, 1.549, 1.766,\n> > +            2.148, 1.827, 1.594, 1.413, 1.276, 1.184, 1.114, 1.062, 1.033, 1.049, 1.092, 1.153, 1.242, 1.383, 1.577, 1.795,\n> > +            2.211, 1.881, 1.636, 1.455, 1.309, 1.214, 1.149, 1.104, 1.081, 1.089, 1.125, 1.184, 1.273, 1.423, 1.622, 1.846,\n> > +            2.319, 1.958, 1.698, 1.516, 1.362, 1.262, 1.203, 1.156, 1.137, 1.142, 1.171, 1.229, 1.331, 1.484, 1.682, 1.933,\n> > +            2.459, 2.072, 1.789, 1.594, 1.441, 1.331, 1.261, 1.219, 1.199, 1.205, 1.232, 1.301, 1.414, 1.571, 1.773, 2.052,\n> > +            2.645, 2.206, 1.928, 1.728, 1.559, 1.451, 1.352, 1.301, 1.282, 1.289, 1.319, 1.395, 1.519, 1.685, 1.904, 2.227\n> > +        ],\n> > +        \"sigma\": 0.005,\n> > +        \"sigma_Cb\": 0.005\n> > +    },\n> > +    \"rpi.contrast\":\n> > +    {\n> > +        \"ce_enable\": 1,\n> > +        \"gamma_curve\":\n> > +        [\n> > +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n> > +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> > +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> > +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> > +            65535, 65535\n> > +        ]\n> > +    },\n> > +    \"rpi.sharpen\":\n> > +    {\n> > +    },\n> > +    \"rpi.ccm\":\n> > +    {\n> > +        \"ccms\":\n> > +     [\n> > +            {\n> > +             \"ct\": 3900, \"ccm\":\n> > +             [\n> > +                 1.54659, -0.17707, -0.36953, -0.51471, 1.72733, -0.21262, 0.06667, -0.92279, 1.85612\n> > +             ]\n> > +         }\n> > +     ]\n> > +    },\n> > +    \"rpi.focus\":\n> > +    {\n> > +    }\n> > +}\n> > diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> > index 5236bf1e..509ad58b 100644\n> > --- a/src/ipa/raspberrypi/data/meson.build\n> > +++ b/src/ipa/raspberrypi/data/meson.build\n> > @@ -3,6 +3,7 @@\n> >  conf_files = files([\n> >      'imx219.json',\n> >      'imx477.json',\n> > +    'imx290.json',\n>\n> Alphabetical order please.\n>\n> >      'ov5647.json',\n> >      'uncalibrated.json',\n> >  ])\n> > diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> > index 59e49686..7e88f8e0 100644\n> > --- a/src/ipa/raspberrypi/meson.build\n> > +++ b/src/ipa/raspberrypi/meson.build\n> > @@ -21,6 +21,7 @@ rpi_ipa_sources = files([\n> >      'cam_helper_ov5647.cpp',\n> >      'cam_helper_imx219.cpp',\n> >      'cam_helper_imx477.cpp',\n> > +    'cam_helper_imx290.cpp',\n>\n> Here too.\n\nWill do! Version 2 of this set incoming shortly.\n\nThanks again\n\nDavid\n\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> >      'controller/controller.cpp',\n> >      'controller/histogram.cpp',\n> >      'controller/algorithm.cpp',\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 06169BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Mar 2021 22:11:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 598B168A9F;\n\tMon,  8 Mar 2021 23:11:49 +0100 (CET)","from mail-oi1-x234.google.com (mail-oi1-x234.google.com\n\t[IPv6:2607:f8b0:4864:20::234])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D95D4602ED\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Mar 2021 23:11:47 +0100 (CET)","by mail-oi1-x234.google.com with SMTP id o22so2953331oic.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 08 Mar 2021 14:11:47 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"B4/2EpeV\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=LSIDzQsJqFFgYB98jpEnDEnAXWsSDL5n142e4HFAdX0=;\n\tb=B4/2EpeVmWBHxdxEQIAoF3k9PhenoDn3dT3XUOIFEhtUFZqeybRWnAD7qSOasEuEZP\n\tId6Wf4R6ridME18Oc8rruU4qYcBPGupO0hT3ydQJBpg4Mng+C0+mIIZoLvrp1QM38ufq\n\tRYMGC5UjIVGoq4L7ONpQ3+3Th9kW/Rfy4Cqh5FZuELHMBCYhNFC88zsNT29VkoAbGxwC\n\tntmHmim8Wur9FDaSmQuAgdTqv7HrG806C4OYmjsakJwKg6X8B7qVNnZX74zxYxn5pEx4\n\tqYLhxWLWSpEqEglwvNkhMa8qLKmue4D8W44pUuevPo7W4GYOsNnQucs59pmw57gL3SUR\n\tUddw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=LSIDzQsJqFFgYB98jpEnDEnAXWsSDL5n142e4HFAdX0=;\n\tb=cGUB+yM0+JMBaVqKeeqJn2vJKhb+q6AFQyTODp8fzSm3mpmmrxfjIrk2DCgcpCI1Vj\n\tBhVpifttixSMOODW9Xk0nkszgk+b5/Ypr+FB946uepGfgVsTmHhB0EovsdBJ3CCmEA8a\n\tTmj0PBL0XB+84G36I6VDy4KVLOK0Ywse0lim1qU6tjy+467/XPQBCNRO5ImH2CPDWHvL\n\tZAPb1kpvoG7dvwyn6CpI7mQA9/nS7lbRvvsMtagYxXv92i9+Yx2T8ZrYSjsRRKoBvW4J\n\tw5EeP6d2s39+2mTqDtCedbto43iySWK3GchaupcD7QZWtFJahe+UoEt4GQ+kno9gy0sK\n\tKRlA==","X-Gm-Message-State":"AOAM531bcSsFvQo6I5+i5NIZktgN70jL2nB6qitEwHiWnHLUjTLFF8W9\n\tBOzyn1RxmFKbOJAGNfY9xhdVJjA32N5qI1KQbzDJng==","X-Google-Smtp-Source":"ABdhPJyR+gJbKqLJ0h6uy10/ZYQcW+4dISibHepFks7mUsk86TLXiRG/pcBoHa/d5cVPQFEAzoBPOiU6HD9i5eMV2hM=","X-Received":"by 2002:aca:4a87:: with SMTP id\n\tx129mr732613oia.107.1615241506732; \n\tMon, 08 Mar 2021 14:11:46 -0800 (PST)","MIME-Version":"1.0","References":"<20210304153120.1904-1-david.plowman@raspberrypi.com>\n\t<20210304153120.1904-3-david.plowman@raspberrypi.com>\n\t<YEZ7aRAOzrtZFRSQ@pendragon.ideasonboard.com>","In-Reply-To":"<YEZ7aRAOzrtZFRSQ@pendragon.ideasonboard.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 8 Mar 2021 22:11:35 +0000","Message-ID":"<CAHW6GYLWOEPoJq0qMhZx0T2c8x8fWMvXUFMewmpfB0oF0ra+8g@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15538,"web_url":"https://patchwork.libcamera.org/comment/15538/","msgid":"<YEai9cNXP0mRBo7L@pendragon.ideasonboard.com>","date":"2021-03-08T22:19:33","subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi David,\n\nOn Mon, Mar 08, 2021 at 10:11:35PM +0000, David Plowman wrote:\n> On Mon, 8 Mar 2021 at 19:31, Laurent Pinchart wrote:\n> > On Thu, Mar 04, 2021 at 03:31:20PM +0000, David Plowman wrote:\n> > > imx290 and imx327 share the same kernel driver (imx290.c) and are\n> > > therefore both recognised here as \"imx290\".\n> >\n> > Are there any differences between the two sensors that may need to be\n> > handled anywhere in libcamera ?\n> \n> Good question, and the answer is... I don't really know. I don't have\n> any modules that I know to have an imx290 in them, but at some point\n> I'm sure we or someone else will come across one and we'll find out.\n> At some point some we're going to have to start coping with different\n> modules with the same (or indistinguishable sensors) in them too.\n\nThere are two issues here, differences between the IMX290 and IMX327\nsensors, and differences between modules. For the former, would it make\nsense to already add a sony,imx327 compatible string to the imx290\ndriver, and make use of it ? To be clear, it's not a blocker for this\npatch.\n\n> > > We add the necessary\n> > > CamHelper for these sensors, as well as a camera tuning file.\n> > >\n> > > The tuning was done with an Innomaker STARVIS IMX327LQR module. These\n> > > have no IR cut filter so there is no proper colour tuning. However,\n> > > you should obtain reasonable results for most modules using this\n> > > sensor. Specific tunings for further modules can always be added\n> > > subsequently.\n> > >\n> > > To use this sensor on the Raspberry Pi platform, please add\n> > >\n> > > dtoverlay=imx290,clock-frequency=74250000\n> > >\n> > > into your /boot/config.txt file.\n> > >\n> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > ---\n> > >  src/ipa/raspberrypi/cam_helper_imx290.cpp |  67 +++++++++\n> > >  src/ipa/raspberrypi/data/imx290.json      | 165 ++++++++++++++++++++++\n> > >  src/ipa/raspberrypi/data/meson.build      |   1 +\n> > >  src/ipa/raspberrypi/meson.build           |   1 +\n> > >  4 files changed, 234 insertions(+)\n> > >  create mode 100644 src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > >  create mode 100644 src/ipa/raspberrypi/data/imx290.json\n> > >\n> > > diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > > new file mode 100644\n> > > index 00000000..6f412e40\n> > > --- /dev/null\n> > > +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > > @@ -0,0 +1,67 @@\n> > > +/* SPDX-License-Identifier: BSD-2-Clause */\n> > > +/*\n> > > + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> > > + *\n> > > + * cam_helper_imx290.cpp - camera helper for imx290 sensor\n> > > + */\n> > > +\n> > > +#include <math.h>\n> > > +\n> > > +#include \"cam_helper.hpp\"\n> > > +\n> > > +using namespace RPiController;\n> > > +\n> > > +class CamHelperImx290 : public CamHelper\n> > > +{\n> > > +public:\n> > > +     CamHelperImx290();\n> > > +     uint32_t GainCode(double gain) const override;\n> > > +     double Gain(uint32_t gain_code) const override;\n> > > +     void GetDelays(int &exposure_delay, int &gain_delay,\n> > > +                    int &vblank_delay) 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 = 2;\n> > > +};\n> > > +\n> > > +CamHelperImx290::CamHelperImx290()\n> > > +     : CamHelper(nullptr, frameIntegrationDiff)\n> > > +{\n> > > +}\n> > > +\n> > > +uint32_t CamHelperImx290::GainCode(double gain) const\n> > > +{\n> > > +     int code = 66.6667 * log10(gain);\n> > > +     return std::max(0, std::min(code, 0xf0));\n> > > +}\n> > > +\n> > > +double CamHelperImx290::Gain(uint32_t gain_code) const\n> > > +{\n> > > +     return pow(10, 0.015 * gain_code);\n> > > +}\n> > > +\n> > > +void CamHelperImx290::GetDelays(int &exposure_delay, int &gain_delay,\n> > > +                             int &vblank_delay) const\n> > > +{\n> > > +     exposure_delay = 2;\n> > > +     gain_delay = 2;\n> > > +     vblank_delay = 2;\n> > > +}\n> > > +\n> > > +unsigned int CamHelperImx290::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 CamHelperImx290();\n> > > +}\n> > > +\n> > > +static RegisterCamHelper reg(\"imx290\", &Create);\n> > > diff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json\n> > > new file mode 100644\n> > > index 00000000..6fb92cc4\n> > > --- /dev/null\n> > > +++ b/src/ipa/raspberrypi/data/imx290.json\n> > > @@ -0,0 +1,165 @@\n> > > +{\n> > > +    \"rpi.black_level\":\n> > > +    {\n> > > +        \"black_level\": 3840\n> > > +    },\n> > > +    \"rpi.dpc\":\n> > > +    {\n> > > +    },\n> > > +    \"rpi.lux\":\n> > > +    {\n> > > +        \"reference_shutter_speed\": 6813,\n> > > +        \"reference_gain\": 1.0,\n> > > +        \"reference_aperture\": 1.0,\n> > > +        \"reference_lux\": 890,\n> > > +        \"reference_Y\": 12900\n> > > +    },\n> > > +    \"rpi.noise\":\n> > > +    {\n> > > +        \"reference_constant\": 0,\n> > > +        \"reference_slope\": 2.67\n> > > +    },\n> > > +    \"rpi.geq\":\n> > > +    {\n> > > +        \"offset\": 187,\n> > > +        \"slope\": 0.00842\n> > > +    },\n> > > +    \"rpi.sdn\":\n> > > +    {\n> > > +    },\n> > > +    \"rpi.awb\":\n> > > +    {\n> > > +     \"bayes\": 0\n> > > +    },\n> > > +    \"rpi.agc\":\n> > > +    {\n> > > +     \"speed\": 0.2,\n> > > +        \"metering_modes\":\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> > > +            \"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> > > +        },\n> > > +        \"exposure_modes\":\n> > > +        {\n> > > +            \"normal\":\n> > > +            {\n> > > +                \"shutter\":\n> > > +                [\n> > > +                    10, 30000, 60000\n> > > +                ],\n> > > +                \"gain\":\n> > > +                [\n> > > +                    1.0,  2.0,   8.0\n> > > +                ]\n> > > +            },\n> > > +            \"sport\":\n> > > +            {\n> > > +                \"shutter\":\n> > > +                [\n> > > +                    10, 5000, 10000, 20000, 120000\n> > > +                ],\n> > > +                \"gain\":\n> > > +                [\n> > > +                    1.0, 2.0, 4.0, 6.0, 6.0\n> > > +                ]\n> > > +            }\n> > > +        },\n> > > +        \"constraint_modes\":\n> > > +        {\n> > > +            \"normal\":\n> > > +            [\n> > > +            ],\n> > > +            \"highlight\":\n> > > +            [\n> > > +                {\n> > > +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> > > +                    [\n> > > +                        0, 0.5, 1000, 0.5\n> > > +                    ]\n> > > +                },\n> > > +                {\n> > > +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> > > +                    [\n> > > +                        0, 0.8, 1000, 0.8\n> > > +                    ]\n> > > +                }\n> > > +            ]\n> > > +        },\n> > > +        \"y_target\":\n> > > +        [\n> > > +            0, 0.16, 1000, 0.16, 10000, 0.16\n> > > +        ]\n> > > +    },\n> > > +    \"rpi.alsc\":\n> > > +    {\n> > > +        \"omega\": 1.3,\n> > > +        \"n_iter\": 100,\n> > > +        \"luminance_strength\": 0.7,\n> > > +        \"luminance_lut\":\n> > > +        [\n> > > +            2.844, 2.349, 2.018, 1.775, 1.599, 1.466, 1.371, 1.321, 1.306, 1.316, 1.357, 1.439, 1.552, 1.705, 1.915, 2.221,\n> > > +            2.576, 2.151, 1.851, 1.639, 1.478, 1.358, 1.272, 1.231, 1.218, 1.226, 1.262, 1.335, 1.438, 1.571, 1.766, 2.067,\n> > > +            2.381, 2.005, 1.739, 1.545, 1.389, 1.278, 1.204, 1.166, 1.153, 1.161, 1.194, 1.263, 1.356, 1.489, 1.671, 1.943,\n> > > +            2.242, 1.899, 1.658, 1.481, 1.329, 1.225, 1.156, 1.113, 1.096, 1.107, 1.143, 1.201, 1.289, 1.423, 1.607, 1.861,\n> > > +            2.152, 1.831, 1.602, 1.436, 1.291, 1.193, 1.121, 1.069, 1.047, 1.062, 1.107, 1.166, 1.249, 1.384, 1.562, 1.801,\n> > > +            2.104, 1.795, 1.572, 1.407, 1.269, 1.174, 1.099, 1.041, 1.008, 1.029, 1.083, 1.146, 1.232, 1.364, 1.547, 1.766,\n> > > +            2.104, 1.796, 1.572, 1.403, 1.264, 1.171, 1.097, 1.036, 1.001, 1.025, 1.077, 1.142, 1.231, 1.363, 1.549, 1.766,\n> > > +            2.148, 1.827, 1.594, 1.413, 1.276, 1.184, 1.114, 1.062, 1.033, 1.049, 1.092, 1.153, 1.242, 1.383, 1.577, 1.795,\n> > > +            2.211, 1.881, 1.636, 1.455, 1.309, 1.214, 1.149, 1.104, 1.081, 1.089, 1.125, 1.184, 1.273, 1.423, 1.622, 1.846,\n> > > +            2.319, 1.958, 1.698, 1.516, 1.362, 1.262, 1.203, 1.156, 1.137, 1.142, 1.171, 1.229, 1.331, 1.484, 1.682, 1.933,\n> > > +            2.459, 2.072, 1.789, 1.594, 1.441, 1.331, 1.261, 1.219, 1.199, 1.205, 1.232, 1.301, 1.414, 1.571, 1.773, 2.052,\n> > > +            2.645, 2.206, 1.928, 1.728, 1.559, 1.451, 1.352, 1.301, 1.282, 1.289, 1.319, 1.395, 1.519, 1.685, 1.904, 2.227\n> > > +        ],\n> > > +        \"sigma\": 0.005,\n> > > +        \"sigma_Cb\": 0.005\n> > > +    },\n> > > +    \"rpi.contrast\":\n> > > +    {\n> > > +        \"ce_enable\": 1,\n> > > +        \"gamma_curve\":\n> > > +        [\n> > > +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n> > > +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> > > +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> > > +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> > > +            65535, 65535\n> > > +        ]\n> > > +    },\n> > > +    \"rpi.sharpen\":\n> > > +    {\n> > > +    },\n> > > +    \"rpi.ccm\":\n> > > +    {\n> > > +        \"ccms\":\n> > > +     [\n> > > +            {\n> > > +             \"ct\": 3900, \"ccm\":\n> > > +             [\n> > > +                 1.54659, -0.17707, -0.36953, -0.51471, 1.72733, -0.21262, 0.06667, -0.92279, 1.85612\n> > > +             ]\n> > > +         }\n> > > +     ]\n> > > +    },\n> > > +    \"rpi.focus\":\n> > > +    {\n> > > +    }\n> > > +}\n> > > diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> > > index 5236bf1e..509ad58b 100644\n> > > --- a/src/ipa/raspberrypi/data/meson.build\n> > > +++ b/src/ipa/raspberrypi/data/meson.build\n> > > @@ -3,6 +3,7 @@\n> > >  conf_files = files([\n> > >      'imx219.json',\n> > >      'imx477.json',\n> > > +    'imx290.json',\n> >\n> > Alphabetical order please.\n> >\n> > >      'ov5647.json',\n> > >      'uncalibrated.json',\n> > >  ])\n> > > diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> > > index 59e49686..7e88f8e0 100644\n> > > --- a/src/ipa/raspberrypi/meson.build\n> > > +++ b/src/ipa/raspberrypi/meson.build\n> > > @@ -21,6 +21,7 @@ rpi_ipa_sources = files([\n> > >      'cam_helper_ov5647.cpp',\n> > >      'cam_helper_imx219.cpp',\n> > >      'cam_helper_imx477.cpp',\n> > > +    'cam_helper_imx290.cpp',\n> >\n> > Here too.\n> \n> Will do! Version 2 of this set incoming shortly.\n> \n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >\n> > >      'controller/controller.cpp',\n> > >      'controller/histogram.cpp',\n> > >      'controller/algorithm.cpp',","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 3701CBD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  8 Mar 2021 22:20:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 71CED68AA4;\n\tMon,  8 Mar 2021 23:20:05 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 664BE602ED\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  8 Mar 2021 23:20:04 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C9A40E7B;\n\tMon,  8 Mar 2021 23:20:03 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Puw00gJ7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1615242004;\n\tbh=/oN3PwZ35pwMkzOHqYg9f/FEpYE0+4/p7lHHuaK3ZB8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Puw00gJ75tyGbbfismJGR98ZJ5bgM0uySUfOv+eDVTTviQ9w1MTiyqcRM9/mHjrYw\n\t1XF3sxWFF+d/BEr1ASLi4wM+m+GM7tqFA6iujUAGWMemo+QBFmvZEQGRvHiVt1+FYd\n\tIIyrWZRypvAMOAoOPwRUr0a58+yEOERCaF0+UDAk=","Date":"Tue, 9 Mar 2021 00:19:33 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YEai9cNXP0mRBo7L@pendragon.ideasonboard.com>","References":"<20210304153120.1904-1-david.plowman@raspberrypi.com>\n\t<20210304153120.1904-3-david.plowman@raspberrypi.com>\n\t<YEZ7aRAOzrtZFRSQ@pendragon.ideasonboard.com>\n\t<CAHW6GYLWOEPoJq0qMhZx0T2c8x8fWMvXUFMewmpfB0oF0ra+8g@mail.gmail.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<CAHW6GYLWOEPoJq0qMhZx0T2c8x8fWMvXUFMewmpfB0oF0ra+8g@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15568,"web_url":"https://patchwork.libcamera.org/comment/15568/","msgid":"<CAPY8ntBmKoBDsQ8pDHgGk_ziA-uQOfURY68H4=N77BcXqJnxqg@mail.gmail.com>","date":"2021-03-09T12:34:48","subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","submitter":{"id":27,"url":"https://patchwork.libcamera.org/api/people/27/","name":"Dave Stevenson","email":"dave.stevenson@raspberrypi.com"},"content":"Hi Laurent & David\n\nOn Mon, 8 Mar 2021 at 22:20, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> On Mon, Mar 08, 2021 at 10:11:35PM +0000, David Plowman wrote:\n> > On Mon, 8 Mar 2021 at 19:31, Laurent Pinchart wrote:\n> > > On Thu, Mar 04, 2021 at 03:31:20PM +0000, David Plowman wrote:\n> > > > imx290 and imx327 share the same kernel driver (imx290.c) and are\n> > > > therefore both recognised here as \"imx290\".\n> > >\n> > > Are there any differences between the two sensors that may need to be\n> > > handled anywhere in libcamera ?\n> >\n> > Good question, and the answer is... I don't really know. I don't have\n> > any modules that I know to have an imx290 in them, but at some point\n> > I'm sure we or someone else will come across one and we'll find out.\n> > At some point some we're going to have to start coping with different\n> > modules with the same (or indistinguishable sensors) in them too.\n>\n> There are two issues here, differences between the IMX290 and IMX327\n> sensors, and differences between modules. For the former, would it make\n> sense to already add a sony,imx327 compatible string to the imx290\n> driver, and make use of it ? To be clear, it's not a blocker for this\n> patch.\n\nI have a mono IMX290 from Vision Components here, as well as several\nIMX327's. Vision Components appear to use literally the same PCB for\nthe two modules - they are both silkscreened IMX327.\n\nIMX290 is the bigger brother to IMX327. It can do 1080p120 (10bit\nonly, 4lane CSI2 at 891Mb/s/lane), whilst IMX327 can only do 1080p60\n(10 or 12bit, 2lane CSI2 at 891Mb/s/lane, or 4lane at 445.5Mb/s/lane).\n\nProgramming interface is identical except for allowing frsel=0 for\n120fps on IMX290.\n\nThe driver is largely Andrey Konovalov's mainline driver with controls\nadded, and support for an alternate source clock frequency\n(74.250MHz).\nIt switches mode based on link frequency, and doesn't support the\n1080p120fps mode, so is actually independent of whether it is 327 or\n290. Based on the link frequency numbers it's a max of 1080p30 on\neither lane configuration, but I thought I'd had 1080p60.\n\nOne to investigate to make the driver more flexible, but shouldn't\naffect libcamera (other than wanting mono support!). The Pi ISP won't\nsupport 1080p120 so is actually of limited interest to us.\n\n  Dave\n\n> > > > We add the necessary\n> > > > CamHelper for these sensors, as well as a camera tuning file.\n> > > >\n> > > > The tuning was done with an Innomaker STARVIS IMX327LQR module. These\n> > > > have no IR cut filter so there is no proper colour tuning. However,\n> > > > you should obtain reasonable results for most modules using this\n> > > > sensor. Specific tunings for further modules can always be added\n> > > > subsequently.\n> > > >\n> > > > To use this sensor on the Raspberry Pi platform, please add\n> > > >\n> > > > dtoverlay=imx290,clock-frequency=74250000\n> > > >\n> > > > into your /boot/config.txt file.\n> > > >\n> > > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > > ---\n> > > >  src/ipa/raspberrypi/cam_helper_imx290.cpp |  67 +++++++++\n> > > >  src/ipa/raspberrypi/data/imx290.json      | 165 ++++++++++++++++++++++\n> > > >  src/ipa/raspberrypi/data/meson.build      |   1 +\n> > > >  src/ipa/raspberrypi/meson.build           |   1 +\n> > > >  4 files changed, 234 insertions(+)\n> > > >  create mode 100644 src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > > >  create mode 100644 src/ipa/raspberrypi/data/imx290.json\n> > > >\n> > > > diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > > > new file mode 100644\n> > > > index 00000000..6f412e40\n> > > > --- /dev/null\n> > > > +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > > > @@ -0,0 +1,67 @@\n> > > > +/* SPDX-License-Identifier: BSD-2-Clause */\n> > > > +/*\n> > > > + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> > > > + *\n> > > > + * cam_helper_imx290.cpp - camera helper for imx290 sensor\n> > > > + */\n> > > > +\n> > > > +#include <math.h>\n> > > > +\n> > > > +#include \"cam_helper.hpp\"\n> > > > +\n> > > > +using namespace RPiController;\n> > > > +\n> > > > +class CamHelperImx290 : public CamHelper\n> > > > +{\n> > > > +public:\n> > > > +     CamHelperImx290();\n> > > > +     uint32_t GainCode(double gain) const override;\n> > > > +     double Gain(uint32_t gain_code) const override;\n> > > > +     void GetDelays(int &exposure_delay, int &gain_delay,\n> > > > +                    int &vblank_delay) 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 = 2;\n> > > > +};\n> > > > +\n> > > > +CamHelperImx290::CamHelperImx290()\n> > > > +     : CamHelper(nullptr, frameIntegrationDiff)\n> > > > +{\n> > > > +}\n> > > > +\n> > > > +uint32_t CamHelperImx290::GainCode(double gain) const\n> > > > +{\n> > > > +     int code = 66.6667 * log10(gain);\n> > > > +     return std::max(0, std::min(code, 0xf0));\n> > > > +}\n> > > > +\n> > > > +double CamHelperImx290::Gain(uint32_t gain_code) const\n> > > > +{\n> > > > +     return pow(10, 0.015 * gain_code);\n> > > > +}\n> > > > +\n> > > > +void CamHelperImx290::GetDelays(int &exposure_delay, int &gain_delay,\n> > > > +                             int &vblank_delay) const\n> > > > +{\n> > > > +     exposure_delay = 2;\n> > > > +     gain_delay = 2;\n> > > > +     vblank_delay = 2;\n> > > > +}\n> > > > +\n> > > > +unsigned int CamHelperImx290::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 CamHelperImx290();\n> > > > +}\n> > > > +\n> > > > +static RegisterCamHelper reg(\"imx290\", &Create);\n> > > > diff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json\n> > > > new file mode 100644\n> > > > index 00000000..6fb92cc4\n> > > > --- /dev/null\n> > > > +++ b/src/ipa/raspberrypi/data/imx290.json\n> > > > @@ -0,0 +1,165 @@\n> > > > +{\n> > > > +    \"rpi.black_level\":\n> > > > +    {\n> > > > +        \"black_level\": 3840\n> > > > +    },\n> > > > +    \"rpi.dpc\":\n> > > > +    {\n> > > > +    },\n> > > > +    \"rpi.lux\":\n> > > > +    {\n> > > > +        \"reference_shutter_speed\": 6813,\n> > > > +        \"reference_gain\": 1.0,\n> > > > +        \"reference_aperture\": 1.0,\n> > > > +        \"reference_lux\": 890,\n> > > > +        \"reference_Y\": 12900\n> > > > +    },\n> > > > +    \"rpi.noise\":\n> > > > +    {\n> > > > +        \"reference_constant\": 0,\n> > > > +        \"reference_slope\": 2.67\n> > > > +    },\n> > > > +    \"rpi.geq\":\n> > > > +    {\n> > > > +        \"offset\": 187,\n> > > > +        \"slope\": 0.00842\n> > > > +    },\n> > > > +    \"rpi.sdn\":\n> > > > +    {\n> > > > +    },\n> > > > +    \"rpi.awb\":\n> > > > +    {\n> > > > +     \"bayes\": 0\n> > > > +    },\n> > > > +    \"rpi.agc\":\n> > > > +    {\n> > > > +     \"speed\": 0.2,\n> > > > +        \"metering_modes\":\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> > > > +            \"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> > > > +        },\n> > > > +        \"exposure_modes\":\n> > > > +        {\n> > > > +            \"normal\":\n> > > > +            {\n> > > > +                \"shutter\":\n> > > > +                [\n> > > > +                    10, 30000, 60000\n> > > > +                ],\n> > > > +                \"gain\":\n> > > > +                [\n> > > > +                    1.0,  2.0,   8.0\n> > > > +                ]\n> > > > +            },\n> > > > +            \"sport\":\n> > > > +            {\n> > > > +                \"shutter\":\n> > > > +                [\n> > > > +                    10, 5000, 10000, 20000, 120000\n> > > > +                ],\n> > > > +                \"gain\":\n> > > > +                [\n> > > > +                    1.0, 2.0, 4.0, 6.0, 6.0\n> > > > +                ]\n> > > > +            }\n> > > > +        },\n> > > > +        \"constraint_modes\":\n> > > > +        {\n> > > > +            \"normal\":\n> > > > +            [\n> > > > +            ],\n> > > > +            \"highlight\":\n> > > > +            [\n> > > > +                {\n> > > > +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> > > > +                    [\n> > > > +                        0, 0.5, 1000, 0.5\n> > > > +                    ]\n> > > > +                },\n> > > > +                {\n> > > > +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> > > > +                    [\n> > > > +                        0, 0.8, 1000, 0.8\n> > > > +                    ]\n> > > > +                }\n> > > > +            ]\n> > > > +        },\n> > > > +        \"y_target\":\n> > > > +        [\n> > > > +            0, 0.16, 1000, 0.16, 10000, 0.16\n> > > > +        ]\n> > > > +    },\n> > > > +    \"rpi.alsc\":\n> > > > +    {\n> > > > +        \"omega\": 1.3,\n> > > > +        \"n_iter\": 100,\n> > > > +        \"luminance_strength\": 0.7,\n> > > > +        \"luminance_lut\":\n> > > > +        [\n> > > > +            2.844, 2.349, 2.018, 1.775, 1.599, 1.466, 1.371, 1.321, 1.306, 1.316, 1.357, 1.439, 1.552, 1.705, 1.915, 2.221,\n> > > > +            2.576, 2.151, 1.851, 1.639, 1.478, 1.358, 1.272, 1.231, 1.218, 1.226, 1.262, 1.335, 1.438, 1.571, 1.766, 2.067,\n> > > > +            2.381, 2.005, 1.739, 1.545, 1.389, 1.278, 1.204, 1.166, 1.153, 1.161, 1.194, 1.263, 1.356, 1.489, 1.671, 1.943,\n> > > > +            2.242, 1.899, 1.658, 1.481, 1.329, 1.225, 1.156, 1.113, 1.096, 1.107, 1.143, 1.201, 1.289, 1.423, 1.607, 1.861,\n> > > > +            2.152, 1.831, 1.602, 1.436, 1.291, 1.193, 1.121, 1.069, 1.047, 1.062, 1.107, 1.166, 1.249, 1.384, 1.562, 1.801,\n> > > > +            2.104, 1.795, 1.572, 1.407, 1.269, 1.174, 1.099, 1.041, 1.008, 1.029, 1.083, 1.146, 1.232, 1.364, 1.547, 1.766,\n> > > > +            2.104, 1.796, 1.572, 1.403, 1.264, 1.171, 1.097, 1.036, 1.001, 1.025, 1.077, 1.142, 1.231, 1.363, 1.549, 1.766,\n> > > > +            2.148, 1.827, 1.594, 1.413, 1.276, 1.184, 1.114, 1.062, 1.033, 1.049, 1.092, 1.153, 1.242, 1.383, 1.577, 1.795,\n> > > > +            2.211, 1.881, 1.636, 1.455, 1.309, 1.214, 1.149, 1.104, 1.081, 1.089, 1.125, 1.184, 1.273, 1.423, 1.622, 1.846,\n> > > > +            2.319, 1.958, 1.698, 1.516, 1.362, 1.262, 1.203, 1.156, 1.137, 1.142, 1.171, 1.229, 1.331, 1.484, 1.682, 1.933,\n> > > > +            2.459, 2.072, 1.789, 1.594, 1.441, 1.331, 1.261, 1.219, 1.199, 1.205, 1.232, 1.301, 1.414, 1.571, 1.773, 2.052,\n> > > > +            2.645, 2.206, 1.928, 1.728, 1.559, 1.451, 1.352, 1.301, 1.282, 1.289, 1.319, 1.395, 1.519, 1.685, 1.904, 2.227\n> > > > +        ],\n> > > > +        \"sigma\": 0.005,\n> > > > +        \"sigma_Cb\": 0.005\n> > > > +    },\n> > > > +    \"rpi.contrast\":\n> > > > +    {\n> > > > +        \"ce_enable\": 1,\n> > > > +        \"gamma_curve\":\n> > > > +        [\n> > > > +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n> > > > +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> > > > +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> > > > +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> > > > +            65535, 65535\n> > > > +        ]\n> > > > +    },\n> > > > +    \"rpi.sharpen\":\n> > > > +    {\n> > > > +    },\n> > > > +    \"rpi.ccm\":\n> > > > +    {\n> > > > +        \"ccms\":\n> > > > +     [\n> > > > +            {\n> > > > +             \"ct\": 3900, \"ccm\":\n> > > > +             [\n> > > > +                 1.54659, -0.17707, -0.36953, -0.51471, 1.72733, -0.21262, 0.06667, -0.92279, 1.85612\n> > > > +             ]\n> > > > +         }\n> > > > +     ]\n> > > > +    },\n> > > > +    \"rpi.focus\":\n> > > > +    {\n> > > > +    }\n> > > > +}\n> > > > diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> > > > index 5236bf1e..509ad58b 100644\n> > > > --- a/src/ipa/raspberrypi/data/meson.build\n> > > > +++ b/src/ipa/raspberrypi/data/meson.build\n> > > > @@ -3,6 +3,7 @@\n> > > >  conf_files = files([\n> > > >      'imx219.json',\n> > > >      'imx477.json',\n> > > > +    'imx290.json',\n> > >\n> > > Alphabetical order please.\n> > >\n> > > >      'ov5647.json',\n> > > >      'uncalibrated.json',\n> > > >  ])\n> > > > diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> > > > index 59e49686..7e88f8e0 100644\n> > > > --- a/src/ipa/raspberrypi/meson.build\n> > > > +++ b/src/ipa/raspberrypi/meson.build\n> > > > @@ -21,6 +21,7 @@ rpi_ipa_sources = files([\n> > > >      'cam_helper_ov5647.cpp',\n> > > >      'cam_helper_imx219.cpp',\n> > > >      'cam_helper_imx477.cpp',\n> > > > +    'cam_helper_imx290.cpp',\n> > >\n> > > Here too.\n> >\n> > Will do! Version 2 of this set incoming shortly.\n> >\n> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > >\n> > > >      'controller/controller.cpp',\n> > > >      'controller/histogram.cpp',\n> > > >      'controller/algorithm.cpp',\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 4618EBD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Mar 2021 12:35:06 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A138668AA3;\n\tTue,  9 Mar 2021 13:35:05 +0100 (CET)","from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com\n\t[IPv6:2a00:1450:4864:20::32c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A046A68A99\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Mar 2021 13:35:03 +0100 (CET)","by mail-wm1-x32c.google.com with SMTP id\n\tf22-20020a7bc8d60000b029010c024a1407so5908008wml.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 09 Mar 2021 04:35:03 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"kv2wsZh7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=C6sF2R2qMyGJ9JG/2f/IhiuzGqeQ8XsscFK4Rr7im/g=;\n\tb=kv2wsZh7g3UVQ9rhbs6k+8AfZ3LQApmPbALhfUI/HztYqn7EGxCdpy42uS909bL/ci\n\tdKsyBF3exTV27Y/q6aJ2xKLTAFC1fPDicXxtrP22lFG2R4wQouBsWThfRNcuU5LBt9sS\n\tJTyXERdiOZGgj8RJi06Mzwo8XCsPCLHFtjyGoBlsQuI0qXl19fhcNPed0g7JvzJpuKso\n\tYpFiU2i6eTjwLsWirLH4VQUbPIgBsUTK7NVYxSKgWRhMXqi6FsWgBB5W/cO3ZN6Z8Co4\n\t2HZEaTXSFvzqzJRBOZJZhTmwfavrx3fiRqLjEe36MI0VHOVWs8pX+W7Ofvev/R5eMTZa\n\tzwWA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=C6sF2R2qMyGJ9JG/2f/IhiuzGqeQ8XsscFK4Rr7im/g=;\n\tb=i9Q4NRKaUNB1y062t66+aTzcLtKhS2Rxr4wiC45f5a26DO/0aTvpIYvU7GCXLV/c66\n\tZCKxRSWFGNaPsakmGGpPKGp92mEL1ntk2nST981omQN/GFa7rn0+6jAuUvbbZr7DuYB9\n\t5K3T1DbWZrUr72hlmJH1vrBV7/2kpecQHFdcv143Vb0qZqVhNLyeMQW1ZVXwUhGFE3Eg\n\tL2AUA0PHW3t/XK26AInkucxX65pkXssRM8JOgcJbyQW/K9mH8DPAGCKqQdk/Tr/qbtjY\n\tpVh4p5AmHURNIfAUsX+JQtxRu4yOqA3nM8mFKK4kcaNB7nEvJxN8QOxn0rlsEhpSTBjJ\n\t5MDA==","X-Gm-Message-State":"AOAM532wnheRL0Z4QRPsDMgU2V+RQ2n2ryQYAmeRv8VoXCKvHiGu4Bn+\n\t5QnMc6P/XKioorDiTZnWz3A2bY2ALgavogZxbSCp9g==","X-Google-Smtp-Source":"ABdhPJyhSdtllKLDWvEF7HYe+xOI70X2/WT47TNlbZdbwNBLOoVzMxuggGyI+EXhtkGUOtaK6YtApvbAgUrLuYGOfPk=","X-Received":"by 2002:a1c:a74b:: with SMTP id\n\tq72mr3757500wme.158.1615293303115; \n\tTue, 09 Mar 2021 04:35:03 -0800 (PST)","MIME-Version":"1.0","References":"<20210304153120.1904-1-david.plowman@raspberrypi.com>\n\t<20210304153120.1904-3-david.plowman@raspberrypi.com>\n\t<YEZ7aRAOzrtZFRSQ@pendragon.ideasonboard.com>\n\t<CAHW6GYLWOEPoJq0qMhZx0T2c8x8fWMvXUFMewmpfB0oF0ra+8g@mail.gmail.com>\n\t<YEai9cNXP0mRBo7L@pendragon.ideasonboard.com>","In-Reply-To":"<YEai9cNXP0mRBo7L@pendragon.ideasonboard.com>","From":"Dave Stevenson <dave.stevenson@raspberrypi.com>","Date":"Tue, 9 Mar 2021 12:34:48 +0000","Message-ID":"<CAPY8ntBmKoBDsQ8pDHgGk_ziA-uQOfURY68H4=N77BcXqJnxqg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15575,"web_url":"https://patchwork.libcamera.org/comment/15575/","msgid":"<a56d2315-e967-8b5e-d507-6f9aef355c93@linaro.org>","date":"2021-03-09T18:28:24","subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","submitter":{"id":25,"url":"https://patchwork.libcamera.org/api/people/25/","name":"Andrey Konovalov","email":"andrey.konovalov@linaro.org"},"content":"Hi Dave,\n\nOne correction below...\n\nOn 09.03.2021 15:34, Dave Stevenson wrote:\n> Hi Laurent & David\n> \n> On Mon, 8 Mar 2021 at 22:20, Laurent Pinchart\n> <laurent.pinchart@ideasonboard.com> wrote:\n>>\n>> Hi David,\n>>\n>> On Mon, Mar 08, 2021 at 10:11:35PM +0000, David Plowman wrote:\n>>> On Mon, 8 Mar 2021 at 19:31, Laurent Pinchart wrote:\n>>>> On Thu, Mar 04, 2021 at 03:31:20PM +0000, David Plowman wrote:\n>>>>> imx290 and imx327 share the same kernel driver (imx290.c) and are\n>>>>> therefore both recognised here as \"imx290\".\n>>>>\n>>>> Are there any differences between the two sensors that may need to be\n>>>> handled anywhere in libcamera ?\n>>>\n>>> Good question, and the answer is... I don't really know. I don't have\n>>> any modules that I know to have an imx290 in them, but at some point\n>>> I'm sure we or someone else will come across one and we'll find out.\n>>> At some point some we're going to have to start coping with different\n>>> modules with the same (or indistinguishable sensors) in them too.\n>>\n>> There are two issues here, differences between the IMX290 and IMX327\n>> sensors, and differences between modules. For the former, would it make\n>> sense to already add a sony,imx327 compatible string to the imx290\n>> driver, and make use of it ? To be clear, it's not a blocker for this\n>> patch.\n> \n> I have a mono IMX290 from Vision Components here, as well as several\n> IMX327's. Vision Components appear to use literally the same PCB for\n> the two modules - they are both silkscreened IMX327.\n> \n> IMX290 is the bigger brother to IMX327. It can do 1080p120 (10bit\n> only, 4lane CSI2 at 891Mb/s/lane), whilst IMX327 can only do 1080p60\n> (10 or 12bit, 2lane CSI2 at 891Mb/s/lane, or 4lane at 445.5Mb/s/lane).\n> \n> Programming interface is identical except for allowing frsel=0 for\n> 120fps on IMX290.\n> \n> The driver is largely Andrey Konovalov's mainline driver\n\nThe original author and the maintainer is Manivannan Sadhasivam.\nI did add some changes on top of his work :)\n\nThanks,\nAndrey\n\n> with controls\n> added, and support for an alternate source clock frequency\n> (74.250MHz).\n> It switches mode based on link frequency, and doesn't support the\n> 1080p120fps mode, so is actually independent of whether it is 327 or\n> 290. Based on the link frequency numbers it's a max of 1080p30 on\n> either lane configuration, but I thought I'd had 1080p60.\n> \n> One to investigate to make the driver more flexible, but shouldn't\n> affect libcamera (other than wanting mono support!). The Pi ISP won't\n> support 1080p120 so is actually of limited interest to us.\n> \n>    Dave\n> \n>>>>> We add the necessary\n>>>>> CamHelper for these sensors, as well as a camera tuning file.\n>>>>>\n>>>>> The tuning was done with an Innomaker STARVIS IMX327LQR module. These\n>>>>> have no IR cut filter so there is no proper colour tuning. However,\n>>>>> you should obtain reasonable results for most modules using this\n>>>>> sensor. Specific tunings for further modules can always be added\n>>>>> subsequently.\n>>>>>\n>>>>> To use this sensor on the Raspberry Pi platform, please add\n>>>>>\n>>>>> dtoverlay=imx290,clock-frequency=74250000\n>>>>>\n>>>>> into your /boot/config.txt file.\n>>>>>\n>>>>> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>>>>> ---\n>>>>>   src/ipa/raspberrypi/cam_helper_imx290.cpp |  67 +++++++++\n>>>>>   src/ipa/raspberrypi/data/imx290.json      | 165 ++++++++++++++++++++++\n>>>>>   src/ipa/raspberrypi/data/meson.build      |   1 +\n>>>>>   src/ipa/raspberrypi/meson.build           |   1 +\n>>>>>   4 files changed, 234 insertions(+)\n>>>>>   create mode 100644 src/ipa/raspberrypi/cam_helper_imx290.cpp\n>>>>>   create mode 100644 src/ipa/raspberrypi/data/imx290.json\n>>>>>\n>>>>> diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n>>>>> new file mode 100644\n>>>>> index 00000000..6f412e40\n>>>>> --- /dev/null\n>>>>> +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n>>>>> @@ -0,0 +1,67 @@\n>>>>> +/* SPDX-License-Identifier: BSD-2-Clause */\n>>>>> +/*\n>>>>> + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n>>>>> + *\n>>>>> + * cam_helper_imx290.cpp - camera helper for imx290 sensor\n>>>>> + */\n>>>>> +\n>>>>> +#include <math.h>\n>>>>> +\n>>>>> +#include \"cam_helper.hpp\"\n>>>>> +\n>>>>> +using namespace RPiController;\n>>>>> +\n>>>>> +class CamHelperImx290 : public CamHelper\n>>>>> +{\n>>>>> +public:\n>>>>> +     CamHelperImx290();\n>>>>> +     uint32_t GainCode(double gain) const override;\n>>>>> +     double Gain(uint32_t gain_code) const override;\n>>>>> +     void GetDelays(int &exposure_delay, int &gain_delay,\n>>>>> +                    int &vblank_delay) 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 = 2;\n>>>>> +};\n>>>>> +\n>>>>> +CamHelperImx290::CamHelperImx290()\n>>>>> +     : CamHelper(nullptr, frameIntegrationDiff)\n>>>>> +{\n>>>>> +}\n>>>>> +\n>>>>> +uint32_t CamHelperImx290::GainCode(double gain) const\n>>>>> +{\n>>>>> +     int code = 66.6667 * log10(gain);\n>>>>> +     return std::max(0, std::min(code, 0xf0));\n>>>>> +}\n>>>>> +\n>>>>> +double CamHelperImx290::Gain(uint32_t gain_code) const\n>>>>> +{\n>>>>> +     return pow(10, 0.015 * gain_code);\n>>>>> +}\n>>>>> +\n>>>>> +void CamHelperImx290::GetDelays(int &exposure_delay, int &gain_delay,\n>>>>> +                             int &vblank_delay) const\n>>>>> +{\n>>>>> +     exposure_delay = 2;\n>>>>> +     gain_delay = 2;\n>>>>> +     vblank_delay = 2;\n>>>>> +}\n>>>>> +\n>>>>> +unsigned int CamHelperImx290::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 CamHelperImx290();\n>>>>> +}\n>>>>> +\n>>>>> +static RegisterCamHelper reg(\"imx290\", &Create);\n>>>>> diff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json\n>>>>> new file mode 100644\n>>>>> index 00000000..6fb92cc4\n>>>>> --- /dev/null\n>>>>> +++ b/src/ipa/raspberrypi/data/imx290.json\n>>>>> @@ -0,0 +1,165 @@\n>>>>> +{\n>>>>> +    \"rpi.black_level\":\n>>>>> +    {\n>>>>> +        \"black_level\": 3840\n>>>>> +    },\n>>>>> +    \"rpi.dpc\":\n>>>>> +    {\n>>>>> +    },\n>>>>> +    \"rpi.lux\":\n>>>>> +    {\n>>>>> +        \"reference_shutter_speed\": 6813,\n>>>>> +        \"reference_gain\": 1.0,\n>>>>> +        \"reference_aperture\": 1.0,\n>>>>> +        \"reference_lux\": 890,\n>>>>> +        \"reference_Y\": 12900\n>>>>> +    },\n>>>>> +    \"rpi.noise\":\n>>>>> +    {\n>>>>> +        \"reference_constant\": 0,\n>>>>> +        \"reference_slope\": 2.67\n>>>>> +    },\n>>>>> +    \"rpi.geq\":\n>>>>> +    {\n>>>>> +        \"offset\": 187,\n>>>>> +        \"slope\": 0.00842\n>>>>> +    },\n>>>>> +    \"rpi.sdn\":\n>>>>> +    {\n>>>>> +    },\n>>>>> +    \"rpi.awb\":\n>>>>> +    {\n>>>>> +     \"bayes\": 0\n>>>>> +    },\n>>>>> +    \"rpi.agc\":\n>>>>> +    {\n>>>>> +     \"speed\": 0.2,\n>>>>> +        \"metering_modes\":\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>>>>> +            \"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>>>>> +        },\n>>>>> +        \"exposure_modes\":\n>>>>> +        {\n>>>>> +            \"normal\":\n>>>>> +            {\n>>>>> +                \"shutter\":\n>>>>> +                [\n>>>>> +                    10, 30000, 60000\n>>>>> +                ],\n>>>>> +                \"gain\":\n>>>>> +                [\n>>>>> +                    1.0,  2.0,   8.0\n>>>>> +                ]\n>>>>> +            },\n>>>>> +            \"sport\":\n>>>>> +            {\n>>>>> +                \"shutter\":\n>>>>> +                [\n>>>>> +                    10, 5000, 10000, 20000, 120000\n>>>>> +                ],\n>>>>> +                \"gain\":\n>>>>> +                [\n>>>>> +                    1.0, 2.0, 4.0, 6.0, 6.0\n>>>>> +                ]\n>>>>> +            }\n>>>>> +        },\n>>>>> +        \"constraint_modes\":\n>>>>> +        {\n>>>>> +            \"normal\":\n>>>>> +            [\n>>>>> +            ],\n>>>>> +            \"highlight\":\n>>>>> +            [\n>>>>> +                {\n>>>>> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n>>>>> +                    [\n>>>>> +                        0, 0.5, 1000, 0.5\n>>>>> +                    ]\n>>>>> +                },\n>>>>> +                {\n>>>>> +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n>>>>> +                    [\n>>>>> +                        0, 0.8, 1000, 0.8\n>>>>> +                    ]\n>>>>> +                }\n>>>>> +            ]\n>>>>> +        },\n>>>>> +        \"y_target\":\n>>>>> +        [\n>>>>> +            0, 0.16, 1000, 0.16, 10000, 0.16\n>>>>> +        ]\n>>>>> +    },\n>>>>> +    \"rpi.alsc\":\n>>>>> +    {\n>>>>> +        \"omega\": 1.3,\n>>>>> +        \"n_iter\": 100,\n>>>>> +        \"luminance_strength\": 0.7,\n>>>>> +        \"luminance_lut\":\n>>>>> +        [\n>>>>> +            2.844, 2.349, 2.018, 1.775, 1.599, 1.466, 1.371, 1.321, 1.306, 1.316, 1.357, 1.439, 1.552, 1.705, 1.915, 2.221,\n>>>>> +            2.576, 2.151, 1.851, 1.639, 1.478, 1.358, 1.272, 1.231, 1.218, 1.226, 1.262, 1.335, 1.438, 1.571, 1.766, 2.067,\n>>>>> +            2.381, 2.005, 1.739, 1.545, 1.389, 1.278, 1.204, 1.166, 1.153, 1.161, 1.194, 1.263, 1.356, 1.489, 1.671, 1.943,\n>>>>> +            2.242, 1.899, 1.658, 1.481, 1.329, 1.225, 1.156, 1.113, 1.096, 1.107, 1.143, 1.201, 1.289, 1.423, 1.607, 1.861,\n>>>>> +            2.152, 1.831, 1.602, 1.436, 1.291, 1.193, 1.121, 1.069, 1.047, 1.062, 1.107, 1.166, 1.249, 1.384, 1.562, 1.801,\n>>>>> +            2.104, 1.795, 1.572, 1.407, 1.269, 1.174, 1.099, 1.041, 1.008, 1.029, 1.083, 1.146, 1.232, 1.364, 1.547, 1.766,\n>>>>> +            2.104, 1.796, 1.572, 1.403, 1.264, 1.171, 1.097, 1.036, 1.001, 1.025, 1.077, 1.142, 1.231, 1.363, 1.549, 1.766,\n>>>>> +            2.148, 1.827, 1.594, 1.413, 1.276, 1.184, 1.114, 1.062, 1.033, 1.049, 1.092, 1.153, 1.242, 1.383, 1.577, 1.795,\n>>>>> +            2.211, 1.881, 1.636, 1.455, 1.309, 1.214, 1.149, 1.104, 1.081, 1.089, 1.125, 1.184, 1.273, 1.423, 1.622, 1.846,\n>>>>> +            2.319, 1.958, 1.698, 1.516, 1.362, 1.262, 1.203, 1.156, 1.137, 1.142, 1.171, 1.229, 1.331, 1.484, 1.682, 1.933,\n>>>>> +            2.459, 2.072, 1.789, 1.594, 1.441, 1.331, 1.261, 1.219, 1.199, 1.205, 1.232, 1.301, 1.414, 1.571, 1.773, 2.052,\n>>>>> +            2.645, 2.206, 1.928, 1.728, 1.559, 1.451, 1.352, 1.301, 1.282, 1.289, 1.319, 1.395, 1.519, 1.685, 1.904, 2.227\n>>>>> +        ],\n>>>>> +        \"sigma\": 0.005,\n>>>>> +        \"sigma_Cb\": 0.005\n>>>>> +    },\n>>>>> +    \"rpi.contrast\":\n>>>>> +    {\n>>>>> +        \"ce_enable\": 1,\n>>>>> +        \"gamma_curve\":\n>>>>> +        [\n>>>>> +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n>>>>> +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n>>>>> +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n>>>>> +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n>>>>> +            65535, 65535\n>>>>> +        ]\n>>>>> +    },\n>>>>> +    \"rpi.sharpen\":\n>>>>> +    {\n>>>>> +    },\n>>>>> +    \"rpi.ccm\":\n>>>>> +    {\n>>>>> +        \"ccms\":\n>>>>> +     [\n>>>>> +            {\n>>>>> +             \"ct\": 3900, \"ccm\":\n>>>>> +             [\n>>>>> +                 1.54659, -0.17707, -0.36953, -0.51471, 1.72733, -0.21262, 0.06667, -0.92279, 1.85612\n>>>>> +             ]\n>>>>> +         }\n>>>>> +     ]\n>>>>> +    },\n>>>>> +    \"rpi.focus\":\n>>>>> +    {\n>>>>> +    }\n>>>>> +}\n>>>>> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n>>>>> index 5236bf1e..509ad58b 100644\n>>>>> --- a/src/ipa/raspberrypi/data/meson.build\n>>>>> +++ b/src/ipa/raspberrypi/data/meson.build\n>>>>> @@ -3,6 +3,7 @@\n>>>>>   conf_files = files([\n>>>>>       'imx219.json',\n>>>>>       'imx477.json',\n>>>>> +    'imx290.json',\n>>>>\n>>>> Alphabetical order please.\n>>>>\n>>>>>       'ov5647.json',\n>>>>>       'uncalibrated.json',\n>>>>>   ])\n>>>>> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n>>>>> index 59e49686..7e88f8e0 100644\n>>>>> --- a/src/ipa/raspberrypi/meson.build\n>>>>> +++ b/src/ipa/raspberrypi/meson.build\n>>>>> @@ -21,6 +21,7 @@ rpi_ipa_sources = files([\n>>>>>       'cam_helper_ov5647.cpp',\n>>>>>       'cam_helper_imx219.cpp',\n>>>>>       'cam_helper_imx477.cpp',\n>>>>> +    'cam_helper_imx290.cpp',\n>>>>\n>>>> Here too.\n>>>\n>>> Will do! Version 2 of this set incoming shortly.\n>>>\n>>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>>>>\n>>>>>       'controller/controller.cpp',\n>>>>>       'controller/histogram.cpp',\n>>>>>       'controller/algorithm.cpp',\n>>\n>> --\n>> Regards,\n>>\n>> Laurent Pinchart\n>> _______________________________________________\n>> libcamera-devel mailing list\n>> libcamera-devel@lists.libcamera.org\n>> https://lists.libcamera.org/listinfo/libcamera-devel\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel\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 B3D35BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Mar 2021 18:28:30 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1FAF768A9C;\n\tTue,  9 Mar 2021 19:28:30 +0100 (CET)","from mail-lf1-x136.google.com (mail-lf1-x136.google.com\n\t[IPv6:2a00:1450:4864:20::136])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 231B268A99\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Mar 2021 19:28:28 +0100 (CET)","by mail-lf1-x136.google.com with SMTP id f1so28744449lfu.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 09 Mar 2021 10:28:28 -0800 (PST)","from [192.168.118.216] ([85.249.43.69])\n\tby smtp.gmail.com with ESMTPSA id\n\tt201sm2065148lff.70.2021.03.09.10.28.25\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tTue, 09 Mar 2021 10:28:25 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"rTzExuYz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=subject:to:cc:references:from:message-id:date:user-agent\n\t:mime-version:in-reply-to:content-language:content-transfer-encoding; \n\tbh=PHAihXxkTloIOasFcTh3EqKKCPKIAUv8BSMaZVHUoYk=;\n\tb=rTzExuYzDE4PVX6Zoz9oiGr+MdiIIF5pLhyyN/tOZ/K/+TUytG6kJPYKTwuBl9qU+y\n\trmLhNpdM2HuvDY5wEmJ/l/tkdCAE2scpRmxhQCXh/LM6qJWkXirKv6MnSeGpHwcwmFbS\n\t0i0fF2hWcvzXgclEZdcpxmafQ3bkkOGNW0tC71fS/UPoK8snbTvKa2Pv194/+YtXUhWu\n\tFhCOUISW8dxX3C+sw7hnO5SwwDoQmcWUegL9DmPjDx9WqqhOy3xFjThJCIxl6S7ZiDIu\n\t5hAXHJaBekunliA/oim2Hstksyl6FRYwqlZMQHn7pBBHf1Mqw+nkZ8Euft/4CGCZkQqO\n\t7hPw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:subject:to:cc:references:from:message-id:date\n\t:user-agent:mime-version:in-reply-to:content-language\n\t:content-transfer-encoding;\n\tbh=PHAihXxkTloIOasFcTh3EqKKCPKIAUv8BSMaZVHUoYk=;\n\tb=m/uG+nQYG56lupZ5Ai6toXxXY2JHC01aWof+PWb7In/EwIJKHuMSTF2oVWd2ZEk99b\n\turI+dOwzUw51PkGxQh/Ed3QwnEjXYCmtNPctcSpwtl4Dw0g/qDdqBdDwTp3CCSMGQnH8\n\tmdDjcdTTVefZ5cXjEifMs/9mDGpZHxkRsrCAwf2zjAQrqcnJm7nprJl6cZKf2nm3Wf0k\n\tkAo0kxR3aabQjvTzouWEgj1A8t878MzNqUUNf8n2GY284A2uCiI6+Qqu/YholxQCucFG\n\ttJ8WbScMYpcTH/E9EGm60lcbfEdp2bqmNf8j9WxGA0+rO2hpjqmsP2xnfuNzUQRihPSq\n\t9ubQ==","X-Gm-Message-State":"AOAM530EIrl9rVlJz6eCya/HdwmlEc2v1YrL5OHthKBsN+4fNzrOIUid\n\tUyt3nbhCzbog+VMdlsHgj1NcCA==","X-Google-Smtp-Source":"ABdhPJwdDrx8FkhOihOM2Kk+lAQrrE9wnONfdja7XHILBeyJOCEhUPXHrPZRQbrCqD7yzzvSllwx3Q==","X-Received":"by 2002:a05:6512:32ab:: with SMTP id\n\tq11mr18219945lfe.106.1615314507224; \n\tTue, 09 Mar 2021 10:28:27 -0800 (PST)","To":"Dave Stevenson <dave.stevenson@raspberrypi.com>","References":"<20210304153120.1904-1-david.plowman@raspberrypi.com>\n\t<20210304153120.1904-3-david.plowman@raspberrypi.com>\n\t<YEZ7aRAOzrtZFRSQ@pendragon.ideasonboard.com>\n\t<CAHW6GYLWOEPoJq0qMhZx0T2c8x8fWMvXUFMewmpfB0oF0ra+8g@mail.gmail.com>\n\t<YEai9cNXP0mRBo7L@pendragon.ideasonboard.com>\n\t<CAPY8ntBmKoBDsQ8pDHgGk_ziA-uQOfURY68H4=N77BcXqJnxqg@mail.gmail.com>","From":"Andrey Konovalov <andrey.konovalov@linaro.org>","Message-ID":"<a56d2315-e967-8b5e-d507-6f9aef355c93@linaro.org>","Date":"Tue, 9 Mar 2021 21:28:24 +0300","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<CAPY8ntBmKoBDsQ8pDHgGk_ziA-uQOfURY68H4=N77BcXqJnxqg@mail.gmail.com>","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Transfer-Encoding":"7bit","Content-Type":"text/plain; charset=\"us-ascii\"; Format=\"flowed\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15576,"web_url":"https://patchwork.libcamera.org/comment/15576/","msgid":"<CAPY8ntCJ3o1NRH_0aLxSPkarptgJrAiY0+PuHt1Y7QFNZfysbg@mail.gmail.com>","date":"2021-03-09T18:42:04","subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","submitter":{"id":27,"url":"https://patchwork.libcamera.org/api/people/27/","name":"Dave Stevenson","email":"dave.stevenson@raspberrypi.com"},"content":"Hi Andrey\n\nOn Tue, 9 Mar 2021 at 18:28, Andrey Konovalov\n<andrey.konovalov@linaro.org> wrote:\n>\n> Hi Dave,\n>\n> One correction below...\n>\n> On 09.03.2021 15:34, Dave Stevenson wrote:\n> > Hi Laurent & David\n> >\n> > On Mon, 8 Mar 2021 at 22:20, Laurent Pinchart\n> > <laurent.pinchart@ideasonboard.com> wrote:\n> >>\n> >> Hi David,\n> >>\n> >> On Mon, Mar 08, 2021 at 10:11:35PM +0000, David Plowman wrote:\n> >>> On Mon, 8 Mar 2021 at 19:31, Laurent Pinchart wrote:\n> >>>> On Thu, Mar 04, 2021 at 03:31:20PM +0000, David Plowman wrote:\n> >>>>> imx290 and imx327 share the same kernel driver (imx290.c) and are\n> >>>>> therefore both recognised here as \"imx290\".\n> >>>>\n> >>>> Are there any differences between the two sensors that may need to be\n> >>>> handled anywhere in libcamera ?\n> >>>\n> >>> Good question, and the answer is... I don't really know. I don't have\n> >>> any modules that I know to have an imx290 in them, but at some point\n> >>> I'm sure we or someone else will come across one and we'll find out.\n> >>> At some point some we're going to have to start coping with different\n> >>> modules with the same (or indistinguishable sensors) in them too.\n> >>\n> >> There are two issues here, differences between the IMX290 and IMX327\n> >> sensors, and differences between modules. For the former, would it make\n> >> sense to already add a sony,imx327 compatible string to the imx290\n> >> driver, and make use of it ? To be clear, it's not a blocker for this\n> >> patch.\n> >\n> > I have a mono IMX290 from Vision Components here, as well as several\n> > IMX327's. Vision Components appear to use literally the same PCB for\n> > the two modules - they are both silkscreened IMX327.\n> >\n> > IMX290 is the bigger brother to IMX327. It can do 1080p120 (10bit\n> > only, 4lane CSI2 at 891Mb/s/lane), whilst IMX327 can only do 1080p60\n> > (10 or 12bit, 2lane CSI2 at 891Mb/s/lane, or 4lane at 445.5Mb/s/lane).\n> >\n> > Programming interface is identical except for allowing frsel=0 for\n> > 120fps on IMX290.\n> >\n> > The driver is largely Andrey Konovalov's mainline driver\n>\n> The original author and the maintainer is Manivannan Sadhasivam.\n> I did add some changes on top of his work :)\n\nWhoops! My apologies to Manivannan, and thanks to you for the correction.\nI must confess to having looked at the recent mainline commits to the\ndriver rather than checking who was listed as the maintainer.\n\n  Dave\n\n> Thanks,\n> Andrey\n>\n> > with controls\n> > added, and support for an alternate source clock frequency\n> > (74.250MHz).\n> > It switches mode based on link frequency, and doesn't support the\n> > 1080p120fps mode, so is actually independent of whether it is 327 or\n> > 290. Based on the link frequency numbers it's a max of 1080p30 on\n> > either lane configuration, but I thought I'd had 1080p60.\n> >\n> > One to investigate to make the driver more flexible, but shouldn't\n> > affect libcamera (other than wanting mono support!). The Pi ISP won't\n> > support 1080p120 so is actually of limited interest to us.\n> >\n> >    Dave\n> >\n> >>>>> We add the necessary\n> >>>>> CamHelper for these sensors, as well as a camera tuning file.\n> >>>>>\n> >>>>> The tuning was done with an Innomaker STARVIS IMX327LQR module. These\n> >>>>> have no IR cut filter so there is no proper colour tuning. However,\n> >>>>> you should obtain reasonable results for most modules using this\n> >>>>> sensor. Specific tunings for further modules can always be added\n> >>>>> subsequently.\n> >>>>>\n> >>>>> To use this sensor on the Raspberry Pi platform, please add\n> >>>>>\n> >>>>> dtoverlay=imx290,clock-frequency=74250000\n> >>>>>\n> >>>>> into your /boot/config.txt file.\n> >>>>>\n> >>>>> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> >>>>> ---\n> >>>>>   src/ipa/raspberrypi/cam_helper_imx290.cpp |  67 +++++++++\n> >>>>>   src/ipa/raspberrypi/data/imx290.json      | 165 ++++++++++++++++++++++\n> >>>>>   src/ipa/raspberrypi/data/meson.build      |   1 +\n> >>>>>   src/ipa/raspberrypi/meson.build           |   1 +\n> >>>>>   4 files changed, 234 insertions(+)\n> >>>>>   create mode 100644 src/ipa/raspberrypi/cam_helper_imx290.cpp\n> >>>>>   create mode 100644 src/ipa/raspberrypi/data/imx290.json\n> >>>>>\n> >>>>> diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> >>>>> new file mode 100644\n> >>>>> index 00000000..6f412e40\n> >>>>> --- /dev/null\n> >>>>> +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> >>>>> @@ -0,0 +1,67 @@\n> >>>>> +/* SPDX-License-Identifier: BSD-2-Clause */\n> >>>>> +/*\n> >>>>> + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> >>>>> + *\n> >>>>> + * cam_helper_imx290.cpp - camera helper for imx290 sensor\n> >>>>> + */\n> >>>>> +\n> >>>>> +#include <math.h>\n> >>>>> +\n> >>>>> +#include \"cam_helper.hpp\"\n> >>>>> +\n> >>>>> +using namespace RPiController;\n> >>>>> +\n> >>>>> +class CamHelperImx290 : public CamHelper\n> >>>>> +{\n> >>>>> +public:\n> >>>>> +     CamHelperImx290();\n> >>>>> +     uint32_t GainCode(double gain) const override;\n> >>>>> +     double Gain(uint32_t gain_code) const override;\n> >>>>> +     void GetDelays(int &exposure_delay, int &gain_delay,\n> >>>>> +                    int &vblank_delay) 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 = 2;\n> >>>>> +};\n> >>>>> +\n> >>>>> +CamHelperImx290::CamHelperImx290()\n> >>>>> +     : CamHelper(nullptr, frameIntegrationDiff)\n> >>>>> +{\n> >>>>> +}\n> >>>>> +\n> >>>>> +uint32_t CamHelperImx290::GainCode(double gain) const\n> >>>>> +{\n> >>>>> +     int code = 66.6667 * log10(gain);\n> >>>>> +     return std::max(0, std::min(code, 0xf0));\n> >>>>> +}\n> >>>>> +\n> >>>>> +double CamHelperImx290::Gain(uint32_t gain_code) const\n> >>>>> +{\n> >>>>> +     return pow(10, 0.015 * gain_code);\n> >>>>> +}\n> >>>>> +\n> >>>>> +void CamHelperImx290::GetDelays(int &exposure_delay, int &gain_delay,\n> >>>>> +                             int &vblank_delay) const\n> >>>>> +{\n> >>>>> +     exposure_delay = 2;\n> >>>>> +     gain_delay = 2;\n> >>>>> +     vblank_delay = 2;\n> >>>>> +}\n> >>>>> +\n> >>>>> +unsigned int CamHelperImx290::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 CamHelperImx290();\n> >>>>> +}\n> >>>>> +\n> >>>>> +static RegisterCamHelper reg(\"imx290\", &Create);\n> >>>>> diff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json\n> >>>>> new file mode 100644\n> >>>>> index 00000000..6fb92cc4\n> >>>>> --- /dev/null\n> >>>>> +++ b/src/ipa/raspberrypi/data/imx290.json\n> >>>>> @@ -0,0 +1,165 @@\n> >>>>> +{\n> >>>>> +    \"rpi.black_level\":\n> >>>>> +    {\n> >>>>> +        \"black_level\": 3840\n> >>>>> +    },\n> >>>>> +    \"rpi.dpc\":\n> >>>>> +    {\n> >>>>> +    },\n> >>>>> +    \"rpi.lux\":\n> >>>>> +    {\n> >>>>> +        \"reference_shutter_speed\": 6813,\n> >>>>> +        \"reference_gain\": 1.0,\n> >>>>> +        \"reference_aperture\": 1.0,\n> >>>>> +        \"reference_lux\": 890,\n> >>>>> +        \"reference_Y\": 12900\n> >>>>> +    },\n> >>>>> +    \"rpi.noise\":\n> >>>>> +    {\n> >>>>> +        \"reference_constant\": 0,\n> >>>>> +        \"reference_slope\": 2.67\n> >>>>> +    },\n> >>>>> +    \"rpi.geq\":\n> >>>>> +    {\n> >>>>> +        \"offset\": 187,\n> >>>>> +        \"slope\": 0.00842\n> >>>>> +    },\n> >>>>> +    \"rpi.sdn\":\n> >>>>> +    {\n> >>>>> +    },\n> >>>>> +    \"rpi.awb\":\n> >>>>> +    {\n> >>>>> +     \"bayes\": 0\n> >>>>> +    },\n> >>>>> +    \"rpi.agc\":\n> >>>>> +    {\n> >>>>> +     \"speed\": 0.2,\n> >>>>> +        \"metering_modes\":\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> >>>>> +            \"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> >>>>> +        },\n> >>>>> +        \"exposure_modes\":\n> >>>>> +        {\n> >>>>> +            \"normal\":\n> >>>>> +            {\n> >>>>> +                \"shutter\":\n> >>>>> +                [\n> >>>>> +                    10, 30000, 60000\n> >>>>> +                ],\n> >>>>> +                \"gain\":\n> >>>>> +                [\n> >>>>> +                    1.0,  2.0,   8.0\n> >>>>> +                ]\n> >>>>> +            },\n> >>>>> +            \"sport\":\n> >>>>> +            {\n> >>>>> +                \"shutter\":\n> >>>>> +                [\n> >>>>> +                    10, 5000, 10000, 20000, 120000\n> >>>>> +                ],\n> >>>>> +                \"gain\":\n> >>>>> +                [\n> >>>>> +                    1.0, 2.0, 4.0, 6.0, 6.0\n> >>>>> +                ]\n> >>>>> +            }\n> >>>>> +        },\n> >>>>> +        \"constraint_modes\":\n> >>>>> +        {\n> >>>>> +            \"normal\":\n> >>>>> +            [\n> >>>>> +            ],\n> >>>>> +            \"highlight\":\n> >>>>> +            [\n> >>>>> +                {\n> >>>>> +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> >>>>> +                    [\n> >>>>> +                        0, 0.5, 1000, 0.5\n> >>>>> +                    ]\n> >>>>> +                },\n> >>>>> +                {\n> >>>>> +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> >>>>> +                    [\n> >>>>> +                        0, 0.8, 1000, 0.8\n> >>>>> +                    ]\n> >>>>> +                }\n> >>>>> +            ]\n> >>>>> +        },\n> >>>>> +        \"y_target\":\n> >>>>> +        [\n> >>>>> +            0, 0.16, 1000, 0.16, 10000, 0.16\n> >>>>> +        ]\n> >>>>> +    },\n> >>>>> +    \"rpi.alsc\":\n> >>>>> +    {\n> >>>>> +        \"omega\": 1.3,\n> >>>>> +        \"n_iter\": 100,\n> >>>>> +        \"luminance_strength\": 0.7,\n> >>>>> +        \"luminance_lut\":\n> >>>>> +        [\n> >>>>> +            2.844, 2.349, 2.018, 1.775, 1.599, 1.466, 1.371, 1.321, 1.306, 1.316, 1.357, 1.439, 1.552, 1.705, 1.915, 2.221,\n> >>>>> +            2.576, 2.151, 1.851, 1.639, 1.478, 1.358, 1.272, 1.231, 1.218, 1.226, 1.262, 1.335, 1.438, 1.571, 1.766, 2.067,\n> >>>>> +            2.381, 2.005, 1.739, 1.545, 1.389, 1.278, 1.204, 1.166, 1.153, 1.161, 1.194, 1.263, 1.356, 1.489, 1.671, 1.943,\n> >>>>> +            2.242, 1.899, 1.658, 1.481, 1.329, 1.225, 1.156, 1.113, 1.096, 1.107, 1.143, 1.201, 1.289, 1.423, 1.607, 1.861,\n> >>>>> +            2.152, 1.831, 1.602, 1.436, 1.291, 1.193, 1.121, 1.069, 1.047, 1.062, 1.107, 1.166, 1.249, 1.384, 1.562, 1.801,\n> >>>>> +            2.104, 1.795, 1.572, 1.407, 1.269, 1.174, 1.099, 1.041, 1.008, 1.029, 1.083, 1.146, 1.232, 1.364, 1.547, 1.766,\n> >>>>> +            2.104, 1.796, 1.572, 1.403, 1.264, 1.171, 1.097, 1.036, 1.001, 1.025, 1.077, 1.142, 1.231, 1.363, 1.549, 1.766,\n> >>>>> +            2.148, 1.827, 1.594, 1.413, 1.276, 1.184, 1.114, 1.062, 1.033, 1.049, 1.092, 1.153, 1.242, 1.383, 1.577, 1.795,\n> >>>>> +            2.211, 1.881, 1.636, 1.455, 1.309, 1.214, 1.149, 1.104, 1.081, 1.089, 1.125, 1.184, 1.273, 1.423, 1.622, 1.846,\n> >>>>> +            2.319, 1.958, 1.698, 1.516, 1.362, 1.262, 1.203, 1.156, 1.137, 1.142, 1.171, 1.229, 1.331, 1.484, 1.682, 1.933,\n> >>>>> +            2.459, 2.072, 1.789, 1.594, 1.441, 1.331, 1.261, 1.219, 1.199, 1.205, 1.232, 1.301, 1.414, 1.571, 1.773, 2.052,\n> >>>>> +            2.645, 2.206, 1.928, 1.728, 1.559, 1.451, 1.352, 1.301, 1.282, 1.289, 1.319, 1.395, 1.519, 1.685, 1.904, 2.227\n> >>>>> +        ],\n> >>>>> +        \"sigma\": 0.005,\n> >>>>> +        \"sigma_Cb\": 0.005\n> >>>>> +    },\n> >>>>> +    \"rpi.contrast\":\n> >>>>> +    {\n> >>>>> +        \"ce_enable\": 1,\n> >>>>> +        \"gamma_curve\":\n> >>>>> +        [\n> >>>>> +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n> >>>>> +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> >>>>> +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> >>>>> +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> >>>>> +            65535, 65535\n> >>>>> +        ]\n> >>>>> +    },\n> >>>>> +    \"rpi.sharpen\":\n> >>>>> +    {\n> >>>>> +    },\n> >>>>> +    \"rpi.ccm\":\n> >>>>> +    {\n> >>>>> +        \"ccms\":\n> >>>>> +     [\n> >>>>> +            {\n> >>>>> +             \"ct\": 3900, \"ccm\":\n> >>>>> +             [\n> >>>>> +                 1.54659, -0.17707, -0.36953, -0.51471, 1.72733, -0.21262, 0.06667, -0.92279, 1.85612\n> >>>>> +             ]\n> >>>>> +         }\n> >>>>> +     ]\n> >>>>> +    },\n> >>>>> +    \"rpi.focus\":\n> >>>>> +    {\n> >>>>> +    }\n> >>>>> +}\n> >>>>> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> >>>>> index 5236bf1e..509ad58b 100644\n> >>>>> --- a/src/ipa/raspberrypi/data/meson.build\n> >>>>> +++ b/src/ipa/raspberrypi/data/meson.build\n> >>>>> @@ -3,6 +3,7 @@\n> >>>>>   conf_files = files([\n> >>>>>       'imx219.json',\n> >>>>>       'imx477.json',\n> >>>>> +    'imx290.json',\n> >>>>\n> >>>> Alphabetical order please.\n> >>>>\n> >>>>>       'ov5647.json',\n> >>>>>       'uncalibrated.json',\n> >>>>>   ])\n> >>>>> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> >>>>> index 59e49686..7e88f8e0 100644\n> >>>>> --- a/src/ipa/raspberrypi/meson.build\n> >>>>> +++ b/src/ipa/raspberrypi/meson.build\n> >>>>> @@ -21,6 +21,7 @@ rpi_ipa_sources = files([\n> >>>>>       'cam_helper_ov5647.cpp',\n> >>>>>       'cam_helper_imx219.cpp',\n> >>>>>       'cam_helper_imx477.cpp',\n> >>>>> +    'cam_helper_imx290.cpp',\n> >>>>\n> >>>> Here too.\n> >>>\n> >>> Will do! Version 2 of this set incoming shortly.\n> >>>\n> >>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> >>>>\n> >>>>>       'controller/controller.cpp',\n> >>>>>       'controller/histogram.cpp',\n> >>>>>       'controller/algorithm.cpp',\n> >>\n> >> --\n> >> Regards,\n> >>\n> >> Laurent Pinchart\n> >> _______________________________________________\n> >> libcamera-devel mailing list\n> >> libcamera-devel@lists.libcamera.org\n> >> https://lists.libcamera.org/listinfo/libcamera-devel\n> > _______________________________________________\n> > libcamera-devel mailing list\n> > libcamera-devel@lists.libcamera.org\n> > https://lists.libcamera.org/listinfo/libcamera-devel\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 2FE93BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Mar 2021 18:42:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8438268AA5;\n\tTue,  9 Mar 2021 19:42:22 +0100 (CET)","from mail-wr1-x431.google.com (mail-wr1-x431.google.com\n\t[IPv6:2a00:1450:4864:20::431])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8279368A99\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Mar 2021 19:42:20 +0100 (CET)","by mail-wr1-x431.google.com with SMTP id e10so17701834wro.12\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 09 Mar 2021 10:42:20 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"njlSN4kK\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=U27WlHJKOUue0r2gPckAlyJK6pOiQYpl45n9g8wlpo4=;\n\tb=njlSN4kKoJGIizBuAm5qy6n9R2tREh4cJsHrswM7FLq1Iow7mbk7Waaf/oJVrQVBZY\n\t9XMGCtIpEhMYW6YtR0ZR7u1rXFRhsL6vBk04nqDwUDxVitcFqBV2vjW8diGxlfWGcI1H\n\tj01LpAEUiRRGnkKq0jRH2HDeAYkUAYJ34RNi9vqVhQv569ZKqYqSyfRi9HkjEbBE/6+A\n\tXhef5I/hcCA4A3WXqDOH4/E/oE3cYf6Lj4rAGhErivt9fKdsq9+ebZu0Xn3SZpruayK0\n\tZGa/2COQqsJI59tlcbtrTKD4FplCoCl4Al11tcIOibtRz5rwHBQzEYOTtHp4CjqAymvt\n\tgrNA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=U27WlHJKOUue0r2gPckAlyJK6pOiQYpl45n9g8wlpo4=;\n\tb=nJ3KVpZnbpKAQa+Hy5ZoLkYYHFR9mDMDD++ulsWGhkikPo1k/HQjULVpbX9EURcadE\n\t9FgMNXhqW3nxqcVODvSiWguOzEMgrj+slv+55u7AlT6Z3Jz+DlK5OwbSy+wHLGh4Fltf\n\t5ruML7Rd7Fg0XuGoOl9HRpzpDEA2Pd2fhRKqaGSbtyVgeZCeid+JuJsC+Cu5pRIupl2m\n\td/ccPHDoYKh3D0qPvKyHN95ez6dyQsqLj7staHhwz3zMzKlotNoTG3Tka2fSKgvAi/gp\n\thKmvdp7mujXbPLzeN6pwj78Oyf5dSGB286xl2GKdezMKhFKmjvkGVzqHuz81dWy9yOil\n\tXYkA==","X-Gm-Message-State":"AOAM531hD8eBrNXmxOhk/Nvnuh2Xlw6FLR0mGTNPUqMy+4QJEadZfVMh\n\tvpgnhjINAqJRflgcoTJJGEZCxGkuycNCt/kY57GY/g==","X-Google-Smtp-Source":"ABdhPJwV9G05z7HLGblZq2fkxtipKo5i2+7hJPW0JkgwYVdKORp9kQuTbHOM+Yh2Bciow4Wn7c7sDkJvOP3QFIrFQcY=","X-Received":"by 2002:adf:f8cd:: with SMTP id\n\tf13mr28744000wrq.27.1615315340015; \n\tTue, 09 Mar 2021 10:42:20 -0800 (PST)","MIME-Version":"1.0","References":"<20210304153120.1904-1-david.plowman@raspberrypi.com>\n\t<20210304153120.1904-3-david.plowman@raspberrypi.com>\n\t<YEZ7aRAOzrtZFRSQ@pendragon.ideasonboard.com>\n\t<CAHW6GYLWOEPoJq0qMhZx0T2c8x8fWMvXUFMewmpfB0oF0ra+8g@mail.gmail.com>\n\t<YEai9cNXP0mRBo7L@pendragon.ideasonboard.com>\n\t<CAPY8ntBmKoBDsQ8pDHgGk_ziA-uQOfURY68H4=N77BcXqJnxqg@mail.gmail.com>\n\t<a56d2315-e967-8b5e-d507-6f9aef355c93@linaro.org>","In-Reply-To":"<a56d2315-e967-8b5e-d507-6f9aef355c93@linaro.org>","From":"Dave Stevenson <dave.stevenson@raspberrypi.com>","Date":"Tue, 9 Mar 2021 18:42:04 +0000","Message-ID":"<CAPY8ntCJ3o1NRH_0aLxSPkarptgJrAiY0+PuHt1Y7QFNZfysbg@mail.gmail.com>","To":"Andrey Konovalov <andrey.konovalov@linaro.org>","Subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":15577,"web_url":"https://patchwork.libcamera.org/comment/15577/","msgid":"<YEfvQLVaxl6HIVmi@pendragon.ideasonboard.com>","date":"2021-03-09T21:57:20","subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Dave,\n\nOn Tue, Mar 09, 2021 at 12:34:48PM +0000, Dave Stevenson wrote:\n> On Mon, 8 Mar 2021 at 22:20, Laurent Pinchart wrote:\n> > On Mon, Mar 08, 2021 at 10:11:35PM +0000, David Plowman wrote:\n> > > On Mon, 8 Mar 2021 at 19:31, Laurent Pinchart wrote:\n> > > > On Thu, Mar 04, 2021 at 03:31:20PM +0000, David Plowman wrote:\n> > > > > imx290 and imx327 share the same kernel driver (imx290.c) and are\n> > > > > therefore both recognised here as \"imx290\".\n> > > >\n> > > > Are there any differences between the two sensors that may need to be\n> > > > handled anywhere in libcamera ?\n> > >\n> > > Good question, and the answer is... I don't really know. I don't have\n> > > any modules that I know to have an imx290 in them, but at some point\n> > > I'm sure we or someone else will come across one and we'll find out.\n> > > At some point some we're going to have to start coping with different\n> > > modules with the same (or indistinguishable sensors) in them too.\n> >\n> > There are two issues here, differences between the IMX290 and IMX327\n> > sensors, and differences between modules. For the former, would it make\n> > sense to already add a sony,imx327 compatible string to the imx290\n> > driver, and make use of it ? To be clear, it's not a blocker for this\n> > patch.\n> \n> I have a mono IMX290 from Vision Components here, as well as several\n> IMX327's. Vision Components appear to use literally the same PCB for\n> the two modules - they are both silkscreened IMX327.\n> \n> IMX290 is the bigger brother to IMX327. It can do 1080p120 (10bit\n> only, 4lane CSI2 at 891Mb/s/lane), whilst IMX327 can only do 1080p60\n> (10 or 12bit, 2lane CSI2 at 891Mb/s/lane, or 4lane at 445.5Mb/s/lane).\n> \n> Programming interface is identical except for allowing frsel=0 for\n> 120fps on IMX290.\n> \n> The driver is largely Andrey Konovalov's mainline driver with controls\n> added, and support for an alternate source clock frequency\n> (74.250MHz).\n> It switches mode based on link frequency, and doesn't support the\n> 1080p120fps mode, so is actually independent of whether it is 327 or\n> 290. Based on the link frequency numbers it's a max of 1080p30 on\n> either lane configuration, but I thought I'd had 1080p60.\n> \n> One to investigate to make the driver more flexible, but shouldn't\n> affect libcamera (other than wanting mono support!). The Pi ISP won't\n> support 1080p120 so is actually of limited interest to us.\n\nThank you for the detailed information. Based on the difference you\noutlined between the IMX290 and IMX327, I think different compatible\nstrings would be useful, to enable the 120fps mode on IMX290 only (we\ndon't have to add 120fps support to the driver just yet, just prepare\nfor it). I've read that the IMX327 has a better light sensitivity than\nthe IMX290, so maybe this would have an influence on algorithms, and\nwould also be worth reporting the correct sensor model to userspace.\n\n> > > > > We add the necessary\n> > > > > CamHelper for these sensors, as well as a camera tuning file.\n> > > > >\n> > > > > The tuning was done with an Innomaker STARVIS IMX327LQR module. These\n> > > > > have no IR cut filter so there is no proper colour tuning. However,\n> > > > > you should obtain reasonable results for most modules using this\n> > > > > sensor. Specific tunings for further modules can always be added\n> > > > > subsequently.\n> > > > >\n> > > > > To use this sensor on the Raspberry Pi platform, please add\n> > > > >\n> > > > > dtoverlay=imx290,clock-frequency=74250000\n> > > > >\n> > > > > into your /boot/config.txt file.\n> > > > >\n> > > > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > > > ---\n> > > > >  src/ipa/raspberrypi/cam_helper_imx290.cpp |  67 +++++++++\n> > > > >  src/ipa/raspberrypi/data/imx290.json      | 165 ++++++++++++++++++++++\n> > > > >  src/ipa/raspberrypi/data/meson.build      |   1 +\n> > > > >  src/ipa/raspberrypi/meson.build           |   1 +\n> > > > >  4 files changed, 234 insertions(+)\n> > > > >  create mode 100644 src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > > > >  create mode 100644 src/ipa/raspberrypi/data/imx290.json\n> > > > >\n> > > > > diff --git a/src/ipa/raspberrypi/cam_helper_imx290.cpp b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > > > > new file mode 100644\n> > > > > index 00000000..6f412e40\n> > > > > --- /dev/null\n> > > > > +++ b/src/ipa/raspberrypi/cam_helper_imx290.cpp\n> > > > > @@ -0,0 +1,67 @@\n> > > > > +/* SPDX-License-Identifier: BSD-2-Clause */\n> > > > > +/*\n> > > > > + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> > > > > + *\n> > > > > + * cam_helper_imx290.cpp - camera helper for imx290 sensor\n> > > > > + */\n> > > > > +\n> > > > > +#include <math.h>\n> > > > > +\n> > > > > +#include \"cam_helper.hpp\"\n> > > > > +\n> > > > > +using namespace RPiController;\n> > > > > +\n> > > > > +class CamHelperImx290 : public CamHelper\n> > > > > +{\n> > > > > +public:\n> > > > > +     CamHelperImx290();\n> > > > > +     uint32_t GainCode(double gain) const override;\n> > > > > +     double Gain(uint32_t gain_code) const override;\n> > > > > +     void GetDelays(int &exposure_delay, int &gain_delay,\n> > > > > +                    int &vblank_delay) 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 = 2;\n> > > > > +};\n> > > > > +\n> > > > > +CamHelperImx290::CamHelperImx290()\n> > > > > +     : CamHelper(nullptr, frameIntegrationDiff)\n> > > > > +{\n> > > > > +}\n> > > > > +\n> > > > > +uint32_t CamHelperImx290::GainCode(double gain) const\n> > > > > +{\n> > > > > +     int code = 66.6667 * log10(gain);\n> > > > > +     return std::max(0, std::min(code, 0xf0));\n> > > > > +}\n> > > > > +\n> > > > > +double CamHelperImx290::Gain(uint32_t gain_code) const\n> > > > > +{\n> > > > > +     return pow(10, 0.015 * gain_code);\n> > > > > +}\n> > > > > +\n> > > > > +void CamHelperImx290::GetDelays(int &exposure_delay, int &gain_delay,\n> > > > > +                             int &vblank_delay) const\n> > > > > +{\n> > > > > +     exposure_delay = 2;\n> > > > > +     gain_delay = 2;\n> > > > > +     vblank_delay = 2;\n> > > > > +}\n> > > > > +\n> > > > > +unsigned int CamHelperImx290::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 CamHelperImx290();\n> > > > > +}\n> > > > > +\n> > > > > +static RegisterCamHelper reg(\"imx290\", &Create);\n> > > > > diff --git a/src/ipa/raspberrypi/data/imx290.json b/src/ipa/raspberrypi/data/imx290.json\n> > > > > new file mode 100644\n> > > > > index 00000000..6fb92cc4\n> > > > > --- /dev/null\n> > > > > +++ b/src/ipa/raspberrypi/data/imx290.json\n> > > > > @@ -0,0 +1,165 @@\n> > > > > +{\n> > > > > +    \"rpi.black_level\":\n> > > > > +    {\n> > > > > +        \"black_level\": 3840\n> > > > > +    },\n> > > > > +    \"rpi.dpc\":\n> > > > > +    {\n> > > > > +    },\n> > > > > +    \"rpi.lux\":\n> > > > > +    {\n> > > > > +        \"reference_shutter_speed\": 6813,\n> > > > > +        \"reference_gain\": 1.0,\n> > > > > +        \"reference_aperture\": 1.0,\n> > > > > +        \"reference_lux\": 890,\n> > > > > +        \"reference_Y\": 12900\n> > > > > +    },\n> > > > > +    \"rpi.noise\":\n> > > > > +    {\n> > > > > +        \"reference_constant\": 0,\n> > > > > +        \"reference_slope\": 2.67\n> > > > > +    },\n> > > > > +    \"rpi.geq\":\n> > > > > +    {\n> > > > > +        \"offset\": 187,\n> > > > > +        \"slope\": 0.00842\n> > > > > +    },\n> > > > > +    \"rpi.sdn\":\n> > > > > +    {\n> > > > > +    },\n> > > > > +    \"rpi.awb\":\n> > > > > +    {\n> > > > > +     \"bayes\": 0\n> > > > > +    },\n> > > > > +    \"rpi.agc\":\n> > > > > +    {\n> > > > > +     \"speed\": 0.2,\n> > > > > +        \"metering_modes\":\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> > > > > +            \"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> > > > > +        },\n> > > > > +        \"exposure_modes\":\n> > > > > +        {\n> > > > > +            \"normal\":\n> > > > > +            {\n> > > > > +                \"shutter\":\n> > > > > +                [\n> > > > > +                    10, 30000, 60000\n> > > > > +                ],\n> > > > > +                \"gain\":\n> > > > > +                [\n> > > > > +                    1.0,  2.0,   8.0\n> > > > > +                ]\n> > > > > +            },\n> > > > > +            \"sport\":\n> > > > > +            {\n> > > > > +                \"shutter\":\n> > > > > +                [\n> > > > > +                    10, 5000, 10000, 20000, 120000\n> > > > > +                ],\n> > > > > +                \"gain\":\n> > > > > +                [\n> > > > > +                    1.0, 2.0, 4.0, 6.0, 6.0\n> > > > > +                ]\n> > > > > +            }\n> > > > > +        },\n> > > > > +        \"constraint_modes\":\n> > > > > +        {\n> > > > > +            \"normal\":\n> > > > > +            [\n> > > > > +            ],\n> > > > > +            \"highlight\":\n> > > > > +            [\n> > > > > +                {\n> > > > > +                    \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> > > > > +                    [\n> > > > > +                        0, 0.5, 1000, 0.5\n> > > > > +                    ]\n> > > > > +                },\n> > > > > +                {\n> > > > > +                    \"bound\": \"UPPER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\":\n> > > > > +                    [\n> > > > > +                        0, 0.8, 1000, 0.8\n> > > > > +                    ]\n> > > > > +                }\n> > > > > +            ]\n> > > > > +        },\n> > > > > +        \"y_target\":\n> > > > > +        [\n> > > > > +            0, 0.16, 1000, 0.16, 10000, 0.16\n> > > > > +        ]\n> > > > > +    },\n> > > > > +    \"rpi.alsc\":\n> > > > > +    {\n> > > > > +        \"omega\": 1.3,\n> > > > > +        \"n_iter\": 100,\n> > > > > +        \"luminance_strength\": 0.7,\n> > > > > +        \"luminance_lut\":\n> > > > > +        [\n> > > > > +            2.844, 2.349, 2.018, 1.775, 1.599, 1.466, 1.371, 1.321, 1.306, 1.316, 1.357, 1.439, 1.552, 1.705, 1.915, 2.221,\n> > > > > +            2.576, 2.151, 1.851, 1.639, 1.478, 1.358, 1.272, 1.231, 1.218, 1.226, 1.262, 1.335, 1.438, 1.571, 1.766, 2.067,\n> > > > > +            2.381, 2.005, 1.739, 1.545, 1.389, 1.278, 1.204, 1.166, 1.153, 1.161, 1.194, 1.263, 1.356, 1.489, 1.671, 1.943,\n> > > > > +            2.242, 1.899, 1.658, 1.481, 1.329, 1.225, 1.156, 1.113, 1.096, 1.107, 1.143, 1.201, 1.289, 1.423, 1.607, 1.861,\n> > > > > +            2.152, 1.831, 1.602, 1.436, 1.291, 1.193, 1.121, 1.069, 1.047, 1.062, 1.107, 1.166, 1.249, 1.384, 1.562, 1.801,\n> > > > > +            2.104, 1.795, 1.572, 1.407, 1.269, 1.174, 1.099, 1.041, 1.008, 1.029, 1.083, 1.146, 1.232, 1.364, 1.547, 1.766,\n> > > > > +            2.104, 1.796, 1.572, 1.403, 1.264, 1.171, 1.097, 1.036, 1.001, 1.025, 1.077, 1.142, 1.231, 1.363, 1.549, 1.766,\n> > > > > +            2.148, 1.827, 1.594, 1.413, 1.276, 1.184, 1.114, 1.062, 1.033, 1.049, 1.092, 1.153, 1.242, 1.383, 1.577, 1.795,\n> > > > > +            2.211, 1.881, 1.636, 1.455, 1.309, 1.214, 1.149, 1.104, 1.081, 1.089, 1.125, 1.184, 1.273, 1.423, 1.622, 1.846,\n> > > > > +            2.319, 1.958, 1.698, 1.516, 1.362, 1.262, 1.203, 1.156, 1.137, 1.142, 1.171, 1.229, 1.331, 1.484, 1.682, 1.933,\n> > > > > +            2.459, 2.072, 1.789, 1.594, 1.441, 1.331, 1.261, 1.219, 1.199, 1.205, 1.232, 1.301, 1.414, 1.571, 1.773, 2.052,\n> > > > > +            2.645, 2.206, 1.928, 1.728, 1.559, 1.451, 1.352, 1.301, 1.282, 1.289, 1.319, 1.395, 1.519, 1.685, 1.904, 2.227\n> > > > > +        ],\n> > > > > +        \"sigma\": 0.005,\n> > > > > +        \"sigma_Cb\": 0.005\n> > > > > +    },\n> > > > > +    \"rpi.contrast\":\n> > > > > +    {\n> > > > > +        \"ce_enable\": 1,\n> > > > > +        \"gamma_curve\":\n> > > > > +        [\n> > > > > +            0, 0, 1024, 5040, 2048, 9338, 3072, 12356, 4096, 15312, 5120, 18051, 6144, 20790, 7168, 23193,\n> > > > > +            8192, 25744, 9216, 27942, 10240, 30035, 11264, 32005, 12288, 33975, 13312, 35815, 14336, 37600, 15360, 39168,\n> > > > > +            16384, 40642, 18432, 43379, 20480, 45749, 22528, 47753, 24576, 49621, 26624, 51253, 28672, 52698, 30720, 53796,\n> > > > > +            32768, 54876, 36864, 57012, 40960, 58656, 45056, 59954, 49152, 61183, 53248, 62355, 57344, 63419, 61440, 64476,\n> > > > > +            65535, 65535\n> > > > > +        ]\n> > > > > +    },\n> > > > > +    \"rpi.sharpen\":\n> > > > > +    {\n> > > > > +    },\n> > > > > +    \"rpi.ccm\":\n> > > > > +    {\n> > > > > +        \"ccms\":\n> > > > > +     [\n> > > > > +            {\n> > > > > +             \"ct\": 3900, \"ccm\":\n> > > > > +             [\n> > > > > +                 1.54659, -0.17707, -0.36953, -0.51471, 1.72733, -0.21262, 0.06667, -0.92279, 1.85612\n> > > > > +             ]\n> > > > > +         }\n> > > > > +     ]\n> > > > > +    },\n> > > > > +    \"rpi.focus\":\n> > > > > +    {\n> > > > > +    }\n> > > > > +}\n> > > > > diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> > > > > index 5236bf1e..509ad58b 100644\n> > > > > --- a/src/ipa/raspberrypi/data/meson.build\n> > > > > +++ b/src/ipa/raspberrypi/data/meson.build\n> > > > > @@ -3,6 +3,7 @@\n> > > > >  conf_files = files([\n> > > > >      'imx219.json',\n> > > > >      'imx477.json',\n> > > > > +    'imx290.json',\n> > > >\n> > > > Alphabetical order please.\n> > > >\n> > > > >      'ov5647.json',\n> > > > >      'uncalibrated.json',\n> > > > >  ])\n> > > > > diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> > > > > index 59e49686..7e88f8e0 100644\n> > > > > --- a/src/ipa/raspberrypi/meson.build\n> > > > > +++ b/src/ipa/raspberrypi/meson.build\n> > > > > @@ -21,6 +21,7 @@ rpi_ipa_sources = files([\n> > > > >      'cam_helper_ov5647.cpp',\n> > > > >      'cam_helper_imx219.cpp',\n> > > > >      'cam_helper_imx477.cpp',\n> > > > > +    'cam_helper_imx290.cpp',\n> > > >\n> > > > Here too.\n> > >\n> > > Will do! Version 2 of this set incoming shortly.\n> > >\n> > > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > >\n> > > > >      'controller/controller.cpp',\n> > > > >      'controller/histogram.cpp',\n> > > > >      'controller/algorithm.cpp',","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 3C101BD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  9 Mar 2021 21:57:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8D2A168AA3;\n\tTue,  9 Mar 2021 22:57:54 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 11DDD68A99\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  9 Mar 2021 22:57:53 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 85D19E9;\n\tTue,  9 Mar 2021 22:57:52 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"FcLth0c4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1615327072;\n\tbh=wT+PXsg3DSvh0k0b8qv2vvD7fmqIWxtMQkSXhkPDj/Q=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FcLth0c4ehkjpxqXQw0WfjfB9xfO2RPpBqZ6OQGee/7gHS9OU7ca36G9SroxxlVGm\n\t+IHQ0n/gvTit6i8gzTBfnihjfy5TkGEc6w1qjlKnaCxTQankuNCJxoYvuQZ5IxCEJ9\n\tH3hQ+hKbbh48iXvolH9F9bP3XKOI8tB1f7PrG+YU=","Date":"Tue, 9 Mar 2021 23:57:20 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Dave Stevenson <dave.stevenson@raspberrypi.com>","Message-ID":"<YEfvQLVaxl6HIVmi@pendragon.ideasonboard.com>","References":"<20210304153120.1904-1-david.plowman@raspberrypi.com>\n\t<20210304153120.1904-3-david.plowman@raspberrypi.com>\n\t<YEZ7aRAOzrtZFRSQ@pendragon.ideasonboard.com>\n\t<CAHW6GYLWOEPoJq0qMhZx0T2c8x8fWMvXUFMewmpfB0oF0ra+8g@mail.gmail.com>\n\t<YEai9cNXP0mRBo7L@pendragon.ideasonboard.com>\n\t<CAPY8ntBmKoBDsQ8pDHgGk_ziA-uQOfURY68H4=N77BcXqJnxqg@mail.gmail.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<CAPY8ntBmKoBDsQ8pDHgGk_ziA-uQOfURY68H4=N77BcXqJnxqg@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH 2/2] ipa: raspberrypi: Add support for\n\timx290/imx327 sensors","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]