{"id":8825,"url":"https://patchwork.libcamera.org/api/patches/8825/?format=json","web_url":"https://patchwork.libcamera.org/patch/8825/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200715140703.566298-3-naush@raspberrypi.com>","date":"2020-07-15T14:06:55","name":"[libcamera-devel,v2,02/10] libcamera: pipeline: ipa: raspberrypi: Rework drop frame signalling","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"a33926636a9931b037562516b855d7ea0720c23d","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8825/mbox/","series":[{"id":1111,"url":"https://patchwork.libcamera.org/api/series/1111/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1111","date":"2020-07-15T14:06:53","name":"Zero-copy RAW stream work","version":2,"mbox":"https://patchwork.libcamera.org/series/1111/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8825/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8825/checks/","tags":{},"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 E44C2BD790\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 15 Jul 2020 14:07:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B1D9D609C7;\n\tWed, 15 Jul 2020 16:07:16 +0200 (CEST)","from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7E27160579\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Jul 2020 16:07:12 +0200 (CEST)","by mail-wm1-x32d.google.com with SMTP id f18so5974725wml.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 15 Jul 2020 07:07:12 -0700 (PDT)","from naushir-VirtualBox.patuck.local ([88.97.76.4])\n\tby smtp.gmail.com with ESMTPSA id\n\tl67sm4195339wml.13.2020.07.15.07.07.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 15 Jul 2020 07:07:10 -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=\"Zy6CfmDa\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=m4D5LJKKW8ExK8OFbShXoKjTF+Hcogn926zMCP2Xrxg=;\n\tb=Zy6CfmDauQla8kAFz6XdgkGuv3iCtkSQEYjZrN2HIxTg1HA7JA3og7Jti8AI2cU7t4\n\t4DEmPpI3bIcElwayLeE8ua8fK6cFgQTU9NR8AB5g0z7Ne5GCN3wzMyzoIXsg2r0yB1Pt\n\tY7eeHPxN94VeSssCwJoZZgbVinPl+X2b4YkG53ZIIWYI7RW3cQJDc5RKGy/FbQcH2gO5\n\td3pDEFlYzomiIKt3bRp8zQSKm0MV1W8sR3DzhSgBt4qVfjcx/78wHY9CjR/c3OBUj36M\n\ttiUeK4w2rQh7sn5Ok9zXTG8Up0xfIUrjfjtyFREImaCftNXzFdSOoE9JZrBF4Qa2ZVdR\n\tBj4A==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=m4D5LJKKW8ExK8OFbShXoKjTF+Hcogn926zMCP2Xrxg=;\n\tb=JS8YHk7b3+Syf4Nvu7w1MMyVHR9gFDt83b2OP2/NSOxD0vW5xAQMg2R3N1GgPmgiKb\n\tHIYoI53Tc4oCeCxCRvO2iOswS2HFzOTHsqjWbJoHo0VCRm6SNnPrSofJciJSDtkG09Xn\n\tNgpwlD9nbuFyyHgz2DUsfvad3ABttUS850vDc2hlh+PvcugtiKUoBvQBC9Q1GQDdxeAU\n\tKGWAZBXNKF35zbakjzh3W0tUqjCmbJVVNmd5tv7FDNR5k1WU1PzX5ZO1acJvhZ16zFZS\n\tPSkT1O/pOOlAwKFfOzzHOHyxxpgwKL8Yb2X4R4ZGZO180/p0yth1vmauwaHrA4kHhKDG\n\tHqYA==","X-Gm-Message-State":"AOAM532P6ZRaAg81/DQN7o2Kw+J2WoH7g9t0L3963tFAs2i8bs19gcU2\n\tLy4oCBVTqJH+ZfDGmrBVV8NGSvE5+IU=","X-Google-Smtp-Source":"ABdhPJzPVufRiq4S26q02mlfGoaz2bF1YVoBY3QAPJaF4uObShVc8XKHwD9gGkfpjefeUDLfgCYo8g==","X-Received":"by 2002:a1c:1bc4:: with SMTP id\n\tb187mr9427041wmb.105.1594822031590; \n\tWed, 15 Jul 2020 07:07:11 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 15 Jul 2020 15:06:55 +0100","Message-Id":"<20200715140703.566298-3-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200715140703.566298-1-naush@raspberrypi.com>","References":"<20200715140703.566298-1-naush@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 02/10] 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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The IPA now signals up front how many frames it wants the pipeline\nhandler to drop. This makes it easier to handle up-coming changes to the\nbuffer handling for import/export buffers.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n include/libcamera/ipa/raspberrypi.h           |  2 +-\n src/ipa/raspberrypi/raspberrypi.cpp           | 21 +++++++-------\n .../pipeline/raspberrypi/raspberrypi.cpp      | 29 ++++++++++++-------\n 3 files changed, 30 insertions(+), 22 deletions(-)","diff":"diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex a18ce9a8..2dab2b00 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -15,8 +15,8 @@ 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_SET_SENSOR_CONFIG,\n+\tRPI_IPA_ACTION_SET_DROP_FRAME_COUNT,\n \tRPI_IPA_ACTION_EMBEDDED_COMPLETE,\n \tRPI_IPA_EVENT_SIGNAL_STAT_READY,\n \tRPI_IPA_EVENT_SIGNAL_ISP_PREPARE,\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex b1f27861..f3568882 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -64,8 +64,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), lsTableHandle_(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@@ -132,8 +132,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@@ -241,14 +239,19 @@ 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+\tIPAOperationData op;\n+\top.operation = RPI_IPA_ACTION_SET_DROP_FRAME_COUNT;\n+\top.data.push_back(drop_frame);\n+\n \tstruct AgcStatus agcStatus;\n \t/* These zero values mean not program anything (unless overwritten). */\n \tagcStatus.shutter_time = 0.0;\n@@ -339,13 +342,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 \t\top.data = { bayerbufferId & RPiIpaMask::ID };\n \t\tqueueFrameAction.emit(0, op);\n \t\tbreak;\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex a80db2eb..8b6f578f 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -131,7 +131,7 @@ class RPiCameraData : public CameraData\n public:\n \tRPiCameraData(PipelineHandler *pipe)\n \t\t: CameraData(pipe), sensor_(nullptr), lsTable_(nullptr),\n-\t\t  state_(State::Stopped), dropFrame_(false), ispOutputCount_(0)\n+\t\t  state_(State::Stopped), dropFrameCount_(0), ispOutputCount_(0)\n \t{\n \t}\n \n@@ -194,14 +194,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@@ -1058,6 +1059,11 @@ void RPiCameraData::queueFrameAction(unsigned int frame, const IPAOperationData\n \t\tgoto done;\n \t}\n \n+\tcase RPI_IPA_ACTION_SET_DROP_FRAME_COUNT: {\n+\t\tdropFrameCount_ = action.data[0];\n+\t\tgoto done;\n+\t}\n+\n \tcase RPI_IPA_ACTION_V4L2_SET_ISP: {\n \t\tControlList controls = action.controls[0];\n \t\tisp_[Isp::Input].dev()->setControls(&controls);\n@@ -1091,7 +1097,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@@ -1100,7 +1105,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@@ -1266,7 +1270,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@@ -1278,7 +1282,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@@ -1323,7 +1327,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@@ -1342,10 +1346,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","prefixes":["libcamera-devel","v2","02/10"]}