From patchwork Thu Dec 11 23:22:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25509 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 956B8C3257 for ; Thu, 11 Dec 2025 23:24:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 49B9A61666; Fri, 12 Dec 2025 00:24:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="lIk0WZjy"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B7B9C61667 for ; Fri, 12 Dec 2025 00:24:01 +0100 (CET) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-7f0da2dfeaeso633955b3a.1 for ; Thu, 11 Dec 2025 15:24:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495440; x=1766100240; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=O+dY2RuVzMDdp5pZPZTVyABA7WROMIfBWzHUoeyG3aU=; b=lIk0WZjyapKIj5qeQ4OuP2astua+hdy/0THniCT11Ml5uMJBEnkrQnv8SMIaYz52F1 JMGBPbav4JTJZUABzRZl26zZZ57M/2Kvn2GKMRdW1EaV8nt3pO2hlexE6K51kcyTQkYb Sco4TQFVHQl3COfLIBRx+GsEL4WDPK/RX/G55eljBqNGlRQ/Rga/4R4eaV/mzxV6x2uK O7h9RcuC1VqNoRG/+sqKnyQhhZ52jOZes2SMJaqCR++sq3D3Gyze8qnyZYVu4QZZAcKt nx+lYr0wyz/nghMGPs9+b++c4WGCZKhbCh0poQupyaCajjF/epiZ3ekp/OOCSJu3fdki jh9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495440; x=1766100240; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=O+dY2RuVzMDdp5pZPZTVyABA7WROMIfBWzHUoeyG3aU=; b=v6qRfVy/KQoSQIWeD/wn28VJabosdyr+KkvH2PuuO5TeR5T3+Ar1ozqD6Fu30rmqnc ATPYm8gEKdbB8qo+D8uvNVPT7E3lY1aVdEnPUEdlyyhOSobGkhAXijwWb1RWy++Ag3qK 9vTc2ohGGlUXappbaMiUYyYgsIssKbXdSeMJLc86gBHbtmjSrpU/hEUxOONxZu0jNil6 n2k0O88Z2+6gRVZbvm2o44ITL7ck7G6+f0ccGLny/tiIM8fZXUsFUPi8gJVlJZYOhMZY I89JGmRgy2J4mzNiz0WjO+iv3H+Jx6IT9KzPg3cXfYESnWPp/2d8KEBBcTB03ZSDZsAg CFzw== X-Gm-Message-State: AOJu0Ywp7hbJ1HGjUauWdVugJb6NNChdoXgzwAsompqHnnj6pLklEYcY 6e9LI2/FSrnLWpLASMTD3i5xrZ16wlkJ7F1B7w2U96KJNs+Os2vHvMnfAivbSlKOqLxzc2I+p3g iEIXC X-Gm-Gg: AY/fxX5+LLvpfLxEp4BfSOYowtg9JcjZ/UZsI9qclCtugfC71Bpf6XXEsug8FmNhadd RgaDyswTYREG//FgotlLo19mKoegtB16JvpySvWC2/w8sqHtxM/gKzNbzchGDdPMyVk/odcEcEu c932vfUy1iU5160a5RW8Sg0Bxt1H0D9p7SQZfh0jfRJe1OIY9cjD+Xo6Q4E9nbiIvIbrhm24FRr tcbLZ+TE1yNnYhXV9gwiPYNHfRTBvRfGzhvLdvLVBk7gLcH+Hd/uZjHMtZ/CLSaEQ8DQw3BUflW c7u3qU5tkOjKTH6/0YMt/Uv9q+ddM4oCnO0C8beqk/1HPGzzh68e38LStME1rPZ8NWLPd/rNbbq af4sRbBnXw6EqTPdomLf8Zuq0naMCIKBS8TPlvczYD6OdpYzRnY8gkuyyUxIuAQV5Dnv2XQohRA ssAmV0J8ku4ZSumFZgsLqmDdJVwZJSVT0HwigrF3f2/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 d2e1a72fcca58-7f66969f9f4mr182935b3a.51.1765495440069; Thu, 11 Dec 2025 15:24:00 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:59 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v5 15/20] libcamera: software_isp: debayer: Introduce a start() / 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 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In order to initialise and deinitialise gpuisp we need to be able to setup EGL in the same thread as Debayer::process() happens in. This requires extending the Debayer object to provide start and stop methods which are triggered through invokeMethod in the same way as process() is. Introduce start() and stop() methods to the Debayer class. Trigger those methods as described above via invokeMethod. The debayer_egl class will take care of initialising and de-initialising as necessary. Debayer CPU sees no functional change. Per feedback from Barnabas the stop method using blocking synchronisation and thus we drop ispWorkerThread_.removeMessages(). [bod: Made method blocking not queued per Robert's bugfixes] Signed-off-by: Bryan O'Donoghue Reviewed-by: Milan Zamazal --- src/libcamera/software_isp/debayer.cpp | 25 +++++++++++++++++++++ src/libcamera/software_isp/debayer.h | 2 ++ src/libcamera/software_isp/software_isp.cpp | 8 +++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 1d135b278..8b4b6cd74 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -336,6 +336,31 @@ Debayer::~Debayer() * debayer processing. */ +/** + * \fn int Debayer::start() + * \brief Execute a start signal in the debayer object from workerthread context. + * + * The start() method is invoked so that a Debayer object can initialise + * internal variables or data. It is called from the software_isp::start + * method. + * + * This method is particularly useful with DebayerEGL as it allows for the + * initialisation of the EGL stack after configure in a thread-safe manner. + */ + +/** + * \fn void Debayer::stop() + * \brief Stop the debayering process and perform cleanup + * + * The stop() method is invoked as the logically corollary of start(). + * Debayer::stop() will be called by software_isp::stop() allowing for any + * cleanup which should happend with stop(). + * + * The stop method similar to start() is useful for DebayerEGL as it allows + * for cleanup of EGL context and/or data that happens in + * DebayerEGL::start. + */ + /** * \fn void Debayer::setParams(DebayerParams ¶ms) * \brief Select the bayer params to use for the next frame debayer diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index ff4a92c15..5c0cb3914 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -48,6 +48,8 @@ public: strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0; virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0; + virtual int start() { return 0; } + virtual void stop() { } virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 928a2520c..7c9ad9160 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -347,7 +347,9 @@ int SoftwareIsp::start() return ret; ispWorkerThread_.start(); - return 0; + + return debayer_->invokeMethod(&DebayerCpu::start, + ConnectionTypeBlocking); } /** @@ -358,9 +360,11 @@ int SoftwareIsp::start() */ void SoftwareIsp::stop() { + debayer_->invokeMethod(&DebayerCpu::stop, + ConnectionTypeBlocking); + ispWorkerThread_.exit(); ispWorkerThread_.wait(); - ispWorkerThread_.removeMessages(debayer_.get()); Thread::current()->dispatchMessages(Message::Type::InvokeMessage, this);