[{"id":11449,"web_url":"https://patchwork.libcamera.org/comment/11449/","msgid":"<e64d334e-ecaa-5e58-bd8c-20a9c20fba71@ideasonboard.com>","date":"2020-07-21T10:59:53","subject":"Re: [libcamera-devel] [PATCH v4 2/9] libcamera: pipeline: ipa:\n\traspberrypi: Rework drop frame signalling","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Naush,\n\nOn 20/07/2020 10:13, Naushir Patuck wrote:\n> The IPA now signals up front how many frames it wants the pipeline\n> handler to drop. This makes it easier to handle up-coming changes to the\n> buffer handling for import/export buffers.\n> \n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nLooks good to me\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> ---\n>  include/libcamera/ipa/raspberrypi.h           |  2 +-\n>  src/ipa/raspberrypi/raspberrypi.cpp           | 20 +++++------\n>  .../pipeline/raspberrypi/raspberrypi.cpp      | 36 +++++++++++--------\n>  3 files changed, 33 insertions(+), 25 deletions(-)\n> \n> diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\n> index a4937769..0f31b6ea 100644\n> --- a/include/libcamera/ipa/raspberrypi.h\n> +++ b/include/libcamera/ipa/raspberrypi.h\n> @@ -14,6 +14,7 @@ enum RPiConfigParameters {\n>  \tRPI_IPA_CONFIG_LS_TABLE = (1 << 0),\n>  \tRPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1),\n>  \tRPI_IPA_CONFIG_SENSOR = (1 << 2),\n> +\tRPI_IPA_CONFIG_DROP_FRAMES = (1 << 3),\n>  };\n>  \n>  enum RPiOperations {\n> @@ -21,7 +22,6 @@ enum RPiOperations {\n>  \tRPI_IPA_ACTION_V4L2_SET_ISP,\n>  \tRPI_IPA_ACTION_STATS_METADATA_COMPLETE,\n>  \tRPI_IPA_ACTION_RUN_ISP,\n> -\tRPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME,\n>  \tRPI_IPA_ACTION_EMBEDDED_COMPLETE,\n>  \tRPI_IPA_EVENT_SIGNAL_STAT_READY,\n>  \tRPI_IPA_EVENT_SIGNAL_ISP_PREPARE,\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index 7bd04880..2d9fb9d8 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -65,8 +65,8 @@ class IPARPi : public IPAInterface\n>  public:\n>  \tIPARPi()\n>  \t\t: lastMode_({}), controller_(), controllerInit_(false),\n> -\t\t  frame_count_(0), check_count_(0), hide_count_(0),\n> -\t\t  mistrust_count_(0), lsTable_(nullptr)\n> +\t\t  frame_count_(0), check_count_(0), mistrust_count_(0),\n> +\t\t  lsTableHandle_(0), lsTable_(nullptr)\n>  \t{\n>  \t}\n>  \n> @@ -137,8 +137,6 @@ private:\n>  \tuint64_t frame_count_;\n>  \t/* For checking the sequencing of Prepare/Process calls. */\n>  \tuint64_t check_count_;\n> -\t/* How many frames the pipeline handler should hide, or \"drop\". */\n> -\tunsigned int hide_count_;\n>  \t/* How many frames we should avoid running control algos on. */\n>  \tunsigned int mistrust_count_;\n>  \t/* LS table allocation passed in from the pipeline handler. */\n> @@ -242,14 +240,18 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n>  \t */\n>  \tframe_count_ = 0;\n>  \tcheck_count_ = 0;\n> +\tint drop_frame = 0;\n>  \tif (controllerInit_) {\n> -\t\thide_count_ = helper_->HideFramesModeSwitch();\n> +\t\tdrop_frame = helper_->HideFramesModeSwitch();\n>  \t\tmistrust_count_ = helper_->MistrustFramesModeSwitch();\n>  \t} else {\n> -\t\thide_count_ = helper_->HideFramesStartup();\n> +\t\tdrop_frame = helper_->HideFramesStartup();\n>  \t\tmistrust_count_ = helper_->MistrustFramesStartup();\n>  \t}\n>  \n> +\tresult->data.push_back(drop_frame);\n> +\tresult->operation |= RPI_IPA_CONFIG_DROP_FRAMES;\n> +\n>  \tstruct AgcStatus agcStatus;\n>  \t/* These zero values mean not program anything (unless overwritten). */\n>  \tagcStatus.shutter_time = 0.0;\n> @@ -366,13 +368,11 @@ void IPARPi::processEvent(const IPAOperationData &event)\n>  \t\t * they are \"unreliable\".\n>  \t\t */\n>  \t\tprepareISP(embeddedbufferId);\n> +\t\tframe_count_++;\n>  \n>  \t\t/* Ready to push the input buffer into the ISP. */\n>  \t\tIPAOperationData op;\n> -\t\tif (++frame_count_ > hide_count_)\n> -\t\t\top.operation = RPI_IPA_ACTION_RUN_ISP;\n> -\t\telse\n> -\t\t\top.operation = RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME;\n> +\t\top.operation = RPI_IPA_ACTION_RUN_ISP;\n\nThe bit field flag here looks better to me indeed!\n\n>  \t\top.data = { bayerbufferId & RPiIpaMask::ID };\n>  \t\tqueueFrameAction.emit(0, op);\n>  \t\tbreak;\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index 6630ef57..d3639ce1 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -133,7 +133,7 @@ class RPiCameraData : public CameraData\n>  public:\n>  \tRPiCameraData(PipelineHandler *pipe)\n>  \t\t: CameraData(pipe), sensor_(nullptr), state_(State::Stopped),\n> -\t\t  dropFrame_(false), ispOutputCount_(0)\n> +\t\t  dropFrameCount_(0), ispOutputCount_(0)\n>  \t{\n>  \t}\n>  \n> @@ -181,14 +181,15 @@ public:\n>  \tstd::queue<FrameBuffer *> embeddedQueue_;\n>  \tstd::deque<Request *> requestQueue_;\n>  \n> +\tunsigned int dropFrameCount_;\n> +\n>  private:\n>  \tvoid checkRequestCompleted();\n>  \tvoid tryRunPipeline();\n>  \tvoid tryFlushQueues();\n>  \tFrameBuffer *updateQueue(std::queue<FrameBuffer *> &q, uint64_t timestamp, V4L2VideoDevice *dev);\n>  \n> -\tbool dropFrame_;\n> -\tint ispOutputCount_;\n> +\tunsigned int ispOutputCount_;\n>  };\n>  \n>  class RPiCameraConfiguration : public CameraConfiguration\n> @@ -999,6 +1000,7 @@ int RPiCameraData::configureIPA()\n>  \tipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig,\n>  \t\t\t&result);\n>  \n> +\tunsigned int resultIdx = 0;\n>  \tif (result.operation & RPI_IPA_CONFIG_STAGGERED_WRITE) {\n>  \t\t/*\n>  \t\t * Setup our staggered control writer with the sensor default\n> @@ -1006,9 +1008,9 @@ int RPiCameraData::configureIPA()\n>  \t\t */\n>  \t\tif (!staggeredCtrl_) {\n>  \t\t\tstaggeredCtrl_.init(unicam_[Unicam::Image].dev(),\n> -\t\t\t\t\t    { { V4L2_CID_ANALOGUE_GAIN, result.data[0] },\n> -\t\t\t\t\t      { V4L2_CID_EXPOSURE, result.data[1] } });\n> -\t\t\tsensorMetadata_ = result.data[2];\n> +\t\t\t\t\t    { { V4L2_CID_ANALOGUE_GAIN, result.data[resultIdx++] },\n> +\t\t\t\t\t      { V4L2_CID_EXPOSURE, result.data[resultIdx++] } });\n> +\t\t\tsensorMetadata_ = result.data[resultIdx++];\n>  \t\t}\n>  \n>  \t\t/* Configure the H/V flip controls based on the sensor rotation. */\n> @@ -1025,6 +1027,11 @@ int RPiCameraData::configureIPA()\n>  \t\t\tLOG(RPI, Error) << \"V4L2 staggered set failed\";\n>  \t}\n>  \n> +\tif (result.operation & RPI_IPA_CONFIG_DROP_FRAMES) {\n> +\t\t/* Configure the number of dropped frames required on startup. */\n> +\t\tdropFrameCount_ = result.data[resultIdx++];\n\nI assume given this is about dropping frames on startup, it only occurs\nonce, and dropFrameCount_ is already zero at this point, so we're not\nlosing a previous request to drop frames for instance.\n\n\n\n\n> +\t}\n> +\n>  \treturn 0;\n>  }\n>  \n> @@ -1075,7 +1082,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n>  \t\tbreak;\n>  \t}\n>  \n> -\tcase RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME:\n>  \tcase RPI_IPA_ACTION_RUN_ISP: {\n>  \t\tunsigned int bufferId = action.data[0];\n>  \t\tFrameBuffer *buffer = unicam_[Unicam::Image].getBuffers()->at(bufferId).get();\n> @@ -1084,7 +1090,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n>  \t\t\t\t<< \", timestamp: \" << buffer->metadata().timestamp;\n>  \n>  \t\tisp_[Isp::Input].dev()->queueBuffer(buffer);\n> -\t\tdropFrame_ = (action.operation == RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME) ? true : false;\n>  \t\tispOutputCount_ = 0;\n>  \t\tbreak;\n>  \t}\n> @@ -1250,7 +1255,7 @@ void RPiCameraData::clearIncompleteRequests()\n>  void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, const RPi::RPiStream *stream)\n>  {\n>  \tif (stream->isExternal()) {\n> -\t\tif (!dropFrame_) {\n> +\t\tif (!dropFrameCount_) {\n>  \t\t\tRequest *request = buffer->request();\n>  \t\t\tpipe_->completeBuffer(camera_, request, buffer);\n>  \t\t}\n> @@ -1262,7 +1267,7 @@ void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, const RPi::RPiStream\n>  \t\t * simply memcpy to the Request buffer and requeue back to the\n>  \t\t * device.\n>  \t\t */\n> -\t\tif (stream == &unicam_[Unicam::Image] && !dropFrame_) {\n> +\t\tif (stream == &unicam_[Unicam::Image] && !dropFrameCount_) {\n>  \t\t\tconst Stream *rawStream = static_cast<const Stream *>(&isp_[Isp::Input]);\n>  \t\t\tRequest *request = requestQueue_.front();\n>  \t\t\tFrameBuffer *raw = request->findBuffer(const_cast<Stream *>(rawStream));\n> @@ -1307,7 +1312,7 @@ void RPiCameraData::checkRequestCompleted()\n>  \t * If we are dropping this frame, do not touch the request, simply\n>  \t * change the state to IDLE when ready.\n>  \t */\n> -\tif (!dropFrame_) {\n> +\tif (!dropFrameCount_) {\n>  \t\tRequest *request = requestQueue_.front();\n>  \t\tif (request->hasPendingBuffers())\n>  \t\t\treturn;\n> @@ -1326,10 +1331,13 @@ void RPiCameraData::checkRequestCompleted()\n>  \t * frame.\n>  \t */\n>  \tif (state_ == State::IpaComplete &&\n> -\t    ((ispOutputCount_ == 3 && dropFrame_) || requestCompleted)) {\n> +\t    ((ispOutputCount_ == 3 && dropFrameCount_) || requestCompleted)) {\n>  \t\tstate_ = State::Idle;\n> -\t\tif (dropFrame_)\n> -\t\t\tLOG(RPI, Info) << \"Dropping frame at the request of the IPA\";\n> +\t\tif (dropFrameCount_) {\n> +\t\t\tdropFrameCount_--;\n> +\t\t\tLOG(RPI, Info) << \"Dropping frame at the request of the IPA (\"\n> +\t\t\t\t       << dropFrameCount_ << \" left)\";\n> +\t\t}\n>  \t}\n>  }\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 04A15BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 21 Jul 2020 10:59:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7A4D260832;\n\tTue, 21 Jul 2020 12:59:58 +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 A14BC60496\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 21 Jul 2020 12:59:56 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 1D7EE51A;\n\tTue, 21 Jul 2020 12:59:56 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"ZiPDw1J3\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1595329196;\n\tbh=sK/nXo+QMrJQ6SmhieCOoAXnOZ3oDq6KDbFYEGIRPFY=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=ZiPDw1J3zjqlozL/8EoT6CyU5zSfZuj5/Xhl8merdWLTt62/vDyoUY5cpH4vl6aAo\n\tEJLwao8OHc7HJyYZt8gJJGSFIzJxKKJjF7WqF+Mbb6RsU7lqQ6waaZKfKg3VdscXVz\n\tzkbhuPig5uAzhvZHgpJ23I1iZFXLp3IKfao4q7EY=","To":"Naushir Patuck <naush@raspberrypi.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20200720091311.805092-1-naush@raspberrypi.com>\n\t<20200720091311.805092-3-naush@raspberrypi.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\t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\n\tWZw01QYHU/GUV/zHJSFk","Organization":"Ideas on Board","Message-ID":"<e64d334e-ecaa-5e58-bd8c-20a9c20fba71@ideasonboard.com>","Date":"Tue, 21 Jul 2020 11:59:53 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.10.0","MIME-Version":"1.0","In-Reply-To":"<20200720091311.805092-3-naush@raspberrypi.com>","Content-Language":"en-GB","Subject":"Re: [libcamera-devel] [PATCH v4 2/9] libcamera: pipeline: ipa:\n\traspberrypi: Rework drop frame signalling","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>","Reply-To":"kieran.bingham@ideasonboard.com","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11472,"web_url":"https://patchwork.libcamera.org/comment/11472/","msgid":"<CAEmqJPo-GmncCSpr13ay1UifBptJEpOo_b4c5E_cfZOib0gurQ@mail.gmail.com>","date":"2020-07-22T07:53:06","subject":"Re: [libcamera-devel] [PATCH v4 2/9] libcamera: pipeline: ipa:\n\traspberrypi: Rework drop frame signalling","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Kieran,\n\nThank you for your review.\n\nOn Tue, 21 Jul 2020 at 11:59, Kieran Bingham\n<kieran.bingham@ideasonboard.com> wrote:\n>\n> Hi Naush,\n>\n> On 20/07/2020 10:13, Naushir Patuck wrote:\n> > The IPA now signals up front how many frames it wants the pipeline\n> > handler to drop. This makes it easier to handle up-coming changes to the\n> > buffer handling for import/export buffers.\n> >\n> > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n>\n> Looks good to me\n>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>\n> > ---\n> >  include/libcamera/ipa/raspberrypi.h           |  2 +-\n> >  src/ipa/raspberrypi/raspberrypi.cpp           | 20 +++++------\n> >  .../pipeline/raspberrypi/raspberrypi.cpp      | 36 +++++++++++--------\n> >  3 files changed, 33 insertions(+), 25 deletions(-)\n> >\n> > diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\n> > index a4937769..0f31b6ea 100644\n> > --- a/include/libcamera/ipa/raspberrypi.h\n> > +++ b/include/libcamera/ipa/raspberrypi.h\n> > @@ -14,6 +14,7 @@ enum RPiConfigParameters {\n> >       RPI_IPA_CONFIG_LS_TABLE = (1 << 0),\n> >       RPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1),\n> >       RPI_IPA_CONFIG_SENSOR = (1 << 2),\n> > +     RPI_IPA_CONFIG_DROP_FRAMES = (1 << 3),\n> >  };\n> >\n> >  enum RPiOperations {\n> > @@ -21,7 +22,6 @@ enum RPiOperations {\n> >       RPI_IPA_ACTION_V4L2_SET_ISP,\n> >       RPI_IPA_ACTION_STATS_METADATA_COMPLETE,\n> >       RPI_IPA_ACTION_RUN_ISP,\n> > -     RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME,\n> >       RPI_IPA_ACTION_EMBEDDED_COMPLETE,\n> >       RPI_IPA_EVENT_SIGNAL_STAT_READY,\n> >       RPI_IPA_EVENT_SIGNAL_ISP_PREPARE,\n> > diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> > index 7bd04880..2d9fb9d8 100644\n> > --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> > +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> > @@ -65,8 +65,8 @@ class IPARPi : public IPAInterface\n> >  public:\n> >       IPARPi()\n> >               : lastMode_({}), controller_(), controllerInit_(false),\n> > -               frame_count_(0), check_count_(0), hide_count_(0),\n> > -               mistrust_count_(0), lsTable_(nullptr)\n> > +               frame_count_(0), check_count_(0), mistrust_count_(0),\n> > +               lsTableHandle_(0), lsTable_(nullptr)\n> >       {\n> >       }\n> >\n> > @@ -137,8 +137,6 @@ private:\n> >       uint64_t frame_count_;\n> >       /* For checking the sequencing of Prepare/Process calls. */\n> >       uint64_t check_count_;\n> > -     /* How many frames the pipeline handler should hide, or \"drop\". */\n> > -     unsigned int hide_count_;\n> >       /* How many frames we should avoid running control algos on. */\n> >       unsigned int mistrust_count_;\n> >       /* LS table allocation passed in from the pipeline handler. */\n> > @@ -242,14 +240,18 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n> >        */\n> >       frame_count_ = 0;\n> >       check_count_ = 0;\n> > +     int drop_frame = 0;\n> >       if (controllerInit_) {\n> > -             hide_count_ = helper_->HideFramesModeSwitch();\n> > +             drop_frame = helper_->HideFramesModeSwitch();\n> >               mistrust_count_ = helper_->MistrustFramesModeSwitch();\n> >       } else {\n> > -             hide_count_ = helper_->HideFramesStartup();\n> > +             drop_frame = helper_->HideFramesStartup();\n> >               mistrust_count_ = helper_->MistrustFramesStartup();\n> >       }\n> >\n> > +     result->data.push_back(drop_frame);\n> > +     result->operation |= RPI_IPA_CONFIG_DROP_FRAMES;\n> > +\n> >       struct AgcStatus agcStatus;\n> >       /* These zero values mean not program anything (unless overwritten). */\n> >       agcStatus.shutter_time = 0.0;\n> > @@ -366,13 +368,11 @@ void IPARPi::processEvent(const IPAOperationData &event)\n> >                * they are \"unreliable\".\n> >                */\n> >               prepareISP(embeddedbufferId);\n> > +             frame_count_++;\n> >\n> >               /* Ready to push the input buffer into the ISP. */\n> >               IPAOperationData op;\n> > -             if (++frame_count_ > hide_count_)\n> > -                     op.operation = RPI_IPA_ACTION_RUN_ISP;\n> > -             else\n> > -                     op.operation = RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME;\n> > +             op.operation = RPI_IPA_ACTION_RUN_ISP;\n>\n> The bit field flag here looks better to me indeed!\n>\n> >               op.data = { bayerbufferId & RPiIpaMask::ID };\n> >               queueFrameAction.emit(0, op);\n> >               break;\n> > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > index 6630ef57..d3639ce1 100644\n> > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > @@ -133,7 +133,7 @@ class RPiCameraData : public CameraData\n> >  public:\n> >       RPiCameraData(PipelineHandler *pipe)\n> >               : CameraData(pipe), sensor_(nullptr), state_(State::Stopped),\n> > -               dropFrame_(false), ispOutputCount_(0)\n> > +               dropFrameCount_(0), ispOutputCount_(0)\n> >       {\n> >       }\n> >\n> > @@ -181,14 +181,15 @@ public:\n> >       std::queue<FrameBuffer *> embeddedQueue_;\n> >       std::deque<Request *> requestQueue_;\n> >\n> > +     unsigned int dropFrameCount_;\n> > +\n> >  private:\n> >       void checkRequestCompleted();\n> >       void tryRunPipeline();\n> >       void tryFlushQueues();\n> >       FrameBuffer *updateQueue(std::queue<FrameBuffer *> &q, uint64_t timestamp, V4L2VideoDevice *dev);\n> >\n> > -     bool dropFrame_;\n> > -     int ispOutputCount_;\n> > +     unsigned int ispOutputCount_;\n> >  };\n> >\n> >  class RPiCameraConfiguration : public CameraConfiguration\n> > @@ -999,6 +1000,7 @@ int RPiCameraData::configureIPA()\n> >       ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig,\n> >                       &result);\n> >\n> > +     unsigned int resultIdx = 0;\n> >       if (result.operation & RPI_IPA_CONFIG_STAGGERED_WRITE) {\n> >               /*\n> >                * Setup our staggered control writer with the sensor default\n> > @@ -1006,9 +1008,9 @@ int RPiCameraData::configureIPA()\n> >                */\n> >               if (!staggeredCtrl_) {\n> >                       staggeredCtrl_.init(unicam_[Unicam::Image].dev(),\n> > -                                         { { V4L2_CID_ANALOGUE_GAIN, result.data[0] },\n> > -                                           { V4L2_CID_EXPOSURE, result.data[1] } });\n> > -                     sensorMetadata_ = result.data[2];\n> > +                                         { { V4L2_CID_ANALOGUE_GAIN, result.data[resultIdx++] },\n> > +                                           { V4L2_CID_EXPOSURE, result.data[resultIdx++] } });\n> > +                     sensorMetadata_ = result.data[resultIdx++];\n> >               }\n> >\n> >               /* Configure the H/V flip controls based on the sensor rotation. */\n> > @@ -1025,6 +1027,11 @@ int RPiCameraData::configureIPA()\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 startup. */\n> > +             dropFrameCount_ = result.data[resultIdx++];\n>\n> I assume given this is about dropping frames on startup, it only occurs\n> once, and dropFrameCount_ is already zero at this point, so we're not\n> losing a previous request to drop frames for instance.\n\nThat's correct.  We now only signal how many frames to drop at\nstartup, and this signal will not make us lose a previous drop frame\nrequest.\n\n>\n>\n>\n>\n> > +     }\n> > +\n> >       return 0;\n> >  }\n> >\n> > @@ -1075,7 +1082,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n> >               break;\n> >       }\n> >\n> > -     case RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME:\n> >       case RPI_IPA_ACTION_RUN_ISP: {\n> >               unsigned int bufferId = action.data[0];\n> >               FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers()->at(bufferId).get();\n> > @@ -1084,7 +1090,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n> >                               << \", timestamp: \" << buffer->metadata().timestamp;\n> >\n> >               isp_[Isp::Input].dev()->queueBuffer(buffer);\n> > -             dropFrame_ = (action.operation == RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME) ? true : false;\n> >               ispOutputCount_ = 0;\n> >               break;\n> >       }\n> > @@ -1250,7 +1255,7 @@ void RPiCameraData::clearIncompleteRequests()\n> >  void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, const RPi::RPiStream *stream)\n> >  {\n> >       if (stream->isExternal()) {\n> > -             if (!dropFrame_) {\n> > +             if (!dropFrameCount_) {\n> >                       Request *request = buffer->request();\n> >                       pipe_->completeBuffer(camera_, request, buffer);\n> >               }\n> > @@ -1262,7 +1267,7 @@ void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, const RPi::RPiStream\n> >                * simply memcpy to the Request buffer and requeue back to the\n> >                * device.\n> >                */\n> > -             if (stream == &unicam_[Unicam::Image] && !dropFrame_) {\n> > +             if (stream == &unicam_[Unicam::Image] && !dropFrameCount_) {\n> >                       const Stream *rawStream = static_cast<const Stream *>(&isp_[Isp::Input]);\n> >                       Request *request = requestQueue_.front();\n> >                       FrameBuffer *raw = request->findBuffer(const_cast<Stream *>(rawStream));\n> > @@ -1307,7 +1312,7 @@ void RPiCameraData::checkRequestCompleted()\n> >        * If we are dropping this frame, do not touch the request, simply\n> >        * change the state to IDLE when ready.\n> >        */\n> > -     if (!dropFrame_) {\n> > +     if (!dropFrameCount_) {\n> >               Request *request = requestQueue_.front();\n> >               if (request->hasPendingBuffers())\n> >                       return;\n> > @@ -1326,10 +1331,13 @@ void RPiCameraData::checkRequestCompleted()\n> >        * frame.\n> >        */\n> >       if (state_ == State::IpaComplete &&\n> > -         ((ispOutputCount_ == 3 && dropFrame_) || requestCompleted)) {\n> > +         ((ispOutputCount_ == 3 && dropFrameCount_) || requestCompleted)) {\n> >               state_ = State::Idle;\n> > -             if (dropFrame_)\n> > -                     LOG(RPI, Info) << \"Dropping frame at the request of the IPA\";\n> > +             if (dropFrameCount_) {\n> > +                     dropFrameCount_--;\n> > +                     LOG(RPI, Info) << \"Dropping frame at the request of the IPA (\"\n> > +                                    << dropFrameCount_ << \" left)\";\n> > +             }\n> >       }\n> >  }\n> >\n> >\n>\n> --\n> Regards\n> --\n> Kieran","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 19AA4BDB1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Jul 2020 07:53:26 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8F0A360943;\n\tWed, 22 Jul 2020 09:53:25 +0200 (CEST)","from mail-lj1-x233.google.com (mail-lj1-x233.google.com\n\t[IPv6:2a00:1450:4864:20::233])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0434C60540\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jul 2020 09:53:23 +0200 (CEST)","by mail-lj1-x233.google.com with SMTP id e8so1499367ljb.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jul 2020 00:53:23 -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=\"gNdqg302\"; 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:content-transfer-encoding;\n\tbh=yqX033MZbWy1++opmiMFQDf5xxd1il80TNNVGN5X9ZA=;\n\tb=gNdqg302IvuDBJsCSizlBcj7+joQrTg2QYUGxvZJGqI40H0b/jo/4GnvfDZzO/fA/T\n\tTDFxAfbioAbHybp+sYSvBf3TotRKB4ZlrQUAkoFZGmenJM21pXXc6qBp324y8P2PJfcA\n\tLZ77hOk7pGYy6uWNvk4vjljhnFOARiJL/Kxyb0zdYZ3rYPCGcVyNodfU9PMRrCthDY5Y\n\t0OYB6ElhlQrCXQ6uS03cnUarPPw8T4KMo4+GXeg0lWFSafBYlpivdjAICKnmwTh1Sc3h\n\tG3y0LRCqmLkZACFvKb+DGHOok4VnBR34eC2jD8Jk5FsOWqT4CGhqAdfA0lQnkSdA1i9B\n\tGA5A==","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:content-transfer-encoding;\n\tbh=yqX033MZbWy1++opmiMFQDf5xxd1il80TNNVGN5X9ZA=;\n\tb=Dq8N2Xb2j084PWLHR9l/PkDcErnPwH3zQKxCfgy0rEaaeEnbKH18rcyLfNYoPuXCnd\n\thpukRDzIM83ExFTAqWcOthiac8zKZHXzryJOOGnXaPGA92qF5OHhQLwEPYZdaxqUkDvj\n\tLv4EKDs1zG3gUiRXj3ztLeuqW8qwYT5SJmfyaHBe6VLBZOdKsVBc7yVrtQCWltn6Nh4i\n\tt0BXn1YgzmFU3wj1i6Nas5i+zsScYC4y9Zs8DOG/cBMIZI8puPtUc+muoXqPnJ6fRpg4\n\tJkiOnKwSi+q1Su1ovvcqzaVezzqhf1Ck3Oe3HD1te6HwPoYf+5bZTWhXY3Md8KJIet1e\n\tPZnQ==","X-Gm-Message-State":"AOAM533shnlFR2e8I7J2Xo2BaI+A3eenImc6wqjtSUqZlDxlRlPwK7Yy\n\txg7gZPOaH8RPq+2a4dx2CRZCBHFXZe+Lii28R3HXlElmhYU=","X-Google-Smtp-Source":"ABdhPJy3hUM9NGJG5Eeti5O4Sgt/r5sAKmSmRlLRfg6669NRfKpNUCtCGZkk3PvclGvVlPOxX8NL6sAAS2oPPOvDzS4=","X-Received":"by 2002:a2e:b167:: with SMTP id a7mr15030334ljm.83.1595404402837;\n\tWed, 22 Jul 2020 00:53:22 -0700 (PDT)","MIME-Version":"1.0","References":"<20200720091311.805092-1-naush@raspberrypi.com>\n\t<20200720091311.805092-3-naush@raspberrypi.com>\n\t<e64d334e-ecaa-5e58-bd8c-20a9c20fba71@ideasonboard.com>","In-Reply-To":"<e64d334e-ecaa-5e58-bd8c-20a9c20fba71@ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Wed, 22 Jul 2020 08:53:06 +0100","Message-ID":"<CAEmqJPo-GmncCSpr13ay1UifBptJEpOo_b4c5E_cfZOib0gurQ@mail.gmail.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 2/9] libcamera: pipeline: ipa:\n\traspberrypi: Rework drop frame signalling","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@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11495,"web_url":"https://patchwork.libcamera.org/comment/11495/","msgid":"<20200722142701.GB29813@pendragon.ideasonboard.com>","date":"2020-07-22T14:27:01","subject":"Re: [libcamera-devel] [PATCH v4 2/9] libcamera: pipeline: ipa:\n\traspberrypi: Rework drop frame signalling","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Naush,\n\nThank you for the patch.\n\nOn Wed, Jul 22, 2020 at 08:53:06AM +0100, Naushir Patuck wrote:\n> On Tue, 21 Jul 2020 at 11:59, Kieran Bingham wrote:\n> > On 20/07/2020 10:13, Naushir Patuck wrote:\n> > > The IPA now signals up front how many frames it wants the pipeline\n> > > handler to drop. This makes it easier to handle up-coming changes to the\n> > > buffer handling for import/export buffers.\n> > >\n> > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> >\n> > Looks good to me\n> >\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> >\n> > > ---\n> > >  include/libcamera/ipa/raspberrypi.h           |  2 +-\n> > >  src/ipa/raspberrypi/raspberrypi.cpp           | 20 +++++------\n> > >  .../pipeline/raspberrypi/raspberrypi.cpp      | 36 +++++++++++--------\n> > >  3 files changed, 33 insertions(+), 25 deletions(-)\n> > >\n> > > diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\n> > > index a4937769..0f31b6ea 100644\n> > > --- a/include/libcamera/ipa/raspberrypi.h\n> > > +++ b/include/libcamera/ipa/raspberrypi.h\n> > > @@ -14,6 +14,7 @@ enum RPiConfigParameters {\n> > >       RPI_IPA_CONFIG_LS_TABLE = (1 << 0),\n> > >       RPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1),\n> > >       RPI_IPA_CONFIG_SENSOR = (1 << 2),\n> > > +     RPI_IPA_CONFIG_DROP_FRAMES = (1 << 3),\n> > >  };\n> > >\n> > >  enum RPiOperations {\n> > > @@ -21,7 +22,6 @@ enum RPiOperations {\n> > >       RPI_IPA_ACTION_V4L2_SET_ISP,\n> > >       RPI_IPA_ACTION_STATS_METADATA_COMPLETE,\n> > >       RPI_IPA_ACTION_RUN_ISP,\n> > > -     RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME,\n> > >       RPI_IPA_ACTION_EMBEDDED_COMPLETE,\n> > >       RPI_IPA_EVENT_SIGNAL_STAT_READY,\n> > >       RPI_IPA_EVENT_SIGNAL_ISP_PREPARE,\n> > > diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> > > index 7bd04880..2d9fb9d8 100644\n> > > --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> > > +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> > > @@ -65,8 +65,8 @@ class IPARPi : public IPAInterface\n> > >  public:\n> > >       IPARPi()\n> > >               : lastMode_({}), controller_(), controllerInit_(false),\n> > > -               frame_count_(0), check_count_(0), hide_count_(0),\n> > > -               mistrust_count_(0), lsTable_(nullptr)\n> > > +               frame_count_(0), check_count_(0), mistrust_count_(0),\n> > > +               lsTableHandle_(0), lsTable_(nullptr)\n\nDid lsTableHandle creep in during a rebase conflict resolution ?\n\n> > >       {\n> > >       }\n> > >\n> > > @@ -137,8 +137,6 @@ private:\n> > >       uint64_t frame_count_;\n> > >       /* For checking the sequencing of Prepare/Process calls. */\n> > >       uint64_t check_count_;\n> > > -     /* How many frames the pipeline handler should hide, or \"drop\". */\n> > > -     unsigned int hide_count_;\n> > >       /* How many frames we should avoid running control algos on. */\n> > >       unsigned int mistrust_count_;\n> > >       /* LS table allocation passed in from the pipeline handler. */\n> > > @@ -242,14 +240,18 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n> > >        */\n> > >       frame_count_ = 0;\n> > >       check_count_ = 0;\n> > > +     int drop_frame = 0;\n\nMaybe unsigned int (as a negative number would be really strange) ?\n\n> > >       if (controllerInit_) {\n> > > -             hide_count_ = helper_->HideFramesModeSwitch();\n> > > +             drop_frame = helper_->HideFramesModeSwitch();\n> > >               mistrust_count_ = helper_->MistrustFramesModeSwitch();\n> > >       } else {\n> > > -             hide_count_ = helper_->HideFramesStartup();\n> > > +             drop_frame = helper_->HideFramesStartup();\n> > >               mistrust_count_ = helper_->MistrustFramesStartup();\n> > >       }\n> > >\n> > > +     result->data.push_back(drop_frame);\n> > > +     result->operation |= RPI_IPA_CONFIG_DROP_FRAMES;\n> > > +\n> > >       struct AgcStatus agcStatus;\n> > >       /* These zero values mean not program anything (unless overwritten). */\n> > >       agcStatus.shutter_time = 0.0;\n> > > @@ -366,13 +368,11 @@ void IPARPi::processEvent(const IPAOperationData &event)\n> > >                * they are \"unreliable\".\n> > >                */\n> > >               prepareISP(embeddedbufferId);\n> > > +             frame_count_++;\n> > >\n> > >               /* Ready to push the input buffer into the ISP. */\n> > >               IPAOperationData op;\n> > > -             if (++frame_count_ > hide_count_)\n> > > -                     op.operation = RPI_IPA_ACTION_RUN_ISP;\n> > > -             else\n> > > -                     op.operation = RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME;\n> > > +             op.operation = RPI_IPA_ACTION_RUN_ISP;\n> >\n> > The bit field flag here looks better to me indeed!\n> >\n> > >               op.data = { bayerbufferId & RPiIpaMask::ID };\n> > >               queueFrameAction.emit(0, op);\n> > >               break;\n> > > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > index 6630ef57..d3639ce1 100644\n> > > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > @@ -133,7 +133,7 @@ class RPiCameraData : public CameraData\n> > >  public:\n> > >       RPiCameraData(PipelineHandler *pipe)\n> > >               : CameraData(pipe), sensor_(nullptr), state_(State::Stopped),\n> > > -               dropFrame_(false), ispOutputCount_(0)\n> > > +               dropFrameCount_(0), ispOutputCount_(0)\n> > >       {\n> > >       }\n> > >\n> > > @@ -181,14 +181,15 @@ public:\n> > >       std::queue<FrameBuffer *> embeddedQueue_;\n> > >       std::deque<Request *> requestQueue_;\n> > >\n> > > +     unsigned int dropFrameCount_;\n> > > +\n> > >  private:\n> > >       void checkRequestCompleted();\n> > >       void tryRunPipeline();\n> > >       void tryFlushQueues();\n> > >       FrameBuffer *updateQueue(std::queue<FrameBuffer *> &q, uint64_t timestamp, V4L2VideoDevice *dev);\n> > >\n> > > -     bool dropFrame_;\n> > > -     int ispOutputCount_;\n> > > +     unsigned int ispOutputCount_;\n> > >  };\n> > >\n> > >  class RPiCameraConfiguration : public CameraConfiguration\n> > > @@ -999,6 +1000,7 @@ int RPiCameraData::configureIPA()\n> > >       ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig,\n> > >                       &result);\n> > >\n> > > +     unsigned int resultIdx = 0;\n> > >       if (result.operation & RPI_IPA_CONFIG_STAGGERED_WRITE) {\n> > >               /*\n> > >                * Setup our staggered control writer with the sensor default\n> > > @@ -1006,9 +1008,9 @@ int RPiCameraData::configureIPA()\n> > >                */\n> > >               if (!staggeredCtrl_) {\n> > >                       staggeredCtrl_.init(unicam_[Unicam::Image].dev(),\n> > > -                                         { { V4L2_CID_ANALOGUE_GAIN, result.data[0] },\n> > > -                                           { V4L2_CID_EXPOSURE, result.data[1] } });\n> > > -                     sensorMetadata_ = result.data[2];\n> > > +                                         { { V4L2_CID_ANALOGUE_GAIN, result.data[resultIdx++] },\n> > > +                                           { V4L2_CID_EXPOSURE, result.data[resultIdx++] } });\n> > > +                     sensorMetadata_ = result.data[resultIdx++];\n\nPaul is experimenting with options to use custom data types for\ncommunication between the pipeline handler and the IPA, it will\nhopefully simplify this kind of use case.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> > >               }\n> > >\n> > >               /* Configure the H/V flip controls based on the sensor rotation. */\n> > > @@ -1025,6 +1027,11 @@ int RPiCameraData::configureIPA()\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 startup. */\n> > > +             dropFrameCount_ = result.data[resultIdx++];\n> >\n> > I assume given this is about dropping frames on startup, it only occurs\n> > once, and dropFrameCount_ is already zero at this point, so we're not\n> > losing a previous request to drop frames for instance.\n> \n> That's correct.  We now only signal how many frames to drop at\n> startup, and this signal will not make us lose a previous drop frame\n> request.\n> \n> > > +     }\n> > > +\n> > >       return 0;\n> > >  }\n> > >\n> > > @@ -1075,7 +1082,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n> > >               break;\n> > >       }\n> > >\n> > > -     case RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME:\n> > >       case RPI_IPA_ACTION_RUN_ISP: {\n> > >               unsigned int bufferId = action.data[0];\n> > >               FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers()->at(bufferId).get();\n> > > @@ -1084,7 +1090,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n> > >                               << \", timestamp: \" << buffer->metadata().timestamp;\n> > >\n> > >               isp_[Isp::Input].dev()->queueBuffer(buffer);\n> > > -             dropFrame_ = (action.operation == RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME) ? true : false;\n> > >               ispOutputCount_ = 0;\n> > >               break;\n> > >       }\n> > > @@ -1250,7 +1255,7 @@ void RPiCameraData::clearIncompleteRequests()\n> > >  void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, const RPi::RPiStream *stream)\n> > >  {\n> > >       if (stream->isExternal()) {\n> > > -             if (!dropFrame_) {\n> > > +             if (!dropFrameCount_) {\n> > >                       Request *request = buffer->request();\n> > >                       pipe_->completeBuffer(camera_, request, buffer);\n> > >               }\n> > > @@ -1262,7 +1267,7 @@ void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, const RPi::RPiStream\n> > >                * simply memcpy to the Request buffer and requeue back to the\n> > >                * device.\n> > >                */\n> > > -             if (stream == &unicam_[Unicam::Image] && !dropFrame_) {\n> > > +             if (stream == &unicam_[Unicam::Image] && !dropFrameCount_) {\n> > >                       const Stream *rawStream = static_cast<const Stream *>(&isp_[Isp::Input]);\n> > >                       Request *request = requestQueue_.front();\n> > >                       FrameBuffer *raw = request->findBuffer(const_cast<Stream *>(rawStream));\n> > > @@ -1307,7 +1312,7 @@ void RPiCameraData::checkRequestCompleted()\n> > >        * If we are dropping this frame, do not touch the request, simply\n> > >        * change the state to IDLE when ready.\n> > >        */\n> > > -     if (!dropFrame_) {\n> > > +     if (!dropFrameCount_) {\n> > >               Request *request = requestQueue_.front();\n> > >               if (request->hasPendingBuffers())\n> > >                       return;\n> > > @@ -1326,10 +1331,13 @@ void RPiCameraData::checkRequestCompleted()\n> > >        * frame.\n> > >        */\n> > >       if (state_ == State::IpaComplete &&\n> > > -         ((ispOutputCount_ == 3 && dropFrame_) || requestCompleted)) {\n> > > +         ((ispOutputCount_ == 3 && dropFrameCount_) || requestCompleted)) {\n> > >               state_ = State::Idle;\n> > > -             if (dropFrame_)\n> > > -                     LOG(RPI, Info) << \"Dropping frame at the request of the IPA\";\n> > > +             if (dropFrameCount_) {\n> > > +                     dropFrameCount_--;\n> > > +                     LOG(RPI, Info) << \"Dropping frame at the request of the IPA (\"\n> > > +                                    << dropFrameCount_ << \" left)\";\n> > > +             }\n> > >       }\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 C66FEC2E68\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Jul 2020 14:27:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 477A360983;\n\tWed, 22 Jul 2020 16:27:09 +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 BC2116053C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jul 2020 16:27:07 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2F9B6329;\n\tWed, 22 Jul 2020 16:27:07 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"udOT7rFF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1595428027;\n\tbh=qqB6zgWcKh/2p2qFsaVecXYyBq4HQQngD5lC66wpaPE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=udOT7rFFWO7cBm+PjLSBacxUHVeAgJg/jWCSUooDntwHEiwOvaM7X4WEC+X57irdq\n\tPCFMbosa46EVYg5vS6+qoBJPHpXdlYS4kWUdUzLqr9CGPhyelfn3Yb8es7EgeswFpg\n\tdnFtdXR0VijqiZuaX+wiHZCr0xsS+ZQpBepbxAsw=","Date":"Wed, 22 Jul 2020 17:27:01 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Message-ID":"<20200722142701.GB29813@pendragon.ideasonboard.com>","References":"<20200720091311.805092-1-naush@raspberrypi.com>\n\t<20200720091311.805092-3-naush@raspberrypi.com>\n\t<e64d334e-ecaa-5e58-bd8c-20a9c20fba71@ideasonboard.com>\n\t<CAEmqJPo-GmncCSpr13ay1UifBptJEpOo_b4c5E_cfZOib0gurQ@mail.gmail.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<CAEmqJPo-GmncCSpr13ay1UifBptJEpOo_b4c5E_cfZOib0gurQ@mail.gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v4 2/9] libcamera: pipeline: ipa:\n\traspberrypi: Rework drop frame signalling","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@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11496,"web_url":"https://patchwork.libcamera.org/comment/11496/","msgid":"<CAEmqJPpxMHLzO2rdAXf8-w+17RLuif12rkC8EhCVLS3qYP_mXA@mail.gmail.com>","date":"2020-07-22T14:29:07","subject":"Re: [libcamera-devel] [PATCH v4 2/9] libcamera: pipeline: ipa:\n\traspberrypi: Rework drop frame signalling","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"content":"Hi Laurent,\n\nThank you for your review.\n\nOn Wed, 22 Jul 2020 at 15:27, Laurent Pinchart\n<laurent.pinchart@ideasonboard.com> wrote:\n>\n> Hi Naush,\n>\n> Thank you for the patch.\n>\n> On Wed, Jul 22, 2020 at 08:53:06AM +0100, Naushir Patuck wrote:\n> > On Tue, 21 Jul 2020 at 11:59, Kieran Bingham wrote:\n> > > On 20/07/2020 10:13, Naushir Patuck wrote:\n> > > > The IPA now signals up front how many frames it wants the pipeline\n> > > > handler to drop. This makes it easier to handle up-coming changes to the\n> > > > buffer handling for import/export buffers.\n> > > >\n> > > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n> > > > Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > >\n> > > Looks good to me\n> > >\n> > > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > >\n> > > > ---\n> > > >  include/libcamera/ipa/raspberrypi.h           |  2 +-\n> > > >  src/ipa/raspberrypi/raspberrypi.cpp           | 20 +++++------\n> > > >  .../pipeline/raspberrypi/raspberrypi.cpp      | 36 +++++++++++--------\n> > > >  3 files changed, 33 insertions(+), 25 deletions(-)\n> > > >\n> > > > diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\n> > > > index a4937769..0f31b6ea 100644\n> > > > --- a/include/libcamera/ipa/raspberrypi.h\n> > > > +++ b/include/libcamera/ipa/raspberrypi.h\n> > > > @@ -14,6 +14,7 @@ enum RPiConfigParameters {\n> > > >       RPI_IPA_CONFIG_LS_TABLE = (1 << 0),\n> > > >       RPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1),\n> > > >       RPI_IPA_CONFIG_SENSOR = (1 << 2),\n> > > > +     RPI_IPA_CONFIG_DROP_FRAMES = (1 << 3),\n> > > >  };\n> > > >\n> > > >  enum RPiOperations {\n> > > > @@ -21,7 +22,6 @@ enum RPiOperations {\n> > > >       RPI_IPA_ACTION_V4L2_SET_ISP,\n> > > >       RPI_IPA_ACTION_STATS_METADATA_COMPLETE,\n> > > >       RPI_IPA_ACTION_RUN_ISP,\n> > > > -     RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME,\n> > > >       RPI_IPA_ACTION_EMBEDDED_COMPLETE,\n> > > >       RPI_IPA_EVENT_SIGNAL_STAT_READY,\n> > > >       RPI_IPA_EVENT_SIGNAL_ISP_PREPARE,\n> > > > diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> > > > index 7bd04880..2d9fb9d8 100644\n> > > > --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> > > > +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> > > > @@ -65,8 +65,8 @@ class IPARPi : public IPAInterface\n> > > >  public:\n> > > >       IPARPi()\n> > > >               : lastMode_({}), controller_(), controllerInit_(false),\n> > > > -               frame_count_(0), check_count_(0), hide_count_(0),\n> > > > -               mistrust_count_(0), lsTable_(nullptr)\n> > > > +               frame_count_(0), check_count_(0), mistrust_count_(0),\n> > > > +               lsTableHandle_(0), lsTable_(nullptr)\n>\n> Did lsTableHandle creep in during a rebase conflict resolution ?\n\nOops, good catch!\n\n>\n> > > >       {\n> > > >       }\n> > > >\n> > > > @@ -137,8 +137,6 @@ private:\n> > > >       uint64_t frame_count_;\n> > > >       /* For checking the sequencing of Prepare/Process calls. */\n> > > >       uint64_t check_count_;\n> > > > -     /* How many frames the pipeline handler should hide, or \"drop\". */\n> > > > -     unsigned int hide_count_;\n> > > >       /* How many frames we should avoid running control algos on. */\n> > > >       unsigned int mistrust_count_;\n> > > >       /* LS table allocation passed in from the pipeline handler. */\n> > > > @@ -242,14 +240,18 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n> > > >        */\n> > > >       frame_count_ = 0;\n> > > >       check_count_ = 0;\n> > > > +     int drop_frame = 0;\n>\n> Maybe unsigned int (as a negative number would be really strange) ?\n\nAck.\n\n>\n> > > >       if (controllerInit_) {\n> > > > -             hide_count_ = helper_->HideFramesModeSwitch();\n> > > > +             drop_frame = helper_->HideFramesModeSwitch();\n> > > >               mistrust_count_ = helper_->MistrustFramesModeSwitch();\n> > > >       } else {\n> > > > -             hide_count_ = helper_->HideFramesStartup();\n> > > > +             drop_frame = helper_->HideFramesStartup();\n> > > >               mistrust_count_ = helper_->MistrustFramesStartup();\n> > > >       }\n> > > >\n> > > > +     result->data.push_back(drop_frame);\n> > > > +     result->operation |= RPI_IPA_CONFIG_DROP_FRAMES;\n> > > > +\n> > > >       struct AgcStatus agcStatus;\n> > > >       /* These zero values mean not program anything (unless overwritten). */\n> > > >       agcStatus.shutter_time = 0.0;\n> > > > @@ -366,13 +368,11 @@ void IPARPi::processEvent(const IPAOperationData &event)\n> > > >                * they are \"unreliable\".\n> > > >                */\n> > > >               prepareISP(embeddedbufferId);\n> > > > +             frame_count_++;\n> > > >\n> > > >               /* Ready to push the input buffer into the ISP. */\n> > > >               IPAOperationData op;\n> > > > -             if (++frame_count_ > hide_count_)\n> > > > -                     op.operation = RPI_IPA_ACTION_RUN_ISP;\n> > > > -             else\n> > > > -                     op.operation = RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME;\n> > > > +             op.operation = RPI_IPA_ACTION_RUN_ISP;\n> > >\n> > > The bit field flag here looks better to me indeed!\n> > >\n> > > >               op.data = { bayerbufferId & RPiIpaMask::ID };\n> > > >               queueFrameAction.emit(0, op);\n> > > >               break;\n> > > > diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > > index 6630ef57..d3639ce1 100644\n> > > > --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > > +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> > > > @@ -133,7 +133,7 @@ class RPiCameraData : public CameraData\n> > > >  public:\n> > > >       RPiCameraData(PipelineHandler *pipe)\n> > > >               : CameraData(pipe), sensor_(nullptr), state_(State::Stopped),\n> > > > -               dropFrame_(false), ispOutputCount_(0)\n> > > > +               dropFrameCount_(0), ispOutputCount_(0)\n> > > >       {\n> > > >       }\n> > > >\n> > > > @@ -181,14 +181,15 @@ public:\n> > > >       std::queue<FrameBuffer *> embeddedQueue_;\n> > > >       std::deque<Request *> requestQueue_;\n> > > >\n> > > > +     unsigned int dropFrameCount_;\n> > > > +\n> > > >  private:\n> > > >       void checkRequestCompleted();\n> > > >       void tryRunPipeline();\n> > > >       void tryFlushQueues();\n> > > >       FrameBuffer *updateQueue(std::queue<FrameBuffer *> &q, uint64_t timestamp, V4L2VideoDevice *dev);\n> > > >\n> > > > -     bool dropFrame_;\n> > > > -     int ispOutputCount_;\n> > > > +     unsigned int ispOutputCount_;\n> > > >  };\n> > > >\n> > > >  class RPiCameraConfiguration : public CameraConfiguration\n> > > > @@ -999,6 +1000,7 @@ int RPiCameraData::configureIPA()\n> > > >       ipa_->configure(sensorInfo, streamConfig, entityControls, ipaConfig,\n> > > >                       &result);\n> > > >\n> > > > +     unsigned int resultIdx = 0;\n> > > >       if (result.operation & RPI_IPA_CONFIG_STAGGERED_WRITE) {\n> > > >               /*\n> > > >                * Setup our staggered control writer with the sensor default\n> > > > @@ -1006,9 +1008,9 @@ int RPiCameraData::configureIPA()\n> > > >                */\n> > > >               if (!staggeredCtrl_) {\n> > > >                       staggeredCtrl_.init(unicam_[Unicam::Image].dev(),\n> > > > -                                         { { V4L2_CID_ANALOGUE_GAIN, result.data[0] },\n> > > > -                                           { V4L2_CID_EXPOSURE, result.data[1] } });\n> > > > -                     sensorMetadata_ = result.data[2];\n> > > > +                                         { { V4L2_CID_ANALOGUE_GAIN, result.data[resultIdx++] },\n> > > > +                                           { V4L2_CID_EXPOSURE, result.data[resultIdx++] } });\n> > > > +                     sensorMetadata_ = result.data[resultIdx++];\n>\n> Paul is experimenting with options to use custom data types for\n> communication between the pipeline handler and the IPA, it will\n> hopefully simplify this kind of use case.\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> > > >               }\n> > > >\n> > > >               /* Configure the H/V flip controls based on the sensor rotation. */\n> > > > @@ -1025,6 +1027,11 @@ int RPiCameraData::configureIPA()\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 startup. */\n> > > > +             dropFrameCount_ = result.data[resultIdx++];\n> > >\n> > > I assume given this is about dropping frames on startup, it only occurs\n> > > once, and dropFrameCount_ is already zero at this point, so we're not\n> > > losing a previous request to drop frames for instance.\n> >\n> > That's correct.  We now only signal how many frames to drop at\n> > startup, and this signal will not make us lose a previous drop frame\n> > request.\n> >\n> > > > +     }\n> > > > +\n> > > >       return 0;\n> > > >  }\n> > > >\n> > > > @@ -1075,7 +1082,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n> > > >               break;\n> > > >       }\n> > > >\n> > > > -     case RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME:\n> > > >       case RPI_IPA_ACTION_RUN_ISP: {\n> > > >               unsigned int bufferId = action.data[0];\n> > > >               FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers()->at(bufferId).get();\n> > > > @@ -1084,7 +1090,6 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n> > > >                               << \", timestamp: \" << buffer->metadata().timestamp;\n> > > >\n> > > >               isp_[Isp::Input].dev()->queueBuffer(buffer);\n> > > > -             dropFrame_ = (action.operation == RPI_IPA_ACTION_RUN_ISP_AND_DROP_FRAME) ? true : false;\n> > > >               ispOutputCount_ = 0;\n> > > >               break;\n> > > >       }\n> > > > @@ -1250,7 +1255,7 @@ void RPiCameraData::clearIncompleteRequests()\n> > > >  void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, const RPi::RPiStream *stream)\n> > > >  {\n> > > >       if (stream->isExternal()) {\n> > > > -             if (!dropFrame_) {\n> > > > +             if (!dropFrameCount_) {\n> > > >                       Request *request = buffer->request();\n> > > >                       pipe_->completeBuffer(camera_, request, buffer);\n> > > >               }\n> > > > @@ -1262,7 +1267,7 @@ void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, const RPi::RPiStream\n> > > >                * simply memcpy to the Request buffer and requeue back to the\n> > > >                * device.\n> > > >                */\n> > > > -             if (stream == &unicam_[Unicam::Image] && !dropFrame_) {\n> > > > +             if (stream == &unicam_[Unicam::Image] && !dropFrameCount_) {\n> > > >                       const Stream *rawStream = static_cast<const Stream *>(&isp_[Isp::Input]);\n> > > >                       Request *request = requestQueue_.front();\n> > > >                       FrameBuffer *raw = request->findBuffer(const_cast<Stream *>(rawStream));\n> > > > @@ -1307,7 +1312,7 @@ void RPiCameraData::checkRequestCompleted()\n> > > >        * If we are dropping this frame, do not touch the request, simply\n> > > >        * change the state to IDLE when ready.\n> > > >        */\n> > > > -     if (!dropFrame_) {\n> > > > +     if (!dropFrameCount_) {\n> > > >               Request *request = requestQueue_.front();\n> > > >               if (request->hasPendingBuffers())\n> > > >                       return;\n> > > > @@ -1326,10 +1331,13 @@ void RPiCameraData::checkRequestCompleted()\n> > > >        * frame.\n> > > >        */\n> > > >       if (state_ == State::IpaComplete &&\n> > > > -         ((ispOutputCount_ == 3 && dropFrame_) || requestCompleted)) {\n> > > > +         ((ispOutputCount_ == 3 && dropFrameCount_) || requestCompleted)) {\n> > > >               state_ = State::Idle;\n> > > > -             if (dropFrame_)\n> > > > -                     LOG(RPI, Info) << \"Dropping frame at the request of the IPA\";\n> > > > +             if (dropFrameCount_) {\n> > > > +                     dropFrameCount_--;\n> > > > +                     LOG(RPI, Info) << \"Dropping frame at the request of the IPA (\"\n> > > > +                                    << dropFrameCount_ << \" left)\";\n> > > > +             }\n> > > >       }\n> > > >  }\n> > > >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\n\nRegards,\nNaush","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 CBDF1C2E68\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 22 Jul 2020 14:29:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 41F1D6093F;\n\tWed, 22 Jul 2020 16:29:27 +0200 (CEST)","from mail-lj1-x235.google.com (mail-lj1-x235.google.com\n\t[IPv6:2a00:1450:4864:20::235])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 16A846053C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jul 2020 16:29:25 +0200 (CEST)","by mail-lj1-x235.google.com with SMTP id b25so2715224ljp.6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 22 Jul 2020 07:29:25 -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=\"IX80iVGl\"; 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:content-transfer-encoding;\n\tbh=1B2hUJF8KuJItuDyWkozOEf++UyDGQiW+ThR8+VHlwE=;\n\tb=IX80iVGlKOkwehDJ63xEBOSkjhi/+1+9o35Vti+4EGodxRVdXNHWv4rnqlKBLy3jQT\n\trC4F7ZbQYuTKt7LH706inE0oD3A2L+5v7GysZvO8LxVtWAWHFTPGpCCfAA9TNBKd1JhO\n\tHts5I6zjlcwrC3ks4zoRBz0pzPziSFgCC6BNAq1hhRnAkwlLdXjngYj2AhK7skw4jpxK\n\tLxjcvFPjnvFUD/RSuTEVhvIxYvqI0Ro2ZGcroNwrWk6Gj9Bdbq6hfLWJKBqJA404BOn7\n\t2CYZxQhw8JOD53b+m5l+pAQUFJtVHOhybnL4z8ZPy0MsZSpT8S4VWvH75+j7LAhOwbnn\n\tj9nA==","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:content-transfer-encoding;\n\tbh=1B2hUJF8KuJItuDyWkozOEf++UyDGQiW+ThR8+VHlwE=;\n\tb=BgX8PS+ydhHOj/r2tcETVSFPDEH9JYBD4sVTx36NmrgHCyb5TQDIvt9m92HeDXJisS\n\tQ2t5thNiu41F7qa/eiOt7TuFNMzvhPK8f5V2HL59j7Vpbq6lXa908fvO4wc/+wc/+8E5\n\tMO4iXPP3wvE2zzuZsm+/9G0XyylXazjVfJrcabf9WhKLbZSCY+4o7e2CDgcfQjU0X8kt\n\tpnQTxIGrhNXgXcLSyg+ObBVjVNSlxyh0BEe9YD1m6BpWwwFoXJ1f0Y/cDDYdknnnF46a\n\tvvLJLC0h2yM5cx6vgk/SoZZnLGp1FVeRUlsLXd80TJ0FfawkntjAwhRuVct3h2OFPILQ\n\tibcw==","X-Gm-Message-State":"AOAM5327NWoEIvzsikjR4G+68N+ZLEwdaS7zNbz5Enl6zPZnSxkbk1g0\n\t4R0ok4uFIjg/RQ4zYFTA9SR7AtJmTYoUbYY6kykjMA==","X-Google-Smtp-Source":"ABdhPJyrKplADpsag9y1PIjBjzac6i59EpfM5t4YBv2bUenvuMzfUZ5Jt7LjoZGakSCKYWR2tx4273KiLZy/W9bbOiA=","X-Received":"by 2002:a2e:a30f:: with SMTP id\n\tl15mr15181509lje.228.1595428163785; \n\tWed, 22 Jul 2020 07:29:23 -0700 (PDT)","MIME-Version":"1.0","References":"<20200720091311.805092-1-naush@raspberrypi.com>\n\t<20200720091311.805092-3-naush@raspberrypi.com>\n\t<e64d334e-ecaa-5e58-bd8c-20a9c20fba71@ideasonboard.com>\n\t<CAEmqJPo-GmncCSpr13ay1UifBptJEpOo_b4c5E_cfZOib0gurQ@mail.gmail.com>\n\t<20200722142701.GB29813@pendragon.ideasonboard.com>","In-Reply-To":"<20200722142701.GB29813@pendragon.ideasonboard.com>","From":"Naushir Patuck <naush@raspberrypi.com>","Date":"Wed, 22 Jul 2020 15:29:07 +0100","Message-ID":"<CAEmqJPpxMHLzO2rdAXf8-w+17RLuif12rkC8EhCVLS3qYP_mXA@mail.gmail.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v4 2/9] libcamera: pipeline: ipa:\n\traspberrypi: Rework drop frame signalling","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@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]