Show a patch.

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

{
    "id": 303,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/303/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/303/",
    "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": "<20190121172705.19985-3-jacopo@jmondi.org>",
    "date": "2019-01-21T17:27:01",
    "name": "[libcamera-devel,2/6] libcamera: v4l2_device: Add setControl function",
    "commit_ref": null,
    "pull_url": null,
    "state": "rejected",
    "archived": false,
    "hash": "f55413d1990692b292c1ccda3e4946ee1992ae60",
    "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/303/mbox/",
    "series": [
        {
            "id": 105,
            "url": "https://patchwork.libcamera.org/api/1.1/series/105/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=105",
            "date": "2019-01-21T17:26:59",
            "name": "libcamera: Augment V4L2 device",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/105/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/303/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/303/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<jacopo@jmondi.org>",
        "Received": [
            "from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F62160C96\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jan 2019 18:27:04 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id BBFD91BF206;\n\tMon, 21 Jan 2019 17:27:03 +0000 (UTC)"
        ],
        "X-Originating-IP": "2.224.242.101",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 21 Jan 2019 18:27:01 +0100",
        "Message-Id": "<20190121172705.19985-3-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20190121172705.19985-1-jacopo@jmondi.org>",
        "References": "<20190121172705.19985-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 2/6] libcamera: v4l2_device: Add\n\tsetControl function",
        "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": "Mon, 21 Jan 2019 17:27:04 -0000"
    },
    "content": "Add function to set controls on a V4L2Device object.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_device.h |  2 ++\n src/libcamera/v4l2_device.cpp       | 38 +++++++++++++++++++++++++++++\n 2 files changed, 40 insertions(+)",
    "diff": "diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\nindex c6f3d9a..2787847 100644\n--- a/src/libcamera/include/v4l2_device.h\n+++ b/src/libcamera/include/v4l2_device.h\n@@ -51,6 +51,8 @@ public:\n \tconst char *deviceName() const { return caps_.card(); }\n \tconst char *busName() const { return caps_.bus_info(); }\n \n+\tint setControl(unsigned int control, int value);\n+\n private:\n \tstd::string devnode_;\n \tint fd_;\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 59a1ad9..aef0996 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -195,4 +195,42 @@ void V4L2Device::close()\n  * \\return The string containing the device location\n  */\n \n+/**\n+ * \\brief Set a control value\n+ * \\param control The control identifier\n+ * \\param value The new control value\n+ *\n+ * Set a user control to the requested value. The function returns the\n+ * new value actually assigned to the control, which might be different\n+ * from the requested \\a value one.\n+ *\n+ * \\return The new control's value for success, or a negative error code otherwise\n+ */\n+int V4L2Device::setControl(unsigned int control, int value)\n+{\n+\tstruct v4l2_control v4l2_ctrl = {\n+\t\t.id = control,\n+\t\t.value = value,\n+\t};\n+\n+\tint ret = ioctl(fd_, VIDIOC_S_CTRL, &v4l2_ctrl);\n+\tif (ret) {\n+\t\tret = -errno;\n+\t\tLOG(Error) << \"Failed to set control: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\tv4l2_ctrl = { };\n+\tv4l2_ctrl.id = control;\n+\n+\tret = ioctl(fd_, VIDIOC_G_CTRL, &v4l2_ctrl);\n+\tif (ret) {\n+\t\tret = -errno;\n+\t\tLOG(Error) << \"Failed to get control: \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\treturn v4l2_ctrl.value;\n+}\n+\n } /* namespace libcamera */\n",
    "prefixes": [
        "libcamera-devel",
        "2/6"
    ]
}