Show a patch.

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

{
    "id": 585,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/585/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/585/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20190219165620.2385-2-jacopo@jmondi.org>",
    "date": "2019-02-19T16:56:18",
    "name": "[libcamera-devel,1/3] libcamera: v4l2_subdevice: Implement ENUM_FRAME_SIZES",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "60d3d2e87fc7bfe0a216335ce61904af08cf3a7d",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/585/mbox/",
    "series": [
        {
            "id": 185,
            "url": "https://patchwork.libcamera.org/api/1.1/series/185/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=185",
            "date": "2019-02-19T16:56:17",
            "name": "libcamera: v4l2_subdev and v4l2_device mixed",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/185/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/585/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/585/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net\n\t[217.70.183.196])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A23FC600FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 19 Feb 2019 17:56:02 +0100 (CET)",
            "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 242C2E000D;\n\tTue, 19 Feb 2019 16:56:01 +0000 (UTC)"
        ],
        "X-Originating-IP": "2.224.242.101",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 19 Feb 2019 17:56:18 +0100",
        "Message-Id": "<20190219165620.2385-2-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190219165620.2385-1-jacopo@jmondi.org>",
        "References": "<20190219165620.2385-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/3] libcamera: v4l2_subdevice: Implement\n\tENUM_FRAME_SIZES",
        "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": "Tue, 19 Feb 2019 16:56:02 -0000"
    },
    "content": "Implement enumFormat() methods to enumerate the available image\nresolutions on the subdevice.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_subdevice.h | 11 ++++\n src/libcamera/v4l2_subdevice.cpp       | 90 ++++++++++++++++++++++++++\n 2 files changed, 101 insertions(+)",
    "diff": "diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex 82fa6685ab52..c7045776555c 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -14,6 +14,16 @@ namespace libcamera {\n class MediaEntity;\n struct Rectangle;\n \n+struct V4L2SubdeviceFormatEnum {\n+\tunsigned int index;\n+\tuint32_t mbus_code;\n+\n+\tuint32_t minWidth;\n+\tuint32_t maxWidth;\n+\tuint32_t minHeight;\n+\tuint32_t maxHeight;\n+};\n+\n struct V4L2SubdeviceFormat {\n \tuint32_t mbus_code;\n \tuint32_t width;\n@@ -36,6 +46,7 @@ public:\n \tint setCrop(unsigned int pad, Rectangle *rect);\n \tint setCompose(unsigned int pad, Rectangle *rect);\n \n+\tint enumFormat(unsigned int pad, V4L2SubdeviceFormatEnum *formatEnum);\n \tint getFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n \tint setFormat(unsigned int pad, V4L2SubdeviceFormat *format);\n \ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex b436f73cc75f..5665154a2762 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -26,6 +26,52 @@ namespace libcamera {\n \n LOG_DEFINE_CATEGORY(V4L2Subdev)\n \n+/**\n+ * \\struct V4L2SubdeviceFormatEnum\n+ * \\brief The V4L2 sub-device image size enumeration\n+ *\n+ * This structure describes an image resolution as enumerated by the V4L2\n+ * sub-device. The structure is used as format exchange between the caller and\n+ * the enumFormat() method. The caller is responsible to fill the media bus\n+ * code to use and the index of the format to be enumerated.\n+ */\n+\n+/**\n+ * \\var V4L2SubdeviceFormatEnum::index\n+ * \\brief The index of the format to be enumerated\n+ */\n+\n+/**\n+ * \\var V4L2SubdeviceFormatEnum::mbus_code\n+ * \\brief The pixel format identification code for the formats to enumerate\n+ *\n+ * \\sa V4L2SubdeviceFormat for media bus format pixel code description.\n+ */\n+\n+/**\n+ * \\var V4L2SubdeviceFormatEnum::minWidth\n+ * \\brief The minimum width of the enumerated format as reported by the V4L2\n+ * sub-device\n+ */\n+\n+/**\n+ * \\var V4L2SubdeviceFormatEnum::maxWidth\n+ * \\brief The maximum width of the enumerated format as reported by the V4L2\n+ * sub-device\n+ */\n+\n+/**\n+ * \\var V4L2SubdeviceFormatEnum::minHeight\n+ * \\brief The minimum height of the enumerated format as reported by the V4L2\n+ * sub-device\n+ */\n+\n+/**\n+ * \\var V4L2SubdeviceFormatEnum::maxHeight\n+ * \\brief The maximum height of the enumerated format as reported by the V4L2\n+ * sub-device\n+ */\n+\n /**\n  * \\struct V4L2SubdeviceFormat\n  * \\brief The V4L2 sub-device image format and sizes\n@@ -171,6 +217,50 @@ int V4L2Subdevice::setCompose(unsigned int pad, Rectangle *rect)\n \treturn setSelection(pad, V4L2_SEL_TGT_COMPOSE, rect);\n }\n \n+/**\n+ * \\brief Enumerate the sub-device image resolutions\n+ * \\param[in] pad The 0-indexed pad number to enumerate formats on\n+ * \\param[inout] formatEnum The format enumeration description\n+ *\n+ * The method retrieve the image resolution of the image format with index\n+ * formatEnum.index for the pixel format specified by formatEnum.mbus_code.\n+ *\n+ * To enumerate image resolutions, the caller shall start enumerating all\n+ * formats by setting the formatEnum.index field to 0, and increasing it by\n+ * one for any successive call, until the -EINVAL return code is returned.\n+ *\n+ * \\return 0 on success, or a negative error code otherwise\n+ */\n+int V4L2Subdevice::enumFormat(unsigned int pad,\n+\t\t\t      V4L2SubdeviceFormatEnum *formatEnum)\n+{\n+\tstruct v4l2_subdev_frame_size_enum sizeEnum = {};\n+\n+\tsizeEnum.index = formatEnum->index;\n+\tsizeEnum.code = formatEnum->mbus_code;\n+\tsizeEnum.pad = pad;\n+\tsizeEnum.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n+\n+\tint ret = ioctl(fd_, VIDIOC_SUBDEV_ENUM_FRAME_SIZE, &sizeEnum);\n+\tif (ret) {\n+\t\tret = -errno;\n+\t\tif (ret == -EINVAL)\n+\t\t\treturn ret;\n+\n+\t\tLOG(V4L2Subdev, Error)\n+\t\t\t<< \"Unable to enumerate format on pad \" << pad\n+\t\t\t<< \" of \" << deviceNode_ << \": \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tformatEnum->maxWidth = sizeEnum.max_width;\n+\tformatEnum->minWidth = sizeEnum.min_width;\n+\tformatEnum->maxHeight = sizeEnum.max_height;\n+\tformatEnum->minHeight = sizeEnum.min_height;\n+\n+\treturn 0;\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",
    "prefixes": [
        "libcamera-devel",
        "1/3"
    ]
}