[{"id":23367,"web_url":"https://patchwork.libcamera.org/comment/23367/","msgid":"<YqG+o4ffjeUVqtq8@pendragon.ideasonboard.com>","date":"2022-06-09T09:34:27","subject":"Re: [libcamera-devel] [RFC PATCH 3/4] libcamera: lens: Add a helper\n\tto get the fixed range lens values","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Jun 09, 2022 at 08:03:05AM +0200, Jean-Michel Hautbois via libcamera-devel wrote:\n> When the focus algorithm runs, it can be asked to go to a specific\n> position, through the controls::LensPosition control. Those controls\n> need specific values to be known, in particular the minimum and maximum\n> value the driver can set to the lens to make it move to a given\n> position.\n> \n> Add a new helper on the camera lens side to get this range or a default\n> nulled structure if it is not available. This particular value needs to\n> be taken into account by the caller and it shall use the minimum and\n> maximum reported by the driver.\n> \n> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n> ---\n>  include/libcamera/internal/camera_lens.h      |  1 +\n>  .../internal/camera_lens_properties.h         |  2 ++\n>  src/libcamera/camera_lens.cpp                 | 19 +++++++++++++++++++\n>  src/libcamera/camera_lens_properties.cpp      |  9 ++++++++-\n>  4 files changed, 30 insertions(+), 1 deletion(-)\n> \n> diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h\n> index 523a1481..f6daff01 100644\n> --- a/include/libcamera/internal/camera_lens.h\n> +++ b/include/libcamera/internal/camera_lens.h\n> @@ -29,6 +29,7 @@ public:\n>  \n>  \tint init();\n>  \tint setFocusPosition(int32_t position);\n> +\tconst Size &getLensRange();\n>  \n>  \tconst std::string &model() const { return model_; }\n>  \n> diff --git a/include/libcamera/internal/camera_lens_properties.h b/include/libcamera/internal/camera_lens_properties.h\n> index 73982550..7424b375 100644\n> --- a/include/libcamera/internal/camera_lens_properties.h\n> +++ b/include/libcamera/internal/camera_lens_properties.h\n> @@ -17,6 +17,8 @@ namespace libcamera {\n>  \n>  struct CameraLensProperties {\n>  \tstatic const CameraLensProperties *get(const std::string &lens);\n> +\n> +\tSize lensFocusRange;\n>  };\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp\n> index d4d44bc7..abec5a27 100644\n> --- a/src/libcamera/camera_lens.cpp\n> +++ b/src/libcamera/camera_lens.cpp\n> @@ -79,6 +79,25 @@ int CameraLens::init()\n>  \treturn 0;\n>  }\n>  \n> +/**\n> + * \\brief Retrieve the lens position range\n> + * \\return The minimum and maximum positions for the given lens or a default\n> + * nulled Size reference\n> + *\n> + * If a lens has no static properties associated, a special value is returned,\n> + * where the minimum and maximum are set to 0. The caller may then chose the\n> + * ones returned by the V4L2_CID_FOCUS_ABSOLUTE call.\n> + */\n> +const Size &CameraLens::getLensRange()\n> +{\n> +\tstatic const Size defaultLensFocusRange = { 0, 0 };\n> +\tif (!staticProps_ || staticProps_->lensFocusRange.isNull())\n> +\t\treturn defaultLensFocusRange;\n> +\n> +\treturn staticProps_->lensFocusRange;\n> +}\n> +\n> +\n>  /**\n>   * \\brief This function sets the focal point of the lens to a specific position.\n>   * \\param[in] position The focal point of the lens\n> diff --git a/src/libcamera/camera_lens_properties.cpp b/src/libcamera/camera_lens_properties.cpp\n> index dee73b43..225546ae 100644\n> --- a/src/libcamera/camera_lens_properties.cpp\n> +++ b/src/libcamera/camera_lens_properties.cpp\n> @@ -32,6 +32,9 @@ LOG_DEFINE_CATEGORY(CameraLensProperties)\n>  /**\n>   * \\struct CameraLensProperties\n>   * \\brief Database of camera lens properties\n> + *\n> + * \\var CameraLensProperties::lensFocusRange\n> + * \\brief The limits for the sensor position, stored as a min and a max.\n>   */\n>  \n>  /**\n> @@ -42,7 +45,11 @@ LOG_DEFINE_CATEGORY(CameraLensProperties)\n>   */\n>  const CameraLensProperties *CameraLensProperties::get(const std::string &lens)\n>  {\n> -\tstatic const std::map<std::string, const CameraLensProperties> lensProps = {};\n> +\tstatic const std::map<std::string, const CameraLensProperties> lensProps = {\n> +\t\t{ \"dw9714\", {\n> +\t\t\t\t.lensFocusRange = { 150, 800 },\n> +\t\t} },\n> +\t};\n\nThis partly answers the question I asked in a reply to the cover letter.\n\nWhat makes you think the lens focus range is an intrinsic property of\nthe VCM driver ?\n\n>  \n>  \tconst auto it = lensProps.find(lens);\n>  \tif (it == lensProps.end()) {","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 B1A6EBD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jun 2022 09:34:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6FDEE65635;\n\tThu,  9 Jun 2022 11:34:34 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F45261FB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jun 2022 11:34:33 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CFB5C6CF;\n\tThu,  9 Jun 2022 11:34:32 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654767274;\n\tbh=dcodra+oexXyXNgHI+CVKpKLC/fw/5LFJjopTEttIDk=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=amAeqHZ7y1MWq9Eec8AQBpP0WivAR58bZ4y9fO8TmB9BBxR4ViziPf9GDAAId+hq9\n\tQOQxAjC1rOv3ne9ca53Uz8b8NL0H6+n+MtsMAgarxSmRuavDex5rfM875Z9vZgxhUF\n\t4Qca77316/2Ot+rvK94WB1l4rPXyuj7vnAqXd3TwbvJFsv6937j2QUNcLQqqTXZkxg\n\tLTkNJy7F8zBgrTsCMVmtE/DjwNd8oXxLCC91AGLcXcd3L+gGJvlc2bHa5kpESx/13h\n\taPB4zHCV4ivgk0CZYYIFoz4kwfTAx4r7odLEg+TKGfIXl9bLImRI6hjoVc3SkRQS1t\n\t61AmocV9ZQXEQ==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654767273;\n\tbh=dcodra+oexXyXNgHI+CVKpKLC/fw/5LFJjopTEttIDk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=bO9vn2D9WFQCfiRSBLb4nNLdojjJfV9MBn3ZYVO6oLiRTgA0Fvrr5axjEFSEacuU9\n\tHr2g51jCVyBP/r5B4OIbaphzqHnf/lOCSXb8teSBLycnXxHP/FaKFhyXis4dEWHBaz\n\t56mJnGAl6mP0EdB8y4z5SlHs0FWMjK/ny9i6ahQc="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"bO9vn2D9\"; dkim-atps=neutral","Date":"Thu, 9 Jun 2022 12:34:27 +0300","To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<YqG+o4ffjeUVqtq8@pendragon.ideasonboard.com>","References":"<20220609060306.57953-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20220609060306.57953-4-jeanmichel.hautbois@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220609060306.57953-4-jeanmichel.hautbois@ideasonboard.com>","Subject":"Re: [libcamera-devel] [RFC PATCH 3/4] libcamera: lens: Add a helper\n\tto get the fixed range lens values","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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23368,"web_url":"https://patchwork.libcamera.org/comment/23368/","msgid":"<4471e841-1217-041f-59c5-f3f22e478690@ideasonboard.com>","date":"2022-06-09T09:40:32","subject":"Re: [libcamera-devel] [RFC PATCH 3/4] libcamera: lens: Add a helper\n\tto get the fixed range lens values","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 09/06/2022 11:34, Laurent Pinchart wrote:\n> On Thu, Jun 09, 2022 at 08:03:05AM +0200, Jean-Michel Hautbois via libcamera-devel wrote:\n>> When the focus algorithm runs, it can be asked to go to a specific\n>> position, through the controls::LensPosition control. Those controls\n>> need specific values to be known, in particular the minimum and maximum\n>> value the driver can set to the lens to make it move to a given\n>> position.\n>>\n>> Add a new helper on the camera lens side to get this range or a default\n>> nulled structure if it is not available. This particular value needs to\n>> be taken into account by the caller and it shall use the minimum and\n>> maximum reported by the driver.\n>>\n>> Signed-off-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n>> ---\n>>   include/libcamera/internal/camera_lens.h      |  1 +\n>>   .../internal/camera_lens_properties.h         |  2 ++\n>>   src/libcamera/camera_lens.cpp                 | 19 +++++++++++++++++++\n>>   src/libcamera/camera_lens_properties.cpp      |  9 ++++++++-\n>>   4 files changed, 30 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/include/libcamera/internal/camera_lens.h b/include/libcamera/internal/camera_lens.h\n>> index 523a1481..f6daff01 100644\n>> --- a/include/libcamera/internal/camera_lens.h\n>> +++ b/include/libcamera/internal/camera_lens.h\n>> @@ -29,6 +29,7 @@ public:\n>>   \n>>   \tint init();\n>>   \tint setFocusPosition(int32_t position);\n>> +\tconst Size &getLensRange();\n>>   \n>>   \tconst std::string &model() const { return model_; }\n>>   \n>> diff --git a/include/libcamera/internal/camera_lens_properties.h b/include/libcamera/internal/camera_lens_properties.h\n>> index 73982550..7424b375 100644\n>> --- a/include/libcamera/internal/camera_lens_properties.h\n>> +++ b/include/libcamera/internal/camera_lens_properties.h\n>> @@ -17,6 +17,8 @@ namespace libcamera {\n>>   \n>>   struct CameraLensProperties {\n>>   \tstatic const CameraLensProperties *get(const std::string &lens);\n>> +\n>> +\tSize lensFocusRange;\n>>   };\n>>   \n>>   } /* namespace libcamera */\n>> diff --git a/src/libcamera/camera_lens.cpp b/src/libcamera/camera_lens.cpp\n>> index d4d44bc7..abec5a27 100644\n>> --- a/src/libcamera/camera_lens.cpp\n>> +++ b/src/libcamera/camera_lens.cpp\n>> @@ -79,6 +79,25 @@ int CameraLens::init()\n>>   \treturn 0;\n>>   }\n>>   \n>> +/**\n>> + * \\brief Retrieve the lens position range\n>> + * \\return The minimum and maximum positions for the given lens or a default\n>> + * nulled Size reference\n>> + *\n>> + * If a lens has no static properties associated, a special value is returned,\n>> + * where the minimum and maximum are set to 0. The caller may then chose the\n>> + * ones returned by the V4L2_CID_FOCUS_ABSOLUTE call.\n>> + */\n>> +const Size &CameraLens::getLensRange()\n>> +{\n>> +\tstatic const Size defaultLensFocusRange = { 0, 0 };\n>> +\tif (!staticProps_ || staticProps_->lensFocusRange.isNull())\n>> +\t\treturn defaultLensFocusRange;\n>> +\n>> +\treturn staticProps_->lensFocusRange;\n>> +}\n>> +\n>> +\n>>   /**\n>>    * \\brief This function sets the focal point of the lens to a specific position.\n>>    * \\param[in] position The focal point of the lens\n>> diff --git a/src/libcamera/camera_lens_properties.cpp b/src/libcamera/camera_lens_properties.cpp\n>> index dee73b43..225546ae 100644\n>> --- a/src/libcamera/camera_lens_properties.cpp\n>> +++ b/src/libcamera/camera_lens_properties.cpp\n>> @@ -32,6 +32,9 @@ LOG_DEFINE_CATEGORY(CameraLensProperties)\n>>   /**\n>>    * \\struct CameraLensProperties\n>>    * \\brief Database of camera lens properties\n>> + *\n>> + * \\var CameraLensProperties::lensFocusRange\n>> + * \\brief The limits for the sensor position, stored as a min and a max.\n>>    */\n>>   \n>>   /**\n>> @@ -42,7 +45,11 @@ LOG_DEFINE_CATEGORY(CameraLensProperties)\n>>    */\n>>   const CameraLensProperties *CameraLensProperties::get(const std::string &lens)\n>>   {\n>> -\tstatic const std::map<std::string, const CameraLensProperties> lensProps = {};\n>> +\tstatic const std::map<std::string, const CameraLensProperties> lensProps = {\n>> +\t\t{ \"dw9714\", {\n>> +\t\t\t\t.lensFocusRange = { 150, 800 },\n>> +\t\t} },\n>> +\t};\n> \n> This partly answers the question I asked in a reply to the cover letter.\n> \n> What makes you think the lens focus range is an intrinsic property of\n> the VCM driver ?\n\nI am not sure of this indeed, probably it will be a couple lens/sensor \nmodel... And what else do we have than the vcm driver ?\nI don't have any tune files as example from \"real life\" so I don't \nreally know what is usually done, any insight will be appreciated ;-).\n\nThanks,\nJM\n\n> \n>>   \n>>   \tconst auto it = lensProps.find(lens);\n>>   \tif (it == lensProps.end()) {\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 14C79BD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jun 2022 09:40:38 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5BE3465633;\n\tThu,  9 Jun 2022 11:40:37 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C90A461FB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jun 2022 11:40:35 +0200 (CEST)","from [IPV6:2a01:e0a:169:7140:ae94:9dc3:50ea:aee6] (unknown\n\t[IPv6:2a01:e0a:169:7140:ae94:9dc3:50ea:aee6])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 3EAA1741;\n\tThu,  9 Jun 2022 11:40:35 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1654767637;\n\tbh=fDqtSArslHWTBzZt41or+kCcs32riied+j9ssDZ4d3E=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=W9oVUIueV9d4ca+o9LoH9v8xci6mevH+uIqhoOL6miVd9DHecbJDuu96FPM4oPS3l\n\tcQM65eNbYg+Dnnbl4HfGxtaafs1Tu0zccGtPj7GdI/2xDFEYTPZMOGlQ+XJyaUjlTW\n\tT6gqnopaevJlnK0qkkh0Kn79C4TiFk/HdzCl45cVYkFSj0TsTQ9L1d2UhxTma4aXO6\n\tXjz7w0qu/vIgwnKV28sAxW7g0P99JO196o9927eDGuu6VU/qEIun7yTbbRy6GoBWts\n\tnZDPRFv0vi94H3BMy5HalIpq0qQrw0GgnKuj480HokRU12Zb6ZJG95SBmaBVTSaq89\n\tnW1Wn5CNWzZAA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1654767635;\n\tbh=fDqtSArslHWTBzZt41or+kCcs32riied+j9ssDZ4d3E=;\n\th=Date:Subject:To:Cc:References:From:In-Reply-To:From;\n\tb=P6VV3mRJaPozlYpPqI3sxBF8P8ePVEeCsal75xZ41vVA+X40rVA/YH9HHxsrXewMo\n\tEyX5mM0D3mm/t4jWmW6qhZdRpEqXVQbp9Zv0qB/rq/kN+9ukFrv/mo7nQ5cYZ4Jszs\n\tt2ZZ+FECCrl2L37yLhCIZ0M9jPwpN1vE+zt6ejZo="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"P6VV3mRJ\"; dkim-atps=neutral","Message-ID":"<4471e841-1217-041f-59c5-f3f22e478690@ideasonboard.com>","Date":"Thu, 9 Jun 2022 11:40:32 +0200","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.9.1","Content-Language":"en-US","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20220609060306.57953-1-jeanmichel.hautbois@ideasonboard.com>\n\t<20220609060306.57953-4-jeanmichel.hautbois@ideasonboard.com>\n\t<YqG+o4ffjeUVqtq8@pendragon.ideasonboard.com>","In-Reply-To":"<YqG+o4ffjeUVqtq8@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [RFC PATCH 3/4] libcamera: lens: Add a helper\n\tto get the fixed range lens values","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":"Jean-Michel Hautbois via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]