[{"id":17636,"web_url":"https://patchwork.libcamera.org/comment/17636/","msgid":"<0bdb1f06-66c1-53d9-6b73-b5229bc2ce24@ideasonboard.com>","date":"2021-06-18T20:21:26","subject":"Re: [libcamera-devel] [PATCH v2 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":"Hi David,\n\nOn 18/06/2021 17:18, 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\nOh nice.\n\nIs the tuning targetted at a specific module?\n\nSuch as the arducam that uses this sensor? or is it just a best-effort /\ngeneric for now?\n\nI think I see that the RPi kernel has a driver for this [0], but I don't\nsee it upstream. Is it on it's way? or expected to be posted sometime?\n\n[0]\nhttps://github.com/raspberrypi/linux/blob/rpi-5.10.y/drivers/media/i2c/ov9281.c\n\nWe'll need a vict err ... volunteer to kick off the upstreaming there\notherwise.\n\n\n> Signed-off-by: David Plowman <david.plowman@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',\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 B87E0BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Jun 2021 20:21:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 32B1668943;\n\tFri, 18 Jun 2021 22:21:31 +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 DFBA46050D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Jun 2021 22:21:29 +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 539CF3F0;\n\tFri, 18 Jun 2021 22:21:29 +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=\"ni2Wq2XH\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624047689;\n\tbh=JwKYwA9Prl0dPE68ZpbgClmcDqVgj0CZzxUt48D/9Oo=;\n\th=Reply-To:To:References:From:Subject:Date:In-Reply-To:From;\n\tb=ni2Wq2XHRN7npXSN9xe5zI5Srq3gGVdfkFqB4ogSppkUiiU1t6bfrcCyHMzsSshsw\n\tR/4aOdUPZGZ2S0plkHZUf4/geepBas5TdmEOZ3EmQDfJmJEBXL4nozmoTd0HUC2vIL\n\tODzNPdMC6i9t6z7E0tiv2fR++U60ui+PJJ3mdjIo=","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210618161807.24242-1-david.plowman@raspberrypi.com>\n\t<20210618161807.24242-4-david.plowman@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Organization":"Ideas on Board","Message-ID":"<0bdb1f06-66c1-53d9-6b73-b5229bc2ce24@ideasonboard.com>","Date":"Fri, 18 Jun 2021 21:21:26 +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":"<20210618161807.24242-4-david.plowman@raspberrypi.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v2 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>"}}]