{"id":14507,"url":"https://patchwork.libcamera.org/api/1.1/patches/14507/?format=json","web_url":"https://patchwork.libcamera.org/patch/14507/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20211110031651.2808099-3-hiroh@chromium.org>","date":"2021-11-10T03:16:51","name":"[libcamera-devel,v5,3/3] libcamera: pipeline: ipu3: Apply the requested test pattern mode","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"8fd93b9ce29a4d796c63776ac5758d175eaf654a","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/1.1/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/14507/mbox/","series":[{"id":2700,"url":"https://patchwork.libcamera.org/api/1.1/series/2700/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2700","date":"2021-11-10T03:16:49","name":"[libcamera-devel,v5,1/3] libcamera: camera_sensor: Reference test pattern modes by enum type","version":5,"mbox":"https://patchwork.libcamera.org/series/2700/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/14507/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/14507/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 B3E8EC324E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 10 Nov 2021 03:17:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 55AD760345;\n\tWed, 10 Nov 2021 04:17:05 +0100 (CET)","from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com\n\t[IPv6:2607:f8b0:4864:20::52c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E3E0C60345\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Nov 2021 04:17:02 +0100 (CET)","by mail-pg1-x52c.google.com with SMTP id r28so983009pga.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 09 Nov 2021 19:17:02 -0800 (PST)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:203:4a73:e1bd:9b3f:4903])\n\tby smtp.gmail.com with ESMTPSA id\n\tk3sm7550163pff.211.2021.11.09.19.16.59\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 09 Nov 2021 19:17:00 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"KSidUDw6\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=oy7jE/IlKj7PzVfnuxUOddepDqkTfQ/0J9TOVft3tQU=;\n\tb=KSidUDw6jmNxrw0miur1Y8OUeFCD5oqxEy9iZKxywPselfeUpGHf8GvI9GKLsao8Vr\n\t2hy74yG/DadA6K4HdLASKYW7G8y56PFai7rA51mdq2xPmqx6stxfygjxhbQdCtOexZDl\n\tBs0gZ3jgMH8lVZSLa0Incpp6ssv/fA0O4uT6E=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\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=oy7jE/IlKj7PzVfnuxUOddepDqkTfQ/0J9TOVft3tQU=;\n\tb=mLJmzTa38TwcWlqgWqnWbzNfygUWrmBDaZmpN9SuevciRhdxavN1mCvk3k4oEepr3N\n\tOTwgefpQ8OgVVKHzDyDJCJtk/VkZJgPkZezsNM3pvUcVjFMSuKr2audrKqy591nlRzH8\n\tT9d9LLpPOrgNze2eDFq4OSoE4rXWlSAmKzbwmVoxL6h8zNmi7niX2Y0DPXcwdvI4miFz\n\tEV2XYsnVU5TNC6BgcGCcfeTjJnnnBDyst987N59XeZx0zOh4bJkyz3dLdfxzynbXlurI\n\tgB0JUvpCk+VIViS8uJOEY7u2DuXBqRYNZpWs/EX3YxNqwKGvpEM/bsltYaJDn2LL/4C6\n\tRMtQ==","X-Gm-Message-State":"AOAM531U8Irwk7edIQBzxhHO7XCUtVRBhftzkaUI8P+Zq9J125GCsSE7\n\tg/oYGt2PKN8+tml3nELZC5PmkSKVKTHR0w==","X-Google-Smtp-Source":"ABdhPJyVDBj+dqrZMIliAYti0rgV90U53hnDNi+fWklUyqHckCznCfzDUG0DMX8OG08xkxa5bcyxrg==","X-Received":"by 2002:a63:8b41:: with SMTP id\n\tj62mr9782680pge.420.1636514221037; \n\tTue, 09 Nov 2021 19:17:01 -0800 (PST)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 10 Nov 2021 12:16:51 +0900","Message-Id":"<20211110031651.2808099-3-hiroh@chromium.org>","X-Mailer":"git-send-email 2.34.0.rc0.344.g81b53c2807-goog","In-Reply-To":"<20211110031651.2808099-1-hiroh@chromium.org>","References":"<20211110031651.2808099-1-hiroh@chromium.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 3/3] libcamera: pipeline: ipu3: Apply\n\tthe requested test pattern mode","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"This enables ipu3 pipeline handler to apply the test pattern mode\nper frame.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n---\n include/libcamera/internal/camera_sensor.h |  1 +\n src/libcamera/camera_sensor.cpp            | 34 ++++++++++++++++++++++\n src/libcamera/pipeline/ipu3/ipu3.cpp       | 29 ++++++++++++++++--\n 3 files changed, 62 insertions(+), 2 deletions(-)","diff":"diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\nindex 60ce0c45..ed782476 100644\n--- a/include/libcamera/internal/camera_sensor.h\n+++ b/include/libcamera/internal/camera_sensor.h\n@@ -58,6 +58,7 @@ public:\n \tconst ControlInfoMap &controls() const;\n \tControlList getControls(const std::vector<uint32_t> &ids);\n \tint setControls(ControlList *ctrls);\n+\tint applyRequestControls(Request *request);\n \n \tV4L2Subdevice *device() { return subdev_.get(); }\n \ndiff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\nindex 35925a95..db13d9ea 100644\n--- a/src/libcamera/camera_sensor.cpp\n+++ b/src/libcamera/camera_sensor.cpp\n@@ -755,6 +755,40 @@ int CameraSensor::setControls(ControlList *ctrls)\n \treturn subdev_->setControls(ctrls);\n }\n \n+/**\n+ * \\brief Apply controls associated with Request\n+ * \\param[in] request Request that may contain contorls to be applied\n+ *\n+ * Some controls have to be applied for a capture associated with Request.\n+ * This picks up such controls and set the driver them.\n+ *\n+ * \\return 0 on success or an error code otherwise\n+ */\n+int32_t CameraSensor::applyRequestControls(Request *request)\n+{\n+\t/* Assumes applying the test pattern mode affects immediately. */\n+\tif (request->controls().contains(controls::draft::TestPatternMode)) {\n+\t\tconst int32_t testPatternMode = request->controls().get(\n+\t\t\tcontrols::draft::TestPatternMode);\n+\n+\t\tLOG(CameraSensor, Debug) << \"Apply test pattern mode: \"\n+\t\t\t\t\t << testPatternMode;\n+\n+\t\tint ret = setTestPatternMode(\n+\t\t\tstatic_cast<controls::draft::TestPatternModeEnum>(testPatternMode));\n+\t\tif (ret) {\n+\t\t\tLOG(CameraSensor, Error)\n+\t\t\t\t<< \"Failed to set test pattern mode: \" << ret;\n+\t\t\treturn ret;\n+\t\t}\n+\n+\t\trequest->metadata().set(controls::draft::TestPatternMode,\n+\t\t\t\t\ttestPatternMode);\n+\t}\n+\n+\treturn 0;\n+}\n+\n /**\n  * \\fn CameraSensor::device()\n  * \\brief Retrieve the camera sensor device\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 63cb7f11..dd662ff1 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -59,6 +59,7 @@ public:\n \tvoid statBufferReady(FrameBuffer *buffer);\n \tvoid queuePendingRequests();\n \tvoid cancelPendingRequests();\n+\tvoid frameStart(uint32_t sequence);\n \n \tCIO2Device cio2_;\n \tImgUDevice *imgu_;\n@@ -77,7 +78,10 @@ public:\n \n \tstd::unique_ptr<ipa::ipu3::IPAProxyIPU3> ipa_;\n \n+\t/* Requests before queueing cio2 device. */\n \tstd::queue<Request *> pendingRequests_;\n+\t/* Requests queued in cio2 device and before passing imgu device. */\n+\tstd::queue<Request *> processingRequests_;\n \n \tControlInfoMap ipaControls_;\n \n@@ -802,6 +806,7 @@ void PipelineHandlerIPU3::stop(Camera *camera)\n \n \tret |= data->imgu_->stop();\n \tret |= data->cio2_.stop();\n+\n \tif (ret)\n \t\tLOG(IPU3, Warning) << \"Failed to stop camera \" << camera->id();\n \n@@ -822,6 +827,8 @@ void IPU3CameraData::cancelPendingRequests()\n \t\tpipe()->completeRequest(request);\n \t\tpendingRequests_.pop();\n \t}\n+\n+\tdata->processingRequests_ = {};\n }\n \n void IPU3CameraData::queuePendingRequests()\n@@ -852,6 +859,8 @@ void IPU3CameraData::queuePendingRequests()\n \n \t\tinfo->rawBuffer = rawBuffer;\n \n+\t\tprocessingRequests_.push(request);\n+\n \t\tipa::ipu3::IPU3Event ev;\n \t\tev.op = ipa::ipu3::EventProcessControls;\n \t\tev.frame = info->id;\n@@ -1131,8 +1140,8 @@ int PipelineHandlerIPU3::registerCameras()\n \t\tdata->delayedCtrls_ =\n \t\t\tstd::make_unique<DelayedControls>(cio2->sensor()->device(),\n \t\t\t\t\t\t\t  params);\n-\t\tdata->cio2_.frameStart().connect(data->delayedCtrls_.get(),\n-\t\t\t\t\t\t &DelayedControls::applyControls);\n+\t\tdata->cio2_.frameStart().connect(data.get(),\n+\t\t\t\t\t\t &IPU3CameraData::frameStart);\n \n \t\t/* Convert the sensor rotation to a transformation */\n \t\tint32_t rotation = 0;\n@@ -1423,6 +1432,22 @@ void IPU3CameraData::statBufferReady(FrameBuffer *buffer)\n \tipa_->processEvent(ev);\n }\n \n+void IPU3CameraData::frameStart(uint32_t sequence)\n+{\n+\tif (!processingRequests_.empty()) {\n+\t\t/* Handle controls which are to be set ready for the next frame to start. */\n+\t\tRequest *request = processingRequests_.front();\n+\t\tprocessingRequests_.pop();\n+\n+\t\tint ret = cio2_.sensor()->applyRequestControls(request);\n+\t\tif (ret)\n+\t\t\tLOG(IPU3, Error) << \"Failed applying controls: \" << ret;\n+\t}\n+\n+\t/* Controls that don't affect immediately are applied in delayedCtrls. */\n+\tdelayedCtrls_->applyControls(sequence);\n+}\n+\n REGISTER_PIPELINE_HANDLER(PipelineHandlerIPU3)\n \n } /* namespace libcamera */\n","prefixes":["libcamera-devel","v5","3/3"]}