From patchwork Tue Dec 2 13:31:48 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: 25303 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 9756CC32F3 for ; Tue, 2 Dec 2025 13:32:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 152F760D1F; Tue, 2 Dec 2025 14:32:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gBKbwXrs"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 67E3360D1F for ; Tue, 2 Dec 2025 14:32:21 +0100 (CET) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-42b3c5defb2so3807469f8f.2 for ; Tue, 02 Dec 2025 05:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764682341; x=1765287141; 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=Tg/LFmOYwGkiUiyeOgsMC6wUGyRuydBpKVxRE0sdxus=; b=gBKbwXrsD8IQb/0mgoFC8m0tdIhPUM/0Iwy4K0UYsMf8L+gf64zwksIocgy2ibyDVe 9gRuWjBsfXb9ubolbTxfX+KYWOhmh+J8usFfbKN+ZkEmLnEdBly2TtQDfPybPpsZl4Qg p5Mr3PQtjfU8NGEZoNYICB+AZbe+itmlvsf+5IGBZd3JlfsRNjLgDE9ytEJMlDwdPE3V elnZmcwoFdhR+LWLdk6Yl7HprJ4yunnr86HVYESnx+TZDv9y+QD/N79GIWuU8WZwgNI4 TA20mhKINWW40PeoURP5NO6+TFi/z4GgEI/YfDaYx/Wk7doVX+vUSXPCvmvP0r59fgzV Q6vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764682341; x=1765287141; 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=Tg/LFmOYwGkiUiyeOgsMC6wUGyRuydBpKVxRE0sdxus=; b=h+RgsCMpy32gUP3w5opy9LB1FAAZo4iMF6/yqVzJENlleyBKZt4SxPSa9OZgoAuTxp AjSQeD53Lui4Fjiociod1oVJh1dXEnAP6mhlQ8nzDWSS9Nz+pGno36JdMGGWk/GwrQcb q2hkCC//epWB1WFC95xxkY2b/rMlKsHq4ODGybRtYFR0uwLUFvr+B4noLLB4xF0EBwUw rgX/qhwCj/nlnN2IGjCuIHSTIfnBKR2suhkZtBh8jZ1DbxIsNwzco5qoJdfTdsssAY0T vjWozc4J2zT0tyYBPfFKYPFf0AX8zkdLTr6cusIDLm2dVxJgZ0UoXP6IY+k2c360JKxR qjsg== X-Gm-Message-State: AOJu0Ywxj6/KFC3f73C+uTGqLHJQcBenKLdiw2UsQiCW0/qRvofAc1a4 LvFvOtSWCvo6dtrRpDBV2Q2XtDDK1ouXbN/9wa8fQmWTYZrusOXOGkMVN506eRt4ChyONXVlFG6 w6Da3 X-Gm-Gg: ASbGncuVXOuHvLbVOQI9CAEX3KXB0o6hByOgWAJPymFZpLMNFDhSh3TEUulDffsEc0j 6WeGInBD1YUroW8sK0r8jN524XSHgpyAFFOE0T8ExJ0B502sLmEhg0oNOp4jqtuD7U2u9euTyjW ARxvW5GiLwap+SgDHoSFeN15CUnXHSOrQ11cqqHk0+f+t9nmhmzTbntJO3cAf0dHAigDoLoaRFC z2ktTRJTMGcah/Iez08v19i2PSqUlmHpNmGJaP5uk/9IWxwwdjWyZG+Be713tH3yHq1SqvmGb9n QPWmmnuQiV6y+i+MGhNcTFLMNMQAkU0Y4YX2DIzZNg90bhSgw0PCbJtPoL+hnVyKwZ79QfxKGhk VjLVPLyn4DT+L6S3dJSt3CbPBlL+mjKsxeQ5q77t76WI+MGUcm3U6KemWz6jhxzKyuTpFp8zJAA t1CTkS4clxD2A2LxBh/ol/YWmMWZ/g1cGJLtFTD+tkrgGyltLnbtmyQzReHeFPJBxexR7wOSD2U qgdbQ== X-Google-Smtp-Source: AGHT+IEqPPe24H6F2MIPekC3VJHco0AMtEVv7uhuBtKIb8y4S4Eqm0Mkr3gYeX9DIP4TmfN3Sf/MEA== X-Received: by 2002:a05:6000:4022:b0:42b:3746:3b85 with SMTP id ffacd0b85a97d-42cc1d198c0mr42444785f8f.45.1764682340571; Tue, 02 Dec 2025 05:32:20 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42e1c5c30c4sm33363322f8f.9.2025.12.02.05.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Dec 2025 05:32:20 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal , Kieran Bingham Subject: [PATCH v3 17/22] libcamera: software_isp: debayer: Introduce a stop() callback to the debayer object Date: Tue, 2 Dec 2025 13:31:48 +0000 Message-ID: <20251202133157.661407-18-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251202133157.661407-1-bryan.odonoghue@linaro.org> References: <20251202133157.661407-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" The eGL class wants to be able to teardown its sync_ data member properly but, doing so in the destructor means we can't make the eGL context current and thus can't tear down the sync primitive properly. Introduce a stop() method to the debayer class which triggers from the softisp's stop method, allowing a controlled and appropriate tear-down of debayer-egl and egl class related data well before the destructors get invoked. Reviewed-by: Milan Zamazal [bod: Made method blocking not queued per Robert's bugfixes] Reviewed-by: Kieran Bingham Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.cpp | 9 +++++++++ src/libcamera/software_isp/debayer.h | 1 + src/libcamera/software_isp/software_isp.cpp | 4 +++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 1d135b278..dae1f12d9 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -336,6 +336,15 @@ Debayer::~Debayer() * debayer processing. */ +/** + * \fn void Debayer::stop() + * \brief Stop the debayering process and perform cleanup + * + * In the DebayerCPU case this is an empty stub function but + * for the GPU case this does something useful. The stub here is to + * ensure the right version of the virtual gets called. + */ + /** * \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..30bad9651 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -48,6 +48,7 @@ public: strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0; virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 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 4f6792122..c0ff91cc4 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -367,9 +367,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);