[{"id":2896,"web_url":"https://patchwork.libcamera.org/comment/2896/","msgid":"<20191015001211.GB5976@bigcity.dyn.berto.se>","date":"2019-10-15T00:12:11","subject":"Re: [libcamera-devel] [PATCH 02/10] libcamera: v4l2_controls: Move\n\tV4L2ControlId out of V4L2ControlInfo","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo, Laurent,\n\nThanks for your patch.\n\nOn 2019-10-14 02:27:48 +0300, Laurent Pinchart wrote:\n> From: Jacopo Mondi <jacopo@jmondi.org>\n> \n> In order to reconcile the libcamera and V4L2 control info maps, we need\n> to move the V4L2ControlId embedded in V4L2ControlInfo map out of the\n> class. Store the V4L2ControlId instances in the V4L2Device that creates\n> them, and only reference them from V4L2ControlInfo.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/include/v4l2_controls.h | 7 ++++---\n>  src/libcamera/include/v4l2_device.h   | 4 +++-\n>  src/libcamera/v4l2_controls.cpp       | 6 ++++--\n>  src/libcamera/v4l2_device.cpp         | 3 ++-\n>  4 files changed, 13 insertions(+), 7 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\n> index 133f5262febf..4d7ac1a133c7 100644\n> --- a/src/libcamera/include/v4l2_controls.h\n> +++ b/src/libcamera/include/v4l2_controls.h\n> @@ -28,13 +28,14 @@ public:\n>  class V4L2ControlInfo\n>  {\n>  public:\n> -\tV4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);\n> +\tV4L2ControlInfo(const V4L2ControlId &id,\n> +\t\t\tconst struct v4l2_query_ext_ctrl &ctrl);\n>  \n> -\tconst ControlId &id() const { return id_; }\n> +\tconst ControlId &id() const { return *id_; }\n>  \tconst ControlRange &range() const { return range_; }\n>  \n>  private:\n> -\tV4L2ControlId id_;\n> +\tconst V4L2ControlId *id_;\n>  \tControlRange range_;\n>  };\n>  \n> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> index daa762d58d2b..5a5b85827f23 100644\n> --- a/src/libcamera/include/v4l2_device.h\n> +++ b/src/libcamera/include/v4l2_device.h\n> @@ -8,7 +8,8 @@\n>  #define __LIBCAMERA_V4L2_DEVICE_H__\n>  \n>  #include <map>\n> -#include <string>\n> +#include <memory>\n> +#include <vector>\n>  \n>  #include <linux/videodev2.h>\n>  \n> @@ -48,6 +49,7 @@ private:\n>  \t\t\t    const struct v4l2_ext_control *v4l2Ctrls,\n>  \t\t\t    unsigned int count);\n>  \n> +\tstd::vector<std::unique_ptr<V4L2ControlId>> controlIds_;\n>  \tV4L2ControlInfoMap controls_;\n>  \tstd::string deviceNode_;\n>  \tint fd_;\n> diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\n> index dcf31b7a8f26..12c4fb271ba5 100644\n> --- a/src/libcamera/v4l2_controls.cpp\n> +++ b/src/libcamera/v4l2_controls.cpp\n> @@ -122,10 +122,12 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl)\n>  \n>  /**\n>   * \\brief Construct a V4L2ControlInfo from a struct v4l2_query_ext_ctrl\n> + * \\param[in] id The V4L2 control ID\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> -\t: id_(ctrl)\n> +V4L2ControlInfo::V4L2ControlInfo(const V4L2ControlId &id,\n> +\t\t\t\t const struct v4l2_query_ext_ctrl &ctrl)\n> +\t: id_(&id)\n>  {\n>  \tif (ctrl.type == V4L2_CTRL_TYPE_INTEGER64)\n>  \t\trange_ = ControlRange(static_cast<int64_t>(ctrl.minimum),\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 54cc214ecce9..144a60b4fe93 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -386,9 +386,10 @@ void V4L2Device::listControls()\n>  \t\t\tcontinue;\n>  \t\t}\n>  \n> +\t\tcontrolIds_.emplace_back(utils::make_unique<V4L2ControlId>(ctrl));\n>  \t\tctrls.emplace(std::piecewise_construct,\n>  \t\t\t      std::forward_as_tuple(ctrl.id),\n> -\t\t\t      std::forward_as_tuple(ctrl));\n> +\t\t\t      std::forward_as_tuple(*controlIds_.back().get(), ctrl));\n>  \t}\n>  \n>  \tcontrols_ = std::move(ctrls);\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 6891F600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Oct 2019 02:12:13 +0200 (CEST)","by mail-lf1-x141.google.com with SMTP id u16so455655lfq.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 14 Oct 2019 17:12:13 -0700 (PDT)","from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159])\n\tby smtp.gmail.com with ESMTPSA id\n\ty3sm4566869lji.53.2019.10.14.17.12.11\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 14 Oct 2019 17:12:12 -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=/jXBIAQBIgmJ6ErFkCiAUjSItkJgHlKVIhHf5OFHPmk=;\n\tb=Hd1Q9RBCYPk8WH8ePPs/rsYIvA9CWvzAJ/YIFnOlO6uJ/Wvt/rk53lgomHXPKf5kvK\n\tjBrBQTjBNp0vN2nI/b+QKNuxSoAkiYp3aOOr2o2XaILQECb4RFsEGBLEeDbNgMsP+Eq3\n\tN2qHAl8mdY4Nf7F2ESnlzuYT4Ujj5yx3WUFge5AZsLWfW/M6wEjSeLGyZfa6sZbK929s\n\t1bIErriITpcfG/4cjD8/Dt+QNKJd2ThUXGxxTRZ/ujILTlPWViYvSOotjdne9m1shfk3\n\t1wrwPpV7JXvK2gZ1sXjpCPshA1B63EnhDJCKyCwEqqDD5fQpwLWggsNk2WYbv3CttVuW\n\ththg==","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=/jXBIAQBIgmJ6ErFkCiAUjSItkJgHlKVIhHf5OFHPmk=;\n\tb=Zq2wH8q+1KD8m/3JYA+dPFy5/Ay4L5IShCWtMRMQYMQDCHa15DhuX8Inc8e+ekaZk0\n\tXkc06mc/pQ7q8dqEHJG5NjCZIcf+RC3HxTKwAObs5J5ZC76rVmqAHMtS4IAnWHdCBo9a\n\tTcub2I9wNXMYFSGujYjjNWV9ez4nImc301ma97sd9EbFht0kzdqr9ZRFqXkavxENNmL+\n\t3ovxVwjmdSyjN5cF6Hhl8HZIc1iawxRcQNocoutWu3/49E+HJtaWAgaNwrhkL/ejOCcD\n\tW6PePAu6PrJMu3RZPqll2IGvMutUNU5YG/F1qqQettjOkwLpOpyFJ+kAkymJaLzzHQWS\n\tqVRQ==","X-Gm-Message-State":"APjAAAWdfcpW169pF00OE6eP6rOurO6exwJN28RxJrmtst/idFMLQqzP\n\tUKuH/4IfGQMNvhqoSzQ7rzuUC156HvY=","X-Google-Smtp-Source":"APXvYqyhaDQmFuEzwCJHejFP1HUsnp9WMu8ABkt2tCGswuk2OlY7ZobiqSyDIF+DL6v6SQrVh8NEEQ==","X-Received":"by 2002:a19:c7cf:: with SMTP id\n\tx198mr18595723lff.158.1571098332610; \n\tMon, 14 Oct 2019 17:12:12 -0700 (PDT)","Date":"Tue, 15 Oct 2019 02:12:11 +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":"<20191015001211.GB5976@bigcity.dyn.berto.se>","References":"<20191013232755.3292-1-laurent.pinchart@ideasonboard.com>\n\t<20191013232755.3292-3-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-3-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH 02/10] libcamera: v4l2_controls: Move\n\tV4L2ControlId out of V4L2ControlInfo","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:12:13 -0000"}},{"id":2911,"web_url":"https://patchwork.libcamera.org/comment/2911/","msgid":"<20191015145149.dxmvtmqx2ja6vgc6@uno.localdomain>","date":"2019-10-15T14:51:49","subject":"Re: [libcamera-devel] [PATCH 02/10] libcamera: v4l2_controls: Move\n\tV4L2ControlId out of V4L2ControlInfo","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:48AM +0300, Laurent Pinchart wrote:\n> From: Jacopo Mondi <jacopo@jmondi.org>\n>\n> In order to reconcile the libcamera and V4L2 control info maps, we need\n> to move the V4L2ControlId embedded in V4L2ControlInfo map out of the\n> class. Store the V4L2ControlId instances in the V4L2Device that creates\n> them, and only reference them from V4L2ControlInfo.\n>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nMuch better now that ControlId are stored as unique_ptrs.\nGreat!\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> ---\n>  src/libcamera/include/v4l2_controls.h | 7 ++++---\n>  src/libcamera/include/v4l2_device.h   | 4 +++-\n>  src/libcamera/v4l2_controls.cpp       | 6 ++++--\n>  src/libcamera/v4l2_device.cpp         | 3 ++-\n>  4 files changed, 13 insertions(+), 7 deletions(-)\n>\n> diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\n> index 133f5262febf..4d7ac1a133c7 100644\n> --- a/src/libcamera/include/v4l2_controls.h\n> +++ b/src/libcamera/include/v4l2_controls.h\n> @@ -28,13 +28,14 @@ public:\n>  class V4L2ControlInfo\n>  {\n>  public:\n> -\tV4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);\n> +\tV4L2ControlInfo(const V4L2ControlId &id,\n> +\t\t\tconst struct v4l2_query_ext_ctrl &ctrl);\n>\n> -\tconst ControlId &id() const { return id_; }\n> +\tconst ControlId &id() const { return *id_; }\n>  \tconst ControlRange &range() const { return range_; }\n>\n>  private:\n> -\tV4L2ControlId id_;\n> +\tconst V4L2ControlId *id_;\n>  \tControlRange range_;\n>  };\n>\n> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> index daa762d58d2b..5a5b85827f23 100644\n> --- a/src/libcamera/include/v4l2_device.h\n> +++ b/src/libcamera/include/v4l2_device.h\n> @@ -8,7 +8,8 @@\n>  #define __LIBCAMERA_V4L2_DEVICE_H__\n>\n>  #include <map>\n> -#include <string>\n> +#include <memory>\n> +#include <vector>\n>\n>  #include <linux/videodev2.h>\n>\n> @@ -48,6 +49,7 @@ private:\n>  \t\t\t    const struct v4l2_ext_control *v4l2Ctrls,\n>  \t\t\t    unsigned int count);\n>\n> +\tstd::vector<std::unique_ptr<V4L2ControlId>> controlIds_;\n>  \tV4L2ControlInfoMap controls_;\n>  \tstd::string deviceNode_;\n>  \tint fd_;\n> diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\n> index dcf31b7a8f26..12c4fb271ba5 100644\n> --- a/src/libcamera/v4l2_controls.cpp\n> +++ b/src/libcamera/v4l2_controls.cpp\n> @@ -122,10 +122,12 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl)\n>\n>  /**\n>   * \\brief Construct a V4L2ControlInfo from a struct v4l2_query_ext_ctrl\n> + * \\param[in] id The V4L2 control ID\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> -\t: id_(ctrl)\n> +V4L2ControlInfo::V4L2ControlInfo(const V4L2ControlId &id,\n> +\t\t\t\t const struct v4l2_query_ext_ctrl &ctrl)\n> +\t: id_(&id)\n>  {\n>  \tif (ctrl.type == V4L2_CTRL_TYPE_INTEGER64)\n>  \t\trange_ = ControlRange(static_cast<int64_t>(ctrl.minimum),\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 54cc214ecce9..144a60b4fe93 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -386,9 +386,10 @@ void V4L2Device::listControls()\n>  \t\t\tcontinue;\n>  \t\t}\n>\n> +\t\tcontrolIds_.emplace_back(utils::make_unique<V4L2ControlId>(ctrl));\n>  \t\tctrls.emplace(std::piecewise_construct,\n>  \t\t\t      std::forward_as_tuple(ctrl.id),\n> -\t\t\t      std::forward_as_tuple(ctrl));\n> +\t\t\t      std::forward_as_tuple(*controlIds_.back().get(), ctrl));\n>  \t}\n>\n>  \tcontrols_ = std::move(ctrls);\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 relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0AF1961562\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 15 Oct 2019 16:50:02 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 6E44A1BF20D;\n\tTue, 15 Oct 2019 14:50:01 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Tue, 15 Oct 2019 16:51:49 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191015145149.dxmvtmqx2ja6vgc6@uno.localdomain>","References":"<20191013232755.3292-1-laurent.pinchart@ideasonboard.com>\n\t<20191013232755.3292-3-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"hesz4rwoldq5vsg4\"","Content-Disposition":"inline","In-Reply-To":"<20191013232755.3292-3-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH 02/10] libcamera: v4l2_controls: Move\n\tV4L2ControlId out of V4L2ControlInfo","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 14:50:02 -0000"}}]