From patchwork Thu Nov 20 23:20:14 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: 25118 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 7B052C3330 for ; Thu, 20 Nov 2025 23:20:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2BFDF60B13; Fri, 21 Nov 2025 00:20:58 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="F+x8xakm"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 43C0960AAF for ; Fri, 21 Nov 2025 00:20:54 +0100 (CET) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4779cb0a33fso13968775e9.0 for ; Thu, 20 Nov 2025 15:20:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1763680853; x=1764285653; 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=ZFi6TZY5hIuZxehPR0Y+ao56s/Ou2XRORvnhhULoNLs=; b=F+x8xakmCqjGlPJTxxdBg7WUUCJ+f5I8LFMCVkb2DIlXkzUlRznMp6nAlqi9c6f3tl T54PBnPDKyTFaN1mm+Y0/JD8gUuLekqWIGhb8CC6KLh1Dhptsz3noDtBjqJBweZix2FR mBBKlFLsoYA3AW2iaFs34AP6CVYq6ACxtaqVHbHGj/Vw/tu89RiFKqjUkwFEQ+vHYNJB w+aj+u9mZSd24t3dlT127cuNsaNySehxTiCKJ0fRyv6Pb6WjRy7/rCgF2dPUNl9j36Sc was2RrEb/9nOsws76VnAIadpyk1rMqSsIwmDbCObgtVJEBC5xB3+EUY12kHyNI9Z9bej 9E/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763680853; x=1764285653; 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=ZFi6TZY5hIuZxehPR0Y+ao56s/Ou2XRORvnhhULoNLs=; b=dxhXo5yCgWyjgla6WetduoWhHyT9VV+xwdh7zKWFP4tGUMZZzL9776nYpi71TRbZ/u ikCiRAW2znBfG4lG7SuMEjmZCzf9jfmY1QJGR1yhFdc37KLrIrln1oKqi50Ry7fduFXU JK7U75gzm3i81XYQqG8bpqHvEtip63+aZWC3wU5ocZaU/FOiSgV9Q1mi+PBhMD/cTd64 CvBSe8GS6nhMBIun/GgeIgRoCtnU4xEzTXQB8QtgcuWGtqwzsZYSaz3/XCLhp5OdaRRy xd8Su0RuLBwOF5cfG4BdwasmVXCzOlMAG9oVsmTPFZCGKYXigrtWb6mD0ksNUKv6ix2F JlMA== X-Gm-Message-State: AOJu0YydrzbjLo1oB83QsjXU8YG651BE/Hq8oVsZ5gHnTLHFGYSLLzpY MQZI3PaqYH1XJuw08hy0tqvdXgtuAfGCEZ75FkavZfuOaYHTohsE+bXYVVpxGtD0c6QpG8pl2H8 VybWxrCU= X-Gm-Gg: ASbGncsQVIrfoVactc9e2qh8FF4XNRe4SHnI4H+5N8RcT67skHneHogIj9V4phq40A+ vRGTD8v/68NF4N1mayRjpdm5fEeNGeM9pu3ODMXjf2MJ2U9HNe6yt2oXLpchpVh6fMKFEX14LxE 17UQC7ZKi2l6c4avShnJ7OgUJ8HhidOTSsrhNy7zYz730v1KCGHQMJrIJkQssYDnWIDtTeFK8E9 fvUJwboX5Z3CgTdxrrRTfXki2XoF65kUpNW/UKpPh75HEMGZkRTMKFJFb5jE23vbaHeIR4dbp8s K+oPeKWfyMnBN0lTaJxLNyxY1qFFBtAs23medwVi+AF7alkcdoDZlwIxVlTbrhOwZFg8gTx3Eq3 rbn/RaGPXlSqR6NZv+L/s1F2BwPGKhT5s+8KComcSpxRBTXu06uKGfRcXYua3aV94huOYqurn7M P8rTle7yywF0qg5Gu+TKCX1xPJfLbb97M5WcE8jap1bBFspL6SJCrC4P/U74GuNnOagdY= X-Google-Smtp-Source: AGHT+IGFb7DLIoDhZHFAfcSTdib+RQ5z24ZKzLuiQvu0+Xzp+2i1fqIGmH8edG1Q+ToQiYlYvzkZfA== X-Received: by 2002:a05:600c:474b:b0:46e:35a0:3587 with SMTP id 5b1f17b1804b1-477c01ee377mr2676675e9.27.1763680853616; Thu, 20 Nov 2025 15:20:53 -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-477bf3af0ecsm11618415e9.9.2025.11.20.15.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Nov 2025 15:20:52 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal Subject: [PATCH 17/22] libcamera: software_isp: debayer: Introduce a stop() callback to the debayer object Date: Thu, 20 Nov 2025 23:20:14 +0000 Message-ID: <20251120232019.3590-18-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251120232019.3590-1-bryan.odonoghue@linaro.org> References: <20251120232019.3590-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 --- 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 26787a985..530564c02 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());