[{"id":22314,"web_url":"https://patchwork.libcamera.org/comment/22314/","msgid":"<164751666069.856468.433622060271256723@Monstersaurus>","date":"2022-03-17T11:31:00","subject":"Re: [libcamera-devel] [PATCH v1.1 3/4] ipa: raspberrypi: Add camera\n\thelper for Sony IMX296 sensor","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Quoting Laurent Pinchart (2021-12-21 23:44:48)\n> From: Naushir Patuck <naush@raspberrypi.com>\n> \n> The Sony IMX296 sensor has an exponential gain model, and adds a fixed\n> 14.26µs offset to the exposure time expressed in line units.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n> Changes 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> diff --git a/src/ipa/raspberrypi/cam_helper_imx296.cpp b/src/ipa/raspberrypi/cam_helper_imx296.cpp\n> new file mode 100644\n> index 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> +       CamHelperImx296();\n> +       uint32_t GainCode(double gain) const override;\n> +       double Gain(uint32_t gain_code) const override;\n> +       uint32_t ExposureLines(Duration exposure) const override;\n> +       Duration Exposure(uint32_t exposure_lines) const override;\n> +\n> +private:\n> +       static constexpr uint32_t maxGainCode = 239;\n> +       static constexpr Duration timePerLine = 550.0 / 37.125e6 * 1.0s;\n> +\n> +       /*\n> +        * Smallest difference between the frame length and integration time,\n> +        * in units of lines.\n> +        */\n> +       static constexpr int frameIntegrationDiff = 4;\n> +};\n> +\n> +CamHelperImx296::CamHelperImx296()\n> +       : CamHelper(nullptr, frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx296::GainCode(double gain) const\n> +{\n> +       uint32_t code = 20 * std::log10(gain) * 10;\n> +       return std::min(code, maxGainCode);\n> +}\n> +\n> +double CamHelperImx296::Gain(uint32_t gain_code) const\n> +{\n> +       return std::pow(10.0, gain_code / 200.0);\n> +}\n> +\n> +uint32_t CamHelperImx296::ExposureLines(Duration exposure) const\n> +{\n> +       return (exposure - 14.26us) / timePerLine;\n> +}\n> +\n> +Duration CamHelperImx296::Exposure(uint32_t exposure_lines) const\n> +{\n> +       return exposure_lines * timePerLine + 14.26us;\n> +}\n> +\n> +static CamHelper *Create()\n> +{\n> +       return new CamHelperImx296();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx296\", &Create);\n> diff --git a/src/ipa/raspberrypi/meson.build b/src/ipa/raspberrypi/meson.build\n> index 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> \n> base-commit: 8ff5a8d548eee7c2cb14b355867debdb29e75419\n> prerequisite-patch-id: 94059e3f2e08c8ed4c077cd3fbc9ab5f6a43cbe5\n> prerequisite-patch-id: c4afb92de814501d8e0b6f9daa967be862351ed8\n> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 A0AEBBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 17 Mar 2022 11:31:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0FFCF604E9;\n\tThu, 17 Mar 2022 12:31:05 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CC6E8601F8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 17 Mar 2022 12:31:03 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 86309493;\n\tThu, 17 Mar 2022 12:31:03 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647516665;\n\tbh=JwvdWojsGFBCcdNdoE7Iu9WleaktwKzTnbflzW8vTHI=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=oxjBbie1EWAR1Tt1ngMkVyqA7m5emaqfYCexu8R7m1FzHR5UT+QEJgz7Zfhaqz8e5\n\tYq1a5KtE89aaTA8GSKvEnlVvlwnuSaZRtfcIvU2v/SDRbgmUzABF855T6kHKiKlyAy\n\tFEt3aJjYJ5VzRkbE67u+mqyP41IfDn2ntY1WiNhwBiK4yLBfFMU1j0bLbiksLMPDsC\n\tLl7Cp7KPxi19SSVS+guwg9tULnlnNud1kos33FQ64mB427s05Ajmi7nFEnrxo8aQ+E\n\t87gMoXlNfod10h6xMrcBKR5jGk8dPrC5/fYxzoP3ZhxOh7l83MLxmZ18JbR/DH2YFp\n\tauNBaZCKEG6yA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1647516663;\n\tbh=JwvdWojsGFBCcdNdoE7Iu9WleaktwKzTnbflzW8vTHI=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=ovHDbQEvgudF3Vze5v6W2RR4D/TAIuRAHAJcudvH9OV7T53kTG7j/nNm3PU/iumRj\n\tcsFb+Rxcv1kNuyeIt1H4O6GQDUNDj7g2/4CbbBwY4w5TnA3AfF+V2Q7d7c1nL2gjAX\n\t34Xn6VklfWNIKy1eG+fGeRX1+xzOk13hzWncwkHw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ovHDbQEv\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20211221234448.21944-1-laurent.pinchart@ideasonboard.com>","References":"<20211219232714.11427-4-laurent.pinchart@ideasonboard.com>\n\t<20211221234448.21944-1-laurent.pinchart@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 17 Mar 2022 11:31:00 +0000","Message-ID":"<164751666069.856468.433622060271256723@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [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>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]