[{"id":21590,"web_url":"https://patchwork.libcamera.org/comment/21590/","msgid":"<YaqzxMdsvBfgUVCQ@pendragon.ideasonboard.com>","date":"2021-12-04T00:18:12","subject":"Re: [libcamera-devel] [PATCH v2 3/7] libcamera: camera_sensor:\n\tDiscover VCMs through ancillary links","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Daniel,\n\nThank you for the patch.\n\nOn Fri, Dec 03, 2021 at 10:42:26PM +0000, 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> Signed-off-by: Daniel Scally <djrscally@gmail.com>\n> ---\n> Changes in v2:\n> \n> \t- Moved this functionality to CameraSensor::init() instead of the\n> \tpipeline's ::configure() (Laurent)\n> \n>  include/libcamera/internal/camera_sensor.h |  1 +\n>  src/libcamera/camera_sensor.cpp            | 42 ++++++++++++++++++++++\n>  2 files changed, 43 insertions(+)\n> \n> diff --git a/include/libcamera/internal/camera_sensor.h b/include/libcamera/internal/camera_sensor.h\n> index 788c2fa3..d329c512 100644\n> --- a/include/libcamera/internal/camera_sensor.h\n> +++ b/include/libcamera/internal/camera_sensor.h\n> @@ -76,6 +76,7 @@ private:\n>  \tvoid initTestPatternModes(\n>  \t\tconst std::map<int32_t, int32_t> &testPatternModeMap);\n>  \tint initProperties();\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 4c142a58..e1d4d424 100644\n> --- a/src/libcamera/camera_sensor.cpp\n> +++ b/src/libcamera/camera_sensor.cpp\n> @@ -161,6 +161,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 0;\n>  }\n>  \n> @@ -423,6 +427,44 @@ 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> +\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<< \"Error during CameraLens init\";\n\nI'd write \"CameraLens initialization failed\" (although we don't really\nhave rules when it comes to error messages).\n\n> +\t\t\t\treturn ret;\n> +\t\t\t}\n> +\t\t\tbreak;\n\nMissing blank line.\n\n> +\t\tcase MEDIA_ENT_F_FLASH:\n> +\t\t\tLOG(CameraSensor, Warning)\n> +\t\t\t\t<< \"Flash devices not yet supported\";\n> +\t\t\tbreak;\n\nSame here.\n\n> +\t\tdefault:\n> +\t\t\tLOG(CameraSensor, Warning)\n> +\t\t\t\t<< \"Unsupported ancillary entity function\";\n\nIt could be useful to print the function. You could then possibly drop\nthe flash case as it will be caught here.\n\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 DD158BDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tSat,  4 Dec 2021 00:18:41 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4400E60832;\n\tSat,  4 Dec 2021 01:18:41 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 03BC36011A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  4 Dec 2021 01:18:39 +0100 (CET)","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 71A69D89;\n\tSat,  4 Dec 2021 01:18:39 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Z8skKAJI\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638577119;\n\tbh=usqKeBNbQcvmMnMcZaIrJfh/72fOQNV28Q1J1m0Drvo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Z8skKAJIwdyhZ3HmztxI/wJLm7RKn9/XB+Q5QEzJHYYdLLlbEHULffZxiUjPicVLn\n\t6740dcepNqiUx+FjjupYe7rvXIdxfY9UyumYBmjkNaIIpd2hBJCwtV6NT3mZ6MCD5D\n\tMsUMCtDPbk3RDpAulEi9XUFKz4X0AayWBnDJt3bU=","Date":"Sat, 4 Dec 2021 02:18:12 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Daniel Scally <djrscally@gmail.com>","Message-ID":"<YaqzxMdsvBfgUVCQ@pendragon.ideasonboard.com>","References":"<20211203224230.38700-1-djrscally@gmail.com>\n\t<20211203224230.38700-4-djrscally@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211203224230.38700-4-djrscally@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v2 3/7] 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]