[v3,17/22] libcamera: software_isp: debayer: Introduce a stop() callback to the debayer object
diff mbox series

Message ID 20251202133157.661407-18-bryan.odonoghue@linaro.org
State New
Headers show
Series
  • GPUISP precursor series
Related show

Commit Message

Bryan O'Donoghue Dec. 2, 2025, 1:31 p.m. UTC
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 <mzamazal@redhat.com>
[bod: Made method blocking not queued per Robert's bugfixes]
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
---
 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(-)

Patch
diff mbox series

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 &params)
  * \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);