[{"id":2900,"web_url":"https://patchwork.libcamera.org/comment/2900/","msgid":"<20191015002630.GF5976@bigcity.dyn.berto.se>","date":"2019-10-15T00:26:30","subject":"Re: [libcamera-devel] [PATCH 06/10] libcamera: v4l2_controls:\n\tReplace V4L2ControlInfo with V4L2ControlRange","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your work.\n\nOn 2019-10-14 02:27:52 +0300, Laurent Pinchart wrote:\n> The V4L2ControlInfo class only stores a ControlRange. Make it inherit\n> from ControlRange to provide a convenience constructor from a struct\n> v4l2_query_ext_ctrl and rename it to V4L2ControlRange.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\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(-)\n> \n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index 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)\n> diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\n> index 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;\n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index 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;\n> diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> index 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;\n> diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\n> index 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)\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 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. */\n> diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lf1-x141.google.com (mail-lf1-x141.google.com\n\t[IPv6:2a00:1450:4864:20::141])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1C820600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Oct 2019 02:26:32 +0200 (CEST)","by mail-lf1-x141.google.com with SMTP id y127so13063990lfc.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Oct 2019 17:26:32 -0700 (PDT)","from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159])\n\tby smtp.gmail.com with ESMTPSA id\n\th12sm4488276ljg.24.2019.10.14.17.26.30\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 14 Oct 2019 17:26:30 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=ckzVSrFM7x0GLHRXDGl8QLFY7bq624Z12FLEL+oPFNE=;\n\tb=ZtNIemZsfdy0OIhDzkFS6cFVGuCW0orAukFVFxan2767OV9fJHiwBE3rwFBzvLLONH\n\tCICgAG0Pw65OKSnZTyF68PvAvVYWtTJvfSwww+UB2UfDe5fACuPuzUpi5UMc0BagKwc1\n\tMlCtPgrtWN0agTtAdeMy0uUotlB0jxZ2E4WecvezFU5FA9AvhbYWqwRZvXKHz6bnmg/E\n\tKoFG61NpjbfQHCKWBNjU2rMI4ngradlrknh+fueKxJspvUPVRi/DWYHNk+89M7U4nTXt\n\tngQ9Fj9qesOtmrgHeXf1GfkFUmr5uscbCT1Kx12Ywezi4sCbC5I4ZysqJnL6/mjRUxdS\n\tgxiw==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=ckzVSrFM7x0GLHRXDGl8QLFY7bq624Z12FLEL+oPFNE=;\n\tb=iIpa5pgjnpPmspfVY4Z8p2CkQo8zsZwM1eJIqzx+tJ/TglkoNaT9o/9EFaohZtf47O\n\tmrcy0cwKxOhjB3Gzm3UVmuk/UbtKTrXE5l0wFzNR+tfn1GSSao4qi6gTMd9W+xBCNw7K\n\tfeS2ScWbvZJl1mWJ4W8jpIp1A68vq+tVwnkrLhrlgdB3PODywe462xHidsoC/Bh/xb+X\n\trJxvusth2YMXXZQ2etZR2zjfDhOPdXRaUpsXbAGQuqxUS0n1PykdOmFRFWfnfDFyekw7\n\trh7NtUXLCWTqBCkmkKM9iphZzYHjTxLeuSCWww2Qa8ap4VIMyU4DgbU5IKg4zUBVuG7H\n\ty+cA==","X-Gm-Message-State":"APjAAAVUJqNEONSgACagLuw21bgRbRIuXH8UV8YfPgfCZl+dFMsS/ji/\n\tUkiDTODu3GA1sR54na4I23O+Uw==","X-Google-Smtp-Source":"APXvYqyy0nRZuCuqEwiU2JOqSC2N8Ytx8o//WURvXfHlweq7qizfqoda4kt4TeE/0vPoiJitigHB2g==","X-Received":"by 2002:a19:ee08:: with SMTP id\n\tg8mr14233949lfb.117.1571099191377; \n\tMon, 14 Oct 2019 17:26:31 -0700 (PDT)","Date":"Tue, 15 Oct 2019 02:26:30 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191015002630.GF5976@bigcity.dyn.berto.se>","References":"<20191013232755.3292-1-laurent.pinchart@ideasonboard.com>\n\t<20191013232755.3292-7-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20191013232755.3292-7-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH 06/10] libcamera: v4l2_controls:\n\tReplace V4L2ControlInfo 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":"Tue, 15 Oct 2019 00:26:32 -0000"}},{"id":2919,"web_url":"https://patchwork.libcamera.org/comment/2919/","msgid":"<20191015175009.zvc77w4r756caxdo@uno.localdomain>","date":"2019-10-15T17:50:10","subject":"Re: [libcamera-devel] [PATCH 06/10] libcamera: v4l2_controls:\n\tReplace V4L2ControlInfo with V4L2ControlRange","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"HI Laurent,\n\nOn Mon, Oct 14, 2019 at 02:27:52AM +0300, Laurent Pinchart wrote:\n> The V4L2ControlInfo class only stores a ControlRange. Make it inherit\n> from ControlRange to provide a convenience constructor from a struct\n> v4l2_query_ext_ctrl and rename it to V4L2ControlRange.\n>\n> Signed-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(-)\n>\n> diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> index 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)\n> diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\n> index 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;\n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index 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;\n> diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> index 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;\n> diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\n> index 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\nThis is not actual anymore I guess\n\nTrying to re-use the ControlRange documentation:\n\n/**\n * \\class V4L2ControlRange\n * \\brief Describe the limits of valid values for a V4L2 control\n *\n * The V4L2 ControlRange expresses the constraints on valid values for a\n * V4L2 control. A V4L2ControlRange is created inspecting the fields\n * of a struct v4l2_query_ext_ctrl as returned by the kernel.\n */\n\n\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\ns/fieldS/fields/\n\nWith the comment updated and the the small nit fixed\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n\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)\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 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. */\n> diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp\n> index 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> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 213EF61562\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Oct 2019 19:48:22 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id A0644C0002;\n\tTue, 15 Oct 2019 17:48:21 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Tue, 15 Oct 2019 19:50:10 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191015175009.zvc77w4r756caxdo@uno.localdomain>","References":"<20191013232755.3292-1-laurent.pinchart@ideasonboard.com>\n\t<20191013232755.3292-7-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"eqyzsy2paaonc7ad\"","Content-Disposition":"inline","In-Reply-To":"<20191013232755.3292-7-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH 06/10] libcamera: v4l2_controls:\n\tReplace V4L2ControlInfo 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":"Tue, 15 Oct 2019 17:48:22 -0000"}},{"id":2925,"web_url":"https://patchwork.libcamera.org/comment/2925/","msgid":"<20191015191852.GQ4875@pendragon.ideasonboard.com>","date":"2019-10-15T19:18:52","subject":"Re: [libcamera-devel] [PATCH 06/10] libcamera: v4l2_controls:\n\tReplace V4L2ControlInfo with V4L2ControlRange","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Tue, Oct 15, 2019 at 07:50:10PM +0200, Jacopo Mondi wrote:\n> On Mon, Oct 14, 2019 at 02:27:52AM +0300, Laurent Pinchart wrote:\n> > The V4L2ControlInfo class only stores a ControlRange. Make it inherit\n> > from ControlRange to provide a convenience constructor from a struct\n> > v4l2_query_ext_ctrl and rename it to V4L2ControlRange.\n> >\n> > Signed-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(-)\n> >\n> > diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> > index 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)\n> > diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\n> > index 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;\n> > diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> > index 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;\n> > diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> > index 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;\n> > diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\n> > index 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> This is not actual anymore I guess\n> \n> Trying to re-use the ControlRange documentation:\n> \n> /**\n>  * \\class V4L2ControlRange\n>  * \\brief Describe the limits of valid values for a V4L2 control\n>  *\n>  * The V4L2 ControlRange expresses the constraints on valid values for a\n>  * V4L2 control. A V4L2ControlRange is created inspecting the fields\n>  * of a struct v4l2_query_ext_ctrl as returned by the kernel.\n>  */\n\nOops. I'll update the documentation with\n\n * The V4L2ControlRange class is a specialisation of the ControlRange for V4L2\n * controls.\n\nto match V4L2ControlId.\n\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> \n> s/fieldS/fields/\n> \n> With the comment updated and the the small nit fixed\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \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)\n> > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> > index 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. */\n> > diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp\n> > index 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}","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 E5C3961562\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Oct 2019 21:18:55 +0200 (CEST)","from pendragon.ideasonboard.com\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 5B11D324;\n\tTue, 15 Oct 2019 21:18:55 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1571167135;\n\tbh=hOsXkkdLzb2AzawOoxDxZhB6klCgMlDnz6kq+rCHjGc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Jco7C1Gc3jfG0yZey+GJd36p6kaigza9x7W3cyxP7NxLo/5XhDrAiLVtuELRI5liP\n\t4EyrDhqc1Sgyo+v3qDkMwNgQjst5qct2v1WEZv0yhYbdZ5BZDIieLe4VeDvVzIKzAy\n\tgT9z5DEFoS27k4e2NphWFTyTTiaketX8sb9hG2WI=","Date":"Tue, 15 Oct 2019 22:18:52 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191015191852.GQ4875@pendragon.ideasonboard.com>","References":"<20191013232755.3292-1-laurent.pinchart@ideasonboard.com>\n\t<20191013232755.3292-7-laurent.pinchart@ideasonboard.com>\n\t<20191015175009.zvc77w4r756caxdo@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20191015175009.zvc77w4r756caxdo@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 06/10] libcamera: v4l2_controls:\n\tReplace V4L2ControlInfo 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":"Tue, 15 Oct 2019 19:18:56 -0000"}},{"id":2926,"web_url":"https://patchwork.libcamera.org/comment/2926/","msgid":"<20191015192246.GR4875@pendragon.ideasonboard.com>","date":"2019-10-15T19:22:46","subject":"Re: [libcamera-devel] [PATCH 06/10] libcamera: v4l2_controls:\n\tReplace V4L2ControlInfo with V4L2ControlRange","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Tue, Oct 15, 2019 at 10:18:52PM +0300, Laurent Pinchart wrote:\n> On Tue, Oct 15, 2019 at 07:50:10PM +0200, Jacopo Mondi wrote:\n> > On Mon, Oct 14, 2019 at 02:27:52AM +0300, Laurent Pinchart wrote:\n> > > The V4L2ControlInfo class only stores a ControlRange. Make it inherit\n> > > from ControlRange to provide a convenience constructor from a struct\n> > > v4l2_query_ext_ctrl and rename it to V4L2ControlRange.\n> > >\n> > > Signed-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(-)\n> > >\n> > > diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp\n> > > index 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)\n> > > diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\n> > > index 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;\n> > > diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> > > index 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;\n> > > diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> > > index 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;\n> > > diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\n> > > index 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> > This is not actual anymore I guess\n> > \n> > Trying to re-use the ControlRange documentation:\n> > \n> > /**\n> >  * \\class V4L2ControlRange\n> >  * \\brief Describe the limits of valid values for a V4L2 control\n> >  *\n> >  * The V4L2 ControlRange expresses the constraints on valid values for a\n> >  * V4L2 control. A V4L2ControlRange is created inspecting the fields\n> >  * of a struct v4l2_query_ext_ctrl as returned by the kernel.\n> >  */\n> \n> Oops. I'll update the documentation with\n> \n>  * The V4L2ControlRange class is a specialisation of the ControlRange for V4L2\n>  * controls.\n> \n> to match V4L2ControlId.\n\nI ended up with\n\n/**\n * \\class V4L2ControlRange\n * \\brief Convenience specialisation of ControlRange for V4L2 controls\n *\n * The V4L2ControlRange class is a specialisation of the ControlRange for V4L2\n * controls. It offers a convenience constructor from a struct\n * v4l2_query_ext_ctrl, and is otherwise equivalent to the ControlRange class.\n */\n\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> > \n> > s/fieldS/fields/\n> > \n> > With the comment updated and the the small nit fixed\n> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> > \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)\n> > > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> > > index 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. */\n> > > diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp\n> > > index 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}","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 4D86561562\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Oct 2019 21:22:49 +0200 (CEST)","from pendragon.ideasonboard.com\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 C2DC4324;\n\tTue, 15 Oct 2019 21:22:48 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1571167369;\n\tbh=4GKyW/vFGiK4vVvxrMnXQAJlKHvLSiSPFwxcKBVkA94=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=opFT5JpPxD+YaBi2JIX7Yfm/nU5cXQD147FypE9Il+k7Fw12ZR/kRKsiSvQdFZZLB\n\ti3cocvXixDylCcq9B2Sco4ZtK542MLuKhra38hbjSstY3lahyCgcdTQ341Se2S+ySI\n\tfIigu74yWY/Sj5cukDqdCuhHx/wn1VPW1vedokYQ=","Date":"Tue, 15 Oct 2019 22:22:46 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191015192246.GR4875@pendragon.ideasonboard.com>","References":"<20191013232755.3292-1-laurent.pinchart@ideasonboard.com>\n\t<20191013232755.3292-7-laurent.pinchart@ideasonboard.com>\n\t<20191015175009.zvc77w4r756caxdo@uno.localdomain>\n\t<20191015191852.GQ4875@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20191015191852.GQ4875@pendragon.ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 06/10] libcamera: v4l2_controls:\n\tReplace V4L2ControlInfo 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":"Tue, 15 Oct 2019 19:22:49 -0000"}}]