[{"id":29562,"web_url":"https://patchwork.libcamera.org/comment/29562/","msgid":"<aeb96544-06e1-4253-a30b-67d39da864d9@ideasonboard.com>","date":"2024-05-20T10:42:52","subject":"Re: [PATCH 1/3] ipa: rkisp1: Add gamma algorithm","submitter":{"id":156,"url":"https://patchwork.libcamera.org/api/people/156/","name":"Dan Scally","email":"dan.scally@ideasonboard.com"},"content":"Hi Stefan - thanks for the patch\n\nOn 16/05/2024 13:41, Stefan Klug wrote:\n> Add a gamma algorithm for the rkisp1. It defaults to a gamma of 2.2 which\n> closely resembles sRGB.  No seperate sRGB mode was implemented because the pwl\n> that models the gamma curve is so coarse that there is basically no difference\n> between srgb and gamma=2.2\n>\n> The gamma algorithm is not enabled by default. This will be done in future\n> tuning file updates.\n>\n> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> ---\n> Note:\n>\n> This patch breaks the naming conventions. It is implemented inside goc.h/cpp\n> because the hardware block and params inside the rkisp1 are called \"goc\". The\n> class itself is called Gamma, and the algorithm is registered with the name\n> \"Gamma\". The idea was that similar functionalities should be named the same\n> inside the tuning files (even among multipe isps).  It still feels a bit\n> awkward. So thoughts are welcome :-)\n>\n> Cheers,\n> Stefan\n\n\nIs it worth a libipa implementation? Handling the gamma control and building the PWL array from the \ninput gamma value should be basically the same across most of the IPAs, though the logarithmic mode \nhere perhaps makes that not worthwhile.\n\n>\n>   src/ipa/rkisp1/algorithms/goc.cpp     | 89 +++++++++++++++++++++++++++\n>   src/ipa/rkisp1/algorithms/goc.h       | 32 ++++++++++\n>   src/ipa/rkisp1/algorithms/meson.build |  1 +\n>   3 files changed, 122 insertions(+)\n>   create mode 100644 src/ipa/rkisp1/algorithms/goc.cpp\n>   create mode 100644 src/ipa/rkisp1/algorithms/goc.h\n>\n> diff --git a/src/ipa/rkisp1/algorithms/goc.cpp b/src/ipa/rkisp1/algorithms/goc.cpp\n> new file mode 100644\n> index 00000000..1598d730\n> --- /dev/null\n> +++ b/src/ipa/rkisp1/algorithms/goc.cpp\n> @@ -0,0 +1,89 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2024 Ideas On Board\n> + *\n> + * RkISP1 Gamma out control\n> + */\n> +#include \"goc.h\"\n> +\n> +#include <cmath>\n> +\n> +#include <libcamera/base/log.h>\n> +#include <libcamera/base/utils.h>\n> +\n> +#include \"libcamera/internal/yaml_parser.h\"\n> +\n> +#include \"linux/rkisp1-config.h\"\n> +\n> +/**\n> + * \\file gsl.h\n> + */\ns/gsl/goc?\n> +\n> +namespace libcamera {\n> +\n> +namespace ipa::rkisp1::algorithms {\n> +\n> +/**\n> + * \\class Gamma\n> + * \\brief RkISP1 Gamma out control\n> + *\n> + * This algorithm implements the gamma out curve for the RkISP1.\n> + * It defaults to a gamma value of 2.2\n> + * As gamma is internally represented as a piecewise linear function with only\n> + * 16 knots, the difference between gamma=2.2 and sRGB gamma is minimal.\n> + * Therefore sRGB gamma was not implemented as special case.\n> + *\n> + * Useful links:\n> + * https://www.cambridgeincolour.com/tutorials/gamma-correction.htm\n> + * https://en.wikipedia.org/wiki/SRGB\n> + */\n> +\n> +LOG_DEFINE_CATEGORY(RkISP1Gamma)\n> +\n> +Gamma::Gamma()\n> +{\n> +}\n> +\n> +/**\n> + * \\copydoc libcamera::ipa::Algorithm::init\n> + */\n> +int Gamma::init([[maybe_unused]] IPAContext &context,\n> +\t\t[[maybe_unused]] const YamlObject &tuningData)\n> +{\n> +\treturn 0;\n> +}\n\n\nYou don't need to provide the function if it does nothing I think?\n\n> +\n> +/**\n> + * \\copydoc libcamera::ipa::Algorithm::prepare\n> + */\n> +void Gamma::prepare([[maybe_unused]] IPAContext &context,\n> +\t\t    const uint32_t frame,\n> +\t\t    [[maybe_unused]] IPAFrameContext &frameContext,\n> +\t\t    rkisp1_params_cfg *params)\n> +{\n> +\t/* The logarithmic segments as specified in the reference.\n> +\t   Plus an additional 0 to make the loop easier */\n> +\tint segments[] = { 64, 64, 64, 64, 128, 128, 128, 128, 256, 256, 256,\n> +\t\t\t   512, 512, 512, 512, 512, 0 };\n> +\tauto gamma_y = params->others.goc_config.gamma_y;\n> +\n> +\tif (frame > 0)\n> +\t\treturn;\n> +\n> +\tint x = 0;\n> +\tfor (int i = 0; i < RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10; i++) {\n\n\nDoes this need to be done differently for V12? What happens if we half-fill the LUT for V12 revisions?\n\n\n> +\t\tgamma_y[i] = std::pow(x / 4096.0, 1.0 / gamma_) * 1023.0;\n> +\t\tx += segments[i];\n> +\t}\n> +\n> +\tparams->others.goc_config.mode = RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC;\n> +\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_GOC;\n> +\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_GOC;\n> +\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_GOC;\n> +}\n> +\n> +REGISTER_IPA_ALGORITHM(Gamma, \"Gamma\")\n> +\n> +} /* namespace ipa::rkisp1::algorithms */\n> +\n> +} /* namespace libcamera */\n> diff --git a/src/ipa/rkisp1/algorithms/goc.h b/src/ipa/rkisp1/algorithms/goc.h\n> new file mode 100644\n> index 00000000..3c83655b\n> --- /dev/null\n> +++ b/src/ipa/rkisp1/algorithms/goc.h\n> @@ -0,0 +1,32 @@\n> +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> +/*\n> + * Copyright (C) 2021-2022, Ideas On Board\n> + *\n> + * gsl.h - RkISP1 Gamma Sensor Linearization control\n> + */\ns/gsl/goc\n> +\n> +#pragma once\n> +\n> +#include \"algorithm.h\"\n> +\n> +namespace libcamera {\n> +\n> +namespace ipa::rkisp1::algorithms {\n> +\n> +class Gamma : public Algorithm\n> +{\n> +public:\n> +\tGamma();\n> +\t~Gamma() = default;\n> +\n> +\tint init(IPAContext &context, const YamlObject &tuningData) override;\n> +\tvoid prepare(IPAContext &context, const uint32_t frame,\n> +\t\t     IPAFrameContext &frameContext,\n> +\t\t     rkisp1_params_cfg *params) override;\n> +\n> +private:\n> +\tfloat gamma_ = 2.2;\n> +};\n> +\n> +} /* namespace ipa::rkisp1::algorithms */\n> +} /* namespace libcamera */\n> diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build\n> index 93a48329..6ee71a9b 100644\n> --- a/src/ipa/rkisp1/algorithms/meson.build\n> +++ b/src/ipa/rkisp1/algorithms/meson.build\n> @@ -8,6 +8,7 @@ rkisp1_ipa_algorithms = files([\n>       'dpcc.cpp',\n>       'dpf.cpp',\n>       'filter.cpp',\n> +    'goc.cpp',\n>       'gsl.cpp',\n>       'lsc.cpp',\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 05074BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 20 May 2024 10:43:01 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 80C326347C;\n\tMon, 20 May 2024 12:42:59 +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 E3FAC61A58\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 May 2024 12:42:55 +0200 (CEST)","from [192.168.0.43]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 35964581\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 20 May 2024 12:42:44 +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=\"SrHnn7HG\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716201764;\n\tbh=iKNCQEYYD+Fielos8/e1SDPvS7B0jgjj7zb9HfOC2k4=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=SrHnn7HGotfWVwKQJIg5EaIcXlGUawmF6tbBJVlCpYyId+LTSoXj1ydVezwIKZIZ/\n\tFAFUgItF4WJ8UpRkOsMsy3d5KINEI+vCz0kbRxq4cATu/gEa6nh5c7bgplUouHD1kl\n\tzl+t0XoAGNjwUINzePfql8R4Hi5t/x2pqd2Db9WQ=","Message-ID":"<aeb96544-06e1-4253-a30b-67d39da864d9@ideasonboard.com>","Date":"Mon, 20 May 2024 11:42:52 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH 1/3] ipa: rkisp1: Add gamma algorithm","To":"libcamera-devel@lists.libcamera.org","References":"<20240516124150.219054-1-stefan.klug@ideasonboard.com>\n\t<20240516124150.219054-2-stefan.klug@ideasonboard.com>","Content-Language":"en-US","From":"Dan Scally <dan.scally@ideasonboard.com>","Autocrypt":"addr=dan.scally@ideasonboard.com; keydata=\n\txsFNBGLydlEBEADa5O2s0AbUguprfvXOQun/0a8y2Vk6BqkQALgeD6KnXSWwaoCULp18etYW\n\tB31bfgrdphXQ5kUQibB0ADK8DERB4wrzrUb5CMxLBFE7mQty+v5NsP0OFNK9XTaAOcmD+Ove\n\teIjYvqurAaro91jrRVrS1gBRxIFqyPgNvwwL+alMZhn3/2jU2uvBmuRrgnc/e9cHKiuT3Dtq\n\tMHGPKL2m+plk+7tjMoQFfexoQ1JKugHAjxAhJfrkXh6uS6rc01bYCyo7ybzg53m1HLFJdNGX\n\tsUKR+dQpBs3SY4s66tc1sREJqdYyTsSZf80HjIeJjU/hRunRo4NjRIJwhvnK1GyjOvvuCKVU\n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PoxKyaytC4R6BTxVriTJjWK8mbo9jZIRM4vkwkZZ2bu98EweSucxbp\n\tvjESsvMXGgxniqV/RQ/3T7LABYRoIUutARYq58p5HwSP0frF0fdFHYdTa2g7MYZl1ur2JzOC\n\tFHRpGadlNzKDE3fEdoMobxHB3Lm6FDml5GyBAA8+dQYVI0oDwJ3gpZPZ0J5Vx9RbqXe8RDuR\n\tdu90hvCJkq7/tzSQ0GeD3BwXb9/R/A4dVXhaDd91Q1qQXidI+2jwhx8iqiYxbT+DoAUkQRQy\n\txBtoCM1CxH7u45URUgD//fxYr3D4B1SlonA6vdaEdHZOGwECnDpTxecENMbz/Bx7qfrmd901\n\tD+N9SjIwrbVhhSyUXYnSUb8F+9g2RDY42Sk7GcYxIeON4VzKqWM7hpkXZ47pkK0YodO+dRKM\n\tyMcoUWrTK0Uz6UzUGKoJVbxmSW/EJLEGoI5p3NWxWtScEVv8mO49gqQdrRIOheZycDmHnItt\n\t9Qjv00uFhEwv2YfiyGk6iGF2W40s2pH2t6oeuGgmiZ7g6d0MEK8Ql/4zPItvr1c1rpwpXUC1\n\tu1kQWgtnNjFHX3KiYdqjcZeRBiry1X0zY+4Y24wUU0KsEewJwjhmCKAsju1RpdlPg2kC","In-Reply-To":"<20240516124150.219054-2-stefan.klug@ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","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":29586,"web_url":"https://patchwork.libcamera.org/comment/29586/","msgid":"<20240521075157.ugi5n7eocijisucc@jasper>","date":"2024-05-21T07:51:57","subject":"Re: [PATCH 1/3] ipa: rkisp1: Add gamma algorithm","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/people/184/","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"content":"Hi Dan,\n\nthanks for the review.\n\nOn Mon, May 20, 2024 at 11:42:52AM +0100, Dan Scally wrote:\n> Hi Stefan - thanks for the patch\n> \n> On 16/05/2024 13:41, Stefan Klug wrote:\n> > Add a gamma algorithm for the rkisp1. It defaults to a gamma of 2.2 which\n> > closely resembles sRGB.  No seperate sRGB mode was implemented because the pwl\n> > that models the gamma curve is so coarse that there is basically no difference\n> > between srgb and gamma=2.2\n> > \n> > The gamma algorithm is not enabled by default. This will be done in future\n> > tuning file updates.\n> > \n> > Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n> > ---\n> > Note:\n> > \n> > This patch breaks the naming conventions. It is implemented inside goc.h/cpp\n> > because the hardware block and params inside the rkisp1 are called \"goc\". The\n> > class itself is called Gamma, and the algorithm is registered with the name\n> > \"Gamma\". The idea was that similar functionalities should be named the same\n> > inside the tuning files (even among multipe isps).  It still feels a bit\n> > awkward. So thoughts are welcome :-)\n> > \n> > Cheers,\n> > Stefan\n> \n> \n> Is it worth a libipa implementation? Handling the gamma control and building\n> the PWL array from the input gamma value should be basically the same across\n> most of the IPAs, though the logarithmic mode here perhaps makes that not\n> worthwhile.\n\nYes, that could be a solution. I'll give it a try.\n\n> \n> > \n> >   src/ipa/rkisp1/algorithms/goc.cpp     | 89 +++++++++++++++++++++++++++\n> >   src/ipa/rkisp1/algorithms/goc.h       | 32 ++++++++++\n> >   src/ipa/rkisp1/algorithms/meson.build |  1 +\n> >   3 files changed, 122 insertions(+)\n> >   create mode 100644 src/ipa/rkisp1/algorithms/goc.cpp\n> >   create mode 100644 src/ipa/rkisp1/algorithms/goc.h\n> > \n> > diff --git a/src/ipa/rkisp1/algorithms/goc.cpp b/src/ipa/rkisp1/algorithms/goc.cpp\n> > new file mode 100644\n> > index 00000000..1598d730\n> > --- /dev/null\n> > +++ b/src/ipa/rkisp1/algorithms/goc.cpp\n> > @@ -0,0 +1,89 @@\n> > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > +/*\n> > + * Copyright (C) 2024 Ideas On Board\n> > + *\n> > + * RkISP1 Gamma out control\n> > + */\n> > +#include \"goc.h\"\n> > +\n> > +#include <cmath>\n> > +\n> > +#include <libcamera/base/log.h>\n> > +#include <libcamera/base/utils.h>\n> > +\n> > +#include \"libcamera/internal/yaml_parser.h\"\n> > +\n> > +#include \"linux/rkisp1-config.h\"\n> > +\n> > +/**\n> > + * \\file gsl.h\n> > + */\n> s/gsl/goc?\n> > +\n> > +namespace libcamera {\n> > +\n> > +namespace ipa::rkisp1::algorithms {\n> > +\n> > +/**\n> > + * \\class Gamma\n> > + * \\brief RkISP1 Gamma out control\n> > + *\n> > + * This algorithm implements the gamma out curve for the RkISP1.\n> > + * It defaults to a gamma value of 2.2\n> > + * As gamma is internally represented as a piecewise linear function with only\n> > + * 16 knots, the difference between gamma=2.2 and sRGB gamma is minimal.\n> > + * Therefore sRGB gamma was not implemented as special case.\n> > + *\n> > + * Useful links:\n> > + * https://www.cambridgeincolour.com/tutorials/gamma-correction.htm\n> > + * https://en.wikipedia.org/wiki/SRGB\n> > + */\n> > +\n> > +LOG_DEFINE_CATEGORY(RkISP1Gamma)\n> > +\n> > +Gamma::Gamma()\n> > +{\n> > +}\n> > +\n> > +/**\n> > + * \\copydoc libcamera::ipa::Algorithm::init\n> > + */\n> > +int Gamma::init([[maybe_unused]] IPAContext &context,\n> > +\t\t[[maybe_unused]] const YamlObject &tuningData)\n> > +{\n> > +\treturn 0;\n> > +}\n> \n> \n> You don't need to provide the function if it does nothing I think?\n\nOh yes, sure.\n\n> \n> > +\n> > +/**\n> > + * \\copydoc libcamera::ipa::Algorithm::prepare\n> > + */\n> > +void Gamma::prepare([[maybe_unused]] IPAContext &context,\n> > +\t\t    const uint32_t frame,\n> > +\t\t    [[maybe_unused]] IPAFrameContext &frameContext,\n> > +\t\t    rkisp1_params_cfg *params)\n> > +{\n> > +\t/* The logarithmic segments as specified in the reference.\n> > +\t   Plus an additional 0 to make the loop easier */\n> > +\tint segments[] = { 64, 64, 64, 64, 128, 128, 128, 128, 256, 256, 256,\n> > +\t\t\t   512, 512, 512, 512, 512, 0 };\n> > +\tauto gamma_y = params->others.goc_config.gamma_y;\n> > +\n> > +\tif (frame > 0)\n> > +\t\treturn;\n> > +\n> > +\tint x = 0;\n> > +\tfor (int i = 0; i < RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10; i++) {\n> \n> \n> Does this need to be done differently for V12? What happens if we half-fill the LUT for V12 revisions?\n\nYes, it would need to be done differently. I don't have a V12 based\ndevice, so I'm not able to tests it. I could do a dry implementation and\nissue a warning, or error out in case of the V12. I'll have a look.\n\nCheers,\nStefan\n\n> \n> \n> > +\t\tgamma_y[i] = std::pow(x / 4096.0, 1.0 / gamma_) * 1023.0;\n> > +\t\tx += segments[i];\n> > +\t}\n> > +\n> > +\tparams->others.goc_config.mode = RKISP1_CIF_ISP_GOC_MODE_LOGARITHMIC;\n> > +\tparams->module_en_update |= RKISP1_CIF_ISP_MODULE_GOC;\n> > +\tparams->module_ens |= RKISP1_CIF_ISP_MODULE_GOC;\n> > +\tparams->module_cfg_update |= RKISP1_CIF_ISP_MODULE_GOC;\n> > +}\n> > +\n> > +REGISTER_IPA_ALGORITHM(Gamma, \"Gamma\")\n> > +\n> > +} /* namespace ipa::rkisp1::algorithms */\n> > +\n> > +} /* namespace libcamera */\n> > diff --git a/src/ipa/rkisp1/algorithms/goc.h b/src/ipa/rkisp1/algorithms/goc.h\n> > new file mode 100644\n> > index 00000000..3c83655b\n> > --- /dev/null\n> > +++ b/src/ipa/rkisp1/algorithms/goc.h\n> > @@ -0,0 +1,32 @@\n> > +/* SPDX-License-Identifier: LGPL-2.1-or-later */\n> > +/*\n> > + * Copyright (C) 2021-2022, Ideas On Board\n> > + *\n> > + * gsl.h - RkISP1 Gamma Sensor Linearization control\n> > + */\n> s/gsl/goc\n> > +\n> > +#pragma once\n> > +\n> > +#include \"algorithm.h\"\n> > +\n> > +namespace libcamera {\n> > +\n> > +namespace ipa::rkisp1::algorithms {\n> > +\n> > +class Gamma : public Algorithm\n> > +{\n> > +public:\n> > +\tGamma();\n> > +\t~Gamma() = default;\n> > +\n> > +\tint init(IPAContext &context, const YamlObject &tuningData) override;\n> > +\tvoid prepare(IPAContext &context, const uint32_t frame,\n> > +\t\t     IPAFrameContext &frameContext,\n> > +\t\t     rkisp1_params_cfg *params) override;\n> > +\n> > +private:\n> > +\tfloat gamma_ = 2.2;\n> > +};\n> > +\n> > +} /* namespace ipa::rkisp1::algorithms */\n> > +} /* namespace libcamera */\n> > diff --git a/src/ipa/rkisp1/algorithms/meson.build b/src/ipa/rkisp1/algorithms/meson.build\n> > index 93a48329..6ee71a9b 100644\n> > --- a/src/ipa/rkisp1/algorithms/meson.build\n> > +++ b/src/ipa/rkisp1/algorithms/meson.build\n> > @@ -8,6 +8,7 @@ rkisp1_ipa_algorithms = files([\n> >       'dpcc.cpp',\n> >       'dpf.cpp',\n> >       'filter.cpp',\n> > +    'goc.cpp',\n> >       'gsl.cpp',\n> >       'lsc.cpp',\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 431F4BD78E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 May 2024 07:52:02 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DC88763486;\n\tTue, 21 May 2024 09:52:00 +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 DA32761A51\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 May 2024 09:51:59 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:7426:1738:6d7b:2532])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D92745A4;\n\tTue, 21 May 2024 09:51:47 +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=\"I7UI5qoO\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1716277908;\n\tbh=SA9NIlNOqOuydBnuJ1VZAOVZy4CWxU4wQ5l0MgY3jII=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=I7UI5qoOu0LoWVqKtz7AoIuTvyEyh5qM8760MykqPhbq6MFevRPehP3iVhHpAwSjH\n\tvrNGBwRKl8sBFmJqEVkaAJe+KCvdyQFcP8wcM0o+/KWhKmog611gWg5f2LeewEyc+f\n\t609sYS08MMoyGBghA1e6hQYzcIxHD89hsIPCln6w=","Date":"Tue, 21 May 2024 09:51:57 +0200","From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"Dan Scally <dan.scally@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 1/3] ipa: rkisp1: Add gamma algorithm","Message-ID":"<20240521075157.ugi5n7eocijisucc@jasper>","References":"<20240516124150.219054-1-stefan.klug@ideasonboard.com>\n\t<20240516124150.219054-2-stefan.klug@ideasonboard.com>\n\t<aeb96544-06e1-4253-a30b-67d39da864d9@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<aeb96544-06e1-4253-a30b-67d39da864d9@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>"}}]