{"id":23959,"url":"https://patchwork.libcamera.org/api/1.1/patches/23959/?format=json","web_url":"https://patchwork.libcamera.org/patch/23959/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20250725-multicontext-v1-5-ea558291e101@ideasonboard.com>","date":"2025-07-25T10:33:50","name":"[5/9] libcamera: v4l2_subdevice: Add bind context","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2eff03b2b57246d6337c4a323ca5b268ad185f06","submitter":{"id":143,"url":"https://patchwork.libcamera.org/api/1.1/people/143/?format=json","name":"Jacopo Mondi","email":"jacopo.mondi@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23959/mbox/","series":[{"id":5329,"url":"https://patchwork.libcamera.org/api/1.1/series/5329/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5329","date":"2025-07-25T10:33:45","name":"libcamera: Support for multi-context operations","version":1,"mbox":"https://patchwork.libcamera.org/series/5329/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23959/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23959/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 9BDFDC3323\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Jul 2025 10:34:13 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B4D5C690D9;\n\tFri, 25 Jul 2025 12:34:08 +0200 (CEST)","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 4D947690B7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jul 2025 12:33:59 +0200 (CEST)","from [192.168.0.172] (mob-5-90-139-29.net.vodafone.it\n\t[5.90.139.29])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 80641C73;\n\tFri, 25 Jul 2025 12:33:19 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"b21ZIVjX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753439599;\n\tbh=7CHQlqJbhPu1j9qyzC4tfgPWW4kyttKI0UNVFyIDEjw=;\n\th=From:Date:Subject:References:In-Reply-To:To:Cc:From;\n\tb=b21ZIVjX9IPHeCA7+btK2Fn/xweg05D0YtgsWQlHhNHmgcnoUeduDAysMssRmaPmF\n\thBpKAWrlljCnFk21Vt3NF87MADsZOOtPJ0lIhQEjWkfNufp8poJSlG6JGVQwFqbamf\n\t+zPamzmmoEC/Go7B9mCAd+qr9CxhY9Rbnyh7wf4Y=","From":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","Date":"Fri, 25 Jul 2025 12:33:50 +0200","Subject":"[PATCH 5/9] libcamera: v4l2_subdevice: Add bind context","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"7bit","Message-Id":"<20250725-multicontext-v1-5-ea558291e101@ideasonboard.com>","References":"<20250725-multicontext-v1-0-ea558291e101@ideasonboard.com>","In-Reply-To":"<20250725-multicontext-v1-0-ea558291e101@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>","X-Mailer":"b4 0.14.2","X-Developer-Signature":"v=1; a=openpgp-sha256; l=2076;\n\ti=jacopo.mondi@ideasonboard.com; h=from:subject:message-id;\n\tbh=7CHQlqJbhPu1j9qyzC4tfgPWW4kyttKI0UNVFyIDEjw=;\n\tb=owEBbQKS/ZANAwAKAXI0Bo8WoVY8AcsmYgBog12UY0LMH8DuPMmnXZVIRpJjzZe48UDHJD/sq\n\t8/V2iK0fuKJAjMEAAEKAB0WIQS1xD1IgJogio9YOMByNAaPFqFWPAUCaINdlAAKCRByNAaPFqFW\n\tPP/VD/9FxrhdBj7e3wn2YEBcPhxhRT64m/2c8OMR8jeIkwM9L8kVEFuWbJjxnzWjbhQu+uLSZwn\n\tdZtGiJY5G9aCfFisKGFBQ2TW54qyIc3ckAbO7fw8kbEBKTHewZy5DBceODn0VRbMINN31osujcb\n\tq63fg1x/AxBxOxDpuw+u3kINPNvr7XmQ0zp4JZ/kvigcOOYfZHEQ7H3t1EaxO87L2uKpBdacutZ\n\tsTpvX+jjNHttEC+udTf2iqjKTTfIOlKzXBtGDj76c8csBvDpjTI9YDusx8Rq3+gnnUxTYY1bJJX\n\ti9yUdXLVcNwKV3IH6tadEAZ5gKDnNST2qIl0P8eu2iBqNdcsIQySFESYgUu2k3q2K8X3DpDFDN4\n\tT0XenLFB/b2hmuaIZSCvAae9prxEgBeb1yli8PASwmgb9dMOXsiH6TloaJVJ+xS1+z2aqFyqmrB\n\tAPqzNjpBmBSRCLXmmrfo3RavpZs3naaejYQObHFYITfn69zmbbglJnDTpGkipBZEcDM2cbL3UBh\n\tulYxssZJdENW+8X3c3wwKPl3w/OPEQmI3icRF4BmYCVDl9LxYbcyfk7BwgA32EeHzwrWiDsB/PL\n\t+N6IJYoa/m8yUhFJIQdfKgwR2pY11SUCT644dXTXC6PkwhF/CHwOd7iAbt0Xcm1L3CmqfiwNB0s\n\tn/ILybzsDRwdF6g==","X-Developer-Key":"i=jacopo.mondi@ideasonboard.com; a=openpgp;\n\tfpr=72392EDC88144A65C701EA9BA5826A2587AD026B","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":"Add a function to the V4L2Subdevice class that allows to\nbind a subdevice to a media device context using the\nVIDIOC_SUBDEV_BIND_CONTEXT ioctl.\n\nSigned-off-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_subdevice.h |  2 ++\n src/libcamera/v4l2_subdevice.cpp            | 18 ++++++++++++++++++\n 2 files changed, 20 insertions(+)","diff":"diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex fa2a4a21eefbb792c69fa6357934d607a009d11a..f65a587c3034df014390863319a350c8fbd4ed5a 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -140,6 +140,8 @@ public:\n \t\treturn formats({ pad, 0 });\n \t}\n \n+\tint bindContext(unsigned int context);\n+\n \tint getFormat(const Stream &stream, V4L2SubdeviceFormat *format,\n \t\t      Whence whence = ActiveFormat);\n \tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex ce6b0d38cbf1a598e6dc73de8cb36ba245ed73f9..9038783bd2975b6b2063a5d60890e2de82c4aa0d 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -1351,6 +1351,24 @@ std::optional<ColorSpace> V4L2Subdevice::toColorSpace(const v4l2_mbus_framefmt &\n \treturn V4L2Device::toColorSpace(format, colourEncoding);\n }\n \n+/**\n+ * \\brief Bind a subdevice to a media device context\n+ * \\param[in] context The file descriptor that identifies the media device\n+ * context\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2Subdevice::bindContext(unsigned int context)\n+{\n+\tstruct v4l2_subdev_bind_context c = {};\n+\tc.context_fd = context;\n+\n+\tint ret = ioctl(VIDIOC_SUBDEV_BIND_CONTEXT, &c);\n+\tif (ret)\n+\t\tLOG(V4L2, Error) << \"Unable to bind context: \" << strerror(-ret);\n+\n+\treturn ret;\n+}\n+\n /**\n  * \\brief Retrieve the image format set on one of the V4L2 subdevice streams\n  * \\param[in] stream The stream the format is to be retrieved from\n","prefixes":["5/9"]}