Patch Detail
Show a patch.
GET /api/1.1/patches/3953/?format=api
{ "id": 3953, "url": "https://patchwork.libcamera.org/api/1.1/patches/3953/?format=api", "web_url": "https://patchwork.libcamera.org/patch/3953/", "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": "<20200605142037.50260-1-jacopo@jmondi.org>", "date": "2020-06-05T14:20:37", "name": "[libcamera-devel,RFC] libcamera: v4l2_device: Update control info", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "a10b2e6705fa4e90e69894ddaf539e709d304986", "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/3953/mbox/", "series": [ { "id": 959, "url": "https://patchwork.libcamera.org/api/1.1/series/959/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=959", "date": "2020-06-05T14:20:37", "name": "[libcamera-devel,RFC] libcamera: v4l2_device: Update control info", "version": 1, "mbox": "https://patchwork.libcamera.org/series/959/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/3953/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/3953/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 42994603C6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 5 Jun 2020 16:17:41 +0200 (CEST)", "from localhost.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id BF5EF20006;\n\tFri, 5 Jun 2020 14:17:40 +0000 (UTC)" ], "X-Originating-IP": "93.34.118.233", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 5 Jun 2020 16:20:37 +0200", "Message-Id": "<20200605142037.50260-1-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.27.0", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [RFC] libcamera: v4l2_device: Update control info", "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": "Fri, 05 Jun 2020 14:17:41 -0000" }, "content": "Setting controls on a V4L2 device might update the limits of other\nrelated controls (in example, setting a new vertical/horizontal blanking\nvalue might modify the available exposure time duration).\n\nAdd a funtion to update the ControlInfo that represents a control\nminimum, maximum and default values and call it after a new control has\nbeen set and format is changed on a V4L2 subdevice.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n\nWe'll soon need something like that.\nHowever, seems like an expensive operation to perform after every control\nand format update.\n\nOpinions ?\n\n---\n include/libcamera/controls.h | 4 ++\n include/libcamera/internal/v4l2_device.h | 2 +\n src/libcamera/controls.cpp | 18 +++++++++\n src/libcamera/v4l2_device.cpp | 48 ++++++++++++++++++++++++\n src/libcamera/v4l2_subdevice.cpp | 3 ++\n 5 files changed, 75 insertions(+)\n\n--\n2.27.0", "diff": "diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\nindex 80944efc133a..74b0c6b26517 100644\n--- a/include/libcamera/controls.h\n+++ b/include/libcamera/controls.h\n@@ -273,6 +273,10 @@ public:\n \tconst ControlValue &max() const { return max_; }\n \tconst ControlValue &def() const { return def_; }\n\n+\tvoid setMin(ControlValue val) { min_ = val; }\n+\tvoid setMax(ControlValue val) { max_ = val; }\n+\tvoid setDef(ControlValue val) { def_ = val; }\n+\n \tstd::string toString() const;\n\n \tbool operator==(const ControlInfo &other) const\ndiff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h\nindex d491eafd262e..1563ec7272c7 100644\n--- a/include/libcamera/internal/v4l2_device.h\n+++ b/include/libcamera/internal/v4l2_device.h\n@@ -42,6 +42,8 @@ protected:\n\n \tint fd() { return fd_; }\n\n+\tvoid updateControlsInfo();\n+\n private:\n \tvoid listControls();\n \tvoid updateControls(ControlList *ctrls,\ndiff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\nindex dca782667d88..f92128dd1878 100644\n--- a/src/libcamera/controls.cpp\n+++ b/src/libcamera/controls.cpp\n@@ -519,6 +519,24 @@ ControlInfo::ControlInfo(const ControlValue &min,\n * \\return A ControlValue with the default value for the control\n */\n\n+/**\n+ * \\fn ControlInfo::setMin()\n+ * \\brief Set the minimum value for the control\n+ * \\param[in] val The control minimum value\n+ */\n+\n+/**\n+ * \\fn ControlInfo::setMax()\n+ * \\brief Set the maximum value for the control\n+ * \\param[in] val The control maximum value\n+ */\n+\n+/**\n+ * \\fn ControlInfo::setDef()\n+ * \\brief Set the default value for the control\n+ * \\param[in] val The control default value\n+ */\n+\n /**\n * \\brief Provide a string representation of the ControlInfo\n */\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 56ea1ddda2c1..7e1286d7ddd0 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -346,6 +346,7 @@ int V4L2Device::setControls(ControlList *ctrls)\n \t}\n\n \tupdateControls(ctrls, v4l2Ctrls, count);\n+\tupdateControlsInfo();\n\n \treturn ret;\n }\n@@ -380,6 +381,53 @@ int V4L2Device::ioctl(unsigned long request, void *argp)\n * \\return The V4L2 device file descriptor, -1 if the device node is not open\n */\n\n+/**\n+ * \\brief Update the control info\n+ *\n+ * Update all control limits (min and max) and default value.\n+ */\n+void V4L2Device::updateControlsInfo()\n+{\n+\tfor (auto &it : controls_) {\n+\t\tconst ControlId *id = it.first;\n+\t\tControlInfo &info = it.second;\n+\t\tstruct v4l2_query_ext_ctrl ctrl = {};\n+\t\tctrl.id = id->id();\n+\t\tint ret = ioctl(VIDIOC_QUERY_EXT_CTRL, &ctrl);\n+\t\tif (ret) {\n+\t\t\tLOG(V4L2, Error) << \"Unable to query control \"\n+\t\t\t\t\t << ctrl.id << \": \" << strerror(-ret);\n+\t\t\treturn;\n+\t\t}\n+\n+\t\tswitch (ctrl.type) {\n+\t\tcase V4L2_CTRL_TYPE_U8:\n+\t\t\tinfo.setMin({ static_cast<uint8_t>(ctrl.minimum) });\n+\t\t\tinfo.setMax({ static_cast<uint8_t>(ctrl.maximum) });\n+\t\t\tinfo.setDef({ static_cast<uint8_t>(ctrl.default_value) });\n+\t\t\tbreak;\n+\n+\t\tcase V4L2_CTRL_TYPE_BOOLEAN:\n+\t\t\tinfo.setMin({ static_cast<bool>(ctrl.minimum) });\n+\t\t\tinfo.setMax({ static_cast<bool>(ctrl.maximum) });\n+\t\t\tinfo.setDef({ static_cast<bool>(ctrl.default_value) });\n+\t\t\tbreak;\n+\n+\t\tcase V4L2_CTRL_TYPE_INTEGER64:\n+\t\t\tinfo.setMin({ static_cast<bool>(ctrl.minimum) });\n+\t\t\tinfo.setMax({ static_cast<bool>(ctrl.maximum) });\n+\t\t\tinfo.setDef({ static_cast<bool>(ctrl.default_value) });\n+\t\t\tbreak;\n+\n+\t\tdefault:\n+\t\t\tinfo.setMin({ static_cast<bool>(ctrl.minimum) });\n+\t\t\tinfo.setMax({ static_cast<bool>(ctrl.maximum) });\n+\t\t\tinfo.setDef({ static_cast<bool>(ctrl.default_value) });\n+\t\t\tbreak;\n+\t\t}\n+\t}\n+}\n+\n /*\n * \\brief List and store information about all controls supported by the\n * V4L2 device\ndiff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\nindex 7aefc1be032d..c0dc036a09cc 100644\n--- a/src/libcamera/v4l2_subdevice.cpp\n+++ b/src/libcamera/v4l2_subdevice.cpp\n@@ -411,6 +411,9 @@ int V4L2Subdevice::setFormat(unsigned int pad, V4L2SubdeviceFormat *format,\n \tformat->size.height = subdevFmt.format.height;\n \tformat->mbus_code = subdevFmt.format.code;\n\n+\t/* Changing the format could update the contol limits. */\n+\tupdateControlsInfo();\n+\n \treturn 0;\n }\n\n", "prefixes": [ "libcamera-devel", "RFC" ] }