[{"id":27422,"web_url":"https://patchwork.libcamera.org/comment/27422/","msgid":"<CAHW6GYLsAMoVuQd7MBa5TV4g9YUZoorr-MD-j+84Vby6j_62eA@mail.gmail.com>","date":"2023-06-26T13:30:53","subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: imx708: Fix mode switch\n\tdrop frame count","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/people/42/","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"content":"Hi Naush\n\nThanks for the patch.\n\nOn Mon, 26 Jun 2023 at 14:08, Naushir Patuck via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> The imx708 must drop a single frame on startup - but only when in HDR\n> mode. Non-HDR modes do not need to drop frames. Fix the logic in\n> hideFramesModeSwitch() which currently unconditionally advertises to\n> drop one frame.\n>\n> Unfortunately there is no clear way to tell if the sensor is in the HDR\n> mode. So for now, look the resolution and framerate to deduce this.\n>\n> Additionally ensure we override hideFramesStartup() and return the same\n> number as hideFramesModeSwitch().\n>\n> Bug: https://github.com/raspberrypi/libcamera-apps/issues/524\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nIndeed, it's not lovely is it? But in the absence of a \"tonemapped HDR\nformat\" or something to that effect, it's hard to think of a good\nsolution.\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks\nDavid\n\n> ---\n>  src/ipa/rpi/cam_helper/cam_helper_imx708.cpp | 25 +++++++++++++++++++-\n>  1 file changed, 24 insertions(+), 1 deletion(-)\n>\n> diff --git a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n> index 641ba18f4b9d..2cd7afdbd8ec 100644\n> --- a/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n> +++ b/src/ipa/rpi/cam_helper/cam_helper_imx708.cpp\n> @@ -21,6 +21,8 @@ using namespace RPiController;\n>  using namespace libcamera;\n>  using libcamera::utils::Duration;\n>\n> +using namespace std::literals::chrono_literals;\n> +\n>  namespace libcamera {\n>  LOG_DECLARE_CATEGORY(IPARPI)\n>  }\n> @@ -56,7 +58,8 @@ public:\n>                        int &vblankDelay, int &hblankDelay) const override;\n>         bool sensorEmbeddedDataPresent() const override;\n>         double getModeSensitivity(const CameraMode &mode) const override;\n> -       unsigned int hideFramesModeSwitch() const override { return 1; } // seems to be required for HDR\n> +       unsigned int hideFramesModeSwitch() const override;\n> +       unsigned int hideFramesStartup() const;\n>\n>  private:\n>         /*\n> @@ -225,6 +228,26 @@ double CamHelperImx708::getModeSensitivity(const CameraMode &mode) const\n>         return (mode.width > 2304) ? 1.0 : 2.0;\n>  }\n>\n> +unsigned int CamHelperImx708::hideFramesModeSwitch() const\n> +{\n> +       /*\n> +        * We need to drop the first startup frame in HDR mode.\n> +        * Unfortunately the only way to currently determine if the sensor is in\n> +        * the HDR mode is to match with the resolution and framerate - the HDR\n> +        * mode only runs upto 30fps.\n> +        */\n> +       if (mode_.width == 2304 && mode_.height == 1296 &&\n> +           mode_.minFrameDuration <= 1.0s / 30)\n> +               return 1;\n> +       else\n> +               return 0;\n> +}\n> +\n> +unsigned int CamHelperImx708::hideFramesStartup() const\n> +{\n> +       return hideFramesModeSwitch();\n> +}\n> +\n>  void CamHelperImx708::populateMetadata(const MdParser::RegisterMap &registers,\n>                                        Metadata &metadata) const\n>  {\n> --\n> 2.34.1\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 C5535C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 26 Jun 2023 13:31:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0DDA1628C0;\n\tMon, 26 Jun 2023 15:31:07 +0200 (CEST)","from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com\n\t[IPv6:2607:f8b0:4864:20::f33])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 96728628BB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Jun 2023 15:31:05 +0200 (CEST)","by mail-qv1-xf33.google.com with SMTP id\n\t6a1803df08f44-635dbfa710dso9437646d6.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 26 Jun 2023 06:31:05 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1687786267;\n\tbh=WSf1wBCm3dhIMJZ0YiifHqiVf9+6gTNEYN7j9YKW6Ns=;\n\th=References:In-Reply-To:Date:To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=sF1CjINHKSYHTT1Bf6CxZ8djE8gXebwWJMKFaYOYMCWOgUWPHHxfx+hIogdnP43KV\n\t9ZYl2FwqnofERaIELtSn4HGYv+PzVZHop2ZQQ07zOTBKpzzy9bqB2n9kLvmcBwqUZX\n\tUkElaa3M7Ook3LWxPP3eYy0XJvd/EMCLmrcTJbPckKiPfK1LIfp/bFneVOqRTobACB\n\thTnlW5fyOFLFRJ+sMv161buCkergReUoO70Bd/6JMMAi2zh7uk/fprKcprTfRzsRi/\n\t1GrolGhIXuw2UZRNm+C1d8t8+V/gNL/sPnr2dExd00pOu5DpNHRVo++n3OQZ7qjX5Y\n\tkyw5Jn0AvkInw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google; t=1687786264; x=1690378264;\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=Inl+ZJ5h6jSVHwOtBDqbaPY5z0yPWZtGkdi6gY6P/xU=;\n\tb=lsZF6D5/slOEmrpdYrwzKJeOEOye+SZTFIgTOZBXd2du+N39e5xE245mrCpy4/0gvw\n\tjT0WGYNZnGDWJwbAMrN5DO/Ti3o+6MThG1QxLzL9CCgV3tG24GdvVq4PMANar1O3fSNM\n\tQ5UTSo+PP9fumXUfDSofEUcFPbiet8+Ej14S8OII5JIAZ8nBC5zd8yM9u/dwNkrg83be\n\tO82zMfI48cqajuWvip53JMAvQ6TkWhcJgYnYWlwypc1h7LRumY5+b9TD0CJ/0i82xemD\n\tSq0B3pgyUkoJSKiKorj++fHUO193lSgAjcWnQoyjjvyzzcBQUa2NonkClcyUfvv6Oqp3\n\t6dhw=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"lsZF6D5/\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20221208; t=1687786264; x=1690378264;\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=Inl+ZJ5h6jSVHwOtBDqbaPY5z0yPWZtGkdi6gY6P/xU=;\n\tb=apNq2GxXq2bs0VauNqqAGWqBZJrSWoL1CAVMfO21GDR4LFlk1lq6/yIzVCq2GaQmCE\n\tdfyGUQPuvaygG27dDaKOVOeRBYPNVr4M2IfXk7lDrhSCnQWbpHRsK1OqeI2y4up8AUzE\n\txYZtWPhk1rCP4voMCmalWwl6zz/dKUsmbm0gm3RRI6jKY5qwnkDHHcE5KZwOUQSubERz\n\t6RTf4dB9gRC4JPJX5jhE2sHLVYNuAkOKZ5BKSI/VD+d7lezPNs+WpDW6I3wuNB4VAs9Y\n\tOkVU/YLOj2fwwXoTlz8cqQFnIUA+iALiiR2nsvAS2bZFurAvDcLMIr8i8A7paWsHeP7n\n\tevJQ==","X-Gm-Message-State":"AC+VfDyXttfbQC9iYh+wl2aaxqGx/RzS+bf0QmgiqdZDkS/7t+zDx4+n\n\tvPcb2P0gKN1AbYpwey2SYe9DHGh5y95nbuQa5UdtMQ==","X-Google-Smtp-Source":"ACHHUZ74tkxNSY5Ehvng23VvwB1/E6rOEGyTYJ8DPHnCbJstQVfITOQfEee2ZPnVCwF4hjpcSvh6u0TIFievly0KuOg=","X-Received":"by 2002:a05:6214:238c:b0:625:7aae:baf8 with SMTP id\n\tfw12-20020a056214238c00b006257aaebaf8mr32769471qvb.4.1687786264369;\n\tMon, 26 Jun 2023 06:31:04 -0700 (PDT)","MIME-Version":"1.0","References":"<20230626130833.15895-1-naush@raspberrypi.com>","In-Reply-To":"<20230626130833.15895-1-naush@raspberrypi.com>","Date":"Mon, 26 Jun 2023 14:30:53 +0100","Message-ID":"<CAHW6GYLsAMoVuQd7MBa5TV4g9YUZoorr-MD-j+84Vby6j_62eA@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH] ipa: rpi: imx708: Fix mode switch\n\tdrop frame count","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":"David Plowman via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"David Plowman <david.plowman@raspberrypi.com>","Cc":"Nick Hollinghurst <nick.hollinghurst@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]