Show a patch.

GET /api/patches/1158/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1158,
    "url": "https://patchwork.libcamera.org/api/patches/1158/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1158/",
    "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": "<20190503175158.15035-1-kieran.bingham@ideasonboard.com>",
    "date": "2019-05-03T17:51:58",
    "name": "[libcamera-devel] libcamera: v4l2_device: Enumerate Formats",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "9285415d8de9ac8355cfc4ad02e4c4da74655743",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": {
        "id": 11,
        "url": "https://patchwork.libcamera.org/api/users/11/?format=api",
        "username": "kbingham",
        "first_name": "Kieran",
        "last_name": "Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "mbox": "https://patchwork.libcamera.org/patch/1158/mbox/",
    "series": [
        {
            "id": 296,
            "url": "https://patchwork.libcamera.org/api/series/296/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=296",
            "date": "2019-05-03T17:51:58",
            "name": "[libcamera-devel] libcamera: v4l2_device: Enumerate Formats",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/296/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1158/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1158/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<kieran.bingham@ideasonboard.com>",
        "Received": [
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 72C0B60003\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 May 2019 19:52:02 +0200 (CEST)",
            "from Q.Home (unknown [IPv6:2a02:c7f:1887:5d00:c990:5ff4:193b:c9b8])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CFB4731E;\n\tFri,  3 May 2019 19:52:01 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1556905921;\n\tbh=zNJGJxpOWEj23Mp7+tRn/mmxD3ZLAnp2Zg70dVwcNLs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=pxMOZf1Z22rch6DSGk5u4wkxpYKMZpociZ/9zeG63n31ziityP5VHHvBvWf0mwvzP\n\tLy85hT+agSvDXkrtmzJkNCC+ocF0YczIR/xKSJAQoKThQACnbgl1jjs9gaiH0LutKh\n\tGP/AnH+Yd6VNoQZxpj4vy9Mvtv9SGK5bULztNYsE=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Fri,  3 May 2019 18:51:58 +0100",
        "Message-Id": "<20190503175158.15035-1-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190503171319.GD4903@pendragon.ideasonboard.com>",
        "References": "<20190503171319.GD4903@pendragon.ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH] libcamera: v4l2_device: Enumerate Formats",
        "X-BeenThere": "libcamera-devel@lists.libcamera.org",
        "X-Mailman-Version": "2.1.23",
        "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>",
        "X-List-Received-Date": "Fri, 03 May 2019 17:52:02 -0000"
    },
    "content": "Provide a means to enumerate the supported formats on a device and\nreturn a FormatEnum of the results.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/include/v4l2_device.h |  5 ++\n src/libcamera/v4l2_device.cpp       | 93 +++++++++++++++++++++++++++++\n 2 files changed, 98 insertions(+)\n\nThis is an untested method for enumerating frame sizes from a V4L2Device.\nIt might warrant some updates to use the new Size type.",
    "diff": "diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 2e7bd1e7f4cc..87c2aa35bd5c 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -16,6 +16,7 @@\n #include <libcamera/geometry.h>\n #include <libcamera/signal.h>\n \n+#include \"formats.h\"\n #include \"log.h\"\n \n namespace libcamera {\n@@ -124,6 +125,7 @@ public:\n \tconst char *busName() const { return caps_.bus_info(); }\n \tconst std::string &deviceNode() const { return deviceNode_; }\n \n+\tFormatEnum formats(void);\n \tint getFormat(V4L2DeviceFormat *format);\n \tint setFormat(V4L2DeviceFormat *format);\n \n@@ -144,6 +146,9 @@ protected:\n \tstd::string logPrefix() const;\n \n private:\n+\tint enumerateFrameSizes(unsigned int pixelFormat,\n+\t\t\t\tstd::vector<SizeRange> *sizes);\n+\n \tint getFormatSingleplane(V4L2DeviceFormat *format);\n \tint setFormatSingleplane(V4L2DeviceFormat *format);\n \ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 8366ffc4db55..12b622ba8db5 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -412,6 +412,99 @@ std::string V4L2Device::logPrefix() const\n \treturn deviceNode_ + (V4L2_TYPE_IS_OUTPUT(bufferType_) ? \"[out]\" : \"[cap]\");\n }\n \n+int V4L2Device::enumerateFrameSizes(unsigned int pixelFormat,\n+\t\t\t\t    std::vector<SizeRange> *sizes)\n+{\n+\tstruct v4l2_frmsizeenum sizeEnum = {};\n+\tint ret;\n+\n+\tsizeEnum.index = 0;\n+\tsizeEnum.pixel_format = pixelFormat;\n+\n+\twhile (true) {\n+\t\tret = ioctl(fd_, VIDIOC_ENUM_FRAMESIZES, &sizeEnum);\n+\t\tif (ret)\n+\t\t\tbreak;\n+\n+\t\tswitch (sizeEnum.type) {\n+\t\tcase V4L2_FRMSIZE_TYPE_DISCRETE:\n+\t\t\tsizes->emplace_back(sizeEnum.discrete.width, sizeEnum.discrete.height,\n+\t\t\t\t\t    sizeEnum.discrete.width, sizeEnum.discrete.height);\n+\t\t\tbreak;\n+\n+\t\tcase V4L2_FRMSIZE_TYPE_CONTINUOUS:\n+\t\tcase V4L2_FRMSIZE_TYPE_STEPWISE:\n+\t\t\tsizes->emplace_back(sizeEnum.stepwise.min_width, sizeEnum.stepwise.min_height,\n+\t\t\t\t\t    sizeEnum.stepwise.max_width, sizeEnum.stepwise.max_height);\n+\t\t\t/*\n+\t\t\t * TODO: How do we handle the {step_width,step_height}\n+\t\t\t * parameters here\n+\t\t\t */\n+\t\t\tbreak;\n+\t\tdefault:\n+\t\t\tbreak;\n+\t\t}\n+\n+\t\tsizeEnum.index++;\n+\t}\n+\n+\tif (ret && (errno != EINVAL && errno != ENOTTY)) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Unable to enumerate frame sizes\"\n+\t\t\t<< \": \" << strerror(-ret);\n+\t\tsizes->clear();\n+\n+\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+/**\n+ * \\brief List the device image resolutions and formats on \\a pad\n+ *\n+ * Retrieve a list of image formats and sizes available on the video device.\n+ *\n+ * Each image size list is associated with a pixel format code for which\n+ * the reported resolutions are supported.\n+ *\n+ * \\return A map of image formats associated with a list of image sizes, or\n+ * an empty map on error.\n+ */\n+FormatEnum V4L2Device::formats(void)\n+{\n+\tFormatEnum formatMap = {};\n+\tstruct v4l2_fmtdesc v4l2FormatDesc = {};\n+\tint ret;\n+\n+\tv4l2FormatDesc.index = 0;\n+\tv4l2FormatDesc.type = bufferType_;\n+\n+\twhile (true) {\n+\t\tret = ioctl(fd_, VIDIOC_ENUM_FMT, &v4l2FormatDesc);\n+\t\tif (ret)\n+\t\t\tbreak;\n+\n+\t\tret = enumerateFrameSizes(v4l2FormatDesc.pixelformat,\n+\t\t\t\t\t  &formatMap[v4l2FormatDesc.pixelformat]);\n+\t\tif (ret)\n+\t\t\tbreak;\n+\n+\t\tv4l2FormatDesc.index++;\n+\t}\n+\n+\tif (ret && (errno != EINVAL && errno != ENOTTY)) {\n+\t\tret = -errno;\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Unable to enumerate device formats\"\n+\t\t\t<< \": \" << strerror(-ret);\n+\t\tformatMap.clear();\n+\t}\n+\n+\treturn formatMap;\n+}\n+\n /**\n  * \\brief Retrieve the image format set on the V4L2 device\n  * \\param[out] format The image format applied on the device\n",
    "prefixes": [
        "libcamera-devel"
    ]
}