{"id":12659,"url":"https://patchwork.libcamera.org/api/patches/12659/?format=json","web_url":"https://patchwork.libcamera.org/patch/12659/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210618220430.31457-4-david.plowman@raspberrypi.com>","date":"2021-06-18T22:04:30","name":"[libcamera-devel,v3,3/3] libcamera: ipa: raspberrypi: Add support for ov9281 sensor","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ec5ff119bde72ba6cce67707c6d143f041a43604","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/12659/mbox/","series":[{"id":2155,"url":"https://patchwork.libcamera.org/api/series/2155/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2155","date":"2021-06-18T22:04:28","name":"Support monochrome raw sensors","version":3,"mbox":"https://patchwork.libcamera.org/series/2155/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12659/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12659/checks/","tags":{},"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 B8508C3218\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Jun 2021 22:04:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C3FC66894E;\n\tSat, 19 Jun 2021 00:04:39 +0200 (CEST)","from mail-wr1-x431.google.com (mail-wr1-x431.google.com\n\t[IPv6:2a00:1450:4864:20::431])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8785F68947\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 19 Jun 2021 00:04:35 +0200 (CEST)","by mail-wr1-x431.google.com with SMTP id m18so12276226wrv.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Jun 2021 15:04:35 -0700 (PDT)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tz6sm6966322wrl.15.2021.06.18.15.04.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 18 Jun 2021 15:04:34 -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=\"IEBwXe//\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=6TGYeinK5u1yh1QsS2F056A7jIP5g12wIbkJ8+fEVfw=;\n\tb=IEBwXe//J3qsKqBtu9nggVwruAiwImycFYPkSGQsSp33x8TaRn5qmwqrBQ1DDGYt5c\n\tATikfQbd990lqO+HIz9FTk7NyJfy9Zpk0Bv6AIoKn3mQ7ebZTkceQwjie9CTVMnRO0kk\n\tmIzLpj8SB+bphyVn/Z5npMNsuCkYnDFeOKonLQaEaJWIsDUp9iW6s2EpJebr6rNriX75\n\tYWQKj8QEFgY3KcWpgYz6uaEQmJDsWCPrjMnT55Wo956ZC0c6ocMHgGgnfXSNjgp2O5GZ\n\t341Eh94qdD5juooAa9CRiU79kdYSy+BsNxOphDuWrPQGw77vFXUAzgwxCI+hK53lHCav\n\tpEmA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=6TGYeinK5u1yh1QsS2F056A7jIP5g12wIbkJ8+fEVfw=;\n\tb=ktqp1m67jbptyYfYYzGVDt4brAUx7GRs1oiiVDH6hRqYSZwbSTH0EPjOfylIde+/u3\n\tUw1Gikdt4tXxqgs07dLaVGk7ojDsQalmxRYrwZZ2CtRSNxwpqN+Dd/8hUMBDEf+mXyz1\n\t80iNhN63AZhbEI1Wcz7hTsQBwWQkUfYrlqvaWlFx286I60F+B1er8cTgL+jN8JLZULyr\n\tIsgp8+Dvo13J51JiJbJ0U04YxPc5gL064yNLI18BPJsAMuso/Us2UnQ545utKWFn6h2T\n\tVDPV5QbNQTOX+dlk5xPFwIRn2g6qcM5pgAqYdZqp0v/pS+7ezlxNIdHS8FuXIk9vC0QC\n\tWc4Q==","X-Gm-Message-State":"AOAM531WNHViMEJ33xHLFB/6b5lIYNPYABW12cduMJ4nDQFq0A7D/ryM\n\t37kKHvFOu2fE12FpVoCuIYcQBin0uvmzfVjo","X-Google-Smtp-Source":"ABdhPJwaxQEo52xkzfkwrkOk5w0qsjkoOKO8GJ75rRreOqQP9W2PPTr7u2I34+pfZd9f7xl3EYJqvg==","X-Received":"by 2002:adf:fa08:: with SMTP id\n\tm8mr14367450wrr.319.1624053874831; \n\tFri, 18 Jun 2021 15:04:34 -0700 (PDT)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 18 Jun 2021 23:04:30 +0100","Message-Id":"<20210618220430.31457-4-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20210618220430.31457-1-david.plowman@raspberrypi.com>","References":"<20210618220430.31457-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 3/3] libcamera: ipa: raspberrypi: Add\n\tsupport 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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The necessary tuning file and CamHelper is added for the ov9281 sensor\n(which the driver names as the \"mov9281\").\n\nThe ov9281 is a 1280x800 monochrome global shutter sensor. To enable\nit, please add\n\ndtoverlay=ov9281\n\nto the /boot/config.txt file and reboot the Pi.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-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","diff":"diff --git a/src/ipa/raspberrypi/cam_helper_mov9281.cpp b/src/ipa/raspberrypi/cam_helper_mov9281.cpp\nnew file mode 100644\nindex 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);\ndiff --git a/src/ipa/raspberrypi/data/meson.build b/src/ipa/raspberrypi/data/meson.build\nindex 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',\ndiff --git a/src/ipa/raspberrypi/data/mov9281.json b/src/ipa/raspberrypi/data/mov9281.json\nnew file mode 100644\nindex 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+}\ndiff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\nindex 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","prefixes":["libcamera-devel","v3","3/3"]}