Show a patch.

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

{
    "id": 1153,
    "url": "https://patchwork.libcamera.org/api/patches/1153/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/1153/",
    "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": "<20190503153403.8728-2-kieran.bingham@ideasonboard.com>",
    "date": "2019-05-03T15:34:02",
    "name": "[libcamera-devel,1/2] libcamera: v4l2_device: Add tryFormat support",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "23332d8daeafc8810537f2ff849958c7c5526b58",
    "submitter": {
        "id": 4,
        "url": "https://patchwork.libcamera.org/api/people/4/?format=api",
        "name": "Kieran Bingham",
        "email": "kieran.bingham@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/1153/mbox/",
    "series": [
        {
            "id": 292,
            "url": "https://patchwork.libcamera.org/api/series/292/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=292",
            "date": "2019-05-03T15:34:01",
            "name": "V4L2Device Try format support",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/292/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/1153/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/1153/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 DF9CD60E63\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  3 May 2019 17:34:10 +0200 (CEST)",
            "from Q.Home (unknown [IPv6:2a02:c7f:1887:5d00:c990:5ff4:193b:c9b8])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6B32C510;\n\tFri,  3 May 2019 17:34:09 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1556897649;\n\tbh=KSkQX1KCvGAAaCPbYyIs5Id7UtuHmaWkt2eOdAzQE5Q=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=PCQqx3vCyc2jh5Bn8VnhCKY8WHWyctz0Zb1GZydO7nkwzaqd3Q5kid4RMDD/nCXRq\n\tmfztG812sXCROuPneoxDKE/2N57PaoEnpKeTdFZgA+y6uUJF2+p/COKQh7msaBMUf1\n\tSRon6WsEk87rFBm61DEdEghWGdwT3McFkIJzmEV0=",
        "From": "Kieran Bingham <kieran.bingham@ideasonboard.com>",
        "To": "LibCamera Devel <libcamera-devel@lists.libcamera.org>",
        "Date": "Fri,  3 May 2019 16:34:02 +0100",
        "Message-Id": "<20190503153403.8728-2-kieran.bingham@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190503153403.8728-1-kieran.bingham@ideasonboard.com>",
        "References": "<20190503153403.8728-1-kieran.bingham@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 1/2] libcamera: v4l2_device: Add tryFormat\n\tsupport",
        "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 15:34:11 -0000"
    },
    "content": "Extend the internal functionality of setFormat{Single,Multi}plane to\nallow 'trying' a format. This provides the facility of checking a format\nwith the driver before committing to it.\n\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/libcamera/include/v4l2_device.h |  7 +++++--\n src/libcamera/v4l2_device.cpp       | 29 +++++++++++++++++++++++------\n 2 files changed, 28 insertions(+), 8 deletions(-)",
    "diff": "diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex 2e7bd1e7f4cc..a08615c3bd9a 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -126,6 +126,7 @@ public:\n \n \tint getFormat(V4L2DeviceFormat *format);\n \tint setFormat(V4L2DeviceFormat *format);\n+\tint tryFormat(V4L2DeviceFormat *format);\n \n \tint exportBuffers(BufferPool *pool);\n \tint importBuffers(BufferPool *pool);\n@@ -145,10 +146,12 @@ protected:\n \n private:\n \tint getFormatSingleplane(V4L2DeviceFormat *format);\n-\tint setFormatSingleplane(V4L2DeviceFormat *format);\n+\tint trySetFormatSingleplane(V4L2DeviceFormat *format,\n+\t\t\t\t    unsigned long request);\n \n \tint getFormatMultiplane(V4L2DeviceFormat *format);\n-\tint setFormatMultiplane(V4L2DeviceFormat *format);\n+\tint trySetFormatMultiplane(V4L2DeviceFormat *format,\n+\t\t\t\t   unsigned long request);\n \n \tint requestBuffers(unsigned int count);\n \tint createPlane(Buffer *buffer, unsigned int plane,\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 1bbf79673c16..d965c7226b04 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -434,8 +434,23 @@ int V4L2Device::getFormat(V4L2DeviceFormat *format)\n  */\n int V4L2Device::setFormat(V4L2DeviceFormat *format)\n {\n-\treturn caps_.isMultiplanar() ? setFormatMultiplane(format) :\n-\t\t\t\t       setFormatSingleplane(format);\n+\treturn caps_.isMultiplanar() ? trySetFormatMultiplane(format, VIDIOC_S_FMT) :\n+\t\t\t\t       trySetFormatSingleplane(format, VIDIOC_S_FMT);\n+}\n+\n+/**\n+ * \\brief Validate an image format on the V4L2 device\n+ * \\param[inout] format The image format to apply to the device\n+ *\n+ * Try the supplied \\a format on the device, and return the format parameters\n+ * that would have been applied, as \\ref V4L2Device::setFormat would do.\n+ *\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2Device::tryFormat(V4L2DeviceFormat *format)\n+{\n+\treturn caps_.isMultiplanar() ? trySetFormatMultiplane(format, VIDIOC_TRY_FMT) :\n+\t\t\t\t       trySetFormatSingleplane(format, VIDIOC_TRY_FMT);\n }\n \n int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)\n@@ -462,7 +477,8 @@ int V4L2Device::getFormatSingleplane(V4L2DeviceFormat *format)\n \treturn 0;\n }\n \n-int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)\n+int V4L2Device::trySetFormatSingleplane(V4L2DeviceFormat *format,\n+\t\t\t\t\tunsigned long request)\n {\n \tstruct v4l2_format v4l2Format = {};\n \tstruct v4l2_pix_format *pix = &v4l2Format.fmt.pix;\n@@ -475,7 +491,7 @@ int V4L2Device::setFormatSingleplane(V4L2DeviceFormat *format)\n \tpix->bytesperline = format->planes[0].bpl;\n \tpix->field = V4L2_FIELD_NONE;\n \n-\tret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);\n+\tret = ioctl(fd_, request, &v4l2Format);\n \tif (ret) {\n \t\tret = -errno;\n \t\tLOG(V4L2, Error) << \"Unable to set format: \" << strerror(-ret);\n@@ -523,7 +539,8 @@ int V4L2Device::getFormatMultiplane(V4L2DeviceFormat *format)\n \treturn 0;\n }\n \n-int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n+int V4L2Device::trySetFormatMultiplane(V4L2DeviceFormat *format,\n+\t\t\t\t       unsigned long request)\n {\n \tstruct v4l2_format v4l2Format = {};\n \tstruct v4l2_pix_format_mplane *pix = &v4l2Format.fmt.pix_mp;\n@@ -541,7 +558,7 @@ int V4L2Device::setFormatMultiplane(V4L2DeviceFormat *format)\n \t\tpix->plane_fmt[i].sizeimage = format->planes[i].size;\n \t}\n \n-\tret = ioctl(fd_, VIDIOC_S_FMT, &v4l2Format);\n+\tret = ioctl(fd_, request, &v4l2Format);\n \tif (ret) {\n \t\tret = -errno;\n \t\tLOG(V4L2, Error) << \"Unable to set format: \" << strerror(-ret);\n",
    "prefixes": [
        "libcamera-devel",
        "1/2"
    ]
}