{"id":19779,"url":"https://patchwork.libcamera.org/api/patches/19779/?format=json","web_url":"https://patchwork.libcamera.org/patch/19779/","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":"<20240319151121.561588-3-kieran.bingham@ideasonboard.com>","date":"2024-03-19T15:11:21","name":"[2/2] ipa: rpi: Add IMX283 support","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1312642f05a904e16a723f0c1eb33ec3d7f017a4","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/19779/mbox/","series":[{"id":4233,"url":"https://patchwork.libcamera.org/api/series/4233/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4233","date":"2024-03-19T15:11:19","name":"ipa: Add support for the Sony IMX283 Camera Sensor.","version":1,"mbox":"https://patchwork.libcamera.org/series/4233/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/19779/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/19779/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 9AF24C3274\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 19 Mar 2024 15:11:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 437EC62D2B;\n\tTue, 19 Mar 2024 16:11:29 +0100 (CET)","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 26EC562CAE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Mar 2024 16:11:26 +0100 (CET)","from Monstersaurus.local\n\t(aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net\n\t[82.37.23.78])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4710415C5;\n\tTue, 19 Mar 2024 16:10:59 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"TJL2st2W\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1710861059;\n\tbh=S0dSskxn+MAX19CtbjvHHtGk12DfB09FRAvzD+O6EqQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=TJL2st2W+xe8fDpELvpMc6QvqWnB7lCwlhDwYvOpljiSm3bE4hf8ane+w91jTJtyi\n\tYenEeFGNKdSNASDKiYwLHBMyEbIsscyhNnH2ncITCc2Z0jst1MUVNw4X8H/eXQhHYD\n\tE3tQTKzEuHUKJoAhIPWL6lXHVeEEBFDPhad/z6T8=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Cc":"Will Whang <will@willwhang.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"[PATCH 2/2] ipa: rpi: Add IMX283 support","Date":"Tue, 19 Mar 2024 15:11:21 +0000","Message-Id":"<20240319151121.561588-3-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20240319151121.561588-1-kieran.bingham@ideasonboard.com>","References":"<20240319151121.561588-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"From: Will Whang <will@willwhang.com>\n\nAdd tuning files and camera helpers for the Sony IMX283.\n\nSigned-off-by: Will Whang <will@willwhang.com>\n[Kieran: Fix checkstyle formatting, extend commit message, remove pi5]\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n---\nThis is a partial cherry-pick from\nhttps://github.com/raspberrypi/libcamera/pull/118\n\nThe Pi5 support has not been included, as Pi5 is not yet upstream.\nOnce Pi5 is submitted, the remaining components from\nhttps://github.com/raspberrypi/libcamera/pull/118 for the IMX283 should\nbe submitted on top.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/ipa/rpi/cam_helper/cam_helper_imx283.cpp |  73 +++++\n src/ipa/rpi/cam_helper/meson.build           |   1 +\n src/ipa/rpi/vc4/data/imx283.json             | 320 +++++++++++++++++++\n src/ipa/rpi/vc4/data/meson.build             |   1 +\n 4 files changed, 395 insertions(+)\n create mode 100644 src/ipa/rpi/cam_helper/cam_helper_imx283.cpp\n create mode 100644 src/ipa/rpi/vc4/data/imx283.json","diff":"diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx283.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx283.cpp\nnew file mode 100644\nindex 000000000000..5674b75466b5\n--- /dev/null\n+++ b/src/ipa/rpi/cam_helper/cam_helper_imx283.cpp\n@@ -0,0 +1,73 @@\n+/* SPDX-License-Identifier: BSD-2-Clause */\n+/*\n+ * Copyright (C) 2021, Raspberry Pi Ltd\n+ *\n+ * cam_helper_imx283.cpp - camera information for imx283 sensor\n+ */\n+\n+#include <assert.h>\n+\n+#include \"cam_helper.h\"\n+#include \"math.h\"\n+using namespace RPiController;\n+\n+class CamHelperImx283 : public CamHelper\n+{\n+public:\n+\tCamHelperImx283();\n+\tuint32_t gainCode(double gain) const override;\n+\tdouble gain(uint32_t gainCode) const override;\n+\tvoid getDelays(int &exposureDelay, int &gainDelay,\n+\t\t       int &vblankDelay, int &hblankDelay) const override;\n+\tunsigned int hideFramesModeSwitch() const override;\n+\n+private:\n+\t/*\n+\t * Smallest difference between the frame length and integration time,\n+\t * in units of lines.\n+\t */\n+\tstatic constexpr int frameIntegrationDiff = 4;\n+};\n+\n+/*\n+ * Imx283 doesn't output metadata, so we have to use the \"unicam parser\" which\n+ * works by counting frames.\n+ */\n+\n+CamHelperImx283::CamHelperImx283()\n+\t: CamHelper({}, frameIntegrationDiff)\n+{\n+}\n+\n+uint32_t CamHelperImx283::gainCode(double gain) const\n+{\n+\treturn static_cast<uint32_t>(2048.0 - 2048.0 / gain);\n+}\n+\n+double CamHelperImx283::gain(uint32_t gainCode) const\n+{\n+\treturn static_cast<double>(2048.0 / (2048 - gainCode));\n+}\n+\n+void CamHelperImx283::getDelays(int &exposureDelay, int &gainDelay,\n+\t\t\t\tint &vblankDelay, int &hblankDelay) const\n+{\n+\t/* The driver appears to behave as follows: */\n+\texposureDelay = 2;\n+\tgainDelay = 2;\n+\tvblankDelay = 2;\n+\thblankDelay = 2;\n+}\n+\n+unsigned int CamHelperImx283::hideFramesModeSwitch() const\n+{\n+\t/* After a mode switch, we seem to get 1 bad frame. */\n+\treturn 1;\n+}\n+\n+static CamHelper *create()\n+{\n+\treturn new CamHelperImx283();\n+}\n+\n+static RegisterCamHelper reg(\"imx283\", &create);\ndiff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build\nindex 7262505742f3..1e43f1da29cd 100644\n--- a/src/ipa/rpi/cam_helper/meson.build\n+++ b/src/ipa/rpi/cam_helper/meson.build\n@@ -4,6 +4,7 @@ rpi_ipa_cam_helper_sources = files([\n     'cam_helper.cpp',\n     'cam_helper_ov5647.cpp',\n     'cam_helper_imx219.cpp',\n+    'cam_helper_imx283.cpp',\n     'cam_helper_imx290.cpp',\n     'cam_helper_imx296.cpp',\n     'cam_helper_imx477.cpp',\ndiff --git a/src/ipa/rpi/vc4/data/imx283.json b/src/ipa/rpi/vc4/data/imx283.json\nnew file mode 100644\nindex 000000000000..20892de19299\n--- /dev/null\n+++ b/src/ipa/rpi/vc4/data/imx283.json\n@@ -0,0 +1,320 @@\n+{\n+    \"version\": 2.0,\n+    \"target\": \"bcm2835\",\n+    \"algorithms\": [\n+        {\n+            \"rpi.black_level\":\n+            {\n+                \"black_level\": 3200\n+            }\n+        },\n+        {\n+            \"rpi.dpc\": { }\n+        },\n+        {\n+            \"rpi.lux\":\n+            {\n+                \"reference_shutter_speed\": 2461,\n+                \"reference_gain\": 1.0,\n+                \"reference_aperture\": 1.0,\n+                \"reference_lux\": 1148,\n+                \"reference_Y\": 13314\n+            }\n+        },\n+        {\n+            \"rpi.noise\":\n+            {\n+                \"reference_constant\": 0,\n+                \"reference_slope\": 2.204\n+            }\n+        },\n+        {\n+            \"rpi.geq\":\n+            {\n+                \"offset\": 199,\n+                \"slope\": 0.01947\n+            }\n+        },\n+        {\n+            \"rpi.sdn\": { }\n+        },\n+        {\n+            \"rpi.awb\":\n+            {\n+                \"priors\": [\n+                    {\n+                        \"lux\": 0,\n+                        \"prior\":\n+                        [\n+                            2000, 1.0,\n+                            3000, 0.0,\n+                            13000, 0.0\n+                        ]\n+                    },\n+                    {\n+                        \"lux\": 800,\n+                        \"prior\":\n+                        [\n+                            2000, 0.0,\n+                            6000, 2.0,\n+                            13000, 2.0\n+                        ]\n+                    },\n+                    {\n+                        \"lux\": 1500,\n+                        \"prior\":\n+                        [\n+                            2000, 0.0,\n+                            4000, 1.0,\n+                            6000, 6.0,\n+                            6500, 7.0,\n+                            7000, 1.0,\n+                            13000, 1.0\n+                        ]\n+                    }\n+                ],\n+                \"modes\":\n+                {\n+                    \"auto\":\n+                    {\n+                        \"lo\": 2500,\n+                        \"hi\": 8000\n+                    },\n+                    \"incandescent\":\n+                    {\n+                        \"lo\": 2500,\n+                        \"hi\": 3000\n+                    },\n+                    \"tungsten\":\n+                    {\n+                        \"lo\": 3000,\n+                        \"hi\": 3500\n+                    },\n+                    \"fluorescent\":\n+                    {\n+                        \"lo\": 4000,\n+                        \"hi\": 4700\n+                    },\n+                    \"indoor\":\n+                    {\n+                        \"lo\": 3000,\n+                        \"hi\": 5000\n+                    },\n+                    \"daylight\":\n+                    {\n+                        \"lo\": 5500,\n+                        \"hi\": 6500\n+                    },\n+                    \"cloudy\":\n+                    {\n+                        \"lo\": 7000,\n+                        \"hi\": 8600\n+                    }\n+                },\n+                \"bayes\": 1,\n+                \"ct_curve\":\n+                [\n+                    2213.0, 0.9607, 0.2593,\n+                    2255.0, 0.9309, 0.2521,\n+                    2259.0, 0.9257, 0.2508,\n+                    5313.0, 0.4822, 0.5909,\n+                    6237.0, 0.4726, 0.6376\n+                ],\n+                \"sensitivity_r\": 1.0,\n+                \"sensitivity_b\": 1.0,\n+                \"transverse_pos\": 0.0144,\n+                \"transverse_neg\": 0.01\n+            }\n+        },\n+        {\n+            \"rpi.agc\":\n+            {\n+                \"metering_modes\":\n+                {\n+                    \"centre-weighted\":\n+                    {\n+                        \"weights\":\n+                        [\n+                            3, 3, 3, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 0, 0\n+                        ]\n+                    },\n+                    \"spot\":\n+                    {\n+                        \"weights\":\n+                        [\n+                            2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0\n+                        ]\n+                    },\n+                    \"matrix\":\n+                    {\n+                        \"weights\":\n+                        [\n+                            1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1\n+                        ]\n+                    }\n+                },\n+                \"exposure_modes\":\n+                {\n+                    \"normal\":\n+                    {\n+                        \"shutter\": [ 100, 10000, 30000, 60000, 120000 ],\n+                        \"gain\": [ 1.0, 2.0, 4.0, 6.0, 6.0 ]\n+                    },\n+                    \"short\":\n+                    {\n+                        \"shutter\": [ 100, 5000, 10000, 20000, 120000 ],\n+                        \"gain\": [ 1.0, 2.0, 4.0, 6.0, 6.0 ]\n+                    }\n+                },\n+                \"constraint_modes\":\n+                {\n+                    \"normal\": [\n+                        {\n+                            \"bound\": \"LOWER\",\n+                            \"q_lo\": 0.98,\n+                            \"q_hi\": 1.0,\n+                            \"y_target\":\n+                            [\n+                                0, 0.5,\n+                                1000, 0.5\n+                            ]\n+                        }\n+                    ],\n+                    \"highlight\": [\n+                        {\n+                            \"bound\": \"LOWER\",\n+                            \"q_lo\": 0.98,\n+                            \"q_hi\": 1.0,\n+                            \"y_target\":\n+                            [\n+                                0, 0.5,\n+                                1000, 0.5\n+                            ]\n+                        },\n+                        {\n+                            \"bound\": \"UPPER\",\n+                            \"q_lo\": 0.98,\n+                            \"q_hi\": 1.0,\n+                            \"y_target\":\n+                            [\n+                                0, 0.8,\n+                                1000, 0.8\n+                            ]\n+                        }\n+                    ]\n+                },\n+                \"y_target\":\n+                [\n+                    0, 0.16,\n+                    1000, 0.165,\n+                    10000, 0.17\n+                ]\n+            }\n+        },\n+        {\n+            \"rpi.alsc\":\n+            {\n+                \"omega\": 1.3,\n+                \"n_iter\": 100,\n+                \"luminance_strength\": 0.7\n+            }\n+        },\n+        {\n+            \"rpi.contrast\":\n+            {\n+                \"ce_enable\": 1,\n+                \"gamma_curve\":\n+                [\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+        {\n+            \"rpi.ccm\":\n+            {\n+                \"ccms\": [\n+                    {\n+                        \"ct\": 2213,\n+                        \"ccm\":\n+                        [\n+                            1.91264, -0.27609, -0.63655,\n+                            -0.65708, 2.11718, -0.46009,\n+                            0.03629, -1.38441, 2.34811\n+                        ]\n+                    },\n+                    {\n+                        \"ct\": 2255,\n+                        \"ccm\":\n+                        [\n+                            1.90369, -0.29309, -0.61059,\n+                            -0.64693, 2.08169, -0.43476,\n+                            0.04086, -1.29999, 2.25914\n+                        ]\n+                    },\n+                    {\n+                        \"ct\": 2259,\n+                        \"ccm\":\n+                        [\n+                            1.92762, -0.35134, -0.57628,\n+                            -0.63523, 2.08481, -0.44958,\n+                            0.06754, -1.32953, 2.26199\n+                        ]\n+                    },\n+                    {\n+                        \"ct\": 5313,\n+                        \"ccm\":\n+                        [\n+                            1.75924, -0.54053, -0.21871,\n+                            -0.38159, 1.88671, -0.50511,\n+                            -0.00747, -0.53492, 1.54239\n+                        ]\n+                    },\n+                    {\n+                        \"ct\": 6237,\n+                        \"ccm\":\n+                        [\n+                            2.19299, -0.74764, -0.44536,\n+                            -0.51678, 2.27651, -0.75972,\n+                            -0.06498, -0.74269, 1.80767\n+                        ]\n+                    }\n+                ]\n+            }\n+        },\n+        {\n+            \"rpi.sharpen\": { }\n+        }\n+    ]\n+}\n\\ No newline at end of file\ndiff --git a/src/ipa/rpi/vc4/data/meson.build b/src/ipa/rpi/vc4/data/meson.build\nindex afbf875a113a..60477c112196 100644\n--- a/src/ipa/rpi/vc4/data/meson.build\n+++ b/src/ipa/rpi/vc4/data/meson.build\n@@ -3,6 +3,7 @@\n conf_files = files([\n     'imx219.json',\n     'imx219_noir.json',\n+    'imx283.json',\n     'imx290.json',\n     'imx296.json',\n     'imx296_mono.json',\n","prefixes":["2/2"]}