[{"id":37095,"web_url":"https://patchwork.libcamera.org/comment/37095/","msgid":"<176423742730.567526.5309096084780079641@ping.linuxembedded.co.uk>","date":"2025-11-27T09:57:07","subject":"Re: [PATCH v2 17/22] libcamera: software_isp: debayer: Introduce a\n\tstop() callback to the debayer object","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Bryan O'Donoghue (2025-11-27 02:22:49)\n> The eGL class wants to be able to teardown its sync_ data member\n> properly but, doing so in the destructor means we can't make the eGL\n> context current and thus can't tear down the sync primitive properly.\n> \n> Introduce a stop() method to the debayer class which triggers from the\n> softisp's stop method, allowing a controlled and appropriate tear-down\n> of debayer-egl and egl class related data well before the destructors\n> get invoked.\n> \n> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>\n> [bod: Made method blocking not queued per Robert's bugfixes]\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  src/libcamera/software_isp/debayer.h        |  1 +\n>  src/libcamera/software_isp/debayer_cpu.cpp  | 10 ++++++++++\n>  src/libcamera/software_isp/debayer_cpu.h    |  1 +\n>  src/libcamera/software_isp/software_isp.cpp |  3 +++\n>  4 files changed, 15 insertions(+)\n> \n> diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\n> index 451c1c9ac..088b062c0 100644\n> --- a/src/libcamera/software_isp/debayer.h\n> +++ b/src/libcamera/software_isp/debayer.h\n> @@ -48,6 +48,7 @@ public:\n>         strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;\n>  \n>         virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0;\n> +       virtual void stop() = 0;\n>  \n>         virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;\n>  \n> diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\n> index 00738c56b..28fb8ca50 100644\n> --- a/src/libcamera/software_isp/debayer_cpu.cpp\n> +++ b/src/libcamera/software_isp/debayer_cpu.cpp\n> @@ -788,6 +788,16 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n>         inputBufferReady.emit(input);\n>  }\n>  \n> +/**\n> + * \\fn void Debayer::stop()\n> + * \\brief Stop the debayering process and perform cleanup\n> + *\n> + * In the DebayerCPU case this is an empty stub function but\n> + * for the GPU case this does something useful. The stub here is to\n> + * ensure the right version of the virtual gets called.\n> + */\n> +void DebayerCpu::stop() {}\n\nI think the lint stage will want this reformated. With that:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> +\n>  SizeRange DebayerCpu::sizes(PixelFormat inputFormat, const Size &inputSize)\n>  {\n>         Size patternSize = this->patternSize(inputFormat);\n> diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\n> index ecc4f9dd0..2d385cf01 100644\n> --- a/src/libcamera/software_isp/debayer_cpu.h\n> +++ b/src/libcamera/software_isp/debayer_cpu.h\n> @@ -38,6 +38,7 @@ public:\n>         std::tuple<unsigned int, unsigned int>\n>         strideAndFrameSize(const PixelFormat &outputFormat, const Size &size);\n>         void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params);\n> +       void stop();\n>         SizeRange sizes(PixelFormat inputFormat, const Size &inputSize);\n>         const SharedFD &getStatsFD() { return stats_->getStatsFD(); }\n>  \n> diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\n> index 4c232339b..aa4a40cb6 100644\n> --- a/src/libcamera/software_isp/software_isp.cpp\n> +++ b/src/libcamera/software_isp/software_isp.cpp\n> @@ -367,6 +367,9 @@ int SoftwareIsp::start()\n>   */\n>  void SoftwareIsp::stop()\n>  {\n> +       debayer_->invokeMethod(&Debayer::stop,\n> +                              ConnectionTypeBlocking);\n> +\n>         ispWorkerThread_.exit();\n>         ispWorkerThread_.wait();\n>         ispWorkerThread_.removeMessages(debayer_.get());\n> -- \n> 2.51.2\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BFA9FC3260\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 Nov 2025 09:57:11 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 69A4460AA1;\n\tThu, 27 Nov 2025 10:57:11 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D5808609DE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 Nov 2025 10:57:09 +0100 (CET)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net [86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id AD368593;\n\tThu, 27 Nov 2025 10:54:59 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"QRny0bNL\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764237299;\n\tbh=2fBfqcTJmxDKGbx+yidLW+zZ6eE49Jv6pIq38mZHePA=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=QRny0bNLAZRu9wYxT+a0QX+u+d1Mse1zAothkiLNQ7dycVymUU7eAGpl3VrZpX60Z\n\t5Nw4ZkFJqb1oRnWT+6JgiOlGxxRQxrYyZXWD+9oFoF9Lr7REmX28mHiCq/zdoWXAmk\n\teyu01YMIzWZTrL8taA3KIj5tFu+JD22V4iRepjlE=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20251127022256.178929-18-bryan.odonoghue@linaro.org>","References":"<20251127022256.178929-1-bryan.odonoghue@linaro.org>\n\t<20251127022256.178929-18-bryan.odonoghue@linaro.org>","Subject":"Re: [PATCH v2 17/22] libcamera: software_isp: debayer: Introduce a\n\tstop() callback to the debayer object","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"pavel@ucw.cz, Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tMilan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Thu, 27 Nov 2025 09:57:07 +0000","Message-ID":"<176423742730.567526.5309096084780079641@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":37135,"web_url":"https://patchwork.libcamera.org/comment/37135/","msgid":"<cc68383d-49f9-4a7b-a0b8-230aea07b8ba@ideasonboard.com>","date":"2025-12-01T12:09:42","subject":"Re: [PATCH v2 17/22] libcamera: software_isp: debayer: Introduce a\n\tstop() callback to the debayer object","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/people/216/","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"content":"Hi\n\n2025. 11. 27. 3:22 keltezéssel, Bryan O'Donoghue írta:\n> The eGL class wants to be able to teardown its sync_ data member\n> properly but, doing so in the destructor means we can't make the eGL\n> context current and thus can't tear down the sync primitive properly.\n> \n> Introduce a stop() method to the debayer class which triggers from the\n> softisp's stop method, allowing a controlled and appropriate tear-down\n> of debayer-egl and egl class related data well before the destructors\n> get invoked.\n> \n> Reviewed-by: Milan Zamazal <mzamazal@redhat.com>\n> [bod: Made method blocking not queued per Robert's bugfixes]\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>   src/libcamera/software_isp/debayer.h        |  1 +\n>   src/libcamera/software_isp/debayer_cpu.cpp  | 10 ++++++++++\n>   src/libcamera/software_isp/debayer_cpu.h    |  1 +\n>   src/libcamera/software_isp/software_isp.cpp |  3 +++\n>   4 files changed, 15 insertions(+)\n> \n> diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\n> index 451c1c9ac..088b062c0 100644\n> --- a/src/libcamera/software_isp/debayer.h\n> +++ b/src/libcamera/software_isp/debayer.h\n> @@ -48,6 +48,7 @@ public:\n>   \tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0;\n>   \n>   \tvirtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0;\n> +\tvirtual void stop() = 0;\n\nAny reason not to do `virtual void stop() { }` here?\n\n\n>   \n>   \tvirtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0;\n>   \n> diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\n> index 00738c56b..28fb8ca50 100644\n> --- a/src/libcamera/software_isp/debayer_cpu.cpp\n> +++ b/src/libcamera/software_isp/debayer_cpu.cpp\n> @@ -788,6 +788,16 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n>   \tinputBufferReady.emit(input);\n>   }\n>   \n> +/**\n> + * \\fn void Debayer::stop()\n> + * \\brief Stop the debayering process and perform cleanup\n> + *\n> + * In the DebayerCPU case this is an empty stub function but\n> + * for the GPU case this does something useful. The stub here is to\n> + * ensure the right version of the virtual gets called.\n> + */\n> +void DebayerCpu::stop() {}\n> +\n>   SizeRange DebayerCpu::sizes(PixelFormat inputFormat, const Size &inputSize)\n>   {\n>   \tSize patternSize = this->patternSize(inputFormat);\n> diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h\n> index ecc4f9dd0..2d385cf01 100644\n> --- a/src/libcamera/software_isp/debayer_cpu.h\n> +++ b/src/libcamera/software_isp/debayer_cpu.h\n> @@ -38,6 +38,7 @@ public:\n>   \tstd::tuple<unsigned int, unsigned int>\n>   \tstrideAndFrameSize(const PixelFormat &outputFormat, const Size &size);\n>   \tvoid process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params);\n> +\tvoid stop();\n>   \tSizeRange sizes(PixelFormat inputFormat, const Size &inputSize);\n>   \tconst SharedFD &getStatsFD() { return stats_->getStatsFD(); }\n>   \n> diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp\n> index 4c232339b..aa4a40cb6 100644\n> --- a/src/libcamera/software_isp/software_isp.cpp\n> +++ b/src/libcamera/software_isp/software_isp.cpp\n> @@ -367,6 +367,9 @@ int SoftwareIsp::start()\n>    */\n>   void SoftwareIsp::stop()\n>   {\n> +\tdebayer_->invokeMethod(&Debayer::stop,\n> +\t\t\t       ConnectionTypeBlocking);\n> +\n>   \tispWorkerThread_.exit();\n>   \tispWorkerThread_.wait();\n>   \tispWorkerThread_.removeMessages(debayer_.get());\n\nAnd I think the `removeMessages()` is technically no longer strictly needed\nbecause the blocking call should ensure no pending messages of are waiting in\n`ispWorkerThread`.\n\n\nRegards,\nBarnabás Pőcze","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C5A71C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  1 Dec 2025 12:09:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D8A4160AD0;\n\tMon,  1 Dec 2025 13:09:50 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D29D60A7B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  1 Dec 2025 13:09:49 +0100 (CET)","from [192.168.33.24] (185.182.214.104.nat.pool.zt.hu\n\t[185.182.214.104])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5BE216DF;\n\tMon,  1 Dec 2025 13:07:34 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Bfi4oOkY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1764590855;\n\tbh=lY7tgyuQb2r+f3i+4PEUOBWVj8iU9vWmhcOPSlHVC60=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=Bfi4oOkY8OF2Nth1pnfSJWbEHOaAdMVlIeN3STCrcQnHvfodaXSvovaUHKSDwgtvc\n\te4mdcZs/K6DlsDou46b08ZNvEtR7gdyZwoplM4doRArsJ6VSvWSVw4Ib+qVh1DOsuj\n\t6Qlf9ffe9PMc53iMqzC2Y+LMfmJkMDj8RZgRv6pc=","Message-ID":"<cc68383d-49f9-4a7b-a0b8-230aea07b8ba@ideasonboard.com>","Date":"Mon, 1 Dec 2025 13:09:42 +0100","MIME-Version":"1.0","User-Agent":"Mozilla Thunderbird","Subject":"Re: [PATCH v2 17/22] libcamera: software_isp: debayer: Introduce a\n\tstop() callback to the debayer object","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>,\n\tlibcamera-devel@lists.libcamera.org","Cc":"pavel@ucw.cz, Milan Zamazal <mzamazal@redhat.com>","References":"<20251127022256.178929-1-bryan.odonoghue@linaro.org>\n\t<20251127022256.178929-18-bryan.odonoghue@linaro.org>","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","Content-Language":"en-US, hu-HU","In-Reply-To":"<20251127022256.178929-18-bryan.odonoghue@linaro.org>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]