[{"id":22114,"web_url":"https://patchwork.libcamera.org/comment/22114/","msgid":"<Yfsfk6W5sZjeBMjT@pendragon.ideasonboard.com>","date":"2022-02-03T00:19:31","subject":"Re: [libcamera-devel] [PATCH v4 4/9] 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 Dan,\n\nThank you for the patch.\n\nOn Mon, Jan 31, 2022 at 10:33:25PM +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> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-off-by: Daniel Scally <djrscally@gmail.com>\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            | 39 ++++++++++++++++++++++\n>  2 files changed, 40 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..f00c0aca 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,41 @@ 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\nA break would be good here too, even if not strictly required.\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 85281BF415\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  3 Feb 2022 00:19:57 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 47EDF60C4B;\n\tThu,  3 Feb 2022 01:19:57 +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 EB34D609C3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Feb 2022 01:19:55 +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 79EF949C;\n\tThu,  3 Feb 2022 01:19:55 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"Iu3kamvD\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1643847595;\n\tbh=wCK20iYelY9OceCHd7CpNFnU7dcgZR+SPUMU6bze2fo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Iu3kamvD3l7Y896UMnLqVeJncx9O0ysWn/6dqbZo1URH8Zj/mXCjnyYWwsd3jv5CY\n\tYM/hcZX7DVoU6Br4bquad80NUpt+tlaJp7yYfVc5mmwhcFH4CMOhA2HlXFiDlQUsu7\n\taoELQaVXYxCRKsJWANclxjAct/lHnmqrCoWIpqCk=","Date":"Thu, 3 Feb 2022 02:19:31 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Daniel Scally <djrscally@gmail.com>","Message-ID":"<Yfsfk6W5sZjeBMjT@pendragon.ideasonboard.com>","References":"<20220131223330.61563-1-djrscally@gmail.com>\n\t<20220131223330.61563-5-djrscally@gmail.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220131223330.61563-5-djrscally@gmail.com>","Subject":"Re: [libcamera-devel] [PATCH v4 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":22122,"web_url":"https://patchwork.libcamera.org/comment/22122/","msgid":"<0c8df65f-23cc-8247-70ab-7fec3ca4bd50@gmail.com>","date":"2022-02-03T09:40:43","subject":"Re: [libcamera-devel] [PATCH v4 4/9] libcamera: camera_sensor:\n\tDiscover VCMs through ancillary links","submitter":{"id":90,"url":"https://patchwork.libcamera.org/api/people/90/","name":"Daniel Scally","email":"djrscally@gmail.com"},"content":"Morning Laurent\n\nOn 03/02/2022 00:19, Laurent Pinchart wrote:\n> Hi Dan,\n>\n> Thank you for the patch.\n>\n> On Mon, Jan 31, 2022 at 10:33:25PM +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>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>> Signed-off-by: Daniel Scally <djrscally@gmail.com>\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            | 39 ++++++++++++++++++++++\n>>  2 files changed, 40 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..f00c0aca 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,41 @@ 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> A break would be good here too, even if not strictly required.\n\n\nOkedokey - I'll add it in v5. Thanks for the comments on the other\npatches also :)\n\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 0179ABDCBF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  3 Feb 2022 09:40:48 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 403E4609E1;\n\tThu,  3 Feb 2022 10:40:47 +0100 (CET)","from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com\n\t[IPv6:2a00:1450:4864:20::32d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 48B1F6020B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  3 Feb 2022 10:40:45 +0100 (CET)","by mail-wm1-x32d.google.com with SMTP id\n\to30-20020a05600c511e00b0034f4c3186f4so6685359wms.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 03 Feb 2022 01:40:45 -0800 (PST)","from [192.168.0.14]\n\t(cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net. [86.13.91.161])\n\tby smtp.gmail.com with ESMTPSA id\n\t14sm24377030wrz.100.2022.02.03.01.40.43\n\t(version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);\n\tThu, 03 Feb 2022 01:40:44 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"gH1e1EsY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;\n\th=message-id:date:mime-version:user-agent:subject:content-language:to\n\t:cc:references:from:in-reply-to:content-transfer-encoding;\n\tbh=V8hGVOZklCxR6ED3/1XTdi8PwMO6hw9ZqLQM3TaiO1w=;\n\tb=gH1e1EsYSFDJk39dnuFLKE4j9p+OLbGk3i4NqocKA/XBmCo2ikbVZFc9Ssaw2515sN\n\t7qWZ4GuWEJktpCWRo4ErcHtnGo/noTBV6VvIVPxIk4rr9PeGwQb2D5gktL/J++gRXO11\n\tJ7yD+mXKNESBieh+0VNWTQ+icvFizmafGojOJFqUWOPuGX4OhOw0KUhIz4Hz1njzKXmN\n\tUCaDnaSAtLzeAOhKRnzi0o8mokZoGoxE1h9DpLvdzBA5uNa+Le07ynyK0BTlwy95cBwD\n\ttwkTK/Q5RO0piUxlDMWU+eBBod02gTFh2xbjqPrRVQTphF30ZR+1V5XCwgm5YW5yo5hU\n\tOkNg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:message-id:date:mime-version:user-agent:subject\n\t:content-language:to:cc:references:from:in-reply-to\n\t:content-transfer-encoding;\n\tbh=V8hGVOZklCxR6ED3/1XTdi8PwMO6hw9ZqLQM3TaiO1w=;\n\tb=uXw1HIoTJRG5x2FSmpb7QMtPO1Ry3OD+n1zTsek3hYBFQ4wRBv/dSMEWZtU87YAvbv\n\tiNBakjeTGbsI66kk8K04vArEJfqUbQ4Q64szYzVNOh5MdHAlW1tvLGxuktQz1TM+3LcB\n\tdUjVHeoiS4g4EY/3UhdRc+JLrUjM5KlNhP85+ieWQSWVkskMZd+1tDwgp/hcN1NLcbXe\n\t0cSNDVAN4CvxVZ1MEWXj/znhqI8QX509F6AMFvgDQlXif2N5qqX6LumFKzTUI4XhTV7O\n\tPhQIOD72kZ926ltaEYF5hx7HbNhxY6akWMx5cJj6YMuz6t7TgPDhwOeLcHpFwCT+kA/v\n\tg8Cw==","X-Gm-Message-State":"AOAM533EYWxwdJmCnK0TKSrRKOAcTIgVJF2ud7WCnrkAZ9wyXpRfAzaL\n\tmjS6HcvWg+mRZPlH5SNYT+dP9rrUEzySvA==","X-Google-Smtp-Source":"ABdhPJyfxwySfL9gM5XevN8G2cRk2Un+rx9qfch09Z1RGVhkmUoxViT8ud65RR3N2oLzF9q7eh75zQ==","X-Received":"by 2002:a05:600c:2251:: with SMTP id\n\ta17mr9729798wmm.102.1643881244726; \n\tThu, 03 Feb 2022 01:40:44 -0800 (PST)","Message-ID":"<0c8df65f-23cc-8247-70ab-7fec3ca4bd50@gmail.com>","Date":"Thu, 3 Feb 2022 09:40:43 +0000","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":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20220131223330.61563-1-djrscally@gmail.com>\n\t<20220131223330.61563-5-djrscally@gmail.com>\n\t<Yfsfk6W5sZjeBMjT@pendragon.ideasonboard.com>","From":"Daniel Scally <djrscally@gmail.com>","In-Reply-To":"<Yfsfk6W5sZjeBMjT@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v4 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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]