[{"id":35122,"web_url":"https://patchwork.libcamera.org/comment/35122/","msgid":"<353ebd385f0487c2dafdce42f243029d61e8b6f8.camel@ideasonboard.com>","date":"2025-07-25T10:37:34","subject":"Re: [PATCH 5/9] libcamera: v4l2_subdevice: Add bind context","submitter":{"id":215,"url":"https://patchwork.libcamera.org/api/people/215/","name":"Isaac Scott","email":"isaac.scott@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Fri, 2025-07-25 at 12:33 +0200, Jacopo Mondi wrote:\n> Add a function to the V4L2Subdevice class that allows to\n> bind a subdevice to a media device context using the\n> VIDIOC_SUBDEV_BIND_CONTEXT ioctl.\n> \n> Signed-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(+)\n> \n> diff --git a/include/libcamera/internal/v4l2_subdevice.h\n> b/include/libcamera/internal/v4l2_subdevice.h\n> index\n> fa2a4a21eefbb792c69fa6357934d607a009d11a..f65a587c3034df014390863319a\n> 350c8fbd4ed5a 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\nReviewed-by: Isaac Scott <isaac.scott@ideasonboard.com>\n\n>  \tint getFormat(const Stream &stream, V4L2SubdeviceFormat\n> *format,\n>  \t\t      Whence whence = ActiveFormat);\n>  \tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n> diff --git a/src/libcamera/v4l2_subdevice.cpp\n> b/src/libcamera/v4l2_subdevice.cpp\n> index\n> ce6b0d38cbf1a598e6dc73de8cb36ba245ed73f9..9038783bd2975b6b2063a5d6089\n> 0e2de82c4aa0d 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -1351,6 +1351,24 @@ std::optional<ColorSpace>\n> 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\n> 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: \" <<\n> strerror(-ret);\n> +\n> +\treturn ret;\n> +}\n> +\n>  /**\n>   * \\brief Retrieve the image format set on one of the V4L2 subdevice\n> streams\n>   * \\param[in] stream The stream the format is to be retrieved from","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 0F6FFC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Jul 2025 10:37:39 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B5FE6690CF;\n\tFri, 25 Jul 2025 12:37:38 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A140690AC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Jul 2025 12:37:37 +0200 (CEST)","from isaac-ThinkPad-T16-Gen-2.lan\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 A495278E;\n\tFri, 25 Jul 2025 12:36:57 +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=\"RoK6giJh\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1753439817;\n\tbh=yzUQ6f9m9IlfBrjVacojrmbkvqB7rMaj2q4zDosg7v8=;\n\th=Subject:From:To:Date:In-Reply-To:References:From;\n\tb=RoK6giJhOq7j6lsSHaJqEp3wcDpdARH+JbTUJhnwG1oGybSf3GGXW8zrI3UxBdX+0\n\ttn4FQtBLqAHmriJs1sdfqJm/olDB/UerQcdTLT+eAq1n73e4psgp1BeJ1Ulh/qgZgn\n\tO2MFwCACqE1ZOwDpdUkhVfvAUCNK6hUfObAbq980=","Message-ID":"<353ebd385f0487c2dafdce42f243029d61e8b6f8.camel@ideasonboard.com>","Subject":"Re: [PATCH 5/9] libcamera: v4l2_subdevice: Add bind context","From":"Isaac Scott <isaac.scott@ideasonboard.com>","To":"Jacopo Mondi <jacopo.mondi@ideasonboard.com>, \n\tlibcamera-devel@lists.libcamera.org","Date":"Fri, 25 Jul 2025 11:37:34 +0100","In-Reply-To":"<20250725-multicontext-v1-5-ea558291e101@ideasonboard.com>","References":"<20250725-multicontext-v1-0-ea558291e101@ideasonboard.com>\n\t<20250725-multicontext-v1-5-ea558291e101@ideasonboard.com>","Content-Type":"text/plain; charset=\"UTF-8\"","Content-Transfer-Encoding":"quoted-printable","User-Agent":"Evolution 3.56.2 (by Flathub.org) ","MIME-Version":"1.0","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>"}}]