Patch Detail
Show a patch.
GET /api/1.1/patches/3570/?format=api
{ "id": 3570, "url": "https://patchwork.libcamera.org/api/1.1/patches/3570/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3570/", "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": "<20200427213236.333777-2-jacopo@jmondi.org>", "date": "2020-04-27T21:32:30", "name": "[libcamera-devel,v4,1/7] libcamera: v4l2_subdevice: Expose setSelection()", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "c8534474464bc08d6eff25e8ee3d1af2ea1cf369", "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/3570/mbox/", "series": [ { "id": 837, "url": "https://patchwork.libcamera.org/api/1.1/series/837/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=837", "date": "2020-04-27T21:32:29", "name": "libcamera: Add CameraSensorInfo", "version": 4, "mbox": "https://patchwork.libcamera.org/series/837/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3570/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3570/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DEC3860AFA\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 27 Apr 2020 23:29:32 +0200 (CEST)", "from uno.homenet.telecomitalia.it (a-ur1-85.tin.it\n\t[212.216.150.148]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 2DA5140009;\n\tMon, 27 Apr 2020 21:29:31 +0000 (UTC)" ], "X-Originating-IP": "212.216.150.148", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 27 Apr 2020 23:32:30 +0200", "Message-Id": "<20200427213236.333777-2-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.26.1", "In-Reply-To": "<20200427213236.333777-1-jacopo@jmondi.org>", "References": "<20200427213236.333777-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 1/7] libcamera: v4l2_subdevice: Expose\n\tsetSelection()", "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": "Mon, 27 Apr 2020 21:29:33 -0000" }, "content": "Expose V4L2Subdevice::setSelection() method and drop\nV4L2Subdevice::setCrop() and V4L2Subdevice::setComopse() as wrapping\neach target with a single function does not provide any benefit.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_subdevice.h | 7 +--\n src/libcamera/pipeline/ipu3/ipu3.cpp | 4 +-\n src/libcamera/v4l2_subdevice.cpp | 76 ++++++++++----------------\n 3 files changed, 34 insertions(+), 53 deletions(-)", "diff": "diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex 4a04eadfb1f9..9a5c812db9b6 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -46,8 +46,8 @@ public:\n \n \tconst MediaEntity *entity() const { return entity_; }\n \n-\tint setCrop(unsigned int pad, Rectangle *rect);\n-\tint setCompose(unsigned int pad, Rectangle *rect);\n+\tint setSelection(unsigned int pad, unsigned int target,\n+\t\t\t Rectangle *rect);\n \n \tImageFormats formats(unsigned int pad);\n \n@@ -67,9 +67,6 @@ private:\n \tstd::vector<SizeRange> enumPadSizes(unsigned int pad,\n \t\t\t\t\t unsigned int code);\n \n-\tint setSelection(unsigned int pad, unsigned int target,\n-\t\t\t Rectangle *rect);\n-\n \tconst MediaEntity *entity_;\n };\n \ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex b45900159d06..ff33f15f9eac 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -1135,11 +1135,11 @@ int ImgUDevice::configureInput(const Size &size,\n \t\t.width = inputFormat->size.width,\n \t\t.height = inputFormat->size.height,\n \t};\n-\tret = imgu_->setCrop(PAD_INPUT, &rect);\n+\tret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_CROP, &rect);\n \tif (ret)\n \t\treturn ret;\n \n-\tret = imgu_->setCompose(PAD_INPUT, &rect);\n+\tret = imgu_->setSelection(PAD_INPUT, V4L2_SEL_TGT_COMPOSE, &rect);\n \tif (ret)\n \t\treturn ret;\n \ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 5a479a96b795..432e89eacbd3 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -134,27 +134,42 @@ int V4L2Subdevice::open()\n */\n \n /**\n- * \\brief Set a crop rectangle on one of the V4L2 subdevice pads\n+ * \\brief Set selection rectangle \\a rect for \\a target\n * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\n- * \\param[inout] rect The rectangle describing crop target area\n+ * \\param[in] target The selection target defined by the V4L2_SEL_TGT_* flags\n+ * \\param[inout] rect The selection rectangle to be applied\n * \\return 0 on success or a negative error code otherwise\n */\n-int V4L2Subdevice::setCrop(unsigned int pad, Rectangle *rect)\n+int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n+\t\t\t\tRectangle *rect)\n {\n-\treturn setSelection(pad, V4L2_SEL_TGT_CROP, rect);\n-}\n+\tstruct v4l2_subdev_selection sel = {};\n \n-/**\n- * \\brief Set a compose rectangle on one of the V4L2 subdevice pads\n- * \\param[in] pad The 0-indexed pad number the rectangle is to be applied to\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 V4L2Subdevice::setCompose(unsigned int pad, Rectangle *rect)\n-{\n-\treturn setSelection(pad, V4L2_SEL_TGT_COMPOSE, rect);\n-}\n+\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n+\tsel.pad = pad;\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->width;\n+\tsel.r.height = rect->height;\n+\n+\tint ret = ioctl(VIDIOC_SUBDEV_S_SELECTION, &sel);\n+\tif (ret < 0) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n+\t\t\t<< pad << \": \" << strerror(-ret);\n+\t\treturn ret;\n+\t}\n+\n+\trect->x = sel.r.left;\n+\trect->y = sel.r.top;\n+\trect->width = sel.r.width;\n+\trect->height = sel.r.height;\n+\n+\treturn 0;\n+}\n /**\n * \\brief Enumerate all media bus codes and frame sizes on a \\a pad\n * \\param[in] pad The 0-indexed pad number to enumerate formats on\n@@ -343,35 +358,4 @@ std::vector<SizeRange> V4L2Subdevice::enumPadSizes(unsigned int pad,\n \treturn sizes;\n }\n \n-int V4L2Subdevice::setSelection(unsigned int pad, unsigned int target,\n-\t\t\t\tRectangle *rect)\n-{\n-\tstruct v4l2_subdev_selection sel = {};\n-\n-\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n-\tsel.pad = pad;\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->width;\n-\tsel.r.height = rect->height;\n-\n-\tint ret = ioctl(VIDIOC_SUBDEV_S_SELECTION, &sel);\n-\tif (ret < 0) {\n-\t\tLOG(V4L2, Error)\n-\t\t\t<< \"Unable to set rectangle \" << target << \" on pad \"\n-\t\t\t<< pad << \": \" << strerror(-ret);\n-\t\treturn ret;\n-\t}\n-\n-\trect->x = sel.r.left;\n-\trect->y = sel.r.top;\n-\trect->width = sel.r.width;\n-\trect->height = sel.r.height;\n-\n-\treturn 0;\n-}\n-\n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v4", "1/7" ] }