From patchwork Fri Jan 31 19:18:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22718 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 F01CBBD808 for ; Fri, 31 Jan 2025 19:18:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4935668562; Fri, 31 Jan 2025 20:18:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Bxd/PoG0"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 63DFF60353 for ; Fri, 31 Jan 2025 20:18:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1738351130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=8345HAgJj4p2w3Qm4C+dUCpQHYXnmMx6BGAK0zMibbU=; b=Bxd/PoG0aOKTGw3GWhuYYrPotWkDZCLsBsXr0dbsQt50ou1pibDdGtMD24z+fwWX+jMb22 1vHE6fbprULLtUhYW7pQw+4VrYj6KHeb0UBZUOrm4zvxijo38tAyq1gOVRLEqcdrXCBWJl qxzQviOps9XljpCrerd++fD4lAsspxc= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-613-HNFMtl8pPCej2qCGp4U3Hw-1; Fri, 31 Jan 2025 14:18:47 -0500 X-MC-Unique: HNFMtl8pPCej2qCGp4U3Hw-1 X-Mimecast-MFC-AGG-ID: HNFMtl8pPCej2qCGp4U3Hw Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C43F71956087; Fri, 31 Jan 2025 19:18:45 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.45.224.38]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7A33B19560A3; Fri, 31 Jan 2025 19:18:43 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Laurent Pinchart , Stanislaw Gruszka , =?utf-8?b?QmFybmFiw6FzIFDFkWN6?= =?utf-8?q?e?= Subject: [PATCH v2] libcamera: software_isp: Handle signals in the proper thread Date: Fri, 31 Jan 2025 20:18:38 +0100 Message-ID: <20250131191838.47661-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: r5S3VjHqxFHhw_pNU4eWQsA5kwWm8gyHPGELSfAmj88_1738351126 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true 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" inputBufferReady ready signal in the simple pipeline is handled in the pipeline handler thread. outputBufferReady and ispStatsReady signals should be handled there too. Rather than relying on the user of the SoftwareIsp instance, let SoftwareIsp inherits Object. SoftwareIsp serves as a signal proxy, the signals above are emitted from signal handlers. This means that if SoftwareIsp inherits Object then the slots are invoked in SoftwareIsp thread. Which is the camera manager thread because the SoftwareIsp instance is created there. Signed-off-by: Milan Zamazal Reviewed-by: Laurent Pinchart --- .../internal/software_isp/software_isp.h | 3 ++- src/libcamera/pipeline/simple/simple.cpp | 19 ++++++------------- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index d51b03fd..440a296d 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -43,7 +44,7 @@ struct StreamConfiguration; LOG_DECLARE_CATEGORY(SoftwareIsp) -class SoftwareIsp +class SoftwareIsp : public Object { public: SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 8ac24e6e..fade8fda 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -538,20 +538,13 @@ int SimpleCameraData::init() swIsp_.reset(); } else { /* - * The inputBufferReady signal is emitted from the soft ISP thread, - * and needs to be handled in the pipeline handler thread. Signals - * implement queued delivery, but this works transparently only if - * the receiver is bound to the target thread. As the - * SimpleCameraData class doesn't inherit from the Object class, it - * is not bound to any thread, and the signal would be delivered - * synchronously. Instead, connect the signal to a lambda function - * bound explicitly to the pipe, which is bound to the pipeline - * handler thread. The function then simply forwards the call to - * conversionInputDone(). + * The connected signals should be handled by the camera manager + * thread. This method is called in the camera manager thread and + * instantiates the SoftwareIsp instance, which inherits Object and + * emits the signals from the instance's own signal handlers; thus + * the slots here are invoked in the camera manager thread. */ - swIsp_->inputBufferReady.connect(pipe, [this](FrameBuffer *buffer) { - this->conversionInputDone(buffer); - }); + swIsp_->inputBufferReady.connect(this, &SimpleCameraData::conversionInputDone); swIsp_->outputBufferReady.connect(this, &SimpleCameraData::conversionOutputDone); swIsp_->ispStatsReady.connect(this, &SimpleCameraData::ispStatsReady); swIsp_->setSensorControls.connect(this, &SimpleCameraData::setSensorControls);