{"id":15209,"url":"https://patchwork.libcamera.org/api/1.1/patches/15209/?format=json","web_url":"https://patchwork.libcamera.org/patch/15209/","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":"<20211221234448.21944-1-laurent.pinchart@ideasonboard.com>","date":"2021-12-21T23:44:48","name":"[libcamera-devel,v1.1,3/4] ipa: raspberrypi: Add camera helper for Sony IMX296 sensor","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"3fd3c66d2af5430bbbb305395e2c6d638128f17f","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":{"id":14,"url":"https://patchwork.libcamera.org/api/1.1/users/14/?format=json","username":"pinchartl","first_name":"Laurent","last_name":"Pinchart","email":"laurent.pinchart@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/15209/mbox/","series":[{"id":2860,"url":"https://patchwork.libcamera.org/api/1.1/series/2860/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2860","date":"2021-12-21T23:44:48","name":null,"version":1,"mbox":"https://patchwork.libcamera.org/series/2860/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15209/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15209/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 629DCBE080\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Dec 2021 23:45:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B3A48608F9;\n\tWed, 22 Dec 2021 00:45:01 +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 7D90760223\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Dec 2021 00:44:59 +0100 (CET)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D6873894;\n\tWed, 22 Dec 2021 00:44:58 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"b/qFjn+N\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1640130299;\n\tbh=j2Cz2yqgW9fXPJHtjHMZi04wZDdEnoEJt3StdzKXNRI=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=b/qFjn+NJUGoud8qi6jL6xs/h3HR2YPczfVaxhn7gV63dfNR99EFy+KEKPcTX5BIP\n\tM6p9ACeyI9OajB8Tj/FBtFx4Q/vi8oCcE61D71P4SQraKzqsNukvnGTCjfO/mZWayg\n\tsk7Qu6rVlBhMV5X6zlZ0iVCu7F6k7ZnUeD+aC+ao=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 22 Dec 2021 01:44:48 +0200","Message-Id":"<20211221234448.21944-1-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.32.0","In-Reply-To":"<20211219232714.11427-4-laurent.pinchart@ideasonboard.com>","References":"<20211219232714.11427-4-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v1.1 3/4] ipa: raspberrypi: Add camera\n\thelper for Sony IMX296 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":"From: Naushir Patuck <naush@raspberrypi.com>\n\nThe Sony IMX296 sensor has an exponential gain model, and adds a fixed\n14.26µs offset to the exposure time expressed in line units.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\nChanges since v1:\n\n- Drop metadata support\n---\n src/ipa/raspberrypi/cam_helper_imx296.cpp | 69 +++++++++++++++++++++++\n src/ipa/raspberrypi/meson.build           |  1 +\n 2 files changed, 70 insertions(+)\n create mode 100644 src/ipa/raspberrypi/cam_helper_imx296.cpp\n\n\nbase-commit: 8ff5a8d548eee7c2cb14b355867debdb29e75419\nprerequisite-patch-id: 94059e3f2e08c8ed4c077cd3fbc9ab5f6a43cbe5\nprerequisite-patch-id: c4afb92de814501d8e0b6f9daa967be862351ed8","diff":"diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp\nnew file mode 100644\nindex 000000000000..a1a771cb96d5\n--- /dev/null\n+++ b/src/ipa/raspberrypi/cam_helper_imx296.cpp\n@@ -0,0 +1,69 @@\n+/* SPDX-License-Identifier: BSD-2-Clause */\n+/*\n+ * Copyright (C) 2020, Raspberry Pi (Trading) Limited\n+ *\n+ * cam_helper_imx296.cpp - Camera helper for IMX296 sensor\n+ */\n+\n+#include <algorithm>\n+#include <cmath>\n+#include <stddef.h>\n+\n+#include \"cam_helper.hpp\"\n+\n+using namespace RPiController;\n+using libcamera::utils::Duration;\n+using namespace std::literals::chrono_literals;\n+\n+class CamHelperImx296 : public CamHelper\n+{\n+public:\n+\tCamHelperImx296();\n+\tuint32_t GainCode(double gain) const override;\n+\tdouble Gain(uint32_t gain_code) const override;\n+\tuint32_t ExposureLines(Duration exposure) const override;\n+\tDuration Exposure(uint32_t exposure_lines) const override;\n+\n+private:\n+\tstatic constexpr uint32_t maxGainCode = 239;\n+\tstatic constexpr Duration timePerLine = 550.0 / 37.125e6 * 1.0s;\n+\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+CamHelperImx296::CamHelperImx296()\n+\t: CamHelper(nullptr, frameIntegrationDiff)\n+{\n+}\n+\n+uint32_t CamHelperImx296::GainCode(double gain) const\n+{\n+\tuint32_t code = 20 * std::log10(gain) * 10;\n+\treturn std::min(code, maxGainCode);\n+}\n+\n+double CamHelperImx296::Gain(uint32_t gain_code) const\n+{\n+\treturn std::pow(10.0, gain_code / 200.0);\n+}\n+\n+uint32_t CamHelperImx296::ExposureLines(Duration exposure) const\n+{\n+\treturn (exposure - 14.26us) / timePerLine;\n+}\n+\n+Duration CamHelperImx296::Exposure(uint32_t exposure_lines) const\n+{\n+\treturn exposure_lines * timePerLine + 14.26us;\n+}\n+\n+static CamHelper *Create()\n+{\n+\treturn new CamHelperImx296();\n+}\n+\n+static RegisterCamHelper reg(\"imx296\", &Create);\ndiff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\nindex 176055f42248..32897e07dad9 100644\n--- a/src/ipa/raspberrypi/meson.build\n+++ b/src/ipa/raspberrypi/meson.build\n@@ -21,6 +21,7 @@ rpi_ipa_sources = files([\n     'cam_helper_ov5647.cpp',\n     'cam_helper_imx219.cpp',\n     'cam_helper_imx290.cpp',\n+    'cam_helper_imx296.cpp',\n     'cam_helper_imx477.cpp',\n     'cam_helper_imx519.cpp',\n     'cam_helper_ov9281.cpp',\n","prefixes":["libcamera-devel","v1.1","3/4"]}