[{"id":17640,"web_url":"https://patchwork.libcamera.org/comment/17640/","msgid":"<3f9adef8-bebf-7545-5f25-ca83b8d3c293@ideasonboard.com>","date":"2021-06-18T22:23:31","subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 18/06/2021 23:04, David Plowman wrote:\n> The necessary tuning file and CamHelper is added for the ov9281 sensor\n> (which the driver names as the \"mov9281\").\n> \n> The ov9281 is a 1280x800 monochrome global shutter sensor. To enable\n> it, please add\n> \n> dtoverlay=ov9281\n> \n> to the /boot/config.txt file and reboot the Pi.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\nAs long as we know that this is destined for upstream integration:\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>.\n\n\n\n> ---\n>  src/ipa/raspberrypi/cam_helper_mov9281.cpp | 65 +++++++++++++++\n>  src/ipa/raspberrypi/data/meson.build       |  1 +\n>  src/ipa/raspberrypi/data/mov9281.json      | 92 ++++++++++++++++++++++\n>  src/ipa/raspberrypi/meson.build            |  1 +\n>  4 files changed, 159 insertions(+)\n>  create mode 100644 src/ipa/raspberrypi/cam_helper_mov9281.cpp\n>  create mode 100644 src/ipa/raspberrypi/data/mov9281.json\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper_mov9281.cpp b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> new file mode 100644\n> index 00000000..29519cb0\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> @@ -0,0 +1,65 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> + *\n> + * cam_helper_mov9281.cpp - camera information for ov9281 sensor\n> + */\n> +\n> +#include <assert.h>\n> +\n> +#include \"cam_helper.hpp\"\n> +\n> +using namespace RPiController;\n> +\n> +class CamHelperOv9281 : public CamHelper\n> +{\n> +public:\n> +\tCamHelperOv9281();\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> +\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 = 4;\n> +};\n> +\n> +/*\n> + * OV9281 doesn't output metadata, so we have to use the \"unicam parser\" which\n> + * works by counting frames.\n> + */\n> +\n> +CamHelperOv9281::CamHelperOv9281()\n> +\t: CamHelper(nullptr, frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperOv9281::GainCode(double gain) const\n> +{\n> +\treturn static_cast<uint32_t>(gain * 16.0);\n> +}\n> +\n> +double CamHelperOv9281::Gain(uint32_t gain_code) const\n> +{\n> +\treturn static_cast<double>(gain_code) / 16.0;\n> +}\n> +\n> +void CamHelperOv9281::GetDelays(int &exposure_delay, int &gain_delay,\n> +\t\t\t\tint &vblank_delay) const\n> +{\n> +\t/* The driver appears to behave as follows: */\n> +\texposure_delay = 2;\n> +\tgain_delay = 2;\n> +\tvblank_delay = 2;\n> +}\n> +\n> +static CamHelper *Create()\n> +{\n> +\treturn new CamHelperOv9281();\n> +}\n> +\n> +static RegisterCamHelper reg(\"mov9281\", &Create);\n> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> index 92ad3272..f8baab6d 100644\n> --- a/src/ipa/raspberrypi/data/meson.build\n> +++ b/src/ipa/raspberrypi/data/meson.build\n> @@ -4,6 +4,7 @@ conf_files = files([\n>      'imx219.json',\n>      'imx290.json',\n>      'imx477.json',\n> +    'mov9281.json',\n>      'ov5647.json',\n>      'se327m12.json',\n>      'uncalibrated.json',\n> diff --git a/src/ipa/raspberrypi/data/mov9281.json b/src/ipa/raspberrypi/data/mov9281.json\n> new file mode 100644\n> index 00000000..ecd262be\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/data/mov9281.json\n> @@ -0,0 +1,92 @@\n> +{\n> +    \"rpi.black_level\":\n> +    {\n> +        \"black_level\": 4096\n> +    },\n> +    \"rpi.lux\":\n> +    {\n> +        \"reference_shutter_speed\": 2000,\n> +        \"reference_gain\": 1.0,\n> +        \"reference_aperture\": 1.0,\n> +        \"reference_lux\": 800,\n> +        \"reference_Y\": 20000\n> +    },\n> +    \"rpi.noise\":\n> +    {\n> +        \"reference_constant\": 0,\n> +        \"reference_slope\": 2.5\n> +    },\n> +    \"rpi.sdn\":\n> +    {\n> +    },\n> +    \"rpi.agc\":\n> +    {\n> +        \"metering_modes\":\n> +        {\n> +            \"centre-weighted\": {\n> +                \"weights\": [4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0]\n> +            }\n> +        },\n> +        \"exposure_modes\":\n> +        {\n> +            \"normal\":\n> +            {\n> +                \"shutter\": [ 100, 15000, 30000, 60000, 120000 ],\n> +                \"gain\":    [ 1.0, 2.0,   3.0,   4.0,   6.0    ]\n> +            }\n> +        },\n> +        \"constraint_modes\":\n> +        {\n> +            \"normal\":\n> +            [\n> +                { \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\": [ 0, 0.4, 1000, 0.4 ] }\n> +            ]\n> +        },\n> +        \"y_target\": [ 0, 0.16, 1000, 0.165, 10000, 0.17 ]\n> +    },\n> +    \"rpi.alsc\":\n> +    {\n> +        \"n_iter\": 0,\n> +        \"luminance_strength\": 1.0,\n> +        \"corner_strength\": 1.5\n> +    },\n> +    \"rpi.contrast\":\n> +    {\n> +        \"ce_enable\": 0,\n> +        \"gamma_curve\": [\n> +            0,     0,\n> +            1024,  5040,\n> +            2048,  9338,\n> +            3072,  12356,\n> +            4096,  15312,\n> +            5120,  18051,\n> +            6144,  20790,\n> +            7168,  23193,\n> +            8192,  25744,\n> +            9216,  27942,\n> +            10240, 30035,\n> +            11264, 32005,\n> +            12288, 33975,\n> +            13312, 35815,\n> +            14336, 37600,\n> +            15360, 39168,\n> +            16384, 40642,\n> +            18432, 43379,\n> +            20480, 45749,\n> +            22528, 47753,\n> +            24576, 49621,\n> +            26624, 51253,\n> +            28672, 52698,\n> +            30720, 53796,\n> +            32768, 54876,\n> +            36864, 57012,\n> +            40960, 58656,\n> +            45056, 59954,\n> +            49152, 61183,\n> +            53248, 62355,\n> +            57344, 63419,\n> +            61440, 64476,\n> +            65535, 65535\n> +        ]\n> +    }\n> +}\n> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> index 230356d3..93f04e9e 100644\n> --- a/src/ipa/raspberrypi/meson.build\n> +++ b/src/ipa/raspberrypi/meson.build\n> @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n>      'cam_helper_imx219.cpp',\n>      'cam_helper_imx290.cpp',\n>      'cam_helper_imx477.cpp',\n> +    'cam_helper_mov9281.cpp',\n>      'controller/controller.cpp',\n>      'controller/histogram.cpp',\n>      'controller/algorithm.cpp',\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 026B8C3218\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Jun 2021 22:23:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 711CC6050C;\n\tSat, 19 Jun 2021 00:23:35 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A6716050C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 19 Jun 2021 00:23:34 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 14B4555C;\n\tSat, 19 Jun 2021 00:23:34 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"eHS73Wdi\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624055014;\n\tbh=YVcfZJEW/qIns2yXHeRdTG/0MEnYfQzJrt9FPNcvMuo=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=eHS73Wdixzl+nK/QNwxvLuzsJY/ACaCtOkWnHejvyhADZwsLJGdS0WTP2kmYvK7OM\n\tIa8TKmLURV8RW/dRdJ2b5v4g+CaAEkUzo2KwrOenlHEzoLtCJm9rUL7EXXNDN9owYx\n\tIk0v1bL1+PvqqPPMK4PThtkh6przi58PxhliVY90=","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210618220430.31457-1-david.plowman@raspberrypi.com>\n\t<20210618220430.31457-4-david.plowman@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Organization":"Ideas on Board","Message-ID":"<3f9adef8-bebf-7545-5f25-ca83b8d3c293@ideasonboard.com>","Date":"Fri, 18 Jun 2021 23:23:31 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.8.1","MIME-Version":"1.0","In-Reply-To":"<20210618220430.31457-4-david.plowman@raspberrypi.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","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>","Reply-To":"kieran.bingham@ideasonboard.com","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17867,"web_url":"https://patchwork.libcamera.org/comment/17867/","msgid":"<YNlpXXCoHZ7BtZwA@pendragon.ideasonboard.com>","date":"2021-06-28T06:17:01","subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","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 Fri, Jun 18, 2021 at 11:04:30PM +0100, David Plowman wrote:\n> The necessary tuning file and CamHelper is added for the ov9281 sensor\n> (which the driver names as the \"mov9281\").\n\nThis bothers me a little bit, as it will likely need to be renamed to\nov9281 when upstreaming. Why is there an \"m\" prefix, and could it be\ndropped ?\n\n> The ov9281 is a 1280x800 monochrome global shutter sensor. To enable\n> it, please add\n> \n> dtoverlay=ov9281\n> \n> to the /boot/config.txt file and reboot the Pi.\n> \n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n> ---\n>  src/ipa/raspberrypi/cam_helper_mov9281.cpp | 65 +++++++++++++++\n>  src/ipa/raspberrypi/data/meson.build       |  1 +\n>  src/ipa/raspberrypi/data/mov9281.json      | 92 ++++++++++++++++++++++\n>  src/ipa/raspberrypi/meson.build            |  1 +\n>  4 files changed, 159 insertions(+)\n>  create mode 100644 src/ipa/raspberrypi/cam_helper_mov9281.cpp\n>  create mode 100644 src/ipa/raspberrypi/data/mov9281.json\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper_mov9281.cpp b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> new file mode 100644\n> index 00000000..29519cb0\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> @@ -0,0 +1,65 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> + *\n> + * cam_helper_mov9281.cpp - camera information for ov9281 sensor\n> + */\n> +\n> +#include <assert.h>\n> +\n> +#include \"cam_helper.hpp\"\n> +\n> +using namespace RPiController;\n> +\n> +class CamHelperOv9281 : public CamHelper\n> +{\n> +public:\n> +\tCamHelperOv9281();\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> +\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 = 4;\n> +};\n> +\n> +/*\n> + * OV9281 doesn't output metadata, so we have to use the \"unicam parser\" which\n> + * works by counting frames.\n> + */\n> +\n> +CamHelperOv9281::CamHelperOv9281()\n> +\t: CamHelper(nullptr, frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperOv9281::GainCode(double gain) const\n> +{\n> +\treturn static_cast<uint32_t>(gain * 16.0);\n> +}\n> +\n> +double CamHelperOv9281::Gain(uint32_t gain_code) const\n> +{\n> +\treturn static_cast<double>(gain_code) / 16.0;\n> +}\n> +\n> +void CamHelperOv9281::GetDelays(int &exposure_delay, int &gain_delay,\n> +\t\t\t\tint &vblank_delay) const\n> +{\n> +\t/* The driver appears to behave as follows: */\n> +\texposure_delay = 2;\n> +\tgain_delay = 2;\n> +\tvblank_delay = 2;\n> +}\n> +\n> +static CamHelper *Create()\n> +{\n> +\treturn new CamHelperOv9281();\n> +}\n> +\n> +static RegisterCamHelper reg(\"mov9281\", &Create);\n> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> index 92ad3272..f8baab6d 100644\n> --- a/src/ipa/raspberrypi/data/meson.build\n> +++ b/src/ipa/raspberrypi/data/meson.build\n> @@ -4,6 +4,7 @@ conf_files = files([\n>      'imx219.json',\n>      'imx290.json',\n>      'imx477.json',\n> +    'mov9281.json',\n>      'ov5647.json',\n>      'se327m12.json',\n>      'uncalibrated.json',\n> diff --git a/src/ipa/raspberrypi/data/mov9281.json b/src/ipa/raspberrypi/data/mov9281.json\n> new file mode 100644\n> index 00000000..ecd262be\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/data/mov9281.json\n> @@ -0,0 +1,92 @@\n> +{\n> +    \"rpi.black_level\":\n> +    {\n> +        \"black_level\": 4096\n> +    },\n> +    \"rpi.lux\":\n> +    {\n> +        \"reference_shutter_speed\": 2000,\n> +        \"reference_gain\": 1.0,\n> +        \"reference_aperture\": 1.0,\n> +        \"reference_lux\": 800,\n> +        \"reference_Y\": 20000\n> +    },\n> +    \"rpi.noise\":\n> +    {\n> +        \"reference_constant\": 0,\n> +        \"reference_slope\": 2.5\n> +    },\n> +    \"rpi.sdn\":\n> +    {\n> +    },\n> +    \"rpi.agc\":\n> +    {\n> +        \"metering_modes\":\n> +        {\n> +            \"centre-weighted\": {\n> +                \"weights\": [4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0]\n> +            }\n> +        },\n> +        \"exposure_modes\":\n> +        {\n> +            \"normal\":\n> +            {\n> +                \"shutter\": [ 100, 15000, 30000, 60000, 120000 ],\n> +                \"gain\":    [ 1.0, 2.0,   3.0,   4.0,   6.0    ]\n> +            }\n> +        },\n> +        \"constraint_modes\":\n> +        {\n> +            \"normal\":\n> +            [\n> +                { \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\": [ 0, 0.4, 1000, 0.4 ] }\n> +            ]\n> +        },\n> +        \"y_target\": [ 0, 0.16, 1000, 0.165, 10000, 0.17 ]\n> +    },\n> +    \"rpi.alsc\":\n> +    {\n> +        \"n_iter\": 0,\n> +        \"luminance_strength\": 1.0,\n> +        \"corner_strength\": 1.5\n> +    },\n> +    \"rpi.contrast\":\n> +    {\n> +        \"ce_enable\": 0,\n> +        \"gamma_curve\": [\n> +            0,     0,\n> +            1024,  5040,\n> +            2048,  9338,\n> +            3072,  12356,\n> +            4096,  15312,\n> +            5120,  18051,\n> +            6144,  20790,\n> +            7168,  23193,\n> +            8192,  25744,\n> +            9216,  27942,\n> +            10240, 30035,\n> +            11264, 32005,\n> +            12288, 33975,\n> +            13312, 35815,\n> +            14336, 37600,\n> +            15360, 39168,\n> +            16384, 40642,\n> +            18432, 43379,\n> +            20480, 45749,\n> +            22528, 47753,\n> +            24576, 49621,\n> +            26624, 51253,\n> +            28672, 52698,\n> +            30720, 53796,\n> +            32768, 54876,\n> +            36864, 57012,\n> +            40960, 58656,\n> +            45056, 59954,\n> +            49152, 61183,\n> +            53248, 62355,\n> +            57344, 63419,\n> +            61440, 64476,\n> +            65535, 65535\n> +        ]\n> +    }\n> +}\n> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> index 230356d3..93f04e9e 100644\n> --- a/src/ipa/raspberrypi/meson.build\n> +++ b/src/ipa/raspberrypi/meson.build\n> @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n>      'cam_helper_imx219.cpp',\n>      'cam_helper_imx290.cpp',\n>      'cam_helper_imx477.cpp',\n> +    'cam_helper_mov9281.cpp',\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 E06D3C321E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jun 2021 06:17:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 29738684D5;\n\tMon, 28 Jun 2021 08:17:04 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C47AA6028C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 08:17:02 +0200 (CEST)","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 59B9DB8A;\n\tMon, 28 Jun 2021 08:17:02 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"K260PiRa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624861022;\n\tbh=CuCoJm5U+nnsXcZ+OUl9Yo8W3UA3IB0Oz6z63S12zO4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=K260PiRa4jQHv9C9kqft7TXghpY4PSxGxq64ClGw4WS8nZipn+BKEX4LUEg/YpdYY\n\tR3980x00Qb2xG8pkXtX/YcPsWkqVlj48F/e9grWRgM25gq25t5n1xvu64yAOO7bTdz\n\teNRXCC5eBp/nzWqLB552Kj/jYm5FnsGmO0IIIrE4=","Date":"Mon, 28 Jun 2021 09:17:01 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YNlpXXCoHZ7BtZwA@pendragon.ideasonboard.com>","References":"<20210618220430.31457-1-david.plowman@raspberrypi.com>\n\t<20210618220430.31457-4-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210618220430.31457-4-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","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","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17870,"web_url":"https://patchwork.libcamera.org/comment/17870/","msgid":"<CAHW6GYK4YBPEfUMi_DXF6XnjEoZPQ3yi9u3vZykVXeYmBJQqsg@mail.gmail.com>","date":"2021-06-28T06:47:39","subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Laurent\n\nThanks for the comments.\n\nOn Mon, 28 Jun 2021 at 07:17, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> Thank you for the patch.\n>\n> On Fri, Jun 18, 2021 at 11:04:30PM +0100, David Plowman wrote:\n> > The necessary tuning file and CamHelper is added for the ov9281 sensor\n> > (which the driver names as the \"mov9281\").\n>\n> This bothers me a little bit, as it will likely need to be renamed to\n> ov9281 when upstreaming. Why is there an \"m\" prefix, and could it be\n> dropped ?\n\nYes, I'm suspicious that the \"m\" is actually a reference to \"mono\",\nthereby opening the way for colour versions of this sensor. In fact it\nwould be helpful for the driver to advertise a different name in such\ncases so that a more appropriate tuning file can be identified (though\nas we know, that still isn't really good enough...!) But maybe\nsomething a little less cryptic than just \"m\" would help?\n\nBest regards\nDavid\n\n>\n> > The ov9281 is a 1280x800 monochrome global shutter sensor. To enable\n> > it, please add\n> >\n> > dtoverlay=ov9281\n> >\n> > to the /boot/config.txt file and reboot the Pi.\n> >\n> > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n> > ---\n> >  src/ipa/raspberrypi/cam_helper_mov9281.cpp | 65 +++++++++++++++\n> >  src/ipa/raspberrypi/data/meson.build       |  1 +\n> >  src/ipa/raspberrypi/data/mov9281.json      | 92 ++++++++++++++++++++++\n> >  src/ipa/raspberrypi/meson.build            |  1 +\n> >  4 files changed, 159 insertions(+)\n> >  create mode 100644 src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> >  create mode 100644 src/ipa/raspberrypi/data/mov9281.json\n> >\n> > diff --git a/src/ipa/raspberrypi/cam_helper_mov9281.cpp b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > new file mode 100644\n> > index 00000000..29519cb0\n> > --- /dev/null\n> > +++ b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > @@ -0,0 +1,65 @@\n> > +/* SPDX-License-Identifier: BSD-2-Clause */\n> > +/*\n> > + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> > + *\n> > + * cam_helper_mov9281.cpp - camera information for ov9281 sensor\n> > + */\n> > +\n> > +#include <assert.h>\n> > +\n> > +#include \"cam_helper.hpp\"\n> > +\n> > +using namespace RPiController;\n> > +\n> > +class CamHelperOv9281 : public CamHelper\n> > +{\n> > +public:\n> > +     CamHelperOv9281();\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> > +\n> > +private:\n> > +     /*\n> > +      * Smallest difference between the frame length and integration time,\n> > +      * in units of lines.\n> > +      */\n> > +     static constexpr int frameIntegrationDiff = 4;\n> > +};\n> > +\n> > +/*\n> > + * OV9281 doesn't output metadata, so we have to use the \"unicam parser\" which\n> > + * works by counting frames.\n> > + */\n> > +\n> > +CamHelperOv9281::CamHelperOv9281()\n> > +     : CamHelper(nullptr, frameIntegrationDiff)\n> > +{\n> > +}\n> > +\n> > +uint32_t CamHelperOv9281::GainCode(double gain) const\n> > +{\n> > +     return static_cast<uint32_t>(gain * 16.0);\n> > +}\n> > +\n> > +double CamHelperOv9281::Gain(uint32_t gain_code) const\n> > +{\n> > +     return static_cast<double>(gain_code) / 16.0;\n> > +}\n> > +\n> > +void CamHelperOv9281::GetDelays(int &exposure_delay, int &gain_delay,\n> > +                             int &vblank_delay) const\n> > +{\n> > +     /* The driver appears to behave as follows: */\n> > +     exposure_delay = 2;\n> > +     gain_delay = 2;\n> > +     vblank_delay = 2;\n> > +}\n> > +\n> > +static CamHelper *Create()\n> > +{\n> > +     return new CamHelperOv9281();\n> > +}\n> > +\n> > +static RegisterCamHelper reg(\"mov9281\", &Create);\n> > diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> > index 92ad3272..f8baab6d 100644\n> > --- a/src/ipa/raspberrypi/data/meson.build\n> > +++ b/src/ipa/raspberrypi/data/meson.build\n> > @@ -4,6 +4,7 @@ conf_files = files([\n> >      'imx219.json',\n> >      'imx290.json',\n> >      'imx477.json',\n> > +    'mov9281.json',\n> >      'ov5647.json',\n> >      'se327m12.json',\n> >      'uncalibrated.json',\n> > diff --git a/src/ipa/raspberrypi/data/mov9281.json b/src/ipa/raspberrypi/data/mov9281.json\n> > new file mode 100644\n> > index 00000000..ecd262be\n> > --- /dev/null\n> > +++ b/src/ipa/raspberrypi/data/mov9281.json\n> > @@ -0,0 +1,92 @@\n> > +{\n> > +    \"rpi.black_level\":\n> > +    {\n> > +        \"black_level\": 4096\n> > +    },\n> > +    \"rpi.lux\":\n> > +    {\n> > +        \"reference_shutter_speed\": 2000,\n> > +        \"reference_gain\": 1.0,\n> > +        \"reference_aperture\": 1.0,\n> > +        \"reference_lux\": 800,\n> > +        \"reference_Y\": 20000\n> > +    },\n> > +    \"rpi.noise\":\n> > +    {\n> > +        \"reference_constant\": 0,\n> > +        \"reference_slope\": 2.5\n> > +    },\n> > +    \"rpi.sdn\":\n> > +    {\n> > +    },\n> > +    \"rpi.agc\":\n> > +    {\n> > +        \"metering_modes\":\n> > +        {\n> > +            \"centre-weighted\": {\n> > +                \"weights\": [4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0]\n> > +            }\n> > +        },\n> > +        \"exposure_modes\":\n> > +        {\n> > +            \"normal\":\n> > +            {\n> > +                \"shutter\": [ 100, 15000, 30000, 60000, 120000 ],\n> > +                \"gain\":    [ 1.0, 2.0,   3.0,   4.0,   6.0    ]\n> > +            }\n> > +        },\n> > +        \"constraint_modes\":\n> > +        {\n> > +            \"normal\":\n> > +            [\n> > +                { \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\": [ 0, 0.4, 1000, 0.4 ] }\n> > +            ]\n> > +        },\n> > +        \"y_target\": [ 0, 0.16, 1000, 0.165, 10000, 0.17 ]\n> > +    },\n> > +    \"rpi.alsc\":\n> > +    {\n> > +        \"n_iter\": 0,\n> > +        \"luminance_strength\": 1.0,\n> > +        \"corner_strength\": 1.5\n> > +    },\n> > +    \"rpi.contrast\":\n> > +    {\n> > +        \"ce_enable\": 0,\n> > +        \"gamma_curve\": [\n> > +            0,     0,\n> > +            1024,  5040,\n> > +            2048,  9338,\n> > +            3072,  12356,\n> > +            4096,  15312,\n> > +            5120,  18051,\n> > +            6144,  20790,\n> > +            7168,  23193,\n> > +            8192,  25744,\n> > +            9216,  27942,\n> > +            10240, 30035,\n> > +            11264, 32005,\n> > +            12288, 33975,\n> > +            13312, 35815,\n> > +            14336, 37600,\n> > +            15360, 39168,\n> > +            16384, 40642,\n> > +            18432, 43379,\n> > +            20480, 45749,\n> > +            22528, 47753,\n> > +            24576, 49621,\n> > +            26624, 51253,\n> > +            28672, 52698,\n> > +            30720, 53796,\n> > +            32768, 54876,\n> > +            36864, 57012,\n> > +            40960, 58656,\n> > +            45056, 59954,\n> > +            49152, 61183,\n> > +            53248, 62355,\n> > +            57344, 63419,\n> > +            61440, 64476,\n> > +            65535, 65535\n> > +        ]\n> > +    }\n> > +}\n> > diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> > index 230356d3..93f04e9e 100644\n> > --- a/src/ipa/raspberrypi/meson.build\n> > +++ b/src/ipa/raspberrypi/meson.build\n> > @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n> >      'cam_helper_imx219.cpp',\n> >      'cam_helper_imx290.cpp',\n> >      'cam_helper_imx477.cpp',\n> > +    'cam_helper_mov9281.cpp',\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 E7E40C321A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jun 2021 06:47:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 352A5684D5;\n\tMon, 28 Jun 2021 08:47:52 +0200 (CEST)","from mail-wr1-x434.google.com (mail-wr1-x434.google.com\n\t[IPv6:2a00:1450:4864:20::434])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AE6726028C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 08:47:50 +0200 (CEST)","by mail-wr1-x434.google.com with SMTP id g7so15186953wri.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 27 Jun 2021 23:47:50 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"G62LY8J1\"; 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=G1xwpI4VETo9HY/ASkPTK74nr8Cfwduzfbw5GQXbdYw=;\n\tb=G62LY8J1oyK4DKS0vpoIkPvRWTGV9WK1jxSb6SLObDuguoBduqU9miGgADr06t4S7m\n\tDTbh3mnnZFTatX0a2A9Nv1lH739PvEAvScb3otDuIcta+9s+0a7ir7TiGizN+QeWg08W\n\tjRIS2uDl4ZetvU0EL0i/GoEcGjd05kadfqC3/moSmDmu3L0882bSX9Qjk5x+0DWhoEGL\n\tCdP2CwGYkvSMdT++2ru1NGol8op51Z5QPPAdkPbOiCYU9BSv+TMH0/sIV9c6Rbp79fvK\n\tbzQfdvsniOA03yDmU7or8ZgNHLMReYfD57uBja6keaAZlY82wGT0I7FIeM56Xp1EZ8EB\n\t9HNw==","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=G1xwpI4VETo9HY/ASkPTK74nr8Cfwduzfbw5GQXbdYw=;\n\tb=qs+CP8AvZYfu/FeabUihC+Eg8uOUmWhG/fBQQ8k2ttC7TAU1VmLRZpSe5gfogkVFKG\n\tAckxMOSdGHyXqBDv6iO8XIjOOBLPqHE2pwvi7WlCFLA/UZ1byszqsqYDOyxlNiWK2WX7\n\tl+sAOjfC9ViHpQpB3JSydcgM/+zyz+VZEKpSTPlON/6VO/QjqRsQumxaN4ocXfpm/HyT\n\tE5qcSdyyM2VHzC9sjBmYsnZIR8T6NrVGboG1eo7DowZVjqzy/nwTOfsYgDOjLhJEzuyU\n\tvY/ejQlL0RoKviTe8ZRgORh0KTG202miK40CpT/Gvsnz67InXxpoXkZ1yEnXwzRNy5RA\n\tkWsA==","X-Gm-Message-State":"AOAM5317WVZ9q2cG0yaUII18XgoCHHHPDbzLkXoFswKNIjqmUWgxSsSc\n\t4oFnJcH0cwQxprICjN29jBW9B9PGIPV0lrhIDNfqoA35Ez4=","X-Google-Smtp-Source":"ABdhPJzZSFb4qdBVAEU5a/PMaOYngAwqHTaL/+kod403+HYwJyca1TgvykCOkx5eMmbA1659sC9WFBaNhRdjOa4flcc=","X-Received":"by 2002:a05:6000:188b:: with SMTP id\n\ta11mr24504080wri.274.1624862870233; \n\tSun, 27 Jun 2021 23:47:50 -0700 (PDT)","MIME-Version":"1.0","References":"<20210618220430.31457-1-david.plowman@raspberrypi.com>\n\t<20210618220430.31457-4-david.plowman@raspberrypi.com>\n\t<YNlpXXCoHZ7BtZwA@pendragon.ideasonboard.com>","In-Reply-To":"<YNlpXXCoHZ7BtZwA@pendragon.ideasonboard.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 28 Jun 2021 07:47:39 +0100","Message-ID":"<CAHW6GYK4YBPEfUMi_DXF6XnjEoZPQ3yi9u3vZykVXeYmBJQqsg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17873,"web_url":"https://patchwork.libcamera.org/comment/17873/","msgid":"<YNl0Ea5DktTAJOrX@pendragon.ideasonboard.com>","date":"2021-06-28T07:02:41","subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","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, Jun 28, 2021 at 07:47:39AM +0100, David Plowman wrote:\n> On Mon, 28 Jun 2021 at 07:17, Laurent Pinchart wrote:\n> > On Fri, Jun 18, 2021 at 11:04:30PM +0100, David Plowman wrote:\n> > > The necessary tuning file and CamHelper is added for the ov9281 sensor\n> > > (which the driver names as the \"mov9281\").\n> >\n> > This bothers me a little bit, as it will likely need to be renamed to\n> > ov9281 when upstreaming. Why is there an \"m\" prefix, and could it be\n> > dropped ?\n> \n> Yes, I'm suspicious that the \"m\" is actually a reference to \"mono\",\n> thereby opening the way for colour versions of this sensor. In fact it\n> would be helpful for the driver to advertise a different name in such\n> cases so that a more appropriate tuning file can be identified (though\n> as we know, that still isn't really good enough...!) But maybe\n> something a little less cryptic than just \"m\" would help?\n\nIs there a colour version of the OV9281 ? If not, I'd just drop the\nprefix. If there is, the media entity should be named according to the\nOmnivision naming scheme.\n\n> > > The ov9281 is a 1280x800 monochrome global shutter sensor. To enable\n> > > it, please add\n> > >\n> > > dtoverlay=ov9281\n> > >\n> > > to the /boot/config.txt file and reboot the Pi.\n> > >\n> > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n> > > ---\n> > >  src/ipa/raspberrypi/cam_helper_mov9281.cpp | 65 +++++++++++++++\n> > >  src/ipa/raspberrypi/data/meson.build       |  1 +\n> > >  src/ipa/raspberrypi/data/mov9281.json      | 92 ++++++++++++++++++++++\n> > >  src/ipa/raspberrypi/meson.build            |  1 +\n> > >  4 files changed, 159 insertions(+)\n> > >  create mode 100644 src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > >  create mode 100644 src/ipa/raspberrypi/data/mov9281.json\n> > >\n> > > diff --git a/src/ipa/raspberrypi/cam_helper_mov9281.cpp b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > > new file mode 100644\n> > > index 00000000..29519cb0\n> > > --- /dev/null\n> > > +++ b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > > @@ -0,0 +1,65 @@\n> > > +/* SPDX-License-Identifier: BSD-2-Clause */\n> > > +/*\n> > > + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> > > + *\n> > > + * cam_helper_mov9281.cpp - camera information for ov9281 sensor\n> > > + */\n> > > +\n> > > +#include <assert.h>\n> > > +\n> > > +#include \"cam_helper.hpp\"\n> > > +\n> > > +using namespace RPiController;\n> > > +\n> > > +class CamHelperOv9281 : public CamHelper\n> > > +{\n> > > +public:\n> > > +     CamHelperOv9281();\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> > > +\n> > > +private:\n> > > +     /*\n> > > +      * Smallest difference between the frame length and integration time,\n> > > +      * in units of lines.\n> > > +      */\n> > > +     static constexpr int frameIntegrationDiff = 4;\n> > > +};\n> > > +\n> > > +/*\n> > > + * OV9281 doesn't output metadata, so we have to use the \"unicam parser\" which\n> > > + * works by counting frames.\n> > > + */\n> > > +\n> > > +CamHelperOv9281::CamHelperOv9281()\n> > > +     : CamHelper(nullptr, frameIntegrationDiff)\n> > > +{\n> > > +}\n> > > +\n> > > +uint32_t CamHelperOv9281::GainCode(double gain) const\n> > > +{\n> > > +     return static_cast<uint32_t>(gain * 16.0);\n> > > +}\n> > > +\n> > > +double CamHelperOv9281::Gain(uint32_t gain_code) const\n> > > +{\n> > > +     return static_cast<double>(gain_code) / 16.0;\n> > > +}\n> > > +\n> > > +void CamHelperOv9281::GetDelays(int &exposure_delay, int &gain_delay,\n> > > +                             int &vblank_delay) const\n> > > +{\n> > > +     /* The driver appears to behave as follows: */\n> > > +     exposure_delay = 2;\n> > > +     gain_delay = 2;\n> > > +     vblank_delay = 2;\n> > > +}\n> > > +\n> > > +static CamHelper *Create()\n> > > +{\n> > > +     return new CamHelperOv9281();\n> > > +}\n> > > +\n> > > +static RegisterCamHelper reg(\"mov9281\", &Create);\n> > > diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> > > index 92ad3272..f8baab6d 100644\n> > > --- a/src/ipa/raspberrypi/data/meson.build\n> > > +++ b/src/ipa/raspberrypi/data/meson.build\n> > > @@ -4,6 +4,7 @@ conf_files = files([\n> > >      'imx219.json',\n> > >      'imx290.json',\n> > >      'imx477.json',\n> > > +    'mov9281.json',\n> > >      'ov5647.json',\n> > >      'se327m12.json',\n> > >      'uncalibrated.json',\n> > > diff --git a/src/ipa/raspberrypi/data/mov9281.json b/src/ipa/raspberrypi/data/mov9281.json\n> > > new file mode 100644\n> > > index 00000000..ecd262be\n> > > --- /dev/null\n> > > +++ b/src/ipa/raspberrypi/data/mov9281.json\n> > > @@ -0,0 +1,92 @@\n> > > +{\n> > > +    \"rpi.black_level\":\n> > > +    {\n> > > +        \"black_level\": 4096\n> > > +    },\n> > > +    \"rpi.lux\":\n> > > +    {\n> > > +        \"reference_shutter_speed\": 2000,\n> > > +        \"reference_gain\": 1.0,\n> > > +        \"reference_aperture\": 1.0,\n> > > +        \"reference_lux\": 800,\n> > > +        \"reference_Y\": 20000\n> > > +    },\n> > > +    \"rpi.noise\":\n> > > +    {\n> > > +        \"reference_constant\": 0,\n> > > +        \"reference_slope\": 2.5\n> > > +    },\n> > > +    \"rpi.sdn\":\n> > > +    {\n> > > +    },\n> > > +    \"rpi.agc\":\n> > > +    {\n> > > +        \"metering_modes\":\n> > > +        {\n> > > +            \"centre-weighted\": {\n> > > +                \"weights\": [4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0]\n> > > +            }\n> > > +        },\n> > > +        \"exposure_modes\":\n> > > +        {\n> > > +            \"normal\":\n> > > +            {\n> > > +                \"shutter\": [ 100, 15000, 30000, 60000, 120000 ],\n> > > +                \"gain\":    [ 1.0, 2.0,   3.0,   4.0,   6.0    ]\n> > > +            }\n> > > +        },\n> > > +        \"constraint_modes\":\n> > > +        {\n> > > +            \"normal\":\n> > > +            [\n> > > +                { \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\": [ 0, 0.4, 1000, 0.4 ] }\n> > > +            ]\n> > > +        },\n> > > +        \"y_target\": [ 0, 0.16, 1000, 0.165, 10000, 0.17 ]\n> > > +    },\n> > > +    \"rpi.alsc\":\n> > > +    {\n> > > +        \"n_iter\": 0,\n> > > +        \"luminance_strength\": 1.0,\n> > > +        \"corner_strength\": 1.5\n> > > +    },\n> > > +    \"rpi.contrast\":\n> > > +    {\n> > > +        \"ce_enable\": 0,\n> > > +        \"gamma_curve\": [\n> > > +            0,     0,\n> > > +            1024,  5040,\n> > > +            2048,  9338,\n> > > +            3072,  12356,\n> > > +            4096,  15312,\n> > > +            5120,  18051,\n> > > +            6144,  20790,\n> > > +            7168,  23193,\n> > > +            8192,  25744,\n> > > +            9216,  27942,\n> > > +            10240, 30035,\n> > > +            11264, 32005,\n> > > +            12288, 33975,\n> > > +            13312, 35815,\n> > > +            14336, 37600,\n> > > +            15360, 39168,\n> > > +            16384, 40642,\n> > > +            18432, 43379,\n> > > +            20480, 45749,\n> > > +            22528, 47753,\n> > > +            24576, 49621,\n> > > +            26624, 51253,\n> > > +            28672, 52698,\n> > > +            30720, 53796,\n> > > +            32768, 54876,\n> > > +            36864, 57012,\n> > > +            40960, 58656,\n> > > +            45056, 59954,\n> > > +            49152, 61183,\n> > > +            53248, 62355,\n> > > +            57344, 63419,\n> > > +            61440, 64476,\n> > > +            65535, 65535\n> > > +        ]\n> > > +    }\n> > > +}\n> > > diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> > > index 230356d3..93f04e9e 100644\n> > > --- a/src/ipa/raspberrypi/meson.build\n> > > +++ b/src/ipa/raspberrypi/meson.build\n> > > @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n> > >      'cam_helper_imx219.cpp',\n> > >      'cam_helper_imx290.cpp',\n> > >      'cam_helper_imx477.cpp',\n> > > +    'cam_helper_mov9281.cpp',\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 4AA3DC321A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jun 2021 07:02:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BA316684D2;\n\tMon, 28 Jun 2021 09:02:45 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 775DF684D2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 09:02:43 +0200 (CEST)","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 D6DE0B8A;\n\tMon, 28 Jun 2021 09:02:42 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"K0Jr6DfX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624863763;\n\tbh=ewsr0FXhFG/gQ9ak06nazfLOz2XeO3YfSEh3fnyINEk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=K0Jr6DfXZrcV9sRVf/kN4Ktmo78FOcDS466mBmEykFr0s7vj1HPVbWzGRgR6bI8Ji\n\tYtHNtRbxZTql4DgqkfstBOMaealuGovl310ufQ55124RA1rxpMIm9TnfaGtmJj4wfT\n\tqwV967VW6EZaJCVJJ/zU0U/Y5yWwB/JVnJi4B1mk=","Date":"Mon, 28 Jun 2021 10:02:41 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YNl0Ea5DktTAJOrX@pendragon.ideasonboard.com>","References":"<20210618220430.31457-1-david.plowman@raspberrypi.com>\n\t<20210618220430.31457-4-david.plowman@raspberrypi.com>\n\t<YNlpXXCoHZ7BtZwA@pendragon.ideasonboard.com>\n\t<CAHW6GYK4YBPEfUMi_DXF6XnjEoZPQ3yi9u3vZykVXeYmBJQqsg@mail.gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<CAHW6GYK4YBPEfUMi_DXF6XnjEoZPQ3yi9u3vZykVXeYmBJQqsg@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17881,"web_url":"https://patchwork.libcamera.org/comment/17881/","msgid":"<CAPY8ntCmAbYOMknJYEaGicisHymVDGR0f5YuM2Gbc7ACFjdXUg@mail.gmail.com>","date":"2021-06-28T09:15:48","subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","submitter":{"id":27,"url":"https://patchwork.libcamera.org/api/people/27/","name":"Dave Stevenson","email":"dave.stevenson@raspberrypi.com"},"content":"On Mon, 28 Jun 2021 at 08:02, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi David,\n>\n> On Mon, Jun 28, 2021 at 07:47:39AM +0100, David Plowman wrote:\n> > On Mon, 28 Jun 2021 at 07:17, Laurent Pinchart wrote:\n> > > On Fri, Jun 18, 2021 at 11:04:30PM +0100, David Plowman wrote:\n> > > > The necessary tuning file and CamHelper is added for the ov9281 sensor\n> > > > (which the driver names as the \"mov9281\").\n> > >\n> > > This bothers me a little bit, as it will likely need to be renamed to\n> > > ov9281 when upstreaming. Why is there an \"m\" prefix, and could it be\n> > > dropped ?\n> >\n> > Yes, I'm suspicious that the \"m\" is actually a reference to \"mono\",\n> > thereby opening the way for colour versions of this sensor. In fact it\n> > would be helpful for the driver to advertise a different name in such\n> > cases so that a more appropriate tuning file can be identified (though\n> > as we know, that still isn't really good enough...!) But maybe\n> > something a little less cryptic than just \"m\" would help?\n>\n> Is there a colour version of the OV9281 ? If not, I'd just drop the\n> prefix. If there is, the media entity should be named according to the\n> Omnivision naming scheme.\n\nNo colour version that I'm aware of.\n\nThe m was present in the Rockchip original driver that I based this on\n- https://github.com/rockchip-linux/kernel/blob/develop-4.4/drivers/media/i2c/ov9281.c#L1103\nNo issues at all in removing it.\n\n  Dave\n\n> > > > The ov9281 is a 1280x800 monochrome global shutter sensor. To enable\n> > > > it, please add\n> > > >\n> > > > dtoverlay=ov9281\n> > > >\n> > > > to the /boot/config.txt file and reboot the Pi.\n> > > >\n> > > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > > Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > ---\n> > > >  src/ipa/raspberrypi/cam_helper_mov9281.cpp | 65 +++++++++++++++\n> > > >  src/ipa/raspberrypi/data/meson.build       |  1 +\n> > > >  src/ipa/raspberrypi/data/mov9281.json      | 92 ++++++++++++++++++++++\n> > > >  src/ipa/raspberrypi/meson.build            |  1 +\n> > > >  4 files changed, 159 insertions(+)\n> > > >  create mode 100644 src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > > >  create mode 100644 src/ipa/raspberrypi/data/mov9281.json\n> > > >\n> > > > diff --git a/src/ipa/raspberrypi/cam_helper_mov9281.cpp b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > > > new file mode 100644\n> > > > index 00000000..29519cb0\n> > > > --- /dev/null\n> > > > +++ b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > > > @@ -0,0 +1,65 @@\n> > > > +/* SPDX-License-Identifier: BSD-2-Clause */\n> > > > +/*\n> > > > + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> > > > + *\n> > > > + * cam_helper_mov9281.cpp - camera information for ov9281 sensor\n> > > > + */\n> > > > +\n> > > > +#include <assert.h>\n> > > > +\n> > > > +#include \"cam_helper.hpp\"\n> > > > +\n> > > > +using namespace RPiController;\n> > > > +\n> > > > +class CamHelperOv9281 : public CamHelper\n> > > > +{\n> > > > +public:\n> > > > +     CamHelperOv9281();\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> > > > +\n> > > > +private:\n> > > > +     /*\n> > > > +      * Smallest difference between the frame length and integration time,\n> > > > +      * in units of lines.\n> > > > +      */\n> > > > +     static constexpr int frameIntegrationDiff = 4;\n> > > > +};\n> > > > +\n> > > > +/*\n> > > > + * OV9281 doesn't output metadata, so we have to use the \"unicam parser\" which\n> > > > + * works by counting frames.\n> > > > + */\n> > > > +\n> > > > +CamHelperOv9281::CamHelperOv9281()\n> > > > +     : CamHelper(nullptr, frameIntegrationDiff)\n> > > > +{\n> > > > +}\n> > > > +\n> > > > +uint32_t CamHelperOv9281::GainCode(double gain) const\n> > > > +{\n> > > > +     return static_cast<uint32_t>(gain * 16.0);\n> > > > +}\n> > > > +\n> > > > +double CamHelperOv9281::Gain(uint32_t gain_code) const\n> > > > +{\n> > > > +     return static_cast<double>(gain_code) / 16.0;\n> > > > +}\n> > > > +\n> > > > +void CamHelperOv9281::GetDelays(int &exposure_delay, int &gain_delay,\n> > > > +                             int &vblank_delay) const\n> > > > +{\n> > > > +     /* The driver appears to behave as follows: */\n> > > > +     exposure_delay = 2;\n> > > > +     gain_delay = 2;\n> > > > +     vblank_delay = 2;\n> > > > +}\n> > > > +\n> > > > +static CamHelper *Create()\n> > > > +{\n> > > > +     return new CamHelperOv9281();\n> > > > +}\n> > > > +\n> > > > +static RegisterCamHelper reg(\"mov9281\", &Create);\n> > > > diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> > > > index 92ad3272..f8baab6d 100644\n> > > > --- a/src/ipa/raspberrypi/data/meson.build\n> > > > +++ b/src/ipa/raspberrypi/data/meson.build\n> > > > @@ -4,6 +4,7 @@ conf_files = files([\n> > > >      'imx219.json',\n> > > >      'imx290.json',\n> > > >      'imx477.json',\n> > > > +    'mov9281.json',\n> > > >      'ov5647.json',\n> > > >      'se327m12.json',\n> > > >      'uncalibrated.json',\n> > > > diff --git a/src/ipa/raspberrypi/data/mov9281.json b/src/ipa/raspberrypi/data/mov9281.json\n> > > > new file mode 100644\n> > > > index 00000000..ecd262be\n> > > > --- /dev/null\n> > > > +++ b/src/ipa/raspberrypi/data/mov9281.json\n> > > > @@ -0,0 +1,92 @@\n> > > > +{\n> > > > +    \"rpi.black_level\":\n> > > > +    {\n> > > > +        \"black_level\": 4096\n> > > > +    },\n> > > > +    \"rpi.lux\":\n> > > > +    {\n> > > > +        \"reference_shutter_speed\": 2000,\n> > > > +        \"reference_gain\": 1.0,\n> > > > +        \"reference_aperture\": 1.0,\n> > > > +        \"reference_lux\": 800,\n> > > > +        \"reference_Y\": 20000\n> > > > +    },\n> > > > +    \"rpi.noise\":\n> > > > +    {\n> > > > +        \"reference_constant\": 0,\n> > > > +        \"reference_slope\": 2.5\n> > > > +    },\n> > > > +    \"rpi.sdn\":\n> > > > +    {\n> > > > +    },\n> > > > +    \"rpi.agc\":\n> > > > +    {\n> > > > +        \"metering_modes\":\n> > > > +        {\n> > > > +            \"centre-weighted\": {\n> > > > +                \"weights\": [4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0]\n> > > > +            }\n> > > > +        },\n> > > > +        \"exposure_modes\":\n> > > > +        {\n> > > > +            \"normal\":\n> > > > +            {\n> > > > +                \"shutter\": [ 100, 15000, 30000, 60000, 120000 ],\n> > > > +                \"gain\":    [ 1.0, 2.0,   3.0,   4.0,   6.0    ]\n> > > > +            }\n> > > > +        },\n> > > > +        \"constraint_modes\":\n> > > > +        {\n> > > > +            \"normal\":\n> > > > +            [\n> > > > +                { \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0, \"y_target\": [ 0, 0.4, 1000, 0.4 ] }\n> > > > +            ]\n> > > > +        },\n> > > > +        \"y_target\": [ 0, 0.16, 1000, 0.165, 10000, 0.17 ]\n> > > > +    },\n> > > > +    \"rpi.alsc\":\n> > > > +    {\n> > > > +        \"n_iter\": 0,\n> > > > +        \"luminance_strength\": 1.0,\n> > > > +        \"corner_strength\": 1.5\n> > > > +    },\n> > > > +    \"rpi.contrast\":\n> > > > +    {\n> > > > +        \"ce_enable\": 0,\n> > > > +        \"gamma_curve\": [\n> > > > +            0,     0,\n> > > > +            1024,  5040,\n> > > > +            2048,  9338,\n> > > > +            3072,  12356,\n> > > > +            4096,  15312,\n> > > > +            5120,  18051,\n> > > > +            6144,  20790,\n> > > > +            7168,  23193,\n> > > > +            8192,  25744,\n> > > > +            9216,  27942,\n> > > > +            10240, 30035,\n> > > > +            11264, 32005,\n> > > > +            12288, 33975,\n> > > > +            13312, 35815,\n> > > > +            14336, 37600,\n> > > > +            15360, 39168,\n> > > > +            16384, 40642,\n> > > > +            18432, 43379,\n> > > > +            20480, 45749,\n> > > > +            22528, 47753,\n> > > > +            24576, 49621,\n> > > > +            26624, 51253,\n> > > > +            28672, 52698,\n> > > > +            30720, 53796,\n> > > > +            32768, 54876,\n> > > > +            36864, 57012,\n> > > > +            40960, 58656,\n> > > > +            45056, 59954,\n> > > > +            49152, 61183,\n> > > > +            53248, 62355,\n> > > > +            57344, 63419,\n> > > > +            61440, 64476,\n> > > > +            65535, 65535\n> > > > +        ]\n> > > > +    }\n> > > > +}\n> > > > diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> > > > index 230356d3..93f04e9e 100644\n> > > > --- a/src/ipa/raspberrypi/meson.build\n> > > > +++ b/src/ipa/raspberrypi/meson.build\n> > > > @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n> > > >      'cam_helper_imx219.cpp',\n> > > >      'cam_helper_imx290.cpp',\n> > > >      'cam_helper_imx477.cpp',\n> > > > +    'cam_helper_mov9281.cpp',\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 E7E14C321F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jun 2021 09:16:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6F465684D6;\n\tMon, 28 Jun 2021 11:16:04 +0200 (CEST)","from mail-wr1-x429.google.com (mail-wr1-x429.google.com\n\t[IPv6:2a00:1450:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 802AB684D2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 11:16:03 +0200 (CEST)","by mail-wr1-x429.google.com with SMTP id l8so11564337wry.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 02:16:03 -0700 (PDT)"],"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=\"Q6h2mAxh\"; 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=qlD6TzX+gHAG6EX9CU9UocBANp3OnFXp4rcklk7aH1E=;\n\tb=Q6h2mAxh2d/UsX/fK/9jbK6PDEBQSTxSCN8pwG/f3iwPPxKR7yjPC5qzSaNbcr6MNn\n\teRH7oGx2C3F8UScuh2tZX7Xh0AJ7/Ilmsrgu0jDESbLRcDfHFgR6bZoBBhEabtPUpHoR\n\tzwgAkLDH4AR35QtbIqY9OtDuhVmGjHnW5pnCg2ab2siPmnNZ+BWaaVDkl4u8GLvb6o+2\n\tqt3bRw19PBUMOpjto+4RO70+/P6wekaZoRTnRuSDiHoJLVcKfrUCuqHMN10V5X7jMPGi\n\t/L13YEzPtYo1UgNx8htJX7/Qe8crI/Xn6okhu3tMBdGwk6VrTvZz3qeiSK2Y1c4lVEX2\n\tAkIg==","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=qlD6TzX+gHAG6EX9CU9UocBANp3OnFXp4rcklk7aH1E=;\n\tb=MS/bH3/ykX9MviEEGbqA3UOlr/8Daaq3X7Hhse8gP9cof0MD8LL4Hqkd48vIQ2Votw\n\txJQPbz2vFA/qrdS1GvaPVxU/94k+3Ux6qCU4BUKLLVKUEX6yKCYM8kg/rQFHV0NJ6khu\n\tOrQrWnHqkc4i1+t2Hz0MOPeH4Sj4t3r5VpjF59n3vxkFQuHLcF3WgVCFIoyN+xZ3sKAv\n\temUvmMgC7MeMf3PSNtY3dktC0gueAgbEgLpKGlqhVKjeNnAYfZGMXYV824EfTaRg5pVj\n\tsY1wYNY/Lyq7YXHODLLasIvkYzSeFLU6XAAqfXvrJ8BaHdTq8yFzGq1JtrKhN7/z2/qO\n\t+QRQ==","X-Gm-Message-State":"AOAM533CoB0OWZEFNZsqSRGzGAGV52gD//X1v8WC+rFfIm8U5TzwdH2A\n\t3SBJqXwNnWx69o6AGPW8Xt+8Pf+lDOsI8ubzZ4rZFA==","X-Google-Smtp-Source":"ABdhPJwFUOGXYcxOHFnHRKmz5/oqS9XeRwPLX13o3xq3mDilnOZFB2pbSdMgRHF0PqKX/kVq9VjrlQLeJq2bwXSDJgQ=","X-Received":"by 2002:a5d:4a51:: with SMTP id\n\tv17mr25921004wrs.150.1624871763206; \n\tMon, 28 Jun 2021 02:16:03 -0700 (PDT)","MIME-Version":"1.0","References":"<20210618220430.31457-1-david.plowman@raspberrypi.com>\n\t<20210618220430.31457-4-david.plowman@raspberrypi.com>\n\t<YNlpXXCoHZ7BtZwA@pendragon.ideasonboard.com>\n\t<CAHW6GYK4YBPEfUMi_DXF6XnjEoZPQ3yi9u3vZykVXeYmBJQqsg@mail.gmail.com>\n\t<YNl0Ea5DktTAJOrX@pendragon.ideasonboard.com>","In-Reply-To":"<YNl0Ea5DktTAJOrX@pendragon.ideasonboard.com>","From":"Dave Stevenson <dave.stevenson@raspberrypi.com>","Date":"Mon, 28 Jun 2021 10:15:48 +0100","Message-ID":"<CAPY8ntCmAbYOMknJYEaGicisHymVDGR0f5YuM2Gbc7ACFjdXUg@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17883,"web_url":"https://patchwork.libcamera.org/comment/17883/","msgid":"<CAHW6GYKEpSg5j-y_QknR=GMVEp-jTjZNxztsQeM-1Vc1CTspUA@mail.gmail.com>","date":"2021-06-28T09:20:54","subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Thanks, Dave.\n\nI'll prepare another version that removes the offending \"m\"!\n\nDavid\n\nOn Mon, 28 Jun 2021 at 10:16, Dave Stevenson <dave.stevenson@raspberrypi.com>\nwrote:\n\n> On Mon, 28 Jun 2021 at 08:02, Laurent Pinchart\n> <laurent.pinchart@ideasonboard.com> wrote:\n> >\n> > Hi David,\n> >\n> > On Mon, Jun 28, 2021 at 07:47:39AM +0100, David Plowman wrote:\n> > > On Mon, 28 Jun 2021 at 07:17, Laurent Pinchart wrote:\n> > > > On Fri, Jun 18, 2021 at 11:04:30PM +0100, David Plowman wrote:\n> > > > > The necessary tuning file and CamHelper is added for the ov9281\n> sensor\n> > > > > (which the driver names as the \"mov9281\").\n> > > >\n> > > > This bothers me a little bit, as it will likely need to be renamed to\n> > > > ov9281 when upstreaming. Why is there an \"m\" prefix, and could it be\n> > > > dropped ?\n> > >\n> > > Yes, I'm suspicious that the \"m\" is actually a reference to \"mono\",\n> > > thereby opening the way for colour versions of this sensor. In fact it\n> > > would be helpful for the driver to advertise a different name in such\n> > > cases so that a more appropriate tuning file can be identified (though\n> > > as we know, that still isn't really good enough...!) But maybe\n> > > something a little less cryptic than just \"m\" would help?\n> >\n> > Is there a colour version of the OV9281 ? If not, I'd just drop the\n> > prefix. If there is, the media entity should be named according to the\n> > Omnivision naming scheme.\n>\n> No colour version that I'm aware of.\n>\n> The m was present in the Rockchip original driver that I based this on\n> -\n> https://github.com/rockchip-linux/kernel/blob/develop-4.4/drivers/media/i2c/ov9281.c#L1103\n> No issues at all in removing it.\n>\n>   Dave\n>\n> > > > > The ov9281 is a 1280x800 monochrome global shutter sensor. To\n> enable\n> > > > > it, please add\n> > > > >\n> > > > > dtoverlay=ov9281\n> > > > >\n> > > > > to the /boot/config.txt file and reboot the Pi.\n> > > > >\n> > > > > Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> > > > > Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > > ---\n> > > > >  src/ipa/raspberrypi/cam_helper_mov9281.cpp | 65 +++++++++++++++\n> > > > >  src/ipa/raspberrypi/data/meson.build       |  1 +\n> > > > >  src/ipa/raspberrypi/data/mov9281.json      | 92\n> ++++++++++++++++++++++\n> > > > >  src/ipa/raspberrypi/meson.build            |  1 +\n> > > > >  4 files changed, 159 insertions(+)\n> > > > >  create mode 100644 src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > > > >  create mode 100644 src/ipa/raspberrypi/data/mov9281.json\n> > > > >\n> > > > > diff --git a/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > > > > new file mode 100644\n> > > > > index 00000000..29519cb0\n> > > > > --- /dev/null\n> > > > > +++ b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\n> > > > > @@ -0,0 +1,65 @@\n> > > > > +/* SPDX-License-Identifier: BSD-2-Clause */\n> > > > > +/*\n> > > > > + * Copyright (C) 2021, Raspberry Pi (Trading) Limited\n> > > > > + *\n> > > > > + * cam_helper_mov9281.cpp - camera information for ov9281 sensor\n> > > > > + */\n> > > > > +\n> > > > > +#include <assert.h>\n> > > > > +\n> > > > > +#include \"cam_helper.hpp\"\n> > > > > +\n> > > > > +using namespace RPiController;\n> > > > > +\n> > > > > +class CamHelperOv9281 : public CamHelper\n> > > > > +{\n> > > > > +public:\n> > > > > +     CamHelperOv9281();\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> > > > > +\n> > > > > +private:\n> > > > > +     /*\n> > > > > +      * Smallest difference between the frame length and\n> integration time,\n> > > > > +      * in units of lines.\n> > > > > +      */\n> > > > > +     static constexpr int frameIntegrationDiff = 4;\n> > > > > +};\n> > > > > +\n> > > > > +/*\n> > > > > + * OV9281 doesn't output metadata, so we have to use the \"unicam\n> parser\" which\n> > > > > + * works by counting frames.\n> > > > > + */\n> > > > > +\n> > > > > +CamHelperOv9281::CamHelperOv9281()\n> > > > > +     : CamHelper(nullptr, frameIntegrationDiff)\n> > > > > +{\n> > > > > +}\n> > > > > +\n> > > > > +uint32_t CamHelperOv9281::GainCode(double gain) const\n> > > > > +{\n> > > > > +     return static_cast<uint32_t>(gain * 16.0);\n> > > > > +}\n> > > > > +\n> > > > > +double CamHelperOv9281::Gain(uint32_t gain_code) const\n> > > > > +{\n> > > > > +     return static_cast<double>(gain_code) / 16.0;\n> > > > > +}\n> > > > > +\n> > > > > +void CamHelperOv9281::GetDelays(int &exposure_delay, int\n> &gain_delay,\n> > > > > +                             int &vblank_delay) const\n> > > > > +{\n> > > > > +     /* The driver appears to behave as follows: */\n> > > > > +     exposure_delay = 2;\n> > > > > +     gain_delay = 2;\n> > > > > +     vblank_delay = 2;\n> > > > > +}\n> > > > > +\n> > > > > +static CamHelper *Create()\n> > > > > +{\n> > > > > +     return new CamHelperOv9281();\n> > > > > +}\n> > > > > +\n> > > > > +static RegisterCamHelper reg(\"mov9281\", &Create);\n> > > > > diff --git a/src/ipa/raspberrypi/data/meson.build\n> b/src/ipa/raspberrypi/data/meson.build\n> > > > > index 92ad3272..f8baab6d 100644\n> > > > > --- a/src/ipa/raspberrypi/data/meson.build\n> > > > > +++ b/src/ipa/raspberrypi/data/meson.build\n> > > > > @@ -4,6 +4,7 @@ conf_files = files([\n> > > > >      'imx219.json',\n> > > > >      'imx290.json',\n> > > > >      'imx477.json',\n> > > > > +    'mov9281.json',\n> > > > >      'ov5647.json',\n> > > > >      'se327m12.json',\n> > > > >      'uncalibrated.json',\n> > > > > diff --git a/src/ipa/raspberrypi/data/mov9281.json\n> b/src/ipa/raspberrypi/data/mov9281.json\n> > > > > new file mode 100644\n> > > > > index 00000000..ecd262be\n> > > > > --- /dev/null\n> > > > > +++ b/src/ipa/raspberrypi/data/mov9281.json\n> > > > > @@ -0,0 +1,92 @@\n> > > > > +{\n> > > > > +    \"rpi.black_level\":\n> > > > > +    {\n> > > > > +        \"black_level\": 4096\n> > > > > +    },\n> > > > > +    \"rpi.lux\":\n> > > > > +    {\n> > > > > +        \"reference_shutter_speed\": 2000,\n> > > > > +        \"reference_gain\": 1.0,\n> > > > > +        \"reference_aperture\": 1.0,\n> > > > > +        \"reference_lux\": 800,\n> > > > > +        \"reference_Y\": 20000\n> > > > > +    },\n> > > > > +    \"rpi.noise\":\n> > > > > +    {\n> > > > > +        \"reference_constant\": 0,\n> > > > > +        \"reference_slope\": 2.5\n> > > > > +    },\n> > > > > +    \"rpi.sdn\":\n> > > > > +    {\n> > > > > +    },\n> > > > > +    \"rpi.agc\":\n> > > > > +    {\n> > > > > +        \"metering_modes\":\n> > > > > +        {\n> > > > > +            \"centre-weighted\": {\n> > > > > +                \"weights\": [4, 4, 4, 2, 2, 2, 2, 1, 1, 1, 1, 0,\n> 0, 0, 0]\n> > > > > +            }\n> > > > > +        },\n> > > > > +        \"exposure_modes\":\n> > > > > +        {\n> > > > > +            \"normal\":\n> > > > > +            {\n> > > > > +                \"shutter\": [ 100, 15000, 30000, 60000, 120000 ],\n> > > > > +                \"gain\":    [ 1.0, 2.0,   3.0,   4.0,   6.0    ]\n> > > > > +            }\n> > > > > +        },\n> > > > > +        \"constraint_modes\":\n> > > > > +        {\n> > > > > +            \"normal\":\n> > > > > +            [\n> > > > > +                { \"bound\": \"LOWER\", \"q_lo\": 0.98, \"q_hi\": 1.0,\n> \"y_target\": [ 0, 0.4, 1000, 0.4 ] }\n> > > > > +            ]\n> > > > > +        },\n> > > > > +        \"y_target\": [ 0, 0.16, 1000, 0.165, 10000, 0.17 ]\n> > > > > +    },\n> > > > > +    \"rpi.alsc\":\n> > > > > +    {\n> > > > > +        \"n_iter\": 0,\n> > > > > +        \"luminance_strength\": 1.0,\n> > > > > +        \"corner_strength\": 1.5\n> > > > > +    },\n> > > > > +    \"rpi.contrast\":\n> > > > > +    {\n> > > > > +        \"ce_enable\": 0,\n> > > > > +        \"gamma_curve\": [\n> > > > > +            0,     0,\n> > > > > +            1024,  5040,\n> > > > > +            2048,  9338,\n> > > > > +            3072,  12356,\n> > > > > +            4096,  15312,\n> > > > > +            5120,  18051,\n> > > > > +            6144,  20790,\n> > > > > +            7168,  23193,\n> > > > > +            8192,  25744,\n> > > > > +            9216,  27942,\n> > > > > +            10240, 30035,\n> > > > > +            11264, 32005,\n> > > > > +            12288, 33975,\n> > > > > +            13312, 35815,\n> > > > > +            14336, 37600,\n> > > > > +            15360, 39168,\n> > > > > +            16384, 40642,\n> > > > > +            18432, 43379,\n> > > > > +            20480, 45749,\n> > > > > +            22528, 47753,\n> > > > > +            24576, 49621,\n> > > > > +            26624, 51253,\n> > > > > +            28672, 52698,\n> > > > > +            30720, 53796,\n> > > > > +            32768, 54876,\n> > > > > +            36864, 57012,\n> > > > > +            40960, 58656,\n> > > > > +            45056, 59954,\n> > > > > +            49152, 61183,\n> > > > > +            53248, 62355,\n> > > > > +            57344, 63419,\n> > > > > +            61440, 64476,\n> > > > > +            65535, 65535\n> > > > > +        ]\n> > > > > +    }\n> > > > > +}\n> > > > > diff --git a/src/ipa/raspberrypi/meson.build\n> b/src/ipa/raspberrypi/meson.build\n> > > > > index 230356d3..93f04e9e 100644\n> > > > > --- a/src/ipa/raspberrypi/meson.build\n> > > > > +++ b/src/ipa/raspberrypi/meson.build\n> > > > > @@ -22,6 +22,7 @@ rpi_ipa_sources = files([\n> > > > >      'cam_helper_imx219.cpp',\n> > > > >      'cam_helper_imx290.cpp',\n> > > > >      'cam_helper_imx477.cpp',\n> > > > > +    'cam_helper_mov9281.cpp',\n> > > > >      'controller/controller.cpp',\n> > > > >      'controller/histogram.cpp',\n> > > > >      'controller/algorithm.cpp',\n> >\n> > --\n> > Regards,\n> >\n> > Laurent Pinchart\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 B5D66C3220\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jun 2021 09:21:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 27559684D8;\n\tMon, 28 Jun 2021 11:21:07 +0200 (CEST)","from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com\n\t[IPv6:2a00:1450:4864:20::42e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 42BFC684D2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 11:21:05 +0200 (CEST)","by mail-wr1-x42e.google.com with SMTP id i94so20380839wri.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 02:21:05 -0700 (PDT)"],"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=\"Y4pFWDYh\"; 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=QhJ6NSZfGY6JM+1uOoZ00eKXQSq/w91s9xoHhuB4/TA=;\n\tb=Y4pFWDYhYMtjQ3NWpVRCS0zUwy8gTqG5ZzrKGvXKnxGwXzM8TPqh3JR7HIOKayaENv\n\tMYkmVSih7P2wT6nVb1Q9Cn7RJeP4pSDMShO8QhqyX8A+82ljhZtyt0OaqdPNk4khKU67\n\tE11OYcdfbE5k37tLvFOcoVT2aBS9USE9ViMsYfSKPGeF0JN6Xyu5j8TAtUsZiBJiwZMr\n\tBRyuOzK3rPa6Mbow8Rcaxz5o8NQNpspVl1b6stgRz2xMxvx6xENsOvrqTCbxCjE51rSR\n\tmWuDv2z1ZOi1RwKnZ8eqX7XpFdbpf1WlMztQSpg7KoTggwtLsZtt4RzN5vrabNQMZmJe\n\tYcfQ==","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=QhJ6NSZfGY6JM+1uOoZ00eKXQSq/w91s9xoHhuB4/TA=;\n\tb=NriXolPkDyU1tnhL63bQ0812gAvmxXx8+CmPccIYHMaGK/hqcJngh1V8Vjg9lB6qDZ\n\tb9GoaIw9ENkJQl4Pe5N8NUNoPcccJ6oP/bKBEgUzYyw/bJn2BXrzc6BvZIGap1qw1pDO\n\t1An/e/pektlI2MT/7lIUmclQcWUfH9v6XvtHaPYC5aG3N0WJApKDNyXsXRK1gGnILzh2\n\tLae4TWqty/cmQ4qwhtljAu2fJxrTlPkl8Y6Yar697QjzAcBa3fcycj6ISXNOmrpZ5hw+\n\tSaCeMGN8dZdDzSO0KfgHW8vIwWr4MF6GTyNq1H7cQJzmA44VXTaPIRckcdmKMAT0iGbu\n\t6KLg==","X-Gm-Message-State":"AOAM533EPt4614pfBoIg9hWMmWqdr9+Ur+jvAr+mIGsgjv3wSqjajnAy\n\t6u70WgLeEg2ypd2d7ur4vjkCwbRdPuHU/wVJHkH2Gw==","X-Google-Smtp-Source":"ABdhPJxrWIDrw/TIiukvsvr1gMw2Zrhg8noMJ824ba0EGDHvQ1FVYEBZom50XRp2if/1sr0w1fAYkkstxMpXiIsWJ8o=","X-Received":"by 2002:a05:6000:188b:: with SMTP id\n\ta11mr25198054wri.274.1624872064912; \n\tMon, 28 Jun 2021 02:21:04 -0700 (PDT)","MIME-Version":"1.0","References":"<20210618220430.31457-1-david.plowman@raspberrypi.com>\n\t<20210618220430.31457-4-david.plowman@raspberrypi.com>\n\t<YNlpXXCoHZ7BtZwA@pendragon.ideasonboard.com>\n\t<CAHW6GYK4YBPEfUMi_DXF6XnjEoZPQ3yi9u3vZykVXeYmBJQqsg@mail.gmail.com>\n\t<YNl0Ea5DktTAJOrX@pendragon.ideasonboard.com>\n\t<CAPY8ntCmAbYOMknJYEaGicisHymVDGR0f5YuM2Gbc7ACFjdXUg@mail.gmail.com>","In-Reply-To":"<CAPY8ntCmAbYOMknJYEaGicisHymVDGR0f5YuM2Gbc7ACFjdXUg@mail.gmail.com>","From":"David Plowman <david.plowman@raspberrypi.com>","Date":"Mon, 28 Jun 2021 10:20:54 +0100","Message-ID":"<CAHW6GYKEpSg5j-y_QknR=GMVEp-jTjZNxztsQeM-1Vc1CTspUA@mail.gmail.com>","To":"Dave Stevenson <dave.stevenson@raspberrypi.com>","Content-Type":"multipart/alternative; boundary=\"0000000000003c1d4d05c5d002fa\"","Subject":"Re: [libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi:\n\tAdd support for ov9281 sensor","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]