[{"id":32510,"web_url":"https://patchwork.libcamera.org/comment/32510/","msgid":"<CAEmqJPq2Jf-YSEcs6RfkWXshv22Fyop8BYXY2cDkEC+YTYqprA@mail.gmail.com>","date":"2024-12-04T11:19:34","subject":"Re: [PATCH v1] libcamera: rpi: Add support for IMX258","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Isaac,\n\nOn Wed, 4 Dec 2024 at 10:52, Isaac Scott <isaac.scott@ideasonboard.com> wrote:\n>\n> Add support for the IMX258 camera. This patch adds a minimal cam_helper\n> implementation that allows the IMX258 sensor to be listed by cam, and\n> subsequently be used remotely in tools such as Camshark.\n\nI'm not sure the cam helper alone would be enough to enumerate the\ncamera.  I would have thought you also need a camera tuning file so\nthat the IPA can correctly initialise as well.\n\nRegards,\nNaush\n\n>\n> Based on the implementation of the IMX290's camera helper, adjusted to\n> use the equation listed in the IMX258 datasheet used to calculate\n> analogue gain.\n>\n> Signed-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\n>\n> diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx258.cpp\n> new file mode 100644\n> index 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> +       CamHelperImx258();\n> +       uint32_t gainCode(double gain) const override;\n> +       double gain(uint32_t gainCode) const override;\n> +       void getDelays(int &exposureDelay, int &gainDelay,\n> +                      int &vblankDelay, int &hblankDelay) const override;\n> +private:\n> +       /*\n> +        * Smallest difference between the frame length and integration time,\n> +        * in units of lines.\n> +        */\n> +       static constexpr int frameIntegrationDiff = 2;\n> +};\n> +\n> +CamHelperImx258::CamHelperImx258()\n> +       : CamHelper({}, frameIntegrationDiff)\n> +{\n> +}\n> +\n> +uint32_t CamHelperImx258::gainCode(double gain) const\n> +{\n> +       return static_cast<uint32_t>(512 - 512 / gain);\n> +}\n> +\n> +double CamHelperImx258::gain(uint32_t gainCode) const\n> +{\n> +       return 512.0 / (512.0 - gainCode);\n> +}\n> +\n> +void CamHelperImx258::getDelays(int &exposureDelay, int &gainDelay,\n> +                               int &vblankDelay, int &hblankDelay) const\n> +{\n> +       exposureDelay = 2;\n> +       gainDelay = 2;\n> +       vblankDelay = 2;\n> +       hblankDelay = 2;\n> +}\n> +\n> +static CamHelper *create()\n> +{\n> +       return new CamHelperImx258();\n> +}\n> +\n> +static RegisterCamHelper reg(\"imx258\", &create);\n> diff --git a/src/ipa/rpi/cam_helper/meson.build b/src/ipa/rpi/cam_helper/meson.build\n> index 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> --\n> 2.43.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 E7784BDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Dec 2024 11:20:12 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id CA44A660B1;\n\tWed,  4 Dec 2024 12:20:11 +0100 (CET)","from mail-yb1-xb2e.google.com (mail-yb1-xb2e.google.com\n\t[IPv6:2607:f8b0:4864:20::b2e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1D3116605E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Dec 2024 12:20:10 +0100 (CET)","by mail-yb1-xb2e.google.com with SMTP id\n\t3f1490d57ef6-e30cf3ef571so793846276.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 04 Dec 2024 03:20:10 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"bx0Vo8TQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1733311209; x=1733916009;\n\tdarn=lists.libcamera.org; \n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date:message-id:reply-to;\n\tbh=uwe1lpmGdCnQBXMooZ2jDn0bVVK24RSYrpcknwcI204=;\n\tb=bx0Vo8TQvzIlz4wBj2NltpCm4Ryk0AWJBX/1r6rCMGDYnALeqvtbVJ1Roiz3CvyU9d\n\tXmp6+eHEOpS6Sw4x6SinVpSwQWgv1eF5G6DxC5JfL/Ii/gx7U3UZkQyxhJTnuw2hCp4c\n\tDU9jm+5guexFY+tOXnE2x4Zs4BtrGSNBTxkLmhyFukL7VVHFtCyyATpEFJAZvDLJ3ysw\n\t9K2knmaFANsuR12hroLU9KKxFSegoMyi5hWChZsf4zDDYzdpjxR00hDHOqmqDYY46vjv\n\tGbQwKV21RR13DYEoMPpV5A7XtfawKXpBF33uwRISqyX7hp6WVDQmcUSjIkf7XAwKA/n4\n\t7oIA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1733311209; x=1733916009;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:x-gm-message-state:from:to:cc:subject:date:message-id\n\t:reply-to;\n\tbh=uwe1lpmGdCnQBXMooZ2jDn0bVVK24RSYrpcknwcI204=;\n\tb=OU2EGU0aRcw3xdgVMRvhZIs8VSMpb9ts6KGdcolZJblSPQ+wEqaRFF2x4vF6XwRa4q\n\tYuyrmn7UOQWf1yGZsNEG+JHjLfgsznOKo7TKCafCkxIn1fO+8p2t4prKMD9IZrNAVnPi\n\tCM+OuYBFiRsyQdXoZ/bljpzA/irDZOWjZu9iIehIxbZNMrq6nrHRlnt+QF+U+iU29h/W\n\tIex9QOjBTRFYjV7L7Kpcess/URG4LTICgvOoU3dRCJLcbmgeIhgutX/aJ7a77gCiHrJI\n\t/DEC+MjtU7POOQ5yq8sDFd4f3zIMQkk8pxo1JzHOBYWWjYuqZv2X9892B6vgDAq3JHob\n\t5BXw==","X-Gm-Message-State":"AOJu0YwIohZJuOyq9fJTvY36t0ALT9xGcVlqcqoBUli6SrUA4kpE2Li4\n\tOrmVr1GOHh9JVm4PJ+7VpwmElgFK/9dk2EJsXAT86jBoFt8daVtRDFSJ8MBj/JEGvqpsyW15Vf7\n\tNRiPDgNb6gckXjDl/m7Iyh7d2621EKtZHMnjsqAda8BYVKrUH","X-Gm-Gg":"ASbGncvgJLlhEN3ycWl0UyNLuOnRcKPhJqaXGU2QVVWAdozWp+Xd/FAh476UZphkeYS\n\t+qgRGp5UiRVvMVB7GSd63KYquBwvYwSIuro116ytmU3l0GRzmbo1fpbSvl+GHgc0=","X-Google-Smtp-Source":"AGHT+IFtsl7Mb8szgayN6OG1tDrimnupIF7rbkfq/mvgcYqquwVkogpXxCdPeOoL+5J/gOJnvq8O8QnRR3tDhr64sGY=","X-Received":"by 2002:a05:6902:27c8:b0:e38:c459:fbf2 with SMTP id\n\t3f1490d57ef6-e39d4391db1mr2474158276.11.1733311208777;\n\tWed, 04 Dec 2024 03:20:08 -0800 (PST)","MIME-Version":"1.0","References":"<20241204105223.45807-1-isaac.scott@ideasonboard.com>","In-Reply-To":"<20241204105223.45807-1-isaac.scott@ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Wed, 4 Dec 2024 11:19:34 +0000","Message-ID":"<CAEmqJPq2Jf-YSEcs6RfkWXshv22Fyop8BYXY2cDkEC+YTYqprA@mail.gmail.com>","Subject":"Re: [PATCH v1] libcamera: rpi: Add support for IMX258","To":"Isaac Scott <isaac.scott@ideasonboard.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"text/plain; charset=\"UTF-8\"","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":32513,"web_url":"https://patchwork.libcamera.org/comment/32513/","msgid":"<a230ca5dc97c30748b7a1fd676bd288a9fd80307.camel@ideasonboard.com>","date":"2024-12-04T11:38:14","subject":"Re: [PATCH v1] libcamera: rpi: Add support for IMX258","submitter":{"id":215,"url":"https://patchwork.libcamera.org/api/people/215/","name":"Isaac Scott","email":"isaac.scott@ideasonboard.com"},"content":"Hi Naushir,\n\nOn Wed, 2024-12-04 at 11:19 +0000, Naushir Patuck wrote:\n> Hi Isaac,\n> \n> On Wed, 4 Dec 2024 at 10:52, Isaac Scott\n> <isaac.scott@ideasonboard.com> wrote:\n> > \n> > Add support for the IMX258 camera. This patch adds a minimal\n> > cam_helper\n> > implementation that allows the IMX258 sensor to be listed by cam,\n> > and\n> > subsequently be used remotely in tools such as Camshark.\n> \n> I'm not sure the cam helper alone would be enough to enumerate the\n> camera.  I would have thought you also need a camera tuning file so\n> that the IPA can correctly initialise as well.\n> \n\nYou're right! I used uncalibrated.yaml to make this, I am running\nthrough the tuning process now.\n\n> Regards,\n> Naush\n> > \n\nBest wishes,\nIsaac\n\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 6FF8BBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  4 Dec 2024 11:38:20 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 718F1660B1;\n\tWed,  4 Dec 2024 12:38:19 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 69757618B5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Dec 2024 12:38:17 +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 695E04D4;\n\tWed,  4 Dec 2024 12:37:49 +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=\"RE5rp6nE\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1733312269;\n\tbh=mQMwTpxo66IaHSggaGmAIMrwAXkO+kO/MsdUakQGNcw=;\n\th=Subject:From:To:Cc:Date:In-Reply-To:References:From;\n\tb=RE5rp6nEta5GdWCpOMv7IDqUjYcf0rVix4SBWMY8C9pU8dOUpe8B/SfPe1fZ8K8hA\n\tgFwSJYTnqzxrwhEVq6ipaPGz0mSDaZ3eXRGo2nrcJnLDgX/U8oKslKEAM3Bk/wY5KG\n\tMvXEihb6CTFNn90fY5a1Zrjp892MBRjS6jx04Vsw=","Message-ID":"<a230ca5dc97c30748b7a1fd676bd288a9fd80307.camel@ideasonboard.com>","Subject":"Re: [PATCH v1] libcamera: rpi: Add support for IMX258","From":"Isaac Scott <isaac.scott@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Wed, 04 Dec 2024 11:38:14 +0000","In-Reply-To":"<CAEmqJPq2Jf-YSEcs6RfkWXshv22Fyop8BYXY2cDkEC+YTYqprA@mail.gmail.com>","References":"<20241204105223.45807-1-isaac.scott@ideasonboard.com>\n\t<CAEmqJPq2Jf-YSEcs6RfkWXshv22Fyop8BYXY2cDkEC+YTYqprA@mail.gmail.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","User-Agent":"Evolution 3.54.1 (by Flathub.org) ","MIME-Version":"1.0","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>"}}]