Patch Detail
Show a patch.
GET /api/patches/8625/?format=api
{ "id": 8625, "url": "https://patchwork.libcamera.org/api/patches/8625/?format=api", "web_url": "https://patchwork.libcamera.org/patch/8625/", "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": "<20200704133140.1738660-5-paul.elder@ideasonboard.com>", "date": "2020-07-04T13:31:22", "name": "[libcamera-devel,v3,04/22] libcamera: V4L2VideoDevice: Add tryFormat", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "713b85aae25cd88180b41643b240fccc2e398c88", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/8625/mbox/", "series": [ { "id": 1083, "url": "https://patchwork.libcamera.org/api/series/1083/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1083", "date": "2020-07-04T13:31:18", "name": "Clean up formats in v4l2-compat and pipeline handlers", "version": 3, "mbox": "https://patchwork.libcamera.org/series/1083/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/8625/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/8625/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 A4F12BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat, 4 Jul 2020 13:32:04 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7341860E3F;\n\tSat, 4 Jul 2020 15:32:04 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0391560C50\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 4 Jul 2020 15:32:03 +0200 (CEST)", "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 85F55296;\n\tSat, 4 Jul 2020 15:32:01 +0200 (CEST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"qwN9Vw+w\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593869522;\n\tbh=aKCQ4dp/ptdqUv1bvCyZGuoDg4r4Ml4ik9kjQPlnovA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=qwN9Vw+wR41q+iOUQR5W3Zlkz991jFFJ0uuaR83QqM4Q3DBuJUaJWu1rFcm3yrsd2\n\tBRWv3KZkpvw6MXOW5ehbPM5vIbR3hJ8hM5f/BMZYXU39MaJsWJJqFX9tUgnIlqBtUP\n\tSKC7OI7Je6210sxed7Ufj0VZB7wIyGC886czqHoc=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 4 Jul 2020 22:31:22 +0900", "Message-Id": "<20200704133140.1738660-5-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.27.0", "In-Reply-To": "<20200704133140.1738660-1-paul.elder@ideasonboard.com>", "References": "<20200704133140.1738660-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH v3 04/22] libcamera: V4L2VideoDevice: Add\n\ttryFormat", "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>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "libcamera-devel-bounces@lists.libcamera.org", "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>" }, "content": "Add tryFormat and its variations (meta, single-plane, multi-plane) to\nV4L2VideoDevice.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nNew in v3\n---\n include/libcamera/internal/v4l2_videodevice.h | 4 +\n src/libcamera/v4l2_videodevice.cpp | 121 ++++++++++++++++++\n 2 files changed, 125 insertions(+)", "diff": "diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 4d21f5a..56c3aee 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -186,6 +186,7 @@ public:\n \tconst V4L2Capability &caps() const { return caps_; }\n \n \tint getFormat(V4L2DeviceFormat *format);\n+\tint tryFormat(V4L2DeviceFormat *format);\n \tint setFormat(V4L2DeviceFormat *format);\n \tstd::map<V4L2PixelFormat, std::vector<SizeRange>> formats(uint32_t code = 0);\n \n@@ -217,12 +218,15 @@ protected:\n \n private:\n \tint getFormatMeta(V4L2DeviceFormat *format);\n+\tint tryFormatMeta(V4L2DeviceFormat *format);\n \tint setFormatMeta(V4L2DeviceFormat *format);\n \n \tint getFormatMultiplane(V4L2DeviceFormat *format);\n+\tint tryFormatMultiplane(V4L2DeviceFormat *format);\n \tint setFormatMultiplane(V4L2DeviceFormat *format);\n \n \tint getFormatSingleplane(V4L2DeviceFormat *format);\n+\tint tryFormatSingleplane(V4L2DeviceFormat *format);\n \tint setFormatSingleplane(V4L2DeviceFormat *format);\n \n \tstd::vector<V4L2PixelFormat> enumPixelformats(uint32_t code);\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 3614b2e..f25914c 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -723,6 +723,26 @@ int V4L2VideoDevice::getFormat(V4L2DeviceFormat *format)\n \t\treturn getFormatSingleplane(format);\n }\n \n+/**\n+ * \\brief Try an image format on the V4L2 video device\n+ * \\param[inout] format The image format to test applicablity to the video device\n+ *\n+ * Test if the supplied \\a format to the video device is acceptable, and return\n+ * the actually applied format parameters, as \\ref V4L2VideoDevice::tryFormat\n+ * would do.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2VideoDevice::tryFormat(V4L2DeviceFormat *format)\n+{\n+\tif (caps_.isMeta())\n+\t\treturn tryFormatMeta(format);\n+\telse if (caps_.isMultiplanar())\n+\t\treturn tryFormatMultiplane(format);\n+\telse\n+\t\treturn tryFormatSingleplane(format);\n+}\n+\n /**\n * \\brief Configure an image format on the V4L2 video device\n * \\param[inout] format The image format to apply to the video device\n@@ -765,6 +785,35 @@ int V4L2VideoDevice::getFormatMeta(V4L2DeviceFormat *format)\n \treturn 0;\n }\n \n+int V4L2VideoDevice::tryFormatMeta(V4L2DeviceFormat *format)\n+{\n+\tstruct v4l2_format v4l2Format = {};\n+\tstruct v4l2_meta_format *pix = &v4l2Format.fmt.meta;\n+\tint ret;\n+\n+\tv4l2Format.type = bufferType_;\n+\tpix->dataformat = format->fourcc;\n+\tpix->buffersize = format->planes[0].size;\n+\tret = ioctl(VIDIOC_TRY_FMT, &v4l2Format);\n+\tif (ret) {\n+\t\tLOG(V4L2, Error) << \"Unable to try format: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\t/*\n+\t * Return to caller the format actually applied on the video device,\n+\t * which might differ from the requested one.\n+\t */\n+\tformat->size.width = 0;\n+\tformat->size.height = 0;\n+\tformat->fourcc = V4L2PixelFormat(pix->dataformat);\n+\tformat->planesCount = 1;\n+\tformat->planes[0].bpl = pix->buffersize;\n+\tformat->planes[0].size = pix->buffersize;\n+\n+\treturn 0;\n+}\n+\n int V4L2VideoDevice::setFormatMeta(V4L2DeviceFormat *format)\n {\n \tstruct v4l2_format v4l2Format = {};\n@@ -820,6 +869,46 @@ int V4L2VideoDevice::getFormatMultiplane(V4L2DeviceFormat *format)\n \treturn 0;\n }\n \n+int V4L2VideoDevice::tryFormatMultiplane(V4L2DeviceFormat *format)\n+{\n+\tstruct v4l2_format v4l2Format = {};\n+\tstruct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;\n+\tint ret;\n+\n+\tv4l2Format.type = bufferType_;\n+\tpix->width = format->size.width;\n+\tpix->height = format->size.height;\n+\tpix->pixelformat = format->fourcc;\n+\tpix->num_planes = format->planesCount;\n+\tpix->field = V4L2_FIELD_NONE;\n+\n+\tfor (unsigned int i = 0; i < pix->num_planes; ++i) {\n+\t\tpix->plane_fmt[i].bytesperline = format->planes[i].bpl;\n+\t\tpix->plane_fmt[i].sizeimage = format->planes[i].size;\n+\t}\n+\n+\tret = ioctl(VIDIOC_TRY_FMT, &v4l2Format);\n+\tif (ret) {\n+\t\tLOG(V4L2, Error) << \"Unable to try format: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\t/*\n+\t * Return to caller the format actually applied on the video device,\n+\t * which might differ from the requested one.\n+\t */\n+\tformat->size.width = pix->width;\n+\tformat->size.height = pix->height;\n+\tformat->fourcc = V4L2PixelFormat(pix->pixelformat);\n+\tformat->planesCount = pix->num_planes;\n+\tfor (unsigned int i = 0; i < format->planesCount; ++i) {\n+\t\tformat->planes[i].bpl = pix->plane_fmt[i].bytesperline;\n+\t\tformat->planes[i].size = pix->plane_fmt[i].sizeimage;\n+\t}\n+\n+\treturn 0;\n+}\n+\n int V4L2VideoDevice::setFormatMultiplane(V4L2DeviceFormat *format)\n {\n \tstruct v4l2_format v4l2Format = {};\n@@ -883,6 +972,38 @@ int V4L2VideoDevice::getFormatSingleplane(V4L2DeviceFormat *format)\n \treturn 0;\n }\n \n+int V4L2VideoDevice::tryFormatSingleplane(V4L2DeviceFormat *format)\n+{\n+\tstruct v4l2_format v4l2Format = {};\n+\tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n+\tint ret;\n+\n+\tv4l2Format.type = bufferType_;\n+\tpix->width = format->size.width;\n+\tpix->height = format->size.height;\n+\tpix->pixelformat = format->fourcc;\n+\tpix->bytesperline = format->planes[0].bpl;\n+\tpix->field = V4L2_FIELD_NONE;\n+\tret = ioctl(VIDIOC_TRY_FMT, &v4l2Format);\n+\tif (ret) {\n+\t\tLOG(V4L2, Error) << \"Unable to try format: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\t/*\n+\t * Return to caller the format actually applied on the device,\n+\t * which might differ from the requested one.\n+\t */\n+\tformat->size.width = pix->width;\n+\tformat->size.height = pix->height;\n+\tformat->fourcc = V4L2PixelFormat(pix->pixelformat);\n+\tformat->planesCount = 1;\n+\tformat->planes[0].bpl = pix->bytesperline;\n+\tformat->planes[0].size = pix->sizeimage;\n+\n+\treturn 0;\n+}\n+\n int V4L2VideoDevice::setFormatSingleplane(V4L2DeviceFormat *format)\n {\n \tstruct v4l2_format v4l2Format = {};\n", "prefixes": [ "libcamera-devel", "v3", "04/22" ] }