[{"id":39178,"web_url":"https://patchwork.libcamera.org/comment/39178/","msgid":"<178179707030.861173.3000542699221537457@ping.linuxembedded.co.uk>","date":"2026-06-18T15:37:50","subject":"Re: [PATCH v2 2/2] ipa: rpi: Add cam_helper for Sony IMX678","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jai Luthra (2026-06-18 15:56:42)\n> From: will whang <will@willwhang.com>\n> \n> This adds a basic cam helper for Sony IMX678, modelling the gain curve\n> and the sensor limits for the maximum exposure time.\n> \n> Link: https://github.com/will127534/libcamera/commit/619459e7c70306ba18476\n> Signed-off-by: will whang <will@willwhang.com>\n> Co-developed-by: Jai Luthra <jai.luthra@ideasonboard.com>\n> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>\n\nWe're in RPi IPA space here, so I've added Naush for consideration, but\nyou've tackled my concerns, Thanks.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n> Changes in v2:\n> - Drop hideFramesStartup() and hideFramesModeSwitch()\n> - Use std::pow() instead of pow()\n> - Drop unnecessary includes, and include <algorithm> and <cmath> for\n>   std::pow and std::min/max\n> - Reword comment for embedded data, as the sensor supports it but the\n>   driver currently does not\n> - Cleanup more issues with whitespace\n> - Add a Co-developed-by tag now that it's not a complete copy-paste\n> - Update commit message\n> ---\n>  src/ipa/rpi/cam_helper/cam_helper_imx678.cpp | 56 ++++++++++++++++++++++++++++\n>  src/ipa/rpi/cam_helper/meson.build           |  1 +\n>  2 files changed, 57 insertions(+)\n> \n> diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp\n> new file mode 100644\n> index 000000000..916433bf6\n> --- /dev/null\n> +++ b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp\n> @@ -0,0 +1,56 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Copyright (C) 2026, Will Whang\n> + *\n> + * cam_helper_imx678.cpp - camera information for Sony IMX678 sensor\n> + */\n> +\n> +#include <algorithm>\n> +#include <cmath>\n> +\n> +#include \"cam_helper.h\"\n> +\n> +using namespace RPiController;\n> +\n> +class CamHelperImx678 : public CamHelper\n> +{\n> +public:\n> +       CamHelperImx678();\n> +       uint32_t gainCode(double gain) const override;\n> +       double gain(uint32_t gainCode) const override;\n> +\n> +private:\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> +/*\n> + * IMX678 driver currently doesn't expose a metadata stream, so we have to use\n> + * the \"unicam parser\" which works by counting frames.\n> + */\n> +\n> +CamHelperImx678::CamHelperImx678()\n> +       : CamHelper({}, frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx678::gainCode(double gain) const\n> +{\n> +       int code = 66.6667 * log10(gain);\n> +       return std::max(0, std::min(code, 0xf0));\n> +}\n> +\n> +double CamHelperImx678::gain(uint32_t gainCode) const\n> +{\n> +       return std::pow(10, 0.015 * gainCode);\n> +}\n> +\n> +static CamHelper *create()\n> +{\n> +       return new CamHelperImx678();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx678\", &create);\n> diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build\n> index 87b6a3600..eabd55dce 100644\n> --- a/src/ipa/rpi/cam_helper/meson.build\n> +++ b/src/ipa/rpi/cam_helper/meson.build\n> @@ -10,6 +10,7 @@ rpi_ipa_cam_helper_sources = files([\n>      'cam_helper_imx415.cpp',\n>      'cam_helper_imx477.cpp',\n>      'cam_helper_imx519.cpp',\n> +    'cam_helper_imx678.cpp',\n>      'cam_helper_imx708.cpp',\n>      'cam_helper_ov64a40.cpp',\n>      'cam_helper_ov7251.cpp',\n> \n> -- \n> 2.54.0\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 7C033C3261\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Jun 2026 15:37:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7784D62E9D;\n\tThu, 18 Jun 2026 17:37:54 +0200 (CEST)","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 C748961754\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2026 17:37:52 +0200 (CEST)","from monstersaurus.ideasonboard.com\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 95A838E0;\n\tThu, 18 Jun 2026 17:37:17 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"iVlaeLSU\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1781797037;\n\tbh=dmd4b1rQ5DgUgEpIXFDJ812Egf7OqjF7EHNvOYN2nkk=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=iVlaeLSUd9jz7sdz/M1sM3e4TyBkEytbjxmaEH1r/D2ttbfvudbDzhJPojAZScOVQ\n\tCNXSBXM9QsqCnMGqdYHTTlfnvxfYohlz5GwxqbdlyURiobXqbPVebK9ilgwA9o/GmE\n\tylfngkwvkgk2JUn0H54bXuNYW0Qw+Lw/ezSmkEw8=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20260618-imx678-v2-2-a288102744c3@ideasonboard.com>","References":"<20260618-imx678-v2-0-a288102744c3@ideasonboard.com>\n\t<20260618-imx678-v2-2-a288102744c3@ideasonboard.com>","Subject":"Re: [PATCH v2 2/2] ipa: rpi: Add cam_helper for Sony IMX678","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJai Luthra <jai.luthra@ideasonboard.com>, will whang <will@willwhang.com>","To":"Jai Luthra <jai.luthra@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org,\n\tNaushir Patuck <naush@raspberrypi.com>, ","Date":"Thu, 18 Jun 2026 16:37:50 +0100","Message-ID":"<178179707030.861173.3000542699221537457@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","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>"}},{"id":39179,"web_url":"https://patchwork.libcamera.org/comment/39179/","msgid":"<20260618154846.GA3410390@killaraus.ideasonboard.com>","date":"2026-06-18T15:48:46","subject":"Re: [PATCH v2 2/2] ipa: rpi: Add cam_helper for Sony IMX678","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Jun 18, 2026 at 08:26:42PM +0530, Jai Luthra wrote:\n> From: will whang <will@willwhang.com>\n> \n> This adds a basic cam helper for Sony IMX678, modelling the gain curve\n> and the sensor limits for the maximum exposure time.\n> \n> Link: https://github.com/will127534/libcamera/commit/619459e7c70306ba18476\n> Signed-off-by: will whang <will@willwhang.com>\n> Co-developed-by: Jai Luthra <jai.luthra@ideasonboard.com>\n> Signed-off-by: Jai Luthra <jai.luthra@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n> Changes in v2:\n> - Drop hideFramesStartup() and hideFramesModeSwitch()\n> - Use std::pow() instead of pow()\n> - Drop unnecessary includes, and include <algorithm> and <cmath> for\n>   std::pow and std::min/max\n> - Reword comment for embedded data, as the sensor supports it but the\n>   driver currently does not\n> - Cleanup more issues with whitespace\n> - Add a Co-developed-by tag now that it's not a complete copy-paste\n> - Update commit message\n> ---\n>  src/ipa/rpi/cam_helper/cam_helper_imx678.cpp | 56 ++++++++++++++++++++++++++++\n>  src/ipa/rpi/cam_helper/meson.build           |  1 +\n>  2 files changed, 57 insertions(+)\n> \n> diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp\n> new file mode 100644\n> index 000000000..916433bf6\n> --- /dev/null\n> +++ b/src/ipa/rpi/cam_helper/cam_helper_imx678.cpp\n> @@ -0,0 +1,56 @@\n> +/* SPDX-License-Identifier: BSD-2-Clause */\n> +/*\n> + * Copyright (C) 2026, Will Whang\n> + *\n> + * cam_helper_imx678.cpp - camera information for Sony IMX678 sensor\n> + */\n> +\n> +#include <algorithm>\n> +#include <cmath>\n> +\n> +#include \"cam_helper.h\"\n> +\n> +using namespace RPiController;\n> +\n> +class CamHelperImx678 : public CamHelper\n> +{\n> +public:\n> +\tCamHelperImx678();\n> +\tuint32_t gainCode(double gain) const override;\n> +\tdouble gain(uint32_t gainCode) 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> + * IMX678 driver currently doesn't expose a metadata stream, so we have to use\n> + * the \"unicam parser\" which works by counting frames.\n> + */\n> +\n> +CamHelperImx678::CamHelperImx678()\n> +\t: CamHelper({}, frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx678::gainCode(double gain) const\n> +{\n> +\tint code = 66.6667 * log10(gain);\n> +\treturn std::max(0, std::min(code, 0xf0));\n> +}\n> +\n> +double CamHelperImx678::gain(uint32_t gainCode) const\n> +{\n> +\treturn std::pow(10, 0.015 * gainCode);\n> +}\n> +\n> +static CamHelper *create()\n> +{\n> +\treturn new CamHelperImx678();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx678\", &create);\n> diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build\n> index 87b6a3600..eabd55dce 100644\n> --- a/src/ipa/rpi/cam_helper/meson.build\n> +++ b/src/ipa/rpi/cam_helper/meson.build\n> @@ -10,6 +10,7 @@ rpi_ipa_cam_helper_sources = files([\n>      'cam_helper_imx415.cpp',\n>      'cam_helper_imx477.cpp',\n>      'cam_helper_imx519.cpp',\n> +    'cam_helper_imx678.cpp',\n>      'cam_helper_imx708.cpp',\n>      'cam_helper_ov64a40.cpp',\n>      'cam_helper_ov7251.cpp',","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 580ABBF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Jun 2026 15:48:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0DE3962C6B;\n\tThu, 18 Jun 2026 17:48:50 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8CC7861754\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Jun 2026 17:48:48 +0200 (CEST)","from killaraus.ideasonboard.com\n\t(2001-14ba-70f3-e800--a06.rev.dnainternet.fi\n\t[IPv6:2001:14ba:70f3:e800::a06])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4B3678E0;\n\tThu, 18 Jun 2026 17:48:13 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZA5Np6wg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1781797693;\n\tbh=Ean/AAcrbQETXuNpdZv8L4J7BacV+D5vSdSbnn3mTMM=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ZA5Np6wgoZdYS0YYrOwEX/yeZzdCY5+pEcBLDz+vjc4NJX3Y4hTSYFR5HuNozXlwt\n\tWxulIiVumPqxNIktEXHxxjfYOg3GzC4UG2Mf0RCdogsTqssYa0toHuPvls84ERjHaD\n\tXQGPG1kVdTDXXsCWDs3we/650/E5n9QQQo06sqNU=","Date":"Thu, 18 Jun 2026 18:48:46 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jai Luthra <jai.luthra@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\twill whang <will@willwhang.com>","Subject":"Re: [PATCH v2 2/2] ipa: rpi: Add cam_helper for Sony IMX678","Message-ID":"<20260618154846.GA3410390@killaraus.ideasonboard.com>","References":"<20260618-imx678-v2-0-a288102744c3@ideasonboard.com>\n\t<20260618-imx678-v2-2-a288102744c3@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20260618-imx678-v2-2-a288102744c3@ideasonboard.com>","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>"}}]