{"id":26508,"url":"https://patchwork.libcamera.org/api/patches/26508/?format=json","web_url":"https://patchwork.libcamera.org/patch/26508/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260408115630.12456-2-johannes.goede@oss.qualcomm.com>","date":"2026-04-08T11:56:28","name":"[1/3] libcamera: pipeline: Allow pipeline-handlers to opt out of locking the media devices","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2df8af1d71daa7bbb1f6ecb578d6336be646a81a","submitter":{"id":242,"url":"https://patchwork.libcamera.org/api/people/242/?format=json","name":"Hans de Goede","email":"johannes.goede@oss.qualcomm.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26508/mbox/","series":[{"id":5877,"url":"https://patchwork.libcamera.org/api/series/5877/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5877","date":"2026-04-08T11:56:27","name":"libcamera: Finer grained MediaDevice locking","version":1,"mbox":"https://patchwork.libcamera.org/series/5877/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26508/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26508/checks/","tags":{},"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 65A80C32BB\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  8 Apr 2026 11:56:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E96162E05;\n\tWed,  8 Apr 2026 13:56:38 +0200 (CEST)","from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com\n\t[205.220.180.131])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6FCC862DDA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Apr 2026 13:56:36 +0200 (CEST)","from pps.filterd (m0279870.ppops.net [127.0.0.1])\n\tby mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n\t63878Ekp2450585 for <libcamera-devel@lists.libcamera.org>;\n\tWed, 8 Apr 2026 11:56:35 GMT","from mail-qt1-f200.google.com (mail-qt1-f200.google.com\n\t[209.85.160.200])\n\tby mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ddae6amnf-1\n\t(version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 08 Apr 2026 11:56:35 +0000 (GMT)","by mail-qt1-f200.google.com with SMTP id\n\td75a77b69052e-50b3544bc7bso84700881cf.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 08 Apr 2026 04:56:34 -0700 (PDT)","from t14s\n\t(2001-1c00-0c32-7800-07d4-cca3-ec08-7ac7.cable.dynamic.v6.ziggo.nl.\n\t[2001:1c00:c32:7800:7d4:cca3:ec08:7ac7])\n\tby smtp.gmail.com with ESMTPSA id\n\ta640c23a62f3a-b9c3c97219dsm632410766b.5.2026.04.08.04.56.32\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 08 Apr 2026 04:56:32 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key;\n\tunprotected) header.d=qualcomm.com header.i=@qualcomm.com\n\theader.b=\"WxvRR6oD\"; dkim=pass (2048-bit key;\n\tunprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n\theader.b=\"Xd/U8/TS\"; dkim-atps=neutral","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n\tcc:content-transfer-encoding:date:from:in-reply-to:message-id\n\t:mime-version:references:subject:to; s=qcppdkim1; bh=W+1iJkfEjBH\n\tFzIiPGPwUKqcpbF9+SIRH8ysjR3FBK3g=; b=WxvRR6oDoeq3Ey28NQvcact+D1b\n\tCyoqmADJ9QegACZ0ewdOOiF6XW0Erw0LLOpmB+JBGmC4xJ1dvOMIFFDTPbXDthQg\n\tT+FFCPcwR5f36vbEJ9lgpEFIM0sXWzi59g84Dt/CfnxnrIcF3kssYW8KhBuLan/g\n\tZ+U3y2GG1C7KNwj7VRXkjJS613y64PIopka+Gs3X/LgGhcXTu702P+wUgwxXXl0A\n\tGdsikM2MlWpnM6veXLsIptmUSyI4O9e5C2Kb4LM5RTgKis7w4umfkFrBVaKCbPOY\n\t8S3kXj3e9uaNctyDZD29EVm4Xpvr7OlzGm22vsEpI/KewhhHAB8F/7+04Cw==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=oss.qualcomm.com; s=google; t=1775649394; x=1776254194;\n\tdarn=lists.libcamera.org; \n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=W+1iJkfEjBHFzIiPGPwUKqcpbF9+SIRH8ysjR3FBK3g=;\n\tb=Xd/U8/TSegsCPiQ6zB80ojufL9tVi6FoGukDoS3RzqPIiWGV3DmOmjqM7zsLOyMGiO\n\t0wRZc+cSdDeYLDkhFQooZ1SAnEbH5lWSwT5EdaCkcyd6eN3ih8G3xBLaOytgNI/BwuqY\n\tGo+2VVWZpX6N4q/idEfFSjQ4fOm1Xm0/XfrPfLrDfIqKurYGV8LbuvL+xKy4/p2xBqgS\n\tCxHsYfD/2bhvUh3oRFy9Skqte9R7RbefZjTcdxq8mgrkkYJnYA+cZP7sX6BO9Pwwc+4v\n\tUgEogixfRvTl5ZMYH9nsJpExq7dil7/WKCtfFbI4AES5TWIHTfZ5Khb+x/7fSmi/Jzn4\n\tgzjA=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20251104; t=1775649394; x=1776254194;\n\th=content-transfer-encoding:mime-version:references:in-reply-to\n\t:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n\t:to:cc:subject:date:message-id:reply-to;\n\tbh=W+1iJkfEjBHFzIiPGPwUKqcpbF9+SIRH8ysjR3FBK3g=;\n\tb=gFl5OBtDkfmaBw8RiHYxpx8MUpdA/GRasI6L5vdj3c2yJJvLtmuelCvV7pLMEw0RCl\n\tzhdJCjCOxpFzv49P2QnDY8RVRfJUmOc4Av8GwC1iqGQv+PiQeWOujO6BOyCRToj3RNDr\n\tJnheFTeWlQQb0WGy27v6YBUWiGHUQKPMGI8KR6iUJGQlYHGLFa2rkQuev6YA+QDeS/Zh\n\t5i4WFwX4uv+b+Z4n7dYBuVGEo+hOgUVbp1skBD6pHUwrlbvJ9lXeG1wVZmw9hlw9+hAO\n\t7yphl1wA9QatobDtxlCSyKZYTIbweofAU3x0fPIHk5WghvFMIexYbI8poE8VU2TODqmO\n\tOgPw==","X-Gm-Message-State":"AOJu0YwLxXqSMW+2Tfv39tgIF1S5P1YpOR1cTy2tTAXcMW5PHHHkDvfz\n\t7OKUVcmsy1hu0i2hxAdkuI9mVo0wvf6Kau8qe5XV86XcNhxHLOp9UenJ5KgYyxPd1n3JHs7aG30\n\tXDk2DBL4W4CCnpVjrcUGUF1pPK7P3MIsu6MVsddIP9i03ZMk8xpIv9Yfbx8QgosOMVtu2WGbMPt\n\tI54qKWVtHi","X-Gm-Gg":"AeBDieu7p9DSiMdMxux6248m0uOi/vv5QC2zMIW7jFpUkNz3oiUURdrThiwDX8ZD+jJ\n\tvb1ACkGNQUd7h4FQgQR5snsQfzfBOYYTxIU5x7U6fDio+3Y8o1tbT7Mp0UeroyBz4NS1wPhiZSg\n\tIaIABFYkrvqFR9RSnyKix2UHmAJAem1WxZ1m9ocdvaaMCetABf+tWBCeRVvZuJsCOUciBaKAgOP\n\t1y+VQi4Pdtb29GSN0CPpNBl/A+4HygM+VuDe/a8tD0SzC8HkRYuIO5OFmc92mjG9mqvsrGR85vA\n\tGVs8/yJKrCjD90Y9kP55ykXOM74m4LG5dCl2P1lPHoXyIkQqgCtKAxCkgiEdK8VF+Rs5sxsBS7q\n\tm7Gip4rHxdcdyKjv/YDqRIznc3qXeJ2IStdqFevFPWKcLFE6McvH+FjbSA9CcZEBqwlGotV4Haz\n\tWwClPqVxcSLJTCmjw5Ms2ctzYIT5DIb+eN","X-Received":["by 2002:ac8:7d0e:0:b0:50d:6d66:7267 with SMTP id\n\td75a77b69052e-50d6d66736dmr280029371cf.7.1775649394224; \n\tWed, 08 Apr 2026 04:56:34 -0700 (PDT)","by 2002:ac8:7d0e:0:b0:50d:6d66:7267 with SMTP id\n\td75a77b69052e-50d6d66736dmr280029031cf.7.1775649393749; \n\tWed, 08 Apr 2026 04:56:33 -0700 (PDT)"],"From":"Hans de Goede <johannes.goede@oss.qualcomm.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Loic Poulain <loic.poulain@oss.qualcomm.com>,\n\tHans de Goede <johannes.goede@oss.qualcomm.com>","Subject":"[PATCH 1/3] libcamera: pipeline: Allow pipeline-handlers to opt out\n\tof 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","Content-Transfer-Encoding":"8bit","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDA4MDExMCBTYWx0ZWRfX41gSiPp+R0/L\n\t3qgSbDgelKyu45KZyCPYYsOv/VXEvfvB8o5lpxkDG0tfOXk+DucITfngf5Fz5uJqdIC0VFC4AYP\n\tD4h0CYCzBjOvDFYwXDEr2AMq2K0lOB3CTZZ6KVX3LfNfo16UtEmp2eYnwGvq8L5I3vO7aLgEkFa\n\tob6UjlIQIAmzM2rkiRTY2Lig2qBLT1cTbSYoCaHOeuRwaOVC7hvo5KXZD6Fs0Oo9t17lpxGzBzW\n\tydaXyh3+Xbq9Ue54uAgpQ10bwr00dHZjkJOw1MJI2NJN9ZVv5mkY4BaxS8o6KCgKkuTS6x7mcsT\n\tP0yzx2m+DRXrD7J4qI4EzYKsBaGHir+Y8QpMGqMoy6J6DM45MT/RvbA3zhN95oxysJaE5Ir1vbK\n\tuKpjZ6tcr7vFnVcn0JAZSdugp3enVsi/p8VGzQbZcpBgCJmBwDdReZwQuP56IxXsnFcD2Mw0kLM\n\tPpx1hnsSAlsVtdodjSg==","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\n\ta=JbAStetqSzwMeJznSMzCyw==:117 a=5kIPp5jG11CJu4rz:21\n\ta=xqWC_Br6kY4A:10\n\ta=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22\n\ta=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8\n\ta=3LanLXOAZEJocNd9WM4A:9 a=uxP6HrT_eTzRwkO_Te1X:22","X-Proofpoint-Virus-Version":"vendor=baseguard\n\tengine=ICAP:2.0.293, Aquarius:18.0.1143, Hydra:6.1.51,\n\tFMLib:17.12.100.49\n\tdefinitions=2026-04-08_03,2026-04-08_01,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tpriorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015\n\tphishscore=0 malwarescore=0 spamscore=0 bulkscore=0 adultscore=0\n\tsuspectscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n\troute=outbound adjust=0 reason=mlx scancount=1\n\tengine=8.22.0-2604010000\n\tdefinitions=main-2604080110","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>"},"content":"On Qualcomm chips any CSI-phy can be connected to any CSI-decoder and\nany CSI-decoder can be connected to any Video-Front-End (VFE, DMA write\nengine and co). Basically there are 2 big cross-switches between PHYs\nand decoders and between decoders and VFEs which can be controlled through\nmedia-controller links.\n\nAs such the entite CAMSS block with CSI-phys, decoders and VFEs is\nrepresented to userspace as a single /dev/media# node.\n\nAs long as active links from unrelated cameras are not touched when setting\nup a new camera 2 independent raw data-streams can be run and managed by 2\ndifferent libcamera instances.\n\nBut the standard locking of the /dev/media# node by the first libcamera\ninstance to start streaming from one of the camera blocks this.\n\nAdd a new lockOnAcquire_ class member which defaults to true and allow\npipeline-handlers to opt out of the /dev/media# locking by setting this\nto false.\n\nNote pipeline-handlers which opt-out will need to implement their own\nalternative locking from acquireDevice(). This could be done for example\nby using lockf() on the phy, decoder and VFE v4l2-subdevs used by\nthe camera being acquired.\n\nSigned-off-by: Hans de Goede <johannes.goede@oss.qualcomm.com>\n---\n include/libcamera/internal/pipeline_handler.h | 2 ++\n src/libcamera/pipeline_handler.cpp            | 8 ++++----\n 2 files changed, 6 insertions(+), 4 deletions(-)","diff":"diff --git a/include/libcamera/internal/pipeline_handler.h b/include/libcamera/internal/pipeline_handler.h\nindex b4f97477a..1c88d2e99 100644\n--- a/include/libcamera/internal/pipeline_handler.h\n+++ b/include/libcamera/internal/pipeline_handler.h\n@@ -70,6 +70,7 @@ public:\n \n \tCameraManager *cameraManager() const { return manager_; }\n \n+\n protected:\n \tvoid registerCamera(std::shared_ptr<Camera> camera);\n \tvoid hotplugMediaDevice(std::shared_ptr<MediaDevice> media);\n@@ -83,6 +84,7 @@ protected:\n \n \tCameraManager *manager_;\n \tconst unsigned int maxQueuedRequestsDevice_;\n+\tbool lockOnAcquire_;\n \n private:\n \tvoid unlockMediaDevices();\ndiff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp\nindex 5c469e5ba..34bfda4af 100644\n--- a/src/libcamera/pipeline_handler.cpp\n+++ b/src/libcamera/pipeline_handler.cpp\n@@ -72,7 +72,7 @@ LOG_DEFINE_CATEGORY(Pipeline)\n PipelineHandler::PipelineHandler(CameraManager *manager,\n \t\t\t\t unsigned int maxQueuedRequestsDevice)\n \t: manager_(manager), maxQueuedRequestsDevice_(maxQueuedRequestsDevice),\n-\t  useCount_(0)\n+\t  lockOnAcquire_(true), useCount_(0)\n {\n }\n \n@@ -170,7 +170,7 @@ PipelineHandler::acquireMediaDevice(DeviceEnumerator *enumerator,\n  */\n bool PipelineHandler::acquire(Camera *camera)\n {\n-\tif (useCount_ == 0) {\n+\tif (useCount_ == 0 && lockOnAcquire_) {\n \t\tfor (std::shared_ptr<MediaDevice> &media : mediaDevices_) {\n \t\t\tif (!media->lock()) {\n \t\t\t\tunlockMediaDevices();\n@@ -180,7 +180,7 @@ bool PipelineHandler::acquire(Camera *camera)\n \t}\n \n \tif (!acquireDevice(camera)) {\n-\t\tif (useCount_ == 0)\n+\t\tif (useCount_ == 0 && lockOnAcquire_)\n \t\t\tunlockMediaDevices();\n \n \t\treturn false;\n@@ -212,7 +212,7 @@ void PipelineHandler::release(Camera *camera)\n \n \treleaseDevice(camera);\n \n-\tif (useCount_ == 1)\n+\tif (useCount_ == 1 && lockOnAcquire_)\n \t\tunlockMediaDevices();\n \n \t--useCount_;\n","prefixes":["1/3"]}