{"id":22867,"url":"https://patchwork.libcamera.org/api/1.1/patches/22867/?format=json","web_url":"https://patchwork.libcamera.org/patch/22867/","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":"<20250225164116.414301-4-stanislaw.gruszka@linux.intel.com>","date":"2025-02-25T16:41:14","name":"[v5,3/5] pipeline: simple: Connect and disconnect start frame events","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"c38dcc152ff8c16c01cbb3132931fc840e321816","submitter":{"id":211,"url":"https://patchwork.libcamera.org/api/1.1/people/211/?format=json","name":"Stanislaw Gruszka","email":"stanislaw.gruszka@linux.intel.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/22867/mbox/","series":[{"id":5021,"url":"https://patchwork.libcamera.org/api/1.1/series/5021/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5021","date":"2025-02-25T16:41:11","name":"libcamera: start frame events changes","version":5,"mbox":"https://patchwork.libcamera.org/series/5021/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/22867/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/22867/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 D48EBBDB1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 Feb 2025 16:41:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 92F3D6872D;\n\tTue, 25 Feb 2025 17:41:48 +0100 (CET)","from mgamail.intel.com (mgamail.intel.com [192.198.163.11])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 567D06871F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 Feb 2025 17:41:46 +0100 (CET)","from orviesa006.jf.intel.com ([10.64.159.146])\n\tby fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;\n\t25 Feb 2025 08:41:45 -0800","from sgruszka-mobl.ger.corp.intel.com (HELO localhost)\n\t([10.245.115.185]) by orviesa006-auth.jf.intel.com with\n\tESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Feb 2025 08:41:42 -0800"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=intel.com header.i=@intel.com\n\theader.b=\"ClkalRXy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple;\n\td=intel.com; i=@intel.com; q=dns/txt; s=Intel;\n\tt=1740501707; x=1772037707;\n\th=from:to:cc:subject:date:message-id:in-reply-to:\n\treferences:mime-version:content-transfer-encoding;\n\tbh=nS0he6M5+OnKyzidaXn9nLdjZWwtir6ALzW2zaXi0yQ=;\n\tb=ClkalRXyLENlLRliCsQrnXNc7YbLU9ClxG4fOHFTxtaEP6Q46aJBLW/B\n\tZ4LIWmbK+kLx9geuLab4QBuVJysKHeyvZDN0X0XmTwIViAHjjmYW4U7vd\n\ttmEqo9LTgkS400YS1u5OiC9hmwfSvF0BLLH98D83ufbJ6oa3Jjf5oig/X\n\tewCGxCaOwZSNJQ1TDqHiBeJ3Li9EEtD9K47QB3VmPFgBcjIJYghMSj+3t\n\txzcB71vxGBoodYtYOtLole5wBgyQAVpTUA436S1SaSOWYwWyESyHs3eto\n\tCZMoOrHROfDZzKNGFbocnj84HZYgZtRgm8kO9iFYu+u/KpMUHNB4rpB72 Q==;","X-CSE-ConnectionGUID":["gdOkO2jQTjKTK138JBipjw==","sp+c/Qg9SVWuZM571qW0Xg=="],"X-CSE-MsgGUID":["cl6RS+4URfGegkRfR2ZNHA==","UtSGXvnRQkSvuO6USAR7Bw=="],"X-IronPort-AV":["E=McAfee;i=\"6700,10204,11356\"; a=\"51948277\"","E=Sophos;i=\"6.13,314,1732608000\"; d=\"scan'208\";a=\"51948277\"","E=Sophos;i=\"6.13,314,1732608000\"; d=\"scan'208\";a=\"116426747\""],"X-ExtLoop1":"1","From":"Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tNaushir Patuck <naush@raspberrypi.com>,\n\tSakari Ailus <sakari.ailus@linux.intel.com>,\n\tHans de Goede <hdegoede@redhat.com>","Subject":"[PATCH v5 3/5] pipeline: simple: Connect and disconnect start frame\n\tevents","Date":"Tue, 25 Feb 2025 17:41:14 +0100","Message-Id":"<20250225164116.414301-4-stanislaw.gruszka@linux.intel.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20250225164116.414301-1-stanislaw.gruszka@linux.intel.com>","References":"<20250225164116.414301-1-stanislaw.gruszka@linux.intel.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","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":"Enable frame events on the emitter device during\nSimplePipelineHandler::start(), move signal connection there\nfrom SimplePipelineHandler::configure().\n\nAlso reset delayed controls on start() to prevent using\nstale values.\n\nAccordingly disable/disconnect on SimplePipelineHandler::stopDevice().\n\nThis fixes the assertion like below:\n\n../src/libcamera/delayed_controls.cpp:227:\nlibcamera::ControlList libcamera::DelayedControls::get(uint32_t):\nAssertion `info.type() != ControlTypeNone' failed\n\nwhich can happen rarely at the beginning of streaming when\nControlRingBuffer is not yet filled and there are errors on CSI-2.\nIn such rare scenario we can have call to DelayedControls::get()\nwith frame number that exceed number of saved entries. Handing\nframe start signal assure we do DelayedConntrols::applyControls()\nwith (possibly out of sequence) frame number and later call\nto DelayedControls::get() will get proper not-empty control entry.\n\nBug: https://bugs.libcamera.org/show_bug.cgi?id=241\nCo-developed-by: Hans de Goede <hdegoede@redhat.com>\nSigned-off-by: Hans de Goede <hdegoede@redhat.com>\nSigned-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 23 +++++++++++++++++++----\n 1 file changed, 19 insertions(+), 4 deletions(-)\n\n--\n2.43.0","diff":"diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex 063a098f..774c7824 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -1229,7 +1229,6 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \t\tstatic_cast<SimpleCameraConfiguration *>(c);\n \tSimpleCameraData *data = cameraData(camera);\n \tV4L2VideoDevice *video = data->video_;\n-\tV4L2Subdevice *frameStartEmitter = data->frameStartEmitter_;\n \tint ret;\n\n \t/*\n@@ -1300,9 +1299,6 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \tdata->delayedCtrls_ =\n \t\tstd::make_unique<DelayedControls>(data->sensor_->device(),\n \t\t\t\t\t\t  params);\n-\tif (frameStartEmitter)\n-\t\tframeStartEmitter->frameStart.connect(data->delayedCtrls_.get(),\n-\t\t\t\t\t\t      &DelayedControls::applyControls);\n\n \tStreamConfiguration inputCfg;\n \tinputCfg.pixelFormat = pipeConfig->captureFormat;\n@@ -1341,6 +1337,7 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL\n {\n \tSimpleCameraData *data = cameraData(camera);\n \tV4L2VideoDevice *video = data->video_;\n+\tV4L2Subdevice *frameStartEmitter = data->frameStartEmitter_;\n \tint ret;\n\n \tconst MediaPad *pad = acquirePipeline(data);\n@@ -1370,6 +1367,17 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL\n\n \tvideo->bufferReady.connect(data, &SimpleCameraData::imageBufferReady);\n\n+\tdata->delayedCtrls_->reset();\n+\tif (frameStartEmitter) {\n+\t\tret = frameStartEmitter->setFrameStartEnabled(true);\n+\t\tif (ret) {\n+\t\t\tstop(camera);\n+\t\t\treturn ret;\n+\t\t}\n+\t\tframeStartEmitter->frameStart.connect(data->delayedCtrls_.get(),\n+\t\t\t\t\t\t      &DelayedControls::applyControls);\n+\t}\n+\n \tret = video->streamOn();\n \tif (ret < 0) {\n \t\tstop(camera);\n@@ -1401,6 +1409,13 @@ void SimplePipelineHandler::stopDevice(Camera *camera)\n {\n \tSimpleCameraData *data = cameraData(camera);\n \tV4L2VideoDevice *video = data->video_;\n+\tV4L2Subdevice *frameStartEmitter = data->frameStartEmitter_;\n+\n+\tif (frameStartEmitter) {\n+\t\tframeStartEmitter->setFrameStartEnabled(false);\n+\t\tframeStartEmitter->frameStart.disconnect(data->delayedCtrls_.get(),\n+\t\t\t\t\t\t\t &DelayedControls::applyControls);\n+\t}\n\n \tif (data->useConversion_) {\n \t\tif (data->converter_)\n","prefixes":["v5","3/5"]}