[{"id":23699,"web_url":"https://patchwork.libcamera.org/comment/23699/","msgid":"<165662941384.1516045.10617368030654527259@Monstersaurus>","date":"2022-06-30T22:50:13","subject":"Re: [libcamera-devel] [PATCH v3 22/23] libcamera: camera_lens:\n\tExpose libcamera control limits","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Jacopo Mondi via libcamera-devel (2022-06-30 14:39:01)\n> The CameraLens class exposes the list of V4L2 controls through\n> the CameraLens::controls() function.\n> \n> Modify the implementation to expose the newly introduced\n> LensFocusAbsolute control limits.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  include/libcamera/internal/camera_lens.h |  5 +++-\n>  src/libcamera/camera_lens.cpp            | 33 ++++++++++++++++++------\n>  2 files changed, 29 insertions(+), 9 deletions(-)\n> \n> diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h\n> index 277417daffed..ea98379ecc62 100644\n> --- a/include/libcamera/internal/camera_lens.h\n> +++ b/include/libcamera/internal/camera_lens.h\n> @@ -30,7 +30,7 @@ public:\n>  \n>         const std::string &model() const { return model_; }\n>  \n> -       const ControlInfoMap &controls() const;\n> +       const ControlInfoMap &controls() const { return controls_; }\n>  \n>  protected:\n>         std::string logPrefix() const override;\n> @@ -39,11 +39,14 @@ private:\n>         LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraLens)\n>  \n>         int validateLensDriver();\n> +       void updateControls();\n>  \n>         const MediaEntity *entity_;\n>         std::unique_ptr<V4L2Subdevice> subdev_;\n>  \n>         std::string model_;\n> +\n> +       ControlInfoMap controls_;\n>  };\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp\n> index b3d48199ec3b..08c2c42a9cfa 100644\n> --- a/src/libcamera/camera_lens.cpp\n> +++ b/src/libcamera/camera_lens.cpp\n> @@ -9,6 +9,7 @@\n>  \n>  #include <libcamera/base/utils.h>\n>  \n> +#include \"libcamera/internal/control_ids.h\"\n>  #include \"libcamera/internal/v4l2_subdevice.h\"\n>  \n>  /**\n> @@ -73,6 +74,9 @@ int CameraLens::init()\n>                 return ret;\n>  \n>         model_ = subdev_->model();\n> +\n> +       updateControls();\n> +\n>         return 0;\n>  }\n>  \n> @@ -124,6 +128,13 @@ int CameraLens::validateLensDriver()\n>         return ret;\n>  }\n>  \n> +/**\n> + * \\fn CameraLens::controls()\n> + * \\brief Retrieve the CameraLens controls limits\n> + *\n> + * \\return The ControlInfoMap with the CameraLens controls limits\n> + */\n> +\n>  /**\n>   * \\fn CameraLens::model()\n>   * \\brief Retrieve the lens model name\n> @@ -139,15 +150,21 @@ std::string CameraLens::logPrefix() const\n>         return \"'\" + entity_->name() + \"'\";\n>  }\n>  \n> -/**\n> - * \\fn CameraLens::controls()\n> - * \\brief Retrieve the V4L2 controls of the lens' subdev\n> - *\n> - * \\return A map of the V4L2 controls supported by the lens' driver\n> - */\n> -const ControlInfoMap &CameraLens::controls() const\n> +void CameraLens::updateControls()\n>  {\n> -       return subdev_->controls();\n> +       ControlInfoMap::Map controls;\n> +\n> +       /* The lens driver has been validate, the control is there. */\n\n/validate/validated/\n\nThis looks good to me, but has the corresponding functions for setting\nthe control been updated? \n\nNow that we have libcamera controls in here, I expect the IPA can pass a\nsingle ControlList over, and the CameraLens can just extract only the\ncontrols it can handle... I.e. it would only set the LensFocusAbsolute\ncontrol - after having converted it to any VCM specific V4L2 units\nrequired.\n\nBut for this patch so far, I think\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> +       const ControlInfoMap &lensControls = subdev_->controls();\n> +       const ControlInfo &focusAbsolute = lensControls.at(V4L2_CID_FOCUS_ABSOLUTE);\n> +\n> +       controls[&controls::internal::draft::LensFocusAbsolute] =\n> +               ControlInfo(focusAbsolute.min().get<int32_t>(),\n> +                           focusAbsolute.max().get<int32_t>(),\n> +                           focusAbsolute.def().get<int32_t>());\n> +\n> +       controls_ = ControlInfoMap(std::move(controls),\n> +                                  controls::internal::controls);\n>  }\n>  \n>  } /* namespace libcamera */\n> -- \n> 2.36.1\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 2942CBD808\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 30 Jun 2022 22:50:19 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 858E66564E;\n\tFri,  1 Jul 2022 00:50:18 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 21DC860412\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  1 Jul 2022 00:50:17 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A31EA25C;\n\tFri,  1 Jul 2022 00:50:16 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1656629418;\n\tbh=2iivJmxO//MR/jzeC5FNQKwchnpWQNRVl3ZzIGwCNQM=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=HM7CNo16hAbv9Q16woJ6dps7L4WO3gM+9Q2fF3dm1/cS63Y/7lt3OXwacyyTpEYTt\n\trlqJuYdQ0r0OFds5tZpADEimFO70NXz2lt2tX3h3Z66AMsKE5G5/+URHZ83nWR3dIK\n\tstDeikaKQFj3GCTphZp/KCL6qbvtIoY7HUjmG8pdBwhiAJO7IGvRXjd+nIsnzgeKUf\n\tIwyMewSTDCOEFOHeve4FLmwmawjPPiB/68UXkYDWk26+0H/MxLAA/4z/stLUu8xixy\n\tCs3hMgOkgulxGV2bc1hKb8l7cRTBtNn6qw1YVL9H8pSwDmCSsUxvRsD7EYrIPUPJSH\n\tTe7ySl0HLUybQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1656629416;\n\tbh=2iivJmxO//MR/jzeC5FNQKwchnpWQNRVl3ZzIGwCNQM=;\n\th=In-Reply-To:References:Subject:From:To:Date:From;\n\tb=ecefbretNSJMG+0HgRQe+FJ3yJT2aTBbPN0scvqfrn2ejSiQXP2R1byZ9BuSsWRwX\n\tRGgVrAuNESRNHIyXvUtQQC8yCPVr0tCuAk1U30j4kBc3z+DTr1ZsHe7an7GlR2DHqQ\n\tu7Bv3Ygq2Kxdj6fInYIG1BrYEr8Td3eINMtadIQ4="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ecefbret\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220630133902.321099-23-jacopo@jmondi.org>","References":"<20220630133902.321099-1-jacopo@jmondi.org>\n\t<20220630133902.321099-23-jacopo@jmondi.org>","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","Date":"Thu, 30 Jun 2022 23:50:13 +0100","Message-ID":"<165662941384.1516045.10617368030654527259@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v3 22/23] libcamera: camera_lens:\n\tExpose libcamera control limits","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>","From":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]