[{"id":14056,"web_url":"https://patchwork.libcamera.org/comment/14056/","msgid":"<CAEmqJPr-ooYv0w2UN-799JJRZGi39L_TZOG9DdzGA0i+4g2V=A@mail.gmail.com>","date":"2020-12-04T15:53:24","subject":"Re: [libcamera-devel] [PATCH 2/5] src: raspberrypi: Pass the drop\n\tframe count in start, not configure","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi David,\n\nThank you for the patch.\n\nOn Wed, 2 Dec 2020 at 11:53, David Plowman <david.plowman@raspberrypi.com>\nwrote:\n\n> The number of frames to drop (not display) is passed back now from the\n> start method, not configure. This means applications have a chance to\n> set fixed exposure/gain before starting the camera and this can affect\n> the frame drop count that is returned.\n>\n> Both the IPA implementation file and the pipeline handler need\n> matching modifications.\n>\n> Signed-off-by: David Plowman <david.plowman@raspberrypi.com>\n>\n\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n\n\n> ---\n>  src/ipa/raspberrypi/raspberrypi.cpp           | 38 +++++++++----------\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 25 ++++++------\n>  2 files changed, 32 insertions(+), 31 deletions(-)\n>\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp\n> b/src/ipa/raspberrypi/raspberrypi.cpp\n> index b8298768..0300b8d9 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -182,6 +182,25 @@ int IPARPi::start(const IPAOperationData &ipaConfig,\n> IPAOperationData *result)\n>                 result->operation |= RPi::IPA_CONFIG_SENSOR;\n>         }\n>\n> +       /*\n> +        * Initialise frame counts, and decide how many frames must be\n> hidden or\n> +        *\"mistrusted\", which depends on whether this is a startup from\n> cold,\n> +        * or merely a mode switch in a running system.\n> +        */\n> +       frameCount_ = 0;\n> +       checkCount_ = 0;\n> +       unsigned int dropFrame = 0;\n> +       if (firstStart_) {\n> +               dropFrame = helper_->HideFramesStartup();\n> +               mistrustCount_ = helper_->MistrustFramesStartup();\n> +       } else {\n> +               dropFrame = helper_->HideFramesModeSwitch();\n> +               mistrustCount_ = helper_->MistrustFramesModeSwitch();\n> +       }\n> +\n> +       result->data.push_back(dropFrame);\n> +       result->operation |= RPi::IPA_CONFIG_DROP_FRAMES;\n> +\n>         firstStart_ = false;\n>\n>         return 0;\n> @@ -298,25 +317,6 @@ void IPARPi::configure(const CameraSensorInfo\n> &sensorInfo,\n>         /* Pass the camera mode to the CamHelper to setup algorithms. */\n>         helper_->SetCameraMode(mode_);\n>\n> -       /*\n> -        * Initialise frame counts, and decide how many frames must be\n> hidden or\n> -        *\"mistrusted\", which depends on whether this is a startup from\n> cold,\n> -        * or merely a mode switch in a running system.\n> -        */\n> -       frameCount_ = 0;\n> -       checkCount_ = 0;\n> -       unsigned int dropFrame = 0;\n> -       if (controllerInit_) {\n> -               dropFrame = helper_->HideFramesModeSwitch();\n> -               mistrustCount_ = helper_->MistrustFramesModeSwitch();\n> -       } else {\n> -               dropFrame = helper_->HideFramesStartup();\n> -               mistrustCount_ = helper_->MistrustFramesStartup();\n> -       }\n> -\n> -       result->data.push_back(dropFrame);\n> -       result->operation |= RPi::IPA_CONFIG_DROP_FRAMES;\n> -\n>         if (!controllerInit_) {\n>                 /* Load the tuning file for this sensor. */\n>                 controller_.Read(tuningFile_.c_str());\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 89a44763..5ae56628 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -745,13 +745,6 @@ int PipelineHandlerRPi::start(Camera *camera,\n> [[maybe_unused]] ControlList *cont\n>                 return ret;\n>         }\n>\n> -       ret = queueAllBuffers(camera);\n> -       if (ret) {\n> -               LOG(RPI, Error) << \"Failed to queue buffers\";\n> -               stop(camera);\n> -               return ret;\n> -       }\n> -\n>         /* Check if a ScalerCrop control was specified. */\n>         if (controls)\n>                 data->applyScalerCrop(*controls);\n> @@ -778,6 +771,19 @@ int PipelineHandlerRPi::start(Camera *camera,\n> [[maybe_unused]] ControlList *cont\n>                         LOG(RPI, Error) << \"V4L2 staggered set failed\";\n>         }\n>\n> +       if (result.operation & RPi::IPA_CONFIG_DROP_FRAMES) {\n> +               /* Configure the number of dropped frames required on\n> startup. */\n> +               data->dropFrameCount_ = result.data[0];\n> +       }\n> +\n> +       /* We need to set the dropFrameCount_ before queueing buffers. */\n> +       ret = queueAllBuffers(camera);\n> +       if (ret) {\n> +               LOG(RPI, Error) << \"Failed to queue buffers\";\n> +               stop(camera);\n> +               return ret;\n> +       }\n> +\n>         /*\n>          * IPA configure may have changed the sensor flips - hence the\n> bayer\n>          * order. Get the sensor format and set the ISP input now.\n> @@ -1231,11 +1237,6 @@ int RPiCameraData::configureIPA(const\n> CameraConfiguration *config)\n>                         LOG(RPI, Error) << \"V4L2 staggered set failed\";\n>         }\n>\n> -       if (result.operation & RPi::IPA_CONFIG_DROP_FRAMES) {\n> -               /* Configure the number of dropped frames required on\n> startup. */\n> -               dropFrameCount_ = result.data[resultIdx++];\n> -       }\n> -\n>         /*\n>          * Configure the H/V flip controls based on the combination of\n>          * the sensor and user transform.\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 5F5D4BE176\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri,  4 Dec 2020 15:53:44 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DB812635EF;\n\tFri,  4 Dec 2020 16:53:43 +0100 (CET)","from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 48377635D0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  4 Dec 2020 16:53:42 +0100 (CET)","by mail-lj1-x243.google.com with SMTP id y7so7130849lji.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 04 Dec 2020 07:53:42 -0800 (PST)"],"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=\"X24dpmkI\"; 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=X+FoX6QI8pZWau/WrcQ2kVxjNbwbcFiU8A+j2m2MHBo=;\n\tb=X24dpmkI4wsCNDIyJFTtK2zYuTehlzD3YV7DVq2ECb++2sQ2UMhYAAwwFUCAKwpEBl\n\tNxM8xX4TzIn29bP2xhd9u7K8chaOJ5EDWMOhMFf0JSaeOBOO97YtrPou29M3+snp8yaA\n\tmy+gA96zLeyzyPH32HwWn18MuMt77gg8+xkge6Ke4cf10+H9zhy5ZuScwlxTolC05tQl\n\tWQuuWovAqrQnhgJC9eFg8Vr2uyt7HNwYmBcrzHNMpQZuSRpIumbqCTm4a/I7U/Y8zqt6\n\t3M2JNmLfhxUv9MUXUZRij+PmAXFzg2eQOaa9O/PAVv5YnNqldMvCcP+z8fURLwwloyle\n\t/WkQ==","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=X+FoX6QI8pZWau/WrcQ2kVxjNbwbcFiU8A+j2m2MHBo=;\n\tb=jSiy8ofS2kQwOTNvuvhfwZzeP/Ixmz+ptDOEI8LazW1cw4R/j21hpwZgQ3dLqD9ORZ\n\tP7apx7JJGxdkD/FmnIiLPxdItDBqul1Pg1XydI4WMl6ldFG5Yy7rKCrPFM+4HNSW+Xv1\n\tMkXqVC+KY8aX+d9A6afZkFiM0A+pu5IJW0Nd9tTrQXRSAYdpX+RluLE8nL8FKoCz4Ho3\n\tK72InB4F+h+96HGscU9FwEjKKcfmsl5ziXOnYdXziTWQ7PRARtPfldvYwS+lrE9NGKkA\n\tRAf3YrZYX4jK11L4qN51tGMi24ShYd4etCrNZ4y0/Y3+k9ytzHMQQLMJkm8NgXvT/i1F\n\tQ6pw==","X-Gm-Message-State":"AOAM5338khsmswWaC+JJ9DqyDX7e7RfQja6nLvZ9++dgOkIa0hlXzASd\n\t8g91mHCwtIPvwwEG/E+1bgJxv3l6HwJjGFQlS3Dq2g==","X-Google-Smtp-Source":"ABdhPJy3b09xAXEpsnOvihRt0x8M3So72k/6DsknQ7QaOB+jLGwS/eK1g823EVHpS2tbAW6JdmNWildLSTuVMAqtEHQ=","X-Received":"by 2002:a2e:80c6:: with SMTP id r6mr3691003ljg.83.1607097221656; \n\tFri, 04 Dec 2020 07:53:41 -0800 (PST)","MIME-Version":"1.0","References":"<20201202115253.14705-1-david.plowman@raspberrypi.com>\n\t<20201202115253.14705-3-david.plowman@raspberrypi.com>","In-Reply-To":"<20201202115253.14705-3-david.plowman@raspberrypi.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Fri, 4 Dec 2020 15:53:24 +0000","Message-ID":"<CAEmqJPr-ooYv0w2UN-799JJRZGi39L_TZOG9DdzGA0i+4g2V=A@mail.gmail.com>","To":"David Plowman <david.plowman@raspberrypi.com>","Subject":"Re: [libcamera-devel] [PATCH 2/5] src: raspberrypi: Pass the drop\n\tframe count in start, not configure","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=\"===============1152128361416512522==\"","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]