[{"id":17898,"web_url":"https://patchwork.libcamera.org/comment/17898/","msgid":"<YNn68YnUVboYfJDo@pendragon.ideasonboard.com>","date":"2021-06-28T16:38:09","subject":"Re: [libcamera-devel] [PATCH v4 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 Mon, Jun 28, 2021 at 01:23:24PM +0100, David Plowman wrote:\n> The necessary tuning file and CamHelper is added for the ov9281 sensor.\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> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/ipa/raspberrypi/cam_helper_ov9281.cpp | 65 ++++++++++++++++\n>  src/ipa/raspberrypi/data/meson.build      |  1 +\n>  src/ipa/raspberrypi/data/ov9281.json      | 92 +++++++++++++++++++++++\n>  src/ipa/raspberrypi/meson.build           |  1 +\n>  4 files changed, 159 insertions(+)\n>  create mode 100644 src/ipa/raspberrypi/cam_helper_ov9281.cpp\n>  create mode 100644 src/ipa/raspberrypi/data/ov9281.json\n> \n> diff --git a/src/ipa/raspberrypi/cam_helper_ov9281.cpp b/src/ipa/raspberrypi/cam_helper_ov9281.cpp\n> new file mode 100644\n> index 00000000..54091f83\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/cam_helper_ov9281.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_ov9281.cpp - camera information for ov9281 sensor\n> + */\n> +\n> +#include <assert.h>\n\nThis doesn't seem to be needed. Copy & paste ? Once the metadata parsing\nrework gets merged, could you send a patch that removes the header from\nall locations where it's not needed ?\n\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(\"ov9281\", &Create);\n> diff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\n> index 92ad3272..adf89dbd 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> +    'ov9281.json',\n\nLet's keep these alphabetically sorted. I'll fix is when applying.\n\n>      'ov5647.json',\n>      'se327m12.json',\n>      'uncalibrated.json',\n> diff --git a/src/ipa/raspberrypi/data/ov9281.json b/src/ipa/raspberrypi/data/ov9281.json\n> new file mode 100644\n> index 00000000..ecd262be\n> --- /dev/null\n> +++ b/src/ipa/raspberrypi/data/ov9281.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..714ac27e 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_ov9281.cpp',\n\nIt would be nice to sort the whole array on top of this series.\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 A836AC321F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Jun 2021 16:38:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6DDEA684D3;\n\tMon, 28 Jun 2021 18:38:13 +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 AFE6B6028C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Jun 2021 18:38:11 +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 3E3CCB8A;\n\tMon, 28 Jun 2021 18:38:11 +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=\"IjUuEeB5\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1624898291;\n\tbh=lO4CbCWG9i5jfrhf44F0PfXZVo9COKyAYevTVjhwVPM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=IjUuEeB5X4Jh7NIVRcuGo+yG3YqMhey0nCGglCNkbZS4S1aC0/1osl24U7W8AOOGa\n\t8GNjCsNuuawZ0pF9jiKfpE+AFbPkG74FtxYrQQM8SC/4u8E0E+fTiNs+XQFsmTospA\n\tlF7xnWn8/14zciZbPIfl+fnLzoW28K6M2FUNcppY=","Date":"Mon, 28 Jun 2021 19:38:09 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Message-ID":"<YNn68YnUVboYfJDo@pendragon.ideasonboard.com>","References":"<20210628122324.14541-1-david.plowman@raspberrypi.com>\n\t<20210628122324.14541-4-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210628122324.14541-4-david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v4 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>"}}]