{"id":25509,"url":"https://patchwork.libcamera.org/api/1.1/patches/25509/?format=json","web_url":"https://patchwork.libcamera.org/patch/25509/","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":"<20251211232246.31330-16-bryan.odonoghue@linaro.org>","date":"2025-12-11T23:22:40","name":"[v5,15/20] libcamera: software_isp: debayer: Introduce a start() / stop() methods to the debayer object","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"997a9771e59bab357210a669d8169e078a40d95f","submitter":{"id":175,"url":"https://patchwork.libcamera.org/api/1.1/people/175/?format=json","name":"Bryan O'Donoghue","email":"bryan.odonoghue@linaro.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/25509/mbox/","series":[{"id":5656,"url":"https://patchwork.libcamera.org/api/1.1/series/5656/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5656","date":"2025-12-11T23:22:25","name":"GPUISP precursor series","version":5,"mbox":"https://patchwork.libcamera.org/series/5656/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/25509/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/25509/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 956B8C3257\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 11 Dec 2025 23:24:04 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 49B9A61666;\n\tFri, 12 Dec 2025 00:24:04 +0100 (CET)","from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com\n\t[IPv6:2607:f8b0:4864:20::42c])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B7B9C61667\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Dec 2025 00:24:01 +0100 (CET)","by mail-pf1-x42c.google.com with SMTP id\n\td2e1a72fcca58-7f0da2dfeaeso633955b3a.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Dec 2025 15:24:01 -0800 (PST)","from inspiron14p-linux (M106185144161.v4.enabler.ne.jp.\n\t[106.185.144.161]) by smtp.gmail.com with ESMTPSA id\n\td2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.58\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 11 Dec 2025 15:23:59 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"lIk0WZjy\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=linaro.org; s=google; t=1765495440; x=1766100240;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=O+dY2RuVzMDdp5pZPZTVyABA7WROMIfBWzHUoeyG3aU=;\n\tb=lIk0WZjyapKIj5qeQ4OuP2astua+hdy/0THniCT11Ml5uMJBEnkrQnv8SMIaYz52F1\n\tJMGBPbav4JTJZUABzRZl26zZZ57M/2Kvn2GKMRdW1EaV8nt3pO2hlexE6K51kcyTQkYb\n\tSco4TQFVHQl3COfLIBRx+GsEL4WDPK/RX/G55eljBqNGlRQ/Rga/4R4eaV/mzxV6x2uK\n\tO7h9RcuC1VqNoRG/+sqKnyQhhZ52jOZes2SMJaqCR++sq3D3Gyze8qnyZYVu4QZZAcKt\n\tnx+lYr0wyz/nghMGPs9+b++c4WGCZKhbCh0poQupyaCajjF/epiZ3ekp/OOCSJu3fdki\n\tjh9g==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1765495440; x=1766100240;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=O+dY2RuVzMDdp5pZPZTVyABA7WROMIfBWzHUoeyG3aU=;\n\tb=v6qRfVy/KQoSQIWeD/wn28VJabosdyr+KkvH2PuuO5TeR5T3+Ar1ozqD6Fu30rmqnc\n\tATPYm8gEKdbB8qo+D8uvNVPT7E3lY1aVdEnPUEdlyyhOSobGkhAXijwWb1RWy++Ag3qK\n\t9vTc2ohGGlUXappbaMiUYyYgsIssKbXdSeMJLc86gBHbtmjSrpU/hEUxOONxZu0jNil6\n\tn2k0O88Z2+6gRVZbvm2o44ITL7ck7G6+f0ccGLny/tiIM8fZXUsFUPi8gJVlJZYOhMZY\n\tI89JGmRgy2J4mzNiz0WjO+iv3H+Jx6IT9KzPg3cXfYESnWPp/2d8KEBBcTB03ZSDZsAg\n\tCFzw==","X-Gm-Message-State":"AOJu0Ywp7hbJ1HGjUauWdVugJb6NNChdoXgzwAsompqHnnj6pLklEYcY\n\t6e9LI2/FSrnLWpLASMTD3i5xrZ16wlkJ7F1B7w2U96KJNs+Os2vHvMnfAivbSlKOqLxzc2I+p3g\n\tiEIXC","X-Gm-Gg":"AY/fxX5+LLvpfLxEp4BfSOYowtg9JcjZ/UZsI9qclCtugfC71Bpf6XXEsug8FmNhadd\n\tRgaDyswTYREG//FgotlLo19mKoegtB16JvpySvWC2/w8sqHtxM/gKzNbzchGDdPMyVk/odcEcEu\n\tc932vfUy1iU5160a5RW8Sg0Bxt1H0D9p7SQZfh0jfRJe1OIY9cjD+Xo6Q4E9nbiIvIbrhm24FRr\n\ttcbLZ+TE1yNnYhXV9gwiPYNHfRTBvRfGzhvLdvLVBk7gLcH+Hd/uZjHMtZ/CLSaEQ8DQw3BUflW\n\tc7u3qU5tkOjKTH6/0YMt/Uv9q+ddM4oCnO0C8beqk/1HPGzzh68e38LStME1rPZ8NWLPd/rNbbq\n\taf4sRbBnXw6EqTPdomLf8Zuq0naMCIKBS8TPlvczYD6OdpYzRnY8gkuyyUxIuAQV5Dnv2XQohRA\n\tssAmV0J8ku4ZSumFZgsLqmDdJVwZJSVT0HwigrF3f2/Te233zMa1+43MqpJ+QEoQ==","X-Google-Smtp-Source":"AGHT+IEc9ed/SU6SGbtCStX1wCyfnaKXg/3TdyRUVNJ8Hr6odvAyqhrjP1xek/YRdCG9tk8kMJnRoQ==","X-Received":"by 2002:a05:6a00:6c90:b0:7e8:43f5:bd1e with SMTP id\n\td2e1a72fcca58-7f66969f9f4mr182935b3a.51.1765495440069; \n\tThu, 11 Dec 2025 15:24:00 -0800 (PST)","From":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","To":"libcamera-devel@lists.libcamera.org","Cc":"pavel@ucw.cz,\n\tBryan O'Donoghue <bryan.odonoghue@linaro.org>","Subject":"[PATCH v5 15/20] libcamera: software_isp: debayer: Introduce a\n\tstart() / stop() methods to the debayer object","Date":"Thu, 11 Dec 2025 23:22:40 +0000","Message-ID":"<20251211232246.31330-16-bryan.odonoghue@linaro.org>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20251211232246.31330-1-bryan.odonoghue@linaro.org>","References":"<20251211232246.31330-1-bryan.odonoghue@linaro.org>","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":"In order to initialise and deinitialise gpuisp we need to be able to setup\nEGL in the same thread as Debayer::process() happens in.\n\nThis requires extending the Debayer object to provide start and stop\nmethods which are triggered through invokeMethod in the same way as\nprocess() is.\n\nIntroduce start() and stop() methods to the Debayer class. Trigger those\nmethods as described above via invokeMethod. The debayer_egl class will\ntake care of initialising and de-initialising as necessary. Debayer CPU\nsees no functional change.\n\nPer feedback from Barnabas the stop method using blocking synchronisation\nand thus we drop ispWorkerThread_.removeMessages().\n\n[bod: Made method blocking not queued per Robert's bugfixes]\nSigned-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n---\n src/libcamera/software_isp/debayer.cpp      | 25 +++++++++++++++++++++\n src/libcamera/software_isp/debayer.h        |  2 ++\n src/libcamera/software_isp/software_isp.cpp |  8 +++++--\n 3 files changed, 33 insertions(+), 2 deletions(-)","diff":"diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp\nindex 1d135b278..8b4b6cd74 100644\n--- a/src/libcamera/software_isp/debayer.cpp\n+++ b/src/libcamera/software_isp/debayer.cpp\n@@ -336,6 +336,31 @@ Debayer::~Debayer()\n  * debayer processing.\n  */\n \n+/**\n+ * \\fn int Debayer::start()\n+ * \\brief Execute a start signal in the debayer object from workerthread context.\n+ *\n+ * The start() method is invoked so that a Debayer object can initialise\n+ * internal variables or data. It is called from the software_isp::start\n+ * method.\n+ *\n+ * This method is particularly useful with DebayerEGL as it allows for the\n+ * initialisation of the EGL stack after configure in a thread-safe manner.\n+ */\n+\n+/**\n+ * \\fn void Debayer::stop()\n+ * \\brief Stop the debayering process and perform cleanup\n+ *\n+ * The stop() method is invoked as the logically corollary of start().\n+ * Debayer::stop() will be called by software_isp::stop() allowing for any\n+ * cleanup which should happend with stop().\n+ *\n+ * The stop method similar to start() is useful for DebayerEGL as it allows\n+ * for cleanup of EGL context and/or data that happens in\n+ * DebayerEGL::start.\n+ */\n+\n /**\n  * \\fn void Debayer::setParams(DebayerParams &params)\n  * \\brief Select the bayer params to use for the next frame debayer\ndiff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\nindex ff4a92c15..5c0cb3914 100644\n--- a/src/libcamera/software_isp/debayer.h\n+++ b/src/libcamera/software_isp/debayer.h\n@@ -48,6 +48,8 @@ public:\n \tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;\n \n \tvirtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0;\n+\tvirtual int start() { return 0; }\n+\tvirtual void stop() { }\n \n \tvirtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;\n \ndiff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\nindex 928a2520c..7c9ad9160 100644\n--- a/src/libcamera/software_isp/software_isp.cpp\n+++ b/src/libcamera/software_isp/software_isp.cpp\n@@ -347,7 +347,9 @@ int SoftwareIsp::start()\n \t\treturn ret;\n \n \tispWorkerThread_.start();\n-\treturn 0;\n+\n+\treturn debayer_->invokeMethod(&DebayerCpu::start,\n+\t\t\t\t      ConnectionTypeBlocking);\n }\n \n /**\n@@ -358,9 +360,11 @@ int SoftwareIsp::start()\n  */\n void SoftwareIsp::stop()\n {\n+\tdebayer_->invokeMethod(&DebayerCpu::stop,\n+\t\t\t       ConnectionTypeBlocking);\n+\n \tispWorkerThread_.exit();\n \tispWorkerThread_.wait();\n-\tispWorkerThread_.removeMessages(debayer_.get());\n \n \tThread::current()->dispatchMessages(Message::Type::InvokeMessage, this);\n \n","prefixes":["v5","15/20"]}