[{"id":16273,"web_url":"https://patchwork.libcamera.org/comment/16273/","msgid":"<CAEmqJPrm9Q=aYAwuaRzkNSUXxFd6OkMZGoKpZ9QToqbyxkgyTw@mail.gmail.com>","date":"2021-04-14T10:33:53","subject":"Re: [libcamera-devel] [PATCH v3 2/3] ipa: raspberrypi: Add\n\tCamHelper::ColourGainCode method","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\n\nOn Wed, 14 Apr 2021 at 11:30, David Plowman <david.plowman@raspberrypi.com>\nwrote:\n\n> Some sensors may require the V4L2_RED/BLUE_BALANCE to be set. These\n> will require a ColourGainCode method in the CamHelper, analogous to\n> the GainCode method, but which converts the red and blue gains to the\n> codes that the driver will want.\n>\n> Most sensors don't require these values so it's helpful to provide a\n> default method - noting that it should then never be called.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\n> ---\n>  src/ipa/raspberrypi/cam_helper.cpp | 18 ++++++++++++++++++\n>  src/ipa/raspberrypi/cam_helper.hpp |  4 +++-\n>  2 files changed, 21 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/ipa/raspberrypi/cam_helper.cpp\n> b/src/ipa/raspberrypi/cam_helper.cpp\n> index 0ae0baa0..ad344d29 100644\n> --- a/src/ipa/raspberrypi/cam_helper.cpp\n> +++ b/src/ipa/raspberrypi/cam_helper.cpp\n> @@ -17,6 +17,11 @@\n>  #include \"md_parser.hpp\"\n>\n>  using namespace RPiController;\n> +using namespace libcamera;\n> +\n> +namespace libcamera {\n> +LOG_DECLARE_CATEGORY(IPARPI)\n> +}\n>\n>  static std::map<std::string, CamHelperCreateFunc> cam_helpers;\n>\n> @@ -57,6 +62,19 @@ double CamHelper::Exposure(uint32_t exposure_lines)\n> const\n>         return exposure_lines * mode_.line_length / 1000.0;\n>  }\n>\n> +uint32_t CamHelper::ColourGainCode([[maybe_unused]] double gain) const\n> +{\n> +       /*\n> +        * This is only used when the sensor has RED/BLUE_BALANCE controls.\n> +        * Most do not, so supplying a default is helpful - though no one\n> +        * should be calling it.\n> +        */\n> +       LOG(IPARPI, Fatal)\n> +               << \"Sensor is requesting RED/BLUE gains so a proper \"\n> +               << \"implementation of ColourGainCode must be provided\";\n> +       return 0;\n> +}\n> +\n>  uint32_t CamHelper::GetVBlanking(double &exposure, double\n> minFrameDuration,\n>                                  double maxFrameDuration) const\n>  {\n> diff --git a/src/ipa/raspberrypi/cam_helper.hpp\n> b/src/ipa/raspberrypi/cam_helper.hpp\n> index 4053a870..a0b6b987 100644\n> --- a/src/ipa/raspberrypi/cam_helper.hpp\n> +++ b/src/ipa/raspberrypi/cam_helper.hpp\n> @@ -26,7 +26,8 @@ namespace RPiController {\n>  //\n>  // The ability to convert between number of lines of exposure and actual\n>  // exposure time, and to convert between the sensor's gain codes and\n> actual\n> -// gains.\n> +// gains. Some sensors like to be told the colour (red and blue) gains, so\n> +// there's a method for converting these to gain codes too.\n>  //\n>  // A method to return the number of frames of delay between updating\n> exposure,\n>  // analogue gain and vblanking, and for the changes to take effect. For\n> many\n> @@ -72,6 +73,7 @@ public:\n>                                       double maxFrameDuration) const;\n>         virtual uint32_t GainCode(double gain) const = 0;\n>         virtual double Gain(uint32_t gain_code) const = 0;\n> +       virtual uint32_t ColourGainCode(double gain) const;\n>         virtual void GetDelays(int &exposure_delay, int &gain_delay,\n>                                int &vblank_delay) const;\n>         virtual bool SensorEmbeddedDataPresent() const;\n> --\n> 2.20.1\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel\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 1E30FBD224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 14 Apr 2021 10:34:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D108B6880C;\n\tWed, 14 Apr 2021 12:34:10 +0200 (CEST)","from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com\n\t[IPv6:2a00:1450:4864:20::12d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E17268803\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 14 Apr 2021 12:34:09 +0200 (CEST)","by mail-lf1-x12d.google.com with SMTP id x20so2046368lfu.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 14 Apr 2021 03:34:09 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"RJEUQfIJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=MuzHHJUl7XCSLKiUtK7/2C7rYhEAdDnKH1rBbeLuDpU=;\n\tb=RJEUQfIJJKovxf1Yx9nDQzQbLc7JOMUq6xNozCdqsZGoMBUlmm01/+o51cy8k5h+4w\n\tQAScQWXF6Hml5rMSXVJfShEO1H6y3e/3ldLOa8nLXUqXVYuLswRBblZMgJ5i9NmNZjwQ\n\tQ6FaeVay0QAkLkly61EkK0RIHbOJS2Icq+m59hf8LHnEDFOnaZZDvKb/GuyyGSTL3TYn\n\tZpCa5L1DkFOLY78tPO7dYUGfQVdpFizFKGMMbrKasAnPKLrcEF9Buvgv1v2VI+HVbMBN\n\tnrs2MyPeeTJrpeZy/w5DJP/Yf0gJvpaUbABBPJusjBT+OOJfybDPBoOec/x8Jc9H9Drj\n\thj2A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=MuzHHJUl7XCSLKiUtK7/2C7rYhEAdDnKH1rBbeLuDpU=;\n\tb=snDDjyHySGGOgA9lUfpM9M2zDDOc7ZGcEy2YIZxbyRlJGRGcGNZTNddLquEqcNuW4w\n\tN3aN2eQbk3fy97kthxHsSJj0Z7hL3c8ntFtx6iTqVoDSoSEnub0Dsnt0No1At89N617s\n\t/lpddv2u2EEPIB0AA4DP5BeY62tLxIiCuvIpjjN4wpSOOQU9hY94oUxohybNsME1xDOd\n\tY0lAsCjsx4Furc0ryGIkELcrsbGp93+hzxi8WloePzwVPLAZxDDAY54OP3Zfw4JdaUWf\n\t9XKmrdUHNGbetAYQ8NoBa+kg90+LHot4gOAxpTzqeyHppu9p4cyU/Ipx5rfwcmfgBX+G\n\tMvYQ==","X-Gm-Message-State":"AOAM533TygQ2muCRpJKHCbPgjuYnqU440ZegHb/72juEUjys2stZ5LRm\n\tTj5O4HipPTCauLKL06YjwgbeLHilfIi0ZFLNLmnPJg==","X-Google-Smtp-Source":"ABdhPJzHMWWV6MuUJpaBsGQy/Q67TrndrhudRlEUGyIQgWevJaPRDcyEFiwfMFuNUQ2Bhs2bIILV2UmiGYPHgCKE8ZY=","X-Received":"by 2002:a05:6512:b25:: with SMTP id\n\tw37mr26413144lfu.272.1618396449004; \n\tWed, 14 Apr 2021 03:34:09 -0700 (PDT)","MIME-Version":"1.0","References":"<20210414102955.9503-1-david.plowman@raspberrypi.com>\n\t<20210414102955.9503-3-david.plowman@raspberrypi.com>","In-Reply-To":"<20210414102955.9503-3-david.plowman@raspberrypi.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Wed, 14 Apr 2021 11:33:53 +0100","Message-ID":"<CAEmqJPrm9Q=aYAwuaRzkNSUXxFd6OkMZGoKpZ9QToqbyxkgyTw@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH v3 2/3] ipa: raspberrypi: Add\n\tCamHelper::ColourGainCode method","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Content-Type":"multipart/mixed;\n\tboundary=\"===============7229830032159016546==\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]