{"id":22159,"url":"https://patchwork.libcamera.org/api/patches/22159/?format=json","web_url":"https://patchwork.libcamera.org/patch/22159/","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":"<20241204105223.45807-1-isaac.scott@ideasonboard.com>","date":"2024-12-04T10:52:23","name":"[v1] libcamera: rpi: Add support for IMX258","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7c61f3f64cdef02a64b296dc755c452664d4a08f","submitter":{"id":215,"url":"https://patchwork.libcamera.org/api/people/215/?format=json","name":"Isaac Scott","email":"isaac.scott@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22159/mbox/","series":[{"id":4844,"url":"https://patchwork.libcamera.org/api/series/4844/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=4844","date":"2024-12-04T10:52:23","name":"[v1] libcamera: rpi: Add support for IMX258","version":1,"mbox":"https://patchwork.libcamera.org/series/4844/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22159/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22159/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 483E3BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Dec 2024 10:52:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 24084660AD;\n\tWed,  4 Dec 2024 11:52:53 +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 EBB84618B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Dec 2024 11:52:50 +0100 (CET)","from isaac-ThinkPad-T16-Gen-2.lan\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C5E9E6D6;\n\tWed,  4 Dec 2024 11:52:22 +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=\"XJqabQTT\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733309542;\n\tbh=M2XHIdVNQacwasaCWQen2lIwg2f00tx+UGqMxTbTts4=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=XJqabQTTNhi2Smvv1m9LegCQ9OYScLS1yRvFNKGqBG+dhXbrI7Bg+7YLFIC9JWAIZ\n\tC9jQk9FmKAJkiLagAFYgT4GM+mNYPxsUX+jpPYhKgFxDzC5zBYOfmmK276TGNRHDZ4\n\tv9gjiBR1rvKxRoMthDtZJf+FReiwOiaPc06Yua8I=","From":"Isaac Scott <isaac.scott@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Cc":"Isaac Scott <isaac.scott@ideasonboard.com>","Subject":"[PATCH v1] libcamera: rpi: Add support for IMX258","Date":"Wed,  4 Dec 2024 10:52:23 +0000","Message-ID":"<20241204105223.45807-1-isaac.scott@ideasonboard.com>","X-Mailer":"git-send-email 2.43.0","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":"Add support for the IMX258 camera. This patch adds a minimal cam_helper\nimplementation that allows the IMX258 sensor to be listed by cam, and\nsubsequently be used remotely in tools such as Camshark.\n\nBased on the implementation of the IMX290's camera helper, adjusted to\nuse the equation listed in the IMX258 datasheet used to calculate\nanalogue gain.\n\nSigned-off-by: Isaac Scott <isaac.scott@ideasonboard.com>\n---\n src/ipa/rpi/cam_helper/cam_helper_imx258.cpp | 60 ++++++++++++++++++++\n src/ipa/rpi/cam_helper/meson.build           |  1 +\n 2 files changed, 61 insertions(+)\n create mode 100644 src/ipa/rpi/cam_helper/cam_helper_imx258.cpp","diff":"diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp\nnew file mode 100644\nindex 00000000..12c0332a\n--- /dev/null\n+++ b/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp\n@@ -0,0 +1,60 @@\n+/* SPDX-License-Identifier: BSD-2-Clause */\n+/*\n+ * Copyright (C) 2024 Ideas On Board Oy\n+ *\n+ * camera helper for imx258 sensor\n+ * based on Raspberry Pi's imx290 helper\n+ */\n+\n+#include <cmath>\n+\n+#include \"cam_helper.h\"\n+\n+using namespace RPiController;\n+\n+class CamHelperImx258 : public CamHelper\n+{\n+public:\n+\tCamHelperImx258();\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+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 = 2;\n+};\n+\n+CamHelperImx258::CamHelperImx258()\n+\t: CamHelper({}, frameIntegrationDiff)\n+{\n+}\n+\n+uint32_t CamHelperImx258::gainCode(double gain) const\n+{\n+\treturn static_cast<uint32_t>(512 - 512 / gain);\n+}\n+\n+double CamHelperImx258::gain(uint32_t gainCode) const\n+{\n+\treturn 512.0 / (512.0 - gainCode);\n+}\n+\n+void CamHelperImx258::getDelays(int &exposureDelay, int &gainDelay,\n+\t\t\t\tint &vblankDelay, int &hblankDelay) const\n+{\n+\texposureDelay = 2;\n+\tgainDelay = 2;\n+\tvblankDelay = 2;\n+\thblankDelay = 2;\n+}\n+\n+static CamHelper *create()\n+{\n+\treturn new CamHelperImx258();\n+}\n+\n+static RegisterCamHelper reg(\"imx258\", &create);\ndiff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build\nindex 03e88fe0..a8245e42 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_imx258.cpp',\n     'cam_helper_imx283.cpp',\n     'cam_helper_imx290.cpp',\n     'cam_helper_imx296.cpp',\n","prefixes":["v1"]}