Patch Detail
Show a patch.
GET /api/1.1/patches/1862/?format=api
{ "id": 1862, "url": "https://patchwork.libcamera.org/api/1.1/patches/1862/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1862/", "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": "<20190827095008.11405-7-jacopo@jmondi.org>", "date": "2019-08-27T09:50:06", "name": "[libcamera-devel,v2,6/7] libcamera: v4l2_subdevice: Add selection support", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "b630ae1cd028e8debaa94e10630931674550d059", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": { "id": 15, "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api", "username": "jmondi", "first_name": "Jacopo", "last_name": "Mondi", "email": "jacopo@jmondi.org" }, "mbox": "https://patchwork.libcamera.org/patch/1862/mbox/", "series": [ { "id": 468, "url": "https://patchwork.libcamera.org/api/1.1/series/468/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=468", "date": "2019-08-27T09:50:00", "name": "libcamera: camera_sensor: Collect camera location and sizes", "version": 2, "mbox": "https://patchwork.libcamera.org/series/468/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1862/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1862/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D41C160C1E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 27 Aug 2019 11:48:48 +0200 (CEST)", "from uno.homenet.telecomitalia.it (unknown [87.18.63.98])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 30201100008;\n\tTue, 27 Aug 2019 09:48:48 +0000 (UTC)" ], "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 27 Aug 2019 11:50:06 +0200", "Message-Id": "<20190827095008.11405-7-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20190827095008.11405-1-jacopo@jmondi.org>", "References": "<20190827095008.11405-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 6/7] libcamera: v4l2_subdevice: Add\n\tselection support", "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, 27 Aug 2019 09:48:49 -0000" }, "content": "Currently the selection API are implemented by wrappers of the\nsetSelection method. As we add support for more targets, adding new\nwrapper does not scale well. Make the setSelection operation public and\nimplement getSelection, and require callers to specify the selection\ntarget in the operation parameters list.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_subdevice.h | 9 +-\n src/libcamera/pipeline/ipu3/ipu3.cpp | 4 +-\n src/libcamera/v4l2_subdevice.cpp | 113 ++++++++++++++++---------\n 3 files changed, 78 insertions(+), 48 deletions(-)", "diff": "diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\nindex 9c077674f997..b69b93280894 100644\n--- a/src/libcamera/include/v4l2_subdevice.h\n+++ b/src/libcamera/include/v4l2_subdevice.h\n@@ -41,8 +41,10 @@ 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 getSelection(unsigned int pad, unsigned int target,\n+\t\t\t 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@@ -60,9 +62,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 827906d5cd2e..bd027c7f10be 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -1071,11 +1071,11 @@ int ImgUDevice::configureInput(const Size &size,\n \t\t.w = inputFormat->size.width,\n \t\t.h = 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 a188298de34c..262dfa23ee57 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -127,25 +127,87 @@ int V4L2Subdevice::open()\n */\n \n /**\n- * \\brief Set a crop 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 crop target area\n+ * \\brief Get the V4L2_SEL_TGT_* selection \\a target rectangle on \\a pad\n+ * \\param[in] pad The 0-indexed pad number to get the selection target from\n+ * \\param[in] target The selection target V4L2_SEL_TGT_* as defined by the V4L2\n+ * selection API\n+ * \\param[out] rect The rectangle describing the returned selection target\n+ *\n+ * This operations wraps the VIDIOC_SUBDEV_G_SELECTION ioctl, applied to one of\n+ * the V4L2_SEL_TGT_* targets defined by the V4L2 API on the subdevice \\a pad.\n+ * The retrieved selection rectangle is returned in the output parameter \\a\n+ * rect.\n+ *\n * \\return 0 on success or a negative error code otherwise\n */\n-int V4L2Subdevice::setCrop(unsigned int pad, Rectangle *rect)\n+int V4L2Subdevice::getSelection(unsigned int pad, unsigned int target,\n+\t\t\t\tRectangle *rect)\n {\n-\treturn setSelection(pad, V4L2_SEL_TGT_CROP, rect);\n+\tstruct v4l2_subdev_selection sel = {};\n+\n+\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n+\tsel.pad = pad;\n+\tsel.target = target;\n+\n+\tint ret = ioctl(VIDIOC_SUBDEV_G_SELECTION, &sel);\n+\tif (ret < 0) {\n+\t\tLOG(V4L2, Error)\n+\t\t\t<< \"Unable to get 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->w = sel.r.width;\n+\trect->h = sel.r.height;\n+\n+\treturn 0;\n }\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+ * \\brief Set the V4L2_SEL_TGT_* selection \\a target rectangle on \\a pad\n+ * \\param[in] pad The 0-indexed pad number to set the selection target on\n+ * \\param[in] target The selection target V4L2_SEL_TGT_* as defined by the V4L2\n+ * selection API\n+ * \\param[inout] rect The rectangle to be applied to the the selection \\a target\n+ *\n+ * This operations wraps the VIDIOC_SUBDEV_S_SELECTION ioctl, applied to one of\n+ * the V4L2_SEL_TGT_* targets defined by the V4L2 API on the subdevice \\a pad.\n+ * The selection rectangle to apply is described by the parameter \\a rect,\n+ * which is updated to reflect what has been actually applied on the subdevice\n+ * when the method returns.\n+ *\n * \\return 0 on success or a negative error code otherwise\n */\n-int V4L2Subdevice::setCompose(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_COMPOSE, rect);\n+\tstruct v4l2_subdev_selection sel = {};\n+\n+\tsel.which = V4L2_SUBDEV_FORMAT_ACTIVE;\n+\tsel.pad = pad;\n+\tsel.target = target;\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_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->w = sel.r.width;\n+\trect->h = sel.r.height;\n+\n+\treturn 0;\n }\n \n /**\n@@ -329,35 +391,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->w;\n-\tsel.r.height = rect->h;\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->w = sel.r.width;\n-\trect->h = sel.r.height;\n-\n-\treturn 0;\n-}\n-\n } /* namespace libcamera */\n", "prefixes": [ "libcamera-devel", "v2", "6/7" ] }