From patchwork Thu Nov 27 02:22:49 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: 25231 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 1CD9DC3260 for ; Thu, 27 Nov 2025 02:23:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C2CA860B2F; Thu, 27 Nov 2025 03:23:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="GBhld6OY"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D08D60AC5 for ; Thu, 27 Nov 2025 03:23:42 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-477632d9326so1652895e9.1 for ; Wed, 26 Nov 2025 18:23:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210221; x=1764815021; 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=B9KW+pVIFbG1cr3wsRdFTzVVgHUhwNDNjNTuP9XwgZ8=; b=GBhld6OYadgyjT7lAmatR9mU4+V+KEpiCDu7M7IlAN+2N7Ueu5x8Sg/obO5hzz1V5k IvIGBKwLgQbGeyArkTR6Ce+17eiKCTLXtGzjeuE/VyW0crnPvz3Vxsu5FLcC8bgTw/u+ 9S6wLBiAOi/2yVqZLeveveEtCfAZp9MJm3n2tN6YyMsjPQim8K3kJfoDLuCzstbRKo+Y jwMA4C4ZoAanbE9hIly3UtGd41lTTx8JHdiij1jtnVHhNOPezaC1g5JOngr5/VT++TFS 93OPdwxvnwfwLnx1rn7I0ayNfPtXZMMuNWT6BRZuU1KOuDcJba3fPPVoK4YVHBWouHsa 75WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210221; x=1764815021; 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=B9KW+pVIFbG1cr3wsRdFTzVVgHUhwNDNjNTuP9XwgZ8=; b=KmvAbUet9ANqKJULrOQO0dqe537c7PE/2RDEk3WLbmBtnXMY2p5RPVPxgush2BeJF7 A7CC+k+l0ac9Snl3gGWcHihv37SLaOP43xBpYcpo+ZNqDwO7Z1pfs5HaSvdm3/sO8FIk lSgaK5xab60kL0HSSFnNGS4orT8BRQGJLvHJyIAvglWuH6zjL1wis5s/iCgM0NAul25P mJmy/LmInKdI9vnzd1mrEvSwKzMSYc2lywvvW6gk0YciPj4SXrjwHmgZ/49ImPKAQVvN 8/hXt7Q7E4q+WmCsll01xUgG5WKW2xZ0zEEjm5qCoj/AiNa2ufBe+GO9G7JI0DFpjvrE sPqg== X-Gm-Message-State: AOJu0YxDJAbDPRiiQmg8rmvg46WalCdi1qQp0MPF/49XyfnMga/4M+3K ccvI1fKqHnHiWv0gRWyuIgWR132CFDqsfJBitwjKGRtDpHtiYblwoamy+FAa8pr/X7w4UmQmTF7 4yXuszi0= X-Gm-Gg: ASbGncsuWVLcSLcnvBlTzoQf+F956uwygP0LnUhYDYN7tyJEJ13ylOpo0SnO+eMNMz+ /9qjBPDD8d7xfVi1gTT/sFNhUdGU+DEaiD1tOLl6B9SlopRIkIWcy1l+KflMV6usaKlcLZKzCE8 gMn9myphuG8mFqUkPrESCKgO5yLNn6g0Zd2/MJLguXeAUoMuAXaygIb1HPSMdkqDFCIglSKZsUh 901Ey7gx9ME1zqvqB2XrM/qspEiLMWUpa5nV4WP+riA69Pt3Ej0OpA52cGR+0HCrsyFBQItT6Du STmyrCeblqpXo7ibKdrQT6HiYK0NYWesSumBjkx3aTdMynASiAMUgPetljqfYge45wMPy3D0HDx R7del69k06th8KEIXJc6oip8ZbJteTe18ikrvK7OQXia/auKQM3Zo1RZv3Th3Ob1tN2YMJZ6b1a kqNYX/ZVYDH0haVNEdMiGSK7v9o986zE3dk0icd4Hq5epiaHrBtynmRPOZcDaU1fV5ElE= X-Google-Smtp-Source: AGHT+IFluLnn0M1BNwxleHGMBuC7MZO/4YoU/9raAp8G+PvU9fziFn7xpy/Di0FoxYq7tfXORjK0Xw== X-Received: by 2002:a05:600c:4e88:b0:46e:7247:cbc0 with SMTP id 5b1f17b1804b1-477c01d4af2mr218994195e9.18.1764210221492; Wed, 26 Nov 2025 18:23:41 -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 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:41 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal Subject: [PATCH v2 17/22] libcamera: software_isp: debayer: Introduce a stop() callback to the debayer object Date: Thu, 27 Nov 2025 02:22:49 +0000 Message-ID: <20251127022256.178929-18-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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] Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- src/libcamera/software_isp/debayer.h | 1 + src/libcamera/software_isp/debayer_cpu.cpp | 10 ++++++++++ src/libcamera/software_isp/debayer_cpu.h | 1 + src/libcamera/software_isp/software_isp.cpp | 3 +++ 4 files changed, 15 insertions(+) diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 451c1c9ac..088b062c0 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() = 0; virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0; diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 00738c56b..28fb8ca50 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -788,6 +788,16 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output inputBufferReady.emit(input); } +/** + * \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. + */ +void DebayerCpu::stop() {} + SizeRange DebayerCpu::sizes(PixelFormat inputFormat, const Size &inputSize) { Size patternSize = this->patternSize(inputFormat); diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index ecc4f9dd0..2d385cf01 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -38,6 +38,7 @@ public: std::tuple strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params); + void stop(); SizeRange sizes(PixelFormat inputFormat, const Size &inputSize); const SharedFD &getStatsFD() { return stats_->getStatsFD(); } diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 4c232339b..aa4a40cb6 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -367,6 +367,9 @@ int SoftwareIsp::start() */ void SoftwareIsp::stop() { + debayer_->invokeMethod(&Debayer::stop, + ConnectionTypeBlocking); + ispWorkerThread_.exit(); ispWorkerThread_.wait(); ispWorkerThread_.removeMessages(debayer_.get());