[{"id":4123,"web_url":"https://patchwork.libcamera.org/comment/4123/","msgid":"<20200320115044.l2xa5g6ylevrul64@uno.localdomain>","date":"2020-03-20T11:50:44","subject":"Re: [libcamera-devel] [PATCH 01/11] libcamera: controls: Name all\n\tControlInfoMap instance variables infoMap","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Mon, Mar 09, 2020 at 05:24:04PM +0100, Jacopo Mondi wrote:\n> From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> To prepare for the rename of ControlRange to ControlInfo, rename all the\n> ControlInfoMap instance variables currently named info to infoMap. This\n> will help avoiding namespace clashes.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nSorry, submitted but forgot to add my tag\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> ---\n>  include/libcamera/controls.h                  |  2 +-\n>  src/libcamera/control_serializer.cpp          | 29 ++++++++++---------\n>  src/libcamera/controls.cpp                    |  6 ++--\n>  src/libcamera/include/control_serializer.h    |  4 +--\n>  ...{control_info.cpp => control_info_map.cpp} | 18 ++++++------\n>  test/controls/meson.build                     |  8 ++---\n>  test/v4l2_videodevice/controls.cpp            | 18 ++++++------\n>  7 files changed, 43 insertions(+), 42 deletions(-)\n>  rename test/controls/{control_info.cpp => control_info_map.cpp} (74%)\n>\n> diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h\n> index 0e111ab72bce..3d2250f43f3c 100644\n> --- a/include/libcamera/controls.h\n> +++ b/include/libcamera/controls.h\n> @@ -313,7 +313,7 @@ private:\n>  public:\n>  \tControlList();\n>  \tControlList(const ControlIdMap &idmap, ControlValidator *validator = nullptr);\n> -\tControlList(const ControlInfoMap &info, ControlValidator *validator = nullptr);\n> +\tControlList(const ControlInfoMap &infoMap, ControlValidator *validator = nullptr);\n>\n>  \tusing iterator = ControlListMap::iterator;\n>  \tusing const_iterator = ControlListMap::const_iterator;\n> diff --git a/src/libcamera/control_serializer.cpp b/src/libcamera/control_serializer.cpp\n> index 004735fb2aa0..dcc63d20c06c 100644\n> --- a/src/libcamera/control_serializer.cpp\n> +++ b/src/libcamera/control_serializer.cpp\n> @@ -106,19 +106,19 @@ size_t ControlSerializer::binarySize(const ControlRange &range)\n>\n>  /**\n>   * \\brief Retrieve the size in bytes required to serialize a ControlInfoMap\n> - * \\param[in] info The control info map\n> + * \\param[in] infoMap The control info map\n>   *\n>   * Compute and return the size in bytes required to store the serialized\n>   * ControlInfoMap.\n>   *\n>   * \\return The size in bytes required to store the serialized ControlInfoMap\n>   */\n> -size_t ControlSerializer::binarySize(const ControlInfoMap &info)\n> +size_t ControlSerializer::binarySize(const ControlInfoMap &infoMap)\n>  {\n>  \tsize_t size = sizeof(struct ipa_controls_header)\n> -\t\t    + info.size() * sizeof(struct ipa_control_range_entry);\n> +\t\t    + infoMap.size() * sizeof(struct ipa_control_range_entry);\n>\n> -\tfor (const auto &ctrl : info)\n> +\tfor (const auto &ctrl : infoMap)\n>  \t\tsize += binarySize(ctrl.second);\n>\n>  \treturn size;\n> @@ -159,32 +159,33 @@ void ControlSerializer::store(const ControlRange &range,\n>\n>  /**\n>   * \\brief Serialize a ControlInfoMap in a buffer\n> - * \\param[in] info The control info map to serialize\n> + * \\param[in] infoMap The control info map to serialize\n>   * \\param[in] buffer The memory buffer where to serialize the ControlInfoMap\n>   *\n> - * Serialize the \\a info map into the \\a buffer using the serialization format\n> + * Serialize the \\a infoMap into the \\a buffer using the serialization format\n>   * defined by the IPA context interface in ipa_controls.h.\n>   *\n> - * The serializer stores a reference to the \\a info internally. The caller\n> - * shall ensure that \\a info stays valid until the serializer is reset().\n> + * The serializer stores a reference to the \\a infoMap internally. The caller\n> + * shall ensure that \\a infoMap stays valid until the serializer is reset().\n>   *\n>   * \\return 0 on success, a negative error code otherwise\n>   * \\retval -ENOSPC Not enough space is available in the buffer\n>   */\n> -int ControlSerializer::serialize(const ControlInfoMap &info,\n> +int ControlSerializer::serialize(const ControlInfoMap &infoMap,\n>  \t\t\t\t ByteStreamBuffer &buffer)\n>  {\n>  \t/* Compute entries and data required sizes. */\n> -\tsize_t entriesSize = info.size() * sizeof(struct ipa_control_range_entry);\n> +\tsize_t entriesSize = infoMap.size()\n> +\t\t\t   * sizeof(struct ipa_control_range_entry);\n>  \tsize_t valuesSize = 0;\n> -\tfor (const auto &ctrl : info)\n> +\tfor (const auto &ctrl : infoMap)\n>  \t\tvaluesSize += binarySize(ctrl.second);\n>\n>  \t/* Prepare the packet header, assign a handle to the ControlInfoMap. */\n>  \tstruct ipa_controls_header hdr;\n>  \thdr.version = IPA_CONTROLS_FORMAT_VERSION;\n>  \thdr.handle = ++serial_;\n> -\thdr.entries = info.size();\n> +\thdr.entries = infoMap.size();\n>  \thdr.size = sizeof(hdr) + entriesSize + valuesSize;\n>  \thdr.data_offset = sizeof(hdr) + entriesSize;\n>\n> @@ -197,7 +198,7 @@ int ControlSerializer::serialize(const ControlInfoMap &info,\n>  \tByteStreamBuffer entries = buffer.carveOut(entriesSize);\n>  \tByteStreamBuffer values = buffer.carveOut(valuesSize);\n>\n> -\tfor (const auto &ctrl : info) {\n> +\tfor (const auto &ctrl : infoMap) {\n>  \t\tconst ControlId *id = ctrl.first;\n>  \t\tconst ControlRange &range = ctrl.second;\n>\n> @@ -217,7 +218,7 @@ int ControlSerializer::serialize(const ControlInfoMap &info,\n>  \t * Store the map to handle association, to be used to serialize and\n>  \t * deserialize control lists.\n>  \t */\n> -\tinfoMapHandles_[&info] = hdr.handle;\n> +\tinfoMapHandles_[&infoMap] = hdr.handle;\n>\n>  \treturn 0;\n>  }\n> diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp\n> index 4326174adf86..833a436c64df 100644\n> --- a/src/libcamera/controls.cpp\n> +++ b/src/libcamera/controls.cpp\n> @@ -706,11 +706,11 @@ ControlList::ControlList(const ControlIdMap &idmap, ControlValidator *validator)\n>\n>  /**\n>   * \\brief Construct a ControlList with the idmap of a control info map\n> - * \\param[in] info The ControlInfoMap for the control list target object\n> + * \\param[in] infoMap The ControlInfoMap for the control list target object\n>   * \\param[in] validator The validator (may be null)\n>   */\n> -ControlList::ControlList(const ControlInfoMap &info, ControlValidator *validator)\n> -\t: validator_(validator), idmap_(&info.idmap()), infoMap_(&info)\n> +ControlList::ControlList(const ControlInfoMap &infoMap, ControlValidator *validator)\n> +\t: validator_(validator), idmap_(&infoMap.idmap()), infoMap_(&infoMap)\n>  {\n>  }\n>\n> diff --git a/src/libcamera/include/control_serializer.h b/src/libcamera/include/control_serializer.h\n> index b91d13155f5e..026e62340328 100644\n> --- a/src/libcamera/include/control_serializer.h\n> +++ b/src/libcamera/include/control_serializer.h\n> @@ -24,10 +24,10 @@ public:\n>\n>  \tvoid reset();\n>\n> -\tstatic size_t binarySize(const ControlInfoMap &info);\n> +\tstatic size_t binarySize(const ControlInfoMap &infoMap);\n>  \tstatic size_t binarySize(const ControlList &list);\n>\n> -\tint serialize(const ControlInfoMap &info, ByteStreamBuffer &buffer);\n> +\tint serialize(const ControlInfoMap &infoMap, ByteStreamBuffer &buffer);\n>  \tint serialize(const ControlList &list, ByteStreamBuffer &buffer);\n>\n>  \ttemplate<typename T>\n> diff --git a/test/controls/control_info.cpp b/test/controls/control_info_map.cpp\n> similarity index 74%\n> rename from test/controls/control_info.cpp\n> rename to test/controls/control_info_map.cpp\n> index fa9d7bae97d0..eeb702db095b 100644\n> --- a/test/controls/control_info.cpp\n> +++ b/test/controls/control_info_map.cpp\n> @@ -36,41 +36,41 @@ protected:\n>\n>  \tint run() override\n>  \t{\n> -\t\tconst ControlInfoMap &info = camera_->controls();\n> +\t\tconst ControlInfoMap &infoMap = camera_->controls();\n>\n>  \t\t/* Test looking up a valid control by ControlId. */\n> -\t\tif (info.count(&controls::Brightness) != 1) {\n> +\t\tif (infoMap.count(&controls::Brightness) != 1) {\n>  \t\t\tcerr << \"count() on valid control failed\" << endl;\n>  \t\t\treturn TestFail;\n>  \t\t}\n>\n> -\t\tif (info.find(&controls::Brightness) == info.end()) {\n> +\t\tif (infoMap.find(&controls::Brightness) == infoMap.end()) {\n>  \t\t\tcerr << \"find() on valid control failed\" << endl;\n>  \t\t\treturn TestFail;\n>  \t\t}\n>\n> -\t\tinfo.at(&controls::Brightness);\n> +\t\tinfoMap.at(&controls::Brightness);\n>\n>  \t\t/* Test looking up a valid control by numerical ID. */\n> -\t\tif (info.count(controls::Brightness.id()) != 1) {\n> +\t\tif (infoMap.count(controls::Brightness.id()) != 1) {\n>  \t\t\tcerr << \"count() on valid ID failed\" << endl;\n>  \t\t\treturn TestFail;\n>  \t\t}\n>\n> -\t\tif (info.find(controls::Brightness.id()) == info.end()) {\n> +\t\tif (infoMap.find(controls::Brightness.id()) == infoMap.end()) {\n>  \t\t\tcerr << \"find() on valid ID failed\" << endl;\n>  \t\t\treturn TestFail;\n>  \t\t}\n>\n> -\t\tinfo.at(controls::Brightness.id());\n> +\t\tinfoMap.at(controls::Brightness.id());\n>\n>  \t\t/* Test looking up an invalid control by numerical ID. */\n> -\t\tif (info.count(12345) != 0) {\n> +\t\tif (infoMap.count(12345) != 0) {\n>  \t\t\tcerr << \"count() on invalid ID failed\" << endl;\n>  \t\t\treturn TestFail;\n>  \t\t}\n>\n> -\t\tif (info.find(12345) != info.end()) {\n> +\t\tif (infoMap.find(12345) != infoMap.end()) {\n>  \t\t\tcerr << \"find() on invalid ID failed\" << endl;\n>  \t\t\treturn TestFail;\n>  \t\t}\n> diff --git a/test/controls/meson.build b/test/controls/meson.build\n> index f0850df28c8a..16a7f33fdcc6 100644\n> --- a/test/controls/meson.build\n> +++ b/test/controls/meson.build\n> @@ -1,8 +1,8 @@\n>  control_tests = [\n> -    [ 'control_info',   'control_info.cpp' ],\n> -    [ 'control_list',   'control_list.cpp' ],\n> -    [ 'control_range',  'control_range.cpp' ],\n> -    [ 'control_value',  'control_value.cpp' ],\n> +    [ 'control_info_map',           'control_info_map.cpp' ],\n> +    [ 'control_list',               'control_list.cpp' ],\n> +    [ 'control_range',              'control_range.cpp' ],\n> +    [ 'control_value',              'control_value.cpp' ],\n>  ]\n>\n>  foreach t : control_tests\n> diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp\n> index 42c653d4435a..1b71bf0633b4 100644\n> --- a/test/v4l2_videodevice/controls.cpp\n> +++ b/test/v4l2_videodevice/controls.cpp\n> @@ -26,27 +26,27 @@ public:\n>  protected:\n>  \tint run()\n>  \t{\n> -\t\tconst ControlInfoMap &info = capture_->controls();\n> +\t\tconst ControlInfoMap &infoMap = capture_->controls();\n>\n>  \t\t/* Test control enumeration. */\n> -\t\tif (info.empty()) {\n> +\t\tif (infoMap.empty()) {\n>  \t\t\tcerr << \"Failed to enumerate controls\" << endl;\n>  \t\t\treturn TestFail;\n>  \t\t}\n>\n> -\t\tif (info.find(V4L2_CID_BRIGHTNESS) == info.end() ||\n> -\t\t    info.find(V4L2_CID_CONTRAST) == info.end() ||\n> -\t\t    info.find(V4L2_CID_SATURATION) == info.end()) {\n> +\t\tif (infoMap.find(V4L2_CID_BRIGHTNESS) == infoMap.end() ||\n> +\t\t    infoMap.find(V4L2_CID_CONTRAST) == infoMap.end() ||\n> +\t\t    infoMap.find(V4L2_CID_SATURATION) == infoMap.end()) {\n>  \t\t\tcerr << \"Missing controls\" << endl;\n>  \t\t\treturn TestFail;\n>  \t\t}\n>\n> -\t\tconst ControlRange &brightness = info.find(V4L2_CID_BRIGHTNESS)->second;\n> -\t\tconst ControlRange &contrast = info.find(V4L2_CID_CONTRAST)->second;\n> -\t\tconst ControlRange &saturation = info.find(V4L2_CID_SATURATION)->second;\n> +\t\tconst ControlRange &brightness = infoMap.find(V4L2_CID_BRIGHTNESS)->second;\n> +\t\tconst ControlRange &contrast = infoMap.find(V4L2_CID_CONTRAST)->second;\n> +\t\tconst ControlRange &saturation = infoMap.find(V4L2_CID_SATURATION)->second;\n>\n>  \t\t/* Test getting controls. */\n> -\t\tControlList ctrls(info);\n> +\t\tControlList ctrls(infoMap);\n>  \t\tctrls.set(V4L2_CID_BRIGHTNESS, -1);\n>  \t\tctrls.set(V4L2_CID_CONTRAST, -1);\n>  \t\tctrls.set(V4L2_CID_SATURATION, -1);\n> --\n> 2.25.0\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 relay7-d.mail.gandi.net (relay7-d.mail.gandi.net\n\t[217.70.183.200])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id AFE2860416\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Mar 2020 12:47:48 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 4E6AD2000A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Mar 2020 11:47:48 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Fri, 20 Mar 2020 12:50:44 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200320115044.l2xa5g6ylevrul64@uno.localdomain>","References":"<20200309162414.720306-1-jacopo@jmondi.org>\n\t<20200309162414.720306-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200309162414.720306-2-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 01/11] libcamera: controls: Name all\n\tControlInfoMap instance variables infoMap","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 20 Mar 2020 11:47:48 -0000"}}]