Patch Detail
Show a patch.
GET /api/1.1/patches/2188/?format=api
{ "id": 2188, "url": "https://patchwork.libcamera.org/api/1.1/patches/2188/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2188/", "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": "<20191013232755.3292-7-laurent.pinchart@ideasonboard.com>", "date": "2019-10-13T23:27:52", "name": "[libcamera-devel,06/10] libcamera: v4l2_controls: Replace V4L2ControlInfo with V4L2ControlRange", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "288fc96238018251679f7a880e5ac241da47abe8", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2188/mbox/", "series": [ { "id": 534, "url": "https://patchwork.libcamera.org/api/1.1/series/534/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=534", "date": "2019-10-13T23:27:46", "name": "Merge V4L2ControlInfoMap and ControlInfoMap", "version": 1, "mbox": "https://patchwork.libcamera.org/series/534/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2188/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2188/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C85AE6196E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Oct 2019 01:28:04 +0200 (CEST)", "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 738A280B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Oct 2019 01:28:04 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1571009284;\n\tbh=2207Q+vgrysFUFCGDBxd6SzFiHatE8Q74PP4SpXJ+RM=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=fE1m8gKYDCoFJkhW1pmVHCfpk9Hn16ZXM4hzJZ6RLgf9sBXqWV/SBkmpfbTpouYQS\n\tq8VJxk4ddtHrNw3ILRJ95irzhD6phYacWSJJJ6aO9JepxDekHxu0yFtxXs9+B/mNO/\n\t4CS2hUHoXB1sqp6W+si3XHqn/ZsQS+YIW9G2WtLc=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 14 Oct 2019 02:27:52 +0300", "Message-Id": "<20191013232755.3292-7-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20191013232755.3292-1-laurent.pinchart@ideasonboard.com>", "References": "<20191013232755.3292-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 06/10] libcamera: v4l2_controls: Replace\n\tV4L2ControlInfo with V4L2ControlRange", "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": "Sun, 13 Oct 2019 23:28:06 -0000" }, "content": "The V4L2ControlInfo class only stores a ControlRange. Make it inherit\nfrom ControlRange to provide a convenience constructor from a struct\nv4l2_query_ext_ctrl and rename it to V4L2ControlRange.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/ipa/rkisp1/rkisp1.cpp | 8 ++---\n src/libcamera/include/v4l2_controls.h | 43 ++++++++++++---------------\n src/libcamera/pipeline/uvcvideo.cpp | 4 +--\n src/libcamera/pipeline/vimc.cpp | 4 +--\n src/libcamera/v4l2_controls.cpp | 30 ++++++++-----------\n src/libcamera/v4l2_device.cpp | 2 +-\n test/v4l2_videodevice/controls.cpp | 24 +++++++--------\n 7 files changed, 52 insertions(+), 63 deletions(-)", "diff": "diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\nindex 13059d99036c..d64c334cbf0c 100644\n--- a/src/ipa/rkisp1/rkisp1.cpp\n+++ b/src/ipa/rkisp1/rkisp1.cpp\n@@ -83,12 +83,12 @@ void IPARkISP1::configure(const std::map<unsigned int, IPAStream> &streamConfig,\n \n \tautoExposure_ = true;\n \n-\tminExposure_ = std::max<uint32_t>(itExp->second.range().min().get<int32_t>(), 1);\n-\tmaxExposure_ = itExp->second.range().max().get<int32_t>();\n+\tminExposure_ = std::max<uint32_t>(itExp->second.min().get<int32_t>(), 1);\n+\tmaxExposure_ = itExp->second.max().get<int32_t>();\n \texposure_ = minExposure_;\n \n-\tminGain_ = std::max<uint32_t>(itGain->second.range().min().get<int32_t>(), 1);\n-\tmaxGain_ = itGain->second.range().max().get<int32_t>();\n+\tminGain_ = std::max<uint32_t>(itGain->second.min().get<int32_t>(), 1);\n+\tmaxGain_ = itGain->second.max().get<int32_t>();\n \tgain_ = minGain_;\n \n \tLOG(IPARkISP1, Info)\ndiff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\nindex ca7217501256..741569824b68 100644\n--- a/src/libcamera/include/v4l2_controls.h\n+++ b/src/libcamera/include/v4l2_controls.h\n@@ -25,38 +25,33 @@ public:\n \tV4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl);\n };\n \n-class V4L2ControlInfo\n+class V4L2ControlRange : public ControlRange\n {\n public:\n-\tV4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);\n-\n-\tconst ControlRange &range() const { return range_; }\n-\n-private:\n-\tControlRange range_;\n+\tV4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl);\n };\n \n-class V4L2ControlInfoMap : private std::map<const ControlId *, V4L2ControlInfo>\n+class V4L2ControlInfoMap : private std::map<const ControlId *, V4L2ControlRange>\n {\n public:\n-\tV4L2ControlInfoMap &operator=(std::map<const ControlId *, V4L2ControlInfo> &&info);\n+\tV4L2ControlInfoMap &operator=(std::map<const ControlId *, V4L2ControlRange> &&info);\n \n-\tusing std::map<const ControlId *, V4L2ControlInfo>::key_type;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::mapped_type;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::value_type;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::size_type;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::iterator;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::const_iterator;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::key_type;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::mapped_type;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::value_type;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::size_type;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::iterator;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::const_iterator;\n \n-\tusing std::map<const ControlId *, V4L2ControlInfo>::begin;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::cbegin;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::end;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::cend;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::at;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::empty;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::size;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::count;\n-\tusing std::map<const ControlId *, V4L2ControlInfo>::find;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::begin;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::cbegin;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::end;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::cend;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::at;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::empty;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::size;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::count;\n+\tusing std::map<const ControlId *, V4L2ControlRange>::find;\n \n \tmapped_type &at(unsigned int key);\n \tconst mapped_type &at(unsigned int key) const;\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 4d76b5fd9347..7356585b982e 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -337,7 +337,7 @@ int UVCCameraData::init(MediaEntity *entity)\n \t/* Initialise the supported controls. */\n \tconst V4L2ControlInfoMap &controls = video_->controls();\n \tfor (const auto &ctrl : controls) {\n-\t\tconst V4L2ControlInfo &info = ctrl.second;\n+\t\tconst V4L2ControlRange &range = ctrl.second;\n \t\tconst ControlId *id;\n \n \t\tswitch (ctrl.first->id()) {\n@@ -362,7 +362,7 @@ int UVCCameraData::init(MediaEntity *entity)\n \n \t\tcontrolInfo_.emplace(std::piecewise_construct,\n \t\t\t\t std::forward_as_tuple(id),\n-\t\t\t\t std::forward_as_tuple(info.range()));\n+\t\t\t\t std::forward_as_tuple(range));\n \t}\n \n \treturn 0;\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex 78c0fe5ae509..87e7e54e964f 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -413,7 +413,7 @@ int VimcCameraData::init(MediaDevice *media)\n \t/* Initialise the supported controls. */\n \tconst V4L2ControlInfoMap &controls = sensor_->controls();\n \tfor (const auto &ctrl : controls) {\n-\t\tconst V4L2ControlInfo &info = ctrl.second;\n+\t\tconst V4L2ControlRange &range = ctrl.second;\n \t\tconst ControlId *id;\n \n \t\tswitch (ctrl.first->id()) {\n@@ -432,7 +432,7 @@ int VimcCameraData::init(MediaDevice *media)\n \n \t\tcontrolInfo_.emplace(std::piecewise_construct,\n \t\t\t\t std::forward_as_tuple(id),\n-\t\t\t\t std::forward_as_tuple(info.range()));\n+\t\t\t\t std::forward_as_tuple(range));\n \t}\n \n \treturn 0;\ndiff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\nindex 9a5e4830db91..4aab34b9a2b4 100644\n--- a/src/libcamera/v4l2_controls.cpp\n+++ b/src/libcamera/v4l2_controls.cpp\n@@ -104,14 +104,14 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl)\n }\n \n /**\n- * \\class V4L2ControlInfo\n+ * \\class V4L2ControlRange\n * \\brief Information on a V4L2 control\n *\n- * The V4L2ControlInfo class represents all the information related to a V4L2\n+ * The V4L2ControlRange class represents all the information related to a V4L2\n * control, such as its ID, its type, its user-readable name and the expected\n * size of its value data.\n *\n- * V4L2ControlInfo instances are created by inspecting the fieldS of a struct\n+ * V4L2ControlRange instances are created by inspecting the fieldS of a struct\n * v4l2_query_ext_ctrl structure, after it has been filled by the device driver\n * as a consequence of a VIDIOC_QUERY_EXT_CTRL ioctl call.\n *\n@@ -121,28 +121,22 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl)\n */\n \n /**\n- * \\brief Construct a V4L2ControlInfo from a struct v4l2_query_ext_ctrl\n+ * \\brief Construct a V4L2ControlRange from a struct v4l2_query_ext_ctrl\n * \\param[in] ctrl The struct v4l2_query_ext_ctrl as returned by the kernel\n */\n-V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n+V4L2ControlRange::V4L2ControlRange(const struct v4l2_query_ext_ctrl &ctrl)\n {\n \tif (ctrl.type == V4L2_CTRL_TYPE_INTEGER64)\n-\t\trange_ = ControlRange(static_cast<int64_t>(ctrl.minimum),\n-\t\t\t\t static_cast<int64_t>(ctrl.maximum));\n+\t\tControlRange::operator=(ControlRange(static_cast<int64_t>(ctrl.minimum),\n+\t\t\t\t\t\t static_cast<int64_t>(ctrl.maximum)));\n \telse\n-\t\trange_ = ControlRange(static_cast<int32_t>(ctrl.minimum),\n-\t\t\t\t static_cast<int32_t>(ctrl.maximum));\n+\t\tControlRange::operator=(ControlRange(static_cast<int32_t>(ctrl.minimum),\n+\t\t\t\t\t\t static_cast<int32_t>(ctrl.maximum)));\n }\n \n-/**\n- * \\fn V4L2ControlInfo::range()\n- * \\brief Retrieve the control value range\n- * \\return The V4L2 control value range\n- */\n-\n /**\n * \\class V4L2ControlInfoMap\n- * \\brief A map of controlID to V4L2ControlInfo\n+ * \\brief A map of controlID to V4L2ControlRange\n */\n \n /**\n@@ -156,9 +150,9 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n *\n * \\return The populated V4L2ControlInfoMap\n */\n-V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map<const ControlId *, V4L2ControlInfo> &&info)\n+V4L2ControlInfoMap &V4L2ControlInfoMap::operator=(std::map<const ControlId *, V4L2ControlRange> &&info)\n {\n-\tstd::map<const ControlId *, V4L2ControlInfo>::operator=(std::move(info));\n+\tstd::map<const ControlId *, V4L2ControlRange>::operator=(std::move(info));\n \n \tidmap_.clear();\n \tfor (const auto &ctrl : *this)\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex 4bb7d5950f3a..133f8abc8f13 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -342,7 +342,7 @@ int V4L2Device::ioctl(unsigned long request, void *argp)\n */\n void V4L2Device::listControls()\n {\n-\tstd::map<const ControlId *, V4L2ControlInfo> ctrls;\n+\tstd::map<const ControlId *, V4L2ControlRange> ctrls;\n \tstruct v4l2_query_ext_ctrl ctrl = {};\n \n \t/* \\todo Add support for menu and compound controls. */\ndiff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp\nindex 3add6e67d2cf..d4b7588eb362 100644\n--- a/test/v4l2_videodevice/controls.cpp\n+++ b/test/v4l2_videodevice/controls.cpp\n@@ -41,9 +41,9 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tconst V4L2ControlInfo &brightness = info.find(V4L2_CID_BRIGHTNESS)->second;\n-\t\tconst V4L2ControlInfo &contrast = info.find(V4L2_CID_CONTRAST)->second;\n-\t\tconst V4L2ControlInfo &saturation = info.find(V4L2_CID_SATURATION)->second;\n+\t\tconst V4L2ControlRange &brightness = info.find(V4L2_CID_BRIGHTNESS)->second;\n+\t\tconst V4L2ControlRange &contrast = info.find(V4L2_CID_CONTRAST)->second;\n+\t\tconst V4L2ControlRange &saturation = info.find(V4L2_CID_SATURATION)->second;\n \n \t\t/* Test getting controls. */\n \t\tV4L2ControlList ctrls(info);\n@@ -65,9 +65,9 @@ protected:\n \t\t}\n \n \t\t/* Test setting controls. */\n-\t\tctrls.set(V4L2_CID_BRIGHTNESS, brightness.range().min());\n-\t\tctrls.set(V4L2_CID_CONTRAST, contrast.range().max());\n-\t\tctrls.set(V4L2_CID_SATURATION, saturation.range().min());\n+\t\tctrls.set(V4L2_CID_BRIGHTNESS, brightness.min());\n+\t\tctrls.set(V4L2_CID_CONTRAST, contrast.max());\n+\t\tctrls.set(V4L2_CID_SATURATION, saturation.min());\n \n \t\tret = capture_->setControls(&ctrls);\n \t\tif (ret) {\n@@ -76,9 +76,9 @@ protected:\n \t\t}\n \n \t\t/* Test setting controls outside of range. */\n-\t\tctrls.set(V4L2_CID_BRIGHTNESS, brightness.range().min().get<int32_t>() - 1);\n-\t\tctrls.set(V4L2_CID_CONTRAST, contrast.range().max().get<int32_t>() + 1);\n-\t\tctrls.set(V4L2_CID_SATURATION, saturation.range().min().get<int32_t>() + 1);\n+\t\tctrls.set(V4L2_CID_BRIGHTNESS, brightness.min().get<int32_t>() - 1);\n+\t\tctrls.set(V4L2_CID_CONTRAST, contrast.max().get<int32_t>() + 1);\n+\t\tctrls.set(V4L2_CID_SATURATION, saturation.min().get<int32_t>() + 1);\n \n \t\tret = capture_->setControls(&ctrls);\n \t\tif (ret) {\n@@ -86,9 +86,9 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tif (ctrls.get(V4L2_CID_BRIGHTNESS) != brightness.range().min() ||\n-\t\t ctrls.get(V4L2_CID_CONTRAST) != contrast.range().max() ||\n-\t\t ctrls.get(V4L2_CID_SATURATION) != saturation.range().min().get<int32_t>() + 1) {\n+\t\tif (ctrls.get(V4L2_CID_BRIGHTNESS) != brightness.min() ||\n+\t\t ctrls.get(V4L2_CID_CONTRAST) != contrast.max() ||\n+\t\t ctrls.get(V4L2_CID_SATURATION) != saturation.min().get<int32_t>() + 1) {\n \t\t\tcerr << \"Controls not updated when set\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n", "prefixes": [ "libcamera-devel", "06/10" ] }