From patchwork Wed Apr 8 11:56:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 26508 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 65A80C32BB for ; Wed, 8 Apr 2026 11:56:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1E96162E05; Wed, 8 Apr 2026 13:56:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.b="WxvRR6oD"; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Xd/U8/TS"; dkim-atps=neutral Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6FCC862DDA for ; Wed, 8 Apr 2026 13:56:36 +0200 (CEST) Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63878Ekp2450585 for ; Wed, 8 Apr 2026 11:56:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=W+1iJkfEjBH FzIiPGPwUKqcpbF9+SIRH8ysjR3FBK3g=; b=WxvRR6oDoeq3Ey28NQvcact+D1b CyoqmADJ9QegACZ0ewdOOiF6XW0Erw0LLOpmB+JBGmC4xJ1dvOMIFFDTPbXDthQg T+FFCPcwR5f36vbEJ9lgpEFIM0sXWzi59g84Dt/CfnxnrIcF3kssYW8KhBuLan/g Z+U3y2GG1C7KNwj7VRXkjJS613y64PIopka+Gs3X/LgGhcXTu702P+wUgwxXXl0A GdsikM2MlWpnM6veXLsIptmUSyI4O9e5C2Kb4LM5RTgKis7w4umfkFrBVaKCbPOY 8S3kXj3e9uaNctyDZD29EVm4Xpvr7OlzGm22vsEpI/KewhhHAB8F/7+04Cw== Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ddae6amnf-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 08 Apr 2026 11:56:35 +0000 (GMT) Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-50b3544bc7bso84700881cf.2 for ; Wed, 08 Apr 2026 04:56:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1775649394; x=1776254194; 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=W+1iJkfEjBHFzIiPGPwUKqcpbF9+SIRH8ysjR3FBK3g=; b=Xd/U8/TSegsCPiQ6zB80ojufL9tVi6FoGukDoS3RzqPIiWGV3DmOmjqM7zsLOyMGiO 0wRZc+cSdDeYLDkhFQooZ1SAnEbH5lWSwT5EdaCkcyd6eN3ih8G3xBLaOytgNI/BwuqY Go+2VVWZpX6N4q/idEfFSjQ4fOm1Xm0/XfrPfLrDfIqKurYGV8LbuvL+xKy4/p2xBqgS CxHsYfD/2bhvUh3oRFy9Skqte9R7RbefZjTcdxq8mgrkkYJnYA+cZP7sX6BO9Pwwc+4v UgEogixfRvTl5ZMYH9nsJpExq7dil7/WKCtfFbI4AES5TWIHTfZ5Khb+x/7fSmi/Jzn4 gzjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775649394; x=1776254194; 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=W+1iJkfEjBHFzIiPGPwUKqcpbF9+SIRH8ysjR3FBK3g=; b=gFl5OBtDkfmaBw8RiHYxpx8MUpdA/GRasI6L5vdj3c2yJJvLtmuelCvV7pLMEw0RCl zhdJCjCOxpFzv49P2QnDY8RVRfJUmOc4Av8GwC1iqGQv+PiQeWOujO6BOyCRToj3RNDr JnheFTeWlQQb0WGy27v6YBUWiGHUQKPMGI8KR6iUJGQlYHGLFa2rkQuev6YA+QDeS/Zh 5i4WFwX4uv+b+Z4n7dYBuVGEo+hOgUVbp1skBD6pHUwrlbvJ9lXeG1wVZmw9hlw9+hAO 7yphl1wA9QatobDtxlCSyKZYTIbweofAU3x0fPIHk5WghvFMIexYbI8poE8VU2TODqmO OgPw== X-Gm-Message-State: AOJu0YwLxXqSMW+2Tfv39tgIF1S5P1YpOR1cTy2tTAXcMW5PHHHkDvfz 7OKUVcmsy1hu0i2hxAdkuI9mVo0wvf6Kau8qe5XV86XcNhxHLOp9UenJ5KgYyxPd1n3JHs7aG30 XDk2DBL4W4CCnpVjrcUGUF1pPK7P3MIsu6MVsddIP9i03ZMk8xpIv9Yfbx8QgosOMVtu2WGbMPt I54qKWVtHi X-Gm-Gg: AeBDieu7p9DSiMdMxux6248m0uOi/vv5QC2zMIW7jFpUkNz3oiUURdrThiwDX8ZD+jJ vb1ACkGNQUd7h4FQgQR5snsQfzfBOYYTxIU5x7U6fDio+3Y8o1tbT7Mp0UeroyBz4NS1wPhiZSg IaIABFYkrvqFR9RSnyKix2UHmAJAem1WxZ1m9ocdvaaMCetABf+tWBCeRVvZuJsCOUciBaKAgOP 1y+VQi4Pdtb29GSN0CPpNBl/A+4HygM+VuDe/a8tD0SzC8HkRYuIO5OFmc92mjG9mqvsrGR85vA GVs8/yJKrCjD90Y9kP55ykXOM74m4LG5dCl2P1lPHoXyIkQqgCtKAxCkgiEdK8VF+Rs5sxsBS7q m7Gip4rHxdcdyKjv/YDqRIznc3qXeJ2IStdqFevFPWKcLFE6McvH+FjbSA9CcZEBqwlGotV4Haz WwClPqVxcSLJTCmjw5Ms2ctzYIT5DIb+eN X-Received: by 2002:ac8:7d0e:0:b0:50d:6d66:7267 with SMTP id d75a77b69052e-50d6d66736dmr280029371cf.7.1775649394224; Wed, 08 Apr 2026 04:56:34 -0700 (PDT) X-Received: by 2002:ac8:7d0e:0:b0:50d:6d66:7267 with SMTP id d75a77b69052e-50d6d66736dmr280029031cf.7.1775649393749; Wed, 08 Apr 2026 04:56:33 -0700 (PDT) Received: from t14s (2001-1c00-0c32-7800-07d4-cca3-ec08-7ac7.cable.dynamic.v6.ziggo.nl. [2001:1c00:c32:7800:7d4:cca3:ec08:7ac7]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b9c3c97219dsm632410766b.5.2026.04.08.04.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Apr 2026 04:56:32 -0700 (PDT) From: Hans de Goede To: libcamera-devel@lists.libcamera.org Cc: Loic Poulain , Hans de Goede Subject: [PATCH 1/3] libcamera: pipeline: Allow pipeline-handlers to opt out of locking the media devices Date: Wed, 8 Apr 2026 13:56:28 +0200 Message-ID: <20260408115630.12456-2-johannes.goede@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408115630.12456-1-johannes.goede@oss.qualcomm.com> References: <20260408115630.12456-1-johannes.goede@oss.qualcomm.com> MIME-Version: 1.0 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDA4MDExMCBTYWx0ZWRfX41gSiPp+R0/L 3qgSbDgelKyu45KZyCPYYsOv/VXEvfvB8o5lpxkDG0tfOXk+DucITfngf5Fz5uJqdIC0VFC4AYP D4h0CYCzBjOvDFYwXDEr2AMq2K0lOB3CTZZ6KVX3LfNfo16UtEmp2eYnwGvq8L5I3vO7aLgEkFa ob6UjlIQIAmzM2rkiRTY2Lig2qBLT1cTbSYoCaHOeuRwaOVC7hvo5KXZD6Fs0Oo9t17lpxGzBzW ydaXyh3+Xbq9Ue54uAgpQ10bwr00dHZjkJOw1MJI2NJN9ZVv5mkY4BaxS8o6KCgKkuTS6x7mcsT P0yzx2m+DRXrD7J4qI4EzYKsBaGHir+Y8QpMGqMoy6J6DM45MT/RvbA3zhN95oxysJaE5Ir1vbK uKpjZ6tcr7vFnVcn0JAZSdugp3enVsi/p8VGzQbZcpBgCJmBwDdReZwQuP56IxXsnFcD2Mw0kLM Ppx1hnsSAlsVtdodjSg== X-Proofpoint-GUID: NU7Ad-WpkZm6xNpN9WaLb2rZFyzKkZTI X-Proofpoint-ORIG-GUID: NU7Ad-WpkZm6xNpN9WaLb2rZFyzKkZTI X-Authority-Analysis: v=2.4 cv=K4AS2SWI c=1 sm=1 tr=0 ts=69d64273 cx=c_pps a=JbAStetqSzwMeJznSMzCyw==:117 a=5kIPp5jG11CJu4rz:21 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=3LanLXOAZEJocNd9WM4A:9 a=uxP6HrT_eTzRwkO_Te1X:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293, Aquarius:18.0.1143, Hydra:6.1.51, FMLib:17.12.100.49 definitions=2026-04-08_03,2026-04-08_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 adultscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000 definitions=main-2604080110 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" On Qualcomm chips any CSI-phy can be connected to any CSI-decoder and any CSI-decoder can be connected to any Video-Front-End (VFE, DMA write engine and co). Basically there are 2 big cross-switches between PHYs and decoders and between decoders and VFEs which can be controlled through media-controller links. As such the entite CAMSS block with CSI-phys, decoders and VFEs is represented to userspace as a single /dev/media# node. As long as active links from unrelated cameras are not touched when setting up a new camera 2 independent raw data-streams can be run and managed by 2 different libcamera instances. But the standard locking of the /dev/media# node by the first libcamera instance to start streaming from one of the camera blocks this. Add a new lockOnAcquire_ class member which defaults to true and allow pipeline-handlers to opt out of the /dev/media# locking by setting this to false. Note pipeline-handlers which opt-out will need to implement their own alternative locking from acquireDevice(). This could be done for example by using lockf() on the phy, decoder and VFE v4l2-subdevs used by the camera being acquired. Signed-off-by: Hans de Goede --- include/libcamera/internal/pipeline_handler.h | 2 ++ src/libcamera/pipeline_handler.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h index b4f97477a..1c88d2e99 100644 --- a/include/libcamera/internal/pipeline_handler.h +++ b/include/libcamera/internal/pipeline_handler.h @@ -70,6 +70,7 @@ public: CameraManager *cameraManager() const { return manager_; } + protected: void registerCamera(std::shared_ptr camera); void hotplugMediaDevice(std::shared_ptr media); @@ -83,6 +84,7 @@ protected: CameraManager *manager_; const unsigned int maxQueuedRequestsDevice_; + bool lockOnAcquire_; private: void unlockMediaDevices(); diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp index 5c469e5ba..34bfda4af 100644 --- a/src/libcamera/pipeline_handler.cpp +++ b/src/libcamera/pipeline_handler.cpp @@ -72,7 +72,7 @@ LOG_DEFINE_CATEGORY(Pipeline) PipelineHandler::PipelineHandler(CameraManager *manager, unsigned int maxQueuedRequestsDevice) : manager_(manager), maxQueuedRequestsDevice_(maxQueuedRequestsDevice), - useCount_(0) + lockOnAcquire_(true), useCount_(0) { } @@ -170,7 +170,7 @@ PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator, */ bool PipelineHandler::acquire(Camera *camera) { - if (useCount_ == 0) { + if (useCount_ == 0 && lockOnAcquire_) { for (std::shared_ptr &media : mediaDevices_) { if (!media->lock()) { unlockMediaDevices(); @@ -180,7 +180,7 @@ bool PipelineHandler::acquire(Camera *camera) } if (!acquireDevice(camera)) { - if (useCount_ == 0) + if (useCount_ == 0 && lockOnAcquire_) unlockMediaDevices(); return false; @@ -212,7 +212,7 @@ void PipelineHandler::release(Camera *camera) releaseDevice(camera); - if (useCount_ == 1) + if (useCount_ == 1 && lockOnAcquire_) unlockMediaDevices(); --useCount_;