Patch Detail
Show a patch.
GET /api/1.1/patches/2768/?format=api
{ "id": 2768, "url": "https://patchwork.libcamera.org/api/1.1/patches/2768/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2768/", "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": "<20200204112444.8395-1-naush@raspberrypi.com>", "date": "2020-02-04T11:24:44", "name": "[libcamera-devel,v3] libcamera: v4l2_videodevice: Add crop/selection control.", "commit_ref": "ea3a00bc33f950c794e8b6d8cf0201a24c0c3d0d", "pull_url": null, "state": "accepted", "archived": false, "hash": "709deea2dc4b69e6ba9b94babe64619f684ae2dc", "submitter": { "id": 34, "url": "https://patchwork.libcamera.org/api/1.1/people/34/?format=api", "name": "Naushir Patuck", "email": "naush@raspberrypi.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2768/mbox/", "series": [ { "id": 659, "url": "https://patchwork.libcamera.org/api/1.1/series/659/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=659", "date": "2020-02-04T11:24:44", "name": "[libcamera-devel,v3] libcamera: v4l2_videodevice: Add crop/selection control.", "version": 3, "mbox": "https://patchwork.libcamera.org/series/659/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2768/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2768/checks/", "tags": {}, "headers": { "Return-Path": "<naush@raspberrypi.com>", "Received": [ "from mail-wm1-x341.google.com (mail-wm1-x341.google.com\n\t[IPv6:2a00:1450:4864:20::341])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A905E60445\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 4 Feb 2020 12:26:47 +0100 (CET)", "by mail-wm1-x341.google.com with SMTP id a9so3152870wmj.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 04 Feb 2020 03:26:47 -0800 (PST)", "from naushir-VirtualBox.pitowers.org (cust51-dsl50.idnet.net.\n\t[212.69.50.51]) by smtp.gmail.com with ESMTPSA id\n\tp7sm3280187wmp.31.2020.02.04.03.26.46\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 04 Feb 2020 03:26:46 -0800 (PST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id;\n\tbh=YI/5KwC4FYG4B34Fr9E1MoGFP89Pz0rzIYpQIGKf9GU=;\n\tb=JBWnrICciFMJvEJmZGaUYO/UPXC7M14uB+cfUQGdUpp3KK3z3yAbVecT1kX2i3mxu5\n\teau6TJwuftKNCKmPiTNXOK9sNNujNyurEU1auOg5aRcR8lOZAYGY/xC+/n1643BvmFbB\n\tNXddTQ49YamFDnCYHQC9E4aA+0qgwIFHRIvsc13O2klE7p9yVa+/Xu53z4ccWzkc3LTY\n\tOZv51axsj64VuoUwNzLmoC6CgtLwQLYtv08CWWbgnGrHwqKgTKOoWTcUclQ0nKnaRB+k\n\tsB2q+uRFktHZry/oHvgNs/ifUpVaF/Jiljbq+zgmJD/aAHfG7C0R1azHD7IpuKOLoVcd\n\tSGXg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id;\n\tbh=YI/5KwC4FYG4B34Fr9E1MoGFP89Pz0rzIYpQIGKf9GU=;\n\tb=N9FWX3QNv9++OdwDTCv+XZS50zy+q6VZ80Oi7iYHxg50BAk4cUSE/HyY5tzEXEUu2/\n\tTnz9IA43k1FISv70HpsKfjaIM38B8H8iwm9st6SGgi9Mt7YnLnGI8ZIs3VypUAeMtTSh\n\tobdHmPiKngY1+66dbmhJlXjp2/AfvqOSjY8ffWHKWiDgTMPyQ+tw1VNZg2KV0kgXaiFk\n\tYa24Z2uadciyufCjS2J8B4/ricIQpXXI/9+uv4yWxOkFzWgywgCdH5dxLvKBkg3FWCTM\n\tEQxcqiunkMoHaOTPlyrVhVle1F2iPoklfFfQkwxMSar32qAKyl/o4SJIJEL8zmRU5WNG\n\te2pA==", "X-Gm-Message-State": "APjAAAXVADB8js30B9YgLrwXp5jzO7XPe1vWz8z6OBep/Czw+/lHbQSh\n\tpmoRG7G1d+Svyb+43J+Rlkb/C1XAK7+xGw==", "X-Google-Smtp-Source": "APXvYqzFgxdOq22Yvlk+VL2kfhAtf7Fw9gQV1TBAbre1/wdiwwMTGfFeSzcKepvFadt1wgAts2TvNA==", "X-Received": "by 2002:a05:600c:299:: with SMTP id\n\t25mr5443902wmk.68.1580815607004; \n\tTue, 04 Feb 2020 03:26:47 -0800 (PST)", "From": "Naushir Patuck <naush@raspberrypi.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 4 Feb 2020 11:24:44 +0000", "Message-Id": "<20200204112444.8395-1-naush@raspberrypi.com>", "X-Mailer": "git-send-email 2.17.1", "Subject": "[libcamera-devel] [PATCH v3] libcamera: v4l2_videodevice: Add\n\tcrop/selection control.", "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>", "X-List-Received-Date": "Tue, 04 Feb 2020 11:26:47 -0000" }, "content": "Add control for cropping/selection on a V4L2 video device through\nthe VIDIOC_S_SELECTION ioctl. This is similar to the existing cropping\ncontrol available on V4L2 sub-devices.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_videodevice.h | 5 +++\n src/libcamera/v4l2_videodevice.cpp | 48 ++++++++++++++++++++++++\n 2 files changed, 53 insertions(+)", "diff": "diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\nindex e4d35ab..fcf0726 100644\n--- a/src/libcamera/include/v4l2_videodevice.h\n+++ b/src/libcamera/include/v4l2_videodevice.h\n@@ -182,6 +182,9 @@ public:\n \tint setFormat(V4L2DeviceFormat *format);\n \tImageFormats formats();\n \n+\tint setCrop(Rectangle *rect);\n+\tint setCompose(Rectangle *rect);\n+\n \tint exportBuffers(unsigned int count,\n \t\t\t std::vector<std::unique_ptr<FrameBuffer>> *buffers);\n \tint importBuffers(unsigned int count);\n@@ -216,6 +219,8 @@ private:\n \tstd::vector<unsigned int> enumPixelformats();\n \tstd::vector<SizeRange> enumSizes(unsigned int pixelFormat);\n \n+\tint setSelection(unsigned int target, Rectangle *rect);\n+\n \tint requestBuffers(unsigned int count);\n \tstd::unique_ptr<FrameBuffer> createBuffer(const struct v4l2_buffer &buf);\n \tFileDescriptor exportDmabufFd(unsigned int index, unsigned int plane);\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 8226773..f3c66ed 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -940,6 +940,54 @@ std::vector<SizeRange> V4L2VideoDevice::enumSizes(unsigned int pixelFormat)\n \treturn sizes;\n }\n \n+/**\n+ * \\brief Set a crop rectangle on the V4L2 video device node\n+ * \\param[inout] rect The rectangle describing the crop target area\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2VideoDevice::setCrop(Rectangle *rect)\n+{\n+\treturn setSelection(V4L2_SEL_TGT_CROP, rect);\n+}\n+\n+/**\n+ * \\brief Set a compose rectangle on the V4L2 video device node\n+ * \\param[inout] rect The rectangle describing the compose target area\n+ * \\return 0 on success or a negative error code otherwise\n+ */\n+int V4L2VideoDevice::setCompose(Rectangle *rect)\n+{\n+\treturn setSelection(V4L2_SEL_TGT_COMPOSE, rect);\n+}\n+\n+int V4L2VideoDevice::setSelection(unsigned int target, Rectangle *rect)\n+{\n+\tstruct v4l2_selection sel = {};\n+\n+\tsel.type = bufferType_;\n+\tsel.target = target;\n+\tsel.flags = 0;\n+\n+\tsel.r.left = rect->x;\n+\tsel.r.top = rect->y;\n+\tsel.r.width = rect->w;\n+\tsel.r.height = rect->h;\n+\n+\tint ret = ioctl(VIDIOC_S_SELECTION, &sel);\n+\tif (ret < 0) {\n+\t\tLOG(V4L2, Error) << \"Unable to set rectangle \" << target\n+\t\t\t\t << \": \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\trect->x = sel.r.left;\n+\trect->y = sel.r.top;\n+\trect->w = sel.r.width;\n+\trect->h = sel.r.height;\n+\n+\treturn 0;\n+}\n+\n int V4L2VideoDevice::requestBuffers(unsigned int count)\n {\n \tstruct v4l2_requestbuffers rb = {};\n", "prefixes": [ "libcamera-devel", "v3" ] }