{"id":2065,"url":"https://patchwork.libcamera.org/api/1.1/patches/2065/?format=json","web_url":"https://patchwork.libcamera.org/patch/2065/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20190929190254.18920-11-laurent.pinchart@ideasonboard.com>","date":"2019-09-29T19:02:51","name":"[libcamera-devel,v2,10/13] libcamera: v4l2_controls: Use the ControlRange class for control info","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"9d2f1b783fbf27d4d5f99fa2d476444ab2f539f5","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2065/mbox/","series":[{"id":512,"url":"https://patchwork.libcamera.org/api/1.1/series/512/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=512","date":"2019-09-29T19:02:41","name":"Improve the application-facing controls API","version":2,"mbox":"https://patchwork.libcamera.org/series/512/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2065/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2065/checks/","tags":{},"headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AE47761656\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 29 Sep 2019 21:03:14 +0200 (CEST)","from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4A3F1A28\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 29 Sep 2019 21:03:14 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1569783794;\n\tbh=1JBHVC3zgWeqhxg+KpD/3fDP3piOGg+VVu2VfNKAqgg=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=tn7mv2m9DNfXvohzPHtSqUe+BbA/YE/3dCTaP6OW6QYo1VRqC6dQNHL3ll64ygOtC\n\tTywjmUdO4ZCFCh3oRu3v2AtaCftf/VP1vmYguOt1Mu+DOI9u7WtdcB5vdIywbFoiSy\n\t8BWb3pduPkOnds+GjtDyOxpo1LMW2prkoG0+iaLM=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Sun, 29 Sep 2019 22:02:51 +0300","Message-Id":"<20190929190254.18920-11-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.21.0","In-Reply-To":"<20190929190254.18920-1-laurent.pinchart@ideasonboard.com>","References":"<20190929190254.18920-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2 10/13] libcamera: v4l2_controls: Use\n\tthe ControlRange class for 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":"Sun, 29 Sep 2019 19:03:15 -0000"},"content":"Use the ControlRange class to express the range of a V4L2 control,\nreplacing the open-coded minimum and maximum fields in the\nV4L2ControlInfo class.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/libcamera/include/v4l2_controls.h |  6 ++----\n src/libcamera/pipeline/uvcvideo.cpp   |  2 +-\n src/libcamera/pipeline/vimc.cpp       |  2 +-\n src/libcamera/v4l2_controls.cpp       | 21 ++++++++++-----------\n 4 files changed, 14 insertions(+), 17 deletions(-)","diff":"diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\nindex f2b67c5d44e1..b39370b2e90e 100644\n--- a/src/libcamera/include/v4l2_controls.h\n+++ b/src/libcamera/include/v4l2_controls.h\n@@ -30,8 +30,7 @@ public:\n \tsize_t size() const { return size_; }\n \tconst std::string &name() const { return name_; }\n \n-\tint64_t min() const { return min_; }\n-\tint64_t max() const { return max_; }\n+\tconst ControlRange &range() const { return range_; }\n \n private:\n \tunsigned int id_;\n@@ -39,8 +38,7 @@ private:\n \tsize_t size_;\n \tstd::string name_;\n \n-\tint64_t min_;\n-\tint64_t max_;\n+\tControlRange range_;\n };\n \n using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;\ndiff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\nindex 860578d41875..88f7fb9bc568 100644\n--- a/src/libcamera/pipeline/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo.cpp\n@@ -364,7 +364,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.min(), info.max()));\n+\t\t\t\t     std::forward_as_tuple(info.range()));\n \t}\n \n \treturn 0;\ndiff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\nindex b2b36b238809..26477dccbb8f 100644\n--- a/src/libcamera/pipeline/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc.cpp\n@@ -437,7 +437,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.min(), info.max()));\n+\t\t\t\t     std::forward_as_tuple(info.range()));\n \t}\n \n \treturn 0;\ndiff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\nindex 64f0555fff7c..6f5f1578b139 100644\n--- a/src/libcamera/v4l2_controls.cpp\n+++ b/src/libcamera/v4l2_controls.cpp\n@@ -74,8 +74,13 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n \ttype_ = ctrl.type;\n \tname_ = static_cast<const char *>(ctrl.name);\n \tsize_ = ctrl.elem_size * ctrl.elems;\n-\tmin_ = ctrl.minimum;\n-\tmax_ = ctrl.maximum;\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+\telse\n+\t\trange_ = ControlRange(static_cast<int32_t>(ctrl.minimum),\n+\t\t\t\t      static_cast<int32_t>(ctrl.maximum));\n }\n \n /**\n@@ -103,15 +108,9 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n  */\n \n /**\n- * \\fn V4L2ControlInfo::min()\n- * \\brief Retrieve the control minimum value\n- * \\return The V4L2 control minimum value\n- */\n-\n-/**\n- * \\fn V4L2ControlInfo::max()\n- * \\brief Retrieve the control maximum value\n- * \\return The V4L2 control maximum value\n+ * \\fn V4L2ControlInfo::range()\n+ * \\brief Retrieve the control value range\n+ * \\return The V4L2 control value range\n  */\n \n /**\n","prefixes":["libcamera-devel","v2","10/13"]}