[{"id":22238,"web_url":"https://patchwork.libcamera.org/comment/22238/","msgid":"<c8e4a066-5a1d-cf1a-b55f-ebe8b6127ff5@ideasonboard.com>","date":"2022-03-09T15:13:19","subject":"Re: [libcamera-devel] [PATCH v5 4/9] libcamera: camera_sensor:\n\tDiscover VCMs through ancillary links","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi !\n\nThanks for the patch !\n\nOn 04/03/2022 00:49, Daniel Scally wrote:\n> Add a function to check for and initialise any VCMs linked to the\n> CameraSensor's entity by ancillary links. This should initialise\n> the lens_ member with the linked entity. Call the new function\n> during CameraSensor::init().\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-off-by: Daniel Scally <djrscally@gmail.com>\n\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n\n> ---\n> Changes in v5:\n> \n> \t- Add a break to the default case\n> \n> Changes in v4:\n> \n> \t- Fixed typo (Laurent)\n> \n> Changes in v3:\n> \n> \t- Fixed some style errors\n> \t- Replaced the flash case by printing the entity function in the\n> \tdefault case.\n> \n>   include/libcamera/internal/camera_sensor.h |  1 +\n>   src/libcamera/camera_sensor.cpp            | 40 ++++++++++++++++++++++\n>   2 files changed, 41 insertions(+)\n> \n> diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\n> index 2fa11567..7fb4eded 100644\n> --- a/include/libcamera/internal/camera_sensor.h\n> +++ b/include/libcamera/internal/camera_sensor.h\n> @@ -81,6 +81,7 @@ private:\n>   \tvoid initTestPatternModes();\n>   \tint initProperties();\n>   \tint applyTestPatternMode(controls::draft::TestPatternModeEnum mode);\n> +\tint discoverAncillaryDevices();\n>   \n>   \tconst MediaEntity *entity_;\n>   \tstd::unique_ptr<V4L2Subdevice> subdev_;\n> diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp\n> index 64f7f12c..8b4406fe 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -172,6 +172,10 @@ int CameraSensor::init()\n>   \tif (ret)\n>   \t\treturn ret;\n>   \n> +\tret = discoverAncillaryDevices();\n> +\tif (ret)\n> +\t\treturn ret;\n> +\n>   \treturn applyTestPatternMode(controls::draft::TestPatternModeEnum::TestPatternModeOff);\n>   }\n>   \n> @@ -443,6 +447,42 @@ int CameraSensor::initProperties()\n>   \treturn 0;\n>   }\n>   \n> +/**\n> + * \\brief Check for and initialise any ancillary devices\n> + *\n> + * Sensors sometimes have ancillary devices such as a Lens or Flash that could\n> + * be linked to their MediaEntity by the kernel. Search for and handle any\n> + * such device.\n> + *\n> + * \\todo Handle MEDIA_ENT_F_FLASH too.\n> + */\n> +int CameraSensor::discoverAncillaryDevices()\n> +{\n> +\tint ret;\n> +\n> +\tfor (MediaEntity *ancillary : entity_->ancillaryEntities()) {\n> +\t\tswitch (ancillary->function()) {\n> +\t\tcase MEDIA_ENT_F_LENS:\n> +\t\t\tfocusLens_ = std::make_unique<CameraLens>(ancillary);\n> +\t\t\tret = focusLens_->init();\n> +\t\t\tif (ret) {\n> +\t\t\t\tLOG(CameraSensor, Error)\n> +\t\t\t\t\t<< \"CameraLens initialisation failed\";\n> +\t\t\t\treturn ret;\n> +\t\t\t}\n> +\t\t\tbreak;\n> +\n> +\t\tdefault:\n> +\t\t\tLOG(CameraSensor, Warning)\n> +\t\t\t\t<< \"Unsupported ancillary entity function \"\n> +\t\t\t\t<< ancillary->function();\n> +\t\t\tbreak;\n> +\t\t}\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> +\n>   /**\n>    * \\fn CameraSensor::model()\n>    * \\brief Retrieve the sensor model name","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 4B869BE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  9 Mar 2022 15:13:24 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E5C5C6118D;\n\tWed,  9 Mar 2022 16:13:23 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D05960475\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Mar 2022 16:13:22 +0100 (CET)","from [IPV6:2a01:e0a:169:7140:3734:287e:1a7f:9772] (unknown\n\t[IPv6:2a01:e0a:169:7140:3734:287e:1a7f:9772])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 189848C4;\n\tWed,  9 Mar 2022 16:13:22 +0100 (CET)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1646838803;\n\tbh=5BInOQKEvjQwV6LuhrO5ULT9MDvD9A8fX9tCiSu18rU=;\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:\n\tFrom;\n\tb=CxoR0BwVFBvfkRjI1a6nbUPOsDXYvAK8N5IEmVvBzWChRUPHq7MjnGwWXgSIX1mZM\n\t8GcZNPApYRGwic7Vbv0RZ6sazoCakabwOtHuzs0zLojqRBzlRH7SbY1g2fZtxRi881\n\tmlJ6KAqqEI5wYFMrFuxbALQRMPta5Ul81IVjYJi3T/OZApsXspb9rLbfE7OjYx4jss\n\ttY8DTacorCwM1ko74EtAiraj/IYajRia4OiKTGwlAEH8bq//6lxEL8dmOjYVP1NIUS\n\tkUfwRO6bRg7sLm2qH+Fm2WYPRaaROXQE4rpsoYLbqsupGUt+yu7gkHo/kQXr6VN5m3\n\t0tPe2SUUb3phw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1646838802;\n\tbh=5BInOQKEvjQwV6LuhrO5ULT9MDvD9A8fX9tCiSu18rU=;\n\th=Date:Subject:To:References:From:In-Reply-To:From;\n\tb=JDUlEkTINhH0Mu7pUaAt2DaW6Rqw7NoRa1oLR0exiT6AnV8wKLl7ykSteIvvr9sdn\n\tQc6aiARd5O/oFiYL+YAb0tvH1ndfWKxCGt2m24IcnZvXsL7v4emClD4858fJ21ZNCj\n\tDoER/TUPwcKYIMp2lmN87NR+M7CO/ZPEelLav+As="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"JDUlEkTI\"; dkim-atps=neutral","Message-ID":"<c8e4a066-5a1d-cf1a-b55f-ebe8b6127ff5@ideasonboard.com>","Date":"Wed, 9 Mar 2022 16:13:19 +0100","MIME-Version":"1.0","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101\n\tThunderbird/91.5.0","Content-Language":"en-US","To":"Daniel Scally <djrscally@gmail.com>, libcamera-devel@lists.libcamera.org","References":"<20220303234956.1463551-1-djrscally@gmail.com>\n\t<20220303234956.1463551-5-djrscally@gmail.com>","In-Reply-To":"<20220303234956.1463551-5-djrscally@gmail.com>","Content-Type":"text/plain; charset=UTF-8; format=flowed","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v5 4/9] libcamera: camera_sensor:\n\tDiscover VCMs through ancillary links","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]