[{"id":25118,"web_url":"https://patchwork.libcamera.org/comment/25118/","msgid":"<CAHW6GYJC-GRvENjFR6kma2HF=tPPc0di3HYh8jtq02Uaecs6cg@mail.gmail.com>","date":"2022-09-23T10:42:09","subject":"Re: [libcamera-devel] [PATCH v2 6/7] pipeline: ipa: raspberrypi:\n\tUse IPA cookies","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, 5 Sept 2022 at 08:40, Naushir Patuck via libcamera-devel\n<libcamera-devel@lists.libcamera.org> wrote:\n>\n> Pass an IPA cookie from the IPA to the pipeline handler through the\n> setDelayedControls signal. This cookie is the index of the current\n> RPiController::Metadata context used for the frame. The cookie is subsequently\n> passed into DelayedControls together with the controls to action.\n>\n> The IPA cookie is then returned from DelayedControls when the frame with the\n> applied controls has been returned from the sensor, and eventually passed back\n> to the IPA from the signalIspPrepare signal.\n>\n> Signed-off-by: Naushir Patuck <naush@raspberrypi.com>\n\nNot a lot to add to this one either... LGTM.\n\nReviewed-by: David Plowman <david.plowman@raspberrypi.com>\nTested-by: David Plowman <david.plowman@raspberrypi.com>\n\nThanks!\nDavid\n\n> ---\n>  include/libcamera/ipa/raspberrypi.mojom            |  3 ++-\n>  src/ipa/raspberrypi/raspberrypi.cpp                |  2 +-\n>  src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 12 +++++++-----\n>  3 files changed, 10 insertions(+), 7 deletions(-)\n>\n> diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom\n> index c0de435b7b33..fb806a1518d5 100644\n> --- a/include/libcamera/ipa/raspberrypi.mojom\n> +++ b/include/libcamera/ipa/raspberrypi.mojom\n> @@ -36,6 +36,7 @@ struct ISPConfig {\n>         uint32 bayerBufferId;\n>         bool embeddedBufferPresent;\n>         libcamera.ControlList controls;\n> +       uint32 ipaCookie;\n>  };\n>\n>  struct IPAConfig {\n> @@ -136,5 +137,5 @@ interface IPARPiEventInterface {\n>         runIsp(uint32 bufferId);\n>         embeddedComplete(uint32 bufferId);\n>         setIspControls(libcamera.ControlList controls);\n> -       setDelayedControls(libcamera.ControlList controls);\n> +       setDelayedControls(libcamera.ControlList controls, uint32 ipaCookie);\n>  };\n> diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\n> index 63cccda901c1..0e80ef9c7b95 100644\n> --- a/src/ipa/raspberrypi/raspberrypi.cpp\n> +++ b/src/ipa/raspberrypi/raspberrypi.cpp\n> @@ -1144,7 +1144,7 @@ void IPARPi::processStats(unsigned int bufferId)\n>                 ControlList ctrls(sensorCtrls_);\n>                 applyAGC(&agcStatus, ctrls);\n>\n> -               setDelayedControls.emit(ctrls);\n> +               setDelayedControls.emit(ctrls, metadataIdx_);\n>         }\n>  }\n>\n> diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> index d34a906c3cea..4d4c9e1fb9c4 100644\n> --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n> @@ -208,7 +208,7 @@ public:\n>         void runIsp(uint32_t bufferId);\n>         void embeddedComplete(uint32_t bufferId);\n>         void setIspControls(const ControlList &controls);\n> -       void setDelayedControls(const ControlList &controls);\n> +       void setDelayedControls(const ControlList &controls, uint32_t ipaCookie);\n>         void setSensorControls(ControlList &controls);\n>         void unicamTimeout();\n>\n> @@ -259,6 +259,7 @@ public:\n>         struct BayerFrame {\n>                 FrameBuffer *buffer;\n>                 ControlList controls;\n> +               unsigned int ipaCookie;\n>         };\n>\n>         std::queue<BayerFrame> bayerQueue_;\n> @@ -1784,9 +1785,9 @@ void RPiCameraData::setIspControls(const ControlList &controls)\n>         handleState();\n>  }\n>\n> -void RPiCameraData::setDelayedControls(const ControlList &controls)\n> +void RPiCameraData::setDelayedControls(const ControlList &controls, uint32_t ipaCookie)\n>  {\n> -       if (!delayedCtrls_->push(controls))\n> +       if (!delayedCtrls_->push(controls, ipaCookie))\n>                 LOG(RPI, Error) << \"V4L2 DelayedControl set failed\";\n>         handleState();\n>  }\n> @@ -1848,13 +1849,13 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer)\n>                  * Lookup the sensor controls used for this frame sequence from\n>                  * DelayedControl and queue them along with the frame buffer.\n>                  */\n> -               auto [ctrl, cookie] = delayedCtrls_->get(buffer->metadata().sequence);\n> +               auto [ctrl, ipaCookie] = delayedCtrls_->get(buffer->metadata().sequence);\n>                 /*\n>                  * Add the frame timestamp to the ControlList for the IPA to use\n>                  * as it does not receive the FrameBuffer object.\n>                  */\n>                 ctrl.set(controls::SensorTimestamp, buffer->metadata().timestamp);\n> -               bayerQueue_.push({ buffer, std::move(ctrl) });\n> +               bayerQueue_.push({ buffer, std::move(ctrl), ipaCookie });\n>         } else {\n>                 embeddedQueue_.push(buffer);\n>         }\n> @@ -2148,6 +2149,7 @@ void RPiCameraData::tryRunPipeline()\n>         ipa::RPi::ISPConfig ispPrepare;\n>         ispPrepare.bayerBufferId = ipa::RPi::MaskBayerData | bayerId;\n>         ispPrepare.controls = std::move(bayerFrame.controls);\n> +       ispPrepare.ipaCookie = bayerFrame.ipaCookie;\n>\n>         if (embeddedBuffer) {\n>                 unsigned int embeddedId = unicam_[Unicam::Embedded].getBufferId(embeddedBuffer);\n> --\n> 2.25.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 A9F4AC0DA4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 23 Sep 2022 10:42:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 006376223A;\n\tFri, 23 Sep 2022 12:42:22 +0200 (CEST)","from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com\n\t[IPv6:2a00:1450:4864:20::22e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B3776621DD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Sep 2022 12:42:20 +0200 (CEST)","by mail-lj1-x22e.google.com with SMTP id a10so14242387ljq.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 23 Sep 2022 03:42:20 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1663929743;\n\tbh=lbWAurURRM2QS7B/YHBawKxhYkmWFSKIFjN87yNohpY=;\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=CuLC5DrHuO0RZ+bC37hVlGY+ZaYgYnJ3wRYK+uh7hvrDqbqWshTR6Fv/MiqVx7sTi\n\tt9EmBIa2hrHKf33oZOjTbpmrJ1Vu9iVzQPlXY2NCf3J6emPZ+MnNkS99hYNZGpKP0Z\n\tLCTJl3gQbqBuLwsi5m0GuPTM6StlXSsnzJXi+UZoUlG2hO0VAKfrETZTshjmVV3FbL\n\tnHuXSWNi2hWMzf2I1p84Xw6/i4HZE2YL+SxjU3BDCLBfs92BbdXgmdQeaNfguufUDU\n\tebaVl111IxqVtKxCPSXicUFb+iZyH9bW3v+ugyyJjRd53UX/ZfoPHSW42xMqg7UXJA\n\tHmCulAnpLCCnQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=cc:to:subject:message-id:date:from:in-reply-to:references\n\t:mime-version:from:to:cc:subject:date;\n\tbh=5rAM35QV02tJm7/AdTc4yBhASrnqqLxKUg0MvaxQuE0=;\n\tb=tTHs/KUB1Ki4hpxz+v5mLYFYXmaqgavqxdezx9NFvVVjli+o4k4j5nvb5X90IV6PqC\n\t/TnCogM1HpDtM22Kft8/5Z8r7qwMNbWGPfaG5OAjy/SmwTP4le5NwYVhb4f0C1CfIv3J\n\t/WWW+XfV7CJNSSdB5y1EW1rNhMJX9QXR4J7Mx8zrkHPkHdGH6PCldLoGlKW8guv1khDz\n\tSimcApm7rTv3d3/NBbWw5vob0YrGOjoHbN2A63xkabzGcnLClgzya5BrJHpWynGOb2OE\n\tDyU4FGzJVZWVOXM6MMCJLpMfbzuceNekOUgvdPjE9vTPeQijZPJyNiKU1grsJWIjjH5Q\n\tQPCg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"tTHs/KUB\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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;\n\tbh=5rAM35QV02tJm7/AdTc4yBhASrnqqLxKUg0MvaxQuE0=;\n\tb=ZDvd5bE9Jp1hS+gzWeT32BPBrE4S69k3KtXVqNcLnazgBhD9/VZyuVJzNyseu9tFjd\n\td85WiwsOOArKKgnejLsAsNVTgSr47WkCFVjI7biAXstgT7RGb0yPywdwOwvHrbpsT/bK\n\t5/tHt1tX81N8yRfVhs6gvQC0+vWt2wx26S7y+Sa7UVDJMmsBk+gJ5zXCSEoeSS9XHOGJ\n\tmbOqB8zg0bPItDEhoddU5pSkrGQ0H/x6vdRTgFMI9qwy/E3NvZ8MXEj/TlhmQOh86tRg\n\thmdZATt1KVYDcmmshO4Z+BGHzXVECueBlHyrZ5xIOA4d6k1Gs/uIX7afGKEGWB6X4GpC\n\tP/sw==","X-Gm-Message-State":"ACrzQf3Lu+spTfYy4O1XmcZ+H/K/xtaVHJsw1iT/TpSWd+p51EQIrMvC\n\tPxfOgflJ5EpaSkgOtgNv0zfum4PFgNkokid3AIlDx1Q28FN/+g==","X-Google-Smtp-Source":"AMsMyM5mZ2HIzowhJGGJBKL/XMxgdjL4H4bPTyke2aH+d0c0f8NQWz4SNcNhD+WsZ4q4Pc0q9+Gq06mN5s8hizZUSnk=","X-Received":"by 2002:a2e:99c2:0:b0:26c:3fb1:4c5a with SMTP id\n\tl2-20020a2e99c2000000b0026c3fb14c5amr2522052ljj.460.1663929740021;\n\tFri, 23 Sep 2022 03:42:20 -0700 (PDT)","MIME-Version":"1.0","References":"<20220905073956.7342-1-naush@raspberrypi.com>\n\t<20220905073956.7342-7-naush@raspberrypi.com>","In-Reply-To":"<20220905073956.7342-7-naush@raspberrypi.com>","Date":"Fri, 23 Sep 2022 11:42:09 +0100","Message-ID":"<CAHW6GYJC-GRvENjFR6kma2HF=tPPc0di3HYh8jtq02Uaecs6cg@mail.gmail.com>","To":"Naushir Patuck <naush@raspberrypi.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Subject":"Re: [libcamera-devel] [PATCH v2 6/7] pipeline: ipa: raspberrypi:\n\tUse IPA cookies","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":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]