[{"id":2757,"web_url":"https://patchwork.libcamera.org/comment/2757/","msgid":"<20191003193907.GL1322@bigcity.dyn.berto.se>","date":"2019-10-03T19:39:07","subject":"Re: [libcamera-devel] [PATCH v2 09/13] libcamera: v4l2_controls:\n\tUse the ControlValue class for data storage","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 effort.\n\nOn 2019-09-29 22:02:50 +0300, Laurent Pinchart wrote:\n> Use the ControlValue class to replace the manually crafted data storage\n> in V4L2Control. This will help sharing code when more data types will be\n> supported.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n>  src/libcamera/include/v4l2_controls.h | 15 +++++++++------\n>  src/libcamera/pipeline/uvcvideo.cpp   |  2 +-\n>  src/libcamera/pipeline/vimc.cpp       |  2 +-\n>  src/libcamera/v4l2_controls.cpp       | 19 ++++++++++---------\n>  src/libcamera/v4l2_device.cpp         |  8 ++++----\n>  5 files changed, 25 insertions(+), 21 deletions(-)\n> \n> diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\n> index 10b726504951..f2b67c5d44e1 100644\n> --- a/src/libcamera/include/v4l2_controls.h\n> +++ b/src/libcamera/include/v4l2_controls.h\n> @@ -16,6 +16,8 @@\n>  #include <linux/v4l2-controls.h>\n>  #include <linux/videodev2.h>\n>  \n> +#include <libcamera/controls.h>\n> +\n>  namespace libcamera {\n>  \n>  class V4L2ControlInfo\n> @@ -46,17 +48,18 @@ using V4L2ControlInfoMap = std::map<unsigned int, V4L2ControlInfo>;\n>  class V4L2Control\n>  {\n>  public:\n> -\tV4L2Control(unsigned int id, int value = 0)\n> -\t\t: id_(id), value_(value) {}\n> -\n> -\tint64_t value() const { return value_; }\n> -\tvoid setValue(int64_t value) { value_ = value; }\n> +\tV4L2Control(unsigned int id, const ControlValue &value = ControlValue())\n> +\t\t: id_(id), value_(value)\n> +\t{\n> +\t}\n>  \n>  \tunsigned int id() const { return id_; }\n> +\tconst ControlValue &value() const { return value_; }\n> +\tControlValue &value() { return value_; }\n>  \n>  private:\n>  \tunsigned int id_;\n> -\tint64_t value_;\n> +\tControlValue value_;\n>  };\n>  \n>  class V4L2ControlList\n> diff --git a/src/libcamera/pipeline/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo.cpp\n> index 2ac582d77801..860578d41875 100644\n> --- a/src/libcamera/pipeline/uvcvideo.cpp\n> +++ b/src/libcamera/pipeline/uvcvideo.cpp\n> @@ -252,7 +252,7 @@ int PipelineHandlerUVC::processControls(UVCCameraData *data, Request *request)\n>  \t\tLOG(UVC, Debug)\n>  \t\t\t<< \"Setting control 0x\"\n>  \t\t\t<< std::hex << std::setw(8) << ctrl.id() << std::dec\n> -\t\t\t<< \" to \" << ctrl.value();\n> +\t\t\t<< \" to \" << ctrl.value().toString();\n>  \n>  \tint ret = data->video_->setControls(&controls);\n>  \tif (ret) {\n> diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp\n> index ec9c1cd2d484..b2b36b238809 100644\n> --- a/src/libcamera/pipeline/vimc.cpp\n> +++ b/src/libcamera/pipeline/vimc.cpp\n> @@ -300,7 +300,7 @@ int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request)\n>  \t\tLOG(VIMC, Debug)\n>  \t\t\t<< \"Setting control 0x\"\n>  \t\t\t<< std::hex << std::setw(8) << ctrl.id() << std::dec\n> -\t\t\t<< \" to \" << ctrl.value();\n> +\t\t\t<< \" to \" << ctrl.value().toString();\n>  \n>  \tint ret = data->sensor_->setControls(&controls);\n>  \tif (ret) {\n> diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\n> index 84258d9954d0..64f0555fff7c 100644\n> --- a/src/libcamera/v4l2_controls.cpp\n> +++ b/src/libcamera/v4l2_controls.cpp\n> @@ -143,6 +143,16 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n>   * \\param value The control value\n>   */\n>  \n> +/**\n> + * \\fn V4L2Control::value() const\n> + * \\brief Retrieve the value of the control\n> + *\n> + * This method is a const version of V4L2Control::value(), returning a const\n> + * reference to the value.\n> + *\n> + * \\return The V4L2 control value\n> + */\n> +\n>  /**\n>   * \\fn V4L2Control::value()\n>   * \\brief Retrieve the value of the control\n> @@ -154,15 +164,6 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n>   * \\return The V4L2 control value\n>   */\n>  \n> -/**\n> - * \\fn V4L2Control::setValue()\n> - * \\brief Set the value of the control\n> - * \\param value The new V4L2 control value\n> - *\n> - * This method stores the control value, which will be applied to the\n> - * device when calling V4L2Device::setControls().\n> - */\n> -\n>  /**\n>   * \\fn V4L2Control::id()\n>   * \\brief Retrieve the control ID this instance refers to\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 349bf2d29704..fd4b9c6d5c62 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -264,14 +264,14 @@ int V4L2Device::setControls(V4L2ControlList *ctrls)\n>  \t\t/* Set the v4l2_ext_control value for the write operation. */\n>  \t\tswitch (info->type()) {\n>  \t\tcase V4L2_CTRL_TYPE_INTEGER64:\n> -\t\t\tv4l2Ctrls[i].value64 = ctrl->value();\n> +\t\t\tv4l2Ctrls[i].value64 = ctrl->value().get<int64_t>();\n>  \t\t\tbreak;\n>  \t\tdefault:\n>  \t\t\t/*\n>  \t\t\t * \\todo To be changed when support for string and\n>  \t\t\t * compound controls will be added.\n>  \t\t\t */\n> -\t\t\tv4l2Ctrls[i].value = ctrl->value();\n> +\t\t\tv4l2Ctrls[i].value = ctrl->value().get<int32_t>();\n>  \t\t\tbreak;\n>  \t\t}\n>  \t}\n> @@ -393,14 +393,14 @@ void V4L2Device::updateControls(V4L2ControlList *ctrls,\n>  \n>  \t\tswitch (info->type()) {\n>  \t\tcase V4L2_CTRL_TYPE_INTEGER64:\n> -\t\t\tctrl->setValue(v4l2Ctrl->value64);\n> +\t\t\tctrl->value().set<int64_t>(v4l2Ctrl->value64);\n>  \t\t\tbreak;\n>  \t\tdefault:\n>  \t\t\t/*\n>  \t\t\t * \\todo To be changed when support for string and\n>  \t\t\t * compound controls will be added.\n>  \t\t\t */\n> -\t\t\tctrl->setValue(v4l2Ctrl->value);\n> +\t\t\tctrl->value().set<int32_t>(v4l2Ctrl->value);\n>  \t\t\tbreak;\n>  \t\t}\n>  \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-lj1-x242.google.com (mail-lj1-x242.google.com\n\t[IPv6:2a00:1450:4864:20::242])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2256E60BE8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Oct 2019 21:39:09 +0200 (CEST)","by mail-lj1-x242.google.com with SMTP id 7so4059967ljw.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 03 Oct 2019 12:39:09 -0700 (PDT)","from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159])\n\tby smtp.gmail.com with ESMTPSA id\n\ty206sm636313lfc.6.2019.10.03.12.39.07\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 03 Oct 2019 12:39:07 -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=I/FoSzZnGnH5BDzr4z4W9PGi7clIZRcjtX2HIHT3W2g=;\n\tb=ByV4xN1bxu1prpSGoeBe9NJleJTKm1GK32fF+bNLCadfJyvbm5Mbn1oicGpoMpBGOn\n\ttvu1/382s6YFONNtwH2OLvWfl9VMNpGizQd/PlDHkYbwMKZVaarFW0QqHQau57pkODFO\n\tVsl4DscT8x0WrGmxyaoFZ4Ux03QmY9sakEFkuF/p+Ou8AVe5xBMIfOKUC3njbQC41Qte\n\tKI/FG7PcMuQPOu62LPUNnFUqMbmQAvFIIePuede4MhvTw8WOm6lHPv5merXIMZed3XOC\n\tWixzPOzDIgwuOUOtDgogl2zHehpGRpEp8e9sogzJrUA4U/jU5728kpIg42P7ea6i74gq\n\tw5dw==","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=I/FoSzZnGnH5BDzr4z4W9PGi7clIZRcjtX2HIHT3W2g=;\n\tb=pvgJV21a8fomRr+QYvWhQBqaQFn5RXwZJibMtsdBtJrsitIseDjgnBEetWx/H4FbJ0\n\tJXVJSBku24kGXYLQScGJcEvQMPN4/M+fRHKCLB/1bsPp6YpLfIUgU+nWF4JVQUZqOvXu\n\ttsa79JEQM4EZ2zO5HUfaIu4LHmwYFXNUJpJqBcPh87CicbefWSZsGY4999lJqWMKDQfn\n\t5MPRDoM28u6NhyqRFislq7qOelDWnNuq9vrYcCCsUtp1bJyiBUZBIJb3dAPESIenQNTf\n\t6jzJ/FY5dKbxi4pruPas8ufNvu1oWz0brN0/szA01lY3tIrXLFunyaeW3x9aMbGQ4z/V\n\t2VZw==","X-Gm-Message-State":"APjAAAXz4vTXY0IDXy/+H1DD5lSOt6CroBCvMMKHBFLLdxdvqL5UO3Ot\n\tPDUa9az5J62Kcgjt5gbJqS1UJsIpYPg=","X-Google-Smtp-Source":"APXvYqxAeXoJ0Q5csipPPvrE9QwMyXvCCLP7yqLGpgd0iZPjkUHwQ6E1HsMPC/UcCTvspN4Q8u+KtA==","X-Received":"by 2002:a2e:8507:: with SMTP id j7mr6954928lji.151.1570131548488;\n\tThu, 03 Oct 2019 12:39:08 -0700 (PDT)","Date":"Thu, 3 Oct 2019 21:39:07 +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":"<20191003193907.GL1322@bigcity.dyn.berto.se>","References":"<20190929190254.18920-1-laurent.pinchart@ideasonboard.com>\n\t<20190929190254.18920-10-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":"<20190929190254.18920-10-laurent.pinchart@ideasonboard.com>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH v2 09/13] libcamera: v4l2_controls:\n\tUse the ControlValue class for data storage","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":"Thu, 03 Oct 2019 19:39:09 -0000"}}]