{"id":20815,"url":"https://patchwork.libcamera.org/api/1.1/patches/20815/?format=json","web_url":"https://patchwork.libcamera.org/patch/20815/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20240807093449.1926-3-naush@raspberrypi.com>","date":"2024-08-07T09:34:49","name":"[v1,2/2] ipa: rpi: Adding IMX283 support","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"237b77149a7e3e558e09ff9110cc612176662e26","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/20815/mbox/","series":[{"id":4493,"url":"https://patchwork.libcamera.org/api/1.1/series/4493/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4493","date":"2024-08-07T09:34:47","name":"Raspberrypi: Add support for IMX283","version":1,"mbox":"https://patchwork.libcamera.org/series/4493/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/20815/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/20815/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 40CF9C324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  7 Aug 2024 09:35:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 33AD0633B4;\n\tWed,  7 Aug 2024 11:35:00 +0200 (CEST)","from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com\n\t[IPv6:2a00:1450:4864:20::12c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 899FA633AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  7 Aug 2024 11:34:56 +0200 (CEST)","by mail-lf1-x12c.google.com with SMTP id\n\t2adb3069b0e04-52f01993090so2034469e87.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 07 Aug 2024 02:34:56 -0700 (PDT)","from naush-laptop.pitowers.org ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\tffacd0b85a97d-36bbcf1daeesm15449769f8f.33.2024.08.07.02.34.54\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 07 Aug 2024 02:34:54 -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=\"GqX28oc+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1723023295; x=1723628095;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=FJy3vdIz7fRnBV2svyHR9IKg3thV8MfAzuQZV9tYwks=;\n\tb=GqX28oc+pwrQMDtw7SkCxVs3EJWS9bD6FObO2vOvVUCWUcnyDf+XCVQehLKO34EN4u\n\tbJ1j55qzgkjijqklExa15hyeWrlYvZMyVw34hvUj6bPdi2GHJNf2oI9AidA4am80wQ8v\n\tCi+g19NeD7ApFDj7dX6wPe8B+zrmfMoBm73BpOq4CAfMGuwASX3w2UH35UrznQBuxX78\n\tTwaZ/yZ4fxru52HhRGtXHm8/oxv4cExotuNWmrtxNcBDZW1Jma8d8066HrNgVO6TekXw\n\t98BEqafSlPqmJfCLkIQLoBCD7CeOH/H0/TZUjhjd9PhaWJl9hIaWR8kbMyftN+WR4Boo\n\tZg7Q==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1723023295; x=1723628095;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc\n\t:subject:date:message-id:reply-to;\n\tbh=FJy3vdIz7fRnBV2svyHR9IKg3thV8MfAzuQZV9tYwks=;\n\tb=jQrwzRetJzyg/LVylsaX5xlS55UkI6uVncwX/peJKO1MwN4NhbtjumXNoZQgyc8RFp\n\taye8KS9AGtlesvsK0zR2Fm2OAKaggOUKqFMON5Rsu/WChvWNzn7EyDZKubwSEKp1QGuH\n\tMvcgiCtiGctNqewCp5D0/8DmQoOY8pF9sJbnu0awUYene2b2lfhukKA0f8T/K3V6/8tc\n\tMuC/1sTMfSzH46P392Smb3/Sdn+AWbL2rKQrlSarBZM5gpHlIfIpf58OevH1CET/0Yak\n\tvciwiszQeR7iHnuLXgU0IZ9X1VbYQXdTdRMGRiohzwbDmQ6maiGZ7DrGAhquB5UptBk0\n\tFWvg==","X-Gm-Message-State":"AOJu0YwX1LJ4kFikwo59wHJ31Tr7xJZbCXkaEf7mN5t5ga6Hpiqjx4Io\n\tzGoh1hs239ta9plx/UP/Jk1hvx7xQNnHGpnieyqeDK25TlU2bJGXhU0QzQ5X5NdHnLrFVxLgTN4\n\t6","X-Google-Smtp-Source":"AGHT+IFhQi933Dq2riS+Gur/F8fQcrorq5cIsV2CqFrWwqNlZh+eqWeK3bFo5oIWNaPk8XtFFi03gw==","X-Received":"by 2002:a05:6512:3e15:b0:52c:e0fb:92c0 with SMTP id\n\t2adb3069b0e04-530bb385315mr10843993e87.34.1723023295111; \n\tWed, 07 Aug 2024 02:34:55 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"will whang <will@willwhang.com>, Naushir Patuck <naush@raspberrypi.com>","Subject":"[PATCH v1 2/2] ipa: rpi: Adding IMX283 support","Date":"Wed,  7 Aug 2024 10:34:49 +0100","Message-Id":"<20240807093449.1926-3-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20240807093449.1926-1-naush@raspberrypi.com>","References":"<20240807093449.1926-1-naush@raspberrypi.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 support for the IMX283 sensor for the VC4 target.\n\nSigned-off-by: will whang <will@willwhang.com>\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.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             | 313 +++++++++++++++++++\n src/ipa/rpi/vc4/data/meson.build             |   1 +\n 4 files changed, 388 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..1fd4d7f31b04\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) 2024, 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 delayed controls 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..bfacecc8e3c2\n--- /dev/null\n+++ b/src/ipa/rpi/vc4/data/imx283.json\n@@ -0,0 +1,313 @@\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+                },\n+                \"bayes\": 1,\n+                \"ct_curve\":\n+                [\n+                    2213.0, 0.9607, 0.2593,\n+                    5313.0, 0.4822, 0.5909,\n+                    6237.0, 0.4739, 0.6308\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+}\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":["v1","2/2"]}