Patch Detail
Show a patch.
GET /api/patches/19558/?format=api
{ "id": 19558, "url": "https://patchwork.libcamera.org/api/patches/19558/?format=api", "web_url": "https://patchwork.libcamera.org/patch/19558/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20240227140953.26093-8-laurent.pinchart@ideasonboard.com>", "date": "2024-02-27T14:09:51", "name": "[7/9] libcamera: v4l2_subdevice: Add stream support to get/set functions", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "b19d17b994d0f4cc33cd9be56ecb387c99f4e869", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/19558/mbox/", "series": [ { "id": 4189, "url": "https://patchwork.libcamera.org/api/series/4189/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=4189", "date": "2024-02-27T14:09:44", "name": "libcamera: v4l2_subdevice: Prepare for embedded data support", "version": 1, "mbox": "https://patchwork.libcamera.org/series/4189/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/19558/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/19558/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 D7DD6C3264\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 27 Feb 2024 14:10:05 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8DB8D6294A;\n\tTue, 27 Feb 2024 15:10:05 +0100 (CET)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C34E6295C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Feb 2024 15:10:01 +0100 (CET)", "from pendragon.ideasonboard.com (89-27-53-110.bb.dnainternet.fi\n\t[89.27.53.110])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ED66B8C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Feb 2024 15:09:48 +0100 (CET)" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"COHGNGeK\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1709042989;\n\tbh=a3qsrKIOsceJktUAPvPWrEIXX0wtYFnw/q+/NLjtua8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=COHGNGeK9S4S6wiK8Fe6VtyvqoNPecr49T6cBiOtObbm7H9F6Tl66Yu9lCIFc/j7Y\n\tHdgPpBQYWMkh87HIwWfnV5os2RR+rxSowxkmgL2xBF6ov2yRTVnJhFzsGt6xlyLfQh\n\tMjKAICJo/hrOGPJxdt5uPhM9uDs3Gk1/FhOyGz2Q=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Subject": "[PATCH 7/9] libcamera: v4l2_subdevice: Add stream support to get/set\n\tfunctions", "Date": "Tue, 27 Feb 2024 16:09:51 +0200", "Message-ID": "<20240227140953.26093-8-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.43.0", "In-Reply-To": "<20240227140953.26093-1-laurent.pinchart@ideasonboard.com>", "References": "<20240227140953.26093-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "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": "Extend the V4L2Subdevice API with stream support for the functions that\nget and set formats and selection rectangles. Add a Stream structure to\nidentify a subdev pad and stream, and use it to extend the V4L2Subdevice\nfunctions that get and set formats and selection rectangles with stream\nsupport.\n\nTo preserve the existing pad-based API, implement overloaded functions\nthat wrap the new stream-based API. This allows callers that are not\nstream-aware to use a simpler pad-based API, instead of having to\nexplicitly set the stream number to 0 in all API calls.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/internal/v4l2_subdevice.h | 41 +++-\n src/libcamera/v4l2_subdevice.cpp | 232 ++++++++++++++------\n 2 files changed, 202 insertions(+), 71 deletions(-)", "diff": "diff --git a/include/libcamera/internal/v4l2_subdevice.h b/include/libcamera/internal/v4l2_subdevice.h\nindex 1115cfa55594..65003394a984 100644\n--- a/include/libcamera/internal/v4l2_subdevice.h\n+++ b/include/libcamera/internal/v4l2_subdevice.h\n@@ -80,6 +80,11 @@ public:\n \t\tActiveFormat = V4L2_SUBDEV_FORMAT_ACTIVE,\n \t};\n \n+\tstruct Stream {\n+\t\tunsigned int pad;\n+\t\tunsigned int stream;\n+\t};\n+\n \tclass Routing : public std::vector<struct v4l2_subdev_route>\n \t{\n \tpublic:\n@@ -93,17 +98,39 @@ public:\n \n \tconst MediaEntity *entity() const { return entity_; }\n \n-\tint getSelection(unsigned int pad, unsigned int target,\n+\tint getSelection(const Stream &stream, unsigned int target,\n \t\t\t Rectangle *rect);\n-\tint setSelection(unsigned int pad, unsigned int target,\n+\tint getSelection(unsigned int pad, unsigned int target, Rectangle *rect)\n+\t{\n+\t\treturn getSelection({ pad, 0 }, target, rect);\n+\t}\n+\tint setSelection(const Stream &stream, unsigned int target,\n \t\t\t Rectangle *rect);\n+\tint setSelection(unsigned int pad, unsigned int target, Rectangle *rect)\n+\t{\n+\t\treturn setSelection({ pad, 0 }, target, rect);\n+\t}\n \n-\tFormats formats(unsigned int pad);\n+\tFormats formats(const Stream &stream);\n+\tFormats formats(unsigned int pad)\n+\t{\n+\t\treturn formats({ pad, 0 });\n+\t}\n \n+\tint getFormat(const Stream &stream, V4L2SubdeviceFormat *format,\n+\t\t Whence whence = ActiveFormat);\n \tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n+\t\t Whence whence = ActiveFormat)\n+\t{\n+\t\treturn getFormat({ pad, 0 }, format, whence);\n+\t}\n+\tint setFormat(const Stream &stream, V4L2SubdeviceFormat *format,\n \t\t Whence whence = ActiveFormat);\n \tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n-\t\t Whence whence = ActiveFormat);\n+\t\t Whence whence = ActiveFormat)\n+\t{\n+\t\treturn setFormat({ pad, 0 }, format, whence);\n+\t}\n \n \tint getRouting(Routing *routing, Whence whence = ActiveFormat);\n \tint setRouting(Routing *routing, Whence whence = ActiveFormat);\n@@ -123,8 +150,8 @@ private:\n \tstd::optional<ColorSpace>\n \ttoColorSpace(const v4l2_mbus_framefmt &format) const;\n \n-\tstd::vector<unsigned int> enumPadCodes(unsigned int pad);\n-\tstd::vector<SizeRange> enumPadSizes(unsigned int pad,\n+\tstd::vector<unsigned int> enumPadCodes(const Stream &stream);\n+\tstd::vector<SizeRange> enumPadSizes(const Stream &stream,\n \t\t\t\t\t unsigned int code);\n \n \tconst MediaEntity *entity_;\n@@ -133,4 +160,6 @@ private:\n \tstruct V4L2SubdeviceCapability caps_;\n };\n \n+std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Stream &stream);\n+\n } /* namespace libcamera */\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 19ddecf714c6..efe8b0f793e9 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -814,6 +814,35 @@ std::ostream &operator<<(std::ostream &out, const V4L2SubdeviceFormat &f)\n * \\brief The format operation applies to TRY formats\n */\n \n+/**\n+ * \\class V4L2Subdevice::Stream\n+ * \\brief V4L2 subdevice stream\n+ *\n+ * This class identifies a subdev stream, by bundling the pad number with the\n+ * stream number. It is used in all stream-aware functions of the V4L2Subdevice\n+ * class to identify the stream the functions operate on.\n+ *\n+ * \\var V4L2Subdevice::Stream::pad\n+ * \\brief The 0-indexed pad number\n+ *\n+ * \\var V4L2Subdevice::Stream::stream\n+ * \\brief The stream number\n+ */\n+\n+/**\n+ * \\brief Insert a text representation of a V4L2Subdevice::Stream into an\n+ *\toutput stream\n+ * \\param[in] out The output stream\n+ * \\param[in] stream The V4L2Subdevice::Stream\n+ * \\return The output stream \\a out\n+ */\n+std::ostream &operator<<(std::ostream &out, const V4L2Subdevice::Stream &stream)\n+{\n+\tout << stream.pad << \"/\" << stream.stream;\n+\n+\treturn out;\n+}\n+\n /**\n * \\class V4L2Subdevice::Routing\n * \\brief V4L2 subdevice routing table\n@@ -879,7 +908,10 @@ int V4L2Subdevice::open()\n \t\treturn ret;\n \t}\n \n-\t/* If the subdev supports streams, enable the streams API. */\n+\t/*\n+\t * If the subdev supports streams, enable the streams API, and retrieve\n+\t * and cache the routing table.\n+\t */\n \tif (caps_.hasStreams()) {\n \t\tstruct v4l2_subdev_client_capability clientCaps{};\n \t\tclientCaps.capabilities = V4L2_SUBDEV_CLIENT_CAP_STREAMS;\n@@ -905,7 +937,7 @@ int V4L2Subdevice::open()\n \n /**\n * \\brief Get selection rectangle \\a rect for \\a target\n- * \\param[in] pad The 0-indexed pad number the rectangle is retrieved from\n+ * \\param[in] stream The stream the rectangle is retrieved from\n * \\param[in] target The selection target defined by the V4L2_SEL_TGT_* flags\n * \\param[out] rect The retrieved selection rectangle\n *\n@@ -913,13 +945,14 @@ int V4L2Subdevice::open()\n *\n * \\return 0 on success or a negative error code otherwise\n */\n-int V4L2Subdevice::getSelection(unsigned int pad, unsigned int target,\n+int V4L2Subdevice::getSelection(const Stream &stream, unsigned int target,\n \t\t\t\tRectangle *rect)\n {\n \tstruct v4l2_subdev_selection sel = {};\n \n \tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n-\tsel.pad = pad;\n+\tsel.pad = stream.pad;\n+\tsel.stream = stream.stream;\n \tsel.target = target;\n \tsel.flags = 0;\n \n@@ -927,7 +960,8 @@ int V4L2Subdevice::getSelection(unsigned int pad, unsigned int target,\n \tif (ret < 0) {\n \t\tLOG(V4L2, Error)\n \t\t\t<< \"Unable to get rectangle \" << target << \" on pad \"\n-\t\t\t<< pad << \": \" << strerror(-ret);\n+\t\t\t<< stream.pad << \"/\" << stream.stream << \": \"\n+\t\t\t<< strerror(-ret);\n \t\treturn ret;\n \t}\n \n@@ -939,9 +973,20 @@ int V4L2Subdevice::getSelection(unsigned int pad, unsigned int target,\n \treturn 0;\n }\n \n+/**\n+ * \\fn V4L2Subdevice::getSelection(unsigned int pad, unsigned int target,\n+ *\tRectangle *rect)\n+ * \\brief Get selection rectangle \\a rect for \\a target\n+ * \\param[in] pad The 0-indexed pad number the rectangle is retrieved from\n+ * \\param[in] target The selection target defined by the V4L2_SEL_TGT_* flags\n+ * \\param[out] rect The retrieved selection rectangle\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+\n /**\n * \\brief Set selection rectangle \\a rect for \\a target\n- * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\n+ * \\param[in] stream The stream the rectangle is to be applied to\n * \\param[in] target The selection target defined by the V4L2_SEL_TGT_* flags\n * \\param[inout] rect The selection rectangle to be applied\n *\n@@ -949,13 +994,14 @@ int V4L2Subdevice::getSelection(unsigned int pad, unsigned int target,\n *\n * \\return 0 on success or a negative error code otherwise\n */\n-int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n+int V4L2Subdevice::setSelection(const Stream &stream, unsigned int target,\n \t\t\t\tRectangle *rect)\n {\n \tstruct v4l2_subdev_selection sel = {};\n \n \tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n-\tsel.pad = pad;\n+\tsel.pad = stream.pad;\n+\tsel.stream = stream.stream;\n \tsel.target = target;\n \tsel.flags = 0;\n \n@@ -968,7 +1014,8 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n \tif (ret < 0) {\n \t\tLOG(V4L2, Error)\n \t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n-\t\t\t<< pad << \": \" << strerror(-ret);\n+\t\t\t<< stream.pad << \"/\" << stream.stream << \": \"\n+\t\t\t<< strerror(-ret);\n \t\treturn ret;\n \t}\n \n@@ -979,26 +1026,40 @@ int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n \n \treturn 0;\n }\n+\n /**\n- * \\brief Enumerate all media bus codes and frame sizes on a \\a pad\n- * \\param[in] pad The 0-indexed pad number to enumerate formats on\n+ * \\fn V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n+ *\tRectangle *rect)\n+ * \\brief Set selection rectangle \\a rect for \\a target\n+ * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\n+ * \\param[in] target The selection target defined by the V4L2_SEL_TGT_* flags\n+ * \\param[inout] rect The selection rectangle to be applied\n+ *\n+ * \\todo Define a V4L2SelectionTarget enum for the selection target\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+\n+/**\n+ * \\brief Enumerate all media bus codes and frame sizes on a \\a stream\n+ * \\param[in] stream The stream to enumerate formats for\n *\n * Enumerate all media bus codes and frame sizes supported by the subdevice on\n- * a \\a pad.\n+ * a \\a stream.\n *\n * \\return A list of the supported device formats\n */\n-V4L2Subdevice::Formats V4L2Subdevice::formats(unsigned int pad)\n+V4L2Subdevice::Formats V4L2Subdevice::formats(const Stream &stream)\n {\n \tFormats formats;\n \n-\tif (pad >= entity_->pads().size()) {\n-\t\tLOG(V4L2, Error) << \"Invalid pad: \" << pad;\n+\tif (stream.pad >= entity_->pads().size()) {\n+\t\tLOG(V4L2, Error) << \"Invalid pad: \" << stream.pad;\n \t\treturn {};\n \t}\n \n-\tfor (unsigned int code : enumPadCodes(pad)) {\n-\t\tstd::vector<SizeRange> sizes = enumPadSizes(pad, code);\n+\tfor (unsigned int code : enumPadCodes(stream)) {\n+\t\tstd::vector<SizeRange> sizes = enumPadSizes(stream, code);\n \t\tif (sizes.empty())\n \t\t\treturn {};\n \n@@ -1006,7 +1067,7 @@ V4L2Subdevice::Formats V4L2Subdevice::formats(unsigned int pad)\n \t\tif (!inserted.second) {\n \t\t\tLOG(V4L2, Error)\n \t\t\t\t<< \"Could not add sizes for media bus code \"\n-\t\t\t\t<< code << \" on pad \" << pad;\n+\t\t\t\t<< code << \" on pad \" << stream.pad;\n \t\t\treturn {};\n \t\t}\n \t}\n@@ -1014,6 +1075,17 @@ V4L2Subdevice::Formats V4L2Subdevice::formats(unsigned int pad)\n \treturn formats;\n }\n \n+/**\n+ * \\fn V4L2Subdevice::formats(unsigned int pad)\n+ * \\brief Enumerate all media bus codes and frame sizes on a \\a pad\n+ * \\param[in] pad The 0-indexed pad number to enumerate formats on\n+ *\n+ * Enumerate all media bus codes and frame sizes supported by the subdevice on\n+ * a \\a pad\n+ *\n+ * \\return A list of the supported device formats\n+ */\n+\n std::optional<ColorSpace> V4L2Subdevice::toColorSpace(const v4l2_mbus_framefmt &format) const\n {\n \t/*\n@@ -1045,25 +1117,26 @@ std::optional<ColorSpace> V4L2Subdevice::toColorSpace(const v4l2_mbus_framefmt &\n }\n \n /**\n- * \\brief Retrieve the image format set on one of the V4L2 subdevice pads\n- * \\param[in] pad The 0-indexed pad number the format is to be retrieved from\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 * \\param[out] format The image bus format\n * \\param[in] whence The format to get, \\ref V4L2Subdevice::ActiveFormat\n * \"ActiveFormat\" or \\ref V4L2Subdevice::TryFormat \"TryFormat\"\n * \\return 0 on success or a negative error code otherwise\n */\n-int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n+int V4L2Subdevice::getFormat(const Stream &stream, V4L2SubdeviceFormat *format,\n \t\t\t Whence whence)\n {\n \tstruct v4l2_subdev_format subdevFmt = {};\n \tsubdevFmt.which = whence;\n-\tsubdevFmt.pad = pad;\n+\tsubdevFmt.pad = stream.pad;\n+\tsubdevFmt.stream = stream.stream;\n \n \tint ret = ioctl(VIDIOC_SUBDEV_G_FMT, &subdevFmt);\n \tif (ret) {\n \t\tLOG(V4L2, Error)\n-\t\t\t<< \"Unable to get format on pad \" << pad\n-\t\t\t<< \": \" << strerror(-ret);\n+\t\t\t<< \"Unable to get format on pad \" << stream.pad << \"/\"\n+\t\t\t<< stream.stream << \": \" << strerror(-ret);\n \t\treturn ret;\n \t}\n \n@@ -1076,6 +1149,66 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n }\n \n /**\n+ * \\fn V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n+ *\tWhence whence)\n+ * \\brief Retrieve the image format set on one of the V4L2 subdevice pads\n+ * \\param[in] pad The 0-indexed pad number the format is to be retrieved from\n+ * \\param[out] format The image bus format\n+ * \\param[in] whence The format to get, \\ref V4L2Subdevice::ActiveFormat\n+ * \"ActiveFormat\" or \\ref V4L2Subdevice::TryFormat \"TryFormat\"\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+\n+/**\n+ * \\brief Set an image format on one of the V4L2 subdevice pads\n+ * \\param[in] stream The stream the format is to be applied to\n+ * \\param[inout] format The image bus format to apply to the stream\n+ * \\param[in] whence The format to set, \\ref V4L2Subdevice::ActiveFormat\n+ * \"ActiveFormat\" or \\ref V4L2Subdevice::TryFormat \"TryFormat\"\n+ *\n+ * Apply the requested image format to the desired stream and return the\n+ * actually applied format parameters, as getFormat() would do.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2Subdevice::setFormat(const Stream &stream, V4L2SubdeviceFormat *format,\n+\t\t\t Whence whence)\n+{\n+\tstruct v4l2_subdev_format subdevFmt = {};\n+\tsubdevFmt.which = whence;\n+\tsubdevFmt.pad = stream.pad;\n+\tsubdevFmt.stream = stream.stream;\n+\tsubdevFmt.format.width = format->size.width;\n+\tsubdevFmt.format.height = format->size.height;\n+\tsubdevFmt.format.code = format->code;\n+\tsubdevFmt.format.field = V4L2_FIELD_NONE;\n+\tif (format->colorSpace) {\n+\t\tfromColorSpace(format->colorSpace, subdevFmt.format);\n+\n+\t\t/* The CSC flag is only applicable to source pads. */\n+\t\tif (entity_->pads()[stream.pad]->flags() & MEDIA_PAD_FL_SOURCE)\n+\t\t\tsubdevFmt.format.flags |= V4L2_MBUS_FRAMEFMT_SET_CSC;\n+\t}\n+\n+\tint ret = ioctl(VIDIOC_SUBDEV_S_FMT, &subdevFmt);\n+\tif (ret) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Unable to set format on pad \" << stream.pad << \"/\"\n+\t\t\t<< stream.stream << \": \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tformat->size.width = subdevFmt.format.width;\n+\tformat->size.height = subdevFmt.format.height;\n+\tformat->code = subdevFmt.format.code;\n+\tformat->colorSpace = toColorSpace(subdevFmt.format);\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\fn V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n+ *\tWhence whence)\n * \\brief Set an image format on one of the V4L2 subdevice pads\n * \\param[in] pad The 0-indexed pad number the format is to be applied to\n * \\param[inout] format The image bus format to apply to the subdevice's pad\n@@ -1087,39 +1220,6 @@ int V4L2Subdevice::getFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n *\n * \\return 0 on success or a negative error code otherwise\n */\n-int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n-\t\t\t Whence whence)\n-{\n-\tstruct v4l2_subdev_format subdevFmt = {};\n-\tsubdevFmt.which = whence;\n-\tsubdevFmt.pad = pad;\n-\tsubdevFmt.format.width = format->size.width;\n-\tsubdevFmt.format.height = format->size.height;\n-\tsubdevFmt.format.code = format->code;\n-\tsubdevFmt.format.field = V4L2_FIELD_NONE;\n-\tif (format->colorSpace) {\n-\t\tfromColorSpace(format->colorSpace, subdevFmt.format);\n-\n-\t\t/* The CSC flag is only applicable to source pads. */\n-\t\tif (entity_->pads()[pad]->flags() & MEDIA_PAD_FL_SOURCE)\n-\t\t\tsubdevFmt.format.flags |= V4L2_MBUS_FRAMEFMT_SET_CSC;\n-\t}\n-\n-\tint ret = ioctl(VIDIOC_SUBDEV_S_FMT, &subdevFmt);\n-\tif (ret) {\n-\t\tLOG(V4L2, Error)\n-\t\t\t<< \"Unable to set format on pad \" << pad\n-\t\t\t<< \": \" << strerror(-ret);\n-\t\treturn ret;\n-\t}\n-\n-\tformat->size.width = subdevFmt.format.width;\n-\tformat->size.height = subdevFmt.format.height;\n-\tformat->code = subdevFmt.format.code;\n-\tformat->colorSpace = toColorSpace(subdevFmt.format);\n-\n-\treturn 0;\n-}\n \n /**\n * \\brief Retrieve the subdevice's internal routing table\n@@ -1282,14 +1382,15 @@ std::string V4L2Subdevice::logPrefix() const\n \treturn \"'\" + entity_->name() + \"'\";\n }\n \n-std::vector<unsigned int> V4L2Subdevice::enumPadCodes(unsigned int pad)\n+std::vector<unsigned int> V4L2Subdevice::enumPadCodes(const Stream &stream)\n {\n \tstd::vector<unsigned int> codes;\n \tint ret;\n \n \tfor (unsigned int index = 0; ; index++) {\n \t\tstruct v4l2_subdev_mbus_code_enum mbusEnum = {};\n-\t\tmbusEnum.pad = pad;\n+\t\tmbusEnum.pad = stream.pad;\n+\t\tmbusEnum.stream = stream.stream;\n \t\tmbusEnum.index = index;\n \t\tmbusEnum.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n \n@@ -1302,15 +1403,15 @@ std::vector<unsigned int> V4L2Subdevice::enumPadCodes(unsigned int pad)\n \n \tif (ret < 0 && ret != -EINVAL) {\n \t\tLOG(V4L2, Error)\n-\t\t\t<< \"Unable to enumerate formats on pad \" << pad\n-\t\t\t<< \": \" << strerror(-ret);\n+\t\t\t<< \"Unable to enumerate formats on pad \" << stream.pad\n+\t\t\t<< \"/\" << stream.stream << \": \" << strerror(-ret);\n \t\treturn {};\n \t}\n \n \treturn codes;\n }\n \n-std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,\n+std::vector<SizeRange> V4L2Subdevice::enumPadSizes(const Stream &stream,\n \t\t\t\t\t\t unsigned int code)\n {\n \tstd::vector<SizeRange> sizes;\n@@ -1319,7 +1420,8 @@ std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,\n \tfor (unsigned int index = 0;; index++) {\n \t\tstruct v4l2_subdev_frame_size_enum sizeEnum = {};\n \t\tsizeEnum.index = index;\n-\t\tsizeEnum.pad = pad;\n+\t\tsizeEnum.pad = stream.pad;\n+\t\tsizeEnum.stream = stream.stream;\n \t\tsizeEnum.code = code;\n \t\tsizeEnum.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n \n@@ -1333,8 +1435,8 @@ std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,\n \n \tif (ret < 0 && ret != -EINVAL && ret != -ENOTTY) {\n \t\tLOG(V4L2, Error)\n-\t\t\t<< \"Unable to enumerate sizes on pad \" << pad\n-\t\t\t<< \": \" << strerror(-ret);\n+\t\t\t<< \"Unable to enumerate sizes on pad \" << stream.pad\n+\t\t\t<< \"/\" << stream.stream << \": \" << strerror(-ret);\n \t\treturn {};\n \t}\n \n", "prefixes": [ "7/9" ] }